public class NewickTreeParser extends Object
Modifier and Type | Field and Description |
---|---|
private int |
branchLabel |
private String |
newickString |
Constructor and Description |
---|
NewickTreeParser()
Create the parser.
|
NewickTreeParser(String newickFile)
Create the parser.
|
Modifier and Type | Method and Description |
---|---|
private PhyloNode |
addNodeToTree(String node,
Tree<PhyloNode,Edge<PhyloNode>> tree,
PhyloNode parent,
boolean createUniqueName)
Given a string that represents a node in the tree, split in into its constituent name and distance components and
add it to the tree.
|
private Collection<String> |
findNodes(String tree)
Parse a tree splitting it into top level nodes and subtrees.
|
private int |
getClosingParenthesis(String strng)
Get the index of the closing parenthesis in a string that starts with an opening parenthesis.
|
Tree<PhyloNode,Edge<PhyloNode>> |
parse()
Parse a string from a Newick file.
|
Tree<PhyloNode,Edge<PhyloNode>> |
parse(String newickStr)
Parse a given string that MUST be a valid Newick format.
|
private void |
parseNode(String node,
Tree<PhyloNode,Edge<PhyloNode>> tree,
PhyloNode parent)
Parse a string containing information on a node in Newick format and attach it to a given tree.
|
private void |
parseString(String stringToParse,
PhyloNode parent,
Tree<PhyloNode,Edge<PhyloNode>> tree)
Parse a string in Newick format (where the root node has been removed) recursively.
|
private String newickString
private int branchLabel
public NewickTreeParser(String newickFile)
newickFile
- the name of the file containing the tree.public NewickTreeParser()
public final Tree<PhyloNode,Edge<PhyloNode>> parse(String newickStr)
newickStr
- the string to parse.public final Tree<PhyloNode,Edge<PhyloNode>> parse()
private void parseString(String stringToParse, PhyloNode parent, Tree<PhyloNode,Edge<PhyloNode>> tree)
stringToParse
- the string to be parsed.parent
- the parent node for the string (initially this is the root node but will be a brach node if
this method is called recursively).tree
- the tree to which the created nodes will be attached.private Collection<String> findNodes(String tree)
tree
- the tree tp be parsed.private int getClosingParenthesis(String strng)
strng
- the string to examine.private void parseNode(String node, Tree<PhyloNode,Edge<PhyloNode>> tree, PhyloNode parent)
node
- the string containing the node information.tree
- the tree to which the created node will be attached.parent
- the node on the tree to which the new node will be created.private PhyloNode addNodeToTree(String node, Tree<PhyloNode,Edge<PhyloNode>> tree, PhyloNode parent, boolean createUniqueName)
node
- the string representing the node.tree
- the tree object on which the node will be placed.parent
- the parent node to which this node is attached.createUniqueName
- if the name of the node is not unique then add create a unique one if this is true.Copyright © 2015 University of Glasgow. All rights reserved.