|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.data.AlphabetContainer
public class AlphabetContainer
The container for some alphabets used in a sequence, sample, model or ... .
The container enables the user to have at each position a different alphabet
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.AlphabetContainerType
Possible types of AlphabetContainers are discrete alphabets,
continuous alphabets, or alphabets mixed of discrete and continuous
symbols at different positions. |
| Constructor Summary | |
|---|---|
AlphabetContainer(Alphabet abc)
This constructor creates a simple AlphabetContainer. |
|
AlphabetContainer(Alphabet[] abc)
This constructor creates an AlphabetContainer with different
alphabets for each position. |
|
AlphabetContainer(Alphabet[] abc,
int[] assignment)
This constructor creates an AlphabetContainer that uses different
alphabets. |
|
AlphabetContainer(AlphabetContainer[] cons,
int[] lengths)
This constructor 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)
Extracts the AlphabetContainerParameterSet from a
StringBuffer. |
|
| Method Summary | |
|---|---|
boolean |
checkConsistency(AlphabetContainer abc)
Checks whether two alphabets are consistent. |
int |
compareTo(AlphabetContainer abc)
|
Alphabet |
getAlphabetAt(int pos)
Returns the underlying alphabet of position pos. |
double |
getAlphabetLengthAt(int pos)
Returns the length of the underlying alphabet of position pos. |
double |
getCode(int pos,
String sym)
Returns the encoded symbol sym for position pos
. |
AlphabetContainer |
getCompositeContainer(int[] start,
int[] length)
This method returns a container of alphabets e.g. for composite motifs/sequences. |
AlphabetContainerParameterSet |
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). |
double |
getMaximalAlphabetLength()
Returns the maximal alphabet length of this container. |
double |
getMin(int pos)
Returns the minimal value of the underlying alphabet of position pos. |
double |
getMinimalAlphabetLength()
Returns the minimal alphabet length of this container. |
int |
getPossibleLength()
Returns the possible length for sequences using this container. |
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)
This method returns a subcontainer for the positions starting at start and with length length. |
String |
getSymbol(int pos,
double val)
This method returns a String representation of val. |
AlphabetContainer.AlphabetContainerType |
getType()
Returns the type of this AlphabetContainer. |
boolean |
ignoresCase()
If this method returns true 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()
If this method returns true all positions use discrete
values. |
boolean |
isDiscreteAt(int pos)
Returns true if position pos is a discrete
random variable. |
boolean |
isEncodedSymbol(int pos,
double continuous)
Returns true if continuous is a symbol of the
alphabet used in position pos. |
boolean |
isReverseComplementable()
This method helps to determine if the AlphabetContainer also
computes the reverse complement of a sequence. |
boolean |
isSimple()
This method answers the question whether all random variables are defined over the same range, i.e. all positions use the same (fixed) alphabet. |
int |
toDiscrete(int pos,
double val)
Returns the discrete value for val at a position
pos. |
String |
toString()
|
StringBuffer |
toXML()
This method returns an XML-representation of an instance of the implementing class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AlphabetContainer(Alphabet abc)
AlphabetContainer. All
positions use the same alphabet and therefore sequences of arbitrary
length can be handled.
abc - the alphabetpublic AlphabetContainer(Alphabet[] abc)
AlphabetContainer with different
alphabets for each position. The assignment from 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 alphabetsAlphabetContainer(Alphabet[], int[])
public AlphabetContainer(AlphabetContainer[] cons,
int[] lengths)
throws IllegalArgumentException
AlphabetContainer based on
given AlphabetContainers.
cons - the AlphabetContainerslengths - the corresponding lengths of each AlphabetContainer
that is used
IllegalArgumentException - if the given length for an AlphabetContainer is not
possible
public 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 assignment-array.
abc - the alphabetsassignment - the assignment-array
IllegalArgumentException - if the assignment from the alphabets to the positions is not
correct
public AlphabetContainer(AlphabetContainerParameterSet parameters)
throws IllegalArgumentException,
DoubleSymbolException,
ParameterSetParser.NotInstantiableException
AlphabetContainer from an
AlphabetContainerParameterSet that contains all necessary
parameters.
parameters - the parameters
IllegalArgumentException - is thrown if the AlphabetContainerParameterSet is not
cloneable
DoubleSymbolException - is thrown if the definitions within parameters
contains a symbol twice
ParameterSetParser.NotInstantiableException - if an instance could not be created
public AlphabetContainer(StringBuffer xml)
throws NonParsableException
AlphabetContainerParameterSet from a
StringBuffer.
xml - the XML stream
NonParsableException - if the stream is not parsable| Method Detail |
|---|
public 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 positions
AlphabetContainer that uses as less as possible
alphabets
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 - this Alphabet should be inserteduseNewAlphabet - This array is used 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
AlphabetContainer contain three alphabets A0,A1,A2 (Ai
for position i) and 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 position:
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 0public boolean checkConsistency(AlphabetContainer abc)
abc - the second alphabet
public int compareTo(AlphabetContainer abc)
compareTo in interface Comparable<AlphabetContainer>public Alphabet getAlphabetAt(int pos)
pos. Please note
that the alphabet is returned as reference, so take care of what you are
doing with it!
pos - the position
public double getAlphabetLengthAt(int pos)
pos.
pos - the position
pos
public double getCode(int pos,
String sym)
throws WrongAlphabetException
sym for position pos
.
pos - the positionsym - the symbol
WrongAlphabetException - if the symbol is not defined in the alphabet
public AlphabetContainer getCompositeContainer(int[] start,
int[] length)
start - the array of start indiceslength - the array of lengths
getSubContainer(int, int)
public AlphabetContainerParameterSet 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 a InstanceParameterSet, an equivalent
InstanceParameterSet should be returned, such that an instance created using this
InstanceParameterSet would be in principle equal to the current instance.
getCurrentParameterSet in interface InstantiableFromParameterSetInstanceParameterSet
Exception - is thrown if the InstanceParameterSet could not be returnedpublic String getDelim()
public double getMaximalAlphabetLength()
public double getMin(int pos)
pos.
pos - the position
public double getMinimalAlphabetLength()
public int getPossibleLength()
public AlphabetContainer getSubContainer(int start,
int length)
start and with length length. The method can be
used for subsequences, ... .
start - the index of the start positionlength - the length
getCompositeContainer(int[], int[])
public String getSymbol(int pos,
double val)
String representation of val.
pos - the positionval - the value
String representation for val at position
pospublic final boolean ignoresCase()
true all used alphabets ignore the
case.
true if all used alphabets ignore the casepublic final boolean isDiscrete()
true all positions use discrete
values.
true if all positions use discrete valuespublic boolean isDiscreteAt(int pos)
true if position pos is a discrete
random variable.
pos - the position
true if position pos is a discrete
random variable
public boolean isEncodedSymbol(int pos,
double continuous)
true if continuous is a symbol of the
alphabet used in position pos.
pos - the positioncontinuous - the continuous value
true if continuous is a symbol of the
alphabet used in position pospublic final boolean isSimple()
public final boolean isReverseComplementable()
AlphabetContainer also
computes the reverse complement of a sequence.
true if the AlphabetContainer also computes
the reverse complement of a sequence
public int toDiscrete(int pos,
double val)
val at a position
pos.
pos - the positionval - the value
val at position
pospublic String toString()
toString in class Objectpublic StringBuffer toXML()
Storable
toXML in interface Storablepublic final AlphabetContainer.AlphabetContainerType getType()
AlphabetContainer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||