|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.data.AlphabetContainer
public class AlphabetContainer
The container for Alphabet
s 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
Nested Class Summary | |
---|---|
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 AlphabetContainer s. |
Field Summary | |
---|---|
protected AlphabetContainer.AbstractAlphabetContainerParameterSet<?> |
parameters
The parameters for this instance. |
Constructor Summary | |
---|---|
AlphabetContainer(Alphabet... abc)
Creates a new AlphabetContainer with different Alphabet s
for each position. |
|
AlphabetContainer(Alphabet abc)
Creates a new simple AlphabetContainer . |
|
AlphabetContainer(Alphabet[] abc,
int[] assignment)
Creates a new AlphabetContainer that uses different
Alphabet s. |
|
AlphabetContainer(AlphabetContainer[] cons,
int[] lengths)
Creates an new sparse AlphabetContainer based on given
AlphabetContainer s. |
|
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 . |
Method Summary | |
---|---|
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)
Returns the encoded symbol for sym of the Alphabet
of position pos of this AlphabetContainer . |
AlphabetContainer |
getCompositeContainer(int[] start,
int[] length)
Returns an AlphabetContainer of Alphabet s e.g. for
composite motifs/sequences. |
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. a sequence). |
int[] |
getIndexForAlphabets()
This method returns an object that is used for assigning the positions of the Sequence s to specific Alphabet s. |
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 Alphabet s used in the current AlphabetContainer . |
int |
getPossibleLength()
Returns the possible length for Sequence s using this
AlphabetContainer . |
static AlphabetContainer |
getSimplifiedAlphabetContainer(Alphabet[] abc,
int[] assignment)
This method creates a new AlphabetContainer that uses as less as
possible Alphabet s to describe the container. |
AlphabetContainer |
getSubContainer(int start,
int length)
Returns a sub-container with the Alphabet s 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 Alphabet s 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 Alphabet s into an existing
AlphabetContainer . |
boolean |
isDiscrete()
Indicates if all positions use discrete Alphabet s. |
boolean |
isDiscreteAt(int pos)
Indicates if position pos is a discrete random variable,
i.e. if the Alphabet of position pos is discrete. |
boolean |
isEncodedSymbol(int pos,
double continuous)
Indicates if continuous is a symbol of the Alphabet
used at position pos of the AlphabetContainer . |
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. if the AlphabetContainer is simple and all positions use the
same (fixed) Alphabet . |
int |
toDiscrete(int pos,
double val)
Returns the discrete value for val of the Alphabet
of position pos in the AlphabetContainer . |
String |
toString()
|
StringBuffer |
toXML()
This method returns an XML representation as StringBuffer of an
instance of the implementing class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected AlphabetContainer.AbstractAlphabetContainerParameterSet<?> parameters
Constructor Detail |
---|
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 Alphabet
s
for each position. The assignment of the Alphabet
s to the
positions is given by the order in the Alphabet
array. This
constructor should only be used if all Alphabet
s are pairwise
different.
abc
- the different Alphabet
s for each positionAlphabetContainer(Alphabet[], int[])
public AlphabetContainer(AlphabetContainer[] cons, int[] lengths) throws IllegalArgumentException
AlphabetContainer
based on given
AlphabetContainer
s.
cons
- the given AlphabetContainer
slengths
- the corresponding lengths of each AlphabetContainer
that is used
IllegalArgumentException
- if the given length for an AlphabetContainer
is not
possiblepublic AlphabetContainer(Alphabet[] abc, int[] assignment) throws IllegalArgumentException
AlphabetContainer
that uses different
Alphabet
s. The Alphabet
s can be used more than once. The
assignment for the Alphabet
s to the positions is given by the
array assignment
.
abc
- the Alphabet
sassignment
- the assignment array
IllegalArgumentException
- if the assignment of the Alphabet
s 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 set
IllegalArgumentException
- if something is wrong with the parameters in the
AlphabetContainerParameterSet
DoubleSymbolException
- if the definitions within parameters
contains a
symbol twice
ParameterSetParser.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 StringBuffer
NonParsableException
- if the AlphabetContainer
could not be reconstructed
out of the XML representation (the StringBuffer
could
not be parsed)Storable
Method Detail |
---|
public static AlphabetContainer getSimplifiedAlphabetContainer(Alphabet[] abc, int[] assignment)
AlphabetContainer
that uses as less as
possible Alphabet
s to describe the container. So, if possible,
Alphabet
s will be reused.
abc
- the Alphabet
sassignment
- the assignment of the Alphabet
s to the positions
AlphabetContainer
that uses as less as possible
Alphabet
sAlphabetContainer(Alphabet[], int[])
public static AlphabetContainer insertAlphabet(AlphabetContainer aC, Alphabet a, boolean[] useNewAlphabet) throws IllegalArgumentException
AlphabetContainer
by
incorporating additional Alphabet
s into an existing
AlphabetContainer
.
aC
- the AlphabetContainer
used as template for the
returned AlphabetContainer
a
- the Alphabet
that should be inserteduseNewAlphabet
- an array to define, which Alphabet
s are used for which
positions Sequence
s 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 above
IllegalArgumentException
- 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 AlphabetContainer
true
if the AlphabetContainer
s 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 position
Alphabet
of the given positionpublic double getAlphabetLengthAt(int pos)
Alphabet
of position
pos
.
pos
- the position
Alphabet
of position
pos
public double getCode(int pos, String sym) throws WrongAlphabetException
sym
of the Alphabet
of position pos
of this AlphabetContainer
.
pos
- the position of the Alphabet
sym
- the symbol that should be returned encoded
WrongAlphabetException
- if the symbol is not defined in the Alphabet
of the
given positiongetAlphabetAt(int)
public AlphabetContainer getCompositeContainer(int[] start, int[] length)
AlphabetContainer
of Alphabet
s e.g. for
composite motifs/sequences.
start
- the array of start indiceslength
- the array of lengths
AlphabetContainer
getSubContainer(int, int)
public AlphabetContainer.AbstractAlphabetContainerParameterSet<? extends AlphabetContainer> getCurrentParameterSet() throws Exception
InstantiableFromParameterSet
InstanceParameterSet
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 InstantiableFromParameterSet
InstanceParameterSet
Exception
- 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 position
Alphabet
of the given positionAlphabet.getMin()
public double getMinimalAlphabetLength()
Alphabet
length of this
AlphabetContainer
.
Alphabet
length of this
AlphabetContainer
public int getPossibleLength()
Sequence
s using this
AlphabetContainer
. If 0 (zero) is returned, all lengths are
possible.
AlphabetContainer
public AlphabetContainer getSubContainer(int start, int length)
Alphabet
s 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 length
Alphabet
sgetCompositeContainer(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
.
pos
- the position of the Alphabet
val
- the value of the encoded symbol
String
representation for the encoded symbol
val
of the Alphabet
of position
pos
public final boolean ignoresCase()
Alphabet
s ignore the case.
true
if all used alphabets ignore the case,
false
otherwisepublic final boolean isDiscrete()
Alphabet
s.
true
if all positions use discrete Alphabet
s,
otherwise false
public boolean isDiscreteAt(int pos)
pos
is a discrete random variable,
i.e. if the Alphabet
of position pos
is discrete.
pos
- the position
true
if position pos
is a discrete
random variable, false
otherwisepublic boolean isEncodedSymbol(int pos, double continuous)
continuous
is a symbol of the Alphabet
used at position pos
of the AlphabetContainer
.
pos
- the positioncontinuous
- the continuous value
true
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)
val
of the Alphabet
of position pos
in the AlphabetContainer
.
pos
- the positionval
- the value
val
of the Alphabet
of position pos
isDiscreteAt(int)
public String toString()
toString
in class Object
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
toXML
in interface Storable
public final AlphabetContainer.AlphabetContainerType getType()
AlphabetContainer
.
AlphabetContainer.AlphabetContainerType
public int getAlphabetIndexForPosition(int pos)
Alphabet
that is used for the given position.
pos
- the position
Alphabet
public int getNumberOfAlphabets()
Alphabet
s used in the current AlphabetContainer
.
Alphabet
spublic int[] getIndexForAlphabets()
Sequence
s to specific Alphabet
s.
null
or an int array
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |