info.bioinfweb.jphyloio.formats.nexus.commandreaders.sets

## Class AbstractNexusSetReader

- java.lang.Object
- - info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractNexusCommandEventReader
  - - info.bioinfweb.jphyloio.formats.nexus.commandreaders.sets.AbstractNexusSetReader

- All Implemented Interfaces:
    NexusCommandEventReader, NexusConstants, ReadWriteConstants
  Direct Known Subclasses:
    CharSetReader, IDBasedSetsReader

      public abstract class AbstractNexusSetReader
      extends AbstractNexusCommandEventReader
      implements NexusConstants, ReadWriteConstants

  General reader implementation to read the Nexus commands that define different kinds of sets.

  It supports reading sets in Nexus standard and vector format.

  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Field Summary

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.nexus.NexusConstants

      `ALTERNATIVE_END_COMMAND, BEGIN_COMMAND, BLOCK_NAME_CHARACTERS, BLOCK_NAME_DATA, BLOCK_NAME_NETWORKS, BLOCK_NAME_SETS, BLOCK_NAME_TAXA, BLOCK_NAME_TREES, BLOCK_NAME_UNALIGNED, CHARACTER_NAME_STATES_SEPARATOR, COMMAND_END, COMMAND_NAME_CHAR_LABELS, COMMAND_NAME_CHAR_SET, COMMAND_NAME_CHAR_STATE_LABELS, COMMAND_NAME_DIMENSIONS, COMMAND_NAME_FORMAT, COMMAND_NAME_LINK, COMMAND_NAME_MATRIX, COMMAND_NAME_NETWORK, COMMAND_NAME_TAX_LABELS, COMMAND_NAME_TAXON_SET, COMMAND_NAME_TITLE, COMMAND_NAME_TRANSLATE, COMMAND_NAME_TREE, COMMAND_NAME_TREE_SET, COMMENT_END, COMMENT_START, DIMENSIONS_SUBCOMMAND_NCHAR, DIMENSIONS_SUBCOMMAND_NEW_TAXA, DIMENSIONS_SUBCOMMAND_NTAX, ELEMENT_SEPARATOR, END_COMMAND, FIRST_LINE, FORMAT_NAME_STANDARD, FORMAT_NAME_VECTOR, FORMAT_SUBCOMMAND_DATA_TYPE, FORMAT_SUBCOMMAND_GAP_CHAR, FORMAT_SUBCOMMAND_INTERLEAVE, FORMAT_SUBCOMMAND_MATCH_CHAR, FORMAT_SUBCOMMAND_MISSING_CHAR, FORMAT_SUBCOMMAND_NO_LABELS, FORMAT_SUBCOMMAND_NO_TOKENS, FORMAT_SUBCOMMAND_SYMBOLS, FORMAT_SUBCOMMAND_TOKENS, FORMAT_SUBCOMMAND_TRANSPOSE, FORMAT_VALUE_CONTINUOUS_DATA_TYPE, FORMAT_VALUE_DNA_DATA_TYPE, FORMAT_VALUE_MIXED_DATA_TYPE, FORMAT_VALUE_NUCLEOTIDE_DATA_TYPE, FORMAT_VALUE_PROTEIN_DATA_TYPE, FORMAT_VALUE_RNA_DATA_TYPE, FORMAT_VALUE_STANDARD_DATA_TYPE, KEY_VALUE_SEPARATOR, MATRIX_POLYMORPHIC_TOKEN_END, MATRIX_POLYMORPHIC_TOKEN_START, MATRIX_UNCERTAINS_TOKEN_END, MATRIX_UNCERTAINS_TOKEN_START, NEXUS_FORMAT_NAME, NEXUS_NAMESPACE_PREFIX, NEXUS_PREDICATE_NAMESPACE, SET_END_INDEX_SYMBOL, SET_KEY_WORD_ALL, SET_KEY_WORD_REMAINING, SET_REGULAR_INTERVAL_SYMBOL, SET_TO_SYMBOL, SET_VECTOR_CONTAINED, SET_VECTOR_NOT_CONTAINED, UNTIL_WHITESPACE_COMMENT_COMMAND_EQUAL_PATTERN, UNTIL_WHITESPACE_COMMENT_COMMAND_PATTERN, VALUE_DELIMITER, WORD_DELIMITER`

    - ### Fields inherited from interface info.bioinfweb.jphyloio.ReadWriteConstants

      `ATTRIBUTE_STRING_KEY, ATTRIBUTES_NAMESPACE_FOLDER, DATA_TYPE_NAMESPACE_FOLDER, DATA_TYPE_SIMPLE_VALUE_LIST, DEFAULT_CHAR_SET_ID_PREFIX, DEFAULT_CHARACTER_DEFINITION_ID_PREFIX, DEFAULT_EDGE_ID_PREFIX, DEFAULT_GENERAL_ID_PREFIX, DEFAULT_MATRIX_ID_PREFIX, DEFAULT_MAX_COMMENT_LENGTH, DEFAULT_MAX_TOKENS_TO_READ, DEFAULT_META_ID_PREFIX, DEFAULT_NETWORK_ID_PREFIX, DEFAULT_NODE_EDGE_SET_ID_PREFIX, DEFAULT_NODE_ID_PREFIX, DEFAULT_OTU_ID_PREFIX, DEFAULT_OTU_LIST_ID_PREFIX, DEFAULT_OTU_SET_ID_PREFIX, DEFAULT_SEQUENCE_ID_PREFIX, DEFAULT_SEQUENCE_SET_ID_PREFIX, DEFAULT_TOKEN_DEFINITION_ID_PREFIX, DEFAULT_TOKEN_SET_ID_PREFIX, DEFAULT_TREE_ID_PREFIX, DEFAULT_TREE_NETWORK_GROUP_ID_PREFIX, DEFAULT_TREE_NETWORK_SET_ID_PREFIX, JPHYLOIO_ATTRIBUTES_NAMESPACE, JPHYLOIO_ATTRIBUTES_PREFIX, JPHYLOIO_DATA_TYPE_NAMESPACE, JPHYLOIO_DATA_TYPE_PREFIX, JPHYLOIO_FORMATS_NAMESPACE_PREFIX, JPHYLOIO_GENERAL_NAMESPACE, JPHYLOIO_NAMESPACE_PREFIX, JPHYLOIO_PREDICATE_NAMESPACE, JPHYLOIO_PREDICATE_PREFIX, PREDICATE_CHARACTER_COUNT, PREDICATE_EDGE_LENGTH, PREDICATE_EDGE_SOURCE_NODE, PREDICATE_EDGE_TARGET_NODE, PREDICATE_HAS_CUSTOM_XML, PREDICATE_HAS_LITERAL_METADATA, PREDICATE_HAS_RESOURCE_METADATA, PREDICATE_IS_CROSSLINK, PREDICATE_NAMESPACE_FOLDER, PREDICATE_PART_SEPERATOR, PREDICATE_SEQUENCE_COUNT, RESERVED_ID_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractNexusSetReader(EventContentType setType, java.lang.String commandName, java.lang.String[] validBlocks, NexusReaderStreamDataProvider nexusDocument)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `createEventsForInterval(long start, long end)` Creates the event(s) representing the specified interval in the current set type
    `protected boolean` | `doReadNextEvent()`
    `protected abstract long` | `elementIndexByName(java.lang.String name)` Converts the Nexus name of a set element to its index.
    `protected abstract long` | `getElementCount()` Returns the number of elements which can potentially be contained in this set (e.g.
    `protected abstract java.lang.String` | `getLinkedID()` Returns the ID if the object that is linked to this set (e.g.

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.nexus.commandreaders.AbstractNexusCommandEventReader

      `consumeWhiteSpaceAndCommentsToBuffer, getCommandName, getStreamDataProvider, getValidBlocks, isAllDataProcessed, readNextEvent, setAllDataProcessed`

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

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

- - ### Constructor Detail

    - #### AbstractNexusSetReader

          public AbstractNexusSetReader(EventContentType setType,
                                        java.lang.String commandName,
                                        java.lang.String[] validBlocks,
                                        NexusReaderStreamDataProvider nexusDocument)

  - ### Method Detail

    - #### getLinkedID

          protected abstract java.lang.String getLinkedID()

      Returns the ID if the object that is linked to this set (e.g. an alignment start event related to a character set or an OTU list related to an OTU set)
      Returns:
        the ID of the linked start element
      Throws:
        `java.io.IOException`

    - #### getElementCount

          protected abstract long getElementCount()

      Returns the number of elements which can potentially be contained in this set (e.g. the number of declared taxa or the number of alignment columns).
      Returns:
        the number of elements or -1 if the number is currently undefined (e.g. if no block is linked to the current `SETS` block

    - #### createEventsForInterval

          protected abstract void createEventsForInterval(long start,
                                                          long end)
                                                   throws java.io.IOException

      Creates the event(s) representing the specified interval in the current set type
      Parameters:
        `start` - the fist index of the interval
        `end` - the first index after the end of the interval
      Throws:
        `java.io.IOException` - if an I/O error occurs while writing the event(s)

    - #### elementIndexByName

          protected abstract long elementIndexByName(java.lang.String name)

      Converts the Nexus name of a set element to its index.
      Parameters:
        `name` - the Nexus name of the element
      Returns:
        the index of the specified element or -1 if an element with the specified name could not be found

    - #### doReadNextEvent

          protected boolean doReadNextEvent()
                                     throws java.io.IOException

      Specified by:
        `doReadNextEvent` in class `AbstractNexusCommandEventReader`
      Throws:
        `java.io.IOException`