X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fevoinference%2FTestPhylogenyReconstruction.java;h=f6d3975fbcae703bfb0abe16672d1451a3ffafa3;hb=a0b68380946f9cc6fe0a2a8f2994299a92e8d907;hp=534fe21f6b154ad8d44edbc7303700054dcac71c;hpb=64040069224344037891a9fe348ac5d3c88590fb;p=jalview.git diff --git a/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java b/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java index 534fe21..f6d3975 100644 --- a/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java +++ b/forester/java/src/org/forester/evoinference/TestPhylogenyReconstruction.java @@ -34,6 +34,7 @@ import java.util.Date; import java.util.List; import java.util.SortedSet; +import org.forester.archaeopteryx.Archaeopteryx; import org.forester.evoinference.distance.NeighborJoining; import org.forester.evoinference.distance.NeighborJoiningF; import org.forester.evoinference.distance.NeighborJoiningR; @@ -90,7 +91,7 @@ public class TestPhylogenyReconstruction { else { System.out.println( " failed." ); } - //timeNeighborJoining(); + // timeNeighborJoining(); } public static boolean test( final File test_dir ) { @@ -2248,10 +2249,7 @@ public class TestPhylogenyReconstruction { final S s0 = new S(); s0.initialize( 1 ); s0.addPairing( 0, 1, 0 ); - s0.addPairing( 7.0000001, 8, 0 ); - s0.addPairing( 7.00000011, 9, 0 ); - s0.addPairing( 7.000000111, 10, 0 ); - s0.addPairing( 7.000000111, 101, 0 ); + s0.addPairing( 7, 8, 0 ); s0.addPairing( 4, 55, 0 ); s0.addPairing( 2, 3, 0 ); s0.addPairing( 4, 5, 0 ); @@ -2265,7 +2263,7 @@ public class TestPhylogenyReconstruction { if ( s0.size() != 1 ) { return false; } - if ( s0.getS( 0 ).size() != 10 ) { + if ( s0.getS( 0 ).size() != 8 ) { return false; } if ( s0.getValues( 0, 0 ).size() != 1 ) { @@ -2289,13 +2287,7 @@ public class TestPhylogenyReconstruction { if ( s0.getValues( 6, 0 ).size() != 1 ) { return false; } - if ( s0.getValues( 7.0000001, 0 ).size() != 1 ) { - return false; - } - if ( s0.getValues( 7.00000011, 0 ).size() != 1 ) { - return false; - } - if ( s0.getValues( 7.000000111, 0 ).size() != 2 ) { + if ( s0.getValues( 7, 0 ).size() != 1 ) { return false; } if ( !s0.getValues( 0, 0 ).contains( 1 ) ) { @@ -2328,15 +2320,15 @@ public class TestPhylogenyReconstruction { if ( s0.getValues( 5, 0 ).size() != 1 ) { return false; } - if ( s0.getS( 0 ).size() != 10 ) { + if ( s0.getS( 0 ).size() != 8 ) { return false; } s0.removePairing( 5, 6, 0 ); - if ( s0.getS( 0 ).size() != 9 ) { + if ( s0.getS( 0 ).size() != 7 ) { return false; } s0.addPairing( 5, 6, 0 ); - if ( s0.getS( 0 ).size() != 10 ) { + if ( s0.getS( 0 ).size() != 8 ) { return false; } if ( s0.getValues( 5, 0 ).size() != 1 ) { @@ -2352,9 +2344,9 @@ public class TestPhylogenyReconstruction { if ( !s0.getValues( 5, 0 ).contains( 403 ) ) { return false; } - s0.addPairing( 693.539324, 100, 0 ); - s0.addPairing( 693.539324, 101, 0 ); - if ( s0.getValues( 693.539324, 0 ).size() != 2 ) { + s0.addPairing( 693, 100, 0 ); + s0.addPairing( 693, 101, 0 ); + if ( s0.getValues( 693, 0 ).size() != 2 ) { return false; } s0.addPairing( 2, 33, 0 ); @@ -2381,39 +2373,6 @@ public class TestPhylogenyReconstruction { if ( !a[ 2 ].contains( 333 ) ) { return false; } - if ( a[ 2 ].size() != 3 ) { - return false; - } - if ( a[ 8 ].size() != 1 ) { - return false; - } - if ( !a[ 8 ].contains( 9 ) ) { - return false; - } - if ( a[ 9 ].size() != 2 ) { - return false; - } - if ( !a[ 9 ].contains( 10 ) ) { - return false; - } - if ( !a[ 9 ].contains( 101 ) ) { - return false; - } - if ( !a[ 10 ].contains( 100 ) ) { - return false; - } - if ( !a[ 10 ].contains( 101 ) ) { - return false; - } - if ( a[ 4 ].size() != 2 ) { - return false; - } - if ( !a[ 4 ].contains( 5 ) ) { - return false; - } - if ( !a[ 4 ].contains( 55 ) ) { - return false; - } } catch ( final Exception e ) { e.printStackTrace( System.out ); @@ -2522,10 +2481,30 @@ public class TestPhylogenyReconstruction { m.setRow( "1.52430 1.44650 0.59580 0.46310 0.00000 0.34840 0.30830", 4 ); m.setRow( "1.60430 1.43890 0.61790 0.50610 0.34840 0.00000 0.26920", 5 ); m.setRow( "1.59050 1.46290 0.55830 0.47100 0.30830 0.26920 0.00000", 6 ); + final NeighborJoining nj = NeighborJoining.createInstance( true, 6 ); + //nj = NeighborJoining.createInstance( true, 6 ); + final Phylogeny pnj = nj.execute( m ); + Archaeopteryx.createApplication( pnj ); + // + m = new BasicSymmetricalDistanceMatrix( 7 ); + m.setIdentifier( 0, "Bovine" ); + m.setIdentifier( 1, "Mouse" ); + m.setIdentifier( 2, "Gibbon" ); + m.setIdentifier( 3, "Orang" ); + m.setIdentifier( 4, "Gorilla" ); + m.setIdentifier( 5, "Chimp" ); + m.setIdentifier( 6, "Human" ); + m.setRow( "0.00000 1.68660 1.71980 1.66060 1.52430 1.60430 1.59050", 0 ); + m.setRow( "1.68660 0.00000 1.52320 1.48410 1.44650 1.43890 1.46290", 1 ); + m.setRow( "1.71980 1.52320 0.00000 0.71150 0.59580 0.61790 0.55830", 2 ); + m.setRow( "1.66060 1.48410 0.71150 0.00000 0.46310 0.50610 0.47100", 3 ); + m.setRow( "1.52430 1.44650 0.59580 0.46310 0.00000 0.34840 0.30830", 4 ); + m.setRow( "1.60430 1.43890 0.61790 0.50610 0.34840 0.00000 0.26920", 5 ); + m.setRow( "1.59050 1.46290 0.55830 0.47100 0.30830 0.26920 0.00000", 6 ); final NeighborJoiningR nj2 = NeighborJoiningR.createInstance( true, 6 ); //nj = NeighborJoining.createInstance( true, 6 ); final Phylogeny p2 = nj2.execute( m ); - // Archaeopteryx.createApplication( p2 ); + Archaeopteryx.createApplication( p2 ); p2.reRoot( p2.getNode( "Bovine" ) ); if ( isUnequal( p2.getNode( "Chimp" ).getDistanceToParent(), 0.151675 ) ) { return false; @@ -2937,6 +2916,15 @@ public class TestPhylogenyReconstruction { } private static void timeNeighborJoining() { + final NeighborJoiningR njr = NeighborJoiningR.createInstance(); + for( int n = 3; n <= 9; ++n ) { + final int x = ( int ) Math.pow( 2, n ); + final BasicSymmetricalDistanceMatrix mt = new BasicSymmetricalDistanceMatrix( x ); + mt.randomize( new Date().getTime() ); + final long start_time = new Date().getTime(); + njr.execute( mt ); + System.out.println( "Size: " + x + " -> " + ( new Date().getTime() - start_time ) + "ms" ); + } final NeighborJoiningF njf = NeighborJoiningF.createInstance(); for( int n = 3; n <= 9; ++n ) { final int x = ( int ) Math.pow( 2, n );