|
||||||||||
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 position. This is impossible if you use
only instances of Alphabet. The container maps the given Alphabet objects to the positions.
AlphabetContainer is immutable.
Alphabet
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 AlphabetContainer from the StringBuffer. |
Method Summary | |
---|---|
boolean |
checkConsistency(AlphabetContainer abc)
Checks whether to 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 ParameterSet 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 min 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 used 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 repsresentation of val |
boolean |
hasEveryWhereSameAlphabetSize()
Returns true if all used alphabets have the same alphabet size, otherwise false . |
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 exsisting AlphabetContainer . |
boolean |
isDiscrete()
If this method returns true all postions 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 AlphabectContainer also to compute the reverse complement of a sequence. |
boolean |
isSimple()
This method answers the question whether all random variable are defined over the same range, i.e. all positions use the same (fixed) alphabet. |
int |
toDiscrete(int pos,
double val)
|
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)
abc
- the alphabetpublic AlphabetContainer(Alphabet[] abc)
abc
- the alphabetsAlphabetContainer(Alphabet[], int[])
public AlphabetContainer(AlphabetContainer[] cons, int[] lengths) throws IllegalArgumentException
cons
- the AlphabetContainerslengths
- the corresponding lengths each AlphabetContainer is used
IllegalArgumentException
- if the given length for an AlphabetContainer is not possiblepublic AlphabetContainer(Alphabet[] abc, int[] assignment) throws IllegalArgumentException
abc
- the alphabetsassignment
- the assignment array
IllegalArgumentException
- if the assignment from 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 parameters
IllegalArgumentException
- is thrown if the AlphabetContainerParameterSet
is not cloneable
DoubleSymbolException
- is thrown if the definitions within parameters
contains a doublette symbol
ParameterSetParser.NotInstantiableException
public AlphabetContainer(StringBuffer xml) throws NonParsableException
xml
- the XML stream
NonParsableException
- if the stream is not parsableMethod Detail |
---|
public static AlphabetContainer getSimplifiedAlphabetContainer(Alphabet[] abc, int[] assignment)
abc
- the alphabetsassignment
- the assigment of the alphabets to the positions
public static AlphabetContainer insertAlphabet(AlphabetContainer aC, Alphabet a, boolean[] useNewAlphabet) throws IllegalArgumentException
AlphabetContainer
by incorporating additional alphabets
into an exsisting AlphabetContainer
.
aC
- the AlphabetContainer used as template for the returned AlphabetContainera
- this Alphabet should be inserteduseNewAlphabet
- This array is used to define, which Alphabet
s are used for which positions. Sequence
the returned
AlphabetContainer
is capable to handle
false
forces to use the alphabet given by the given
AlphabetContainer
true
forces to used the given Alphabet
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.
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
public double getCode(int pos, String sym) throws WrongAlphabetException
sym
for position pos
.
pos
- the positionsym
- the symbol
WrongAlphabetException
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
InstantiableFromParameterSet
ParameterSet
that has been used to instantiate the current instance of the implementing
class. If the current instance was not created using a ParameterSet
, an equivalent
ParameterSet
should be returned, such that an instance created using this
ParameterSet
would be in principle equal to the current instance.
getCurrentParameterSet
in interface InstantiableFromParameterSet
ParameterSet
Exception
- is thrown if the ParameterSet
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)
val
pos
- the positionval
- the value
val
at position pos
public final boolean hasEveryWhereSameAlphabetSize()
true
if all used alphabets have the same alphabet size, otherwise false
.
I.e. it returns getMaximalAlphabetLength() == getMinimalAlphabetLength()
true
if all used alphabets have the same alphabet sizegetMaximalAlphabetLength()
,
getMinimalAlphabetLength()
public final boolean ignoresCase()
true
all used alphabets ignore the case.
true
if all used alphabets ignore the casepublic final boolean isDiscrete()
true
all postions use discrete values.
true
if all postions 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 variablepublic 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
pos
public final boolean isSimple()
public final boolean isReverseComplementable()
true
if the AlphabectContainer also to compute the reverse complement of a sequence.public int toDiscrete(int pos, double val)
pos
- the positionval
- the value
val
at position pos
public String toString()
toString
in class Object
public StringBuffer toXML()
Storable
toXML
in interface Storable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |