X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Ftest%2FTest.java;h=0dd12a5987c29039c2980c0572e29ad2d8e395a2;hb=af5e25d369f3240ce41018957383044c12126d98;hp=78fe31be0483ffb5457fbb7cebbfef93ccb8edaa;hpb=9c40cd3d1b7ed7c39c84deeec45490d4615fb792;p=jalview.git diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index 78fe31b..0dd12a5 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -2,8 +2,8 @@ // FORESTER -- software libraries and applications // for evolutionary biology research and applications. // -// Copyright (C) 2008-2009 Christian M. Zmasek -// Copyright (C) 2008-2009 Burnham Institute for Medical Research +// Copyright (C) 2014 Christian M. Zmasek +// Copyright (C) 2014 Sanford-Burnham Medical Research Institute // All rights reserved // // This library is free software; you can redistribute it and/or @@ -20,7 +20,6 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // -// Contact: phylosoft @ gmail . com // WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.test; @@ -29,6 +28,8 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; import java.net.URL; import java.util.ArrayList; import java.util.Date; @@ -40,6 +41,7 @@ import java.util.Set; import java.util.SortedSet; import org.forester.application.support_transfer; +import org.forester.archaeopteryx.AptxUtil; import org.forester.archaeopteryx.TreePanelUtil; import org.forester.archaeopteryx.webservices.WebserviceUtil; import org.forester.development.DevelopmentTools; @@ -62,8 +64,10 @@ import org.forester.io.parsers.util.ParserUtils; import org.forester.io.writers.PhylogenyWriter; import org.forester.io.writers.SequenceWriter; import org.forester.msa.BasicMsa; +import org.forester.msa.DeleteableMsa; import org.forester.msa.Mafft; import org.forester.msa.Msa; +import org.forester.msa.Msa.MSA_FORMAT; import org.forester.msa.MsaInferrer; import org.forester.msa.MsaMethods; import org.forester.pccx.TestPccx; @@ -102,7 +106,7 @@ import org.forester.sdi.SDI; import org.forester.sdi.SDIR; import org.forester.sdi.TestGSDI; import org.forester.sequence.BasicSequence; -import org.forester.sequence.Sequence; +import org.forester.sequence.MolecularSequence; import org.forester.species.BasicSpecies; import org.forester.species.Species; import org.forester.surfacing.TestSurfacing; @@ -135,7 +139,7 @@ public final class Test { private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator(); - private final static boolean PERFORM_DB_TESTS = false; + private final static boolean PERFORM_DB_TESTS = true; private static final boolean PERFORM_WEB_TREE_ACCESS = true; private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/" + ForesterConstants.PHYLO_XML_VERSION + "/" @@ -177,6 +181,15 @@ 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." ); @@ -285,6 +298,15 @@ public final class Test { succeeded++; } System.out.println( "OK." ); + System.out.print( "Taxonomy data extraction: " ); + if ( Test.testExtractTaxonomyDataFromNodeName() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } System.out.print( "Taxonomy code extraction: " ); if ( Test.testExtractTaxonomyCodeFromNodeName() ) { System.out.println( "OK." ); @@ -312,7 +334,6 @@ public final class Test { System.out.println( "failed." ); failed++; } - System.exit( -1 ); System.out.print( "Uri for Aptx web sequence accession: " ); if ( Test.testCreateUriForSeqWeb() ) { System.out.println( "OK." ); @@ -901,6 +922,15 @@ public final class Test { System.out.println( "failed." ); failed++; } + System.out.print( "Deleteable MSA: " ); + if ( Test.testDeleteableMsa() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } if ( PERFORM_DB_TESTS ) { System.out.print( "Uniprot Entry Retrieval: " ); if ( Test.testUniprotEntryRetrieval() ) { @@ -950,6 +980,15 @@ public final class Test { System.out.println( "failed." ); failed++; } + System.out.print( "NHX parsing from URL 2: " ); + if ( Test.testNHXparsingFromURL2() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } System.out.print( "phyloXML parsing from URL: " ); if ( Test.testPhyloXMLparsingFromURL() ) { System.out.println( "OK." ); @@ -1117,6 +1156,72 @@ public final class Test { return true; } + public 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 ), + false, + false, + false, + TAXONOMY_EXTRACTION.NO, + false ); + if ( ( phys == null ) || ( phys.length != 5 ) ) { + return false; + } + 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[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ), + false, + false, + false, + TAXONOMY_EXTRACTION.NO, + false ); + if ( ( phys2 == null ) || ( phys2.length != 5 ) ) { + return false; + } + if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) { + System.out.println( phys2[ 0 ].toNewHampshire() ); + return false; + } + if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) { + System.out.println( phys2[ 1 ].toNewHampshire() ); + return false; + } + final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/" + + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false ); + if ( ( phys3 == null ) || ( phys3.length != 1 ) ) { + return false; + } + if ( !phys3[ 0 ] + .toNewHampshire() + .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) { + System.out.println( phys3[ 0 ].toNewHampshire() ); + return false; + } + final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/" + + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false ); + if ( ( phys4 == null ) || ( phys4.length != 1 ) ) { + return false; + } + if ( !phys4[ 0 ] + .toNewHampshire() + .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) { + System.out.println( phys4[ 0 ].toNewHampshire() ); + 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"; @@ -1456,7 +1561,7 @@ public final class Test { private static boolean testAminoAcidSequence() { try { - final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" ); + final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" ); if ( aa1.getLength() != 13 ) { return false; } @@ -1469,15 +1574,15 @@ public final class Test { if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) { return false; } - final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" ); - if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) { + final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" ); + if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) { return false; } - final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" ); + final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" ); if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) { return false; } - final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" ); + final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" ); if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) { return false; } @@ -2075,7 +2180,6 @@ public final class Test { if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) { return false; } - // if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) { return false; } @@ -2949,7 +3053,6 @@ public final class Test { if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) { return false; } - // final Phylogeny[] t2 = factory .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);", new NHXParser() ); @@ -2959,7 +3062,6 @@ public final class Test { for( final Phylogeny target : t2 ) { ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 ); } - // final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg", new NHXParser() )[ 0 ]; final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() ); @@ -3468,7 +3570,7 @@ public final class Test { if ( t4.getNumberOfExternalNodes() != 5 ) { return false; } - String s = w.toNewHampshire( t4, false, true ).toString(); + String s = w.toNewHampshire( t4, true ).toString(); if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) { return false; } @@ -3489,7 +3591,7 @@ public final class Test { if ( !n.getName().equals( "D" ) ) { return false; } - s = w.toNewHampshire( t4, false, true ).toString(); + s = w.toNewHampshire( t4, true ).toString(); if ( !s.equals( "((A,B12),D);" ) ) { return false; } @@ -3498,7 +3600,7 @@ public final class Test { if ( t5.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t5, false, true ).toString(); + s = w.toNewHampshire( t5, true ).toString(); if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) { return false; } @@ -3507,7 +3609,7 @@ public final class Test { if ( t6.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t6, false, false ).toString(); + s = w.toNewHampshire( t6, false ).toString(); if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) { return false; } @@ -3516,7 +3618,7 @@ public final class Test { if ( t7.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t7, false, true ).toString(); + s = w.toNewHampshire( t7, true ).toString(); if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) { return false; } @@ -3525,7 +3627,7 @@ public final class Test { if ( t8.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t8, false, false ).toString(); + s = w.toNewHampshire( t8, false ).toString(); if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) { return false; } @@ -3534,7 +3636,7 @@ public final class Test { if ( t9.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t9, false, true ).toString(); + s = w.toNewHampshire( t9, true ).toString(); if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) { return false; } @@ -3543,7 +3645,7 @@ public final class Test { if ( t10.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t10, false, true ).toString(); + s = w.toNewHampshire( t10, true ).toString(); if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) { return false; } @@ -3552,7 +3654,7 @@ public final class Test { if ( t11.getNumberOfExternalNodes() != 2 ) { return false; } - s = w.toNewHampshire( t11, false, true ).toString(); + s = w.toNewHampshire( t11, true ).toString(); if ( !s.equals( "(B,C);" ) ) { return false; } @@ -3560,7 +3662,7 @@ public final class Test { if ( t11.getNumberOfExternalNodes() != 1 ) { return false; } - s = w.toNewHampshire( t11, false, false ).toString(); + s = w.toNewHampshire( t11, false ).toString(); if ( !s.equals( "B;" ) ) { return false; } @@ -3569,7 +3671,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 8 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) { return false; } @@ -3577,7 +3679,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 7 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) { return false; } @@ -3585,7 +3687,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 6 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) { return false; } @@ -3593,7 +3695,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) { return false; } @@ -3601,7 +3703,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 4 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "((A2,A3),(C1,C2));" ) ) { return false; } @@ -3609,7 +3711,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 3 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "(A2,(C1,C2));" ) ) { return false; } @@ -3617,7 +3719,7 @@ public final class Test { if ( t12.getNumberOfExternalNodes() != 2 ) { return false; } - s = w.toNewHampshire( t12, false, true ).toString(); + s = w.toNewHampshire( t12, true ).toString(); if ( !s.equals( "(C1,C2);" ) ) { return false; } @@ -3626,7 +3728,7 @@ public final class Test { if ( t13.getNumberOfExternalNodes() != 4 ) { return false; } - s = w.toNewHampshire( t13, false, true ).toString(); + s = w.toNewHampshire( t13, true ).toString(); if ( !s.equals( "(A,B,C,E:5.0);" ) ) { return false; } @@ -3635,7 +3737,7 @@ public final class Test { if ( t14.getNumberOfExternalNodes() != 5 ) { return false; } - s = w.toNewHampshire( t14, false, true ).toString(); + s = w.toNewHampshire( t14, true ).toString(); if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) { return false; } @@ -3894,10 +3996,6 @@ public final class Test { System.out.println( entry.getSequenceName() ); return false; } - // if ( !entry.getSequenceSymbol().equals( "" ) ) { - // System.out.println( entry.getSequenceSymbol() ); - // return false; - // } if ( !entry.getGeneName().equals( "treX-like" ) ) { System.out.println( entry.getGeneName() ); return false; @@ -3917,7 +4015,6 @@ public final class Test { if ( entry.getCrossReferences().size() != 5 ) { return false; } - // final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" ); if ( !entry1.getAccession().equals( "ABJ16409" ) ) { return false; @@ -3941,7 +4038,6 @@ public final class Test { if ( entry1.getCrossReferences().size() != 6 ) { return false; } - // final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" ); if ( !entry2.getAccession().equals( "NM_184234" ) ) { return false; @@ -3993,8 +4089,6 @@ public final class Test { if ( entry3.getCrossReferences().size() != 8 ) { return false; } - // - // final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" ); if ( !entry4.getAccession().equals( "AAA36557" ) ) { return false; @@ -4177,25 +4271,95 @@ public final class Test { if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" ) + if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" ) .equals( "Mus musculus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" ) + if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" ) .equals( "Mus musculus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) { + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) { + return false; + } + if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" ) + if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" ) + .equals( "Mus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" ) .equals( "Mus musculus" ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus" ) + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" ) + .equals( "Mus musculus musculus" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" ) .equals( "Mus musculus musculus" ) ) { return false; } @@ -4206,7 +4370,8 @@ public final class Test { if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" ).equals( "Pilostyles mexicana" ) ) { + if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" ) + .equals( "Pilostyles mexicana" ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" ) @@ -4214,7 +4379,7 @@ public final class Test { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" ) - .equals( "Escherichia coli str K12/DH10B" ) ) { + .equals( "Escherichia coli str. K12/DH10B" ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" ) @@ -4222,7 +4387,7 @@ public final class Test { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" ) - .equals( "Arabidopsis lyrata subsp lyrata" ) ) { + .equals( "Arabidopsis lyrata subsp. lyrata" ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" ) @@ -4238,7 +4403,7 @@ public final class Test { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" ) - .equals( "Arabidopsis lyrata subsp lyrata" ) ) { + .equals( "Arabidopsis lyrata subsp. lyrata" ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" ) @@ -4261,35 +4426,116 @@ public final class Test { .equals( "Escherichia coli (str. K12)" ) ) { return false; } + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" ) + .equals( "Escherichia coli (str. K12)" ) ) { + return false; + } if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" ) .equals( "Escherichia coli (str. K12)" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ) - .equals( "Macrocera sp." ) ) { - - return false; + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" ) + .equals( "Escherichia coli (var. K12)" ) ) { + return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ) - .equals( "Macrocera sp." ) ) { - + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { return false; } - if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ) - .equals( "Macrocera sp." ) ) { - - + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils + .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils + .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" ) + .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) { return false; } if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" ) .equals( "Macrocera sp." ) ) { - - return false; - } if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ) - .equals( "Macrocera sp" ) ) { - - + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" ) + .equals( "Sesamum rigidum subsp. merenskyanum" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" ) + .equals( "Sesamum rigidum subsp. merenskyanum" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" ) + .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) { + return false; + } + if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" ) + .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) { + return false; + } + } + catch ( final Exception e ) { + e.printStackTrace( System.out ); + return false; + } + return true; + } + + private static boolean testExtractTaxonomyDataFromNodeName() { + try { + PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "HNRPR_HUMAN" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { + return false; + } + n = new PhylogenyNode( "HNRPR_HUMAN_X" ); + if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) { return false; } } @@ -4636,7 +4882,7 @@ public final class Test { if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) { return false; } - if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) { + if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) { return false; } if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) { @@ -5924,11 +6170,11 @@ public final class Test { private static boolean testMsaQualityMethod() { try { - 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(); + final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" ); + final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" ); + final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" ); + final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" ); + final List l = new ArrayList(); l.add( s0 ); l.add( s1 ); l.add( s2 ); @@ -5963,6 +6209,227 @@ public final class Test { return true; } + private static boolean testMsaEntropy() { + try { + final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" ); + final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" ); + final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" ); + final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" ); + final List l = new ArrayList(); + l.add( s0 ); + l.add( s1 ); + 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 ) ); + final List l2 = new ArrayList(); + l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) ); + l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) ); + l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) ); + l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) ); + l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) ); + l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) ); + l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) ); + l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) ); + l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) ); + l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) ); + l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) ); + l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) ); + l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) ); + l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) ); + l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) ); + l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) ); + l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) ); + l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) ); + l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) ); + l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) ); + 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 ) ); + } + catch ( final Exception e ) { + e.printStackTrace( System.out ); + return false; + } + return true; + } + + private static boolean testDeleteableMsa() { + try { + final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" ); + final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" ); + final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" ); + final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" ); + final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" ); + final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" ); + final List l0 = new ArrayList(); + l0.add( s0 ); + l0.add( s1 ); + l0.add( s2 ); + l0.add( s3 ); + l0.add( s4 ); + l0.add( s5 ); + final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 ); + dmsa0.deleteRow( "b", false ); + if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) { + return false; + } + dmsa0.deleteRow( "e", false ); + dmsa0.deleteRow( "a", false ); + dmsa0.deleteRow( "f", false ); + if ( dmsa0.getLength() != 4 ) { + return false; + } + if ( dmsa0.getNumberOfSequences() != 2 ) { + return false; + } + if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) { + return false; + } + if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) { + return false; + } + if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) { + return false; + } + if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) { + return false; + } + if ( dmsa0.getColumnAt( 0 ).size() != 2 ) { + return false; + } + dmsa0.deleteRow( "c", false ); + dmsa0.deleteRow( "d", false ); + if ( dmsa0.getNumberOfSequences() != 0 ) { + return false; + } + // + final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" ); + final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" ); + final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" ); + final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" ); + final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" ); + final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" ); + final List l1 = new ArrayList(); + l1.add( s_0 ); + l1.add( s_1 ); + l1.add( s_2 ); + l1.add( s_3 ); + l1.add( s_4 ); + l1.add( s_5 ); + final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 ); + dmsa1.deleteGapOnlyColumns(); + dmsa1.deleteRow( "a", false ); + dmsa1.deleteRow( "f", false ); + dmsa1.deleteRow( "d", false ); + dmsa1.deleteGapOnlyColumns(); + if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) { + return false; + } + if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) { + return false; + } + if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) { + return false; + } + dmsa1.deleteRow( "c", false ); + dmsa1.deleteGapOnlyColumns(); + final Writer w0 = new StringWriter(); + dmsa1.write( w0, MSA_FORMAT.FASTA ); + final Writer w1 = new StringWriter(); + dmsa1.write( w1, MSA_FORMAT.PHYLIP ); + if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) { + return false; + } + if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) { + return false; + } + final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" ); + final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" ); + final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" ); + final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" ); + final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" ); + final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" ); + final List l2 = new ArrayList(); + l2.add( s__0 ); + l2.add( s__1 ); + l2.add( s__2 ); + l2.add( s__3 ); + l2.add( s__4 ); + l2.add( s__5 ); + final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 ); + dmsa2.deleteGapColumns( 0.5 ); + if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) { + return false; + } + if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) { + return false; + } + if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) { + return false; + } + dmsa2.deleteGapColumns( 0.2 ); + if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) { + return false; + } + if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) { + return false; + } + if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) { + return false; + } + dmsa2.deleteGapColumns( 0 ); + dmsa2.deleteRow( "a", false ); + dmsa2.deleteRow( "b", false ); + dmsa2.deleteRow( "f", false ); + dmsa2.deleteRow( "e", false ); + dmsa2.setIdentifier( 0, "new_c" ); + dmsa2.setIdentifier( 1, "new_d" ); + dmsa2.setResidueAt( 0, 0, 'x' ); + final MolecularSequence s = dmsa2.deleteRow( "new_d", true ); + if ( !s.getMolecularSequenceAsString().equals( "D" ) ) { + return false; + } + final Writer w = new StringWriter(); + dmsa2.write( w, MSA_FORMAT.PHYLIP ); + final String phylip = w.toString(); + if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) { + System.out.println( phylip ); + return false; + } + final Writer w2 = new StringWriter(); + dmsa2.write( w2, MSA_FORMAT.FASTA ); + final String fasta = w2.toString(); + if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) { + System.out.println( fasta ); + return false; + } + } + catch ( final Exception e ) { + e.printStackTrace( System.out ); + return false; + } + return true; + } + private static boolean testNextNodeWithCollapsing() { try { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); @@ -6022,8 +6489,6 @@ public final class Test { 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 ]; @@ -6052,8 +6517,6 @@ public final class Test { 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 ]; @@ -6080,8 +6543,6 @@ public final class Test { 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 ]; @@ -6098,8 +6559,6 @@ public final class Test { 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(); @@ -6135,8 +6594,6 @@ public final class Test { 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(); @@ -6170,8 +6627,6 @@ public final class Test { 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(); @@ -6205,8 +6660,6 @@ public final class Test { 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(); @@ -6243,8 +6696,6 @@ public final class Test { 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(); @@ -6278,8 +6729,6 @@ public final class Test { 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(); @@ -6315,8 +6764,6 @@ public final class Test { 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(); @@ -6348,8 +6795,6 @@ public final class Test { 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(); @@ -6384,8 +6829,6 @@ public final class Test { 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(); @@ -6416,8 +6859,6 @@ public final class Test { 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(); @@ -6448,8 +6889,6 @@ public final class Test { 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(); @@ -6906,7 +7345,6 @@ public final class Test { if ( phy != null ) { return false; } - // p.reset(); if ( !p.hasNext() ) { return false; @@ -6928,7 +7366,6 @@ public final class Test { if ( phy != null ) { return false; } - //// p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" ); if ( !p.hasNext() ) { return false; @@ -6950,7 +7387,6 @@ public final class Test { if ( phy != null ) { return false; } - // p.reset(); if ( !p.hasNext() ) { return false; @@ -6972,7 +7408,6 @@ public final class Test { if ( phy != null ) { return false; } - // p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" ); if ( !p.hasNext() ) { return false; @@ -7695,10 +8130,10 @@ public final class Test { nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO ); nhxp.setReplaceUnderscores( true ); final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ]; - if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) { + if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) { return false; } - if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) { + if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) { return false; } final Phylogeny p1b = factory @@ -7989,14 +8424,14 @@ public final class Test { if ( p50.getNode( "A" ) == null ) { return false; } - if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) + if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) .equals( "((A,B)ab:2.0[88],C);" ) ) { return false; } - if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) { + if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) { return false; } - if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ) + if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES ) .equals( "((A,B)88:2.0,C);" ) ) { return false; } @@ -8014,13 +8449,63 @@ public final class Test { if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) { return false; } - // final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ]; if ( p54.getNode( "A" ) == null ) { return false; } - if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) - .equals( "((A,B)[88],C);" ) ) { + if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) { + return false; + } + final Phylogeny p55 = factory + .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1x\":0.0798012);" ), + new NHXParser() )[ 0 ]; + if ( !p55 + .toNewHampshire() + .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,lcl|HPV66_L1.1x:0.0798012);" ) ) { + System.out.println( p55.toNewHampshire() ); + return false; + } + final Phylogeny p56 = factory + .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ), + new NHXParser() )[ 0 ]; + if ( !p56 + .toNewHampshire() + .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) { + System.out.println( p56.toNewHampshire() ); + return false; + } + final Phylogeny p57 = factory + .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ), + new NHXParser() )[ 0 ]; + if ( !p57 + .toNewHampshire() + .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) { + System.out.println( p56.toNewHampshire() ); + return false; + } + final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';"; + final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ]; + if ( !p58.toNewHampshire().equals( s58 ) ) { + System.out.println( p58.toNewHampshire() ); + return false; + } + final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";"; + final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ]; + if ( !p59.toNewHampshire().equals( s59 ) ) { + System.out.println( p59.toNewHampshire() ); + return false; + } + final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');"; + final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ]; + if ( !p60.toNewHampshire().equals( s60 ) ) { + System.out.println( p60.toNewHampshire() ); + return false; + } + final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';"; + final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ]; + if ( !p61.toNewHampshire() + .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) { + System.out.println( p61.toNewHampshire() ); return false; } } @@ -8511,6 +8996,14 @@ public final class Test { System.out.println( n6.toNewHampshireX() ); return false; } + final PhylogenyNode n7 = new PhylogenyNode(); + n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " ); + if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) + .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) { + System.out.println( n7 + .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) ); + return false; + } } catch ( final Exception e ) { e.printStackTrace( System.out ); @@ -8947,6 +9440,12 @@ public final class Test { if ( !p10.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 p11 = factory + .create( " [79] ( ('A: \" ' [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]", + new NHXParser() )[ 0 ]; + 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; + } } catch ( final Exception e ) { e.printStackTrace( System.out ); @@ -9037,13 +9536,13 @@ public final class Test { if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) { return false; } - if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) { + if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) { return false; } if ( phy.getNodes( "noquotes" ).size() != 1 ) { return false; } - if ( phy.getNodes( "A ( B C '" ).size() != 1 ) { + if ( phy.getNodes( "A ( B C '" ).size() != 1 ) { return false; } final NHXParser p1p = new NHXParser(); @@ -9073,7 +9572,7 @@ public final class Test { final Phylogeny p10 = factory .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]", new NHXParser() )[ 0 ]; - final String p10_clean_str = "(('A B':0.2,B:0.3):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]"; + final String p10_clean_str = "(('A B':0.2,B:0.3):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]"; if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) { return false; } @@ -9081,11 +9580,10 @@ public final class Test { if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) { return false; } - // final Phylogeny p12 = factory .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]", new NHXParser() )[ 0 ]; - final String p12_clean_str = "(('A B':0.2[&&NHX:S=monkey!],'BB B':0.03):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]"; + final String p12_clean_str = "(('A B':0.2[&&NHX:S=monkey!],'BB B':0.03):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]"; if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) { return false; } @@ -9093,7 +9591,7 @@ public final class Test { if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) { return false; } - final String p12_clean_str_nh = "(('A B':0.2,'BB B':0.03):0.5,'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1;"; + final String p12_clean_str_nh = "(('A B':0.2,'BB B':0.03):0.5,'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1;"; if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) { return false; } @@ -10776,8 +11274,7 @@ public final class Test { } final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" ); SequenceDbWsTools.obtainSeqInformation( n2 ); - if ( !n2.getNodeData().getSequence().getName() - .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) { + if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) { return false; } if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) { @@ -10829,7 +11326,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10839,7 +11335,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10849,7 +11344,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10859,7 +11353,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10869,7 +11362,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10879,7 +11371,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) { @@ -10889,7 +11380,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) { @@ -10899,7 +11389,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) { @@ -10909,7 +11398,6 @@ public final class Test { } return false; } - // id = SequenceAccessionTools.parseAccessorFromString( "P4A123" ); if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) { @@ -10925,6 +11413,39 @@ public final class Test { System.out.println( "provider=" + id.getSource() ); return false; } + id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" ); + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) + || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) { + if ( id != null ) { + System.out.println( "value =" + id.getValue() ); + System.out.println( "provider=" + id.getSource() ); + } + return false; + } + id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" ); + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) + || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) { + if ( id != null ) { + System.out.println( "value =" + id.getValue() ); + System.out.println( "provider=" + id.getSource() ); + } + return false; + } + id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" ); + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() ) + || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) { + if ( id != null ) { + System.out.println( "value =" + id.getValue() ); + System.out.println( "provider=" + id.getSource() ); + } + return false; + } + id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" ); + if ( id != null ) { + System.out.println( "value =" + id.getValue() ); + System.out.println( "provider=" + id.getSource() ); + return false; + } } catch ( final Exception e ) { e.printStackTrace( System.out ); @@ -11096,14 +11617,12 @@ public final class Test { if ( !s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) ); if ( !s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) ); @@ -11113,7 +11632,6 @@ public final class Test { if ( !s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) ); @@ -11121,7 +11639,6 @@ public final class Test { if ( !s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) ); @@ -11130,14 +11647,12 @@ public final class Test { if ( !s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) ); @@ -11146,7 +11661,6 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) ); @@ -11156,7 +11670,6 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) ); @@ -11164,49 +11677,42 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) ); if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) ); @@ -11214,7 +11720,6 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) ); @@ -11222,7 +11727,6 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) ); @@ -11230,7 +11734,6 @@ public final class Test { if ( s0.match( query_nodes ) ) { return false; } - // query_nodes = new HashSet(); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) ); query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) ); @@ -12015,7 +12518,6 @@ public final class Test { System.out.println( n17.toString() ); return false; } - // final PhylogenyNode n18 = PhylogenyNode .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) { @@ -12042,6 +12544,40 @@ public final class Test { System.out.println( n21.toString() ); return false; } + final PhylogenyNode n23 = PhylogenyNode + .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis", + NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); + if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) { + System.out.println( n23.toString() ); + return false; + } + final PhylogenyNode n24 = PhylogenyNode + .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); + if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) { + System.out.println( n24.toString() ); + return false; + } + // + final PhylogenyNode n25 = PhylogenyNode + .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE", + NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); + if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) { + System.out.println( n25.toString() ); + return false; + } + final PhylogenyNode n26 = PhylogenyNode + .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE", + NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); + if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) { + System.out.println( n26.toString() ); + return false; + } + final PhylogenyNode n27 = PhylogenyNode + .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE ); + if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) { + System.out.println( n27.toString() ); + return false; + } } catch ( final Exception e ) { e.printStackTrace( System.out ); @@ -12134,6 +12670,14 @@ public final class Test { if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) { return false; } + if ( !entry + .getMolecularSequence() + .getMolecularSequenceAsString() + .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" ) + || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) { + System.out.println( entry.getMolecularSequence().getMolecularSequenceAsString() ); + return false; + } } catch ( final IOException e ) { System.out.println();