| findLoc | R Documentation |
Finds all locations of a known character substring inside a character string.
findLoc(
subchain,
chain,
outlist = FALSE,
named = FALSE,
all. = FALSE,
which = min,
ignore.case = TRUE,
perl = FALSE,
fixed = FALSE,
useBytes = FALSE
)
subchain |
character, length 1, e.g. a peptide sequence |
chain |
(named) character, length 1 or a (named) list of such characters such as a list of protein chains obtained from a fasta file |
outlist |
logical. Default, FALSE, the output is a (named) integer vector of locations. Otherwise, it is a (named) list of location vectors, each corresponding to a chain in a list of chains |
named |
logical. Default, FALSE. Output is not named. Otherwise, the output is named |
all. |
logical, default FALSE, returns the leftmost or the rightmost location inside the chain. When TRUE, returns all locations inside the chain for each chain in a list |
which |
symbol. Location to report. Default, min. Requires |
ignore.case, perl, fixed, useBytes |
arguments to base::gregexpr |
Wrapper to base::gregexpr, the function scans all chains in a list of chains to find subchain locations. The location is defined as the position inside the chain relative to the left end of the chain of the first subchain character.
A (named) integer or a (named) list of integer vectors of subchain locations inside the chain.
gregexpr
if (interactive()) {
# 1. List of chains
chain = list(chain1 = 'alpdxoipoyloiekladxoipoylyl',
chain2 = 'kdxoipoylyydxoipoylopldxoipoylac')
subchain = 'DXOIPOYL' # ignoring the case
findLoc(subchain, chain, outlist = TRUE, named = TRUE, all. = TRUE) # named list
findLoc(subchain, chain, named = TRUE, all. = TRUE) # named integer
findLoc(subchain, chain, outlist = TRUE, named = TRUE) # the leftmost positions
findLoc(subchain, chain, which = max, named = TRUE) # the rightmost positions
# 2. Single chain
chain = chain[[1]]
findLoc(subchain, chain, all. = TRUE)
findLoc(subchain, chain, which = max)
findLoc(subchain, chain) # default location
findLoc(subchain, chain, which = max, ignore.case = FALSE) # not ignoring the case
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.