Fixed issue with reading from TreeBase
[jalview.git] / forester / java / src / org / forester / test / Test.java
index 94798ae..3efa354 100644 (file)
@@ -40,6 +40,9 @@ import java.util.Locale;
 import java.util.Set;
 import java.util.SortedSet;
 
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+
 import org.forester.application.support_transfer;
 import org.forester.archaeopteryx.AptxUtil;
 import org.forester.archaeopteryx.TreePanelUtil;
@@ -125,10 +128,7 @@ import org.forester.util.SequenceAccessionTools;
 import org.forester.ws.seqdb.SequenceDatabaseEntry;
 import org.forester.ws.seqdb.SequenceDbWsTools;
 import org.forester.ws.seqdb.UniProtTaxonomy;
-import org.forester.ws.wabi.TxSearch;
-import org.forester.ws.wabi.TxSearch.RANKS;
-import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
-import org.forester.ws.wabi.TxSearch.TAX_RANK;
+
 
 @SuppressWarnings( "unused")
 public final class Test {
@@ -150,7 +150,7 @@ public final class Test {
     private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
     private final static double  ZERO_DIFF                 = 1.0E-9;
 
-    public static boolean isEqual( final double a, final double b ) {
+    private static boolean isEqual( final double a, final double b ) {
         return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
     }
 
@@ -181,15 +181,7 @@ public final class Test {
             System.exit( -1 );
         }
         final long start_time = new Date().getTime();
-        System.out.print( "MSA entropy: " );
-        if ( Test.testMsaEntropy() ) {
-            System.out.println( "OK." );
-            succeeded++;
-        }
-        else {
-            System.out.println( "failed." );
-            failed++;
-        }
+        
         System.out.print( "Basic node methods: " );
         if ( Test.testBasicNodeMethods() ) {
             System.out.println( "OK." );
@@ -931,6 +923,15 @@ public final class Test {
             System.out.println( "failed." );
             failed++;
         }
+        System.out.print( "MSA entropy: " );
+        if ( Test.testMsaEntropy() ) {
+            System.out.println( "OK." );
+            succeeded++;
+        }
+        else {
+            System.out.println( "failed." );
+            failed++;
+        }
         if ( PERFORM_DB_TESTS ) {
             System.out.print( "Uniprot Entry Retrieval: " );
             if ( Test.testUniprotEntryRetrieval() ) {
@@ -971,8 +972,8 @@ public final class Test {
             }
         }
         if ( PERFORM_WEB_TREE_ACCESS ) {
-            System.out.print( "NHX parsing from URL: " );
-            if ( Test.testNHXparsingFromURL() ) {
+            System.out.print( "TreeBase acccess: " );
+            if ( Test.testTreeBaseReading() ) {
                 System.out.println( "OK." );
                 succeeded++;
             }
@@ -980,8 +981,8 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            System.out.print( "NHX parsing from URL 2: " );
-            if ( Test.testNHXparsingFromURL2() ) {
+            System.out.print( "ToL access: " );
+            if ( Test.testToLReading() ) {
                 System.out.println( "OK." );
                 succeeded++;
             }
@@ -989,8 +990,8 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            System.out.print( "phyloXML parsing from URL: " );
-            if ( Test.testPhyloXMLparsingFromURL() ) {
+            System.out.print( "NHX parsing from URL: " );
+            if ( Test.testNHXparsingFromURL() ) {
                 System.out.println( "OK." );
                 succeeded++;
             }
@@ -998,8 +999,8 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            System.out.print( "TreeBase acccess: " );
-            if ( Test.testTreeBaseReading() ) {
+            System.out.print( "NHX parsing from URL 2: " );
+            if ( Test.testNHXparsingFromURL2() ) {
                 System.out.println( "OK." );
                 succeeded++;
             }
@@ -1007,9 +1008,8 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            //
-            System.out.print( "ToL access: " );
-            if ( Test.testToLReading() ) {
+            System.out.print( "phyloXML parsing from URL: " );
+            if ( Test.testPhyloXMLparsingFromURL() ) {
                 System.out.println( "OK." );
                 succeeded++;
             }
@@ -1017,7 +1017,6 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            //
             System.out.print( "TreeFam access: " );
             if ( Test.testTreeFamReading() ) {
                 System.out.println( "OK." );
@@ -1027,8 +1026,6 @@ public final class Test {
                 System.out.println( "failed." );
                 failed++;
             }
-            //
-            //
             System.out.print( "Pfam tree access: " );
             if ( Test.testPfamTreeReading() ) {
                 System.out.println( "OK." );
@@ -1057,7 +1054,7 @@ public final class Test {
         }
     }
 
-    public static boolean testEngulfingOverlapRemoval() {
+    private static boolean testEngulfingOverlapRemoval() {
         try {
             final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
             final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
@@ -1156,7 +1153,7 @@ public final class Test {
         return true;
     }
 
-    public static final boolean testNHXparsingFromURL2() {
+    private static final boolean testNHXparsingFromURL2() {
         try {
             final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
             final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
@@ -1223,7 +1220,7 @@ public final class Test {
         return true;
     }
 
-    public static final boolean testNHXparsingFromURL() {
+    private 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 );
@@ -1291,7 +1288,7 @@ public final class Test {
         return true;
     }
 
-    public static boolean testOverlapRemoval() {
+    private static boolean testOverlapRemoval() {
         try {
             final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
             final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
@@ -1445,49 +1442,61 @@ public final class Test {
         return true;
     }
 
-    public static final boolean testPfamTreeReading() {
+    private static final boolean testPfamTreeReading() {
         try {
             final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
             final NHXParser parser = new NHXParser();
             parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
             parser.setReplaceUnderscores( false );
             parser.setGuessRootedness( true );
-            final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
-            final Phylogeny[] phys = factory.create( u.openStream(), parser );
+            final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser);
             if ( ( phys == null ) || ( phys.length != 1 ) ) {
                 return false;
             }
             if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
                 return false;
             }
+            final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, parser);
+            if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
+                return false;
+            }
+            if ( phys2[ 0 ].getNumberOfExternalNodes() != phys[ 0 ].getNumberOfExternalNodes() ) {
+                return false;
+            }
         }
         catch ( final Exception e ) {
             e.printStackTrace();
+            return false;
         }
         return true;
     }
 
-    public static final boolean testPhyloXMLparsingFromURL() {
+    private 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() );
+            final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
+            
             if ( ( phys == null ) || ( phys.length != 2 ) ) {
                 return false;
             }
+            final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
+            
+            if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
+                return false;
+            }
         }
         catch ( final Exception e ) {
             e.printStackTrace();
+            return false;
         }
         return true;
     }
 
-    public static final boolean testToLReading() {
+    private static final boolean testToLReading() {
         try {
             final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
-            final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
-            final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
+            final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
             if ( ( phys == null ) || ( phys.length != 1 ) ) {
                 return false;
             }
@@ -1500,47 +1509,138 @@ public final class Test {
             if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
                 return false;
             }
+            //
+            final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
+            final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
+            if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
+                return false;
+            }
+            if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
+                return false;
+            }
+            if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
+                return false;
+            }
         }
         catch ( final Exception e ) {
             e.printStackTrace();
+            return false;
         }
         return true;
     }
 
-    public static final boolean testTreeBaseReading() {
+    private static final boolean testTreeBaseReading() {
         try {
-            final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
+            final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );  
             final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
             parser.setReplaceUnderscores( true );
-            final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
-            final Phylogeny[] phys = factory.create( u.openStream(), parser );
+            final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
             if ( ( phys == null ) || ( phys.length != 1 ) ) {
                 return false;
             }
+            final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );  
+            final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
+            final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
+            if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
+                return false;
+            }
+            final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );  
+            final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
+            final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
+            if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
+                return false;
+            }
+            final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );  
+            final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
+            final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
+             if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
+                return false;
+            }
+            final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );  
+            final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
+            final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
+             if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
+                return false;
+            }
             final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
             final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
             parser2.setReplaceUnderscores( true );
-            final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
-            final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
+            final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
             if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
                 return false;
             }
+            final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
+            final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
+            final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
+            if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ),
+                    new NexusPhylogeniesParser() );
+            if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
+                return false;
+            }
+            final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) ,
+                    new NexusPhylogeniesParser() );
+            if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
+                return false;
+            }
         }
         catch ( final Exception e ) {
             e.printStackTrace();
+            return false;
         }
         return true;
     }
 
