S - the type of the sequence objects (e.g. a List implementation or a BioJava sequence type)T - the type of sequence elements (tokens) the implementing provider object works withpublic abstract class AbstractMapBasedAlignmentModel<S,T> extends AbstractUndecoratedAlignmentModel<T>
Map to identify the sequence object belonging to a sequence ID. The ordering of the
sequences is implemented using an additional list storing the IDs. Inherited classes have the option
to provide a custom map implementation instead of HashMap which is the default.
Sequences are sorted by the order they are added to the model. This ordering in independent to the
SequenceOrder object used in an associated AlignmentArea.
SequenceAccessAlignmentModel,
SequenceOrder,
AlignmentArea| Constructor and Description |
|---|
AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs)
Creates a new instance of this class relying on a
HashMap. |
AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs,
java.util.Map<java.lang.String,S> sequenceMap)
Creates a new instance of this class with a custom map implementation.
|
AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs,
java.util.Map<java.lang.String,S> sequenceMap,
java.util.List<java.lang.String> sequenceOrder)
Creates a new instance of this class with a custom map and list implementation.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsSequence(java.lang.String sequenceID)
Checks if a sequence associated with the specified unique identifier is contained in this model.
|
protected abstract S |
createNewSequence(java.lang.String sequenceID,
java.lang.String sequenceName)
Implementing classes must offer a way to create their custom instances of sequence objects
overwriting this method.
|
protected void |
doAddSequence(java.lang.String sequenceID,
java.lang.String sequenceName)
This method is called by
AbstractUndecoratedAlignmentModel.addSequence(String) if #isReadOnly() returns false. |
protected void |
doRemoveSequence(java.lang.String sequenceID)
This method is called by
#removeSequence(int) if #isReadOnly() returns false. |
int |
getSequenceCount()
Returns the number of sequences in the underlying data source.
|
protected java.util.Map<java.lang.String,S> |
getSequenceMap()
Returns the underlying map object used to assign sequences to their IDs.
|
protected java.util.List<java.lang.String> |
getSequenceOrder()
Returns the list object used to determine the order of the sequences.
|
java.util.Iterator<java.lang.String> |
sequenceIDIterator()
Returns an iterator returned the IDs of the stored sequences in the order they were added
to this model.
|
addSequence, addSequence, appendToken, appendTokens, doRenameSequence, fireAfterSequenceChange, fireAfterTokenChange, getApproxMaxSequenceLength, getIDManager, getMaxSequenceLength, getTokenSet, isReuseSequenceIDs, isSequencesReadOnly, isTokensReadOnly, removeSequence, renameSequence, sequenceIDsByName, sequenceNameByID, setMaxSequeceLengthRecalculte, setReuseSequenceIDs, setTokenSetfireAfterSequenceRenamed, getChangeListeners, getID, getLabel, setID, setLabelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSequenceLength, getTokenAt, getWriteType, insertTokenAt, insertTokensAt, removeTokenAt, removeTokensAt, setTokenAt, setTokensAtpublic AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs, java.util.Map<java.lang.String,S> sequenceMap, java.util.List<java.lang.String> sequenceOrder)
tokenSet - the token set which is supported by the implementationidManager - the ID manager to be used by the new instance (maybe shared among multiple instances)reuseSequenceIDs - Specifies whether unused IDs of the underlying ID manager should be reused by this model.
(See the documentation of AbstractUndecoratedAlignmentModel.isReuseSequenceIDs() for details. Specify false, if you are unsure
what this property does.)sequenceMap - the map instance used to assign sequences to their IDs (must be empty)sequenceOrder - the list object defining the order of the sequencespublic AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs, java.util.Map<java.lang.String,S> sequenceMap)
tokenSet - the token set which is supported by the implementationidManager - the ID manager to be used by the new instance (maybe shared among multiple instances)reuseSequenceIDs - Specifies whether unused IDs of the underlying ID manager should be reused by this model.
(See the documentation of AbstractUndecoratedAlignmentModel.isReuseSequenceIDs() for details. Specify false, if you are unsure
what this property does.)sequenceMap - the map instance used to assign sequences to their IDspublic AbstractMapBasedAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs)
HashMap.tokenSet - the token set which is supported by the implementationidManager - the ID manager to be used by the new instance (maybe shared among multiple instances)reuseSequenceIDs - Specifies whether unused IDs of the underlying ID manager should be reused by this model.
(See the documentation of AbstractUndecoratedAlignmentModel.isReuseSequenceIDs() for details. Specify false, if you are unsure
what this property does.)protected java.util.Map<java.lang.String,S> getSequenceMap()
protected java.util.List<java.lang.String> getSequenceOrder()
ArrayList in the current implementation (Note that the implementing class
might change in future releases of LibrAlign.)public boolean containsSequence(java.lang.String sequenceID)
AlignmentModelsequenceID - the ID of the sequence to checked ontrue if an according sequence was found, false otherwisepublic java.util.Iterator<java.lang.String> sequenceIDIterator()
AlignmentModel.sequenceIDIterator()public int getSequenceCount()
AlignmentModelprotected abstract S createNewSequence(java.lang.String sequenceID, java.lang.String sequenceName)
#doAddSequence(int, String) before
adding the new sequences to map and the oder list.sequenceID - the ID the new sequence must havesequenceName - the name the new sequence will haveprotected void doAddSequence(java.lang.String sequenceID, java.lang.String sequenceName)
AbstractUndecoratedAlignmentModelAbstractUndecoratedAlignmentModel.addSequence(String) if #isReadOnly() returns false.
Implementing classes should add the specified new sequence to their underlying data source in this
method. The according events or exceptions are already created by this class if necessary, therefore
this does not need to be done in the implementation of this method.doAddSequence in class AbstractUndecoratedAlignmentModel<T>sequenceID - the unique identifier for the new sequence which has been generated before the
call of this methodsequenceName - the initial name the new sequence shall haveprotected void doRemoveSequence(java.lang.String sequenceID)
AbstractUndecoratedAlignmentModel#removeSequence(int) if #isReadOnly() returns false.
Implementing classes should remove the specified sequence from their underlying data source in this
method. The according events or exceptions are already created by this class if necessary, therefore
this does not need to be done in the implementation of this method.doRemoveSequence in class AbstractUndecoratedAlignmentModel<T>sequenceID - the unique identifier of the sequence to be removed