T
- the token type used in the associated alignment modelpublic class DegapedIndexCalculator<T> extends Object
It allows to specify a set of tokens to be considered as gaps. This set may contain any token, not necessarily actual gap tokens like '-'.
#degapedIndex(int, int)
is the key method which calculates the index a token in a
sequence would have, if that sequence contained no gaps (no tokens contained in getGapTokens()
).
Constructor and Description |
---|
DegapedIndexCalculator(AlignmentModel<T> model)
Creates a new instance of this class using a
HashSet containing the gap token specified by the
token set of model . |
DegapedIndexCalculator(AlignmentModel<T> model,
Set<T> gapTokens)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
int |
degapedIndex(String sequenceID,
int originalIndex)
Calculates the ungapped index according to a position in the sequence containing gaps.
|
protected void |
finalize() |
Set<T> |
getGapTokens()
Returns the set of gap tokens used by this instance.
|
AlignmentModel<T> |
getModel()
Returns the alignment model this instance works on.
|
public DegapedIndexCalculator(AlignmentModel<T> model, Set<T> gapTokens)
model
- the alignment model to calculate ungapped indices fromgapTokens
- a set of tokens to be considered as gapspublic DegapedIndexCalculator(AlignmentModel<T> model)
HashSet
containing the gap token specified by the
token set of model
. Additional gap tokens can be added using getGapTokens()
later on.model
- the alignment model to calculate ungapped indices inpublic AlignmentModel<T> getModel()
public Set<T> getGapTokens()
public int degapedIndex(String sequenceID, int originalIndex)
If originalIndex
refers to position of the original sequence containing a gap,
the ungapped index of the next non-gap token on the left is returned. If no non-gap
token exists left of the specified position, 0 is returned.
The runtime of this method scales linearly to the distance between originalIndex
in this call of this method and originalIndex
in the previous call with the same
sequence ID. If this is the first call with the specified sequence ID ever or since the
last modification of the according sequence, the runtime is proportional to
originalIndex
.
sequenceID
- the ID of the sequence where the ungapped index shall be determinedoriginalIndex
- the index in the original sequence including gaps