public class SeqContentPattern extends Object implements BioPattern
Regular expressions can be used to find sequence patterns. However, some things can't be easily expressed as a regular expression. For example, a region of length 10 that contains at least 8 Gs and up to two Ts and no other symbols. A SeqContentPattern can be built that does represent this.
SeqContentPattern scp = new SeqContentPattern(DNATools.getDNA());
scp.setLength(10);
scp.setMinCounts(DNATools.g(), 8);
scp.setMaxCounts(DNATools.t(), 2);
scp.setMaxCounts(DNATools.c(), 0);
scp.setMaxCounts(DNATools.a(), 0);
The minimum counts default to 0, and the maximum counts default to the length. If you have not manually set the maximum count for a symbol, it will continue to adjust while you change the length. Once you have set it, it will not vary, even if you do set the length. To re-set a maximum count to track the length, set it to -1.
All regions of the defined length for which all constraints are satisfied will potentialy be found. At the moment we have not defined what will happen for multiple regions that overlap all of which satisfy the constraints.
Constructor and Description |
---|
SeqContentPattern(FiniteAlphabet alpha)
Create a new SeqContentPattern over an alphabet.
|
Modifier and Type | Method and Description |
---|---|
int |
getLength()
Get the current length.
|
int |
getMaxCounts(AtomicSymbol as)
Get the maximum counts required for a symbol.
|
int |
getMinCounts(AtomicSymbol as)
Get the minimum counts required for a symbol.
|
BioMatcher |
matcher(SymbolList symList)
Get a matcher that will use these parameters to search a SymbolList.
|
void |
setLength(int length)
Set the pattern length.
|
void |
setMaxCounts(AtomicSymbol as,
int count)
Set the maximum counts required for a symbol.
|
void |
setMinCounts(AtomicSymbol as,
int count)
Set the minimum counts required for a symbol.
|
public SeqContentPattern(FiniteAlphabet alpha)
alpha
- the FiniteAlphabet for this patternpublic int getLength()
public void setLength(int length)
length
- the new lengthpublic void setMinCounts(AtomicSymbol as, int count) throws IllegalSymbolException
as
- the AtomicSymbol to checkcount
- the minimum number of counts it must haveIllegalSymbolException
- if as is not known in this alphabetpublic int getMinCounts(AtomicSymbol as) throws IllegalSymbolException
as
- the AtomicSymbol to checkIllegalSymbolException
- if as is not known in this alphabetpublic void setMaxCounts(AtomicSymbol as, int count) throws IllegalSymbolException
as
- the AtomicSymbol to checkcount
- the maximum number of counts it must haveIllegalSymbolException
- if as is not known in this alphabetpublic int getMaxCounts(AtomicSymbol as) throws IllegalSymbolException
as
- the AtomicSymbol to checkIllegalSymbolException
- if as is not known in this alphabetpublic BioMatcher matcher(SymbolList symList) throws IllegalAlphabetException
BioPattern
The resulting BioMatcher is independant of this BioPattern. In particular, calling any mutator methods on this pattern will not affect the matcher.
matcher
in interface BioPattern
symList
- the SymbolList to match againstIllegalAlphabetException
- if symList is not over the right alphabetCopyright © 2014 BioJava. All rights reserved.