public class NexusEventWriter extends AbstractTextEventWriter<NexusWriterStreamDataProvider> implements NexusConstants
This writer is able to write OTU, sequence and tree data to Nexus formatted streams. It will ignore any data for
phylogenetic networks that are provided by DocumentDataAdapter#getTreeNetworkIterator(ReadWriteParameterMap), because the Nexus
format only supports trees.
NewickStringWriter.
Metadata nested into other elements will be ignored.
Sequence labels will be used though, if no OTU is linked. In such cases the NEWTAXA subcommand will be specified
in the DIMENSIONS command.
If an OTU event without a defined label is provided by the data adapter, this writer will use the OTU ID as the taxon
name in Nexus instead. If two OTUs with identical labels are provided, the Nexus name of the second will be a combination
of the ID and the label, while the first will be represented as the unchanged label as usual. If additional conflicts
occur (e.g. if an ID of an OTU without a label is equal to the label of a previous OTU) an index will be added to the end
of the label, until it is unique labels. The elements (ID, label, index) of edited Nexus names will be separated by
AbstractEventWriter.EDITED_LABEL_SEPARATOR.
The Nexus names that have actually been used in the output can be obtained from the LabelEditingReporter added
to the parameter map using ReadWriteParameterMap.getLabelEditingReporter(). (A reference to the parameter map
passed to one of the #writeDocument() methods must be kept by the application code, in order to access the
label editing reporter after the document has been written.)
FORMAT
command. According warnings will be logged, if multiple token sets are found.
NexusEventReader supports an extension of the Nexus format introduced by MrBayes but this writer
currently does not make use of that, since the output would not be conform with the Nexus standard and some
applications may not be able to read it.
ReadWriteParameterNames.KEY_WRITER_INSTANCEReadWriteParameterNames.KEY_LOGGERReadWriteParameterNames.KEY_APPLICATION_NAMEReadWriteParameterNames.KEY_APPLICATION_VERSIONReadWriteParameterNames.KEY_APPLICATION_URLReadWriteParameterNames.KEY_LINE_SEPARATORReadWriteParameterNames.KEY_SEQUENCE_EXTENSION_TOKENReadWriteParameterNames.KEY_MAXIMUM_NAME_LENGTH (If this parameter is omitted, any name length is possible.)ReadWriteParameterNames.KEY_ALWAYS_WRITE_NEXUS_NODE_LABELSReadWriteParameterNames.KEY_GENERATE_NEXUS_TRANSLATION_TABLEReadWriteParameterNames.KEY_LABEL_EDITING_REPORTERReadWriteParameterNames.KEY_OBJECT_TRANSLATOR_FACTORYAbstractEventWriter.NoEditUniqueLabelHandler, AbstractEventWriter.UniqueLabelHandlerEDITED_LABEL_SEPARATORALTERNATIVE_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| Constructor and Description |
|---|
NexusEventWriter() |
| Modifier and Type | Method and Description |
|---|---|
protected NexusWriterStreamDataProvider |
createStreamDataProvider()
This method is called in the constructor of
AbstractEventWriter to initialize the stream
data provider that will be returned by AbstractEventWriter.getStreamDataProvider(). |
protected void |
doWriteDocument(DocumentDataAdapter document,
java.io.Writer writer,
ReadWriteParameterMap parameters) |
static java.lang.String |
formatToken(java.lang.String token) |
java.lang.String |
getFormatID()
Returns a string ID uniquely identifying the target format of this instance.
|
protected ApplicationLogger |
getLogger() |
protected java.util.Map<java.lang.String,NexusMatrixWriteResult> |
getMatrixIDToBlockTypeMap() |
protected ReadWriteParameterMap |
getParameters() |
protected void |
writeBlockEnd() |
protected void |
writeBlockStart(java.lang.String name) |
protected void |
writeCommandEnd() |
static void |
writeKeyValueExpression(java.io.Writer writer,
java.lang.String key,
java.lang.String value) |
protected void |
writeLineStart(java.io.Writer writer,
java.lang.String text) |
protected void |
writeLinkCommand(java.lang.String linkedID,
java.lang.String linkedBlockName,
EventContentType linkedContentType) |
getWritercreateUniqueLabel, createUniqueLabel, createUniqueLabel, createUniqueLinkedOTULabel, decreaseIndention, determineMaxSequenceLength, extendSequence, getFileStartInfo, getIndention, getLabeledIDName, getLinkedOTUNameOTUFirst, getLinkedOTUNameOwnFirst, getReferencedOTUList, getStreamDataProvider, increaseIndention, logIngnoredOTULists, writeDocument, writeDocument, writeDocument, writeLineBreakpublic NexusEventWriter()
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 NexusWriterStreamDataProvider 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<NexusWriterStreamDataProvider>protected ReadWriteParameterMap getParameters()
protected ApplicationLogger getLogger()
protected java.util.Map<java.lang.String,NexusMatrixWriteResult> getMatrixIDToBlockTypeMap()
protected void writeLineStart(java.io.Writer writer, java.lang.String text) throws java.io.IOException
writeLineStart in class AbstractEventWriter<NexusWriterStreamDataProvider>java.io.IOExceptionpublic static java.lang.String formatToken(java.lang.String token)
protected void writeCommandEnd() throws java.io.IOException
java.io.IOExceptionprotected void writeBlockStart(java.lang.String name) throws java.io.IOException
java.io.IOExceptionprotected void writeBlockEnd() throws java.io.IOException
java.io.IOExceptionpublic static void writeKeyValueExpression(java.io.Writer writer, java.lang.String key, java.lang.String value) throws java.io.IOException
java.io.IOExceptionprotected void writeLinkCommand(java.lang.String linkedID, java.lang.String linkedBlockName, EventContentType linkedContentType) throws java.io.IOException
java.io.IOExceptionprotected void doWriteDocument(DocumentDataAdapter document, java.io.Writer writer, ReadWriteParameterMap parameters) throws java.io.IOException
doWriteDocument in class AbstractTextEventWriter<NexusWriterStreamDataProvider>java.io.IOException