public class RandomAccessIndexTranslator<T> extends AbstractIndexTranslator<T,RandomAccessIndexTranslator.IndexTranslations>
AlignmentModel
.
A set of tokens to be considered as gaps can be defined using the gapTokens
constructor parameter.
In contrast to SequentialAccessIndexTranslator
this class stores the mapping for all positions of all sequences to
allow fast random access, while SequentialAccessIndexTranslator
calculates the mapping in each call with a runtime
proportional to the distance between the indices used in two subsequent calls. Therefore this implementation is faster for
random access but uses more memory.
Modifier and Type | Class and Description |
---|---|
protected static class |
RandomAccessIndexTranslator.IndexTranslations |
Constructor and Description |
---|
RandomAccessIndexTranslator(AlignmentModel<T> model)
Creates a new instance of this class using a
HashSet containing the gap token specified by the
token set of model . |
RandomAccessIndexTranslator(AlignmentModel<T> model,
java.util.Set<T> gapTokens) |
Modifier and Type | Method and Description |
---|---|
protected RandomAccessIndexTranslator.IndexTranslations |
createSequenceData(java.lang.String sequenceID) |
int |
getAlignedIndex(java.lang.String sequenceID,
int unalignedIndex)
Returns the column in the alignment, the specified token is contained in
|
IndexRelation |
getUnalignedIndex(java.lang.String sequenceID,
int alignedIndex)
Returns the index of the sequence token at the specified alignment column.
|
int |
getUnalignedLength(java.lang.String sequenceID) |
finalize, getGapTokens, getModel, getSequenceData
public RandomAccessIndexTranslator(AlignmentModel<T> model, java.util.Set<T> gapTokens)
public RandomAccessIndexTranslator(AlignmentModel<T> model)
HashSet
containing the gap token specified by the
token set of model
. Additional gap tokens can be added using AbstractIndexTranslator.getGapTokens()
later on.model
- the alignment model to calculate ungapped indices inprotected RandomAccessIndexTranslator.IndexTranslations createSequenceData(java.lang.String sequenceID)
createSequenceData
in class AbstractIndexTranslator<T,RandomAccessIndexTranslator.IndexTranslations>
public IndexRelation getUnalignedIndex(java.lang.String sequenceID, int alignedIndex)
IndexTranslator
getUnalignedIndex
in interface IndexTranslator<T>
getUnalignedIndex
in class AbstractIndexTranslator<T,RandomAccessIndexTranslator.IndexTranslations>
sequenceID
- the ID of the sequence which contains the token to be locatedalignedIndex
- the column index in the alignmentIndexRelation.getCorresponding()
will return IndexRelation.GAP
, and IndexRelation.getBefore()
and
{IndexRelation#getAfter()} the positions of the neighboring tokens, if present. If the specified
column contains a token, IndexRelation.getCorresponding()
will return the index of that
token in the unaligned sequence.)public int getAlignedIndex(java.lang.String sequenceID, int unalignedIndex)
IndexTranslator
getAlignedIndex
in interface IndexTranslator<T>
getAlignedIndex
in class AbstractIndexTranslator<T,RandomAccessIndexTranslator.IndexTranslations>
sequenceID
- the ID of the sequence which contains the token to be locatedunalignedIndex
- the index of the token in the unaligned sequencepublic int getUnalignedLength(java.lang.String sequenceID)