public class NewickStringWriter extends java.lang.Object implements NewickConstants
NewickEventWriter
and NexusEventWriter
.NewickEventWriter
,
NexusEventWriter
,
Metadata demo applicationALLOCATION_SEPARATOR_SYMBOL, ALLOCATION_SYMBOL, ALTERNATIVE_NAME_DELIMITER, COMMENT_END, COMMENT_START, DATA_TYPE_NEWICK_ARRAY, E_NEWICK_EDGE_TYPE_HYBRIDIZATION, E_NEWICK_EDGE_TYPE_LATERAL_GENE_TRANSFER, E_NEWICK_EDGE_TYPE_RECOMBINATION, E_NEWICK_NAMESPACE_PREFIX, E_NEWICK_NETWORK_DATA_SEPARATOR, ELEMENT_SEPERATOR, FIELD_END_SYMBOL, FIELD_START_SYMBOL, FIELD_VALUE_SEPARATOR_SYMBOL, FREE_NAME_BLANK, HOT_COMMENT_START_SYMBOL, INDEX_END_SYMBOL, INDEX_START_SYMBOL, LENGTH_SEPERATOR, NAME_DELIMITER, NEWICK_DATA_TYPE_NAMESPACE, NEWICK_FORMAT_NAME, NEWICK_NAMESPACE_PREFIX, NHX_KEY_CONFIDENCE, NHX_KEY_EVENT, NHX_KEY_GENE_NAME, NHX_KEY_PREFIX, NHX_KEY_SCIENTIFIC_NAME, NHX_KEY_SEQUENCE_ACCESSION, NHX_KEY_TAXONOMY_ID, NHX_START, NHX_VALUE_SEPARATOR_SYMBOL, PREDICATE_E_NEWICK_EDGE_TYPE, ROOTED_HOT_COMMENT, SUBTREE_END, SUBTREE_START, TERMINAL_SYMBOL, UNROOTED_HOT_COMMENT
Constructor and Description |
---|
NewickStringWriter(TextWriterStreamDataProvider<?> streamDataProvider,
TreeNetworkDataAdapter tree,
NewickWriterNodeLabelProcessor nodeLabelProcessor,
ReadWriteParameterMap parameters)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatToken(java.lang.String token,
char delimiter) |
static boolean |
isFreeNameCharForWriting(char c) |
void |
write()
Writes the tree data specified in the constructor to the specified stream.
|
public NewickStringWriter(TextWriterStreamDataProvider<?> streamDataProvider, TreeNetworkDataAdapter tree, NewickWriterNodeLabelProcessor nodeLabelProcessor, ReadWriteParameterMap parameters)
writer
- the writer to write the Newick string totree
- the tree data adapter providing the tree data to be writtenotuList
- the list of OTU definitions to be used to label unlabeled tree nodes (Maybe null
.)useOTUFirst
- Specify true
here, if
AbstractEventWriter#getLinkedOTUNameOTUFirst(LinkedLabeledIDEvent, OTUListDataAdapter)
shall be used to determine node names (e.g. for writing Nexus) or false
if
AbstractEventWriter#getLinkedOTUNameOwnFirst(LinkedLabeledIDEvent, OTUListDataAdapter)
should be used instead (e.g. for writing Newick).parameters
- the write parameter map specified to the calling readerpublic static boolean isFreeNameCharForWriting(char c)
public static java.lang.String formatToken(java.lang.String token, char delimiter)
public void write() throws java.io.IOException
If the specified tree/network data adapter models a phylogenetic network and not a tree, nothing is written and an according warning is logged. Additionally warnings are logged, if the tree adapter provides metadata or if multiple root edges are available.
If an empty tree definition (with no root edge) is specified, the written Newick string
only consists of the terminal symbol ';'
.
java.io.IOException
- if an I/O error occurs while writing to specified writer