From: cmzmasek Date: Mon, 18 Jul 2011 16:04:01 +0000 (+0000) Subject: work in airplane X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a6b799447987d651276b06c1330b22836420ded;p=jalview.git work in airplane --- diff --git a/forester/java/src/org/forester/application/simple_node_processor.java b/forester/java/src/org/forester/application/simple_node_processor.java index 033bd9f..c7e495a 100644 --- a/forester/java/src/org/forester/application/simple_node_processor.java +++ b/forester/java/src/org/forester/application/simple_node_processor.java @@ -40,18 +40,25 @@ public class simple_node_processor { private final static String BASE = "b_"; public static void main( final String args[] ) { + File in = null; + File out = null; if ( ( args.length != 2 ) ) { - System.exit( -1 ); + // System.exit( -1 ); + if ( ( args.length == 0 ) ) { + in = new File("C:\\Users\\zma\\dollo.xml"); + out = null; + } } try { + System.out.println( "..."); CommandLineArguments cla = null; cla = new CommandLineArguments( args ); - final File in = cla.getFile( 0 ); - final File out = cla.getFile( 1 ); - if ( out.exists() ) { - System.out.println( out + " already exists" ); - System.exit( -1 ); - } + // in = cla.getFile( 0 ); + // out = cla.getFile( 1 ); + // if ( out.exists() ) { + // System.out.println( out + " already exists" ); + // System.exit( -1 ); + // } final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); final PhyloXmlParser xml_parser = new PhyloXmlParser(); final Phylogeny[] phylogenies_0 = factory.create( in, xml_parser ); diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 348d29d..3562e10 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -158,11 +158,11 @@ public final class Configuration { { "Taxonomy Colorize", "display", "yes" }, { "Colorize Branches", "display", "no" }, { "Use Branch-Width", "nodisplay", "no" }, { "Show Custom Nodes", "display", "yes" }, { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" }, - { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "no" }, + { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" }, { "Prot/Gene Acc", "display", "no" }, { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" }, { "Annotation Colorize", "nodisplay", "no" }, - { "Property", "nodisplay", "no" }, { "Prot/Gene Symbol", "display", "no" }, + { "Property", "nodisplay", "no" }, { "Prot/Gene Symbol", "display", "yes" }, { "Rollover", "display", "yes" }, { "Relation Confidence", "display", "no" }, { "Vector Data", "display", "no" }, { "Taxonomy Images", "display", "no" } }; final static String clickto_options[][] = { diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java index 5ef3b5f..dd3dba0 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java @@ -420,7 +420,23 @@ public class PhylogenyNode implements PhylogenyNodeI, Comparable if ( isInternal() && !isCollapse() ) { throw new UnsupportedOperationException( "attempt to get next external node of an uncollapsed internal node" ); } - else if ( isLastExternalNode() ) { + if ( isRoot() ) { + return null; + } + if ( getParent().isCollapse() ) { + throw new UnsupportedOperationException( "attempt to get next external node of node with a collapsed parent" ); + } + // This checks if last node. + PhylogenyNode n = this; + boolean last = true; + while ( !n.isRoot() ) { + if ( !n.isLastChildNode() ) { + last = false; + break; + } + n = n.getParent(); + } + if ( last ) { return null; } int index = getChildNodeIndex(); @@ -431,146 +447,18 @@ public class PhylogenyNode implements PhylogenyNodeI, Comparable .isLastChildNode() ) ) { index = current_node.getChildNodeIndex(); previous_node = current_node; - System.out.println(" " + previous_node.getName()); current_node = current_node.getParent(); } - // if ( !current_node.isCollapse() ) { - current_node = current_node.getChildNode( index + 1 ); - //} + if ( index < current_node.getNumberOfDescendants() - 1 ) { + current_node = current_node.getChildNode( index + 1 ); + } while ( current_node.isInternal() && !current_node.isCollapse() ) { current_node = current_node.getFirstChildNode(); } return current_node; } - public static void main( final String[] args ) { - try { - final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); - PhylogenyNode n; - List ext = new ArrayList(); -// final StringBuffer sb0 = new StringBuffer( -// "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); -// final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ]; -// -// t0.getNode( "cd" ).setCollapse( true ); -// t0.getNode( "cde" ).setCollapse( true ); - // n = t0.getFirstExternalNode(); - -// while ( n != null ) { -// System.out.println( n.getName() ); -// ext.add( n ); -// n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); -// } -// -// // Archaeopteryx.createApplication( t ); -// if ( !ext.get( 0 ).getName().equals( "a" ) ) { -// System.out.println( "0 fail" ); -// } -// if ( !ext.get( 1 ).getName().equals( "b" ) ) { -// System.out.println( "1 fail" ); -// } -// if ( !ext.get( 2 ).getName().equals( "cde" ) ) { -// System.out.println( "2 fail" ); -// } -// if ( !ext.get( 3 ).getName().equals( "f" ) ) { -// System.out.println( "3 fail" ); -// } -// if ( !ext.get( 4 ).getName().equals( "g" ) ) { -// System.out.println( "4 fail" ); -// } -// if ( !ext.get( 5 ).getName().equals( "h" ) ) { -// System.out.println( "5 fail" ); -// } - // if ( !ext.get( 6 ).getName().equals( "a" ) ) { - // System.out.println( "6 fail" ); - // } - // if ( !ext.get( 7 ).getName().equals( "a" ) ) { - // System.out.println( "7 fail" ); - // } - - - final StringBuffer sb1 = new StringBuffer( - "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); - final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ]; - - t1.getNode( "ab" ).setCollapse( true ); - t1.getNode( "cd" ).setCollapse( true ); - t1.getNode( "cde" ).setCollapse( true ); - // n = t1.getFirstExternalNode(); - n = t1.getNode( "ab" ); - ext = new ArrayList(); - while ( n != null ) { - System.out.println( n.getName() ); - ext.add( n ); - n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); - } - - // Archaeopteryx.createApplication( t1 ); - if ( !ext.get( 0 ).getName().equals( "ab" ) ) { - System.out.println( "0 fail" ); - } - - if ( !ext.get( 1 ).getName().equals( "cde" ) ) { - System.out.println( "1 fail" ); - } - if ( !ext.get( 2 ).getName().equals( "f" ) ) { - System.out.println( "2 fail" ); - } - if ( !ext.get( 3 ).getName().equals( "g" ) ) { - System.out.println( "3 fail" ); - } - if ( !ext.get( 4 ).getName().equals( "h" ) ) { - System.out.println( "4 fail" ); - } - - // - // - final StringBuffer sb2 = new StringBuffer( - "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); - final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ]; - - t2.getNode( "ab" ).setCollapse( true ); - t2.getNode( "cd" ).setCollapse( true ); - t2.getNode( "cde" ).setCollapse( true ); - t2.getNode( "c" ).setCollapse( true ); - t2.getNode( "d" ).setCollapse( true ); - t2.getNode( "e" ).setCollapse( true ); - t2.getNode( "gh" ).setCollapse( true ); - // t2.getNode( "h" ).setCollapse( true ); - // n = t1.getFirstExternalNode(); - n = t2.getNode( "ab" ); - ext = new ArrayList(); - while ( n != null ) { - System.out.println( n.getName() ); - ext.add( n ); - n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); - } - - // Archaeopteryx.createApplication( t1 ); - if ( !ext.get( 0 ).getName().equals( "ab" ) ) { - System.out.println( "0 fail" ); - } - - if ( !ext.get( 1 ).getName().equals( "cde" ) ) { - System.out.println( "1 fail" ); - } - if ( !ext.get( 2 ).getName().equals( "f" ) ) { - System.out.println( "2 fail" ); - } - if ( !ext.get( 3 ).getName().equals( "g" ) ) { - System.out.println( "3 fail" ); - } - if ( !ext.get( 4 ).getName().equals( "h" ) ) { - System.out.println( "4 fail" ); - } - - - } - catch ( IOException e ) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + public final NodeData getNodeData() { diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index 637d05c..b5a3aeb 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -38,6 +38,7 @@ import java.util.Locale; import java.util.Set; import org.forester.application.support_transfer; +import org.forester.archaeopteryx.Archaeopteryx; import org.forester.development.DevelopmentTools; import org.forester.evoinference.TestPhylogenyReconstruction; import org.forester.evoinference.matrix.character.CharacterStateMatrix; @@ -684,6 +685,15 @@ public final class Test { System.out.println( "failed [will not count towards failed tests]" ); } } + System.out.print( "Next nodes with collapsed: " ); + if ( Test.testNextNodeWithCollapsing() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } // System.out.print( "WABI TxSearch: " ); // if ( Test.testWabiTxSearch() ) { // System.out.println( "OK." ); @@ -8100,4 +8110,565 @@ public final class Test { } return true; } + + private static boolean testNextNodeWithCollapsing() { + try { + final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); + PhylogenyNode n; + List ext = new ArrayList(); + final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ]; + t0.getNode( "cd" ).setCollapse( true ); + t0.getNode( "cde" ).setCollapse( true ); + n = t0.getFirstExternalNode(); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "cde" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "h" ) ) { + return false; + } + ext.clear(); + final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ]; + t1.getNode( "ab" ).setCollapse( true ); + t1.getNode( "cd" ).setCollapse( true ); + t1.getNode( "cde" ).setCollapse( true ); + n = t1.getNode( "ab" ); + ext = new ArrayList(); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "cde" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "h" ) ) { + return false; + } + // + // + ext.clear(); + final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ]; + t2.getNode( "ab" ).setCollapse( true ); + t2.getNode( "cd" ).setCollapse( true ); + t2.getNode( "cde" ).setCollapse( true ); + t2.getNode( "c" ).setCollapse( true ); + t2.getNode( "d" ).setCollapse( true ); + t2.getNode( "e" ).setCollapse( true ); + t2.getNode( "gh" ).setCollapse( true ); + n = t2.getNode( "ab" ); + ext = new ArrayList(); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "cde" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "gh" ) ) { + return false; + } + // + // + ext.clear(); + final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ]; + t3.getNode( "ab" ).setCollapse( true ); + t3.getNode( "cd" ).setCollapse( true ); + t3.getNode( "cde" ).setCollapse( true ); + t3.getNode( "c" ).setCollapse( true ); + t3.getNode( "d" ).setCollapse( true ); + t3.getNode( "e" ).setCollapse( true ); + t3.getNode( "gh" ).setCollapse( true ); + t3.getNode( "fgh" ).setCollapse( true ); + n = t3.getNode( "ab" ); + ext = new ArrayList(); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "cde" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + ext.clear(); + final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ]; + t4.getNode( "ab" ).setCollapse( true ); + t4.getNode( "cd" ).setCollapse( true ); + t4.getNode( "cde" ).setCollapse( true ); + t4.getNode( "c" ).setCollapse( true ); + t4.getNode( "d" ).setCollapse( true ); + t4.getNode( "e" ).setCollapse( true ); + t4.getNode( "gh" ).setCollapse( true ); + t4.getNode( "fgh" ).setCollapse( true ); + t4.getNode( "abcdefgh" ).setCollapse( true ); + n = t4.getNode( "abcdefgh" ); + if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) { + return false; + } + // + // + final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ]; + ext.clear(); + n = t5.getFirstExternalNode(); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 8 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 7 ).getName().equals( "h" ) ) { + return false; + } + // + // + final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ]; + ext.clear(); + t6.getNode( "ab" ).setCollapse( true ); + n = t6.getNode( "ab" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 7 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "h" ) ) { + return false; + } + // + // + final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ]; + ext.clear(); + t7.getNode( "cd" ).setCollapse( true ); + n = t7.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 7 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "cd" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "h" ) ) { + return false; + } + // + // + final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" ); + final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ]; + ext.clear(); + t8.getNode( "cd" ).setCollapse( true ); + t8.getNode( "c" ).setCollapse( true ); + t8.getNode( "d" ).setCollapse( true ); + n = t8.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 7 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "cd" ) ) { + System.out.println( "2 fail" ); + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "g" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "h" ) ) { + return false; + } + // + // + final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ]; + ext.clear(); + t9.getNode( "gh" ).setCollapse( true ); + n = t9.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 7 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "gh" ) ) { + return false; + } + // + // + final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ]; + ext.clear(); + t10.getNode( "gh" ).setCollapse( true ); + t10.getNode( "g" ).setCollapse( true ); + t10.getNode( "h" ).setCollapse( true ); + n = t10.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 7 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "f" ) ) { + return false; + } + if ( !ext.get( 6 ).getName().equals( "gh" ) ) { + return false; + } + // + // + final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ]; + ext.clear(); + t11.getNode( "gh" ).setCollapse( true ); + t11.getNode( "fgh" ).setCollapse( true ); + n = t11.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 6 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ]; + ext.clear(); + t12.getNode( "gh" ).setCollapse( true ); + t12.getNode( "fgh" ).setCollapse( true ); + t12.getNode( "g" ).setCollapse( true ); + t12.getNode( "h" ).setCollapse( true ); + t12.getNode( "f" ).setCollapse( true ); + n = t12.getNode( "a" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 6 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "a" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "b" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" ); + final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ]; + ext.clear(); + t13.getNode( "ab" ).setCollapse( true ); + t13.getNode( "b" ).setCollapse( true ); + t13.getNode( "fgh" ).setCollapse( true ); + t13.getNode( "gh" ).setCollapse( true ); + n = t13.getNode( "ab" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 5 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" ); + final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ]; + ext.clear(); + t14.getNode( "ab" ).setCollapse( true ); + t14.getNode( "a" ).setCollapse( true ); + t14.getNode( "fgh" ).setCollapse( true ); + t14.getNode( "gh" ).setCollapse( true ); + n = t14.getNode( "ab" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 5 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + final StringBuffer sb15 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,x,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" ); + final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ]; + ext.clear(); + t15.getNode( "ab" ).setCollapse( true ); + t15.getNode( "a" ).setCollapse( true ); + t15.getNode( "fgh" ).setCollapse( true ); + t15.getNode( "gh" ).setCollapse( true ); + n = t15.getNode( "ab" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 6 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "c" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "d" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "e" ) ) { + return false; + } + if ( !ext.get( 4 ).getName().equals( "x" ) ) { + return false; + } + if ( !ext.get( 5 ).getName().equals( "fgh" ) ) { + return false; + } + // + // + final StringBuffer sb16 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,x,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" ); + final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ]; + ext.clear(); + t16.getNode( "ab" ).setCollapse( true ); + t16.getNode( "a" ).setCollapse( true ); + t16.getNode( "fgh" ).setCollapse( true ); + t16.getNode( "gh" ).setCollapse( true ); + t16.getNode( "cd" ).setCollapse( true ); + t16.getNode( "cde" ).setCollapse( true ); + t16.getNode( "d" ).setCollapse( true ); + t16.getNode( "x" ).setCollapse( true ); + n = t16.getNode( "ab" ); + while ( n != null ) { + ext.add( n ); + n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes(); + } + if ( ext.size() != 4 ) { + return false; + } + if ( !ext.get( 0 ).getName().equals( "ab" ) ) { + return false; + } + if ( !ext.get( 1 ).getName().equals( "cde" ) ) { + return false; + } + if ( !ext.get( 2 ).getName().equals( "x" ) ) { + return false; + } + if ( !ext.get( 3 ).getName().equals( "fgh" ) ) { + return false; + } + } + catch ( final Exception e ) { + e.printStackTrace( System.out ); + return false; + } + return true; + } }