public class DiscreteAlphabet extends Alphabet
Strings. For DNA
alphabets, the class DNAAlphabet should be used.| Modifier and Type | Class and Description |
|---|---|
static class |
DiscreteAlphabet.DiscreteAlphabetParameterSet
Class for the
ParameterSet of a
DiscreteAlphabet. |
Alphabet.AlphabetParameterSet<T extends Alphabet>| Modifier and Type | Field and Description |
|---|---|
protected String[] |
alphabet
The alphabet as
String array. |
protected boolean |
caseInsensitive
Switch to decide whether the input should be treated case sensitive or insensitive.
|
protected Alphabet.AlphabetParameterSet |
parameters
The parameter set describing this
DiscreteAlphabet . |
| Constructor and Description |
|---|
DiscreteAlphabet(boolean caseInsensitive,
String... alphabet)
Creates a new
DiscreteAlphabet from a given alphabet as a
String array. |
DiscreteAlphabet(DiscreteAlphabet.DiscreteAlphabetParameterSet parameters)
The constructor for the
InstantiableFromParameterSet
interface. |
DiscreteAlphabet(int min,
int max)
Creates a new
DiscreteAlphabet from a minimal and a maximal
value, i.e. |
DiscreteAlphabet(StringBuffer representation)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Alphabet b) |
int |
getCode(String symbol)
Returns the code of a given symbol.
|
Alphabet.AlphabetParameterSet |
getCurrentParameterSet()
Returns the
InstanceParameterSet that has been used to
instantiate the current instance of the implementing class. |
int |
getMaximalSymbolLength()
Returns the length of the longest "symbol" in the alphabet.
|
double |
getMin()
Returns the minimal value of the
Alphabet. |
String |
getSymbolAt(int i)
Returns the symbol at position
i in the alphabet. |
boolean |
ignoresCase()
Indicates if the alphabet ignores the case.
|
boolean |
isEncodedSymbol(int candidate)
Indicates if
candidate is an element of the internal
interval. |
boolean |
isSymbol(String candidat)
Tests if a given symbol is contained in the alphabet.
|
double |
length()
Returns the number of symbols in the calling alphabet.
|
String |
toString() |
StringBuffer |
toXML()
This method returns an XML representation as
StringBuffer of an
instance of the implementing class. |
checkConsistencyprotected boolean caseInsensitive
protected Alphabet.AlphabetParameterSet parameters
DiscreteAlphabet .public DiscreteAlphabet(StringBuffer representation) throws NonParsableException
Storable.
Creates a new DiscreteAlphabet out of its XML representation.representation - the XML representation as StringBufferNonParsableException - if the DiscreteAlphabet could not be reconstructed
out of the XML representation (the StringBuffer
representation could not be parsed)Storablepublic DiscreteAlphabet(DiscreteAlphabet.DiscreteAlphabetParameterSet parameters) throws IllegalArgumentException, DoubleSymbolException
InstantiableFromParameterSet
interface. Creates a new DiscreteAlphabet from a given set of
parameters.parameters - the parameter set for the DiscreteAlphabetIllegalArgumentException - if space or tab will be used as symbolsDoubleSymbolException - if one of the symbols occurred more than onceInstantiableFromParameterSetpublic DiscreteAlphabet(int min,
int max)
throws IllegalArgumentException
DiscreteAlphabet from a minimal and a maximal
value, i.e. in [min,max].min - the minimal value (inclusive)max - the maximal value (inclusive)IllegalArgumentException - if min > maxpublic DiscreteAlphabet(boolean caseInsensitive,
String... alphabet)
throws DoubleSymbolException,
IllegalArgumentException
DiscreteAlphabet from a given alphabet as a
String array. This String array is cloned internally.alphabet - the alphabet as String arraycaseInsensitive - indicates if there will be no difference between lowercase and
uppercase letters/symbols in the alphabet (no case sensitivity)DoubleSymbolException - if one of the symbols occurred more than onceIllegalArgumentException - if one of the symbols is either empty or a white-space
characterpublic Alphabet.AlphabetParameterSet getCurrentParameterSet() throws Exception
InstantiableFromParameterSetInstanceParameterSet that has been used to
instantiate the current instance of the implementing class. If the
current instance was not created using an InstanceParameterSet,
an equivalent InstanceParameterSet should be returned, so that an
instance created using this InstanceParameterSet would be in
principle equal to the current instance.getCurrentParameterSet in interface InstantiableFromParameterSetgetCurrentParameterSet in class AlphabetInstanceParameterSetException - if the InstanceParameterSet could not be returnedpublic StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.public int compareTo(Alphabet b)
public int getCode(String symbol) throws WrongAlphabetException
symbol - the given symbolWrongAlphabetException - if the symbol is not defined in the alphabetpublic final int getMaximalSymbolLength()
public double getMin()
AlphabetAlphabet.public final String getSymbolAt(int i)
i in the alphabet.i - the position in the alphabetipublic final boolean ignoresCase()
true if the alphabet ignores the case,
false otherwisepublic final boolean isEncodedSymbol(int candidate)
candidate is an element of the internal
interval.candidate - the value to be testedtrue if candidate is an element of the
internal interval, false otherwisepublic final boolean isSymbol(String candidat)
candidat - the candidat symboltrue if the candidat is a symbol of the
alphabet, false otherwisepublic final double length()