public class FASTAEventWriter extends AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<FASTAEventWriter>> implements FASTAConstants
This write is able to write sequence data to FASTA formatted streams. It will ignore any data for phylogenetic
trees and networks that are provided by DocumentDataAdapter#getTreeNetworkIterator(ReadWriteParameterMap)
, because the
FASTA format does not support such data.
Since FASTA does not support OTU or taxon lists as well, such a list (if provided by
DocumentDataAdapter.getOTUListIterator(ReadWriteParameterMap)
) will also not be written. OTU definitions (if present)
will though be used, if a sequence with a linked OTU ID but without a label is specified. In such cases
OTUListDataAdapter#getOTUStartEvent(String)
will be used to determine the according OTU label. If that OTU
label is also null
, the sequence ID will be used as the sequence name in FASTA.
Comments and metadata nested in any of the supported elements will be ignored, with the only exception of comments before the first token of a sequence. Such comments will be included in FASTA, since this is only valid position for comments in the format.
ReadWriteParameterNames.KEY_LOGGER
ReadWriteParameterNames.KEY_SEQUENCE_EXTENSION_TOKEN
ReadWriteParameterNames.KEY_LINE_LENGTH
ReadWriteParameterNames.KEY_WRITER_INSTANCE
ReadWriteParameterNames.KEY_LINE_SEPARATOR
ReadWriteParameterNames.KEY_MAXIMUM_NAME_LENGTH
(If this parameter is omitted, any name length is possible.)ReadWriteParameterNames.KEY_LABEL_EDITING_REPORTER
AbstractEventWriter.NoEditUniqueLabelHandler, AbstractEventWriter.UniqueLabelHandler
EDITED_LABEL_SEPARATOR
COMMENT_START_CHAR, DEFAULT_LINE_LENGTH, FASTA_FORMAT_NAME, NAME_START_CHAR
Constructor and Description |
---|
FASTAEventWriter() |
Modifier and Type | Method and Description |
---|---|
protected TextWriterStreamDataProvider<FASTAEventWriter> |
createStreamDataProvider()
This method is called in the constructor of
AbstractEventWriter to initialize the stream
data provider that will be returned by AbstractEventWriter.getStreamDataProvider() . |
java.lang.String |
getFormatID()
Returns a string ID uniquely identifying the target format of this instance.
|
protected java.lang.String |
maskReservedLabelCharacters(java.lang.String label) |
protected void |
writeSingleMatrix(DocumentDataAdapter document,
MatrixDataAdapter matrix,
java.util.Iterator<java.lang.String> sequenceIDIterator,
ReadWriteParameterMap parameters)
Implementations of this method should write a single matrix to their target format.
|
doWriteDocument, editSequenceOrNodeLabel
getWriter
createUniqueLabel, createUniqueLabel, createUniqueLabel, createUniqueLinkedOTULabel, decreaseIndention, determineMaxSequenceLength, extendSequence, getFileStartInfo, getIndention, getLabeledIDName, getLinkedOTUNameOTUFirst, getLinkedOTUNameOwnFirst, getReferencedOTUList, getStreamDataProvider, increaseIndention, logIngnoredOTULists, writeDocument, writeDocument, writeDocument, writeLineBreak, writeLineStart
public FASTAEventWriter()
public java.lang.String getFormatID()
JPhyloIOFormatSpecificObject
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
).
getFormatID
in interface JPhyloIOFormatSpecificObject
JPhyloIOReaderWriterFactory.getFormatInfo(String)
protected TextWriterStreamDataProvider<FASTAEventWriter> createStreamDataProvider()
AbstractEventWriter
AbstractEventWriter
to initialize the stream
data provider that will be returned by AbstractEventWriter.getStreamDataProvider()
. Inheriting classes that use
their own stream data provider implementation should overwrite this method.
This default implementation creates a new instance of WriterStreamDataProvider
.
createStreamDataProvider
in class AbstractEventWriter<TextWriterStreamDataProvider<FASTAEventWriter>>
protected java.lang.String maskReservedLabelCharacters(java.lang.String label)
maskReservedLabelCharacters
in class AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<FASTAEventWriter>>
protected void writeSingleMatrix(DocumentDataAdapter document, MatrixDataAdapter matrix, java.util.Iterator<java.lang.String> sequenceIDIterator, ReadWriteParameterMap parameters) throws java.io.IOException
AbstractSingleMatrixEventWriter
writeSingleMatrix
in class AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<FASTAEventWriter>>
document
- the document containing the matrixmatrix
- the (non-empty) matrix to be writtensequenceIDIterator
- an iterator oder all sequences in matrix
positioned before the first sequenceparameters
- the parameter map for the writer implementationjava.io.IOException