Class TreesBlock

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TreesBlock.NewickTreeString
      A simple representation of a Newick tree as a single string.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String TREES_BLOCK
      A constant representing the name of Trees blocks.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreesBlock()
      Delegates to NexusBlock.Abstract constructor using TreesBlock.TREES_BLOCK as the name.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addComment​(NexusComment comment)
      Adds a comment.
      void addTranslation​(java.lang.String label, java.lang.String taxa)
      Add a translation.
      void addTree​(java.lang.String label, TreesBlock.NewickTreeString tree)
      Adds a tree.
      void addTree​(java.lang.String label, org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph)
      Deprecated. 
      void addTree​(java.lang.String label, org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph, java.lang.String topLabel)
      Add a tree, converting weighted graph (JGraphT) to NewickString.
      boolean containsTranslation​(java.lang.String label)
      Checks to see if we contain the given translation.
      boolean containsTree​(java.lang.String label)
      Checks to see if we contain the given tree.
      java.util.List getComments()
      Returns all comments.
      java.lang.String getNodePrefix()
      Returns the node prefix.
      java.lang.String getTopNode()
      Returns the top node of the previously requested graph.
      java.util.Map getTranslations()
      Get the translations added so far.
      java.lang.Object getTree​(java.lang.String label)
      Returns a tree for given label
      org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> getTreeAsWeightedJGraphT​(java.lang.String label)
      Get given (NewickString) tree by label, converts it to weighted graph (JGraphT).
      java.util.Map getTrees()
      Returns all trees.
      java.lang.String getTreeText​(org.jgrapht.UndirectedGraph<java.lang.String,​org.jgrapht.graph.DefaultEdge> treegraph, java.lang.String node, java.lang.String parent)  
      java.lang.String getTreeText​(org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph, java.lang.String node, java.lang.String parent)  
      void removeComment​(NexusComment comment)
      Removes a comment.
      void removeTranslation​(java.lang.String label)
      Removes the given translation.
      void removeTree​(java.lang.String label)
      Removes a tree.
      void setNodePrefix​(java.lang.String prefix)
      Sets the node prefix of intermediate nodes for returned graphs.
      protected void writeBlockContents​(java.io.Writer writer)
      Implement this to write out block contents, not including the BEGIN and END tags.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TreesBlock

        public TreesBlock()
        Delegates to NexusBlock.Abstract constructor using TreesBlock.TREES_BLOCK as the name.
    • Method Detail

      • addTranslation

        public void addTranslation​(java.lang.String label,
                                   java.lang.String taxa)
        Add a translation.
        Parameters:
        label - the label to add.
        taxa - the taxa name this label will represent.
      • removeTranslation

        public void removeTranslation​(java.lang.String label)
        Removes the given translation.
        Parameters:
        label - the label to remove.
      • containsTranslation

        public boolean containsTranslation​(java.lang.String label)
        Checks to see if we contain the given translation.
        Parameters:
        label - the label to check for.
        Returns:
        true if we already contain it.
      • getTranslations

        public java.util.Map getTranslations()
        Get the translations added so far.
        Returns:
        the translations added so far.
      • addTree

        public void addTree​(java.lang.String label,
                            TreesBlock.NewickTreeString tree)
        Adds a tree.
        Parameters:
        label - the label to give the tree.
        tree - the tree to add.
      • removeTree

        public void removeTree​(java.lang.String label)
        Removes a tree.
        Parameters:
        label - the label to remove.
      • containsTree

        public boolean containsTree​(java.lang.String label)
        Checks to see if we contain the given tree.
        Parameters:
        label - the label to check for.
        Returns:
        true if we already contain it.
      • getTrees

        public java.util.Map getTrees()
        Returns all trees.
        Returns:
        all the selected trees.
      • getTree

        public java.lang.Object getTree​(java.lang.String label)
        Returns a tree for given label
        Parameters:
        label - the label to select.
        Returns:
        selected tree.
      • getTreeText

        public java.lang.String getTreeText​(org.jgrapht.UndirectedGraph<java.lang.String,​org.jgrapht.graph.DefaultEdge> treegraph,
                                            java.lang.String node,
                                            java.lang.String parent)
      • addTree

        public void addTree​(java.lang.String label,
                            org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph)
        Deprecated.
        Add a tree, converting weighted graph (JGraphT) to NewickString This will assume a (arbitrary) root node using the old convention of labeling intermediate nodes as p*.
        Parameters:
        label - the label to add
        treegraph - the treegraph to convert.
      • getTreeText

        public java.lang.String getTreeText​(org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph,
                                            java.lang.String node,
                                            java.lang.String parent)
      • addTree

        public void addTree​(java.lang.String label,
                            org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> treegraph,
                            java.lang.String topLabel)
        Add a tree, converting weighted graph (JGraphT) to NewickString.
        Parameters:
        label - the label to add
        treegraph - the treegraph to convert.
        topLabel - the label of the top (root if rooted tree) node.
      • getTreeAsWeightedJGraphT

        public org.jgrapht.WeightedGraph<java.lang.String,​org.jgrapht.graph.DefaultWeightedEdge> getTreeAsWeightedJGraphT​(java.lang.String label)
                                                                                                                         throws ParseException
        Get given (NewickString) tree by label, converts it to weighted graph (JGraphT). Alters this.weighted!
        Parameters:
        label - label for tree selection
        Returns:
        converted tree as undirectedGraph
        Throws:
        ParseException
      • addComment

        public void addComment​(NexusComment comment)
        Adds a comment.
        Parameters:
        comment - the comment to add.
      • removeComment

        public void removeComment​(NexusComment comment)
        Removes a comment.
        Parameters:
        comment - the comment to remove.
      • getComments

        public java.util.List getComments()
        Returns all comments.
        Returns:
        all the selected comments.
      • writeBlockContents

        protected void writeBlockContents​(java.io.Writer writer)
                                   throws java.io.IOException
        Description copied from class: NexusBlock.Abstract
        Implement this to write out block contents, not including the BEGIN and END tags.
        Specified by:
        writeBlockContents in class NexusBlock.Abstract
        Parameters:
        writer - the writer to write to.
        Throws:
        java.io.IOException - if writing failed.
      • getTopNode

        public java.lang.String getTopNode()
        Returns the top node of the previously requested graph. The topNode will be the root node if the tree is rooted, if not then it will just be the top most node of the newick string with no biological meaning. The top node from the #getTreeAsJGraphT(java.lang.String) and getTreeAsWeightedJGraphT(java.lang.String) might vary, and this function will return the top node of the previously called method only. If no method was called, null is returned. Note: the top node between graphs, probably does not vary, but, just in case, the note is here and the user should get a different top for each type of graph.
        Returns:
        the top node.
      • setNodePrefix

        public void setNodePrefix​(java.lang.String prefix)
        Sets the node prefix of intermediate nodes for returned graphs. The intermediate nodes of graphs have to be named, the conventions being: 1. Generate a new node name using a prefix plus an integer 2. If the node name clashes with any taxon name, use another integer
        Parameters:
        prefix - The prefix
      • getNodePrefix

        public java.lang.String getNodePrefix()
        Returns the node prefix.
        Returns:
        the node prefix