info.bioinfweb.treegraph.document.io.newick
Class NewickStringReader
java.lang.Object
info.bioinfweb.treegraph.document.io.newick.NewickStringChars
info.bioinfweb.treegraph.document.io.newick.NewickStringReader
public class NewickStringReader
- extends NewickStringChars
This class converts a tree in the newick format to a Document. First
the string is decomposed into Tokens by a NewickParser and then the
developed token list is syntactically analyzed. The following grammar is used:
Tree --> Branch TERMINAL_SYMBOL
Subtree --> Leaf | Internal
Leaf --> Name
Internal --> SUBTREE_START BranchList SUBTREE_END Name
BranchList --> Branch | Branch ELEMENT_SEPERATOR BranchList
Branch --> Subtree Length
Name --> ε | NAME
Length --> ε | LENGTH
Note that this grammar differs from the usual Newick grammar becuase it allows
the root node to have a branch length.
- Author:
- Ben Stöver
|
Method Summary |
static Tree |
read(String newick)
|
static Tree |
read(String newick,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter)
|
static Tree |
read(String newick,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static Node |
readBranch(Vector<NewickToken> tokens,
int start,
int end,
Node root,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static void |
readBranchList(Vector<NewickToken> tokens,
int start,
int end,
Node root,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static Node |
readInternal(Vector<NewickToken> tokens,
int start,
int end,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static Node |
readLeaf(Vector<NewickToken> tokens,
int start,
int end,
TranslTable translTable)
|
private static void |
readName(Vector<NewickToken> tokens,
int previousEnd,
int end,
Node root,
NodeDataAdapter internalAdapter,
TranslTable translTable)
|
private static Node |
readSubtree(Vector<NewickToken> tokens,
int start,
int end,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static Tree |
readTree(Vector<NewickToken> tokens,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter,
TranslTable translTable,
boolean translateInternals)
|
private static int |
searchSubtreeEnd(Vector<NewickToken> tokens,
int start,
int end)
|
private static int |
searchToken(Vector<NewickToken> tokens,
int start,
int end,
TokenType type)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LEAF_ADAPTER
public static final NodeNameAdapter LEAF_ADAPTER
BRANCH_LENGTH_ADAPTER
public static final BranchLengthAdapter BRANCH_LENGTH_ADAPTER
NewickStringReader
public NewickStringReader()
searchSubtreeEnd
private static int searchSubtreeEnd(Vector<NewickToken> tokens,
int start,
int end)
searchToken
private static int searchToken(Vector<NewickToken> tokens,
int start,
int end,
TokenType type)
readBranch
private static Node readBranch(Vector<NewickToken> tokens,
int start,
int end,
Node root,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException
readBranchList
private static void readBranchList(Vector<NewickToken> tokens,
int start,
int end,
Node root,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException
readName
private static void readName(Vector<NewickToken> tokens,
int previousEnd,
int end,
Node root,
NodeDataAdapter internalAdapter,
TranslTable translTable)
throws NewickException
- Throws:
NewickException
readInternal
private static Node readInternal(Vector<NewickToken> tokens,
int start,
int end,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException
readLeaf
private static Node readLeaf(Vector<NewickToken> tokens,
int start,
int end,
TranslTable translTable)
throws NewickException
- Throws:
NewickException
readSubtree
private static Node readSubtree(Vector<NewickToken> tokens,
int start,
int end,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException
readTree
private static Tree readTree(Vector<NewickToken> tokens,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException
read
public static Tree read(String newick)
throws NewickException
- Throws:
NewickException
read
public static Tree read(String newick,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter)
throws NewickException
- Throws:
NewickException
read
public static Tree read(String newick,
NodeDataAdapter internalAdapter,
NodeDataAdapter branchLengthsAdapter,
TranslTable translTable,
boolean translateInternals)
throws NewickException
- Throws:
NewickException