-    public static final boolean testTreeFamReading() {
+    private static final boolean testTreeFamReading() {
         try {
             final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
             final NHXParser parser = new NHXParser();
             parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
             parser.setReplaceUnderscores( false );
             parser.setGuessRootedness( true );
-            final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
-            final Phylogeny[] phys = factory.create( u.openStream(), parser );
+            final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
             if ( ( phys == null ) || ( phys.length != 1 ) ) {
                 return false;
             }
@@ -1550,6 +1650,7 @@ public final class Test {
         }
         catch ( final Exception e ) {
             e.printStackTrace();
+            return false;
         }
         return true;
     }
@@ -1776,6 +1877,21 @@ public final class Test {
             if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
                 return false;
             }
+            if ( !t3.getNode( "root node" ).isDuplication() ) {
+                return false;
+            }
+            if ( !t3.getNode( "node a" ).isDuplication() ) {
+                return false;
+            }
+            if ( t3.getNode( "node a" ).isSpeciation() ) {
+                return false;
+            }
+            if ( t3.getNode( "node bc" ).isDuplication() ) {
+                return false;
+            }
+            if ( !t3.getNode( "node bc" ).isSpeciation() ) {
+                return false;
+            }
             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
                 return false;
             }
@@ -2103,7 +2219,7 @@ public final class Test {
                 return false;
             }
             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
-                    .getConfidence() != 2144 ) {
+                    .getConfidence() != 0 ) {
                 return false;
             }
             if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
