info.bioinfweb.jphyloio.formats.fasta

## Class FASTAEventReader

- java.lang.Object
- - info.bioinfweb.jphyloio.AbstractEventReader<P>
  - - info.bioinfweb.jphyloio.formats.text.AbstractTextEventReader<TextReaderStreamDataProvider<FASTAEventReader>>
    - - info.bioinfweb.jphyloio.formats.fasta.FASTAEventReader

- All Implemented Interfaces:
    FASTAConstants, JPhyloIOEventReader, JPhyloIOFormatSpecificObject, ReadWriteConstants

      public class FASTAEventReader
      extends AbstractTextEventReader<TextReaderStreamDataProvider<FASTAEventReader>>
      implements FASTAConstants

  Event based reader for FASTA alignment files.

  This reader supports comments in lines following the name definition line. Additionally, indices preceding lines containing sequence data are allowed but are ignored by this reader.

  Example:

         >Sequence 1
         ;Some comment
         ;Another comment
          0 ACGT
          5 TAGC
         10 TTAGT
         >Sequence 2
         ACGT-ACC-TAGT

  This reader does not process the sequence names according to any conventions. The full string following '>' will be returned in each `SequenceTokensEvent` and can be parsed later on by the application.

  ### Recognized parameters

  - `ReadWriteParameterNames.KEY_MATCH_TOKEN`
  - `ReadWriteParameterNames.KEY_REPLACE_MATCH_TOKENS`
  - `ReadWriteParameterNames.KEY_MAXIMUM_TOKENS_TO_READ`
  - `ReadWriteParameterNames.KEY_MAXIMUM_COMMENT_LENGTH`
  Author:
    Ben Stöver

- - ### Field Summary

    - ### Fields inherited from class info.bioinfweb.jphyloio.formats.text.AbstractTextEventReader

      `lineConsumed`

    - ### Fields inherited from interface info.bioinfweb.jphyloio.formats.fasta.FASTAConstants

      `COMMENT_START_CHAR, DEFAULT_LINE_LENGTH, FASTA_FORMAT_NAME, NAME_START_CHAR`

    - ### 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
    `FASTAEventReader(java.io.BufferedReader reader, ReadWriteParameterMap parameters)` Creates a new instance of this class.
    `FASTAEventReader(java.io.File file, ReadWriteParameterMap parameters)` Creates a new instance of this class.
    `FASTAEventReader(java.io.InputStream stream, ReadWriteParameterMap parameters)` Creates a new instance of this class.
    `FASTAEventReader(java.io.Reader reader, ReadWriteParameterMap parameters)` Creates a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getFormatID()` Returns a string ID uniquely identifying the target format of this instance.
    `protected void` | `readNextEvent()` Method to be implemented be inherited classes that adds at least one additional event (determined from the underlying data source) to the event queue.

    - ### Methods inherited from class info.bioinfweb.jphyloio.formats.text.AbstractTextEventReader

      `close, consumeWhiteSpaceAndComments, createStreamDataProvider, createTokenList, getReader, readCharacters, readCharacters, readComment, readKeyValueInformation, readToken`

    - ### Methods inherited from class info.bioinfweb.jphyloio.AbstractEventReader

      `addEventListener, fireEvent, getCurrentEventCollection, getIDManager, getLastNonCommentEvent, getParameters, getParentInformation, getPreviousEvent, getSequenceTokensEventManager, getStreamDataProvider, getUpcomingEvents, hasNextEvent, hasSpecialEventCollection, isBeforeFirstAccess, next, nextOfType, peek, removeEventListener, resetCurrentEventCollection, setCurrentEventCollection`

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

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

- - ### Constructor Detail

    - #### FASTAEventReader

          public FASTAEventReader(java.io.BufferedReader reader,
                                  ReadWriteParameterMap parameters)
                           throws java.io.IOException

      Creates a new instance of this class.
      Parameters:
        `reader` - the reader providing the FASTA data to be read
        `parameters` - the parameter map for this reader instance
      Throws:
        `java.io.IOException` - if an I/O exception occurs while parsing the first event

    - #### FASTAEventReader

          public FASTAEventReader(java.io.File file,
                                  ReadWriteParameterMap parameters)
                           throws java.io.IOException

      Creates a new instance of this class.
      Parameters:
        `file` - the FASTA file to be read
        `parameters` - the parameter map for this reader instance
      Throws:
        `java.io.IOException` - if an I/O exception occurs while parsing the first event

    - #### FASTAEventReader

          public FASTAEventReader(java.io.InputStream stream,
                                  ReadWriteParameterMap parameters)
                           throws java.io.IOException

      Creates a new instance of this class.
      Parameters:
        `stream` - the stream providing the FASTA data to be read
        `parameters` - the parameter map for this reader instance
      Throws:
        `java.io.IOException` - if an I/O exception occurs while parsing the first event

    - #### FASTAEventReader

          public FASTAEventReader(java.io.Reader reader,
                                  ReadWriteParameterMap parameters)
                           throws java.io.IOException

      Creates a new instance of this class.
      Parameters:
        `reader` - the reader providing the FASTA data to be read
        `parameters` - the parameter map for this reader instance
      Throws:
        `java.io.IOException` - if an I/O exception occurs while parsing the first event

  - ### Method Detail

    - #### getFormatID

          public java.lang.String getFormatID()

      Description copied from interface: `JPhyloIOFormatSpecificObject`
      Returns a string ID uniquely identifying the target format of this instance. Additional information on the format can be retrieved by passing the returned ID to `JPhyloIOReaderWriterFactory.getFormatInfo(String)`.

      Third party developers that create readers or writers for additional formats must make sure to use a globally unique format ID. It is strongly recommended to use owned reverse domain names for this (e.g. `org.example.additionalformat`).

      Specified by:
        `getFormatID` in interface `JPhyloIOFormatSpecificObject`
      Returns:
        the ID of the target format of this instance
      See Also:
        `JPhyloIOReaderWriterFactory.getFormatInfo(String)`

    - #### readNextEvent

          protected void readNextEvent()
                                throws java.io.IOException

      Description copied from class: `AbstractEventReader`
      Method to be implemented be inherited classes that adds at least one additional event (determined from the underlying data source) to the event queue.
      Specified by:
        `readNextEvent` in class `AbstractEventReader<TextReaderStreamDataProvider<FASTAEventReader>>`
      Throws:
        `java.io.IOException`