public interface MatrixDataAdapter extends ElementDataAdapter<LinkedLabeledIDEvent>
JPhyloIOEventWriter
, including token and character set definitions related to this
matrix.
This interface also allows to provide unaligned data (e.g. for the UNALIGNED block in Nexus).
In such cases implementations need to return an according value in getColumnCount(ReadWriteParameterMap)
.
Applications implementing this adapter may consider to inherit their implementation from
EmptyAnnotatedDataAdapter
or NoCharDefsNoSetsMatrixDataAdapter
.
Modifier and Type | Method and Description |
---|---|
boolean |
containsLongTokens(ReadWriteParameterMap parameters)
Returns whether tokens longer than one character are contained in the matrix modeled by this
instance.
|
ObjectListDataAdapter<CharacterDefinitionEvent> |
getCharacterDefinitions(ReadWriteParameterMap parameters)
Returns a list of character definitions for the matrix modeled by this instance.
|
ObjectListDataAdapter<LinkedLabeledIDEvent> |
getCharacterSets(ReadWriteParameterMap parameters)
Returns a list of character sets defined for the matrix modeled by this instance.
|
long |
getColumnCount(ReadWriteParameterMap parameters)
Returns the number of columns the modeled matrix has, if it contains aligned data or -1 if it
contains unaligned data and each sequence may have a different length.
|
long |
getSequenceCount(ReadWriteParameterMap parameters)
Returns the number of sequences contained in this matrix.
|
java.util.Iterator<java.lang.String> |
getSequenceIDIterator(ReadWriteParameterMap parameters)
Returns an iterator returning the IDs of all sequences in the represented matrix.
|
long |
getSequenceLength(ReadWriteParameterMap parameters,
java.lang.String sequenceID)
Returns the length for the specified sequence.
|
ObjectListDataAdapter<LinkedLabeledIDEvent> |
getSequenceSets(ReadWriteParameterMap parameters)
Returns a list of sequence sets defined for the matrix modeled by this instance.
|
LinkedLabeledIDEvent |
getSequenceStartEvent(ReadWriteParameterMap parameters,
java.lang.String sequenceID)
Returns an event describing the sequence with the specified ID.
|
ObjectListDataAdapter<TokenSetDefinitionEvent> |
getTokenSets(ReadWriteParameterMap parameters)
Returns a list of token sets defined for the matrix modeled by this instance.
|
void |
writeSequencePartContentData(ReadWriteParameterMap parameters,
JPhyloIOEventReceiver receiver,
java.lang.String sequenceID,
long startColumn,
long endColumn)
Implementing classes must write a sequence of events here, that describe the sequence tokens present in
the specified column range.
|
getStartEvent
writeMetadata
long getSequenceCount(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requestgetSequenceIDIterator(ReadWriteParameterMap)
long getColumnCount(ReadWriteParameterMap parameters)
For some writers the return value of this method may also determine which type of sequence data is written. (A Nexus writer would e.g. use an UNALIGNED instead of a CHARACTERS block, if -1 is returned.)
parameters
- the parameter map of the calling writer that provides context information for the data requestboolean containsLongTokens(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requesttrue
if tokens longer than one character may occur, or false
if all tokens
are exactly one character longObjectListDataAdapter<CharacterDefinitionEvent> getCharacterDefinitions(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requestObjectListDataAdapter<LinkedLabeledIDEvent> getCharacterSets(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requestObjectListDataAdapter<TokenSetDefinitionEvent> getTokenSets(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requestObjectListDataAdapter<LinkedLabeledIDEvent> getSequenceSets(ReadWriteParameterMap parameters)
parameters
- the parameter map of the calling writer that provides context information for the data requestjava.util.Iterator<java.lang.String> getSequenceIDIterator(ReadWriteParameterMap parameters)
Note that the returned iterator will be in ongoing use while other methods (e.g.
#writeSequencePartContent(JPhyloIOEventReceiver, String, long, long)
) are called.
Therefore implementing classes should make sure, that the source of the iterator is not
modified while a JPhyloIO writer is in use. (The iterator should not throw a
ConcurrentModificationException
before writing the target document is finished.)
parameters
- the parameter map of the calling writer that provides context information for the data requestLinkedLabeledIDEvent getSequenceStartEvent(ReadWriteParameterMap parameters, java.lang.String sequenceID)
parameters
- the parameter map of the calling writer that provides context information for the data requestsequenceID
- the ID of the sequence to be describedlong getSequenceLength(ReadWriteParameterMap parameters, java.lang.String sequenceID) throws java.lang.IllegalArgumentException
getColumnCount(ReadWriteParameterMap)
returns does not return -1,
this method should return the same value as getColumnCount(ReadWriteParameterMap)
for each sequence. Otherwise it
may return different values for each sequence.parameters
- the parameter map of the calling writer that provides context information for the data requestsequenceID
- the ID of the sequence which defined the lengthjava.lang.IllegalArgumentException
- if an unknown sequence ID was specifiedvoid writeSequencePartContentData(ReadWriteParameterMap parameters, JPhyloIOEventReceiver receiver, java.lang.String sequenceID, long startColumn, long endColumn) throws java.io.IOException, java.lang.IllegalArgumentException
SequencePartContent
in the documentation of JPhyloIOEventReader
.
Note that (according to the grammar definition) metadata related to the sequence as a whole can also be
passed to the receiver
in this method. In most cases it makes sense to pass the respective
metaevents at the beginning of this sequence, i.e., if this method is called with startColumn
= 0
the first events written should be the metaevents for the whole sequence. (Note that the grammar in principle
allows such metaevents also between sequence token events, but not all formats (not all writers) support
metadata at such a position.) The same applies to comment events. (See the documentation of the single
writers for further details on supported data.)
Note that column indices in JPhyloIO start with 0.
parameters
- the parameter map of the calling writer that provides context information for the data requestreceiver
- the receiver to write the events tosequenceID
- the ID of the sequence from which a part shall be writtenstartColumn
- the first column of the sequence part to be written (inclusive)endColumn
- the last column of the sequence part to be written (exclusive)java.io.IOException
- if a I/O error occurs while writing the datajava.lang.IllegalArgumentException
- if an unknown sequence ID was specified