@@ -4016,7 +4132,7 @@ public final class Test {
                 System.out.println( entry.getAnnotations().first().getRefSource() );
                 return false;
             }
-            if ( entry.getCrossReferences().size() != 5 ) {
+            if ( entry.getCrossReferences().size() < 1 ) {
                 return false;
             }
             final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
@@ -4039,7 +4155,7 @@ public final class Test {
                 System.out.println( entry1.getGeneName() );
                 return false;
             }
-            if ( entry1.getCrossReferences().size() != 6 ) {
+            if ( entry1.getCrossReferences().size() < 1 ) {
                 return false;
             }
             final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
@@ -4063,10 +4179,15 @@ public final class Test {
                 System.out.println( entry2.getGeneName() );
                 return false;
             }
-            if ( entry2.getCrossReferences().size() != 3 ) {
+            if ( entry2.getCrossReferences().size() < 1 ) {
+                return false;
+            }
+            if ( !entry2.getChromosome().equals( "20" ) ) {
+                return false;
+            }
+            if ( !entry2.getMap().equals( "20q11.22" ) ) {
                 return false;
             }
-            //
             final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
             if ( !entry3.getAccession().equals( "HM043801" ) ) {
                 return false;
@@ -4090,7 +4211,7 @@ public final class Test {
             if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
                 return false;
             }
-            if ( entry3.getCrossReferences().size() < 7 ) {
+            if ( entry3.getCrossReferences().size() < 1 ) {
                 return false;
             }
             final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
@@ -4113,21 +4234,6 @@ public final class Test {
                 System.out.println( entry4.getGeneName() );
                 return false;
             }
-            //   if ( !entry4.getChromosome().equals( "ras" ) ) {
-            //     System.out.println( entry4.getChromosome() );
-            //     return false;
-            // }
-            // if ( !entry4.getMap().equals( "ras" ) ) {
-            //     System.out.println( entry4.getMap() );
-            //     return false;
-            // }
-            //TODO FIXME gi...
-            //
-            //TODO fails:
-            //            final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
-            //            if ( !entry5.getAccession().equals( "HM043801" ) ) {
-            //                return false;
-            //            }
             final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
             if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
                 return false;
@@ -4144,6 +4250,25 @@ public final class Test {
                 System.out.println( entry5.getTaxonomyIdentifier() );
                 return false;
             }
+            final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
+            if ( !entry6.getAccession().equals( "M30539" ) ) {
+                return false;
+            }
+            if ( !entry6.getGeneName().equals( "ras" ) ) {
+                return false;
+            }
+            if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
+                return false;
+            }
+            if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
+                return false;
+            }
+            if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
+                return false;
+            }
+            if ( entry6.getCrossReferences().size() < 1 ) {
+                return false;
+            }
         }
         catch ( final IOException e ) {
             System.out.println();
@@ -4870,12 +4995,22 @@ public final class Test {
 
     private static boolean testFastaParser() {
         try {
-            if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
+            FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
+            if ( !FastaParser.isLikelyFasta( fis1 ) ) {
+                fis1.close();
                 return false;
             }
-            if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
+            else {
+                fis1.close();
+            }
+            FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
+            if ( FastaParser.isLikelyFasta( fis2 ) ) {
+                fis2.close();
                 return false;
             }
+            else {
+                fis2.close();
+            }
             final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
             if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
                 return false;
@@ -6225,21 +6360,23 @@ public final class Test {
             l.add( s2 );
             l.add( s3 );
             final Msa msa = BasicMsa.createInstance( l );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
-            System.out.println();
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
+            //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+            //FIXME
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
+            //            System.out.println();
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
             final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
             l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
             l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
@@ -6264,10 +6401,10 @@ public final class Test {
             l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
             l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
             final Msa msa2 = BasicMsa.createInstance( l2 );
-            System.out.println();
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
-            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
+            //            System.out.println();
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
+            //            System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
         }
         catch ( final Exception e ) {
             e.printStackTrace( System.out );
@@ -9450,14 +9587,11 @@ public final class Test {
             if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
                 return false;
             }
-            final Phylogeny p12 = factory
-                    .create( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]",
-                             new NHXParser() )[ 0 ];
+            final Phylogeny p12 = factory.create( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]",
+                                                  new NHXParser() )[ 0 ];
             if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
                 return false;
             }
-            
-            
         }
         catch ( final Exception e ) {
             e.printStackTrace( System.out );
@@ -12663,7 +12797,7 @@ public final class Test {
 
     private static boolean testUniprotEntryRetrieval() {
         try {
-            final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
+            final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
             if ( !entry.getAccession().equals( "P12345" ) ) {
                 return false;
             }
@@ -12682,12 +12816,16 @@ public final class Test {
             if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
                 return false;
             }
+            if ( entry.getMolecularSequence() == null ) {
+                return false;
+            }
             if ( !entry
                     .getMolecularSequence()
                     .getMolecularSequenceAsString()
                     .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
                     || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
-                System.out.println( entry.getMolecularSequence().getMolecularSequenceAsString() );
+                System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
+                System.out.println( "expected something else." );
                 return false;
             }
         }
@@ -12697,6 +12835,10 @@ public final class Test {
             e.printStackTrace( System.out );
             return true;
         }
+        catch ( final NullPointerException f ) {
+            f.printStackTrace( System.out );
+            return false;
+        }
         catch ( final Exception e ) {
             return false;
         }
@@ -12886,60 +13028,6 @@ public final class Test {
         }
         return true;
     }
-
-    private static boolean testWabiTxSearch() {
-        try {
-            String result = "";
-            result = TxSearch.searchSimple( "nematostella" );
-            result = TxSearch.getTxId( "nematostella" );
-            if ( !result.equals( "45350" ) ) {
-                return false;
-            }
-            result = TxSearch.getTxName( "45350" );
-            if ( !result.equals( "Nematostella" ) ) {
-                return false;
-            }
-            result = TxSearch.getTxId( "nematostella vectensis" );
-            if ( !result.equals( "45351" ) ) {
-                return false;
-            }
-            result = TxSearch.getTxName( "45351" );
-            if ( !result.equals( "Nematostella vectensis" ) ) {
-                return false;
-            }
-            result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
-            if ( !result.equals( "536089" ) ) {
-                return false;
-            }
-            result = TxSearch.getTxName( "536089" );
-            if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
-                return false;
-            }
-            final List<String> queries = new ArrayList<String>();
-            queries.add( "Campylobacter coli" );
-            queries.add( "Escherichia coli" );
-            queries.add( "Arabidopsis" );
-            queries.add( "Trichoplax" );
-            queries.add( "Samanea saman" );
-            queries.add( "Kluyveromyces marxianus" );
-            queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
-            queries.add( "Bornavirus parrot/PDD/2008" );
-            final List<RANKS> ranks = new ArrayList<RANKS>();
-            ranks.add( RANKS.SUPERKINGDOM );
-            ranks.add( RANKS.KINGDOM );
-            ranks.add( RANKS.FAMILY );
-            ranks.add( RANKS.GENUS );
-            ranks.add( RANKS.TRIBE );
-            result = TxSearch.searchLineage( queries, ranks );
-            result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
-            result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
-        }
-        catch ( final Exception e ) {
-            System.out.println();
-            System.out.println( "the following might be due to absence internet connection:" );
-            e.printStackTrace( System.out );
-            return false;
-        }
-        return true;
-    }
+    
+    
 }