info.bioinfweb.jphyloio.dataadapters.implementations.store

## Class StoreMatrixDataAdapter

- java.lang.Object
- - info.bioinfweb.jphyloio.dataadapters.implementations.store.StoreAnnotatedDataAdapter<LinkedLabeledIDEvent>
  - - info.bioinfweb.jphyloio.dataadapters.implementations.store.StoreMatrixDataAdapter

- All Implemented Interfaces:
    AnnotatedDataAdapter, ElementDataAdapter<LinkedLabeledIDEvent>, MatrixDataAdapter

      public class StoreMatrixDataAdapter
      extends StoreAnnotatedDataAdapter<LinkedLabeledIDEvent>
      implements MatrixDataAdapter

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StoreMatrixDataAdapter(LinkedLabeledIDEvent alignmentStartEvent, boolean longTokens, java.util.List<JPhyloIOEvent> annotations)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.
    `StoreObjectListDataAdapter<CharacterDefinitionEvent>` | `getCharacterDefinitions(ReadWriteParameterMap parameters)` Returns a list of character definitions for the matrix modeled by this instance.
    `StoreObjectListDataAdapter<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.
    `StoreObjectListDataAdapter<LinkedLabeledIDEvent>` | `getMatrix()`
    `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.
    `StoreObjectListDataAdapter<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.
    `LinkedLabeledIDEvent` | `getStartEvent(ReadWriteParameterMap parameters)` Returns the start event of this data element.
    `StoreObjectListDataAdapter<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.

    - ### Methods inherited from class info.bioinfweb.jphyloio.dataadapters.implementations.store.StoreAnnotatedDataAdapter

      `getAnnotations, writeMetadata`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface info.bioinfweb.jphyloio.dataadapters.AnnotatedDataAdapter

      `writeMetadata`

- - ### Constructor Detail

    - #### StoreMatrixDataAdapter

          public StoreMatrixDataAdapter(LinkedLabeledIDEvent alignmentStartEvent,
                                        boolean longTokens,
                                        java.util.List<JPhyloIOEvent> annotations)

  - ### Method Detail

    - #### getStartEvent

          public LinkedLabeledIDEvent getStartEvent(ReadWriteParameterMap parameters)

      Description copied from interface: `ElementDataAdapter`
      Returns the start event of this data element. The returned event can be used to determine the label and ID of the modeled data element or an optionally linked data element.
      Specified by:
        `getStartEvent` in interface `ElementDataAdapter<LinkedLabeledIDEvent>`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        the start event of this data element

    - #### getSequenceCount

          public long getSequenceCount(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns the number of sequences contained in this matrix.
      Specified by:
        `getSequenceCount` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        the number of sequences that will be returned by `MatrixDataAdapter.getSequenceIDIterator(ReadWriteParameterMap)`

    - #### getColumnCount

          public long getColumnCount(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      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.

      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.)

      Specified by:
        `getColumnCount` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        the number of columns in the matrix or -1 if each sequence may have a different length

    - #### containsLongTokens

          public boolean containsLongTokens(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns whether tokens longer than one character are contained in the matrix modeled by this instance. Some writers will use this information to determine, whether whitespace needs to be inserted to separate tokens.
      Specified by:
        `containsLongTokens` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        `true` if tokens longer than one character may occur, or `false` if all tokens are exactly one character long

    - #### getMatrix

          public StoreObjectListDataAdapter<LinkedLabeledIDEvent> getMatrix()

    - #### getCharacterSets

          public StoreObjectListDataAdapter<LinkedLabeledIDEvent> getCharacterSets(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns a list of character sets defined for the matrix modeled by this instance.
      Specified by:
        `getCharacterSets` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        a (possibly empty) list of character sets

    - #### getTokenSets

          public StoreObjectListDataAdapter<TokenSetDefinitionEvent> getTokenSets(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns a list of token sets defined for the matrix modeled by this instance.
      Specified by:
        `getTokenSets` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        a (possibly empty) list of token sets

    - #### getSequenceIDIterator

          public java.util.Iterator<java.lang.String> getSequenceIDIterator(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns an iterator returning the IDs of all sequences in the represented matrix.

      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.)

      Specified by:
        `getSequenceIDIterator` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        an iterator returning the edge IDs (Must return at least one element.)

    - #### getSequenceStartEvent

          public LinkedLabeledIDEvent getSequenceStartEvent(ReadWriteParameterMap parameters,
                                                            java.lang.String sequenceID)
                                                     throws java.lang.IllegalArgumentException

      Description copied from interface: `MatrixDataAdapter`
      Returns an event describing the sequence with the specified ID.
      Specified by:
        `getSequenceStartEvent` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
        `sequenceID` - the ID of the sequence to be described
      Returns:
        an linked OTU event describing the specified sequence
      Throws:
        `java.lang.IllegalArgumentException`

    - #### getSequenceLength

          public long getSequenceLength(ReadWriteParameterMap parameters,
                                        java.lang.String sequenceID)
                                 throws java.lang.IllegalArgumentException

      Description copied from interface: `MatrixDataAdapter`
      Returns the length for the specified sequence. If `MatrixDataAdapter.getColumnCount(ReadWriteParameterMap)` returns does not return -1, this method should return the same value as `MatrixDataAdapter.getColumnCount(ReadWriteParameterMap)` for each sequence. Otherwise it may return different values for each sequence.
      Specified by:
        `getSequenceLength` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
        `sequenceID` - the ID of the sequence which defined the length
      Returns:
        the length of the according sequence
      Throws:
        `java.lang.IllegalArgumentException` - if an unknown sequence ID was specified

    - #### writeSequencePartContentData

          public void writeSequencePartContentData(ReadWriteParameterMap parameters,
                                                   JPhyloIOEventReceiver receiver,
                                                   java.lang.String sequenceID,
                                                   long startColumn,
                                                   long endColumn)
                                            throws java.io.IOException,
                                                   java.lang.IllegalArgumentException

      Description copied from interface: `MatrixDataAdapter`
      Implementing classes must write a sequence of events here, that describe the sequence tokens present in the specified column range. A valid event sequence corresponds to the grammar node `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.

      Specified by:
        `writeSequencePartContentData` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
        `receiver` - the receiver to write the events to
        `sequenceID` - the ID of the sequence from which a part shall be written
        `startColumn` - the first column of the sequence part to be written (inclusive)
        `endColumn` - the last column of the sequence part to be written (exclusive)
      Throws:
        `java.io.IOException` - if a I/O error occurs while writing the data
        `java.lang.IllegalArgumentException` - if an unknown sequence ID was specified

    - #### getCharacterDefinitions

          public StoreObjectListDataAdapter<CharacterDefinitionEvent> getCharacterDefinitions(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns a list of character definitions for the matrix modeled by this instance.
      Specified by:
        `getCharacterDefinitions` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        a (possibly empty) list of character definitions

    - #### getSequenceSets

          public StoreObjectListDataAdapter<LinkedLabeledIDEvent> getSequenceSets(ReadWriteParameterMap parameters)

      Description copied from interface: `MatrixDataAdapter`
      Returns a list of sequence sets defined for the matrix modeled by this instance.
      Specified by:
        `getSequenceSets` in interface `MatrixDataAdapter`
      Parameters:
        `parameters` - the parameter map of the calling writer that provides context information for the data request
      Returns:
        a (possibly empty) list of sequence sets