S
- the type of the sequence objects (e.g. a BioJava sequence type or String
)T
- the type of sequence elements (tokens) the implementing provider object works withpublic abstract class AbstractUnmodifyableAlignmentModel<S,T> extends AbstractMapBasedAlignmentModel<S,T> implements SequenceAccessAlignmentModel<S,T>
Constructor and Description |
---|
AbstractUnmodifyableAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs)
Creates a new instance of this class relying on a
TreeMap . |
AbstractUnmodifyableAlignmentModel(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 and list implementation.
|
AbstractUnmodifyableAlignmentModel(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 |
---|---|
java.lang.String |
addSequence(java.lang.String sequenceName,
S content)
Adds a the specified sequence to the underlying data source and generates an ID for it.
|
S |
getSequence(java.lang.String sequenceID)
Returns the sequence object with the specified ID.
|
AlignmentModelWriteType |
getWriteType()
Returns a value that specifies if whole sequences or single tokens can be edited in the underlying
data source.
|
void |
insertTokenAt(java.lang.String sequenceID,
int index,
T token)
Inserts a token at the specified position.
|
void |
insertTokensAt(java.lang.String sequenceID,
int beginIndex,
java.util.Collection<? extends T> tokens)
Inserts a sequence of tokens starting at the specified position.
|
void |
removeTokenAt(java.lang.String sequenceID,
int index)
Removes the token at the specified position from the underlying data source.
|
void |
removeTokensAt(java.lang.String sequenceID,
int beginIndex,
int endIndex)
Removes the token inside the specified interval from the underlying data source.
|
S |
replaceSequence(java.lang.String sequenceID,
S content)
Replaces the sequence object with the specified ID by the specified contents.
|
void |
setTokenAt(java.lang.String sequenceID,
int index,
T token)
Replaces the token at the specified position by the passed token.
|
void |
setTokensAt(java.lang.String sequenceID,
int beginIndex,
java.util.Collection<? extends T> tokens)
Replaces a sequence of tokens starting at the specified position.
|
containsSequence, createNewSequence, doAddSequence, doRemoveSequence, getSequenceCount, getSequenceMap, getSequenceOrder, sequenceIDIterator
addSequence, addSequence, appendToken, appendTokens, doRenameSequence, fireAfterSequenceChange, fireAfterTokenChange, getApproxMaxSequenceLength, getIDManager, getMaxSequenceLength, getTokenSet, isReuseSequenceIDs, isSequencesReadOnly, isTokensReadOnly, removeSequence, renameSequence, sequenceIDsByName, sequenceNameByID, setMaxSequeceLengthRecalculte, setReuseSequenceIDs, setTokenSet
fireAfterSequenceRenamed, getChangeListeners, getID, getLabel, setID, setLabel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addSequence, addSequence, appendToken, appendTokens, containsSequence, getChangeListeners, getID, getLabel, getMaxSequenceLength, getSequenceCount, getSequenceLength, getTokenAt, getTokenSet, isSequencesReadOnly, isTokensReadOnly, removeSequence, renameSequence, sequenceIDIterator, sequenceIDsByName, sequenceNameByID, setID, setLabel, setTokenSet
public AbstractUnmodifyableAlignmentModel(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 IDssequenceOrder
- the list object defining the order of the sequencespublic AbstractUnmodifyableAlignmentModel(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 AbstractUnmodifyableAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs)
TreeMap
.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.)public java.lang.String addSequence(java.lang.String sequenceName, S content)
This method calls first AbstractUndecoratedAlignmentModel.addSequence(String)
and than #setSequenceContent(int, Object)
internally. Therefore two different events will be fired.
Note that since the sequences in this implementation are considered as unmutable it does not make
sense to call AbstractUndecoratedAlignmentModel.addSequence(String)
on an instance of this class unless you want to have
an empty sequence in the alignment.
addSequence
in interface SequenceAccessAlignmentModel<S,T>
sequenceName
- the name of the new sequencecontent
- the sequence object to be added.AlignmentSourceNotWritableException
- This exception is not thrown by this implementation.public S replaceSequence(java.lang.String sequenceID, S content)
SequenceChangeEvent
s are fired, one for the removal and one for the
insertion.
Between these two events the underlying map does not contain any sequence with the specified ID. For the
case that event handlers of the first event add any new sequences to the map they have to make sure not
to use the ID passed to this method (which might accidentally be created by a call of
AbstractUndecoratedAlignmentModel.addSequence(String)
), because the new contents would than be overwritten in the second step
of this method.
It also has to be noted that there
replaceSequence
in interface SequenceAccessAlignmentModel<S,T>
sequenceID
- the ID of the sequence to be replacedcontent
- the new sequence objectnull
if there was no sequence
with the IDpublic AlignmentModelWriteType getWriteType()
AlignmentModel
getWriteType
in interface AlignmentModel<T>
public void setTokenAt(java.lang.String sequenceID, int index, T token) throws AlignmentSourceNotWritableException
AlignmentModel
setTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedindex
- the index of the element to be replaced (The first element has the index 0.)token
- the new token for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void setTokensAt(java.lang.String sequenceID, int beginIndex, java.util.Collection<? extends T> tokens) throws AlignmentSourceNotWritableException
AlignmentModel
setTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedbeginIndex
- the index of the first element to be replaced
(The first element in the sequence has the index 0.)tokens
- the new tokens for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokensAlignmentModelUtils.charSequenceToTokenList(CharSequence, TokenSet)
public void insertTokenAt(java.lang.String sequenceID, int index, T token) throws AlignmentSourceNotWritableException
AlignmentModel
insertTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentindex
- the new index the inserted element will have
(0 <= elementIndex < sequenceLength
)token
- the token to be insertedAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void insertTokensAt(java.lang.String sequenceID, int beginIndex, java.util.Collection<? extends T> tokens) throws AlignmentSourceNotWritableException
AlignmentModel
tokens
.insertTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedbeginIndex
- the index of the first element to be replaced
(The first element in the sequence has the index 0.)tokens
- the new tokens for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokensAlignmentModelUtils.charSequenceToTokenList(CharSequence, TokenSet)
public void removeTokenAt(java.lang.String sequenceID, int index) throws AlignmentSourceNotWritableException
AlignmentModel
removeTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentindex
- the index of the element to be removed (The first element has the index 0.)AlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void removeTokensAt(java.lang.String sequenceID, int beginIndex, int endIndex) throws AlignmentSourceNotWritableException
AlignmentModel
beginIndex
and extends to the
token at index endIndex - 1). Thus the length of the subsequence is {@code endIndex - beginIndex}.removeTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentbeginIndex
- the beginning index, inclusiveendIndex
- the ending index, exclusiveAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic S getSequence(java.lang.String sequenceID)
SequenceAccess
If the implementing class also implements SequenceDataAdapter
the returned object can be a view
or copy of a sequence in the underlying data source depending in the return value of
SequenceDataAdapter.returnsCopies()
. If SequenceAccessAlignmentModel
is implemented
the object used to store the sequence data is returned.
getSequence
in interface SequenceAccess<S>
sequenceID
- the ID of the sequence to be returned