Split sequences

seq_split_pattern(x, pattern)

Arguments

x

a DNA, RNA or AA vector.

pattern

a DNA, RNA or AA vectors (but same as x) or a character vector of regular expressions, or a list. See section Patterns.

Value

A list of vectors of same class as x.

Patterns

It is important to understand how patterns are treated in bioseq.

Patterns are recycled along the sequences (usually the x argument). This means that if a pattern (vector or list) is of length > 1, it will be replicated until it is the same length as x. The reverse is not true and a vector of patterns longer than a vector of sequences will raise a warning.

Patterns can be DNA, RNA or AA vectors (but they must be from the same class as the sequences they are matched against). If patterns are DNA, RNA or AA vectors, they are disambiguated prior to matching. For example pattern dna("ARG") will match AAG or AGG.

Alternatively, patterns can be a simple character vector containing regular expressions.

Vectors of patterns (DNA, RNA, AA or regex) can also be provided in a list. In that case, each vector of the list will be collapsed prior matching, which means that each vector element will be used as an alternative pattern. For example pattern list(c("AAA", "CCC"), "GG") will match AAA or CCC in the first sequence, GG in the second sequence, AAA or CCC in the third, and so on following the recycling rule.

@section Fuzzy matching: When max_error is greater than zero, the function perform fuzzy matching. Fuzzy matching does not support regular expression.

See also

Examples


x <- dna(a = "ACGTTAGTGTAGCCGT", b = "CTCGAAATGA")
seq_split_pattern(x, dna("AAA"))
#> $a
#> DNA vector of 1 sequences
#> >   ACGTTAGTGTAGCCGT
#> 
#> $b
#> DNA vector of 2 sequences
#> >   CTCG
#> >   TGA
#> 
seq_split_pattern(x, "T.G")
#> $a
#> DNA vector of 3 sequences
#> >   ACGT
#> >   TG
#> >   CCGT
#> 
#> $b
#> DNA vector of 2 sequences
#> >   C
#> >   AAATGA
#>