X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Ftest%2FTest.java;h=80a20b6939784166e02f09d83f4806c4c098bb8e;hb=6479c35c4734850f517a6ef8de0fce500fdd6693;hp=ed1daa10831644a3dfe37c83ee094907b5dedfc9;hpb=e22f363c7273fc888ef911ad1f20d520a6bf030e;p=jalview.git diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index ed1daa1..80a20b6 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -912,13 +912,13 @@ public final class Test { path = "C:\\Program Files\\mafft-win\\mafft.bat"; } else { - path = "/home/czmasek/bin/mafft"; - } - if ( !MsaInferrer.isInstalled( path ) ) { path = "mafft"; - } - if ( !MsaInferrer.isInstalled( path ) ) { - path = "/usr/local/bin/mafft"; + if ( !MsaInferrer.isInstalled( path ) ) { + path = "/usr/bin/mafft"; + } + if ( !MsaInferrer.isInstalled( path ) ) { + path = "/usr/local/bin/mafft"; + } } if ( MsaInferrer.isInstalled( path ) ) { System.out.print( "MAFFT (external program): " ); @@ -958,6 +958,15 @@ public final class Test { System.out.println( "failed." ); failed++; } + System.out.print( "phyloXML parsing from URL: " ); + if ( Test.testPhyloXMLparsingFromURL() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } System.out.println(); final Runtime rt = java.lang.Runtime.getRuntime(); final long free_memory = rt.freeMemory() / 1000000; @@ -1075,24 +1084,44 @@ public final class Test { return true; } + public static final boolean testPhyloXMLparsingFromURL() { + try { + final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml"; + final URL u = new URL( s ); + final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); + final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() ); + if ( ( phys == null ) || ( phys.length != 2 ) ) { + return false; + } + } + catch ( final Exception e ) { + e.printStackTrace(); + } + return true; + } + public static final boolean testNHXparsingFromURL() { try { final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh"; final URL u = new URL( s ); final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); final Phylogeny[] phys = factory.create( u, new NHXParser() ); - if ( ( phys == null ) || ( phys.length != 1 ) ) { + if ( ( phys == null ) || ( phys.length != 5 ) ) { return false; } - if ( !phys[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) { + if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { System.out.println( phys[ 0 ].toNewHampshire() ); return false; } + if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) { + System.out.println( phys[ 1 ].toNewHampshire() ); + return false; + } final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() ); - if ( ( phys2 == null ) || ( phys2.length != 1 ) ) { + if ( ( phys2 == null ) || ( phys2.length != 5 ) ) { return false; } - if ( !phys2[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) { + if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { System.out.println( phys2[ 0 ].toNewHampshire() ); return false; } @@ -1103,42 +1132,30 @@ public final class Test { if ( !p.hasNext() ) { return false; } - if ( !p.next().toNewHampshire().equals( "((a,b),c);" ) ) { + if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { return false; } - if ( p.hasNext() ) { - return false; - } - if ( p.next() != null ) { - return false; - } - if ( p.hasNext() ) { - return false; - } - if ( p.next() != null ) { + if ( !p.hasNext() ) { return false; } p.reset(); if ( !p.hasNext() ) { return false; } - if ( !p.next().toNewHampshire().equals( "((a,b),c);" ) ) { - return false; - } - if ( p.hasNext() ) { + if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { return false; } - if ( p.next() != null ) { + if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) { return false; } - if ( p.hasNext() ) { + p.reset(); + if ( !p.hasNext() ) { return false; } - if ( p.next() != null ) { + if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { return false; } - p.reset(); - if ( !p.hasNext() ) { + if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) { return false; } } @@ -5681,10 +5698,10 @@ public final class Test { private static boolean testMsaQualityMethod() { try { - final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" ); - final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" ); - final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" ); - final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" ); + final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" ); + final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" ); + final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" ); + final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" ); final List l = new ArrayList(); l.add( s0 ); l.add( s1 ); @@ -5703,6 +5720,15 @@ public final class Test { if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) { return false; } + if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) { + return false; + } + if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) { + return false; + } + if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) { + return false; + } } catch ( final Exception e ) { e.printStackTrace( System.out );