- ///////////////
- 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 );
+ // if ( !a[ 2 ].contains( 333 ) ) {
+ // return false;
+ // }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testNeighborJoiningR() {
+ try {
+ final NeighborJoiningR nj0 = NeighborJoiningR.createInstance();
+ final BasicSymmetricalDistanceMatrix m0 = new BasicSymmetricalDistanceMatrix( 4 );
+ m0.setIdentifier( 0, "A" );
+ m0.setIdentifier( 1, "B" );
+ m0.setIdentifier( 2, "C" );
+ m0.setIdentifier( 3, "D" );
+ m0.setRow( "5 ", 1 );
+ m0.setRow( "3 6 ", 2 );
+ m0.setRow( "7.5 10.5 5.5", 3 );
+ final Phylogeny p0 = nj0.execute( m0 );
+ p0.reRoot( p0.getNode( "D" ) );
+ if ( isUnequal( p0.getNode( "A" ).getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
+ return false;
+ }
+ if ( isUnequal( p0.getNode( "C" ).getDistanceToParent(), 0.5 ) ) {
+ return false;
+ }
+ if ( isUnequal( p0.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
+ return false;
+ }
+ if ( isUnequal( p0.getNode( "A" ).getParent().getDistanceToParent(), 1.5 ) ) {
+ return false;
+ }
+ if ( isUnequal( p0.getNode( "A" ).getParent().getParent().getDistanceToParent(), 2.5 ) ) {
+ return false;
+ }
+ final BasicSymmetricalDistanceMatrix m1 = new BasicSymmetricalDistanceMatrix( 6 );
+ m1.setRow( "5", 1 );
+ m1.setRow( "4 7", 2 );
+ m1.setRow( "7 10 7", 3 );
+ m1.setRow( "6 9 6 5", 4 );
+ m1.setRow( "8 11 8 9 8", 5 );
+ m1.setIdentifier( 0, "A" );
+ m1.setIdentifier( 1, "B" );
+ m1.setIdentifier( 2, "C" );
+ m1.setIdentifier( 3, "D" );
+ m1.setIdentifier( 4, "E" );
+ m1.setIdentifier( 5, "F" );
+ final NeighborJoiningR nj1 = NeighborJoiningR.createInstance();
+ final Phylogeny p1 = nj1.execute( m1 );
+ p1.reRoot( p1.getNode( "F" ) );
+ if ( isUnequal( p1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "B" ).getDistanceToParent(), 4 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "C" ).getDistanceToParent(), 2 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "D" ).getDistanceToParent(), 3 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "E" ).getDistanceToParent(), 2 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "F" ).getDistanceToParent(), 2.5 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "A" ).getParent().getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "A" ).getParent().getParent().getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "A" ).getParent().getParent().getParent().getDistanceToParent(), 2.5 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "B" ).getParent().getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "D" ).getParent().getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ if ( isUnequal( p1.getNode( "E" ).getParent().getDistanceToParent(), 1 ) ) {
+ return false;
+ }
+ final BasicSymmetricalDistanceMatrix m2 = new BasicSymmetricalDistanceMatrix( 7 );
+ m2.setIdentifier( 0, "Bovine" );
+ m2.setIdentifier( 1, "Mouse" );
+ m2.setIdentifier( 2, "Gibbon" );
+ m2.setIdentifier( 3, "Orang" );
+ m2.setIdentifier( 4, "Gorilla" );
+ m2.setIdentifier( 5, "Chimp" );
+ m2.setIdentifier( 6, "Human" );
+ m2.setRow( "0.00000 1.68660 1.71980 1.66060 1.52430 1.60430 1.59050", 0 );
+ m2.setRow( "1.68660 0.00000 1.52320 1.48410 1.44650 1.43890 1.46290", 1 );
+ m2.setRow( "1.71980 1.52320 0.00000 0.71150 0.59580 0.61790 0.55830", 2 );
+ m2.setRow( "1.66060 1.48410 0.71150 0.00000 0.46310 0.50610 0.47100", 3 );
+ m2.setRow( "1.52430 1.44650 0.59580 0.46310 0.00000 0.34840 0.30830", 4 );
+ m2.setRow( "1.60430 1.43890 0.61790 0.50610 0.34840 0.00000 0.26920", 5 );
+ m2.setRow( "1.59050 1.46290 0.55830 0.47100 0.30830 0.26920 0.00000", 6 );