2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // Copyright (C) 2000-2001 Washington University School of Medicine
8 // and Howard Hughes Medical Institute
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 // Contact: phylosoft @ gmail . com
26 // WWW: www.phylosoft.org/forester
28 package org.forester.phylogeny;
30 import java.util.ArrayList;
31 import java.util.List;
33 import org.forester.io.parsers.nhx.NHXFormatException;
34 import org.forester.io.parsers.nhx.NHXParser;
35 import org.forester.phylogeny.data.BranchData;
36 import org.forester.phylogeny.data.NodeData;
37 import org.forester.phylogeny.iterators.ChildNodeIteratorForward;
38 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
39 import org.forester.phylogeny.iterators.PreorderTreeIterator;
40 import org.forester.util.ForesterUtil;
42 public class PhylogenyNode implements PhylogenyNodeI, Comparable<PhylogenyNode> {
44 /** Value of -99.0 is used as default value. */
45 public final static double DISTANCE_DEFAULT = -1024.0;
46 private static int _node_count = 0;
47 private byte _indicator;
49 private int _sum_ext_nodes;
52 private double _distance_parent;
53 private boolean _collapse;
54 private PhylogenyNode _parent;
55 private PhylogenyNode _link;
56 private ArrayList<PhylogenyNode> _descendants;
57 private NodeData _node_data;
58 private BranchData _branch_data;
59 private float _x_secondary;
60 private float _y_secondary;
63 * Default constructor for PhylogenyNode.
65 public PhylogenyNode() {
67 setId( PhylogenyNode.getNodeCount() );
68 PhylogenyNode.increaseNodeCount();
69 setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!)
73 * Adds PhylogenyNode n to the list of child nodes and sets the _parent of n
77 * the PhylogenyNode to add
80 final public void addAsChild( final PhylogenyNodeI node ) {
81 final PhylogenyNode n = ( PhylogenyNode ) node;
87 * Adds PhylogenyNode n to the list of child nodes. But does NOT set the
88 * _parent of n to this.
90 * @see addAsChild( PhylogenyNode n )
92 * the PhylogenyNode to add
94 final private void addChildNode( final PhylogenyNode child ) {
95 getDescendants().add( child );
99 final public int compareTo( final PhylogenyNode o ) {
100 final PhylogenyNode n = o;
101 if ( ( getName() == null ) || ( n.getName() == null ) ) {
104 return getName().compareTo( n.getName() );
107 // ---------------------------------------------------------
108 // Copy and delete Nodes, copy subtress
109 // ---------------------------------------------------------
111 * Returns a new PhylogenyNode which has its data copied from this
112 * PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
113 * copied (e.g. _link to _parent). Field "_link" IS copied.
117 final public PhylogenyNode copyNodeData() {
118 final PhylogenyNode node = new PhylogenyNode();
119 PhylogenyNode.decreaseNodeCount();
121 node._sum_ext_nodes = _sum_ext_nodes;
122 node._indicator = _indicator;
125 node._distance_parent = _distance_parent;
126 node._collapse = _collapse;
128 if ( _node_data != null ) {
129 node._node_data = ( NodeData ) _node_data.copy();
131 if ( _branch_data != null ) {
132 node._branch_data = ( BranchData ) _branch_data.copy();
138 * Returns a new PhylogenyNode which has the same data as this
139 * PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT
140 * copied (e.g. _link to _parent). Field "_link" IS copied.
144 final public PhylogenyNode copyNodeDataShallow() {
145 final PhylogenyNode node = new PhylogenyNode();
146 PhylogenyNode.decreaseNodeCount();
148 node._sum_ext_nodes = _sum_ext_nodes;
149 node._indicator = _indicator;
152 node._distance_parent = _distance_parent;
153 node._collapse = _collapse;
155 node._node_data = _node_data;
156 node._branch_data = _branch_data;
162 * Based on node name, sequence, and taxonomy.
166 final public boolean equals( final Object o ) {
170 else if ( o == null ) {
173 else if ( o.getClass() != this.getClass() ) {
174 throw new IllegalArgumentException( "attempt to check [" + this.getClass() + "] equality to " + o + " ["
175 + o.getClass() + "]" );
178 final PhylogenyNode other = ( PhylogenyNode ) o;
179 if ( !getName().equals( other.getName() ) ) {
182 final NodeData this_data = getNodeData();
183 final NodeData other_data = other.getNodeData();
184 if ( ( this_data.isHasSequence() && other_data.isHasSequence() )
185 && ( this_data.isHasTaxonomy() && other_data.isHasTaxonomy() ) ) {
186 return ( this_data.getTaxonomy().isEqual( other_data.getTaxonomy() ) && this_data.getSequence()
187 .isEqual( other_data.getSequence() ) );
189 else if ( this_data.isHasSequence() && other_data.isHasSequence() ) {
190 return ( this_data.getSequence().isEqual( other_data.getSequence() ) );
192 else if ( this_data.isHasTaxonomy() && other_data.isHasTaxonomy() ) {
193 return ( this_data.getTaxonomy().isEqual( other_data.getTaxonomy() ) );
195 else if ( getName().length() > 0 ) {
196 // Node name is not empty, and equal.
205 // ---------------------------------------------------------
206 // Obtaining of Nodes
207 // ---------------------------------------------------------
209 * Returns a List containing references to all external children of this
212 * @return List of references to external Nodes
214 final public List<PhylogenyNode> getAllExternalDescendants() {
215 final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();
216 if ( isExternal() ) {
220 PhylogenyNode node1 = this;
221 while ( !node1.isExternal() ) {
222 node1 = node1.getFirstChildNode();
224 PhylogenyNode node2 = this;
225 while ( !node2.isExternal() ) {
226 node2 = node2.getLastChildNode();
228 while ( node1 != node2 ) {
230 node1 = node1.getNextExternalNode();
237 * Returns a List containing references to all names of the external
238 * children of this PhylogenyNode.
240 * @return List of references to names of external Nodes
242 final public List<String> getAllExternalDescendantsNames() {
243 final List<PhylogenyNode> c = getAllExternalDescendants();
244 final List<String> n = new ArrayList<String>( c.size() );
245 for( final PhylogenyNode phylogenyNode : c ) {
246 n.add( phylogenyNode.getName() );
251 final public BranchData getBranchData() {
252 if ( _branch_data == null ) {
253 _branch_data = new BranchData();
258 final BranchData getBranchDataDirectly() {
263 * This return child node n of this node.
266 * the index of the child to get
267 * @return the child node with index n
268 * @throws IllegalArgumentException
269 * if n is out of bounds
272 final public PhylogenyNode getChildNode( final int i ) {
273 if ( isExternal() ) {
274 throw new UnsupportedOperationException( "attempt to get the child node of an external node." );
276 if ( ( i >= getNumberOfDescendants() ) || ( i < 0 ) ) {
277 throw new IllegalArgumentException( "attempt to get child node " + i + " of a node with "
278 + getNumberOfDescendants() + " child nodes" );
280 return getDescendants().get( i );
284 * Convenience method. Returns the first child PhylogenyNode of this
287 final public PhylogenyNode getChildNode1() {
288 return getChildNode( 0 );
292 * Convenience method. Returns the second child PhylogenyNode of this
295 * [last modified May 18, 2005 by CMZ]
297 final public PhylogenyNode getChildNode2() {
298 return getChildNode( 1 );
302 * This gets the child node index of this node.
305 * @return the child node index of this node
306 * @throws UnsupportedOperationException
307 * if this node is a root node
309 final public int getChildNodeIndex() {
310 return getChildNodeIndex( getParent() );
314 * This gets the child node index of this node, given that parent is its
317 * [last modified Aug 14, 2006 by CMZ]
319 * @return the child node index of this node
320 * @throws UnsupportedOperationException
321 * if this node is a root node
323 final public int getChildNodeIndex( final PhylogenyNode parent ) {
325 throw new UnsupportedOperationException( "Cannot get the child index for a root node." );
327 for( int i = 0; i < parent.getNumberOfDescendants(); ++i ) {
328 if ( parent.getChildNode( i ) == this ) {
332 throw new RuntimeException( "Unexpected exception: Could not determine the child index for node: " + this );
335 final public List<PhylogenyNode> getDescendants() {
340 * Returns the length of the branch leading to the _parent of this
341 * PhylogenyNode (double).
344 final public double getDistanceToParent() {
345 return _distance_parent;
349 * Convenience method. Returns the first child node of this node.
351 * [last modified May 18, 2005 by CMZ]
353 * @return the first child node of this node
355 public final PhylogenyNode getFirstChildNode() {
356 return getChildNode( 0 );
360 * Returns the _indicator value of this PhylogenyNode.
362 public final byte getIndicator() {
367 * Convenience method. Returns the last child node of this node.
369 * [last modified May 18, 2005 by CMZ]
371 * @return the last child node of this node
373 public final PhylogenyNode getLastChildNode() {
374 return getChildNode( getNumberOfDescendants() - 1 );
378 * Returns a refernce to the linked PhylogenyNode of this PhylogenyNode.
379 * Currently, this method is only used for the speciation-_duplication
380 * assignment algorithms.
382 public final PhylogenyNode getLink() {
387 * Returns a refernce to the next external PhylogenyNode of this
388 * PhylogenyNode. TODO should be in Phylogeny. Returns null if no next
389 * external node is available.
391 public final PhylogenyNode getNextExternalNode() {
392 if ( isInternal() ) {
393 throw new UnsupportedOperationException( "attempt to get next external node of an internal node" );
395 else if ( isLastExternalNode() ) {
398 int index = getChildNodeIndex();
399 PhylogenyNode previous_node = this;
400 PhylogenyNode current_node = getParent();
401 while ( !current_node.isRoot()
402 && ( ( current_node.getNumberOfDescendants() == 1 ) || previous_node.isLastChildNode() ) ) {
403 index = current_node.getChildNodeIndex();
404 previous_node = current_node;
405 current_node = current_node.getParent();
407 current_node = current_node.getChildNode( index + 1 );
408 while ( current_node.isInternal() ) {
409 current_node = current_node.getFirstChildNode();
414 public final NodeData getNodeData() {
415 if ( _node_data == null ) {
416 _node_data = new NodeData();
421 final NodeData getNodeDataDirectly() {
425 // ---------------------------------------------------------
426 // Set and get methods for Nodes
427 // ---------------------------------------------------------
429 * Returns the ID (int) of this PhylogenyNode.
432 final public int getId() {
437 * Returns the name of this node.
440 final public String getName() {
441 return getNodeData().getNodeName();
444 final public int getNumberOfDescendants() {
445 return _descendants.size();
449 * Returns the total number of external Nodes originating from this
450 * PhylogenyNode (int).
452 final public int getNumberOfExternalNodes() {
453 return _sum_ext_nodes;
456 final public int getNumberOfParents() {
461 * Returns a refernce to the parent PhylogenyNode of this PhylogenyNode.
463 final public PhylogenyNode getParent() {
468 * Returns a refernce to the next external PhylogenyNode of this
469 * PhylogenyNode. TODO should be in Phylogeny. Returns null if no next
470 * external node is available.
472 final public PhylogenyNode getPreviousExternalNode() {
473 if ( isInternal() ) {
474 throw new UnsupportedOperationException( "Cannot get the previous external node for an internal node." );
476 else if ( isRoot() /* TODO && tree is rooted */) {
477 throw new UnsupportedOperationException( "Cannot get the previous external node for a root node." );
479 else if ( isFirstExternalNode() ) {
480 throw new UnsupportedOperationException( "Attempt to get previous external node of the first external node." );
482 int index = getChildNodeIndex();
483 PhylogenyNode previous_node = this;
484 PhylogenyNode current_node = getParent();
485 while ( !current_node.isRoot()
486 && ( ( current_node.getNumberOfDescendants() == 1 ) || previous_node.isFirstChildNode() ) ) {
487 index = current_node.getChildNodeIndex();
488 previous_node = current_node;
489 current_node = current_node.getParent();
491 current_node = current_node.getChildNode( index - 1 );
492 while ( current_node.isInternal() ) {
493 current_node = current_node.getLastChildNode();
499 * Used for drawing of Trees.
501 final public float getXcoord() {
505 final public float getXSecondary() {
510 * Used for drawing of Trees.
512 final public float getYcoord() {
516 final public float getYSecondary() {
521 final public int hashCode() {
522 final NodeData data = getNodeData();
523 if ( ( getName().length() < 1 ) && !data.isHasSequence() && !data.isHasTaxonomy() ) {
524 return super.hashCode();
526 int result = getName().hashCode();
527 if ( data.isHasSequence() ) {
528 result ^= data.getSequence().hashCode();
530 if ( data.isHasTaxonomy() ) {
531 result ^= data.getTaxonomy().hashCode();
536 final private void init() {
537 _descendants = new ArrayList<PhylogenyNode>();
544 * Deletes data of this PhylogenyNode. Links to the other Nodes in the
545 * Phylogeny, the ID and the sum of external nodes are NOT deleted. Field
546 * "_link" (_link to Nodes in other Phylogeny) IS deleted.
548 * @see #getLink() (Last modified: 12/20/03)
550 final public void initializeData() {
555 _distance_parent = PhylogenyNode.DISTANCE_DEFAULT;
563 * Returns whether this PhylogenyNode should be drawn as collapsed.
565 final public boolean isCollapse() {
570 * Returns true if this PhylogenyNode represents a _duplication event, false
573 final public boolean isDuplication() {
574 return getNodeData().isHasEvent() && getNodeData().getEvent().isDuplication();
578 * Checks whether this PhylogenyNode is external (tip).
580 * @return true if this PhylogenyNode is external, false otherwise
582 final public boolean isExternal() {
583 return ( getNumberOfDescendants() < 1 );
589 * @return DOCUMENT ME!
591 final public boolean isFirstChildNode() {
592 if ( isRoot() /* and tree is rooted TODO */) {
593 throw new UnsupportedOperationException( "Cannot determine whether the root is the first child node of its _parent." );
595 return ( getChildNodeIndex() == 0 );
601 * @return DOCUMENT ME!
603 final public boolean isFirstExternalNode() {
604 if ( isInternal() ) {
607 PhylogenyNode node = this;
608 while ( !node.isRoot() ) {
609 if ( !node.isFirstChildNode() ) {
612 node = node.getParent();
618 * Returns whether a _duplication or speciation event has been assigned for
619 * this PhylogenyNode.
621 final public boolean isHasAssignedEvent() {
622 if ( !getNodeData().isHasEvent() ) {
625 if ( ( getNodeData().getEvent() ).isUnassigned() ) {
632 * Checks whether this PhylogenyNode is internal (tip).
634 * @return true if this PhylogenyNode is external, false otherwise
636 final public boolean isInternal() {
637 return ( !isExternal() );
641 * Returns true if this node is the last child node of its _parent.
643 * [last modified June 01, 2005 by CMZ]
645 * @return true if this node is the last child node of its _parent, false
648 final public boolean isLastChildNode() {
649 if ( isRoot() /* and tree is rooted TODO */) {
650 throw new UnsupportedOperationException( "Cannot determine whether the root is the last child node of its _parent." );
652 return ( getChildNodeIndex() == ( getParent().getNumberOfDescendants() - 1 ) );
658 * @return DOCUMENT ME!
660 final public boolean isLastExternalNode() {
661 if ( isInternal() ) {
664 PhylogenyNode node = this;
665 while ( !node.isRoot() ) {
666 if ( !node.isLastChildNode() ) {
669 node = node.getParent();
675 * Checks whether this PhylogenyNode is a root.
677 * @return true if this PhylogenyNode is the root, false otherwise
679 final public boolean isRoot() {
680 return _parent == null;
683 final public boolean isSpeciation() {
684 return getNodeData().isHasEvent() && getNodeData().getEvent().isSpeciation();
687 // ---------------------------------------------------------
689 // ---------------------------------------------------------
690 final public PhylogenyNodeIterator iterateChildNodesForward() {
691 return new ChildNodeIteratorForward( this );
694 // ---------------------------------------------------------
696 // ---------------------------------------------------------
698 * Prints to the console the subtree originating from this PhylogenyNode in
701 public void preorderPrint() {
702 System.out.println( this + "\n" );
703 if ( isInternal() ) {
704 for( int i = 0; i < getNumberOfDescendants(); ++i ) {
705 getChildNode( i ).preorderPrint();
710 final public void removeChildNode( final int i ) {
711 if ( isExternal() ) {
712 throw new UnsupportedOperationException( "cannot get the child node for a external node." );
714 if ( ( i >= getNumberOfDescendants() ) || ( i < 0 ) ) {
715 throw new IllegalArgumentException( "attempt to get child node " + i + " of a node with "
716 + getNumberOfDescendants() + " child nodes." );
718 getDescendants().remove( i );
721 final public void removeChildNode( final PhylogenyNode remove_me ) {
722 removeChildNode( remove_me.getChildNodeIndex() );
725 final public void setBranchData( final BranchData branch_data ) {
726 _branch_data = branch_data;
730 * Sets the first child PhylogenyNode of this PhylogenyNode to n.
732 final public void setChild1( final PhylogenyNode n ) {
733 setChildNode( 0, n );
737 * Sets the second child PhylogenyNode of this PhylogenyNode to n.
739 final public void setChild2( final PhylogenyNode n ) {
740 setChildNode( 1, n );
744 * Inserts PhylogenyNode n at the specified position i into the list of
745 * child nodes. This does not allow null slots in the list of child nodes:
746 * If i is larger than the number of child nodes, n is just added to the
747 * list, not place at index i.
750 * the index of position where to add the child
752 * the PhylogenyNode to add
754 final public void setChildNode( final int i, final PhylogenyNode node ) {
755 node.setParent( this );
756 if ( getNumberOfDescendants() <= i ) {
757 addChildNode( node );
760 getDescendants().set( i, node );
764 final void setChildNodeOnly( final int i, final PhylogenyNode node ) {
765 if ( getNumberOfDescendants() <= i ) {
766 addChildNode( node );
769 getDescendants().set( i, node );
774 * Sets whether this PhylogenyNode should be drawn as collapsed.
776 final public void setCollapse( final boolean b ) {
781 * Sets the length of the branch leading to the _parent of this
782 * PhylogenyNode to double d.
785 final public void setDistanceToParent( final double d ) {
786 _distance_parent = d;
790 * Sets the _indicator value of this PhylogenyNode to i.
792 final public void setIndicator( final byte i ) {
796 // --------------------------------------------------------------------
797 // Adjust methods (related to Phylogeny construction and
798 // Phylogeny modification)
799 // --------------------------------------------------------------------
801 * Sets the indicators of all the children of this PhylogenyNode to zero.
803 final void setIndicatorsToZero() {
804 for( final PreorderTreeIterator it = new PreorderTreeIterator( this ); it.hasNext(); ) {
805 it.next().setIndicator( ( byte ) 0 );
810 * Sets the linked PhylogenyNode of this PhylogenyNode to n. Currently, this
811 * method is only used for the speciation-_duplication assignment
814 final public void setLink( final PhylogenyNode n ) {
819 * Sets the name of this node.
822 final public void setName( final String node_name ) {
823 getNodeData().setNodeName( node_name );
827 * Sets the Id of this PhylogenyNode to i. In most cases, this number
828 * should not be set to values lower than getNodeCount() -- which this method
831 synchronized final protected void setId( final int i ) {
832 if ( i < getNodeCount() ) {
833 throw new IllegalArgumentException( "attempt to set node id to a value less than total node count (thus violating the uniqueness of node ids)" );
839 * Sets the _parent PhylogenyNode of this PhylogenyNode to n.
842 final public void setParent( final PhylogenyNode n ) {
847 * Sets the total number of external Nodes originating from this
848 * PhylogenyNode to i (int).
850 final public void setSumExtNodes( final int i ) {
852 throw new IllegalArgumentException( "attempt to set sum of external nodes to less than one" );
858 * Used for drawing of Trees.
860 final public void setXcoord( final float x ) {
864 final public void setXSecondary( final float x_secondary ) {
865 _x_secondary = x_secondary;
870 * Used for drawing of Trees.
872 final public void setYcoord( final float y ) {
876 final public void setYSecondary( final float y_secondary ) {
877 _y_secondary = y_secondary;
880 // ---------------------------------------------------------
881 // Writing of Nodes to Strings
882 // ---------------------------------------------------------
883 final public String toNewHampshire( final boolean simple_nh, final boolean write_distance_to_parent ) {
884 final StringBuilder sb = new StringBuilder();
886 if ( !ForesterUtil.isEmpty( getName() ) ) {
889 else if ( getNodeData().isHasTaxonomy() ) {
890 if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
891 data = getNodeData().getTaxonomy().getTaxonomyCode();
893 else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getScientificName() ) ) {
894 data = getNodeData().getTaxonomy().getScientificName();
896 else if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getCommonName() ) ) {
897 data = getNodeData().getTaxonomy().getCommonName();
899 else if ( getNodeData().getTaxonomy().getTaxonomyCode() != null ) {
900 data = getNodeData().getTaxonomy().getTaxonomyCode();
903 else if ( getNodeData().isHasSequence() ) {
904 if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getName() ) ) {
905 data = getNodeData().getSequence().getName();
908 if ( data.length() > 0 ) {
909 data = ForesterUtil.replaceIllegalNhCharacters( data );
910 if ( simple_nh && ( data.length() > 10 ) ) {
911 data = data.substring( 0, 11 );
913 if ( ForesterUtil.isContainsParanthesesableNhCharacter( data ) ) {
922 if ( ( getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) && write_distance_to_parent ) {
924 sb.append( getDistanceToParent() );
926 return sb.toString();
930 * Converts this PhylogenyNode to a New Hampshire X (NHX) String
933 final public String toNewHampshireX() {
934 final StringBuffer sb = new StringBuffer();
935 final StringBuffer s_nhx = new StringBuffer();
936 if ( !ForesterUtil.isEmpty( getName() ) ) {
937 final String name = ForesterUtil.replaceIllegalNhCharacters( getName() );
938 if ( ForesterUtil.isContainsParanthesesableNhCharacter( name ) ) {
947 if ( getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) {
949 sb.append( getDistanceToParent() );
951 if ( getNodeDataDirectly() != null ) {
952 s_nhx.append( getNodeDataDirectly().toNHX() );
954 if ( getBranchDataDirectly() != null ) {
955 s_nhx.append( getBranchDataDirectly().toNHX() );
957 if ( s_nhx.length() > 0 ) {
958 sb.append( "[&&NHX" );
962 return sb.toString();
966 final public String toString() {
967 final StringBuilder sb = new StringBuilder();
968 if ( !ForesterUtil.isEmpty( getName() ) ) {
969 sb.append( getName() );
973 sb.append( getId() );
975 return sb.toString();
979 * Decreases the total number of all Nodes created so far by one.
981 final static synchronized void decreaseNodeCount() {
982 --PhylogenyNode._node_count;
986 * Returns the total number of all Nodes created so far.
988 * @return total number of Nodes (int)
990 synchronized final public static int getNodeCount() {
991 return PhylogenyNode._node_count;
995 * Increases the total number of all Nodes created so far by one.
997 synchronized final private static void increaseNodeCount() {
998 ++PhylogenyNode._node_count;
1002 * Sets the total number of all Nodes created so far to i (int).
1004 synchronized final static void setNodeCount( final int i ) {
1005 PhylogenyNode._node_count = i;
1008 public static PhylogenyNode createInstanceFromNhxString( final String nhx ) throws NHXFormatException {
1009 return new PhylogenyNode( nhx, ForesterUtil.TAXONOMY_EXTRACTION.NO, false );
1012 public static PhylogenyNode createInstanceFromNhxString( final String nhx,
1013 final ForesterUtil.TAXONOMY_EXTRACTION taxonomy_extraction )
1014 throws NHXFormatException {
1015 return new PhylogenyNode( nhx, taxonomy_extraction, false );
1018 public static PhylogenyNode createInstanceFromNhxString( final String nhx,
1019 final ForesterUtil.TAXONOMY_EXTRACTION taxonomy_extraction,
1020 final boolean replace_underscores )
1021 throws NHXFormatException {
1022 return new PhylogenyNode( nhx, taxonomy_extraction, replace_underscores );
1025 private PhylogenyNode( final String nhx,
1026 final ForesterUtil.TAXONOMY_EXTRACTION taxonomy_extraction,
1027 final boolean replace_underscores ) throws NHXFormatException {
1029 NHXParser.parseNHX( nhx, this, taxonomy_extraction, replace_underscores );
1030 setId( PhylogenyNode.getNodeCount() );
1031 PhylogenyNode.increaseNodeCount();
1032 setSumExtNodes( 1 ); // For ext node, this number is 1 (not 0!!)