T
- the type of sequence elements (tokens) the implementing provider object works withpublic abstract class AbstractListAlignmentModel<T> extends AbstractMapBasedAlignmentModel<java.util.List<T>,T>
AlignmentModel
using a map of lists to store alignment data.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
Constructor and Description |
---|
AbstractListAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs)
Creates a new instance of this class using
DEFAULT_INITIAL_CAPACITY as the initial capacity
which is only used if it is lower than AbstractUndecoratedAlignmentModel.getMaxSequenceLength() to create new sequence array
lists. |
AbstractListAlignmentModel(TokenSet<T> tokenSet,
SequenceIDManager idManager,
boolean reuseSequenceIDs,
int initialCapacity,
boolean useMaxLength)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.List<T> |
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 abstract java.util.List<T> |
createNewSequence(java.lang.String sequenceID,
java.lang.String sequenceName,
int initialCapacity)
This method is called by
#createNewSequence(int, String) and must be implemented by inherited classes. |
int |
getInitialCapacity()
Returns the default initial capacity of new list objects created by
#createNewSequence(int, String, int) . |
java.util.List<T> |
getSequence(java.lang.String sequenceID) |
int |
getSequenceLength(java.lang.String sequenceID)
Returns the length of the specified sequence.
|
T |
getTokenAt(java.lang.String sequenceID,
int index)
Returns the token at the specified position.
|
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.
|
boolean |
isUseMaxLength()
Determines if the initial capacity of newly generated list objects shall only depend on the
default capacity or also on the maximum length of the other lists already contained in this provider.
|
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.
|
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, 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
public static final int DEFAULT_INITIAL_CAPACITY
public AbstractListAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs)
DEFAULT_INITIAL_CAPACITY
as the initial capacity
which is only used if it is lower than AbstractUndecoratedAlignmentModel.getMaxSequenceLength()
to create new sequence array
lists.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 AbstractListAlignmentModel(TokenSet<T> tokenSet, SequenceIDManager idManager, boolean reuseSequenceIDs, int initialCapacity, boolean useMaxLength)
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.)initialCapacity
- the initial capacity newly generated array lists will haveuseMaxLength
- Specify true
here if initialCapacity
shall only be used if it
is lower than AbstractUndecoratedAlignmentModel.getMaxSequenceLength()
to create new sequence array lists.public java.util.List<T> getSequence(java.lang.String sequenceID)
public T getTokenAt(java.lang.String sequenceID, int index)
AlignmentModel
sequenceID
- the identifier the sequence where the token is containedindex
- the index of the element contained in the specified sequence (The first element has the index 0.)public void setTokenAt(java.lang.String sequenceID, int index, T token) throws AlignmentSourceNotWritableException
AlignmentModel
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
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
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
.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
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}.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 int getSequenceLength(java.lang.String sequenceID)
AlignmentModel
sequenceID
- the identifier the sequence in the alignment-1
if no sequence with the specified name existspublic AlignmentModelWriteType getWriteType()
AlignmentModel
public int getInitialCapacity()
#createNewSequence(int, String, int)
.public boolean isUseMaxLength()
true
if new lists shall have the maximum length of all other lists already present in
this provider if this maximum is higher than the return value of getInitialCapacity()
,
false
if all new sequences shall always have an initial capacity of
getInitialCapacity()
.protected abstract java.util.List<T> createNewSequence(java.lang.String sequenceID, java.lang.String sequenceName, int initialCapacity)
#createNewSequence(int, String)
and must be implemented by inherited classes.
In contrast to #createNewSequence(int, String)
it provides an additional parameter specifying the
initial capacity the returned list object shall have. This parameter value if set depending on the return
values of isUseMaxLength()
either to a fixed value as specified by getInitialCapacity()
or by the maximum length of other sequences in this provider if any of these contain more elements than
getInitialCapacity()
.sequenceID
- the ID the new sequence must havesequenceName
- the name the new sequence will haveinitialCapacity
- the initial capacity the returned list object shall haveprotected java.util.List<T> createNewSequence(java.lang.String sequenceID, java.lang.String sequenceName)
AbstractMapBasedAlignmentModel
#doAddSequence(int, String)
before
adding the new sequences to map and the oder list.createNewSequence
in class AbstractMapBasedAlignmentModel<java.util.List<T>,T>
sequenceID
- the ID the new sequence must havesequenceName
- the name the new sequence will have