public class AlphabetContainer extends Object implements Storable, InstantiableFromParameterSet, Comparable<AlphabetContainer>
Alphabets used in a Sequence,
DataSet, AbstractTrainableStatisticalModel or ... . The container
enables the user to have a different Alphabet at each position or at
least not the same Alphabet at all positions. This is impossible if
you use only instances of Alphabet. The container maps the given
Alphabet objects to the positions.
AlphabetContainer is immutable.Alphabet| Modifier and Type | Class and Description |
|---|---|
static class |
AlphabetContainer.AbstractAlphabetContainerParameterSet<T extends AlphabetContainer>
This class is the super class of any
InstanceParameterSet for AlphabetContainer. |
static class |
AlphabetContainer.AlphabetContainerType
This
enum defines types of AlphabetContainers. |
| Modifier and Type | Field and Description |
|---|---|
protected AlphabetContainer.AbstractAlphabetContainerParameterSet<?> |
parameters
The parameters for this instance.
|
| Constructor and Description |
|---|
AlphabetContainer(Alphabet... abc)
Creates a new
AlphabetContainer with different Alphabets
for each position. |
AlphabetContainer(Alphabet abc)
Creates a new simple
AlphabetContainer. |
AlphabetContainer(Alphabet[] abc,
int[] assignment)
Creates a new
AlphabetContainer that uses different
Alphabets. |
AlphabetContainer(AlphabetContainer[] cons,
int[] lengths)
Creates an new sparse
AlphabetContainer based on given
AlphabetContainers. |
AlphabetContainer(AlphabetContainerParameterSet parameters)
Creates a new
AlphabetContainer from an
AlphabetContainerParameterSet that contains all necessary
parameters. |
AlphabetContainer(StringBuffer xml)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkConsistency(AlphabetContainer abc)
Checks if this
AlphabetContainer is consistent consistent with
another AlphabetContainer. |
int |
compareTo(AlphabetContainer abc) |
Alphabet |
getAlphabetAt(int pos)
Returns the underlying
Alphabet of position pos. |
int |
getAlphabetIndexForPosition(int pos)
This method returns the index of the
Alphabet that is used for the given position. |
double |
getAlphabetLengthAt(int pos)
Returns the length of the underlying
Alphabet of position
pos. |
double |
getCode(int pos,
String sym)
|
AlphabetContainer |
getCompositeContainer(int[] start,
int[] length)
Returns an
AlphabetContainer of Alphabets e.g. |
AlphabetContainer.AbstractAlphabetContainerParameterSet<? extends AlphabetContainer> |
getCurrentParameterSet()
Returns the
InstanceParameterSet that has been used to
instantiate the current instance of the implementing class. |
String |
getDelim()
Returns the delimiter that should be used (for writing e.g.
|
int[] |
getIndexForAlphabets()
|
double |
getMaximalAlphabetLength()
Returns the maximal
Alphabet length of this
AlphabetContainer. |
double |
getMin(int pos)
Returns the minimal value of the underlying
Alphabet of position
pos. |
double |
getMinimalAlphabetLength()
Returns the minimal
Alphabet length of this
AlphabetContainer. |
int |
getNumberOfAlphabets()
This method returns the number of
Alphabets used in the current AlphabetContainer. |
int |
getPossibleLength()
Returns the possible length for
Sequences using this
AlphabetContainer. |
static AlphabetContainer |
getSimplifiedAlphabetContainer(Alphabet[] abc,
int[] assignment)
This method creates a new
AlphabetContainer that uses as less as
possible Alphabets to describe the container. |
AlphabetContainer |
getSubContainer(int start,
int length)
Returns a sub-container with the
Alphabets for the positions
starting at start and with length length. |
String |
getSymbol(int pos,
double val)
Returns a
String representation of the encoded symbol
val of the Alphabet of position pos of
this AlphabetContainer. |
AlphabetContainer.AlphabetContainerType |
getType()
Returns the type of this
AlphabetContainer. |
boolean |
ignoresCase()
Indicates if all used
Alphabets ignore the case. |
static AlphabetContainer |
insertAlphabet(AlphabetContainer aC,
Alphabet a,
boolean[] useNewAlphabet)
This method may be used to construct a new
AlphabetContainer by
incorporating additional Alphabets into an existing
AlphabetContainer. |
boolean |
isDiscrete()
Indicates if all positions use discrete
Alphabets. |
boolean |
isDiscreteAt(int pos)
Indicates if position
pos is a discrete random variable,
i.e. |
boolean |
isEncodedSymbol(int pos,
double continuous)
|
boolean |
isReverseComplementable()
This method helps to determine if the
AlphabetContainer also
computes the reverse complement of a Sequence. |
boolean |
isSimple()
Indicates whether all random variables are defined over the same range,
i.e.
|
int |
toDiscrete(int pos,
double val)
|
String |
toString() |
StringBuffer |
toXML()
This method returns an XML representation as
StringBuffer of an
instance of the implementing class. |
protected AlphabetContainer.AbstractAlphabetContainerParameterSet<?> parameters
public AlphabetContainer(Alphabet abc)
AlphabetContainer. All positions use the
same Alphabet and therefore sequences of arbitrary length can be
handled.abc - the Alphabet for all positionspublic AlphabetContainer(Alphabet... abc)
AlphabetContainer with different Alphabets
for each position. The assignment of the Alphabets to the
positions is given by the order in the Alphabet array. This
constructor should only be used if all Alphabets are pairwise
different.abc - the different Alphabets for each positionAlphabetContainer(Alphabet[], int[])public AlphabetContainer(AlphabetContainer[] cons, int[] lengths) throws IllegalArgumentException
AlphabetContainer based on given
AlphabetContainers.cons - the given AlphabetContainerslengths - the corresponding lengths of each AlphabetContainer
that is usedIllegalArgumentException - if the given length for an AlphabetContainer is not
possiblepublic AlphabetContainer(Alphabet[] abc, int[] assignment) throws IllegalArgumentException
AlphabetContainer that uses different
Alphabets. The Alphabets can be used more than once. The
assignment for the Alphabets to the positions is given by the
array assignment.abc - the Alphabetsassignment - the assignment arrayIllegalArgumentException - if the assignment of the Alphabets to the positions
is not correctpublic AlphabetContainer(AlphabetContainerParameterSet parameters) throws IllegalArgumentException, DoubleSymbolException, ParameterSetParser.NotInstantiableException
AlphabetContainer from an
AlphabetContainerParameterSet that contains all necessary
parameters.parameters - the parameter setIllegalArgumentException - if something is wrong with the parameters in the
AlphabetContainerParameterSetDoubleSymbolException - if the definitions within parameters contains a
symbol twiceParameterSetParser.NotInstantiableException - if an instance could not be createdpublic AlphabetContainer(StringBuffer xml) throws NonParsableException
Storable.
Creates a new AlphabetContainer out of its XML representation.xml - the XML representation as StringBufferNonParsableException - if the AlphabetContainer could not be reconstructed
out of the XML representation (the StringBuffer could
not be parsed)Storablepublic static AlphabetContainer getSimplifiedAlphabetContainer(Alphabet[] abc, int[] assignment)
AlphabetContainer that uses as less as
possible Alphabets to describe the container. So, if possible,
Alphabets will be reused.abc - the Alphabetsassignment - the assignment of the Alphabets to the positionsAlphabetContainer that uses as less as possible
AlphabetsAlphabetContainer(Alphabet[], int[])public static AlphabetContainer insertAlphabet(AlphabetContainer aC, Alphabet a, boolean[] useNewAlphabet) throws IllegalArgumentException
AlphabetContainer by
incorporating additional Alphabets into an existing
AlphabetContainer.aC - the AlphabetContainer used as template for the
returned AlphabetContainera - the Alphabet that should be inserteduseNewAlphabet - an array to define, which Alphabets are used for which
positions Sequences the returned AlphabetContainer is
capable to handle
false forces to use the
Alphabet given by the given AlphabetContainer
true forces to use the
given Alphabet
Alphabet must be
understood as defining new additional positions for which the
given Alphabet should be used. For example: let the
given AlphabetContainer contain three Alphabet
s A0,A1,A2 (Ai for position
i) and therefore have a possible length of three.
Calling this method using this AlphabetContainer, an
additional Alphabet A3 and an assignment
array of [false, true,
true, false, false]
returns a new AlphabetContainer having a possible
length of five and using the following alphabets for those
positions: A0,A3,A3,A1,A2. If the given
AlphabetContainer has a possible length not equal
zero, then the assignment array must contain as many
false-values as the length of the given
AlphabetContainer.AlphabetContainer as described aboveIllegalArgumentException - if useNewAlphabet is null or has
length 0AlphabetContainer(Alphabet[], int[])public boolean checkConsistency(AlphabetContainer abc)
AlphabetContainer is consistent consistent with
another AlphabetContainer.abc - the second AlphabetContainertrue if the AlphabetContainers are
consistent, false otherwiseComparable.compareTo(Object)public int compareTo(AlphabetContainer abc)
compareTo in interface Comparable<AlphabetContainer>public Alphabet getAlphabetAt(int pos)
Alphabet of position pos.
Please note that the Alphabet is returned as reference, so take
care of what you are doing with it!pos - the positionAlphabet of the given positionpublic double getAlphabetLengthAt(int pos)
Alphabet of position
pos.pos - the positionAlphabet of position
pospublic double getCode(int pos,
String sym)
throws WrongAlphabetException
pos - the position of the Alphabetsym - the symbol that should be returned encodedWrongAlphabetException - if the symbol is not defined in the Alphabet of the
given positiongetAlphabetAt(int)public AlphabetContainer getCompositeContainer(int[] start, int[] length)
AlphabetContainer of Alphabets e.g. for
composite motifs/sequences.start - the array of start indiceslength - the array of lengthsAlphabetContainergetSubContainer(int, int)public AlphabetContainer.AbstractAlphabetContainerParameterSet<? extends AlphabetContainer> 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 InstantiableFromParameterSetInstanceParameterSetException - if the InstanceParameterSet could not be returnedpublic String getDelim()
public double getMaximalAlphabetLength()
Alphabet length of this
AlphabetContainer.Alphabet lengthpublic double getMin(int pos)
Alphabet of position
pos.pos - the given positionAlphabet of the given positionAlphabet.getMin()public double getMinimalAlphabetLength()
Alphabet length of this
AlphabetContainer.Alphabet length of this
AlphabetContainerpublic int getPossibleLength()
Sequences using this
AlphabetContainer. If 0 (zero) is returned, all lengths are
possible.AlphabetContainerpublic AlphabetContainer getSubContainer(int start, int length)
Alphabets for the positions
starting at start and with length length. The
method can be used for subsequences, ... .start - the index of the start positionlength - the lengthAlphabetsgetCompositeContainer(int[], int[])public String getSymbol(int pos, double val)
String representation of the encoded symbol
val of the Alphabet of position pos of
this AlphabetContainer.public final boolean ignoresCase()
Alphabets ignore the case.true if all used alphabets ignore the case,
false otherwisepublic final boolean isDiscrete()
Alphabets.true if all positions use discrete Alphabets,
otherwise falsepublic boolean isDiscreteAt(int pos)
pos is a discrete random variable,
i.e. if the Alphabet of position pos is discrete.pos - the positiontrue if position pos is a discrete
random variable, false otherwisepublic boolean isEncodedSymbol(int pos,
double continuous)
pos - the positioncontinuous - the continuous valuetrue if continuous is a symbol of the
Alphabet used in position pos,
false otherwisepublic final boolean isSimple()
AlphabetContainer is simple and all positions use the
same (fixed) Alphabet.AlphabetContainer is simplepublic final boolean isReverseComplementable()
AlphabetContainer also
computes the reverse complement of a Sequence.true if the AlphabetContainer also computes
the reverse complement of a Sequence, false
otherwisepublic int toDiscrete(int pos,
double val)
pos - the positionval - the valueval of the Alphabet
of position posisDiscreteAt(int)public StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.public final AlphabetContainer.AlphabetContainerType getType()
AlphabetContainer.AlphabetContainer.AlphabetContainerTypepublic int getAlphabetIndexForPosition(int pos)
Alphabet that is used for the given position.pos - the positionAlphabetpublic int getNumberOfAlphabets()
Alphabets used in the current AlphabetContainer.Alphabets