Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

Field Summary
`static BranchLengthAdapter` | `BRANCH_LENGTH_ADAPTER`
`private NodeBranchDataAdapter` | `branchLengthsAdapter`
`private CommentDataReader` | `commentDataReader`
`private boolean` | `hiddenDataAdded`
`private NodeBranchDataAdapter` | `internalAdapter`
`static NodeNameAdapter` | `LEAF_ADAPTER`
`private static NewickStringReader` | `sharedInstance`
`private java.util.List<NewickToken>` | `tokens`
`private boolean` | `translateInternals`
`private TranslTable` | `translTable`

Fields inherited from class info.bioinfweb.treegraph.document.io.newick.NewickStringChars
`COMMENT_END, COMMENT_START, ELEMENT_SEPERATOR, FREE_NAME_BLANK, LENGTH_SEPERATOR, NAME_DELIMITER, SUBTREE_END, SUBTREE_START, TERMINAL_SYMBOL`

Constructor Summary
`NewickStringReader()`

Method Summary
`boolean` | `getHiddenDataAdded()` Returns whether hidden data has been read from commetns in the newick string (e.g. from BEAST) during the last call of `read(String, NodeBranchDataAdapter, NodeBranchDataAdapter, TranslTable, boolean)` or one of its convenience methods.
`static NewickStringReader` | `getSharedInstance()`
`Tree` | `read(java.lang.String newick)`
`static Tree[]` | `read(java.lang.String[] newick, NodeBranchDataAdapter internalAdapter, NodeBranchDataAdapter branchLengthsAdapter, TranslTable translTable, boolean translateInternals)`
`Tree` | `read(java.lang.String newick, NodeBranchDataAdapter internalAdapter, NodeBranchDataAdapter branchLengthsAdapter)`
`Tree` | `read(java.lang.String newick, NodeBranchDataAdapter internalAdapter, NodeBranchDataAdapter branchLengthsAdapter, TranslTable translTable, boolean translateInternals)`
`private Node` | `readBranch(int start, int end, Node root)`
`private void` | `readBranchList(int start, int end, Node root)`
`private Node` | `readInternal(int start, int end)`
`private Node` | `readLeaf(int start, int end)`
`private void` | `readName(int previousEnd, int end, Node root, NodeBranchDataAdapter adapter, TranslTable translTable)`
`private Node` | `readSubtree(int start, int end)`
`private Tree` | `readTree()`
`private int` | `searchSubtreeEnd(int start, int end)`
`private int` | `searchToken(int start, int end, TokenType type)`

Methods inherited from class info.bioinfweb.treegraph.document.io.newick.NewickStringChars
`isCharAfterLength, isFreeNameChar, isFreeNameFirstChar`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LEAF_ADAPTER

    public static final NodeNameAdapter LEAF_ADAPTER

### BRANCH_LENGTH_ADAPTER

    public static final BranchLengthAdapter BRANCH_LENGTH_ADAPTER

### sharedInstance

    private static NewickStringReader sharedInstance

### tokens

    private java.util.List<NewickToken> tokens

### internalAdapter

    private NodeBranchDataAdapter internalAdapter

### branchLengthsAdapter

    private NodeBranchDataAdapter branchLengthsAdapter

### translTable

    private TranslTable translTable

### translateInternals

    private boolean translateInternals

### hiddenDataAdded

    private boolean hiddenDataAdded

### commentDataReader

    private CommentDataReader commentDataReader

Constructor Detail

### NewickStringReader

    public NewickStringReader()

Method Detail

### getSharedInstance

    public static NewickStringReader getSharedInstance()

### searchSubtreeEnd

    private int searchSubtreeEnd(int start,
                                 int end)

### searchToken

    private int searchToken(int start,
                            int end,
                            TokenType type)

### readBranch

    private Node readBranch(int start,
                            int end,
                            Node root)
                     throws NewickException

  Throws:
    `NewickException`

### readBranchList

    private void readBranchList(int start,
                                int end,
                                Node root)
                         throws NewickException

  Throws:
    `NewickException`

### readName

    private void readName(int previousEnd,
                          int end,
                          Node root,
                          NodeBranchDataAdapter adapter,
                          TranslTable translTable)
                   throws NewickException

  Throws:
    `NewickException`

### readInternal

    private Node readInternal(int start,
                              int end)
                       throws NewickException

  Throws:
    `NewickException`

### readLeaf

    private Node readLeaf(int start,
                          int end)
                   throws NewickException

  Throws:
    `NewickException`

### readSubtree

    private Node readSubtree(int start,
                             int end)
                      throws NewickException

  Throws:
    `NewickException`

### readTree

    private Tree readTree()
                   throws NewickException

  Throws:
    `NewickException`

### getHiddenDataAdded

    public boolean getHiddenDataAdded()

  Returns whether hidden data has been read from commetns in the newick string (e.g. from BEAST) during the last call of `read(String, NodeBranchDataAdapter, NodeBranchDataAdapter, TranslTable, boolean)` or one of its convenience methods.

  Returns:

### read

    public Tree read(java.lang.String newick)
              throws NewickException

  Throws:
    `NewickException`

### read

    public Tree read(java.lang.String newick,
                     NodeBranchDataAdapter internalAdapter,
                     NodeBranchDataAdapter branchLengthsAdapter)
              throws NewickException

  Throws:
    `NewickException`

### read

    public Tree read(java.lang.String newick,
                     NodeBranchDataAdapter internalAdapter,
                     NodeBranchDataAdapter branchLengthsAdapter,
                     TranslTable translTable,
                     boolean translateInternals)
              throws NewickException

  Throws:
    `NewickException`

### read

    public static Tree[] read(java.lang.String[] newick,
                              NodeBranchDataAdapter internalAdapter,
                              NodeBranchDataAdapter branchLengthsAdapter,
                              TranslTable translTable,
                              boolean translateInternals)
                       throws NewickException

  Throws:
    `NewickException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD