| findPalindromes {Biostrings} | R Documentation |
The findPalindromes function finds palindromic substrings in a subject
string. The palindromes that can be searched for are either strict palindromes
or 2-arm palindromes (the former being a particular case of the latter).
With a DNAString or RNAString subject, they can also be
antipalindromes i.e. the 2 arms are reverse-complementary sequences.
findPalindromes(subject, min.armlength=4, max.ngaps=1, anti=NULL) palindromeArmLength(x, anti=NULL, ...) palindromeLeftArm(x, anti=NULL, ...) palindromeRightArm(x, anti=NULL, ...)
subject |
A BString (or derived) object containing the subject string, or a BStringViews object. |
min.armlength |
An integer giving the minimum length of the arms of the palindromes (or antipalindromes) to search for. |
max.ngaps |
An integer giving the maximum length of the sequence separating the
2 arms of the palindromes (or antipalindromes) to search for.
Note that by default (max.ngaps=1), findPalindromes will
search for strict palindromes (or antipalindromes) only.
|
anti |
Either NULL, TRUE or FALSE.
Values anti=TRUE or anti=FALSE can only be used with
a DNAString or RNAString subject to specify wether or not
the substrings to search for must be antipalindromes.
By default (anti=NULL), antipalindromes are searched for.
|
x |
A BString (or derived) object containing a 2-arm palindrome or antipalindrome, or a BStringViews object containing a set of 2-arm palindromes or antipalindromes. |
... |
Additional arguments to be passed to or from methods. |
findPalindromes returns a BStringViews object containing all
palindromes (or antipalindromes) found in subject (one view per
palindromic substring found).
palindromeArmLength returns the arm length (integer) of the 2-arm
palindrome or antipalindrome x.
It will raise an error if x has no arms. Note that any sequence could
be considered a 2-arm palindrome if we were OK with arms of length 0 but we
are not: x must have arms of length greater or equal to 1 in order to
be considered a 2-arm palindrome. The same apply to 2-arm antipalindromes.
When applied to a BStringViews object x,
palindromeArmLength behaves in a vectorized fashion by returning an
integer vector of the same length as x.
palindromeLeftArm returns an object of the same class as the original
object x and containing the left arm of x.
palindromeRightArm does the same as palindromeLeftArm but on
the right arm of x.
Like palindromeArmLength, both palindromeLeftArm and
palindromeRightArm will raise an error if x has no arms.
Also, when applied to a BStringViews object x, both behave
in a vectorized fashion by returning a BStringViews object of the
same length as x.
H. Pages
matchPattern,
matchLRPatterns,
matchProbePair,
mask,
BStringViews-class,
DNAString-class
## Note that palindromes can be nested
findPalindromes(DNAString("ACGTTNAACGT-ACGTTNAACGT"))
## A real use case
library(BSgenome.Dmelanogaster.FlyBase.r51)
chrX <- Dmelanogaster[["X"]]
noN_chrX <- mask(chrX, "N")
chrX_pals <- findPalindromes(noN_chrX, min.armlength=50, max.ngaps=20)
palindromeArmLength(chrX_pals) # 251
## Of course, whitespaces matter
palindromeArmLength(BString("was it a car or a cat I saw"))
## Note that the 2 arms of a strict palindrome (or antipalindrome) are equal
## to the full sequence.
palindromeLeftArm(BString("Delia saw I was aileD"))
palindromeLeftArm(DNAString("N-ACGTT-AACGT-N"))
palindromeLeftArm(DNAString("N-AAA-N-N-TTT-N"), anti=FALSE)