public abstract class Constraint extends Object implements Storable
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
counts
The counts for each specific constraint.
|
protected double[] |
freq
The frequencies estimated from the counts.
|
protected int[] |
usedPositions
The used positions.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Constraint(int[] usedPositions,
int n)
The main constructor.
|
protected |
Constraint(StringBuffer xml)
The standard constructor for the interface
Storable. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
double weight)
Adds the given
weight to the count with index
index. |
void |
add(Sequence seq,
int start,
double weight)
This method determines the specific constraint that is fulfilled by the
Sequence seq and adds the weight to the
specific counter. |
protected abstract void |
appendAdditionalInfo(StringBuffer xml)
This method appends additional information that is not stored in the base
class to the
StringBuffer. |
protected Constraint |
clone() |
abstract void |
estimate(double ess)
Estimates the (smoothed) relative frequencies using the ess
(equivalent sample size).
|
protected void |
estimateUnConditional(int start,
int end,
double pc,
boolean exceptionWhenNoData)
Estimates unconditionally.
|
protected abstract void |
extractAdditionalInfo(StringBuffer xml)
This method parses additional information from the
StringBuffer
that is not parsed in the base class. |
double |
getCount(int index)
Returns the current count with index
index. |
abstract String |
getDescription(AlphabetContainer con,
int i)
Returns the decoded symbol for the encoded symbol
i. |
double |
getFreq(int index)
Returns the current frequency with index
index. |
double |
getFreq(Sequence seq,
int start)
This method determines the specific constraint that is fulfilled by the
Sequence seq beginning at position
start. |
String |
getFreqInfo(AlphabetContainer con,
NumberFormat nf)
Returns an information about the stored frequencies.
|
int |
getMarginalOrder()
Returns the marginal order, i.e.
|
int |
getNumberOfSpecificConstraints()
Returns the number of specific constraints.
|
int |
getPosition(int index)
Returns the position with index
index. |
int[] |
getPositions()
Returns a clone of the array of used positions.
|
protected abstract String |
getXMLTag()
Returns the XML tag that is used for the class to en- or decode.
|
void |
reset()
This method resets all member variables that are in some way counters,
frequencies, ...
|
void |
resetCounts()
This method allows to reset the internal field
counts that is used for estimating the probabilities. |
abstract int |
satisfiesSpecificConstraint(Sequence seq,
int start)
This method returns the index of the specific constraint that is
fulfilled by the
Sequence seq beginning at position
start. |
abstract String |
toString() |
StringBuffer |
toXML()
This method returns an XML representation as
StringBuffer of an
instance of the implementing class. |
protected double[] counts
protected double[] freq
protected int[] usedPositions
protected Constraint(int[] usedPositions,
int n)
throws IllegalArgumentException
Constraint and checks that
each position is used maximally once.usedPositions - the used positions (will be cloned), have to be non-negativen - the number of specific constraintsIllegalArgumentException - if there are some fundamental errors in the arguments for the positionsprotected Constraint(StringBuffer xml) throws NonParsableException
Storable.
Creates a new Constraint out of its XML representation.xml - the XML representation as StringBufferNonParsableException - if the Constraint could not be reconstructed out of
the XML representation (the StringBuffer could not be
parsed)Storable,
extractAdditionalInfo(StringBuffer)public final void add(int index,
double weight)
weight to the count with index
index.index - the indexweight - the weightpublic void add(Sequence seq, int start, double weight)
Sequence seq and adds the weight to the
specific counter.seq - the sequencestart - the start positionweight - the weight for the sequencesatisfiesSpecificConstraint(Sequence, int),
add(int, double)protected Constraint clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic abstract void estimate(double ess)
ess - the essprotected void estimateUnConditional(int start,
int end,
double pc,
boolean exceptionWhenNoData)
start - the start indexend - the end indexpc - the pseudocount for each parameterexceptionWhenNoData - indicates if an (runtime) exception is thrown if no data was
available to estimate the parametersprotected abstract void appendAdditionalInfo(StringBuffer xml)
StringBuffer.xml - the StringBuffer that is used for appending additional
informationpublic double getCount(int index)
index.index - the indexpublic double getFreq(int index)
index.index - the indexpublic double getFreq(Sequence seq, int start)
Sequence seq beginning at position
start.seq - the Sequencestart - the start positionsatisfiesSpecificConstraint(Sequence, int),
getFreq(int)public int getMarginalOrder()
public int getNumberOfSpecificConstraints()
public int getPosition(int index)
index.index - the indexindexpublic int[] getPositions()
protected abstract String getXMLTag()
public void reset()
public abstract int satisfiesSpecificConstraint(Sequence seq, int start)
Sequence seq beginning at position
start.seq - the sequencestart - the start positionprotected abstract void extractAdditionalInfo(StringBuffer xml) throws NonParsableException
StringBuffer
that is not parsed in the base class.xml - the StringBuffer to be parsedNonParsableException - if something with the parsing went wrongpublic StringBuffer toXML()
StorableStringBuffer of an
instance of the implementing class.public abstract String getDescription(AlphabetContainer con, int i)
i.con - the AlphabetContaineri - the encoded symbolipublic String getFreqInfo(AlphabetContainer con, NumberFormat nf)
con - the AlphabetContainernf - NumberFormat for String representation of frequenciespublic void resetCounts()
counts that is used for estimating the probabilities.