+ if ( getNodeData().isHasTaxonomy() ) {
+ if ( !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getScientificName() ) ) {
+ sb.append( getNodeData().getTaxonomy().getScientificName() );
+ sb.append( " " );
+ }
+ else if ( ( sb.length() <= 1 ) && !ForesterUtil.isEmpty( getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ sb.append( getNodeData().getTaxonomy().getTaxonomyCode() );
+ sb.append( " " );
+ }
+ else if ( getNodeData().getTaxonomy().getIdentifier() != null ) {
+ sb.append( getNodeData().getTaxonomy().getIdentifier().toString() );
+ sb.append( " " );
+ }
+ }
+ if ( getNodeData().isHasSequence() ) {
+ if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getName() ) ) {
+ sb.append( getNodeData().getSequence().getName() );
+ sb.append( " " );
+ }
+ if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getSymbol() ) ) {
+ sb.append( getNodeData().getSequence().getSymbol() );
+ sb.append( " " );
+ }
+ if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getGeneName() ) ) {
+ sb.append( getNodeData().getSequence().getGeneName() );
+ sb.append( " " );
+ }
+ if ( getNodeData().getSequence().getAccession() != null ) {
+ sb.append( getNodeData().getSequence().getAccession().toString() );
+ sb.append( " " );
+ }
+ if ( !ForesterUtil.isEmpty( getNodeData().getSequence().getMolecularSequence() ) ) {
+ sb.append( getNodeData().getSequence().getMolecularSequence() );
+ sb.append( " " );
+ }
+ }
+ if ( sb.length() <= 1 ) {
+ sb.append( "[" );
+ sb.append( getId() );
+ sb.append( "]" );
+ }
+ return sb.toString().trim();
+ }
+
+ /**
+ * Sets the Id of this PhylogenyNode to i. In most cases, this number
+ * should not be set to values lower than getNodeCount() -- which this method
+ * does not allow.
+ */
+ synchronized final protected void setId( final long i ) {
+ if ( i < getNodeCount() ) {
+ throw new IllegalArgumentException( "attempt to set node id to a value less than total node count (thus violating the uniqueness of node ids)" );
+ }
+ _id = i;
+ }
+
+ final BranchData getBranchDataDirectly() {
+ return _branch_data;
+ }
+
+ final NodeData getNodeDataDirectly() {
+ return _node_data;
+ }
+
+ final void setChildNodeOnly( final int i, final PhylogenyNode node ) {
+ if ( getNumberOfDescendants() <= i ) {
+ addChildNode( node );
+ }
+ else {
+ getDescendants().set( i, node );
+ }
+ }
+
+ /**
+ * Sets the indicators of all the children of this PhylogenyNode to zero.
+ */
+ final void setIndicatorsToZero() {
+ for( final PreorderTreeIterator it = new PreorderTreeIterator( this ); it.hasNext(); ) {
+ it.next().setIndicator( ( byte ) 0 );
+ }
+ }
+
+ /**
+ * Adds PhylogenyNode n to the list of child nodes. But does NOT set the
+ * _parent of n to this.
+ *
+ * @see addAsChild( PhylogenyNode n )
+ * @param n
+ * the PhylogenyNode to add
+ */
+ final private void addChildNode( final PhylogenyNode child ) {
+ getDescendants().add( child );
+ }
+
+ public static PhylogenyNode createInstanceFromNhxString( final String nhx ) throws NHXFormatException,
+ PhyloXmlDataFormatException {
+ return new PhylogenyNode( nhx, NHXParser.TAXONOMY_EXTRACTION.NO, false );
+ }
+
+ public static PhylogenyNode createInstanceFromNhxString( final String nhx,
+ final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction )
+ throws NHXFormatException, PhyloXmlDataFormatException {
+ return new PhylogenyNode( nhx, taxonomy_extraction, false );
+ }
+
+ public static PhylogenyNode createInstanceFromNhxString( final String nhx,
+ final NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction,
+ final boolean replace_underscores )
+ throws NHXFormatException, PhyloXmlDataFormatException {
+ return new PhylogenyNode( nhx, taxonomy_extraction, replace_underscores );
+ }
+
+ /**
+ * Returns the total number of all Nodes created so far.
+ *
+ * @return total number of Nodes (long)
+ */
+ synchronized final public static long getNodeCount() {
+ return NODE_COUNT;