public class NewickStringReader extends Object implements ReadWriteConstants
NewickEventReader
and TreeReader
.
Any whitespace, as well as comments contained in '['
and ']'
is allowed between all tokens.
Additionally this reader is able to parse hot comments associated with nodes or edges as metadata as they are used in the output of TreeAnnotator or MrBayes. (See here for a definition.) The following format of hot comments is recognized by this reader:
[&numericValue1=1.05, numericValue2 = 2.76e-5, stringValue1="12", stringValue2=ABC, arrayValue={18, "AB C"}]Each hot comment needs to start with an
'&'
and can contain one or more key/value pairs separated by
','
. Each value can either be a numeric value, a string value or an array value. Arrays are indicated
by braces and array elements are separated by ','
, as shown in the example above. Array elements maybe
any numeric or string value in any combination. Whitespace between tokens of a hot comment is allowed but not
necessary.
In addition, NHX hot comments can be read and are associated with according PhyloXML predicates, of possible. Note that the NHX key is not converted, since there is no directly equivalent PhyloXML predicate.
Hot comments following a node name or a subtree are considered a metadata attached to a node and hot comments following a branch length definition are considered to be attached to an edge (branch). Subsequent hot comments are combined, with the exception that a branch length definition is omitted. In such a case, the first hot comment is considered to attached to the node and all subsequent hot comments are considered to be attached to the edge.
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 and Description |
---|
NewickStringReader(TextReaderStreamDataProvider<?> streamDataProvider,
String treeID,
String treeLabel,
NewickReaderNodeLabelProcessor nodeLabelProcessor)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addNextEvents()
Creates the next JPhyloIO event(s) from the Newick string provided by the underlying reader.
|
void |
processTree()
Read the contents of a Newick string and generates JPhyloIO events from it.
|
public NewickStringReader(TextReaderStreamDataProvider<?> streamDataProvider, String treeID, String treeLabel, NewickReaderNodeLabelProcessor nodeLabelProcessor)
streamDataProvider
- the stream data provider that allows this reader to access the necessary event reader propertiestreeLabel
- the label of the tree to be read (This parameter also determines whether one or more trees shall be read
from the underlying reader. If a string is specified, only one tree is read and the specified label is used for it.
If null
is specified, multiple trees are read until the end of the file is reached. None of them gets a
defined label.)nodeLabelProcessor
- the node label processor to be used to possibly translate node labels in Newick stringsNullPointerException
- if streamDataProvider
or nodeLabelProcessor
are null
public void processTree() throws IOException
IOException
public boolean addNextEvents() throws IOException
true
if more events were add to the queue or false
if reading of the current tree(s)
is finished.IOException