words.pos {seqinr} | R Documentation

## Positions of possibly degenerated motifs within sequences

### Description

`word.pos` searches all the occurences of the motif `pattern` within the sequence `text` and returns their positions. This function is based on `regexp` allowing thus for complex motif searches.

### Usage

    words.pos(pattern, text, extended = TRUE, perl = FALSE)

### Arguments

`pattern` | character string containing a regular expression to be matched in the given character vector.
`text` | a character vector where matches are sought.
`extended` | if `TRUE', extended regular expression matching is used, and if `FALSE' basic regular expressions are used.
`perl` | logical. Should perl-compatible regexps be used if available? Has priority over `extended'

### Details

The regular expressions used are those specified by POSIX 1003.2, either extended or basic, depending on the value of the `extended' argument, unless `perl = TRUE' when they are those of PCRE, ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/.
`perl=TRUE' will only be available if R was compiled against PCRE: this is detected at configure time. All Unix and Windows system should have it.

### Value

a vector of positions for which the motif `pattern` was found in the sequence `text`.

### Author(s)

J.R. Lobry

### References

`citation("seqinr")`

### See Also

`regexpr`

### Examples

    myseq <- "tatagaga"
    words.pos("t", myseq)   # Should be 1 3
    words.pos("tag", myseq) # Should be 3
    words.pos("ga", myseq)  # Should be 5 7
    # How to specify ambiguous base ? Look for YpR motifs by
    words.pos("[ct][ag]", myseq) # Should be 1 3

[Package seqinr version 1.0-4 Index]