// 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
// 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;
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;
import java.util.HashSet;
import org.forester.application.support_transfer;
import org.forester.archaeopteryx.TreePanelUtil;
+import org.forester.archaeopteryx.webservices.WebserviceUtil;
import org.forester.development.DevelopmentTools;
import org.forester.evoinference.TestPhylogenyReconstruction;
import org.forester.evoinference.matrix.character.CharacterStateMatrix;
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;
@SuppressWarnings( "unused")
public final class Test {
- private final static boolean PERFORM_DB_TESTS = false;
- private final static double ZERO_DIFF = 1.0E-9;
- private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
- + ForesterUtil.getFileSeparator() + "test_data"
- + ForesterUtil.getFileSeparator();
private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
+ ForesterUtil.getFileSeparator() + "resources"
+ ForesterUtil.getFileSeparator();
- private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
- private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
+ 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 static final boolean PERFORM_WEB_TREE_ACCESS = true;
+ private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
+ ForesterConstants.PHYLO_XML_VERSION + "/"
+ ForesterConstants.PHYLO_XML_XSD;
- private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
+ private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
+ ForesterConstants.PHYLO_XML_VERSION + "/"
+ ForesterConstants.PHYLO_XML_XSD;
-
- public 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 );
- final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
- final List<Boolean> covered = new ArrayList<Boolean>();
- covered.add( true ); // 0
- covered.add( false ); // 1
- covered.add( true ); // 2
- covered.add( false ); // 3
- covered.add( true ); // 4
- covered.add( true ); // 5
- covered.add( false ); // 6
- covered.add( true ); // 7
- covered.add( true ); // 8
- if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
- return false;
- }
- if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
- return false;
- }
- if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
- return false;
- }
- if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
- return false;
- }
- if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
- return false;
- }
- final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
- final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Protein ab = new BasicProtein( "ab", "varanus", 0 );
- ab.addProteinDomain( a );
- ab.addProteinDomain( b );
- final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
- if ( ab.getNumberOfProteinDomains() != 2 ) {
- return false;
- }
- if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
- return false;
- }
- if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
- return false;
- }
- final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
- if ( ab.getNumberOfProteinDomains() != 2 ) {
- return false;
- }
- if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
- return false;
- }
- final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
- final Domain d = new BasicDomain( "d",
- ( short ) 10000,
- ( short ) 10500,
- ( short ) 1,
- ( short ) 1,
- 0.0000001,
- 1 );
- final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
- final Protein cde = new BasicProtein( "cde", "varanus", 0 );
- cde.addProteinDomain( c );
- cde.addProteinDomain( d );
- cde.addProteinDomain( e );
- final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
- if ( cde.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
- final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
- final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
- final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
- final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
- final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
- fghi.addProteinDomain( f );
- fghi.addProteinDomain( g );
- fghi.addProteinDomain( h );
- fghi.addProteinDomain( i );
- fghi.addProteinDomain( i );
- fghi.addProteinDomain( i );
- fghi.addProteinDomain( i2 );
- final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
- if ( fghi.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
- return false;
- }
- if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
- return false;
- }
- final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
- if ( fghi.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
- final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
- final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
- final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
- final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
- final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
- final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
- final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
- jklm.addProteinDomain( j );
- jklm.addProteinDomain( k );
- jklm.addProteinDomain( l );
- jklm.addProteinDomain( m );
- jklm.addProteinDomain( m0 );
- jklm.addProteinDomain( m1 );
- jklm.addProteinDomain( m2 );
- final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
- if ( jklm.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
- return false;
- }
- if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
- return false;
- }
- final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
- if ( jklm.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
- return false;
- }
- final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
- final Protein od = new BasicProtein( "od", "varanus", 0 );
- od.addProteinDomain( only );
- final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
- if ( od.getNumberOfProteinDomains() != 1 ) {
- return false;
- }
- if ( od_s0.getNumberOfProteinDomains() != 1 ) {
- return false;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- public 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 );
- final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
- final List<Boolean> covered = new ArrayList<Boolean>();
- covered.add( true ); // 0
- covered.add( false ); // 1
- covered.add( true ); // 2
- covered.add( false ); // 3
- covered.add( true ); // 4
- covered.add( true ); // 5
- covered.add( false ); // 6
- covered.add( true ); // 7
- covered.add( true ); // 8
- if ( ForesterUtil.isEngulfed( d0, covered ) ) {
- return false;
- }
- if ( ForesterUtil.isEngulfed( d1, covered ) ) {
- return false;
- }
- if ( ForesterUtil.isEngulfed( d2, covered ) ) {
- return false;
- }
- if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
- return false;
- }
- if ( ForesterUtil.isEngulfed( d4, covered ) ) {
- return false;
- }
- if ( ForesterUtil.isEngulfed( d5, covered ) ) {
- return false;
- }
- if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
- return false;
- }
- final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
- final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
- final Protein abc = new BasicProtein( "abc", "nemve", 0 );
- abc.addProteinDomain( a );
- abc.addProteinDomain( b );
- abc.addProteinDomain( c );
- final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
- final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
- if ( abc.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
- return false;
- }
- if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
- return false;
- }
- if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
- return false;
- }
- final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
- final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
- final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
- final Protein def = new BasicProtein( "def", "nemve", 0 );
- def.addProteinDomain( d );
- def.addProteinDomain( e );
- def.addProteinDomain( f );
- final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
- final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
- if ( def.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( def_r1.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( def_r2.getNumberOfProteinDomains() != 3 ) {
- return false;
- }
- if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
- return false;
- }
- if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
- return false;
- }
- if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
- return false;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
+ 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 ) {
return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
System.out.println( "failed." );
failed++;
}
- if ( PERFORM_DB_TESTS ) {
- System.out.print( "Ebi Entry Retrieval: " );
- if ( Test.testEbiEntryRetrieval() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- }
- ///////////////////////////////////////// System.exit( 0 );
System.out.print( "UniProtKB id extraction: " );
if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
System.out.println( "OK." );
System.out.println( "failed." );
failed++;
}
- if ( PERFORM_DB_TESTS ) {
- System.out.print( "Sequence DB tools 2: " );
- if ( testSequenceDbWsTools2() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- System.exit( -1 );
- }
- }
System.out.print( "Hmmscan output parser: " );
if ( testHmmscanOutputParser() ) {
System.out.println( "OK." );
System.out.println( "failed." );
failed++;
}
- //
System.out.print( "Overlap removal: " );
if ( !org.forester.test.Test.testOverlapRemoval() ) {
System.out.println( "failed." );
succeeded++;
}
System.out.println( "OK." );
- //
System.out.print( "Taxonomy code extraction: " );
if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
System.out.println( "OK." );
System.out.println( "failed." );
failed++;
}
- System.out.print( "Amino acid sequence: " );
- if ( Test.testAminoAcidSequence() ) {
- System.out.println( "OK." );
- succeeded++;
+ System.out.print( "Amino acid sequence: " );
+ if ( Test.testAminoAcidSequence() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "General MSA parser: " );
+ if ( Test.testGeneralMsaParser() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Fasta parser for msa: " );
+ if ( Test.testFastaParser() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Creation of balanced phylogeny: " );
+ if ( Test.testCreateBalancedPhylogeny() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Genbank accessor parsing: " );
+ if ( Test.testGenbankAccessorParsing() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ String path = "";
+ final String os = ForesterUtil.OS_NAME.toLowerCase();
+ if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
+ path = "/usr/local/bin/mafft";
+ }
+ else if ( os.indexOf( "win" ) >= 0 ) {
+ path = "C:\\Program Files\\mafft-win\\mafft.bat";
}
else {
- System.out.println( "failed." );
- failed++;
+ path = "mafft";
+ if ( !MsaInferrer.isInstalled( path ) ) {
+ path = "/usr/bin/mafft";
+ }
+ if ( !MsaInferrer.isInstalled( path ) ) {
+ path = "/usr/local/bin/mafft";
+ }
}
- System.out.print( "General MSA parser: " );
- if ( Test.testGeneralMsaParser() ) {
+ if ( MsaInferrer.isInstalled( path ) ) {
+ System.out.print( "MAFFT (external program): " );
+ if ( Test.testMafft( path ) ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed [will not count towards failed tests]" );
+ }
+ }
+ System.out.print( "Next nodes with collapsed: " );
+ if ( Test.testNextNodeWithCollapsing() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Fasta parser for msa: " );
- if ( Test.testFastaParser() ) {
+ System.out.print( "Simple MSA quality: " );
+ if ( Test.testMsaQualityMethod() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Creation of balanced phylogeny: " );
- if ( Test.testCreateBalancedPhylogeny() ) {
+ System.out.print( "Deleteable MSA: " );
+ if ( Test.testDeleteableMsa() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Genbank accessor parsing: " );
- if ( Test.testGenbankAccessorParsing() ) {
+ if ( PERFORM_DB_TESTS ) {
+ System.out.print( "Uniprot Entry Retrieval: " );
+ if ( Test.testUniprotEntryRetrieval() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Ebi Entry Retrieval: " );
+ if ( Test.testEbiEntryRetrieval() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Sequence DB tools 2: " );
+ if ( testSequenceDbWsTools2() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ System.exit( -1 );
+ }
+ System.out.print( "Uniprot Taxonomy Search: " );
+ if ( Test.testUniprotTaxonomySearch() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ }
+ if ( PERFORM_WEB_TREE_ACCESS ) {
+ System.out.print( "NHX parsing from URL: " );
+ if ( Test.testNHXparsingFromURL() ) {
+ 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." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "TreeBase acccess: " );
+ if ( Test.testTreeBaseReading() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ //
+ System.out.print( "ToL access: " );
+ if ( Test.testToLReading() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ //
+ System.out.print( "TreeFam access: " );
+ if ( Test.testTreeFamReading() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ //
+ //
+ System.out.print( "Pfam tree access: " );
+ if ( Test.testPfamTreeReading() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ }
+ System.out.println();
+ final Runtime rt = java.lang.Runtime.getRuntime();
+ final long free_memory = rt.freeMemory() / 1000000;
+ final long total_memory = rt.totalMemory() / 1000000;
+ System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
+ + free_memory + "MB, total memory: " + total_memory + "MB)" );
+ System.out.println();
+ System.out.println( "Successful tests: " + succeeded );
+ System.out.println( "Failed tests: " + failed );
+ System.out.println();
+ if ( failed < 1 ) {
System.out.println( "OK." );
- succeeded++;
}
- else {
- System.out.println( "failed." );
- failed++;
+ else {
+ System.out.println( "Not OK." );
+ }
+ }
+
+ public 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 );
+ final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final List<Boolean> covered = new ArrayList<Boolean>();
+ covered.add( true ); // 0
+ covered.add( false ); // 1
+ covered.add( true ); // 2
+ covered.add( false ); // 3
+ covered.add( true ); // 4
+ covered.add( true ); // 5
+ covered.add( false ); // 6
+ covered.add( true ); // 7
+ covered.add( true ); // 8
+ if ( ForesterUtil.isEngulfed( d0, covered ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isEngulfed( d1, covered ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isEngulfed( d2, covered ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isEngulfed( d4, covered ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isEngulfed( d5, covered ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
+ return false;
+ }
+ final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
+ final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
+ final Protein abc = new BasicProtein( "abc", "nemve", 0 );
+ abc.addProteinDomain( a );
+ abc.addProteinDomain( b );
+ abc.addProteinDomain( c );
+ final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
+ final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
+ if ( abc.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
+ return false;
+ }
+ if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
+ return false;
+ }
+ if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
+ return false;
+ }
+ final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
+ final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
+ final Protein def = new BasicProtein( "def", "nemve", 0 );
+ def.addProteinDomain( d );
+ def.addProteinDomain( e );
+ def.addProteinDomain( f );
+ final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
+ final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
+ if ( def.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( def_r1.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( def_r2.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
+ return false;
+ }
+ if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
+ return false;
+ }
+ if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ public static final boolean testNHXparsingFromURL() {
+ try {
+ final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
+ final URL u = new URL( s );
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny[] phys = factory.create( u, new NHXParser() );
+ if ( ( phys == null ) || ( phys.length != 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 = factory.create( u.openStream(), new NHXParser() );
+ 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;
+ }
+ final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
+ final NHXParser p = new NHXParser();
+ final URL u2 = new URL( s );
+ p.setSource( u2 );
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
+ return false;
+ }
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ p.reset();
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
+ return false;
+ }
+ p.reset();
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
- if ( PERFORM_DB_TESTS ) {
- System.out.print( "Uniprot Entry Retrieval: " );
- if ( Test.testUniprotEntryRetrieval() ) {
- System.out.println( "OK." );
- succeeded++;
+ return true;
+ }
+
+ public 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 );
+ final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
+ final List<Boolean> covered = new ArrayList<Boolean>();
+ covered.add( true ); // 0
+ covered.add( false ); // 1
+ covered.add( true ); // 2
+ covered.add( false ); // 3
+ covered.add( true ); // 4
+ covered.add( true ); // 5
+ covered.add( false ); // 6
+ covered.add( true ); // 7
+ covered.add( true ); // 8
+ if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
+ return false;
}
- else {
- System.out.println( "failed." );
- failed++;
+ if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
+ return false;
}
- }
- if ( PERFORM_DB_TESTS ) {
- System.out.print( "Uniprot Taxonomy Search: " );
- if ( Test.testUniprotTaxonomySearch() ) {
- System.out.println( "OK." );
- succeeded++;
+ if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
+ return false;
}
- else {
- System.out.println( "failed." );
- failed++;
+ if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
+ return false;
+ }
+ if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
+ return false;
+ }
+ final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
+ final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
+ final Protein ab = new BasicProtein( "ab", "varanus", 0 );
+ ab.addProteinDomain( a );
+ ab.addProteinDomain( b );
+ final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
+ if ( ab.getNumberOfProteinDomains() != 2 ) {
+ return false;
+ }
+ if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
+ return false;
+ }
+ if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
+ return false;
+ }
+ final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
+ if ( ab.getNumberOfProteinDomains() != 2 ) {
+ return false;
+ }
+ if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
+ return false;
+ }
+ final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
+ final Domain d = new BasicDomain( "d",
+ ( short ) 10000,
+ ( short ) 10500,
+ ( short ) 1,
+ ( short ) 1,
+ 0.0000001,
+ 1 );
+ final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
+ final Protein cde = new BasicProtein( "cde", "varanus", 0 );
+ cde.addProteinDomain( c );
+ cde.addProteinDomain( d );
+ cde.addProteinDomain( e );
+ final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
+ if ( cde.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
+ return false;
+ }
+ final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
+ final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
+ final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
+ final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
+ final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
+ final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
+ fghi.addProteinDomain( f );
+ fghi.addProteinDomain( g );
+ fghi.addProteinDomain( h );
+ fghi.addProteinDomain( i );
+ fghi.addProteinDomain( i );
+ fghi.addProteinDomain( i );
+ fghi.addProteinDomain( i2 );
+ final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
+ if ( fghi.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
+ return false;
+ }
+ if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
+ return false;
+ }
+ final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
+ if ( fghi.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
+ final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
+ final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
+ final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
+ final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
+ final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
+ final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
+ final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
+ jklm.addProteinDomain( j );
+ jklm.addProteinDomain( k );
+ jklm.addProteinDomain( l );
+ jklm.addProteinDomain( m );
+ jklm.addProteinDomain( m0 );
+ jklm.addProteinDomain( m1 );
+ jklm.addProteinDomain( m2 );
+ final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
+ if ( jklm.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
+ return false;
+ }
+ if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
+ return false;
+ }
+ final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
+ if ( jklm.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
+ return false;
+ }
+ final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
+ final Protein od = new BasicProtein( "od", "varanus", 0 );
+ od.addProteinDomain( only );
+ final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
+ if ( od.getNumberOfProteinDomains() != 1 ) {
+ return false;
+ }
+ if ( od_s0.getNumberOfProteinDomains() != 1 ) {
+ return false;
}
}
- //----
- String path = "";
- final String os = ForesterUtil.OS_NAME.toLowerCase();
- if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
- path = "/usr/local/bin/mafft";
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
}
- else if ( os.indexOf( "win" ) >= 0 ) {
- path = "C:\\Program Files\\mafft-win\\mafft.bat";
+ return true;
+ }
+
+ public 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 );
+ if ( ( phys == null ) || ( phys.length != 1 ) ) {
+ return false;
+ }
+ if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
+ return false;
+ }
}
- else {
- path = "/home/czmasek/bin/mafft";
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
- if ( !MsaInferrer.isInstalled( path ) ) {
- path = "mafft";
+ return true;
+ }
+
+ public static final boolean testPhyloXMLparsingFromURL() {
+ try {
+ final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
+ final URL u = new URL( s );
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
+ if ( ( phys == null ) || ( phys.length != 2 ) ) {
+ return false;
+ }
}
- if ( !MsaInferrer.isInstalled( path ) ) {
- path = "/usr/local/bin/mafft";
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
- if ( MsaInferrer.isInstalled( path ) ) {
- System.out.print( "MAFFT (external program): " );
- if ( Test.testMafft( path ) ) {
- System.out.println( "OK." );
- succeeded++;
+ return true;
+ }
+
+ public 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() );
+ if ( ( phys == null ) || ( phys.length != 1 ) ) {
+ return false;
}
- else {
- System.out.println( "failed [will not count towards failed tests]" );
+ if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
+ return false;
+ }
+ if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
+ return false;
+ }
+ if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
+ return false;
}
}
- //----
- System.out.print( "Next nodes with collapsed: " );
- if ( Test.testNextNodeWithCollapsing() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
- System.out.print( "Simple MSA quality: " );
- if ( Test.testMsaQualityMethod() ) {
- System.out.println( "OK." );
- succeeded++;
+ return true;
+ }
+
+ public static final boolean testTreeBaseReading() {
+ try {
+ final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
+ final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
+ parser.setReplaceUnderscores( true );
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny[] phys = factory.create( u.openStream(), parser );
+ if ( ( phys == null ) || ( phys.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 );
+ if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
+ return false;
+ }
}
- else {
- System.out.println( "failed." );
- failed++;
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
- System.out.println();
- final Runtime rt = java.lang.Runtime.getRuntime();
- final long free_memory = rt.freeMemory() / 1000000;
- final long total_memory = rt.totalMemory() / 1000000;
- System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
- + free_memory + "MB, total memory: " + total_memory + "MB)" );
- System.out.println();
- System.out.println( "Successful tests: " + succeeded );
- System.out.println( "Failed tests: " + failed );
- System.out.println();
- if ( failed < 1 ) {
- System.out.println( "OK." );
+ return true;
+ }
+
+ public 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 );
+ if ( ( phys == null ) || ( phys.length != 1 ) ) {
+ return false;
+ }
+ if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
+ return false;
+ }
}
- else {
- System.out.println( "Not OK." );
+ catch ( final Exception e ) {
+ e.printStackTrace();
}
+ return true;
}
private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
private static boolean testBasicPhyloXMLparsing() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final PhyloXmlParser xml_parser = new PhyloXmlParser();
+ final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
xml_parser );
if ( xml_parser.getErrorCount() > 0 ) {
private static boolean testBasicPhyloXMLparsingRoundtrip() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final PhyloXmlParser xml_parser = new PhyloXmlParser();
+ final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
}
// Do nothing -- means were not running from jar.
}
if ( xml_parser == null ) {
- xml_parser = new PhyloXmlParser();
+ xml_parser = PhyloXmlParser.createPhyloXmlParser();
if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
}
private static boolean testBasicTreeMethods() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny t1 = factory.create();
- if ( !t1.isEmpty() ) {
- return false;
- }
final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
if ( t2.getNumberOfExternalNodes() != 4 ) {
return false;
return true;
}
- private static boolean testTreeCopy() {
- try {
- final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])";
- final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
- final Phylogeny t1 = t0.copy();
- if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
- return false;
- }
- if ( !t1.toNewHampshireX().equals( str_0 ) ) {
- return false;
- }
- t0.deleteSubtree( t0.getNode( "c" ), true );
- t0.deleteSubtree( t0.getNode( "a" ), true );
- t0.deleteSubtree( t0.getNode( "e" ), true );
- if ( !t0.toNewHampshireX().equals( "(b,d)[&&NHX:S=lizards]" ) ) {
- return false;
- }
- if ( !t1.toNewHampshireX().equals( str_0 ) ) {
- return false;
- }
- t0.deleteSubtree( t0.getNode( "b" ), true );
- t0.deleteSubtree( t0.getNode( "d" ), true );
- if ( !t1.toNewHampshireX().equals( str_0 ) ) {
- return false;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
private static boolean testCreateBalancedPhylogeny() {
try {
final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
return true;
}
- private static boolean testGenbankAccessorParsing() {
- //The format for GenBank Accession numbers are:
- //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
- //Protein: 3 letters + 5 numerals
- //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
- return false;
- }
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
- return false;
- }
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
- return false;
- }
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
- return false;
- }
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
- return false;
- }
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
- return false;
- }
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
- return false;
+ private static boolean testEbiEntryRetrieval() {
+ try {
+ final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
+ if ( !entry.getAccession().equals( "AAK41263" ) ) {
+ System.out.println( entry.getAccession() );
+ return false;
+ }
+ if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
+ System.out.println( entry.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry.getSequenceName()
+ .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
+ 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;
+ }
+ if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
+ System.out.println( entry.getTaxonomyIdentifier() );
+ return false;
+ }
+ if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
+ System.out.println( entry.getAnnotations().first().getRefValue() );
+ return false;
+ }
+ if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
+ System.out.println( entry.getAnnotations().first().getRefSource() );
+ return false;
+ }
+ if ( entry.getCrossReferences().size() != 5 ) {
+ return false;
+ }
+ //
+ final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
+ if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
+ return false;
+ }
+ if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
+ System.out.println( entry1.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
+ System.out.println( entry1.getSequenceName() );
+ return false;
+ }
+ if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
+ System.out.println( entry1.getTaxonomyIdentifier() );
+ return false;
+ }
+ if ( !entry1.getGeneName().equals( "BCL2" ) ) {
+ System.out.println( entry1.getGeneName() );
+ return false;
+ }
+ if ( entry1.getCrossReferences().size() != 6 ) {
+ return false;
+ }
+ //
+ final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
+ if ( !entry2.getAccession().equals( "NM_184234" ) ) {
+ return false;
+ }
+ if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
+ System.out.println( entry2.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry2.getSequenceName()
+ .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
+ System.out.println( entry2.getSequenceName() );
+ return false;
+ }
+ if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
+ System.out.println( entry2.getTaxonomyIdentifier() );
+ return false;
+ }
+ if ( !entry2.getGeneName().equals( "RBM39" ) ) {
+ System.out.println( entry2.getGeneName() );
+ return false;
+ }
+ if ( entry2.getCrossReferences().size() != 3 ) {
+ return false;
+ }
+ //
+ final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
+ if ( !entry3.getAccession().equals( "HM043801" ) ) {
+ return false;
+ }
+ if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
+ System.out.println( entry3.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
+ System.out.println( entry3.getSequenceName() );
+ return false;
+ }
+ if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
+ System.out.println( entry3.getTaxonomyIdentifier() );
+ return false;
+ }
+ if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
+ System.out.println( entry3.getSequenceSymbol() );
+ return false;
+ }
+ if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
+ return false;
+ }
+ if ( entry3.getCrossReferences().size() != 8 ) {
+ return false;
+ }
+ //
+ //
+ final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
+ if ( !entry4.getAccession().equals( "AAA36557" ) ) {
+ return false;
+ }
+ if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
+ System.out.println( entry4.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
+ System.out.println( entry4.getSequenceName() );
+ return false;
+ }
+ if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
+ System.out.println( entry4.getTaxonomyIdentifier() );
+ return false;
+ }
+ if ( !entry4.getGeneName().equals( "ras" ) ) {
+ 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;
+ }
+ if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
+ System.out.println( entry5.getTaxonomyScientificName() );
+ return false;
+ }
+ if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
+ System.out.println( entry5.getSequenceName() );
+ return false;
+ }
+ if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
+ System.out.println( entry5.getTaxonomyIdentifier() );
+ return false;
+ }
}
- if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
- return false;
+ catch ( final IOException e ) {
+ System.out.println();
+ System.out.println( "the following might be due to absence internet connection:" );
+ e.printStackTrace( System.out );
+ return true;
}
- if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
+ catch ( final Exception e ) {
+ e.printStackTrace();
return false;
}
return true;
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( " -1234_Mus_musculus-12 affrre e" )
+ 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" )
.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_2bcl2" )
+ .equals( "Mus musculus musculus" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
+ .equals( "Mus musculus musculus" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
+ .equals( "Mus musculus musculus" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
+ .equals( "Pilostyles mexicana" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
+ .equals( "Escherichia coli strain K12/DH10B" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
+ .equals( "Escherichia coli str. K12/DH10B" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
+ .equals( "Escherichia coli str. K12/DH10B" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
+ .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
+ .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
+ .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
+ .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
+ .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
+ .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
+ .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
+ .equals( "Escherichia coli (strain K12)" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
+ .equals( "Escherichia coli (strain K12)" ) ) {
+ return false;
+ }
+ if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
+ .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( "Escherichia coli (var K12) bcl2" )
+ .equals( "Escherichia coli (var. K12)" ) ) {
+ 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( "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." ) ) {
+ 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 true;
}
+ private static boolean testGenbankAccessorParsing() {
+ //The format for GenBank Accession numbers are:
+ //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
+ //Protein: 3 letters + 5 numerals
+ //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
+ return false;
+ }
+ if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
+ return false;
+ }
+ if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
+ return false;
+ }
+ return true;
+ }
+
private static boolean testGeneralMsaParser() {
try {
final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
private static boolean testGetLCA2() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
+ // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
+ final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
PhylogenyMethods.preOrderReId( p_a );
final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
p_a.getNode( "a" ) );
if ( !p_a_1.getName().equals( "a" ) ) {
return false;
}
- final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
+ final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
PhylogenyMethods.preOrderReId( p_b );
final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
p_b.getNode( "a" ) );
if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
return false;
}
- if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
+ if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
+ return false;
+ }
+ if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
return false;
}
final Protein p1 = proteins.get( 0 );
if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
return false;
}
- if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
- return false;
- }
- if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
- return false;
- }
if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
return false;
}
private static boolean testMsaQualityMethod() {
try {
- final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
- final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
- final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
- final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
+ final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
+ final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
+ final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
+ final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
final List<Sequence> l = new ArrayList<Sequence>();
l.add( s0 );
l.add( s1 );
if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
return false;
}
- if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
+ if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testDeleteableMsa() {
+ try {
+ final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
+ final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
+ final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
+ final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
+ final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
+ final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
+ final List<Sequence> l0 = new ArrayList<Sequence>();
+ 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" );
+ if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
+ return false;
+ }
+ dmsa0.deleteRow( "e" );
+ dmsa0.deleteRow( "a" );
+ dmsa0.deleteRow( "f" );
+ 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" );
+ dmsa0.deleteRow( "d" );
+ if ( dmsa0.getNumberOfSequences() != 0 ) {
+ return false;
+ }
+ //
+ final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
+ final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
+ final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
+ final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
+ final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
+ final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
+ final List<Sequence> l1 = new ArrayList<Sequence>();
+ 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" );
+ dmsa1.deleteRow( "f" );
+ dmsa1.deleteRow( "d" );
+ 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" );
+ 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 Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
+ final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
+ final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
+ final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
+ final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
+ final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
+ final List<Sequence> l2 = new ArrayList<Sequence>();
+ 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 ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
+ if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
return false;
}
- if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
+ 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" );
+ dmsa2.deleteRow( "b" );
+ dmsa2.deleteRow( "f" );
+ dmsa2.deleteRow( "e" );
+ dmsa2.setIdentifier( 0, "new_c" );
+ dmsa2.setIdentifier( 1, "new_d" );
+ dmsa2.setResidueAt( 0, 0, 'x' );
+ dmsa2.deleteRow( "new_d" );
+ final Writer w = new StringWriter();
+ dmsa2.write( w, MSA_FORMAT.PHYLIP );
+ final String phylip = w.toString();
+ if ( !phylip.equals( "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
+ 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 ) ) {
return false;
}
}
if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
return false;
}
+ final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
+ phylogenies = null;
+ phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
+ if ( phylogenies.length != 9 ) {
+ return false;
+ }
+ if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
+ .getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
+ .getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
+ return false;
+ }
+ if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
+ return false;
+ }
+ if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
if ( phy != null ) {
return false;
}
- ////
+ //
p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
if ( !p.hasNext() ) {
return false;
if ( phy != null ) {
return false;
}
- ////
+ //
p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
- // if ( phylogenies.length != 18 ) {
- // return false;
- // }
- //0
if ( !p.hasNext() ) {
return false;
}
+ //0
phy = p.next();
if ( phy == null ) {
return false;
return false;
}
if ( phy.getNumberOfExternalNodes() != 3 ) {
+ System.out.println( phy.toString() );
return false;
}
if ( !phy.getName().equals( "" ) ) {
if ( phy.isRooted() ) {
return false;
}
+ //
+ final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
+ p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
+ // 0
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
+ return false;
+ }
+ // 1
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 2
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 3
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 4
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 5
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 6
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 7
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ // 8
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ if ( phy != null ) {
+ return false;
+ }
+ // 0
+ p2.reset();
+ if ( !p2.hasNext() ) {
+ return false;
+ }
+ phy = p2.next();
+ if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
+ return false;
+ }
+ if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
.equals( "Aranaeus" ) ) {
return false;
}
+ phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
+ if ( phylogenies.length != 3 ) {
+ return false;
+ }
+ if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
+ 0.00100049 ) ) {
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
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
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;
}
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;
}
}
if ( p.next() != null ) {
return false;
}
+ //
+ final String p30_str = "(A,B);(C,D)";
+ final NHXParser p30 = new NHXParser();
+ p30.setSource( p30_str );
+ if ( !p30.hasNext() ) {
+ return false;
+ }
+ Phylogeny phy30 = p30.next();
+ if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
+ System.out.println( phy30.toNewHampshire() );
+ return false;
+ }
+ if ( !p30.hasNext() ) {
+ return false;
+ }
+ Phylogeny phy301 = p30.next();
+ if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
+ System.out.println( phy301.toNewHampshire() );
+ return false;
+ }
+ if ( p30.hasNext() ) {
+ return false;
+ }
+ if ( p30.hasNext() ) {
+ return false;
+ }
+ if ( p30.next() != null ) {
+ return false;
+ }
+ if ( p30.next() != null ) {
+ return false;
+ }
+ p30.reset();
+ if ( !p30.hasNext() ) {
+ return false;
+ }
+ phy30 = p30.next();
+ if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
+ System.out.println( phy30.toNewHampshire() );
+ return false;
+ }
+ if ( !p30.hasNext() ) {
+ return false;
+ }
+ phy301 = p30.next();
+ if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
+ System.out.println( phy301.toNewHampshire() );
+ return false;
+ }
+ if ( p30.hasNext() ) {
+ return false;
+ }
+ if ( p30.hasNext() ) {
+ return false;
+ }
+ if ( p30.next() != null ) {
+ return false;
+ }
+ if ( p30.next() != null ) {
+ return false;
+ }
}
catch ( final Exception e ) {
e.printStackTrace( System.out );
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 );
return false;
}
final PhylogenyNode n13 = PhylogenyNode
- .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
+ .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
return false;
}
if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
return false;
}
final PhylogenyNode n19 = PhylogenyNode
- .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
return false;
}
return false;
}
final PhylogenyNode n30 = PhylogenyNode
- .createInstanceFromNhxString( "blah_1234567-roejojoej",
+ .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
return false;
return false;
}
final PhylogenyNode n31 = PhylogenyNode
- .createInstanceFromNhxString( "blah_12345678-roejojoej",
+ .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
if ( n31.getNodeData().isHasTaxonomy() ) {
return false;
return false;
}
final PhylogenyNode n40 = PhylogenyNode
- .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
return false;
}
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 );
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();
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;
}
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;
}
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;
}
// Do nothing -- means were not running from jar.
}
if ( xml_parser == null ) {
- xml_parser = new PhyloXmlParser();
+ xml_parser = PhyloXmlParser.createPhyloXmlParser();
if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
}
}
if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
return false;
- }
- if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
- return false;
- }
- if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
- return false;
- }
- if ( !p8[ 0 ].getRoot().isDuplication() ) {
- return false;
- }
- if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
- return false;
- }
- if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
- return false;
- }
- if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
- return false;
- }
- if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
- return false;
- }
- if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
- return false;
- }
- if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
- return false;
- }
- if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
- return false;
- }
- p8 = null;
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- private static boolean testSequenceIdParsing() {
- try {
- Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
- if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
- || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
- 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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
+ }
+ if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
+ if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
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" ) ) {
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
- }
+ if ( !p8[ 0 ].getRoot().isDuplication() ) {
return false;
}
- id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
- if ( id != null ) {
- System.out.println( "value =" + id.getValue() );
- System.out.println( "provider=" + id.getSource() );
+ if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
return false;
}
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- private static boolean testSequenceWriter() {
- try {
- final String n = ForesterUtil.LINE_SEPARATOR;
- if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
+ if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
+ if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
+ if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
+ if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
- .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
+ if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
- .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
+ if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
return false;
}
+ p8 = null;
}
catch ( final Exception e ) {
- e.printStackTrace();
+ e.printStackTrace( System.out );
return false;
}
return true;
}
- private static boolean testSpecies() {
+ private static boolean testSequenceDbWsTools1() {
try {
- final Species s1 = new BasicSpecies( "a" );
- final Species s2 = new BasicSpecies( "a" );
- final Species s3 = new BasicSpecies( "A" );
- final Species s4 = new BasicSpecies( "b" );
- if ( !s1.equals( s1 ) ) {
+ final PhylogenyNode n = new PhylogenyNode();
+ n.setName( "NP_001025424" );
+ Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
+ || !acc.getValue().equals( "NP_001025424" ) ) {
return false;
}
- if ( s1.getSpeciesId().equals( "x" ) ) {
+ n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
+ || !acc.getValue().equals( "NP_001025424" ) ) {
return false;
}
- if ( s1.getSpeciesId().equals( null ) ) {
+ n.setName( "NP_001025424.1" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
+ || !acc.getValue().equals( "NP_001025424" ) ) {
return false;
}
- if ( !s1.equals( s2 ) ) {
+ n.setName( "NM_001030253" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
+ || !acc.getValue().equals( "NM_001030253" ) ) {
return false;
}
- if ( s1.equals( s3 ) ) {
+ n.setName( "BCL2_HUMAN" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
+ || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.hashCode() != s1.hashCode() ) {
+ n.setName( "P10415" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
+ || !acc.getValue().equals( "P10415" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.hashCode() != s2.hashCode() ) {
+ n.setName( " P10415 " );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
+ || !acc.getValue().equals( "P10415" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.hashCode() == s3.hashCode() ) {
+ n.setName( "_P10415|" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
+ || !acc.getValue().equals( "P10415" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.compareTo( s1 ) != 0 ) {
+ n.setName( "AY695820" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AY695820" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.compareTo( s2 ) != 0 ) {
+ n.setName( "_AY695820_" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AY695820" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.compareTo( s3 ) != 0 ) {
+ n.setName( "AAA59452" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AAA59452" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s1.compareTo( s4 ) >= 0 ) {
+ n.setName( "_AAA59452_" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AAA59452" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s4.compareTo( s1 ) <= 0 ) {
+ n.setName( "AAA59452.1" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AAA59452.1" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( !s4.getSpeciesId().equals( "b" ) ) {
+ n.setName( "_AAA59452.1_" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AAA59452.1" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- final Species s5 = new BasicSpecies( " C " );
- if ( !s5.getSpeciesId().equals( "C" ) ) {
+ n.setName( "GI:94894583" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
+ || !acc.getValue().equals( "94894583" ) ) {
+ System.out.println( acc.toString() );
return false;
}
- if ( s5.equals( s1 ) ) {
+ n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
+ || !acc.getValue().equals( "71845847" ) ) {
+ System.out.println( acc.toString() );
+ return false;
+ }
+ n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
+ acc = SequenceDbWsTools.obtainSeqAccession( n );
+ if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
+ || !acc.getValue().equals( "AAZ45343.1" ) ) {
+ System.out.println( acc.toString() );
return false;
}
}
catch ( final Exception e ) {
- e.printStackTrace( System.out );
return false;
}
return true;
}
- private static boolean testSplit() {
+ private static boolean testSequenceDbWsTools2() {
try {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
- //Archaeopteryx.createApplication( p0 );
- final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
- ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
- // System.out.println( s0.toString() );
- //
- Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- if ( s0.match( query_nodes ) ) {
- return false;
- }
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( !s0.match( query_nodes ) ) {
- return false;
- }
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- if ( !s0.match( query_nodes ) ) {
+ final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
+ SequenceDbWsTools.obtainSeqInformation( n1 );
+ if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( !s0.match( query_nodes ) ) {
+ 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" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( !s0.match( query_nodes ) ) {
+ if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- if ( s0.match( query_nodes ) ) {
+ final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
+ SequenceDbWsTools.obtainSeqInformation( n3 );
+ if ( !n3.getNodeData().getSequence().getName()
+ .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( s0.match( query_nodes ) ) {
+ }
+ catch ( final IOException e ) {
+ System.out.println();
+ System.out.println( "the following might be due to absence internet connection:" );
+ e.printStackTrace( System.out );
+ return true;
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testSequenceIdParsing() {
+ try {
+ Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
+ if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
+ || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
//
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- if ( s0.match( query_nodes ) ) {
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
//
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- if ( s0.match( query_nodes ) ) {
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ 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" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ //
+ id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
+ if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
+ || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
+ if ( id != null ) {
+ System.out.println( "value =" + id.getValue() );
+ System.out.println( "provider=" + id.getSource() );
+ }
return false;
}
- /////////
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "A" ) );
- // query_nodes.add( new PhylogenyNode( "B" ) );
- // query_nodes.add( new PhylogenyNode( "C" ) );
- // query_nodes.add( new PhylogenyNode( "D" ) );
- // query_nodes.add( new PhylogenyNode( "E" ) );
- // query_nodes.add( new PhylogenyNode( "F" ) );
- // query_nodes.add( new PhylogenyNode( "G" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "A" ) );
- // query_nodes.add( new PhylogenyNode( "B" ) );
- // query_nodes.add( new PhylogenyNode( "C" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- // //
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "D" ) );
- // query_nodes.add( new PhylogenyNode( "E" ) );
- // query_nodes.add( new PhylogenyNode( "F" ) );
- // query_nodes.add( new PhylogenyNode( "G" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- // //
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "A" ) );
- // query_nodes.add( new PhylogenyNode( "B" ) );
- // query_nodes.add( new PhylogenyNode( "C" ) );
- // query_nodes.add( new PhylogenyNode( "D" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- // //
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "E" ) );
- // query_nodes.add( new PhylogenyNode( "F" ) );
- // query_nodes.add( new PhylogenyNode( "G" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- // //
- // query_nodes = new HashSet<PhylogenyNode>();
- // query_nodes.add( new PhylogenyNode( "X" ) );
- // query_nodes.add( new PhylogenyNode( "Y" ) );
- // query_nodes.add( new PhylogenyNode( "F" ) );
- // query_nodes.add( new PhylogenyNode( "G" ) );
- // if ( !s0.match( query_nodes ) ) {
- // return false;
- // }
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
+ 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 );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testSequenceWriter() {
+ try {
+ final String n = ForesterUtil.LINE_SEPARATOR;
+ if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
return false;
}
- ///////////////////////////
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
+ .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
+ .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- if ( s0.match( query_nodes ) ) {
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testSpecies() {
+ try {
+ final Species s1 = new BasicSpecies( "a" );
+ final Species s2 = new BasicSpecies( "a" );
+ final Species s3 = new BasicSpecies( "A" );
+ final Species s4 = new BasicSpecies( "b" );
+ if ( !s1.equals( s1 ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( s1.getSpeciesId().equals( "x" ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( s1.getSpeciesId().equals( null ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( !s1.equals( s2 ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( s1.equals( s3 ) ) {
return false;
}
- //
- query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( s1.hashCode() != s1.hashCode() ) {
+ return false;
+ }
+ if ( s1.hashCode() != s2.hashCode() ) {
+ return false;
+ }
+ if ( s1.hashCode() == s3.hashCode() ) {
+ return false;
+ }
+ if ( s1.compareTo( s1 ) != 0 ) {
+ return false;
+ }
+ if ( s1.compareTo( s2 ) != 0 ) {
+ return false;
+ }
+ if ( s1.compareTo( s3 ) != 0 ) {
+ return false;
+ }
+ if ( s1.compareTo( s4 ) >= 0 ) {
+ return false;
+ }
+ if ( s4.compareTo( s1 ) <= 0 ) {
+ return false;
+ }
+ if ( !s4.getSpeciesId().equals( "b" ) ) {
+ return false;
+ }
+ final Species s5 = new BasicSpecies( " C " );
+ if ( !s5.getSpeciesId().equals( "C" ) ) {
+ return false;
+ }
+ if ( s5.equals( s1 ) ) {
return false;
}
}
catch ( final Exception e ) {
- e.printStackTrace();
+ e.printStackTrace( System.out );
return false;
}
return true;
}
- private static boolean testSplitStrict() {
+ private static boolean testSplit() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
+ //Archaeopteryx.createApplication( p0 );
final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
+ final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
+ // System.out.println( s0.toString() );
+ //
Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
}
//
query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
+ return false;
+ }
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
if ( s0.match( query_nodes ) ) {
return false;
}
//
query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
if ( s0.match( query_nodes ) ) {
return false;
}
+ /////////
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "A" ) );
+ // query_nodes.add( new PhylogenyNode( "B" ) );
+ // query_nodes.add( new PhylogenyNode( "C" ) );
+ // query_nodes.add( new PhylogenyNode( "D" ) );
+ // query_nodes.add( new PhylogenyNode( "E" ) );
+ // query_nodes.add( new PhylogenyNode( "F" ) );
+ // query_nodes.add( new PhylogenyNode( "G" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "A" ) );
+ // query_nodes.add( new PhylogenyNode( "B" ) );
+ // query_nodes.add( new PhylogenyNode( "C" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
+ // //
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "D" ) );
+ // query_nodes.add( new PhylogenyNode( "E" ) );
+ // query_nodes.add( new PhylogenyNode( "F" ) );
+ // query_nodes.add( new PhylogenyNode( "G" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
+ // //
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "A" ) );
+ // query_nodes.add( new PhylogenyNode( "B" ) );
+ // query_nodes.add( new PhylogenyNode( "C" ) );
+ // query_nodes.add( new PhylogenyNode( "D" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
+ // //
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "E" ) );
+ // query_nodes.add( new PhylogenyNode( "F" ) );
+ // query_nodes.add( new PhylogenyNode( "G" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
+ // //
+ // query_nodes = new HashSet<PhylogenyNode>();
+ // query_nodes.add( new PhylogenyNode( "X" ) );
+ // query_nodes.add( new PhylogenyNode( "Y" ) );
+ // query_nodes.add( new PhylogenyNode( "F" ) );
+ // query_nodes.add( new PhylogenyNode( "G" ) );
+ // if ( !s0.match( query_nodes ) ) {
+ // return false;
+ // }
//
query_nodes = new HashSet<PhylogenyNode>();
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
if ( s0.match( query_nodes ) ) {
return false;
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
if ( s0.match( query_nodes ) ) {
return false;
}
+ ///////////////////////////
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
if ( s0.match( query_nodes ) ) {
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
}
//
query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
}
}
catch ( final Exception e ) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- private static boolean testSubtreeDeletion() {
- try {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
- t1.deleteSubtree( t1.getNode( "A" ), false );
- if ( t1.getNumberOfExternalNodes() != 5 ) {
- return false;
- }
- t1.toNewHampshireX();
- t1.deleteSubtree( t1.getNode( "E" ), false );
- if ( t1.getNumberOfExternalNodes() != 4 ) {
- return false;
- }
- t1.toNewHampshireX();
- t1.deleteSubtree( t1.getNode( "F" ), false );
- if ( t1.getNumberOfExternalNodes() != 3 ) {
- return false;
- }
- t1.toNewHampshireX();
- t1.deleteSubtree( t1.getNode( "D" ), false );
- t1.toNewHampshireX();
- if ( t1.getNumberOfExternalNodes() != 3 ) {
- return false;
- }
- t1.deleteSubtree( t1.getNode( "def" ), false );
- t1.toNewHampshireX();
- if ( t1.getNumberOfExternalNodes() != 2 ) {
- return false;
- }
- t1.deleteSubtree( t1.getNode( "B" ), false );
- t1.toNewHampshireX();
- if ( t1.getNumberOfExternalNodes() != 1 ) {
- return false;
- }
- t1.deleteSubtree( t1.getNode( "C" ), false );
- t1.toNewHampshireX();
- if ( t1.getNumberOfExternalNodes() != 1 ) {
- return false;
- }
- t1.deleteSubtree( t1.getNode( "abc" ), false );
- t1.toNewHampshireX();
- if ( t1.getNumberOfExternalNodes() != 1 ) {
- return false;
- }
- t1.deleteSubtree( t1.getNode( "r" ), false );
- if ( t1.getNumberOfExternalNodes() != 0 ) {
- return false;
- }
- if ( !t1.isEmpty() ) {
- return false;
- }
- final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
- t2.deleteSubtree( t2.getNode( "A" ), false );
- t2.toNewHampshireX();
- if ( t2.getNumberOfExternalNodes() != 5 ) {
- return false;
- }
- t2.deleteSubtree( t2.getNode( "abc" ), false );
- t2.toNewHampshireX();
- if ( t2.getNumberOfExternalNodes() != 3 ) {
- return false;
- }
- t2.deleteSubtree( t2.getNode( "def" ), false );
- t2.toNewHampshireX();
- if ( t2.getNumberOfExternalNodes() != 1 ) {
- return false;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- private static boolean testSupportCount() {
- try {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
- final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
- + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
- + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
- + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
- + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
- new NHXParser() );
- SupportCount.count( t0_1, phylogenies_1, true, false );
- final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
- final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
- + "(((((A,B),C),D),E),((F,G),X))"
- + "(((((A,Y),B),C),D),((F,G),E))"
- + "(((((A,B),C),D),E),(F,G))"
- + "(((((A,B),C),D),E),(F,G))"
- + "(((((A,B),C),D),E),(F,G))"
- + "(((((A,B),C),D),E),(F,G),Z)"
- + "(((((A,B),C),D),E),(F,G))"
- + "((((((A,B),C),D),E),F),G)"
- + "(((((X,Y),F,G),E),((A,B),C)),D)",
- new NHXParser() );
- SupportCount.count( t0_2, phylogenies_2, true, false );
- final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
- while ( it.hasNext() ) {
- final PhylogenyNode n = it.next();
- if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
- return false;
- }
- }
- final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
- final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
- + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
- SupportCount.count( t0_3, phylogenies_3, true, false );
- t0_3.reRoot( t0_3.getNode( "def" ).getId() );
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
- return false;
- }
- if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
- return false;
- }
- final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
- + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
- SupportCount.count( t0_4, phylogenies_4, true, false );
- t0_4.reRoot( t0_4.getNode( "F" ).getId() );
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testSplitStrict() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
+ final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
+ Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( !s0.match( query_nodes ) ) {
return false;
}
- Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- double d = SupportCount.compare( b1, a, true, true, true );
- if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- d = SupportCount.compare( b2, a, true, true, true );
- if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
- final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
- d = SupportCount.compare( b3, a, true, true, true );
- if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
- final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
- d = SupportCount.compare( b4, a, true, true, false );
- if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- private static boolean testSupportTransfer() {
- try {
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny p1 = factory.create( "(((A,B)ab:97,C)abc:57,((D,E)de:10,(F,G)fg:50,(H,I)hi:64)defghi)",
- new NHXParser() )[ 0 ];
- final Phylogeny p2 = factory
- .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- support_transfer.moveBranchLengthsToBootstrap( p1 );
- support_transfer.transferSupportValues( p1, p2 );
- if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
- if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
+ //
+ query_nodes = new HashSet<PhylogenyNode>();
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
+ query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
+ if ( s0.match( query_nodes ) ) {
return false;
}
}
catch ( final Exception e ) {
- e.printStackTrace( System.out );
+ e.printStackTrace();
return false;
}
return true;
}
- private static boolean testTaxonomyExtraction() {
+ private static boolean testSubtreeDeletion() {
try {
- final PhylogenyNode n0 = PhylogenyNode
- .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n0.getNodeData().isHasTaxonomy() ) {
- return false;
- }
- final PhylogenyNode n1 = PhylogenyNode
- .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n1.getNodeData().isHasTaxonomy() ) {
- System.out.println( n1.toString() );
- return false;
- }
- final PhylogenyNode n2x = PhylogenyNode
- .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n2x.getNodeData().isHasTaxonomy() ) {
- return false;
- }
- final PhylogenyNode n3 = PhylogenyNode
- .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
- System.out.println( n3.toString() );
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
+ t1.deleteSubtree( t1.getNode( "A" ), false );
+ if ( t1.getNumberOfExternalNodes() != 5 ) {
return false;
}
- final PhylogenyNode n4 = PhylogenyNode
- .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n4.getNodeData().isHasTaxonomy() ) {
- System.out.println( n4.toString() );
+ t1.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "E" ), false );
+ if ( t1.getNumberOfExternalNodes() != 4 ) {
return false;
}
- final PhylogenyNode n5 = PhylogenyNode
- .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n5.getNodeData().isHasTaxonomy() ) {
- System.out.println( n5.toString() );
+ t1.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "F" ), false );
+ if ( t1.getNumberOfExternalNodes() != 3 ) {
return false;
}
- final PhylogenyNode n6 = PhylogenyNode
- .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n6.getNodeData().isHasTaxonomy() ) {
- System.out.println( n6.toString() );
+ t1.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "D" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 3 ) {
return false;
}
- final PhylogenyNode n7 = PhylogenyNode
- .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n7.getNodeData().isHasTaxonomy() ) {
- System.out.println( n7.toString() );
+ t1.deleteSubtree( t1.getNode( "def" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 2 ) {
return false;
}
- final PhylogenyNode n8 = PhylogenyNode
- .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
- System.out.println( n8.toString() );
+ t1.deleteSubtree( t1.getNode( "B" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
return false;
}
- final PhylogenyNode n9 = PhylogenyNode
- .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
- System.out.println( n9.toString() );
+ t1.deleteSubtree( t1.getNode( "C" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
return false;
}
- final PhylogenyNode n10x = PhylogenyNode
- .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n10x.getNodeData().isHasTaxonomy() ) {
- System.out.println( n10x.toString() );
+ t1.deleteSubtree( t1.getNode( "abc" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
return false;
}
- final PhylogenyNode n10xx = PhylogenyNode
- .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n10xx.getNodeData().isHasTaxonomy() ) {
- System.out.println( n10xx.toString() );
+ t1.deleteSubtree( t1.getNode( "r" ), false );
+ if ( t1.getNumberOfExternalNodes() != 0 ) {
return false;
}
- final PhylogenyNode n10 = PhylogenyNode
- .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
- System.out.println( n10.toString() );
+ if ( !t1.isEmpty() ) {
return false;
}
- final PhylogenyNode n11 = PhylogenyNode
- .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
- if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
- System.out.println( n11.toString() );
+ final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
+ t2.deleteSubtree( t2.getNode( "A" ), false );
+ t2.toNewHampshireX();
+ if ( t2.getNumberOfExternalNodes() != 5 ) {
return false;
}
- final PhylogenyNode n12 = PhylogenyNode
- .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
- NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
- if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
- System.out.println( n12.toString() );
+ t2.deleteSubtree( t2.getNode( "abc" ), false );
+ t2.toNewHampshireX();
+ if ( t2.getNumberOfExternalNodes() != 3 ) {
return false;
}
- final PhylogenyNode n13 = PhylogenyNode
- .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
- if ( n13.getNodeData().isHasTaxonomy() ) {
- System.out.println( n13.toString() );
+ t2.deleteSubtree( t2.getNode( "def" ), false );
+ t2.toNewHampshireX();
+ if ( t2.getNumberOfExternalNodes() != 1 ) {
return false;
}
}
return true;
}
- private static boolean testTreeMethods() {
+ private static boolean testSupportCount() {
try {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
- PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
- if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
- System.out.println( t0.toNewHampshireX() );
+ final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
+ final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
+ + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
+ + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
+ + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
+ + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
+ new NHXParser() );
+ SupportCount.count( t0_1, phylogenies_1, true, false );
+ final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
+ final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
+ + "(((((A,B),C),D),E),((F,G),X))"
+ + "(((((A,Y),B),C),D),((F,G),E))"
+ + "(((((A,B),C),D),E),(F,G))"
+ + "(((((A,B),C),D),E),(F,G))"
+ + "(((((A,B),C),D),E),(F,G))"
+ + "(((((A,B),C),D),E),(F,G),Z)"
+ + "(((((A,B),C),D),E),(F,G))"
+ + "((((((A,B),C),D),E),F),G)"
+ + "(((((X,Y),F,G),E),((A,B),C)),D)",
+ new NHXParser() );
+ SupportCount.count( t0_2, phylogenies_2, true, false );
+ final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
+ while ( it.hasNext() ) {
+ final PhylogenyNode n = it.next();
+ if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
+ return false;
+ }
+ }
+ final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
+ final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
+ + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
+ SupportCount.count( t0_3, phylogenies_3, true, false );
+ t0_3.reRoot( t0_3.getNode( "def" ).getId() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
return false;
}
- final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
- PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
- if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
return false;
}
- if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
return false;
}
- if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
return false;
}
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- return true;
- }
-
- private static boolean testSequenceDbWsTools1() {
- try {
- final PhylogenyNode n = new PhylogenyNode();
- n.setName( "NP_001025424" );
- Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
- || !acc.getValue().equals( "NP_001025424" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
return false;
}
- n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
- || !acc.getValue().equals( "NP_001025424" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
return false;
}
- n.setName( "NP_001025424.1" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
- || !acc.getValue().equals( "NP_001025424" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
return false;
}
- n.setName( "NM_001030253" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
- || !acc.getValue().equals( "NM_001030253" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
return false;
}
- n.setName( "BCL2_HUMAN" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
- || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
return false;
}
- n.setName( "P10415" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
- || !acc.getValue().equals( "P10415" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
return false;
}
- n.setName( " P10415 " );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
- || !acc.getValue().equals( "P10415" ) ) {
- System.out.println( acc.toString() );
+ final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
+ + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
+ SupportCount.count( t0_4, phylogenies_4, true, false );
+ t0_4.reRoot( t0_4.getNode( "F" ).getId() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
return false;
}
- n.setName( "_P10415|" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
- || !acc.getValue().equals( "P10415" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
return false;
}
- n.setName( "AY695820" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AY695820" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
return false;
}
- n.setName( "_AY695820_" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AY695820" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
return false;
}
- n.setName( "AAA59452" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AAA59452" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
return false;
}
- n.setName( "_AAA59452_" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AAA59452" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
return false;
}
- n.setName( "AAA59452.1" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AAA59452.1" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
return false;
}
- n.setName( "_AAA59452.1_" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
- || !acc.getValue().equals( "AAA59452.1" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
return false;
}
- n.setName( "GI:94894583" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
- || !acc.getValue().equals( "94894583" ) ) {
- System.out.println( acc.toString() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
+ return false;
+ }
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
+ return false;
+ }
+ Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ double d = SupportCount.compare( b1, a, true, true, true );
+ if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
+ return false;
+ }
+ a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ d = SupportCount.compare( b2, a, true, true, true );
+ if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
+ return false;
+ }
+ a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
+ final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
+ d = SupportCount.compare( b3, a, true, true, true );
+ if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
+ return false;
+ }
+ a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
+ final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
+ d = SupportCount.compare( b4, a, true, true, false );
+ if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
return false;
}
}
catch ( final Exception e ) {
+ e.printStackTrace( System.out );
return false;
}
return true;
- }
-
- private static boolean testSequenceDbWsTools2() {
- try {
- final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
- SequenceDbWsTools.obtainSeqInformation( n1 );
- if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
- return false;
- }
- if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
- return false;
- }
- if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ }
+
+ private static boolean testSupportTransfer() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny p1 = factory.create( "(((A,B)ab:97,C)abc:57,((D,E)de:10,(F,G)fg:50,(H,I)hi:64)defghi)",
+ new NHXParser() )[ 0 ];
+ final Phylogeny p2 = factory
+ .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
return false;
}
- if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
return false;
}
- final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
- SequenceDbWsTools.obtainSeqInformation( n2 );
- System.out.println( n2.toString() );
- if ( !n2.getNodeData().getSequence().getName()
- .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
+ support_transfer.moveBranchLengthsToBootstrap( p1 );
+ support_transfer.transferSupportValues( p1, p2 );
+ if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
return false;
}
- if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
+ if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
return false;
}
- if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
return false;
}
- if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
return false;
}
- final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
- SequenceDbWsTools.obtainSeqInformation( n3 );
- System.out.println( "n=" + n3.toString() );
- if ( !n3.getNodeData().getSequence().getName()
- .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
return false;
}
- if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
return false;
}
- if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
return false;
}
- if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
return false;
}
}
- catch ( final IOException e ) {
- System.out.println();
- System.out.println( "the following might be due to absence internet connection:" );
- e.printStackTrace( System.out );
- return true;
- }
catch ( final Exception e ) {
- e.printStackTrace();
+ e.printStackTrace( System.out );
return false;
}
return true;
}
- private static boolean testEbiEntryRetrieval() {
+ private static boolean testTaxonomyExtraction() {
try {
- final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
- if ( !entry.getAccession().equals( "AAK41263" ) ) {
- System.out.println( entry.getAccession() );
+ final PhylogenyNode n0 = PhylogenyNode
+ .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n0.getNodeData().isHasTaxonomy() ) {
return false;
}
- if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
- System.out.println( entry.getTaxonomyScientificName() );
+ final PhylogenyNode n1 = PhylogenyNode
+ .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n1.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n1.toString() );
return false;
}
- if ( !entry.getSequenceName()
- .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
- System.out.println( entry.getSequenceName() );
+ final PhylogenyNode n2x = PhylogenyNode
+ .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n2x.getNodeData().isHasTaxonomy() ) {
return false;
}
- // if ( !entry.getSequenceSymbol().equals( "" ) ) {
- // System.out.println( entry.getSequenceSymbol() );
- // return false;
- // }
- if ( !entry.getGeneName().equals( "treX-like" ) ) {
- System.out.println( entry.getGeneName() );
+ final PhylogenyNode n3 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
+ System.out.println( n3.toString() );
return false;
}
- if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
- System.out.println( entry.getTaxonomyIdentifier() );
+ final PhylogenyNode n4 = PhylogenyNode
+ .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n4.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n4.toString() );
return false;
}
- if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
- System.out.println( entry.getAnnotations().first().getRefValue() );
+ final PhylogenyNode n5 = PhylogenyNode
+ .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n5.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n5.toString() );
return false;
}
- if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
- System.out.println( entry.getAnnotations().first().getRefSource() );
+ final PhylogenyNode n6 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n6.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n6.toString() );
return false;
}
- if ( entry.getCrossReferences().size() != 5 ) {
+ final PhylogenyNode n7 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n7.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n7.toString() );
return false;
}
- //
- final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
- if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
+ final PhylogenyNode n8 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
+ System.out.println( n8.toString() );
return false;
}
- if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
- System.out.println( entry1.getTaxonomyScientificName() );
+ final PhylogenyNode n9 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
+ System.out.println( n9.toString() );
return false;
}
- if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
- System.out.println( entry1.getSequenceName() );
+ final PhylogenyNode n10x = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n10x.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n10x.toString() );
return false;
}
- if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
- System.out.println( entry1.getTaxonomyIdentifier() );
+ final PhylogenyNode n10xx = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n10xx.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n10xx.toString() );
return false;
}
- if ( !entry1.getGeneName().equals( "BCL2" ) ) {
- System.out.println( entry1.getGeneName() );
+ final PhylogenyNode n10 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
+ System.out.println( n10.toString() );
return false;
}
- if ( entry1.getCrossReferences().size() != 6 ) {
+ final PhylogenyNode n11 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
+ System.out.println( n11.toString() );
return false;
}
- //
- final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
- if ( !entry2.getAccession().equals( "NM_184234" ) ) {
+ final PhylogenyNode n12 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
+ NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
+ System.out.println( n12.toString() );
return false;
}
- if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
- System.out.println( entry2.getTaxonomyScientificName() );
+ final PhylogenyNode n13 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( n13.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n13.toString() );
return false;
}
- if ( !entry2.getSequenceName()
- .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
- System.out.println( entry2.getSequenceName() );
+ final PhylogenyNode n14 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
+ System.out.println( n14.toString() );
return false;
}
- if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
- System.out.println( entry2.getTaxonomyIdentifier() );
+ final PhylogenyNode n15 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
+ System.out.println( n15.toString() );
return false;
}
- if ( !entry2.getGeneName().equals( "RBM39" ) ) {
- System.out.println( entry2.getGeneName() );
+ final PhylogenyNode n16 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
+ System.out.println( n16.toString() );
return false;
}
- if ( entry2.getCrossReferences().size() != 3 ) {
+ final PhylogenyNode n17 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
+ System.out.println( n17.toString() );
return false;
}
//
- final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
- if ( !entry3.getAccession().equals( "HM043801" ) ) {
+ final PhylogenyNode n18 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
+ System.out.println( n18.toString() );
return false;
}
- if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
- System.out.println( entry3.getTaxonomyScientificName() );
+ final PhylogenyNode n19 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
+ NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
+ System.out.println( n19.toString() );
return false;
}
- if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
- System.out.println( entry3.getSequenceName() );
+ final PhylogenyNode n20 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
+ System.out.println( n20.toString() );
return false;
}
- if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
- System.out.println( entry3.getTaxonomyIdentifier() );
+ final PhylogenyNode n21 = PhylogenyNode
+ .createInstanceFromNhxString( "Mus musculus musculus K392",
+ NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
+ System.out.println( n21.toString() );
return false;
}
- if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
- System.out.println( entry3.getSequenceSymbol() );
+ final PhylogenyNode n22 = PhylogenyNode
+ .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
+ NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
+ System.out.println( n22.toString() );
return false;
}
- if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
+ 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;
}
- if ( entry3.getCrossReferences().size() != 8 ) {
+ 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 SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
- if ( !entry4.getAccession().equals( "AAA36557" ) ) {
+ 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;
}
- if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
- System.out.println( entry4.getTaxonomyScientificName() );
+ 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;
}
- if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
- System.out.println( entry4.getSequenceName() );
+ 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;
}
- if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
- System.out.println( entry4.getTaxonomyIdentifier() );
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testTreeCopy() {
+ try {
+ final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
+ final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
+ final Phylogeny t1 = t0.copy();
+ if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
return false;
}
- if ( !entry4.getGeneName().equals( "ras" ) ) {
- System.out.println( entry4.getGeneName() );
+ if ( !t1.toNewHampshireX().equals( str_0 ) ) {
+ return false;
+ }
+ t0.deleteSubtree( t0.getNode( "c" ), true );
+ t0.deleteSubtree( t0.getNode( "a" ), true );
+ t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
+ t0.getNode( "b" ).setName( "Bee" );
+ if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
+ return false;
+ }
+ if ( !t1.toNewHampshireX().equals( str_0 ) ) {
+ return false;
+ }
+ t0.deleteSubtree( t0.getNode( "e" ), true );
+ t0.deleteSubtree( t0.getNode( "Bee" ), true );
+ t0.deleteSubtree( t0.getNode( "d" ), true );
+ if ( !t1.toNewHampshireX().equals( str_0 ) ) {
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 fails:
- // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
- // if ( !entry5.getAccession().equals( "HM043801" ) ) {
- // return false;
- // }
- }
- catch ( final IOException e ) {
- System.out.println();
- System.out.println( "the following might be due to absence internet connection:" );
- e.printStackTrace( System.out );
- return true;
}
catch ( final Exception e ) {
e.printStackTrace();
return true;
}
+ private static boolean testTreeMethods() {
+ try {
+ final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
+ final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
+ PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
+ if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
+ System.out.println( t0.toNewHampshireX() );
+ return false;
+ }
+ final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
+ PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
+ if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
+ return false;
+ }
+ if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
+ return false;
+ }
+ if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
private static boolean testUniprotEntryRetrieval() {
try {
final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );