@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 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;
+ private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
+ private final static double ZERO_DIFF = 1.0E-9;
- 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, 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;
+ public static boolean isEqual( final double a, final double b ) {
+ return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
+ }
+
+ public static void main( final String[] args ) {
+ System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
+ System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
+ + "]" );
+ Locale.setDefault( Locale.US );
+ System.out.println( "[Locale: " + Locale.getDefault() + "]" );
+ int failed = 0;
+ int succeeded = 0;
+ System.out.print( "[Test if directory with files for testing exists/is readable: " );
+ if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
+ System.out.println( "OK.]" );
+ }
+ else {
+ System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
+ System.out.println( "Testing aborted." );
+ System.exit( -1 );
+ }
+ System.out.print( "[Test if resources directory exists/is readable: " );
+ if ( testDir( PATH_TO_RESOURCES ) ) {
+ System.out.println( "OK.]" );
+ }
+ else {
+ System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
+ System.out.println( "Testing aborted." );
+ System.exit( -1 );
+ }
+ final long start_time = new Date().getTime();
+ System.out.print( "Basic node methods: " );
+ if ( Test.testBasicNodeMethods() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Protein id: " );
+ if ( !testProteinId() ) {
+ System.out.println( "failed." );
+ failed++;
+ }
+ else {
+ succeeded++;
+ }
+ System.out.println( "OK." );
+ System.out.print( "Species: " );
+ if ( !testSpecies() ) {
+ System.out.println( "failed." );
+ failed++;
+ }
+ else {
+ succeeded++;
+ }
+ System.out.println( "OK." );
+ System.out.print( "Basic domain: " );
+ if ( !testBasicDomain() ) {
+ System.out.println( "failed." );
+ failed++;
+ }
+ else {
+ succeeded++;
+ }
+ System.out.println( "OK." );
+ System.out.print( "Basic protein: " );
+ if ( !testBasicProtein() ) {
+ System.out.println( "failed." );
+ failed++;
+ }
+ else {
+ succeeded++;
+ }
+ System.out.println( "OK." );
+ System.out.print( "Sequence writer: " );
+ if ( testSequenceWriter() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Sequence id parsing: " );
+ if ( testSequenceIdParsing() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "UniProtKB id extraction: " );
+ if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Sequence DB tools 1: " );
+ if ( testSequenceDbWsTools1() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ if ( PERFORM_DB_TESTS ) {
+ System.out.print( "Ebi Entry Retrieval: " );
+ if ( Test.testEbiEntryRetrieval() ) {
+ System.out.println( "OK." );
+ succeeded++;
}
- if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
- return false;
+ else {
+ System.out.println( "failed." );
+ failed++;
}
- final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
- if ( fghi.getNumberOfProteinDomains() != 7 ) {
- return false;
+ }
+ // System.exit( 0 );
+ if ( PERFORM_DB_TESTS ) {
+ System.out.print( "Sequence DB tools 2: " );
+ if ( testSequenceDbWsTools2() ) {
+ System.out.println( "OK." );
+ succeeded++;
}
- if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
- return false;
+ else {
+ System.out.println( "failed." );
+ failed++;
+ System.exit( -1 );
}
- 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;
- }
-
- public static boolean isEqual( final double a, final double b ) {
- return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
- }
-
- 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.openStream(), new NHXParser() );
- if ( ( phys == null ) || ( phys.length != 1 ) ) {
- return false;
- }
- if ( !phys[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
- System.out.println( phys[ 0 ].toNewHampshire() );
- return false;
- }
- final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
- if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
- return false;
- }
- if ( !phys2[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
- System.out.println( phys2[ 0 ].toNewHampshire() );
- return false;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace();
- }
- return true;
- }
-
- public static void main( final String[] args ) {
- System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
- System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
- + "]" );
- Locale.setDefault( Locale.US );
- System.out.println( "[Locale: " + Locale.getDefault() + "]" );
- int failed = 0;
- int succeeded = 0;
- System.out.print( "[Test if directory with files for testing exists/is readable: " );
- if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
- System.out.println( "OK.]" );
- }
- else {
- System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
- System.out.println( "Testing aborted." );
- System.exit( -1 );
- }
- System.out.print( "[Test if resources directory exists/is readable: " );
- if ( testDir( PATH_TO_RESOURCES ) ) {
- System.out.println( "OK.]" );
- }
- else {
- System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
- System.out.println( "Testing aborted." );
- System.exit( -1 );
}
- final long start_time = new Date().getTime();
- System.out.print( "Basic node methods: " );
- if ( Test.testBasicNodeMethods() ) {
+ // System.exit( 0 );
+ System.out.print( "Hmmscan output parser: " );
+ if ( testHmmscanOutputParser() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Protein id: " );
- if ( !testProteinId() ) {
+ //
+ System.out.print( "Overlap removal: " );
+ if ( !org.forester.test.Test.testOverlapRemoval() ) {
System.out.println( "failed." );
failed++;
}
succeeded++;
}
System.out.println( "OK." );
- System.out.print( "Species: " );
- if ( !testSpecies() ) {
+ System.out.print( "Engulfing overlap removal: " );
+ if ( !Test.testEngulfingOverlapRemoval() ) {
System.out.println( "failed." );
failed++;
}
succeeded++;
}
System.out.println( "OK." );
- System.out.print( "Basic domain: " );
- if ( !testBasicDomain() ) {
+ //
+ System.out.print( "Taxonomy code extraction: " );
+ if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
System.out.println( "failed." );
failed++;
}
- else {
+ System.out.print( "SN extraction: " );
+ if ( Test.testExtractSNFromNodeName() ) {
+ System.out.println( "OK." );
succeeded++;
}
- System.out.println( "OK." );
- System.out.print( "Basic protein: " );
- if ( !testBasicProtein() ) {
+ else {
System.out.println( "failed." );
failed++;
}
- else {
+ System.out.print( "Taxonomy extraction (general): " );
+ if ( Test.testTaxonomyExtraction() ) {
+ System.out.println( "OK." );
succeeded++;
}
- System.out.println( "OK." );
- System.out.print( "Sequence writer: " );
- if ( testSequenceWriter() ) {
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Uri for Aptx web sequence accession: " );
+ if ( Test.testCreateUriForSeqWeb() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Sequence id parsing: " );
- if ( testSequenceIdParsing() ) {
+ System.out.print( "Basic node construction and parsing of NHX (node level): " );
+ if ( Test.testNHXNodeParsing() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "UniProtKB id extraction: " );
- if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
+ System.out.print( "NHX parsing iterating: " );
+ if ( Test.testNHParsingIter() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "failed." );
failed++;
}
- System.out.print( "Sequence DB tools 1: " );
- if ( testSequenceDbWsTools1() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- 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 );
- 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.exit( 0 );
- System.out.print( "Hmmscan output parser: " );
- if ( testHmmscanOutputParser() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- //
- System.out.print( "Overlap removal: " );
- if ( !org.forester.test.Test.testOverlapRemoval() ) {
- System.out.println( "failed." );
- failed++;
- }
- else {
- succeeded++;
- }
- System.out.println( "OK." );
- System.out.print( "Engulfing overlap removal: " );
- if ( !Test.testEngulfingOverlapRemoval() ) {
- System.out.println( "failed." );
- failed++;
- }
- else {
- succeeded++;
- }
- System.out.println( "OK." );
- //
- System.out.print( "Taxonomy code extraction: " );
- if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "SN extraction: " );
- if ( Test.testExtractSNFromNodeName() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "Taxonomy extraction (general): " );
- if ( Test.testTaxonomyExtraction() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "Uri for Aptx web sequence accession: " );
- if ( Test.testCreateUriForSeqWeb() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "Basic node construction and parsing of NHX (node level): " );
- if ( Test.testNHXNodeParsing() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "NHX parsing iterating: " );
- if ( Test.testNHParsingIter() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "NH parsing: " );
- if ( Test.testNHParsing() ) {
+ System.out.print( "NH parsing: " );
+ if ( Test.testNHParsing() ) {
System.out.println( "OK." );
succeeded++;
}
System.out.println( "OK." );
succeeded++;
}
- else {
- System.out.println( "failed [will not count towards failed tests]" );
+ 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++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "Simple MSA quality: " );
+ if ( Test.testMsaQualityMethod() ) {
+ System.out.println( "OK." );
+ succeeded++;
+ }
+ else {
+ System.out.println( "failed." );
+ failed++;
+ }
+ System.out.print( "NHX parsing from URL: " );
+ if ( Test.testNHXparsingFromURL() ) {
+ 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." );
+ }
+ 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 != 1 ) ) {
+ return false;
+ }
+ if ( !phys[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
+ System.out.println( phys[ 0 ].toNewHampshire() );
+ return false;
+ }
+ final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
+ if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
+ return false;
+ }
+ if ( !phys2[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
+ 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);" ) ) {
+ return false;
+ }
+ if ( p.hasNext() ) {
+ return false;
+ }
+ if ( p.next() != null ) {
+ return false;
+ }
+ if ( p.hasNext() ) {
+ return false;
+ }
+ if ( p.next() != null ) {
+ return false;
+ }
+ p.reset();
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ if ( !p.next().toNewHampshire().equals( "((a,b),c);" ) ) {
+ return false;
+ }
+ if ( p.hasNext() ) {
+ return false;
+ }
+ if ( p.next() != null ) {
+ return false;
+ }
+ if ( p.hasNext() ) {
+ return false;
+ }
+ if ( p.next() != null ) {
+ return false;
+ }
+ p.reset();
+ if ( !p.hasNext() ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
+ }
+ 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;
+ }
+ 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, 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;
}
}
- //----
- System.out.print( "Next nodes with collapsed: " );
- if ( Test.testNextNodeWithCollapsing() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "Simple MSA quality: " );
- if ( Test.testMsaQualityMethod() ) {
- System.out.println( "OK." );
- succeeded++;
- }
- else {
- System.out.println( "failed." );
- failed++;
- }
- System.out.print( "NHX parsing from URL: " );
- if ( Test.testNHXparsingFromURL() ) {
- 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." );
- }
- else {
- System.out.println( "Not OK." );
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
}
+ return true;
}
private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
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 ( !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;
- }
- }
- catch ( final Exception e ) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
private static boolean testCreateBalancedPhylogeny() {
try {
final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
if ( !f.exists() ) {
return false;
}
- if ( !f.isDirectory() ) {
+ if ( !f.isDirectory() ) {
+ return false;
+ }
+ if ( !f.canRead() ) {
+ return false;
+ }
+ }
+ catch ( final Exception e ) {
+ return false;
+ }
+ return true;
+ }
+
+ 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 ( !f.canRead() ) {
+ 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;
}
}
- catch ( final Exception e ) {
- 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;
- }
- 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;
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";
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() );
- }
- 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() );
- }
- 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() );
- }
- return false;
- }
- 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" ) ) {
+ if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
+ if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
+ if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
+ if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
- .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
+ if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
return false;
}
- if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
- .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
+ 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();
+ 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 ) ) {
+ 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( "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 ) ) {
+ 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" ) );
- 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( "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().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
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 ) ) {
+ 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( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
- 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" ) );
- 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( "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().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
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 ) ) {
+ 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( "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 ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
+ return false;
+ }
+ if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ return false;
+ }
+ if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
+ 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 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( "F" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- 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( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- 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( "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 ) ) {
+ //
+ 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( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- 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( "D" ) );
- 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( "B" ) );
- 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( "C" ) );
- 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( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
- 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( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- 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( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- 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;
}
- //
- 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 ) ) {
+ }
+ 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( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- 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( "E" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
- 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( "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 ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
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 ) ) {
+ 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( "B" ) );
- 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( "D" ) );
- 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( "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 ( 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( "C" ) );
- 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( "E" ) );
- 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( "A" ) );
- query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
- if ( s0.match( query_nodes ) ) {
+ if ( s1.equals( s3 ) ) {
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.hashCode() != s1.hashCode() ) {
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.hashCode() != s2.hashCode() ) {
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.hashCode() == s3.hashCode() ) {
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.compareTo( s1 ) != 0 ) {
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.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( "A" ) );
+ 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( "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;
+ }
+ /////////
+ // 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( "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( "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" ) );
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() {
+ private static boolean testSplitStrict() {
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 ) {
+ 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() );
- return false;
- }
- final PhylogenyNode n4 = PhylogenyNode
- .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n4.getNodeData().isHasTaxonomy() ) {
- System.out.println( n4.toString() );
- return false;
- }
- final PhylogenyNode n5 = PhylogenyNode
- .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- if ( n5.getNodeData().isHasTaxonomy() ) {
- System.out.println( n5.toString() );
- 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() );
- 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() );
+ 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 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.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "E" ), false );
+ if ( t1.getNumberOfExternalNodes() != 4 ) {
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.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "F" ), false );
+ if ( t1.getNumberOfExternalNodes() != 3 ) {
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.toNewHampshireX();
+ t1.deleteSubtree( t1.getNode( "D" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 3 ) {
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( "def" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 2 ) {
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() );
+ t1.deleteSubtree( t1.getNode( "B" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
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() );
+ t1.deleteSubtree( t1.getNode( "C" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
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() );
+ t1.deleteSubtree( t1.getNode( "abc" ), false );
+ t1.toNewHampshireX();
+ if ( t1.getNumberOfExternalNodes() != 1 ) {
return false;
}
- final PhylogenyNode n13 = PhylogenyNode
- .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
- if ( n13.getNodeData().isHasTaxonomy() ) {
- System.out.println( n13.toString() );
+ t1.deleteSubtree( t1.getNode( "r" ), false );
+ if ( t1.getNumberOfExternalNodes() != 0 ) {
return false;
}
- }
- catch ( final Exception e ) {
- e.printStackTrace( System.out );
- return false;
- }
- 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() );
+ if ( !t1.isEmpty() ) {
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 ) ) {
+ 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;
}
- if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
+ t2.deleteSubtree( t2.getNode( "abc" ), false );
+ t2.toNewHampshireX();
+ if ( t2.getNumberOfExternalNodes() != 3 ) {
return false;
}
- if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
+ t2.deleteSubtree( t2.getNode( "def" ), false );
+ t2.toNewHampshireX();
+ if ( t2.getNumberOfExternalNodes() != 1 ) {
return false;
}
}
return true;
}
- private static boolean testSequenceDbWsTools1() {
+ private static boolean testSupportCount() {
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" ) ) {
- 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" ) ) {
- 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" ) ) {
- return false;
- }
- n.setName( "NM_001030253" );
- acc = SequenceDbWsTools.obtainSeqAccession( n );
- if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
- || !acc.getValue().equals( "NM_001030253" ) ) {
- 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() );
- return false;
+ 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;
+ }
}
- 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_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;
}
- 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( "abc" ) ) != 4 ) {
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( "def" ) ) != 4 ) {
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_3.getNode( "de" ) ) != 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_3.getNode( "A" ) ) != 5 ) {
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_3.getNode( "B" ) ) != 5 ) {
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_3.getNode( "C" ) ) != 5 ) {
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_3.getNode( "D" ) ) != 5 ) {
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_3.getNode( "E" ) ) != 5 ) {
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_3.getNode( "F" ) ) != 5 ) {
return false;
}
- 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() );
+ 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( "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() );
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
return false;
}
- }
- catch ( final Exception e ) {
- 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" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
return false;
}
- if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
return false;
}
- if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
return false;
}
- if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
return false;
}
- final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
- SequenceDbWsTools.obtainSeqInformation( n2 );
- if ( !n2.getNodeData().getSequence().getName()
- .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
return false;
}
- if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
return false;
}
- if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
return false;
}
- if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
return false;
}
- 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" ) ) {
+ 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;
}
- if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
+ 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;
}
- if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
+ 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;
}
- if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
+ 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 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 testSupportTransfer() {
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() );
+ 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 ( !entry.getSequenceName()
- .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
- System.out.println( entry.getSequenceName() );
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
return false;
}
- // if ( !entry.getSequenceSymbol().equals( "" ) ) {
- // System.out.println( entry.getSequenceSymbol() );
- // return false;
- // }
- if ( !entry.getGeneName().equals( "treX-like" ) ) {
- System.out.println( entry.getGeneName() );
+ support_transfer.moveBranchLengthsToBootstrap( p1 );
+ support_transfer.transferSupportValues( p1, p2 );
+ if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
return false;
}
- if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
- System.out.println( entry.getTaxonomyIdentifier() );
+ if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
return false;
}
- if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
- System.out.println( entry.getAnnotations().first().getRefValue() );
+ if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
return false;
}
- if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
- System.out.println( entry.getAnnotations().first().getRefSource() );
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
return false;
}
- if ( entry.getCrossReferences().size() != 5 ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
return false;
}
- //
- final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
- if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
return false;
}
- if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
- System.out.println( entry1.getTaxonomyScientificName() );
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
return false;
}
- if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
- System.out.println( entry1.getSequenceName() );
+ if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
return false;
}
- if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
- System.out.println( entry1.getTaxonomyIdentifier() );
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace( System.out );
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testTaxonomyExtraction() {
+ try {
+ final PhylogenyNode n0 = PhylogenyNode
+ .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n0.getNodeData().isHasTaxonomy() ) {
return false;
}
- if ( !entry1.getGeneName().equals( "BCL2" ) ) {
- System.out.println( entry1.getGeneName() );
+ 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 ( entry1.getCrossReferences().size() != 6 ) {
+ final PhylogenyNode n2x = PhylogenyNode
+ .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
+ if ( n2x.getNodeData().isHasTaxonomy() ) {
return false;
}
- //
- final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
- if ( !entry2.getAccession().equals( "NM_184234" ) ) {
+ 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 ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
- System.out.println( entry2.getTaxonomyScientificName() );
+ 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 ( !entry2.getSequenceName()
- .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
- System.out.println( entry2.getSequenceName() );
+ 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 ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
- System.out.println( entry2.getTaxonomyIdentifier() );
+ 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 ( !entry2.getGeneName().equals( "RBM39" ) ) {
- System.out.println( entry2.getGeneName() );
+ 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;
}
- if ( entry2.getCrossReferences().size() != 3 ) {
+ 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;
}
- //
- final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
- if ( !entry3.getAccession().equals( "HM043801" ) ) {
+ 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 ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
- System.out.println( entry3.getTaxonomyScientificName() );
+ 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 ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
- System.out.println( entry3.getSequenceName() );
+ 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 ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
- System.out.println( entry3.getTaxonomyIdentifier() );
+ 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 ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
- System.out.println( entry3.getSequenceSymbol() );
+ 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;
}
- if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
+ 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 ( entry3.getCrossReferences().size() != 8 ) {
+ final PhylogenyNode n13 = PhylogenyNode
+ .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
+ if ( n13.getNodeData().isHasTaxonomy() ) {
+ System.out.println( n13.toString() );
return false;
}
- //
- //
- final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
- if ( !entry4.getAccession().equals( "AAA36557" ) ) {
+ }
+ 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.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
- System.out.println( entry4.getTaxonomyScientificName() );
+ if ( !t1.toNewHampshireX().equals( str_0 ) ) {
return false;
}
- if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
- System.out.println( entry4.getSequenceName() );
+ 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 ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
- System.out.println( entry4.getTaxonomyIdentifier() );
+ if ( !t1.toNewHampshireX().equals( str_0 ) ) {
return false;
}
- if ( !entry4.getGeneName().equals( "ras" ) ) {
- System.out.println( entry4.getGeneName() );
+ 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 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" ) ) {
+ }
+ catch ( final Exception e ) {
+ e.printStackTrace();
+ return false;
+ }
+ 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;
}
- if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
- System.out.println( entry5.getTaxonomyScientificName() );
+ 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 ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
- System.out.println( entry5.getSequenceName() );
+ if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
return false;
}
- if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
- System.out.println( entry5.getTaxonomyIdentifier() );
+ if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
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;