public class PhylipEventWriter extends AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<PhylipEventWriter>> implements PhylipConstants
This write is able to write sequence data to Phylip formatted streams. It will ignore any data for phylogenetic
trees and networks that are provided by DocumentDataAdapter#getTreeNetworkIterator(ReadWriteParameterMap), because the Phylip
format does not support such data.
Note that sequence names may have to be edited according to the (length) constrains the Phylip format imposes.
According edits can be obtained using the LabelEditingReporter which is returned via the parameters map
(using ReadWriteParameterNames.KEY_LABEL_EDITING_REPORTER).
Since Phylip 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 Phylip.
Comments and metadata nested in any of the supported elements will be ignored.
Recognized parameters:
ReadWriteParameterNames.KEY_SEQUENCE_EXTENSION_TOKENReadWriteParameterNames.KEY_MAXIMUM_NAME_LENGTHReadWriteParameterNames.KEY_LABEL_EDITING_REPORTERReadWriteParameterNames.KEY_LOGGERReadWriteParameterNames.KEY_LINE_SEPARATORReadWriteParameterNames.KEY_MAXIMUM_NAME_LENGTH (If this parameter is omitted, PhylipConstants.DEFAULT_NAME_LENGTH will be used.)ReadWriteParameterNames.KEY_LABEL_EDITING_REPORTERAbstractEventWriter.NoEditUniqueLabelHandler, AbstractEventWriter.UniqueLabelHandlerEDITED_LABEL_SEPARATORDEFAULT_NAME_LENGTH, PHYLIP_FORMAT_NAME, PREMATURE_NAME_END_CHARACTER, RELAXED_PHYLIP_NAME_PATTERN, SEQUENTIAL_PHYLIP_FORMAT_NAME| Constructor and Description |
|---|
PhylipEventWriter()
Creates a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
protected TextWriterStreamDataProvider<PhylipEventWriter> |
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) |
static java.lang.String |
maskReservedPhylipLabelCharacters(java.lang.String label)
Replaces characters that may not occur in Phylip labels according to
this definition.
|
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, editSequenceOrNodeLabelgetWritercreateUniqueLabel, createUniqueLabel, createUniqueLabel, createUniqueLinkedOTULabel, decreaseIndention, determineMaxSequenceLength, extendSequence, getFileStartInfo, getIndention, getLabeledIDName, getLinkedOTUNameOTUFirst, getLinkedOTUNameOwnFirst, getReferencedOTUList, getStreamDataProvider, increaseIndention, logIngnoredOTULists, writeDocument, writeDocument, writeDocument, writeLineBreak, writeLineStartpublic PhylipEventWriter()
#writeDocument() methods.)public java.lang.String getFormatID()
JPhyloIOFormatSpecificObjectJPhyloIOReaderWriterFactory.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 JPhyloIOFormatSpecificObjectJPhyloIOReaderWriterFactory.getFormatInfo(String)protected TextWriterStreamDataProvider<PhylipEventWriter> createStreamDataProvider()
AbstractEventWriterAbstractEventWriter 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<PhylipEventWriter>>public static java.lang.String maskReservedPhylipLabelCharacters(java.lang.String label)
The following replacements are performed:
'(' → '<'')' → '>''[' → '<'']' → '>'':' → '|'';' → '|'',' → '|'label - the label to be editedprotected java.lang.String maskReservedLabelCharacters(java.lang.String label)
maskReservedLabelCharacters in class AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<PhylipEventWriter>>protected void writeSingleMatrix(DocumentDataAdapter document, MatrixDataAdapter matrix, java.util.Iterator<java.lang.String> sequenceIDIterator, ReadWriteParameterMap parameters) throws java.io.IOException
AbstractSingleMatrixEventWriterwriteSingleMatrix in class AbstractSingleMatrixEventWriter<TextWriterStreamDataProvider<PhylipEventWriter>>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