2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
33 import java.util.ArrayList;
34 import java.util.Date;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Locale;
40 import java.util.SortedSet;
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.development.DevelopmentTools;
45 import org.forester.evoinference.TestPhylogenyReconstruction;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
48 import org.forester.go.TestGo;
49 import org.forester.io.parsers.FastaParser;
50 import org.forester.io.parsers.GeneralMsaParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
53 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
54 import org.forester.io.parsers.nexus.NexusCharactersParser;
55 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
56 import org.forester.io.parsers.nhx.NHXParser;
57 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
58 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
59 import org.forester.io.parsers.tol.TolParser;
60 import org.forester.io.parsers.util.ParserUtils;
61 import org.forester.io.writers.PhylogenyWriter;
62 import org.forester.io.writers.SequenceWriter;
63 import org.forester.msa.BasicMsa;
64 import org.forester.msa.Mafft;
65 import org.forester.msa.Msa;
66 import org.forester.msa.MsaInferrer;
67 import org.forester.msa.MsaMethods;
68 import org.forester.pccx.TestPccx;
69 import org.forester.phylogeny.Phylogeny;
70 import org.forester.phylogeny.PhylogenyBranch;
71 import org.forester.phylogeny.PhylogenyMethods;
72 import org.forester.phylogeny.PhylogenyNode;
73 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
74 import org.forester.phylogeny.data.Accession;
75 import org.forester.phylogeny.data.Accession.Source;
76 import org.forester.phylogeny.data.BinaryCharacters;
77 import org.forester.phylogeny.data.BranchWidth;
78 import org.forester.phylogeny.data.Confidence;
79 import org.forester.phylogeny.data.Distribution;
80 import org.forester.phylogeny.data.DomainArchitecture;
81 import org.forester.phylogeny.data.Event;
82 import org.forester.phylogeny.data.Identifier;
83 import org.forester.phylogeny.data.PhylogenyData;
84 import org.forester.phylogeny.data.PhylogenyDataUtil;
85 import org.forester.phylogeny.data.Polygon;
86 import org.forester.phylogeny.data.PropertiesMap;
87 import org.forester.phylogeny.data.Property;
88 import org.forester.phylogeny.data.Property.AppliesTo;
89 import org.forester.phylogeny.data.ProteinDomain;
90 import org.forester.phylogeny.data.Taxonomy;
91 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
92 import org.forester.phylogeny.factories.PhylogenyFactory;
93 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
94 import org.forester.protein.BasicDomain;
95 import org.forester.protein.BasicProtein;
96 import org.forester.protein.Domain;
97 import org.forester.protein.Protein;
98 import org.forester.protein.ProteinId;
99 import org.forester.rio.TestRIO;
100 import org.forester.sdi.SDI;
101 import org.forester.sdi.SDIR;
102 import org.forester.sdi.TestGSDI;
103 import org.forester.sequence.BasicSequence;
104 import org.forester.sequence.Sequence;
105 import org.forester.species.BasicSpecies;
106 import org.forester.species.Species;
107 import org.forester.surfacing.TestSurfacing;
108 import org.forester.tools.ConfidenceAssessor;
109 import org.forester.tools.SupportCount;
110 import org.forester.tools.TreeSplitMatrix;
111 import org.forester.util.AsciiHistogram;
112 import org.forester.util.BasicDescriptiveStatistics;
113 import org.forester.util.BasicTable;
114 import org.forester.util.BasicTableParser;
115 import org.forester.util.DescriptiveStatistics;
116 import org.forester.util.ForesterConstants;
117 import org.forester.util.ForesterUtil;
118 import org.forester.util.GeneralTable;
119 import org.forester.util.SequenceAccessionTools;
120 import org.forester.ws.seqdb.SequenceDatabaseEntry;
121 import org.forester.ws.seqdb.SequenceDbWsTools;
122 import org.forester.ws.seqdb.UniProtTaxonomy;
123 import org.forester.ws.wabi.TxSearch;
124 import org.forester.ws.wabi.TxSearch.RANKS;
125 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
126 import org.forester.ws.wabi.TxSearch.TAX_RANK;
128 @SuppressWarnings( "unused")
129 public final class Test {
131 private final static boolean PERFORM_DB_TESTS = false;
132 private final static double ZERO_DIFF = 1.0E-9;
133 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
134 + ForesterUtil.getFileSeparator() + "test_data"
135 + ForesterUtil.getFileSeparator();
136 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
137 + ForesterUtil.getFileSeparator() + "resources"
138 + ForesterUtil.getFileSeparator();
139 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
140 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/"
142 + ForesterConstants.PHYLO_XML_XSD;
143 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
144 + ForesterConstants.PHYLO_XML_VERSION + "/"
145 + ForesterConstants.PHYLO_XML_XSD;
147 public static boolean testOverlapRemoval() {
149 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
150 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
151 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
152 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
153 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
154 final List<Boolean> covered = new ArrayList<Boolean>();
155 covered.add( true ); // 0
156 covered.add( false ); // 1
157 covered.add( true ); // 2
158 covered.add( false ); // 3
159 covered.add( true ); // 4
160 covered.add( true ); // 5
161 covered.add( false ); // 6
162 covered.add( true ); // 7
163 covered.add( true ); // 8
164 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
167 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
170 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
173 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
176 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
179 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
180 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
181 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
182 ab.addProteinDomain( a );
183 ab.addProteinDomain( b );
184 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
185 if ( ab.getNumberOfProteinDomains() != 2 ) {
188 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
191 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
194 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
195 if ( ab.getNumberOfProteinDomains() != 2 ) {
198 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
201 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
202 final Domain d = new BasicDomain( "d",
209 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
210 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
211 cde.addProteinDomain( c );
212 cde.addProteinDomain( d );
213 cde.addProteinDomain( e );
214 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
215 if ( cde.getNumberOfProteinDomains() != 3 ) {
218 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
221 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
222 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
223 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
224 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
225 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
226 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
227 fghi.addProteinDomain( f );
228 fghi.addProteinDomain( g );
229 fghi.addProteinDomain( h );
230 fghi.addProteinDomain( i );
231 fghi.addProteinDomain( i );
232 fghi.addProteinDomain( i );
233 fghi.addProteinDomain( i2 );
234 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
235 if ( fghi.getNumberOfProteinDomains() != 7 ) {
238 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
241 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
244 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
245 if ( fghi.getNumberOfProteinDomains() != 7 ) {
248 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
251 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
252 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
253 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
254 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
255 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
256 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
257 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
258 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
259 jklm.addProteinDomain( j );
260 jklm.addProteinDomain( k );
261 jklm.addProteinDomain( l );
262 jklm.addProteinDomain( m );
263 jklm.addProteinDomain( m0 );
264 jklm.addProteinDomain( m1 );
265 jklm.addProteinDomain( m2 );
266 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
267 if ( jklm.getNumberOfProteinDomains() != 7 ) {
270 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
273 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
276 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
277 if ( jklm.getNumberOfProteinDomains() != 7 ) {
280 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
283 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
284 final Protein od = new BasicProtein( "od", "varanus", 0 );
285 od.addProteinDomain( only );
286 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
287 if ( od.getNumberOfProteinDomains() != 1 ) {
290 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
294 catch ( final Exception e ) {
295 e.printStackTrace( System.out );
301 public static boolean testEngulfingOverlapRemoval() {
303 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
304 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
305 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
306 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
307 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
308 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
309 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
310 final List<Boolean> covered = new ArrayList<Boolean>();
311 covered.add( true ); // 0
312 covered.add( false ); // 1
313 covered.add( true ); // 2
314 covered.add( false ); // 3
315 covered.add( true ); // 4
316 covered.add( true ); // 5
317 covered.add( false ); // 6
318 covered.add( true ); // 7
319 covered.add( true ); // 8
320 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
323 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
326 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
329 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
332 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
335 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
338 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
341 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
342 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
343 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
344 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
345 abc.addProteinDomain( a );
346 abc.addProteinDomain( b );
347 abc.addProteinDomain( c );
348 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
349 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
350 if ( abc.getNumberOfProteinDomains() != 3 ) {
353 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
356 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
359 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
362 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
365 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
366 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
367 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
368 final Protein def = new BasicProtein( "def", "nemve", 0 );
369 def.addProteinDomain( d );
370 def.addProteinDomain( e );
371 def.addProteinDomain( f );
372 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
373 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
374 if ( def.getNumberOfProteinDomains() != 3 ) {
377 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
380 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
383 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
386 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
389 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
393 catch ( final Exception e ) {
394 e.printStackTrace( System.out );
400 public static boolean isEqual( final double a, final double b ) {
401 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
404 public static final boolean testNHXparsingFromURL() {
406 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
407 final URL u = new URL( s );
408 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
409 final Phylogeny[] phys = factory.create( u.openStream(), new NHXParser() );
410 if ( ( phys == null ) || ( phys.length != 1 ) ) {
413 if ( !phys[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
414 System.out.println( phys[ 0 ].toNewHampshire() );
417 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
418 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
421 if ( !phys2[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
422 System.out.println( phys2[ 0 ].toNewHampshire() );
426 catch ( final Exception e ) {
432 public static void main( final String[] args ) {
433 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
434 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
436 Locale.setDefault( Locale.US );
437 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
440 System.out.print( "[Test if directory with files for testing exists/is readable: " );
441 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
442 System.out.println( "OK.]" );
445 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
446 System.out.println( "Testing aborted." );
449 System.out.print( "[Test if resources directory exists/is readable: " );
450 if ( testDir( PATH_TO_RESOURCES ) ) {
451 System.out.println( "OK.]" );
454 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
455 System.out.println( "Testing aborted." );
458 final long start_time = new Date().getTime();
459 System.out.print( "Basic node methods: " );
460 if ( Test.testBasicNodeMethods() ) {
461 System.out.println( "OK." );
465 System.out.println( "failed." );
468 System.out.print( "Protein id: " );
469 if ( !testProteinId() ) {
470 System.out.println( "failed." );
476 System.out.println( "OK." );
477 System.out.print( "Species: " );
478 if ( !testSpecies() ) {
479 System.out.println( "failed." );
485 System.out.println( "OK." );
486 System.out.print( "Basic domain: " );
487 if ( !testBasicDomain() ) {
488 System.out.println( "failed." );
494 System.out.println( "OK." );
495 System.out.print( "Basic protein: " );
496 if ( !testBasicProtein() ) {
497 System.out.println( "failed." );
503 System.out.println( "OK." );
504 System.out.print( "Sequence writer: " );
505 if ( testSequenceWriter() ) {
506 System.out.println( "OK." );
510 System.out.println( "failed." );
513 System.out.print( "Sequence id parsing: " );
514 if ( testSequenceIdParsing() ) {
515 System.out.println( "OK." );
519 System.out.println( "failed." );
522 System.out.print( "UniProtKB id extraction: " );
523 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
524 System.out.println( "OK." );
528 System.out.println( "failed." );
531 System.out.print( "Sequence DB tools 1: " );
532 if ( testSequenceDbWsTools1() ) {
533 System.out.println( "OK." );
537 System.out.println( "failed." );
540 if ( PERFORM_DB_TESTS ) {
541 System.out.print( "Ebi Entry Retrieval: " );
542 if ( Test.testEbiEntryRetrieval() ) {
543 System.out.println( "OK." );
547 System.out.println( "failed." );
552 if ( PERFORM_DB_TESTS ) {
553 System.out.print( "Sequence DB tools 2: " );
554 if ( testSequenceDbWsTools2() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
565 System.out.print( "Hmmscan output parser: " );
566 if ( testHmmscanOutputParser() ) {
567 System.out.println( "OK." );
571 System.out.println( "failed." );
575 System.out.print( "Overlap removal: " );
576 if ( !org.forester.test.Test.testOverlapRemoval() ) {
577 System.out.println( "failed." );
583 System.out.println( "OK." );
584 System.out.print( "Engulfing overlap removal: " );
585 if ( !Test.testEngulfingOverlapRemoval() ) {
586 System.out.println( "failed." );
592 System.out.println( "OK." );
594 System.out.print( "Taxonomy code extraction: " );
595 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
596 System.out.println( "OK." );
600 System.out.println( "failed." );
603 System.out.print( "SN extraction: " );
604 if ( Test.testExtractSNFromNodeName() ) {
605 System.out.println( "OK." );
609 System.out.println( "failed." );
612 System.out.print( "Taxonomy extraction (general): " );
613 if ( Test.testTaxonomyExtraction() ) {
614 System.out.println( "OK." );
618 System.out.println( "failed." );
621 System.out.print( "Uri for Aptx web sequence accession: " );
622 if ( Test.testCreateUriForSeqWeb() ) {
623 System.out.println( "OK." );
627 System.out.println( "failed." );
630 System.out.print( "Basic node construction and parsing of NHX (node level): " );
631 if ( Test.testNHXNodeParsing() ) {
632 System.out.println( "OK." );
636 System.out.println( "failed." );
639 System.out.print( "NHX parsing iterating: " );
640 if ( Test.testNHParsingIter() ) {
641 System.out.println( "OK." );
645 System.out.println( "failed." );
648 System.out.print( "NH parsing: " );
649 if ( Test.testNHParsing() ) {
650 System.out.println( "OK." );
654 System.out.println( "failed." );
657 System.out.print( "Conversion to NHX (node level): " );
658 if ( Test.testNHXconversion() ) {
659 System.out.println( "OK." );
663 System.out.println( "failed." );
666 System.out.print( "NHX parsing: " );
667 if ( Test.testNHXParsing() ) {
668 System.out.println( "OK." );
672 System.out.println( "failed." );
675 System.out.print( "NHX parsing with quotes: " );
676 if ( Test.testNHXParsingQuotes() ) {
677 System.out.println( "OK." );
681 System.out.println( "failed." );
684 System.out.print( "NHX parsing (MrBayes): " );
685 if ( Test.testNHXParsingMB() ) {
686 System.out.println( "OK." );
690 System.out.println( "failed." );
693 System.out.print( "Nexus characters parsing: " );
694 if ( Test.testNexusCharactersParsing() ) {
695 System.out.println( "OK." );
699 System.out.println( "failed." );
702 System.out.print( "Nexus tree parsing iterating: " );
703 if ( Test.testNexusTreeParsingIterating() ) {
704 System.out.println( "OK." );
708 System.out.println( "failed." );
711 System.out.print( "Nexus tree parsing: " );
712 if ( Test.testNexusTreeParsing() ) {
713 System.out.println( "OK." );
717 System.out.println( "failed." );
720 System.out.print( "Nexus tree parsing (translating): " );
721 if ( Test.testNexusTreeParsingTranslating() ) {
722 System.out.println( "OK." );
726 System.out.println( "failed." );
729 System.out.print( "Nexus matrix parsing: " );
730 if ( Test.testNexusMatrixParsing() ) {
731 System.out.println( "OK." );
735 System.out.println( "failed." );
738 System.out.print( "Basic phyloXML parsing: " );
739 if ( Test.testBasicPhyloXMLparsing() ) {
740 System.out.println( "OK." );
744 System.out.println( "failed." );
747 System.out.print( "Basic phyloXML parsing (validating against schema): " );
748 if ( testBasicPhyloXMLparsingValidating() ) {
749 System.out.println( "OK." );
753 System.out.println( "failed." );
756 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
757 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
758 System.out.println( "OK." );
762 System.out.println( "failed." );
765 System.out.print( "phyloXML Distribution Element: " );
766 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
767 System.out.println( "OK." );
771 System.out.println( "failed." );
774 System.out.print( "Tol XML parsing: " );
775 if ( Test.testBasicTolXMLparsing() ) {
776 System.out.println( "OK." );
780 System.out.println( "failed." );
783 System.out.print( "Copying of node data: " );
784 if ( Test.testCopyOfNodeData() ) {
785 System.out.println( "OK." );
789 System.out.println( "failed." );
792 System.out.print( "Tree copy: " );
793 if ( Test.testTreeCopy() ) {
794 System.out.println( "OK." );
798 System.out.println( "failed." );
801 System.out.print( "Basic tree methods: " );
802 if ( Test.testBasicTreeMethods() ) {
803 System.out.println( "OK." );
807 System.out.println( "failed." );
810 System.out.print( "Tree methods: " );
811 if ( Test.testTreeMethods() ) {
812 System.out.println( "OK." );
816 System.out.println( "failed." );
819 System.out.print( "Postorder Iterator: " );
820 if ( Test.testPostOrderIterator() ) {
821 System.out.println( "OK." );
825 System.out.println( "failed." );
828 System.out.print( "Preorder Iterator: " );
829 if ( Test.testPreOrderIterator() ) {
830 System.out.println( "OK." );
834 System.out.println( "failed." );
837 System.out.print( "Levelorder Iterator: " );
838 if ( Test.testLevelOrderIterator() ) {
839 System.out.println( "OK." );
843 System.out.println( "failed." );
846 System.out.print( "Re-id methods: " );
847 if ( Test.testReIdMethods() ) {
848 System.out.println( "OK." );
852 System.out.println( "failed." );
855 System.out.print( "Methods on last external nodes: " );
856 if ( Test.testLastExternalNodeMethods() ) {
857 System.out.println( "OK." );
861 System.out.println( "failed." );
864 System.out.print( "Methods on external nodes: " );
865 if ( Test.testExternalNodeRelatedMethods() ) {
866 System.out.println( "OK." );
870 System.out.println( "failed." );
873 System.out.print( "Deletion of external nodes: " );
874 if ( Test.testDeletionOfExternalNodes() ) {
875 System.out.println( "OK." );
879 System.out.println( "failed." );
882 System.out.print( "Subtree deletion: " );
883 if ( Test.testSubtreeDeletion() ) {
884 System.out.println( "OK." );
888 System.out.println( "failed." );
891 System.out.print( "Phylogeny branch: " );
892 if ( Test.testPhylogenyBranch() ) {
893 System.out.println( "OK." );
897 System.out.println( "failed." );
900 System.out.print( "Rerooting: " );
901 if ( Test.testRerooting() ) {
902 System.out.println( "OK." );
906 System.out.println( "failed." );
909 System.out.print( "Mipoint rooting: " );
910 if ( Test.testMidpointrooting() ) {
911 System.out.println( "OK." );
915 System.out.println( "failed." );
918 System.out.print( "Node removal: " );
919 if ( Test.testNodeRemoval() ) {
920 System.out.println( "OK." );
924 System.out.println( "failed." );
927 System.out.print( "Support count: " );
928 if ( Test.testSupportCount() ) {
929 System.out.println( "OK." );
933 System.out.println( "failed." );
936 System.out.print( "Support transfer: " );
937 if ( Test.testSupportTransfer() ) {
938 System.out.println( "OK." );
942 System.out.println( "failed." );
945 System.out.print( "Finding of LCA: " );
946 if ( Test.testGetLCA() ) {
947 System.out.println( "OK." );
951 System.out.println( "failed." );
954 System.out.print( "Finding of LCA 2: " );
955 if ( Test.testGetLCA2() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
963 System.out.print( "Calculation of distance between nodes: " );
964 if ( Test.testGetDistance() ) {
965 System.out.println( "OK." );
969 System.out.println( "failed." );
972 System.out.print( "Descriptive statistics: " );
973 if ( Test.testDescriptiveStatistics() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
981 System.out.print( "Data objects and methods: " );
982 if ( Test.testDataObjects() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
990 System.out.print( "Properties map: " );
991 if ( Test.testPropertiesMap() ) {
992 System.out.println( "OK." );
996 System.out.println( "failed." );
999 System.out.print( "SDIse: " );
1000 if ( Test.testSDIse() ) {
1001 System.out.println( "OK." );
1005 System.out.println( "failed." );
1008 System.out.print( "SDIunrooted: " );
1009 if ( Test.testSDIunrooted() ) {
1010 System.out.println( "OK." );
1014 System.out.println( "failed." );
1017 System.out.print( "GSDI: " );
1018 if ( TestGSDI.test() ) {
1019 System.out.println( "OK." );
1023 System.out.println( "failed." );
1026 System.out.print( "RIO: " );
1027 if ( TestRIO.test() ) {
1028 System.out.println( "OK." );
1032 System.out.println( "failed." );
1035 System.out.print( "Phylogeny reconstruction:" );
1036 System.out.println();
1037 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
1038 System.out.println( "OK." );
1042 System.out.println( "failed." );
1045 System.out.print( "Analysis of domain architectures: " );
1046 System.out.println();
1047 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
1048 System.out.println( "OK." );
1052 System.out.println( "failed." );
1055 System.out.print( "GO: " );
1056 System.out.println();
1057 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
1058 System.out.println( "OK." );
1062 System.out.println( "failed." );
1065 System.out.print( "Modeling tools: " );
1066 if ( TestPccx.test() ) {
1067 System.out.println( "OK." );
1071 System.out.println( "failed." );
1074 System.out.print( "Split Matrix strict: " );
1075 if ( Test.testSplitStrict() ) {
1076 System.out.println( "OK." );
1080 System.out.println( "failed." );
1083 System.out.print( "Split Matrix: " );
1084 if ( Test.testSplit() ) {
1085 System.out.println( "OK." );
1089 System.out.println( "failed." );
1092 System.out.print( "Confidence Assessor: " );
1093 if ( Test.testConfidenceAssessor() ) {
1094 System.out.println( "OK." );
1098 System.out.println( "failed." );
1101 System.out.print( "Basic table: " );
1102 if ( Test.testBasicTable() ) {
1103 System.out.println( "OK." );
1107 System.out.println( "failed." );
1110 System.out.print( "General table: " );
1111 if ( Test.testGeneralTable() ) {
1112 System.out.println( "OK." );
1116 System.out.println( "failed." );
1119 System.out.print( "Amino acid sequence: " );
1120 if ( Test.testAminoAcidSequence() ) {
1121 System.out.println( "OK." );
1125 System.out.println( "failed." );
1128 System.out.print( "General MSA parser: " );
1129 if ( Test.testGeneralMsaParser() ) {
1130 System.out.println( "OK." );
1134 System.out.println( "failed." );
1137 System.out.print( "Fasta parser for msa: " );
1138 if ( Test.testFastaParser() ) {
1139 System.out.println( "OK." );
1143 System.out.println( "failed." );
1146 System.out.print( "Creation of balanced phylogeny: " );
1147 if ( Test.testCreateBalancedPhylogeny() ) {
1148 System.out.println( "OK." );
1152 System.out.println( "failed." );
1155 System.out.print( "Genbank accessor parsing: " );
1156 if ( Test.testGenbankAccessorParsing() ) {
1157 System.out.println( "OK." );
1161 System.out.println( "failed." );
1164 if ( PERFORM_DB_TESTS ) {
1165 System.out.print( "Uniprot Entry Retrieval: " );
1166 if ( Test.testUniprotEntryRetrieval() ) {
1167 System.out.println( "OK." );
1171 System.out.println( "failed." );
1175 if ( PERFORM_DB_TESTS ) {
1176 System.out.print( "Uniprot Taxonomy Search: " );
1177 if ( Test.testUniprotTaxonomySearch() ) {
1178 System.out.println( "OK." );
1182 System.out.println( "failed." );
1188 final String os = ForesterUtil.OS_NAME.toLowerCase();
1189 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
1190 path = "/usr/local/bin/mafft";
1192 else if ( os.indexOf( "win" ) >= 0 ) {
1193 path = "C:\\Program Files\\mafft-win\\mafft.bat";
1196 path = "/home/czmasek/bin/mafft";
1198 if ( !MsaInferrer.isInstalled( path ) ) {
1201 if ( !MsaInferrer.isInstalled( path ) ) {
1202 path = "/usr/local/bin/mafft";
1204 if ( MsaInferrer.isInstalled( path ) ) {
1205 System.out.print( "MAFFT (external program): " );
1206 if ( Test.testMafft( path ) ) {
1207 System.out.println( "OK." );
1211 System.out.println( "failed [will not count towards failed tests]" );
1215 System.out.print( "Next nodes with collapsed: " );
1216 if ( Test.testNextNodeWithCollapsing() ) {
1217 System.out.println( "OK." );
1221 System.out.println( "failed." );
1224 System.out.print( "Simple MSA quality: " );
1225 if ( Test.testMsaQualityMethod() ) {
1226 System.out.println( "OK." );
1230 System.out.println( "failed." );
1233 System.out.print( "NHX parsing from URL: " );
1234 if ( Test.testNHXparsingFromURL() ) {
1235 System.out.println( "OK." );
1239 System.out.println( "failed." );
1242 System.out.println();
1243 final Runtime rt = java.lang.Runtime.getRuntime();
1244 final long free_memory = rt.freeMemory() / 1000000;
1245 final long total_memory = rt.totalMemory() / 1000000;
1246 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1247 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1248 System.out.println();
1249 System.out.println( "Successful tests: " + succeeded );
1250 System.out.println( "Failed tests: " + failed );
1251 System.out.println();
1253 System.out.println( "OK." );
1256 System.out.println( "Not OK." );
1260 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1261 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1265 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1266 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1269 private static boolean testAminoAcidSequence() {
1271 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1272 if ( aa1.getLength() != 13 ) {
1275 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1278 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1281 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1284 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1285 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1288 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1289 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1292 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1293 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1297 catch ( final Exception e ) {
1298 e.printStackTrace();
1304 private static boolean testBasicDomain() {
1306 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1307 if ( !pd.getDomainId().equals( "id" ) ) {
1310 if ( pd.getNumber() != 1 ) {
1313 if ( pd.getTotalCount() != 4 ) {
1316 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1319 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1320 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1321 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1322 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1323 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1324 if ( !a1.equals( a1 ) ) {
1327 if ( !a1.equals( a1_copy ) ) {
1330 if ( !a1.equals( a1_equal ) ) {
1333 if ( !a1.equals( a2 ) ) {
1336 if ( a1.equals( a3 ) ) {
1339 if ( a1.compareTo( a1 ) != 0 ) {
1342 if ( a1.compareTo( a1_copy ) != 0 ) {
1345 if ( a1.compareTo( a1_equal ) != 0 ) {
1348 if ( a1.compareTo( a2 ) != 0 ) {
1351 if ( a1.compareTo( a3 ) == 0 ) {
1355 catch ( final Exception e ) {
1356 e.printStackTrace( System.out );
1362 private static boolean testBasicNodeMethods() {
1364 if ( PhylogenyNode.getNodeCount() != 0 ) {
1367 final PhylogenyNode n1 = new PhylogenyNode();
1368 final PhylogenyNode n2 = PhylogenyNode
1369 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1370 final PhylogenyNode n3 = PhylogenyNode
1371 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1372 final PhylogenyNode n4 = PhylogenyNode
1373 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1374 if ( n1.isHasAssignedEvent() ) {
1377 if ( PhylogenyNode.getNodeCount() != 4 ) {
1380 if ( n3.getIndicator() != 0 ) {
1383 if ( n3.getNumberOfExternalNodes() != 1 ) {
1386 if ( !n3.isExternal() ) {
1389 if ( !n3.isRoot() ) {
1392 if ( !n4.getName().equals( "n4" ) ) {
1396 catch ( final Exception e ) {
1397 e.printStackTrace( System.out );
1403 private static boolean testBasicPhyloXMLparsing() {
1405 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1406 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1407 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1409 if ( xml_parser.getErrorCount() > 0 ) {
1410 System.out.println( xml_parser.getErrorMessages().toString() );
1413 if ( phylogenies_0.length != 4 ) {
1416 final Phylogeny t1 = phylogenies_0[ 0 ];
1417 final Phylogeny t2 = phylogenies_0[ 1 ];
1418 final Phylogeny t3 = phylogenies_0[ 2 ];
1419 final Phylogeny t4 = phylogenies_0[ 3 ];
1420 if ( t1.getNumberOfExternalNodes() != 1 ) {
1423 if ( !t1.isRooted() ) {
1426 if ( t1.isRerootable() ) {
1429 if ( !t1.getType().equals( "gene_tree" ) ) {
1432 if ( t2.getNumberOfExternalNodes() != 2 ) {
1435 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1438 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1441 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1444 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1447 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1450 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1453 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1454 .startsWith( "actgtgggggt" ) ) {
1457 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1458 .startsWith( "ctgtgatgcat" ) ) {
1461 if ( t3.getNumberOfExternalNodes() != 4 ) {
1464 if ( !t1.getName().equals( "t1" ) ) {
1467 if ( !t2.getName().equals( "t2" ) ) {
1470 if ( !t3.getName().equals( "t3" ) ) {
1473 if ( !t4.getName().equals( "t4" ) ) {
1476 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1479 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1482 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1485 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1486 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1489 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1492 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1495 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1498 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1499 .equals( "apoptosis" ) ) {
1502 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1503 .equals( "GO:0006915" ) ) {
1506 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1507 .equals( "UniProtKB" ) ) {
1510 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1511 .equals( "experimental" ) ) {
1514 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1515 .equals( "function" ) ) {
1518 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1519 .getValue() != 1 ) {
1522 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1523 .getType().equals( "ml" ) ) {
1526 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1527 .equals( "apoptosis" ) ) {
1530 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1531 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1534 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1535 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1538 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1539 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1542 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1543 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1546 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1547 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1550 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1551 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1554 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1555 .equals( "GO:0005829" ) ) {
1558 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1559 .equals( "intracellular organelle" ) ) {
1562 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1565 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1566 .equals( "UniProt link" ) ) ) {
1569 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1572 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1573 if ( x.size() != 4 ) {
1577 for( final Accession acc : x ) {
1579 if ( !acc.getSource().equals( "KEGG" ) ) {
1582 if ( !acc.getValue().equals( "hsa:596" ) ) {
1589 catch ( final Exception e ) {
1590 e.printStackTrace( System.out );
1596 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1598 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1599 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1600 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1601 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1604 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1606 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1608 if ( xml_parser.getErrorCount() > 0 ) {
1609 System.out.println( xml_parser.getErrorMessages().toString() );
1612 if ( phylogenies_0.length != 4 ) {
1615 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1616 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1617 if ( phylogenies_t1.length != 1 ) {
1620 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1621 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1624 if ( !t1_rt.isRooted() ) {
1627 if ( t1_rt.isRerootable() ) {
1630 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1633 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1634 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1635 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1636 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1639 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1642 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1645 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1648 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1649 .startsWith( "actgtgggggt" ) ) {
1652 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1653 .startsWith( "ctgtgatgcat" ) ) {
1656 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1657 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1658 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1659 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1660 if ( phylogenies_1.length != 1 ) {
1663 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1664 if ( !t3_rt.getName().equals( "t3" ) ) {
1667 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1670 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1673 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1676 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1679 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1680 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1683 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1686 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1689 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1690 .equals( "UniProtKB" ) ) {
1693 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1694 .equals( "apoptosis" ) ) {
1697 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1698 .equals( "GO:0006915" ) ) {
1701 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1702 .equals( "UniProtKB" ) ) {
1705 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1706 .equals( "experimental" ) ) {
1709 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1710 .equals( "function" ) ) {
1713 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1714 .getValue() != 1 ) {
1717 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1718 .getType().equals( "ml" ) ) {
1721 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1722 .equals( "apoptosis" ) ) {
1725 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1726 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1729 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1730 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1733 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1734 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1737 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1738 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1741 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1742 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1745 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1746 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1749 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1750 .equals( "GO:0005829" ) ) {
1753 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1754 .equals( "intracellular organelle" ) ) {
1757 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1760 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1761 .equals( "UniProt link" ) ) ) {
1764 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1767 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1770 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1771 .equals( "Aguinaldo, A. M. A.; J. M. Turbeville, L. S. Linford, M. C. Rivera, J. R. Garey, R. A. Raff, & J. A. Lake (1997). \"Evidence for a clade of nematodes, arthropods and other moulting animals\". Nature 387 (6632): 489–493." ) ) ) {
1774 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1777 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1780 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1783 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1786 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1787 .equals( "ncbi" ) ) {
1790 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1793 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1794 .getName().equals( "B" ) ) {
1797 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1798 .getFrom() != 21 ) {
1801 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1804 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1805 .getLength() != 24 ) {
1808 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1809 .getConfidence() != 2144 ) {
1812 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1813 .equals( "pfam" ) ) {
1816 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1819 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1822 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1825 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1828 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1829 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1832 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1835 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1838 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1841 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1844 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1847 if ( taxbb.getSynonyms().size() != 2 ) {
1850 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1853 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1856 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1859 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1862 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1865 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1866 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1869 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1872 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1875 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1878 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1881 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1884 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1887 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1891 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1894 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1895 .equalsIgnoreCase( "435" ) ) {
1898 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1901 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1902 .equalsIgnoreCase( "443.7" ) ) {
1905 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1908 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1911 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1912 .equalsIgnoreCase( "433" ) ) {
1915 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1916 .getCrossReferences();
1917 if ( x.size() != 4 ) {
1921 for( final Accession acc : x ) {
1923 if ( !acc.getSource().equals( "KEGG" ) ) {
1926 if ( !acc.getValue().equals( "hsa:596" ) ) {
1933 catch ( final Exception e ) {
1934 e.printStackTrace( System.out );
1940 private static boolean testBasicPhyloXMLparsingValidating() {
1942 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1943 PhyloXmlParser xml_parser = null;
1945 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1947 catch ( final Exception e ) {
1948 // Do nothing -- means were not running from jar.
1950 if ( xml_parser == null ) {
1951 xml_parser = PhyloXmlParser.createPhyloXmlParser();
1952 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1953 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1956 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1959 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1961 if ( xml_parser.getErrorCount() > 0 ) {
1962 System.out.println( xml_parser.getErrorMessages().toString() );
1965 if ( phylogenies_0.length != 4 ) {
1968 final Phylogeny t1 = phylogenies_0[ 0 ];
1969 final Phylogeny t2 = phylogenies_0[ 1 ];
1970 final Phylogeny t3 = phylogenies_0[ 2 ];
1971 final Phylogeny t4 = phylogenies_0[ 3 ];
1972 if ( !t1.getName().equals( "t1" ) ) {
1975 if ( !t2.getName().equals( "t2" ) ) {
1978 if ( !t3.getName().equals( "t3" ) ) {
1981 if ( !t4.getName().equals( "t4" ) ) {
1984 if ( t1.getNumberOfExternalNodes() != 1 ) {
1987 if ( t2.getNumberOfExternalNodes() != 2 ) {
1990 if ( t3.getNumberOfExternalNodes() != 4 ) {
1993 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1994 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1995 if ( xml_parser.getErrorCount() > 0 ) {
1996 System.out.println( "errors:" );
1997 System.out.println( xml_parser.getErrorMessages().toString() );
2000 if ( phylogenies_1.length != 4 ) {
2003 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2005 if ( xml_parser.getErrorCount() > 0 ) {
2006 System.out.println( "errors:" );
2007 System.out.println( xml_parser.getErrorMessages().toString() );
2010 if ( phylogenies_2.length != 1 ) {
2013 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2016 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2018 if ( xml_parser.getErrorCount() > 0 ) {
2019 System.out.println( xml_parser.getErrorMessages().toString() );
2022 if ( phylogenies_3.length != 2 ) {
2025 final Phylogeny a = phylogenies_3[ 0 ];
2026 if ( !a.getName().equals( "tree 4" ) ) {
2029 if ( a.getNumberOfExternalNodes() != 3 ) {
2032 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2035 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2038 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2040 if ( xml_parser.getErrorCount() > 0 ) {
2041 System.out.println( xml_parser.getErrorMessages().toString() );
2044 if ( phylogenies_4.length != 1 ) {
2047 final Phylogeny s = phylogenies_4[ 0 ];
2048 if ( s.getNumberOfExternalNodes() != 6 ) {
2051 s.getNode( "first" );
2053 s.getNode( "\"<a'b&c'd\">\"" );
2054 s.getNode( "'''\"" );
2055 s.getNode( "\"\"\"" );
2056 s.getNode( "dick & doof" );
2058 catch ( final Exception e ) {
2059 e.printStackTrace( System.out );
2065 private static boolean testBasicProtein() {
2067 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2068 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2069 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2070 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2071 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2072 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2073 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2074 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2075 p0.addProteinDomain( y );
2076 p0.addProteinDomain( e );
2077 p0.addProteinDomain( b );
2078 p0.addProteinDomain( c );
2079 p0.addProteinDomain( d );
2080 p0.addProteinDomain( a );
2081 p0.addProteinDomain( x );
2082 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2085 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2089 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2090 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2091 aa0.addProteinDomain( a1 );
2092 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2095 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2099 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2100 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2101 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2102 aa1.addProteinDomain( a11 );
2103 aa1.addProteinDomain( a12 );
2104 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2107 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2110 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2111 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2114 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2117 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2120 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2121 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2124 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2127 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2130 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2133 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2134 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2137 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2140 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2143 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2146 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2147 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2150 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2153 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2156 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2160 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2161 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2162 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2163 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2164 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2165 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2166 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2167 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2168 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2169 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2170 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2171 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2172 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2173 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2174 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2175 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2176 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2177 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2178 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2179 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2180 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2181 p00.addProteinDomain( y0 );
2182 p00.addProteinDomain( e0 );
2183 p00.addProteinDomain( b0 );
2184 p00.addProteinDomain( c0 );
2185 p00.addProteinDomain( d0 );
2186 p00.addProteinDomain( a0 );
2187 p00.addProteinDomain( x0 );
2188 p00.addProteinDomain( y1 );
2189 p00.addProteinDomain( y2 );
2190 p00.addProteinDomain( y3 );
2191 p00.addProteinDomain( e1 );
2192 p00.addProteinDomain( e2 );
2193 p00.addProteinDomain( e3 );
2194 p00.addProteinDomain( e4 );
2195 p00.addProteinDomain( e5 );
2196 p00.addProteinDomain( z0 );
2197 p00.addProteinDomain( z1 );
2198 p00.addProteinDomain( z2 );
2199 p00.addProteinDomain( zz0 );
2200 p00.addProteinDomain( zz1 );
2201 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2204 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2207 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2210 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2213 if ( !p00.toDomainArchitectureString( "~", 7, "" ).equals( "a~b~c~d~e~e~e~e~e~e~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2216 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2217 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2218 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2219 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2220 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2221 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2222 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2223 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2224 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2225 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2226 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2227 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2228 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2229 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2230 p.addProteinDomain( B15 );
2231 p.addProteinDomain( C50 );
2232 p.addProteinDomain( A60 );
2233 p.addProteinDomain( A30 );
2234 p.addProteinDomain( C70 );
2235 p.addProteinDomain( B35 );
2236 p.addProteinDomain( B40 );
2237 p.addProteinDomain( A0 );
2238 p.addProteinDomain( A10 );
2239 p.addProteinDomain( A20 );
2240 p.addProteinDomain( B25 );
2241 p.addProteinDomain( D80 );
2242 List<String> domains_ids = new ArrayList<String>();
2243 domains_ids.add( "A" );
2244 domains_ids.add( "B" );
2245 domains_ids.add( "C" );
2246 if ( !p.contains( domains_ids, false ) ) {
2249 if ( !p.contains( domains_ids, true ) ) {
2252 domains_ids.add( "X" );
2253 if ( p.contains( domains_ids, false ) ) {
2256 if ( p.contains( domains_ids, true ) ) {
2259 domains_ids = new ArrayList<String>();
2260 domains_ids.add( "A" );
2261 domains_ids.add( "C" );
2262 domains_ids.add( "D" );
2263 if ( !p.contains( domains_ids, false ) ) {
2266 if ( !p.contains( domains_ids, true ) ) {
2269 domains_ids = new ArrayList<String>();
2270 domains_ids.add( "A" );
2271 domains_ids.add( "D" );
2272 domains_ids.add( "C" );
2273 if ( !p.contains( domains_ids, false ) ) {
2276 if ( p.contains( domains_ids, true ) ) {
2279 domains_ids = new ArrayList<String>();
2280 domains_ids.add( "A" );
2281 domains_ids.add( "A" );
2282 domains_ids.add( "B" );
2283 if ( !p.contains( domains_ids, false ) ) {
2286 if ( !p.contains( domains_ids, true ) ) {
2289 domains_ids = new ArrayList<String>();
2290 domains_ids.add( "A" );
2291 domains_ids.add( "A" );
2292 domains_ids.add( "A" );
2293 domains_ids.add( "B" );
2294 domains_ids.add( "B" );
2295 if ( !p.contains( domains_ids, false ) ) {
2298 if ( !p.contains( domains_ids, true ) ) {
2301 domains_ids = new ArrayList<String>();
2302 domains_ids.add( "A" );
2303 domains_ids.add( "A" );
2304 domains_ids.add( "B" );
2305 domains_ids.add( "A" );
2306 domains_ids.add( "B" );
2307 domains_ids.add( "B" );
2308 domains_ids.add( "A" );
2309 domains_ids.add( "B" );
2310 domains_ids.add( "C" );
2311 domains_ids.add( "A" );
2312 domains_ids.add( "C" );
2313 domains_ids.add( "D" );
2314 if ( !p.contains( domains_ids, false ) ) {
2317 if ( p.contains( domains_ids, true ) ) {
2321 catch ( final Exception e ) {
2322 e.printStackTrace( System.out );
2328 private static boolean testBasicTable() {
2330 final BasicTable<String> t0 = new BasicTable<String>();
2331 if ( t0.getNumberOfColumns() != 0 ) {
2334 if ( t0.getNumberOfRows() != 0 ) {
2337 t0.setValue( 3, 2, "23" );
2338 t0.setValue( 10, 1, "error" );
2339 t0.setValue( 10, 1, "110" );
2340 t0.setValue( 9, 1, "19" );
2341 t0.setValue( 1, 10, "101" );
2342 t0.setValue( 10, 10, "1010" );
2343 t0.setValue( 100, 10, "10100" );
2344 t0.setValue( 0, 0, "00" );
2345 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2348 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2351 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2354 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2357 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2360 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2363 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2366 if ( t0.getNumberOfColumns() != 101 ) {
2369 if ( t0.getNumberOfRows() != 11 ) {
2372 if ( t0.getValueAsString( 49, 4 ) != null ) {
2375 final String l = ForesterUtil.getLineSeparator();
2376 final StringBuffer source = new StringBuffer();
2377 source.append( "" + l );
2378 source.append( "# 1 1 1 1 1 1 1 1" + l );
2379 source.append( " 00 01 02 03" + l );
2380 source.append( " 10 11 12 13 " + l );
2381 source.append( "20 21 22 23 " + l );
2382 source.append( " 30 31 32 33" + l );
2383 source.append( "40 41 42 43" + l );
2384 source.append( " # 1 1 1 1 1 " + l );
2385 source.append( "50 51 52 53 54" + l );
2386 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2387 if ( t1.getNumberOfColumns() != 5 ) {
2390 if ( t1.getNumberOfRows() != 6 ) {
2393 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2396 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2399 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2402 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2405 final StringBuffer source1 = new StringBuffer();
2406 source1.append( "" + l );
2407 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2408 source1.append( " 00; 01 ;02;03" + l );
2409 source1.append( " 10; 11; 12; 13 " + l );
2410 source1.append( "20; 21; 22; 23 " + l );
2411 source1.append( " 30; 31; 32; 33" + l );
2412 source1.append( "40;41;42;43" + l );
2413 source1.append( " # 1 1 1 1 1 " + l );
2414 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2415 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2416 if ( t2.getNumberOfColumns() != 5 ) {
2419 if ( t2.getNumberOfRows() != 6 ) {
2422 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2425 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2428 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2431 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2434 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2437 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2440 final StringBuffer source2 = new StringBuffer();
2441 source2.append( "" + l );
2442 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2443 source2.append( " 00; 01 ;02;03" + l );
2444 source2.append( " 10; 11; 12; 13 " + l );
2445 source2.append( "20; 21; 22; 23 " + l );
2446 source2.append( " " + l );
2447 source2.append( " 30; 31; 32; 33" + l );
2448 source2.append( "40;41;42;43" + l );
2449 source2.append( " comment: 1 1 1 1 1 " + l );
2450 source2.append( ";;;50 ; 52; 53;;54 " + l );
2451 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2457 if ( tl.size() != 2 ) {
2460 final BasicTable<String> t3 = tl.get( 0 );
2461 final BasicTable<String> t4 = tl.get( 1 );
2462 if ( t3.getNumberOfColumns() != 4 ) {
2465 if ( t3.getNumberOfRows() != 3 ) {
2468 if ( t4.getNumberOfColumns() != 4 ) {
2471 if ( t4.getNumberOfRows() != 3 ) {
2474 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2477 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2481 catch ( final Exception e ) {
2482 e.printStackTrace( System.out );
2488 private static boolean testBasicTolXMLparsing() {
2490 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2491 final TolParser parser = new TolParser();
2492 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2493 if ( parser.getErrorCount() > 0 ) {
2494 System.out.println( parser.getErrorMessages().toString() );
2497 if ( phylogenies_0.length != 1 ) {
2500 final Phylogeny t1 = phylogenies_0[ 0 ];
2501 if ( t1.getNumberOfExternalNodes() != 5 ) {
2504 if ( !t1.isRooted() ) {
2507 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2510 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2513 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2516 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2519 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2520 if ( parser.getErrorCount() > 0 ) {
2521 System.out.println( parser.getErrorMessages().toString() );
2524 if ( phylogenies_1.length != 1 ) {
2527 final Phylogeny t2 = phylogenies_1[ 0 ];
2528 if ( t2.getNumberOfExternalNodes() != 664 ) {
2531 if ( !t2.isRooted() ) {
2534 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2537 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2540 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2543 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2546 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2549 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2550 .equals( "Aquifex" ) ) {
2553 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2554 if ( parser.getErrorCount() > 0 ) {
2555 System.out.println( parser.getErrorMessages().toString() );
2558 if ( phylogenies_2.length != 1 ) {
2561 final Phylogeny t3 = phylogenies_2[ 0 ];
2562 if ( t3.getNumberOfExternalNodes() != 184 ) {
2565 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2568 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2571 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2574 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2575 if ( parser.getErrorCount() > 0 ) {
2576 System.out.println( parser.getErrorMessages().toString() );
2579 if ( phylogenies_3.length != 1 ) {
2582 final Phylogeny t4 = phylogenies_3[ 0 ];
2583 if ( t4.getNumberOfExternalNodes() != 1 ) {
2586 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2589 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2592 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2595 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2596 if ( parser.getErrorCount() > 0 ) {
2597 System.out.println( parser.getErrorMessages().toString() );
2600 if ( phylogenies_4.length != 1 ) {
2603 final Phylogeny t5 = phylogenies_4[ 0 ];
2604 if ( t5.getNumberOfExternalNodes() != 13 ) {
2607 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2610 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2613 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2617 catch ( final Exception e ) {
2618 e.printStackTrace( System.out );
2624 private static boolean testBasicTreeMethods() {
2626 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2627 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2628 if ( t2.getNumberOfExternalNodes() != 4 ) {
2631 if ( t2.getHeight() != 8.5 ) {
2634 if ( !t2.isCompletelyBinary() ) {
2637 if ( t2.isEmpty() ) {
2640 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2641 if ( t3.getNumberOfExternalNodes() != 5 ) {
2644 if ( t3.getHeight() != 11 ) {
2647 if ( t3.isCompletelyBinary() ) {
2650 final PhylogenyNode n = t3.getNode( "ABC" );
2651 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
2652 if ( t4.getNumberOfExternalNodes() != 9 ) {
2655 if ( t4.getHeight() != 11 ) {
2658 if ( t4.isCompletelyBinary() ) {
2661 final StringBuffer sb5 = new StringBuffer( "(((A11:2)A1:2,(A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:3,D:8)" );
2662 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2663 if ( t5.getNumberOfExternalNodes() != 8 ) {
2666 if ( t5.getHeight() != 15 ) {
2669 final StringBuffer sb6 = new StringBuffer( "(X,Y,Z,(((A111)A11:2)A1:2,(X,Y,Z,A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:3,D:8)" );
2670 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2671 if ( t6.getHeight() != 15 ) {
2674 final StringBuffer sb7 = new StringBuffer( "(((A11:2)A1:2,(A21:1,A22:2,A23)A2:11,A3:2)A:2,B:10,C:15,D:8)" );
2675 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2676 if ( t7.getHeight() != 15 ) {
2679 final StringBuffer sb8 = new StringBuffer( "(((A11:11)A1:2,(A21:2,A22:2,A23,A24,AA:)A2:11,A3:2)A:2,B:15,C:15,D:15)" );
2680 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2681 if ( t8.getNumberOfExternalNodes() != 10 ) {
2684 if ( t8.getHeight() != 15 ) {
2687 final char[] a9 = new char[] { 'a' };
2688 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2689 if ( t9.getHeight() != 0 ) {
2692 final char[] a10 = new char[] { 'a', ':', '6' };
2693 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2694 if ( t10.getHeight() != 6 ) {
2698 catch ( final Exception e ) {
2699 e.printStackTrace( System.out );
2705 private static boolean testConfidenceAssessor() {
2707 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2708 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2709 final Phylogeny[] ev0 = factory
2710 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2712 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2713 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2716 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2719 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2720 final Phylogeny[] ev1 = factory
2721 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
2723 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2724 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2727 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2730 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2731 final Phylogeny[] ev_b = factory
2732 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
2734 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2735 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2738 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2742 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2743 final Phylogeny[] ev1x = factory
2744 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
2746 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2747 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2750 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2753 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2754 final Phylogeny[] ev_bx = factory
2755 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
2757 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2758 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2761 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2765 final Phylogeny[] t2 = factory
2766 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
2768 final Phylogeny[] ev2 = factory
2769 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
2771 for( final Phylogeny target : t2 ) {
2772 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2775 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2776 new NHXParser() )[ 0 ];
2777 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2778 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2779 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2782 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2785 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2789 catch ( final Exception e ) {
2790 e.printStackTrace();
2796 private static boolean testCopyOfNodeData() {
2798 final PhylogenyNode n1 = PhylogenyNode
2799 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1:O=22:SO=33:SN=44:W=2:C=10.20.30:XN=S=tag1=value1=unit1]" );
2800 final PhylogenyNode n2 = n1.copyNodeData();
2801 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2805 catch ( final Exception e ) {
2806 e.printStackTrace();
2812 private static boolean testTreeCopy() {
2814 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
2815 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
2816 final Phylogeny t1 = t0.copy();
2817 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
2820 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2823 t0.deleteSubtree( t0.getNode( "c" ), true );
2824 t0.deleteSubtree( t0.getNode( "a" ), true );
2825 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
2826 t0.getNode( "b" ).setName( "Bee" );
2827 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
2830 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2833 t0.deleteSubtree( t0.getNode( "e" ), true );
2834 t0.deleteSubtree( t0.getNode( "Bee" ), true );
2835 t0.deleteSubtree( t0.getNode( "d" ), true );
2836 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2840 catch ( final Exception e ) {
2841 e.printStackTrace();
2847 private static boolean testCreateBalancedPhylogeny() {
2849 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2850 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2853 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2856 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2857 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2860 if ( p1.getNumberOfExternalNodes() != 100 ) {
2864 catch ( final Exception e ) {
2865 e.printStackTrace();
2871 private static boolean testCreateUriForSeqWeb() {
2873 final PhylogenyNode n = new PhylogenyNode();
2874 n.setName( "tr|B3RJ64" );
2875 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2878 n.setName( "B0LM41_HUMAN" );
2879 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2882 n.setName( "NP_001025424" );
2883 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2886 n.setName( "_NM_001030253-" );
2887 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2890 n.setName( "XM_002122186" );
2891 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2894 n.setName( "dgh_AAA34956_gdg" );
2895 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2898 n.setName( "AAA34956" );
2899 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2902 n.setName( "GI:394892" );
2903 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2904 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2907 n.setName( "gi_394892" );
2908 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2909 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2912 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2913 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2914 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2917 n.setName( "P12345" );
2918 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2919 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2922 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2923 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2924 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2928 catch ( final Exception e ) {
2929 e.printStackTrace( System.out );
2935 private static boolean testDataObjects() {
2937 final Confidence s0 = new Confidence();
2938 final Confidence s1 = new Confidence();
2939 if ( !s0.isEqual( s1 ) ) {
2942 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2943 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2944 if ( s2.isEqual( s1 ) ) {
2947 if ( !s2.isEqual( s3 ) ) {
2950 final Confidence s4 = ( Confidence ) s3.copy();
2951 if ( !s4.isEqual( s3 ) ) {
2958 final Taxonomy t1 = new Taxonomy();
2959 final Taxonomy t2 = new Taxonomy();
2960 final Taxonomy t3 = new Taxonomy();
2961 final Taxonomy t4 = new Taxonomy();
2962 final Taxonomy t5 = new Taxonomy();
2963 t1.setIdentifier( new Identifier( "ecoli" ) );
2964 t1.setTaxonomyCode( "ECOLI" );
2965 t1.setScientificName( "E. coli" );
2966 t1.setCommonName( "coli" );
2967 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2968 if ( !t1.isEqual( t0 ) ) {
2971 t2.setIdentifier( new Identifier( "ecoli" ) );
2972 t2.setTaxonomyCode( "OTHER" );
2973 t2.setScientificName( "what" );
2974 t2.setCommonName( "something" );
2975 if ( !t1.isEqual( t2 ) ) {
2978 t2.setIdentifier( new Identifier( "nemve" ) );
2979 if ( t1.isEqual( t2 ) ) {
2982 t1.setIdentifier( null );
2983 t3.setTaxonomyCode( "ECOLI" );
2984 t3.setScientificName( "what" );
2985 t3.setCommonName( "something" );
2986 if ( !t1.isEqual( t3 ) ) {
2989 t1.setIdentifier( null );
2990 t1.setTaxonomyCode( "" );
2991 t4.setScientificName( "E. ColI" );
2992 t4.setCommonName( "something" );
2993 if ( !t1.isEqual( t4 ) ) {
2996 t4.setScientificName( "B. subtilis" );
2997 t4.setCommonName( "something" );
2998 if ( t1.isEqual( t4 ) ) {
3001 t1.setIdentifier( null );
3002 t1.setTaxonomyCode( "" );
3003 t1.setScientificName( "" );
3004 t5.setCommonName( "COLI" );
3005 if ( !t1.isEqual( t5 ) ) {
3008 t5.setCommonName( "vibrio" );
3009 if ( t1.isEqual( t5 ) ) {
3014 final Identifier id0 = new Identifier( "123", "pfam" );
3015 final Identifier id1 = ( Identifier ) id0.copy();
3016 if ( !id1.isEqual( id1 ) ) {
3019 if ( !id1.isEqual( id0 ) ) {
3022 if ( !id0.isEqual( id1 ) ) {
3029 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3030 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3031 if ( !pd1.isEqual( pd1 ) ) {
3034 if ( !pd1.isEqual( pd0 ) ) {
3039 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3040 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3041 if ( !pd3.isEqual( pd3 ) ) {
3044 if ( !pd2.isEqual( pd3 ) ) {
3047 if ( !pd0.isEqual( pd3 ) ) {
3052 // DomainArchitecture
3053 // ------------------
3054 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3055 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3056 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3057 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3058 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3059 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3064 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3065 if ( ds0.getNumberOfDomains() != 4 ) {
3068 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3069 if ( !ds0.isEqual( ds0 ) ) {
3072 if ( !ds0.isEqual( ds1 ) ) {
3075 if ( ds1.getNumberOfDomains() != 4 ) {
3078 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3083 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3084 if ( ds0.isEqual( ds2 ) ) {
3090 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3091 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3092 System.out.println( ds3.toNHX() );
3095 if ( ds3.getNumberOfDomains() != 3 ) {
3100 final Event e1 = new Event( Event.EventType.fusion );
3101 if ( e1.isDuplication() ) {
3104 if ( !e1.isFusion() ) {
3107 if ( !e1.asText().toString().equals( "fusion" ) ) {
3110 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3113 final Event e11 = new Event( Event.EventType.fusion );
3114 if ( !e11.isEqual( e1 ) ) {
3117 if ( !e11.toNHX().toString().equals( "" ) ) {
3120 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3121 if ( e2.isDuplication() ) {
3124 if ( !e2.isSpeciationOrDuplication() ) {
3127 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3130 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3133 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3136 if ( e11.isEqual( e2 ) ) {
3139 final Event e2c = ( Event ) e2.copy();
3140 if ( !e2c.isEqual( e2 ) ) {
3143 Event e3 = new Event( 1, 2, 3 );
3144 if ( e3.isDuplication() ) {
3147 if ( e3.isSpeciation() ) {
3150 if ( e3.isGeneLoss() ) {
3153 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3156 final Event e3c = ( Event ) e3.copy();
3157 final Event e3cc = ( Event ) e3c.copy();
3158 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3162 if ( !e3c.isEqual( e3cc ) ) {
3165 Event e4 = new Event( 1, 2, 3 );
3166 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3169 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3172 final Event e4c = ( Event ) e4.copy();
3174 final Event e4cc = ( Event ) e4c.copy();
3175 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3178 if ( !e4c.isEqual( e4cc ) ) {
3181 final Event e5 = new Event();
3182 if ( !e5.isUnassigned() ) {
3185 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3188 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3191 final Event e6 = new Event( 1, 0, 0 );
3192 if ( !e6.asText().toString().equals( "duplication" ) ) {
3195 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3198 final Event e7 = new Event( 0, 1, 0 );
3199 if ( !e7.asText().toString().equals( "speciation" ) ) {
3202 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3205 final Event e8 = new Event( 0, 0, 1 );
3206 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3209 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3213 catch ( final Exception e ) {
3214 e.printStackTrace( System.out );
3220 private static boolean testDeletionOfExternalNodes() {
3222 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3223 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3224 final PhylogenyWriter w = new PhylogenyWriter();
3225 if ( t0.isEmpty() ) {
3228 if ( t0.getNumberOfExternalNodes() != 1 ) {
3231 t0.deleteSubtree( t0.getNode( "A" ), false );
3232 if ( t0.getNumberOfExternalNodes() != 0 ) {
3235 if ( !t0.isEmpty() ) {
3238 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3239 if ( t1.getNumberOfExternalNodes() != 2 ) {
3242 t1.deleteSubtree( t1.getNode( "A" ), false );
3243 if ( t1.getNumberOfExternalNodes() != 1 ) {
3246 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3249 t1.deleteSubtree( t1.getNode( "B" ), false );
3250 if ( t1.getNumberOfExternalNodes() != 1 ) {
3253 t1.deleteSubtree( t1.getNode( "r" ), false );
3254 if ( !t1.isEmpty() ) {
3257 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3258 if ( t2.getNumberOfExternalNodes() != 3 ) {
3261 t2.deleteSubtree( t2.getNode( "B" ), false );
3262 if ( t2.getNumberOfExternalNodes() != 2 ) {
3265 t2.toNewHampshireX();
3266 PhylogenyNode n = t2.getNode( "A" );
3267 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3270 t2.deleteSubtree( t2.getNode( "A" ), false );
3271 if ( t2.getNumberOfExternalNodes() != 2 ) {
3274 t2.deleteSubtree( t2.getNode( "C" ), true );
3275 if ( t2.getNumberOfExternalNodes() != 1 ) {
3278 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3279 if ( t3.getNumberOfExternalNodes() != 4 ) {
3282 t3.deleteSubtree( t3.getNode( "B" ), true );
3283 if ( t3.getNumberOfExternalNodes() != 3 ) {
3286 n = t3.getNode( "A" );
3287 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3290 n = n.getNextExternalNode();
3291 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3294 t3.deleteSubtree( t3.getNode( "A" ), true );
3295 if ( t3.getNumberOfExternalNodes() != 2 ) {
3298 n = t3.getNode( "C" );
3299 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3302 t3.deleteSubtree( t3.getNode( "C" ), true );
3303 if ( t3.getNumberOfExternalNodes() != 1 ) {
3306 t3.deleteSubtree( t3.getNode( "D" ), true );
3307 if ( t3.getNumberOfExternalNodes() != 0 ) {
3310 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3311 if ( t4.getNumberOfExternalNodes() != 6 ) {
3314 t4.deleteSubtree( t4.getNode( "B2" ), true );
3315 if ( t4.getNumberOfExternalNodes() != 5 ) {
3318 String s = w.toNewHampshire( t4, false, true ).toString();
3319 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3322 t4.deleteSubtree( t4.getNode( "B11" ), true );
3323 if ( t4.getNumberOfExternalNodes() != 4 ) {
3326 t4.deleteSubtree( t4.getNode( "C" ), true );
3327 if ( t4.getNumberOfExternalNodes() != 3 ) {
3330 n = t4.getNode( "A" );
3331 n = n.getNextExternalNode();
3332 if ( !n.getName().equals( "B12" ) ) {
3335 n = n.getNextExternalNode();
3336 if ( !n.getName().equals( "D" ) ) {
3339 s = w.toNewHampshire( t4, false, true ).toString();
3340 if ( !s.equals( "((A,B12),D);" ) ) {
3343 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3344 t5.deleteSubtree( t5.getNode( "A" ), true );
3345 if ( t5.getNumberOfExternalNodes() != 5 ) {
3348 s = w.toNewHampshire( t5, false, true ).toString();
3349 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3352 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3353 t6.deleteSubtree( t6.getNode( "B11" ), true );
3354 if ( t6.getNumberOfExternalNodes() != 5 ) {
3357 s = w.toNewHampshire( t6, false, false ).toString();
3358 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3361 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3362 t7.deleteSubtree( t7.getNode( "B12" ), true );
3363 if ( t7.getNumberOfExternalNodes() != 5 ) {
3366 s = w.toNewHampshire( t7, false, true ).toString();
3367 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3370 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3371 t8.deleteSubtree( t8.getNode( "B2" ), true );
3372 if ( t8.getNumberOfExternalNodes() != 5 ) {
3375 s = w.toNewHampshire( t8, false, false ).toString();
3376 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3379 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3380 t9.deleteSubtree( t9.getNode( "C" ), true );
3381 if ( t9.getNumberOfExternalNodes() != 5 ) {
3384 s = w.toNewHampshire( t9, false, true ).toString();
3385 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3388 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3389 t10.deleteSubtree( t10.getNode( "D" ), true );
3390 if ( t10.getNumberOfExternalNodes() != 5 ) {
3393 s = w.toNewHampshire( t10, false, true ).toString();
3394 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3397 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3398 t11.deleteSubtree( t11.getNode( "A" ), true );
3399 if ( t11.getNumberOfExternalNodes() != 2 ) {
3402 s = w.toNewHampshire( t11, false, true ).toString();
3403 if ( !s.equals( "(B,C);" ) ) {
3406 t11.deleteSubtree( t11.getNode( "C" ), true );
3407 if ( t11.getNumberOfExternalNodes() != 1 ) {
3410 s = w.toNewHampshire( t11, false, false ).toString();
3411 if ( !s.equals( "B;" ) ) {
3414 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3415 t12.deleteSubtree( t12.getNode( "B2" ), true );
3416 if ( t12.getNumberOfExternalNodes() != 8 ) {
3419 s = w.toNewHampshire( t12, false, true ).toString();
3420 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3423 t12.deleteSubtree( t12.getNode( "B3" ), true );
3424 if ( t12.getNumberOfExternalNodes() != 7 ) {
3427 s = w.toNewHampshire( t12, false, true ).toString();
3428 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3431 t12.deleteSubtree( t12.getNode( "C3" ), true );
3432 if ( t12.getNumberOfExternalNodes() != 6 ) {
3435 s = w.toNewHampshire( t12, false, true ).toString();
3436 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3439 t12.deleteSubtree( t12.getNode( "A1" ), true );
3440 if ( t12.getNumberOfExternalNodes() != 5 ) {
3443 s = w.toNewHampshire( t12, false, true ).toString();
3444 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3447 t12.deleteSubtree( t12.getNode( "B1" ), true );
3448 if ( t12.getNumberOfExternalNodes() != 4 ) {
3451 s = w.toNewHampshire( t12, false, true ).toString();
3452 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3455 t12.deleteSubtree( t12.getNode( "A3" ), true );
3456 if ( t12.getNumberOfExternalNodes() != 3 ) {
3459 s = w.toNewHampshire( t12, false, true ).toString();
3460 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3463 t12.deleteSubtree( t12.getNode( "A2" ), true );
3464 if ( t12.getNumberOfExternalNodes() != 2 ) {
3467 s = w.toNewHampshire( t12, false, true ).toString();
3468 if ( !s.equals( "(C1,C2);" ) ) {
3471 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3472 t13.deleteSubtree( t13.getNode( "D" ), true );
3473 if ( t13.getNumberOfExternalNodes() != 4 ) {
3476 s = w.toNewHampshire( t13, false, true ).toString();
3477 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3480 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3481 t14.deleteSubtree( t14.getNode( "E" ), true );
3482 if ( t14.getNumberOfExternalNodes() != 5 ) {
3485 s = w.toNewHampshire( t14, false, true ).toString();
3486 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3489 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3490 t15.deleteSubtree( t15.getNode( "B2" ), true );
3491 if ( t15.getNumberOfExternalNodes() != 11 ) {
3494 t15.deleteSubtree( t15.getNode( "B1" ), true );
3495 if ( t15.getNumberOfExternalNodes() != 10 ) {
3498 t15.deleteSubtree( t15.getNode( "B3" ), true );
3499 if ( t15.getNumberOfExternalNodes() != 9 ) {
3502 t15.deleteSubtree( t15.getNode( "B4" ), true );
3503 if ( t15.getNumberOfExternalNodes() != 8 ) {
3506 t15.deleteSubtree( t15.getNode( "A1" ), true );
3507 if ( t15.getNumberOfExternalNodes() != 7 ) {
3510 t15.deleteSubtree( t15.getNode( "C4" ), true );
3511 if ( t15.getNumberOfExternalNodes() != 6 ) {
3515 catch ( final Exception e ) {
3516 e.printStackTrace( System.out );
3522 private static boolean testDescriptiveStatistics() {
3524 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3525 dss1.addValue( 82 );
3526 dss1.addValue( 78 );
3527 dss1.addValue( 70 );
3528 dss1.addValue( 58 );
3529 dss1.addValue( 42 );
3530 if ( dss1.getN() != 5 ) {
3533 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3536 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3539 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3542 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3545 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3548 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3551 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3554 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3557 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3560 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3563 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3566 dss1.addValue( 123 );
3567 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3570 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3573 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3576 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3577 dss2.addValue( -1.85 );
3578 dss2.addValue( 57.5 );
3579 dss2.addValue( 92.78 );
3580 dss2.addValue( 57.78 );
3581 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3584 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3587 final double[] a = dss2.getDataAsDoubleArray();
3588 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3591 dss2.addValue( -100 );
3592 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3595 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3598 final double[] ds = new double[ 14 ];
3613 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3614 if ( bins.length != 4 ) {
3617 if ( bins[ 0 ] != 2 ) {
3620 if ( bins[ 1 ] != 3 ) {
3623 if ( bins[ 2 ] != 4 ) {
3626 if ( bins[ 3 ] != 5 ) {
3629 final double[] ds1 = new double[ 9 ];
3639 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3640 if ( bins1.length != 4 ) {
3643 if ( bins1[ 0 ] != 2 ) {
3646 if ( bins1[ 1 ] != 3 ) {
3649 if ( bins1[ 2 ] != 0 ) {
3652 if ( bins1[ 3 ] != 4 ) {
3655 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3656 if ( bins1_1.length != 3 ) {
3659 if ( bins1_1[ 0 ] != 3 ) {
3662 if ( bins1_1[ 1 ] != 2 ) {
3665 if ( bins1_1[ 2 ] != 4 ) {
3668 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3669 if ( bins1_2.length != 3 ) {
3672 if ( bins1_2[ 0 ] != 2 ) {
3675 if ( bins1_2[ 1 ] != 2 ) {
3678 if ( bins1_2[ 2 ] != 2 ) {
3681 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3695 dss3.addValue( 10 );
3696 dss3.addValue( 10 );
3697 dss3.addValue( 10 );
3698 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3699 histo.toStringBuffer( 10, '=', 40, 5 );
3700 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3702 catch ( final Exception e ) {
3703 e.printStackTrace( System.out );
3709 private static boolean testDir( final String file ) {
3711 final File f = new File( file );
3712 if ( !f.exists() ) {
3715 if ( !f.isDirectory() ) {
3718 if ( !f.canRead() ) {
3722 catch ( final Exception e ) {
3728 private static boolean testGenbankAccessorParsing() {
3729 //The format for GenBank Accession numbers are:
3730 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3731 //Protein: 3 letters + 5 numerals
3732 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3733 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3736 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3739 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3742 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3745 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3748 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3751 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3754 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3757 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3760 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3763 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3766 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3769 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3772 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3778 private static boolean testExternalNodeRelatedMethods() {
3780 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3781 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3782 PhylogenyNode n = t1.getNode( "A" );
3783 n = n.getNextExternalNode();
3784 if ( !n.getName().equals( "B" ) ) {
3787 n = n.getNextExternalNode();
3788 if ( !n.getName().equals( "C" ) ) {
3791 n = n.getNextExternalNode();
3792 if ( !n.getName().equals( "D" ) ) {
3795 n = t1.getNode( "B" );
3796 while ( !n.isLastExternalNode() ) {
3797 n = n.getNextExternalNode();
3799 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3800 n = t2.getNode( "A" );
3801 n = n.getNextExternalNode();
3802 if ( !n.getName().equals( "B" ) ) {
3805 n = n.getNextExternalNode();
3806 if ( !n.getName().equals( "C" ) ) {
3809 n = n.getNextExternalNode();
3810 if ( !n.getName().equals( "D" ) ) {
3813 n = t2.getNode( "B" );
3814 while ( !n.isLastExternalNode() ) {
3815 n = n.getNextExternalNode();
3817 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3818 n = t3.getNode( "A" );
3819 n = n.getNextExternalNode();
3820 if ( !n.getName().equals( "B" ) ) {
3823 n = n.getNextExternalNode();
3824 if ( !n.getName().equals( "C" ) ) {
3827 n = n.getNextExternalNode();
3828 if ( !n.getName().equals( "D" ) ) {
3831 n = n.getNextExternalNode();
3832 if ( !n.getName().equals( "E" ) ) {
3835 n = n.getNextExternalNode();
3836 if ( !n.getName().equals( "F" ) ) {
3839 n = n.getNextExternalNode();
3840 if ( !n.getName().equals( "G" ) ) {
3843 n = n.getNextExternalNode();
3844 if ( !n.getName().equals( "H" ) ) {
3847 n = t3.getNode( "B" );
3848 while ( !n.isLastExternalNode() ) {
3849 n = n.getNextExternalNode();
3851 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3852 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3853 final PhylogenyNode node = iter.next();
3855 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3856 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3857 final PhylogenyNode node = iter.next();
3859 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3860 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3861 if ( !iter.next().getName().equals( "A" ) ) {
3864 if ( !iter.next().getName().equals( "B" ) ) {
3867 if ( !iter.next().getName().equals( "C" ) ) {
3870 if ( !iter.next().getName().equals( "D" ) ) {
3873 if ( !iter.next().getName().equals( "E" ) ) {
3876 if ( !iter.next().getName().equals( "F" ) ) {
3879 if ( iter.hasNext() ) {
3883 catch ( final Exception e ) {
3884 e.printStackTrace( System.out );
3890 private static boolean testExtractSNFromNodeName() {
3892 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3895 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3896 .equals( "Mus musculus musculus" ) ) {
3899 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3900 .equals( "Mus musculus musculus" ) ) {
3903 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3906 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3907 .equals( "Mus musculus" ) ) {
3911 catch ( final Exception e ) {
3912 e.printStackTrace( System.out );
3918 private static boolean testExtractTaxonomyCodeFromNodeName() {
3920 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3923 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3924 .equals( "SOYBN" ) ) {
3927 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3928 .equals( "ARATH" ) ) {
3931 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3932 .equals( "ARATH" ) ) {
3935 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3938 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3941 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3944 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3945 .equals( "SOYBN" ) ) {
3948 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3949 .equals( "SOYBN" ) ) {
3952 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3953 .equals( "SOYBN" ) ) {
3956 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3957 .equals( "SOYBN" ) ) {
3960 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3961 .equals( "SOYBN" ) ) {
3964 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3965 .equals( "SOYBN" ) ) {
3968 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3969 .equals( "SOYBN" ) ) {
3972 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3973 .equals( "SOYBN" ) ) {
3976 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3979 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3980 .equals( "SOYBN" ) ) {
3983 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3984 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3987 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3988 .equals( "9YX45" ) ) {
3991 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3992 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3993 .equals( "MOUSE" ) ) {
3996 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3997 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3998 .equals( "MOUSE" ) ) {
4001 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4002 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4003 .equals( "MOUSE" ) ) {
4006 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4007 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4010 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4011 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4014 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4015 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4018 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4019 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4022 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4023 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4026 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4027 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4030 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4031 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4034 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4035 .equals( "RAT" ) ) {
4038 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4039 .equals( "PIG" ) ) {
4043 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4044 .equals( "MOUSE" ) ) {
4047 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4048 .equals( "MOUSE" ) ) {
4051 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4055 catch ( final Exception e ) {
4056 e.printStackTrace( System.out );
4062 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4064 PhylogenyNode n = new PhylogenyNode();
4065 n.setName( "tr|B3RJ64" );
4066 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4069 n.setName( "tr.B3RJ64" );
4070 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4073 n.setName( "tr=B3RJ64" );
4074 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4077 n.setName( "tr-B3RJ64" );
4078 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4081 n.setName( "tr/B3RJ64" );
4082 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4085 n.setName( "tr\\B3RJ64" );
4086 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4089 n.setName( "tr_B3RJ64" );
4090 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4093 n.setName( " tr|B3RJ64 " );
4094 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4097 n.setName( "-tr|B3RJ64-" );
4098 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4101 n.setName( "-tr=B3RJ64-" );
4102 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4105 n.setName( "_tr=B3RJ64_" );
4106 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4109 n.setName( " tr_tr|B3RJ64_sp|123 " );
4110 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4113 n.setName( "B3RJ64" );
4114 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4117 n.setName( "sp|B3RJ64" );
4118 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4121 n.setName( "sp|B3RJ64C" );
4122 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4125 n.setName( "sp B3RJ64" );
4126 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4129 n.setName( "sp|B3RJ6X" );
4130 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4133 n.setName( "sp|B3RJ6" );
4134 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4137 n.setName( "K1PYK7_CRAGI" );
4138 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4141 n.setName( "K1PYK7_PEA" );
4142 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4145 n.setName( "K1PYK7_RAT" );
4146 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4149 n.setName( "K1PYK7_PIG" );
4150 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4153 n.setName( "~K1PYK7_PIG~" );
4154 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4157 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4158 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4161 n.setName( "K1PYKX_CRAGI" );
4162 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4165 n.setName( "XXXXX_CRAGI" );
4166 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4169 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4170 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4173 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4174 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4177 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4178 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4181 n = new PhylogenyNode();
4182 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4183 seq.setSymbol( "K1PYK7_CRAGI" );
4184 n.getNodeData().addSequence( seq );
4185 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4188 seq.setSymbol( "tr|B3RJ64" );
4189 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4192 n = new PhylogenyNode();
4193 seq = new org.forester.phylogeny.data.Sequence();
4194 seq.setName( "K1PYK7_CRAGI" );
4195 n.getNodeData().addSequence( seq );
4196 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4199 seq.setName( "tr|B3RJ64" );
4200 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4203 n = new PhylogenyNode();
4204 seq = new org.forester.phylogeny.data.Sequence();
4205 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4206 n.getNodeData().addSequence( seq );
4207 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4210 n = new PhylogenyNode();
4211 seq = new org.forester.phylogeny.data.Sequence();
4212 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4213 n.getNodeData().addSequence( seq );
4214 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4218 n = new PhylogenyNode();
4219 n.setName( "ACP19736" );
4220 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4223 n = new PhylogenyNode();
4224 n.setName( "|ACP19736|" );
4225 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4229 catch ( final Exception e ) {
4230 e.printStackTrace( System.out );
4236 private static boolean testFastaParser() {
4238 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4241 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4244 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4245 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4248 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4251 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4254 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4257 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4260 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4264 catch ( final Exception e ) {
4265 e.printStackTrace();
4271 private static boolean testGeneralMsaParser() {
4273 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4274 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4275 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4276 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4277 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4278 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4279 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4280 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4281 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4284 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4287 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4290 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4293 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4296 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4299 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4302 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4305 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4308 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4311 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4314 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4317 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4318 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4321 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4324 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4327 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4328 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4331 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4334 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4337 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4338 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4341 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4344 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4348 catch ( final Exception e ) {
4349 e.printStackTrace();
4355 private static boolean testGeneralTable() {
4357 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4358 t0.setValue( 3, 2, "23" );
4359 t0.setValue( 10, 1, "error" );
4360 t0.setValue( 10, 1, "110" );
4361 t0.setValue( 9, 1, "19" );
4362 t0.setValue( 1, 10, "101" );
4363 t0.setValue( 10, 10, "1010" );
4364 t0.setValue( 100, 10, "10100" );
4365 t0.setValue( 0, 0, "00" );
4366 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4369 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4372 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4375 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4378 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4381 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4384 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4387 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4390 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4393 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4394 t1.setValue( "3", "2", "23" );
4395 t1.setValue( "10", "1", "error" );
4396 t1.setValue( "10", "1", "110" );
4397 t1.setValue( "9", "1", "19" );
4398 t1.setValue( "1", "10", "101" );
4399 t1.setValue( "10", "10", "1010" );
4400 t1.setValue( "100", "10", "10100" );
4401 t1.setValue( "0", "0", "00" );
4402 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4403 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4406 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4409 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4412 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4415 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4418 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4421 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4424 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4427 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4430 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4434 catch ( final Exception e ) {
4435 e.printStackTrace( System.out );
4441 private static boolean testGetDistance() {
4443 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4444 final Phylogeny p1 = factory.create( "(((A:1,B:2,X:100)ab:3,C:4)abc:5,(D:7,(E:9,F:10)ef:8)def:6)r",
4445 new NHXParser() )[ 0 ];
4446 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4449 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4452 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4455 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4458 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4461 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4464 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4467 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4470 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4473 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4476 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4479 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4482 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4485 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4488 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4491 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4494 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4497 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4500 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4503 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4506 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4509 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4512 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4515 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4518 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4521 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4524 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4527 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4530 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4533 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4536 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4539 final Phylogeny p2 = factory.create( "((A:4,B:5,C:6)abc:1,(D:7,E:8,F:9)def:2,(G:10,H:11,I:12)ghi:3)r",
4540 new NHXParser() )[ 0 ];
4541 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4544 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4547 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4550 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4553 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4556 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4559 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4562 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4565 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4568 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4571 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4575 catch ( final Exception e ) {
4576 e.printStackTrace( System.out );
4582 private static boolean testGetLCA() {
4584 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4585 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4586 new NHXParser() )[ 0 ];
4587 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4588 if ( !A.getName().equals( "A" ) ) {
4591 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4592 if ( !gh.getName().equals( "gh" ) ) {
4595 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4596 if ( !ab.getName().equals( "ab" ) ) {
4599 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4600 if ( !ab2.getName().equals( "ab" ) ) {
4603 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4604 if ( !gh2.getName().equals( "gh" ) ) {
4607 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4608 if ( !gh3.getName().equals( "gh" ) ) {
4611 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4612 if ( !abc.getName().equals( "abc" ) ) {
4615 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4616 if ( !abc2.getName().equals( "abc" ) ) {
4619 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4620 if ( !abcd.getName().equals( "abcd" ) ) {
4623 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4624 if ( !abcd2.getName().equals( "abcd" ) ) {
4627 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4628 if ( !abcdef.getName().equals( "abcdef" ) ) {
4631 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4632 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4635 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4636 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4639 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4640 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4643 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4644 if ( !abcde.getName().equals( "abcde" ) ) {
4647 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4648 if ( !abcde2.getName().equals( "abcde" ) ) {
4651 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4652 if ( !r.getName().equals( "abcdefgh" ) ) {
4655 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4656 if ( !r2.getName().equals( "abcdefgh" ) ) {
4659 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4660 if ( !r3.getName().equals( "abcdefgh" ) ) {
4663 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4664 if ( !abcde3.getName().equals( "abcde" ) ) {
4667 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4668 if ( !abcde4.getName().equals( "abcde" ) ) {
4671 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4672 if ( !ab3.getName().equals( "ab" ) ) {
4675 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4676 if ( !ab4.getName().equals( "ab" ) ) {
4679 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4680 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4681 if ( !cd.getName().equals( "cd" ) ) {
4684 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4685 if ( !cd2.getName().equals( "cd" ) ) {
4688 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4689 if ( !cde.getName().equals( "cde" ) ) {
4692 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4693 if ( !cde2.getName().equals( "cde" ) ) {
4696 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4697 if ( !cdef.getName().equals( "cdef" ) ) {
4700 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4701 if ( !cdef2.getName().equals( "cdef" ) ) {
4704 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4705 if ( !cdef3.getName().equals( "cdef" ) ) {
4708 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4709 if ( !rt.getName().equals( "r" ) ) {
4712 final Phylogeny p3 = factory
4713 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4714 new NHXParser() )[ 0 ];
4715 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4716 if ( !bc_3.getName().equals( "bc" ) ) {
4719 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4720 if ( !ac_3.getName().equals( "abc" ) ) {
4723 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4724 if ( !ad_3.getName().equals( "abcde" ) ) {
4727 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4728 if ( !af_3.getName().equals( "abcdef" ) ) {
4731 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4732 if ( !ag_3.getName().equals( "" ) ) {
4735 if ( !ag_3.isRoot() ) {
4738 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4739 if ( !al_3.getName().equals( "" ) ) {
4742 if ( !al_3.isRoot() ) {
4745 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4746 if ( !kl_3.getName().equals( "" ) ) {
4749 if ( !kl_3.isRoot() ) {
4752 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4753 if ( !fl_3.getName().equals( "" ) ) {
4756 if ( !fl_3.isRoot() ) {
4759 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4760 if ( !gk_3.getName().equals( "ghijk" ) ) {
4763 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4764 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4765 if ( !r_4.getName().equals( "r" ) ) {
4768 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4769 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4770 if ( !r_5.getName().equals( "root" ) ) {
4773 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4774 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4775 if ( !r_6.getName().equals( "rot" ) ) {
4778 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4779 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4780 if ( !r_7.getName().equals( "rott" ) ) {
4784 catch ( final Exception e ) {
4785 e.printStackTrace( System.out );
4791 private static boolean testGetLCA2() {
4793 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4794 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4795 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
4796 PhylogenyMethods.preOrderReId( p_a );
4797 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4798 p_a.getNode( "a" ) );
4799 if ( !p_a_1.getName().equals( "a" ) ) {
4802 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
4803 PhylogenyMethods.preOrderReId( p_b );
4804 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4805 p_b.getNode( "a" ) );
4806 if ( !p_b_1.getName().equals( "b" ) ) {
4809 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4810 p_b.getNode( "b" ) );
4811 if ( !p_b_2.getName().equals( "b" ) ) {
4814 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4815 PhylogenyMethods.preOrderReId( p_c );
4816 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4817 p_c.getNode( "a" ) );
4818 if ( !p_c_1.getName().equals( "b" ) ) {
4821 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4822 p_c.getNode( "c" ) );
4823 if ( !p_c_2.getName().equals( "c" ) ) {
4824 System.out.println( p_c_2.getName() );
4828 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4829 p_c.getNode( "b" ) );
4830 if ( !p_c_3.getName().equals( "b" ) ) {
4833 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4834 p_c.getNode( "a" ) );
4835 if ( !p_c_4.getName().equals( "c" ) ) {
4838 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4839 new NHXParser() )[ 0 ];
4840 PhylogenyMethods.preOrderReId( p1 );
4841 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4842 p1.getNode( "A" ) );
4843 if ( !A.getName().equals( "A" ) ) {
4846 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4847 p1.getNode( "gh" ) );
4848 if ( !gh.getName().equals( "gh" ) ) {
4851 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4852 p1.getNode( "B" ) );
4853 if ( !ab.getName().equals( "ab" ) ) {
4856 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4857 p1.getNode( "A" ) );
4858 if ( !ab2.getName().equals( "ab" ) ) {
4861 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4862 p1.getNode( "G" ) );
4863 if ( !gh2.getName().equals( "gh" ) ) {
4866 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4867 p1.getNode( "H" ) );
4868 if ( !gh3.getName().equals( "gh" ) ) {
4871 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4872 p1.getNode( "A" ) );
4873 if ( !abc.getName().equals( "abc" ) ) {
4876 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4877 p1.getNode( "C" ) );
4878 if ( !abc2.getName().equals( "abc" ) ) {
4881 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4882 p1.getNode( "D" ) );
4883 if ( !abcd.getName().equals( "abcd" ) ) {
4886 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4887 p1.getNode( "A" ) );
4888 if ( !abcd2.getName().equals( "abcd" ) ) {
4891 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4892 p1.getNode( "F" ) );
4893 if ( !abcdef.getName().equals( "abcdef" ) ) {
4896 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4897 p1.getNode( "A" ) );
4898 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4901 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4902 p1.getNode( "F" ) );
4903 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4906 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4907 p1.getNode( "ab" ) );
4908 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4911 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4912 p1.getNode( "E" ) );
4913 if ( !abcde.getName().equals( "abcde" ) ) {
4916 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4917 p1.getNode( "A" ) );
4918 if ( !abcde2.getName().equals( "abcde" ) ) {
4921 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4922 p1.getNode( "abcdefgh" ) );
4923 if ( !r.getName().equals( "abcdefgh" ) ) {
4926 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4927 p1.getNode( "H" ) );
4928 if ( !r2.getName().equals( "abcdefgh" ) ) {
4931 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4932 p1.getNode( "A" ) );
4933 if ( !r3.getName().equals( "abcdefgh" ) ) {
4936 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4937 p1.getNode( "abcde" ) );
4938 if ( !abcde3.getName().equals( "abcde" ) ) {
4941 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4942 p1.getNode( "E" ) );
4943 if ( !abcde4.getName().equals( "abcde" ) ) {
4946 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4947 p1.getNode( "B" ) );
4948 if ( !ab3.getName().equals( "ab" ) ) {
4951 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4952 p1.getNode( "ab" ) );
4953 if ( !ab4.getName().equals( "ab" ) ) {
4956 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4957 PhylogenyMethods.preOrderReId( p2 );
4958 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4959 p2.getNode( "d" ) );
4960 if ( !cd.getName().equals( "cd" ) ) {
4963 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4964 p2.getNode( "c" ) );
4965 if ( !cd2.getName().equals( "cd" ) ) {
4968 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4969 p2.getNode( "e" ) );
4970 if ( !cde.getName().equals( "cde" ) ) {
4973 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4974 p2.getNode( "c" ) );
4975 if ( !cde2.getName().equals( "cde" ) ) {
4978 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4979 p2.getNode( "f" ) );
4980 if ( !cdef.getName().equals( "cdef" ) ) {
4983 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4984 p2.getNode( "f" ) );
4985 if ( !cdef2.getName().equals( "cdef" ) ) {
4988 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4989 p2.getNode( "d" ) );
4990 if ( !cdef3.getName().equals( "cdef" ) ) {
4993 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4994 p2.getNode( "a" ) );
4995 if ( !rt.getName().equals( "r" ) ) {
4998 final Phylogeny p3 = factory
4999 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5000 new NHXParser() )[ 0 ];
5001 PhylogenyMethods.preOrderReId( p3 );
5002 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5003 p3.getNode( "c" ) );
5004 if ( !bc_3.getName().equals( "bc" ) ) {
5007 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5008 p3.getNode( "c" ) );
5009 if ( !ac_3.getName().equals( "abc" ) ) {
5012 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5013 p3.getNode( "d" ) );
5014 if ( !ad_3.getName().equals( "abcde" ) ) {
5017 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5018 p3.getNode( "f" ) );
5019 if ( !af_3.getName().equals( "abcdef" ) ) {
5022 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5023 p3.getNode( "g" ) );
5024 if ( !ag_3.getName().equals( "" ) ) {
5027 if ( !ag_3.isRoot() ) {
5030 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5031 p3.getNode( "l" ) );
5032 if ( !al_3.getName().equals( "" ) ) {
5035 if ( !al_3.isRoot() ) {
5038 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5039 p3.getNode( "l" ) );
5040 if ( !kl_3.getName().equals( "" ) ) {
5043 if ( !kl_3.isRoot() ) {
5046 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5047 p3.getNode( "l" ) );
5048 if ( !fl_3.getName().equals( "" ) ) {
5051 if ( !fl_3.isRoot() ) {
5054 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5055 p3.getNode( "k" ) );
5056 if ( !gk_3.getName().equals( "ghijk" ) ) {
5059 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5060 PhylogenyMethods.preOrderReId( p4 );
5061 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5062 p4.getNode( "c" ) );
5063 if ( !r_4.getName().equals( "r" ) ) {
5066 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5067 PhylogenyMethods.preOrderReId( p5 );
5068 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5069 p5.getNode( "c" ) );
5070 if ( !r_5.getName().equals( "root" ) ) {
5073 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5074 PhylogenyMethods.preOrderReId( p6 );
5075 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5076 p6.getNode( "a" ) );
5077 if ( !r_6.getName().equals( "rot" ) ) {
5080 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5081 PhylogenyMethods.preOrderReId( p7 );
5082 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5083 p7.getNode( "e" ) );
5084 if ( !r_7.getName().equals( "rott" ) ) {
5087 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5088 p7.getNode( "a" ) );
5089 if ( !r_71.getName().equals( "rott" ) ) {
5092 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5093 p7.getNode( "rott" ) );
5094 if ( !r_72.getName().equals( "rott" ) ) {
5097 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5098 p7.getNode( "a" ) );
5099 if ( !r_73.getName().equals( "rott" ) ) {
5102 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5103 p7.getNode( "rott" ) );
5104 if ( !r_74.getName().equals( "rott" ) ) {
5107 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5108 p7.getNode( "e" ) );
5109 if ( !r_75.getName().equals( "e" ) ) {
5113 catch ( final Exception e ) {
5114 e.printStackTrace( System.out );
5120 private static boolean testHmmscanOutputParser() {
5121 final String test_dir = Test.PATH_TO_TEST_DATA;
5123 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5124 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5126 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5127 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5128 final List<Protein> proteins = parser2.parse();
5129 if ( parser2.getProteinsEncountered() != 4 ) {
5132 if ( proteins.size() != 4 ) {
5135 if ( parser2.getDomainsEncountered() != 69 ) {
5138 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5141 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5144 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5147 final Protein p1 = proteins.get( 0 );
5148 if ( p1.getNumberOfProteinDomains() != 15 ) {
5151 if ( p1.getLength() != 850 ) {
5154 final Protein p2 = proteins.get( 1 );
5155 if ( p2.getNumberOfProteinDomains() != 51 ) {
5158 if ( p2.getLength() != 1291 ) {
5161 final Protein p3 = proteins.get( 2 );
5162 if ( p3.getNumberOfProteinDomains() != 2 ) {
5165 final Protein p4 = proteins.get( 3 );
5166 if ( p4.getNumberOfProteinDomains() != 1 ) {
5169 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5172 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5175 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5178 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5181 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5184 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5187 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5191 catch ( final Exception e ) {
5192 e.printStackTrace( System.out );
5198 private static boolean testLastExternalNodeMethods() {
5200 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5201 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5202 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5203 final PhylogenyNode n1 = t0.getNode( "A" );
5204 if ( n1.isLastExternalNode() ) {
5207 final PhylogenyNode n2 = t0.getNode( "B" );
5208 if ( n2.isLastExternalNode() ) {
5211 final PhylogenyNode n3 = t0.getNode( "C" );
5212 if ( n3.isLastExternalNode() ) {
5215 final PhylogenyNode n4 = t0.getNode( "D" );
5216 if ( !n4.isLastExternalNode() ) {
5220 catch ( final Exception e ) {
5221 e.printStackTrace( System.out );
5227 private static boolean testLevelOrderIterator() {
5229 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5230 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5231 PhylogenyNodeIterator it0;
5232 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5235 for( it0.reset(); it0.hasNext(); ) {
5238 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5239 if ( !it.next().getName().equals( "r" ) ) {
5242 if ( !it.next().getName().equals( "ab" ) ) {
5245 if ( !it.next().getName().equals( "cd" ) ) {
5248 if ( !it.next().getName().equals( "A" ) ) {
5251 if ( !it.next().getName().equals( "B" ) ) {
5254 if ( !it.next().getName().equals( "C" ) ) {
5257 if ( !it.next().getName().equals( "D" ) ) {
5260 if ( it.hasNext() ) {
5263 final Phylogeny t2 = factory.create( "(((1,2,(a,(X,Y,Z)b)3,4,5,6)A,B,C)abc,(D,E,(f1,(f21)f2,f3)F,G)defg)r",
5264 new NHXParser() )[ 0 ];
5265 PhylogenyNodeIterator it2;
5266 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5269 for( it2.reset(); it2.hasNext(); ) {
5272 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5273 if ( !it3.next().getName().equals( "r" ) ) {
5276 if ( !it3.next().getName().equals( "abc" ) ) {
5279 if ( !it3.next().getName().equals( "defg" ) ) {
5282 if ( !it3.next().getName().equals( "A" ) ) {
5285 if ( !it3.next().getName().equals( "B" ) ) {
5288 if ( !it3.next().getName().equals( "C" ) ) {
5291 if ( !it3.next().getName().equals( "D" ) ) {
5294 if ( !it3.next().getName().equals( "E" ) ) {
5297 if ( !it3.next().getName().equals( "F" ) ) {
5300 if ( !it3.next().getName().equals( "G" ) ) {
5303 if ( !it3.next().getName().equals( "1" ) ) {
5306 if ( !it3.next().getName().equals( "2" ) ) {
5309 if ( !it3.next().getName().equals( "3" ) ) {
5312 if ( !it3.next().getName().equals( "4" ) ) {
5315 if ( !it3.next().getName().equals( "5" ) ) {
5318 if ( !it3.next().getName().equals( "6" ) ) {
5321 if ( !it3.next().getName().equals( "f1" ) ) {
5324 if ( !it3.next().getName().equals( "f2" ) ) {
5327 if ( !it3.next().getName().equals( "f3" ) ) {
5330 if ( !it3.next().getName().equals( "a" ) ) {
5333 if ( !it3.next().getName().equals( "b" ) ) {
5336 if ( !it3.next().getName().equals( "f21" ) ) {
5339 if ( !it3.next().getName().equals( "X" ) ) {
5342 if ( !it3.next().getName().equals( "Y" ) ) {
5345 if ( !it3.next().getName().equals( "Z" ) ) {
5348 if ( it3.hasNext() ) {
5351 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5352 PhylogenyNodeIterator it4;
5353 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5356 for( it4.reset(); it4.hasNext(); ) {
5359 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5360 if ( !it5.next().getName().equals( "r" ) ) {
5363 if ( !it5.next().getName().equals( "A" ) ) {
5366 if ( !it5.next().getName().equals( "B" ) ) {
5369 if ( !it5.next().getName().equals( "C" ) ) {
5372 if ( !it5.next().getName().equals( "D" ) ) {
5375 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5376 PhylogenyNodeIterator it6;
5377 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5380 for( it6.reset(); it6.hasNext(); ) {
5383 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5384 if ( !it7.next().getName().equals( "A" ) ) {
5387 if ( it.hasNext() ) {
5391 catch ( final Exception e ) {
5392 e.printStackTrace( System.out );
5398 private static boolean testMafft( final String path ) {
5400 final List<String> opts = new ArrayList<String>();
5401 opts.add( "--maxiterate" );
5403 opts.add( "--localpair" );
5404 opts.add( "--quiet" );
5406 final MsaInferrer mafft = Mafft.createInstance( path );
5407 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5408 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5411 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5415 catch ( final Exception e ) {
5416 e.printStackTrace( System.out );
5422 private static boolean testMidpointrooting() {
5424 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5425 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5426 PhylogenyMethods.midpointRoot( t0 );
5427 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5430 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5433 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5437 final Phylogeny t1 = factory.create( "((A:1,B:2)AB:1[&&NHX:B=55],(C:3,D:4)CD:3[&&NHX:B=10])ABCD:0.5",
5438 new NHXParser() )[ 0 ];
5439 if ( !t1.isRooted() ) {
5442 PhylogenyMethods.midpointRoot( t1 );
5443 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5446 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5449 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5452 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5455 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5458 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5461 t1.reRoot( t1.getNode( "A" ) );
5462 PhylogenyMethods.midpointRoot( t1 );
5463 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5466 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5469 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5472 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5475 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5479 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5483 catch ( final Exception e ) {
5484 e.printStackTrace( System.out );
5490 private static boolean testMsaQualityMethod() {
5492 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5493 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5494 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5495 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5496 final List<Sequence> l = new ArrayList<Sequence>();
5501 final Msa msa = BasicMsa.createInstance( l );
5502 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5505 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5508 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5511 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5515 catch ( final Exception e ) {
5516 e.printStackTrace( System.out );
5522 private static boolean testNextNodeWithCollapsing() {
5524 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5526 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5527 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5528 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5529 t0.getNode( "cd" ).setCollapse( true );
5530 t0.getNode( "cde" ).setCollapse( true );
5531 n = t0.getFirstExternalNode();
5532 while ( n != null ) {
5534 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5536 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5539 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5542 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5545 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5548 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5551 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5555 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5556 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5557 t1.getNode( "ab" ).setCollapse( true );
5558 t1.getNode( "cd" ).setCollapse( true );
5559 t1.getNode( "cde" ).setCollapse( true );
5560 n = t1.getNode( "ab" );
5561 ext = new ArrayList<PhylogenyNode>();
5562 while ( n != null ) {
5564 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5566 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5569 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5572 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5575 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5578 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5584 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5585 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5586 t2.getNode( "ab" ).setCollapse( true );
5587 t2.getNode( "cd" ).setCollapse( true );
5588 t2.getNode( "cde" ).setCollapse( true );
5589 t2.getNode( "c" ).setCollapse( true );
5590 t2.getNode( "d" ).setCollapse( true );
5591 t2.getNode( "e" ).setCollapse( true );
5592 t2.getNode( "gh" ).setCollapse( true );
5593 n = t2.getNode( "ab" );
5594 ext = new ArrayList<PhylogenyNode>();
5595 while ( n != null ) {
5597 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5599 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5602 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5605 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5608 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5614 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5615 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5616 t3.getNode( "ab" ).setCollapse( true );
5617 t3.getNode( "cd" ).setCollapse( true );
5618 t3.getNode( "cde" ).setCollapse( true );
5619 t3.getNode( "c" ).setCollapse( true );
5620 t3.getNode( "d" ).setCollapse( true );
5621 t3.getNode( "e" ).setCollapse( true );
5622 t3.getNode( "gh" ).setCollapse( true );
5623 t3.getNode( "fgh" ).setCollapse( true );
5624 n = t3.getNode( "ab" );
5625 ext = new ArrayList<PhylogenyNode>();
5626 while ( n != null ) {
5628 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5630 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5633 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5636 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5642 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5643 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5644 t4.getNode( "ab" ).setCollapse( true );
5645 t4.getNode( "cd" ).setCollapse( true );
5646 t4.getNode( "cde" ).setCollapse( true );
5647 t4.getNode( "c" ).setCollapse( true );
5648 t4.getNode( "d" ).setCollapse( true );
5649 t4.getNode( "e" ).setCollapse( true );
5650 t4.getNode( "gh" ).setCollapse( true );
5651 t4.getNode( "fgh" ).setCollapse( true );
5652 t4.getNode( "abcdefgh" ).setCollapse( true );
5653 n = t4.getNode( "abcdefgh" );
5654 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5659 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5660 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5662 n = t5.getFirstExternalNode();
5663 while ( n != null ) {
5665 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5667 if ( ext.size() != 8 ) {
5670 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5673 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5676 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5679 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5682 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5685 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5688 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5691 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5696 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5697 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5699 t6.getNode( "ab" ).setCollapse( true );
5700 n = t6.getNode( "ab" );
5701 while ( n != null ) {
5703 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5705 if ( ext.size() != 7 ) {
5708 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5711 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5714 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5717 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5720 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5723 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5726 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5731 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5732 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5734 t7.getNode( "cd" ).setCollapse( true );
5735 n = t7.getNode( "a" );
5736 while ( n != null ) {
5738 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5740 if ( ext.size() != 7 ) {
5743 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5746 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5749 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5752 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5755 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5758 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5761 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5766 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5767 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5769 t8.getNode( "cd" ).setCollapse( true );
5770 t8.getNode( "c" ).setCollapse( true );
5771 t8.getNode( "d" ).setCollapse( true );
5772 n = t8.getNode( "a" );
5773 while ( n != null ) {
5775 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5777 if ( ext.size() != 7 ) {
5780 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5783 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5786 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5787 System.out.println( "2 fail" );
5790 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5793 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5796 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5799 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5804 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5805 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5807 t9.getNode( "gh" ).setCollapse( true );
5808 n = t9.getNode( "a" );
5809 while ( n != null ) {
5811 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5813 if ( ext.size() != 7 ) {
5816 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5819 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5822 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5825 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5828 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5831 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5834 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5839 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5840 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5842 t10.getNode( "gh" ).setCollapse( true );
5843 t10.getNode( "g" ).setCollapse( true );
5844 t10.getNode( "h" ).setCollapse( true );
5845 n = t10.getNode( "a" );
5846 while ( n != null ) {
5848 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5850 if ( ext.size() != 7 ) {
5853 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5856 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5859 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5862 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5865 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5868 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5871 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5876 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5877 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5879 t11.getNode( "gh" ).setCollapse( true );
5880 t11.getNode( "fgh" ).setCollapse( true );
5881 n = t11.getNode( "a" );
5882 while ( n != null ) {
5884 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5886 if ( ext.size() != 6 ) {
5889 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5892 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5895 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5898 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5901 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5904 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5909 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5910 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5912 t12.getNode( "gh" ).setCollapse( true );
5913 t12.getNode( "fgh" ).setCollapse( true );
5914 t12.getNode( "g" ).setCollapse( true );
5915 t12.getNode( "h" ).setCollapse( true );
5916 t12.getNode( "f" ).setCollapse( true );
5917 n = t12.getNode( "a" );
5918 while ( n != null ) {
5920 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5922 if ( ext.size() != 6 ) {
5925 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5928 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5931 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5934 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5937 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5940 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5945 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5946 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5948 t13.getNode( "ab" ).setCollapse( true );
5949 t13.getNode( "b" ).setCollapse( true );
5950 t13.getNode( "fgh" ).setCollapse( true );
5951 t13.getNode( "gh" ).setCollapse( true );
5952 n = t13.getNode( "ab" );
5953 while ( n != null ) {
5955 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5957 if ( ext.size() != 5 ) {
5960 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5963 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5966 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5969 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5972 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5977 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5978 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5980 t14.getNode( "ab" ).setCollapse( true );
5981 t14.getNode( "a" ).setCollapse( true );
5982 t14.getNode( "fgh" ).setCollapse( true );
5983 t14.getNode( "gh" ).setCollapse( true );
5984 n = t14.getNode( "ab" );
5985 while ( n != null ) {
5987 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5989 if ( ext.size() != 5 ) {
5992 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5995 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5998 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6001 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6004 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6009 final StringBuffer sb15 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,x,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6010 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6012 t15.getNode( "ab" ).setCollapse( true );
6013 t15.getNode( "a" ).setCollapse( true );
6014 t15.getNode( "fgh" ).setCollapse( true );
6015 t15.getNode( "gh" ).setCollapse( true );
6016 n = t15.getNode( "ab" );
6017 while ( n != null ) {
6019 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6021 if ( ext.size() != 6 ) {
6024 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6027 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6030 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6033 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6036 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6039 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6044 final StringBuffer sb16 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,x,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6045 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6047 t16.getNode( "ab" ).setCollapse( true );
6048 t16.getNode( "a" ).setCollapse( true );
6049 t16.getNode( "fgh" ).setCollapse( true );
6050 t16.getNode( "gh" ).setCollapse( true );
6051 t16.getNode( "cd" ).setCollapse( true );
6052 t16.getNode( "cde" ).setCollapse( true );
6053 t16.getNode( "d" ).setCollapse( true );
6054 t16.getNode( "x" ).setCollapse( true );
6055 n = t16.getNode( "ab" );
6056 while ( n != null ) {
6058 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6060 if ( ext.size() != 4 ) {
6063 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6066 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6069 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6072 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6076 catch ( final Exception e ) {
6077 e.printStackTrace( System.out );
6083 private static boolean testNexusCharactersParsing() {
6085 final NexusCharactersParser parser = new NexusCharactersParser();
6086 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6088 String[] labels = parser.getCharStateLabels();
6089 if ( labels.length != 7 ) {
6092 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6095 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6098 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6101 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6104 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6107 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6110 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6113 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6115 labels = parser.getCharStateLabels();
6116 if ( labels.length != 7 ) {
6119 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6122 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6125 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6128 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6131 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6134 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6137 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6141 catch ( final Exception e ) {
6142 e.printStackTrace( System.out );
6148 private static boolean testNexusMatrixParsing() {
6150 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6151 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6153 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6154 if ( m.getNumberOfCharacters() != 9 ) {
6157 if ( m.getNumberOfIdentifiers() != 5 ) {
6160 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6163 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6166 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6169 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6172 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6175 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6178 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6181 // if ( labels.length != 7 ) {
6184 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6187 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6190 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6193 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6196 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6199 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6202 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6205 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6207 // labels = parser.getCharStateLabels();
6208 // if ( labels.length != 7 ) {
6211 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6214 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6217 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6220 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6223 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6226 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6229 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6233 catch ( final Exception e ) {
6234 e.printStackTrace( System.out );
6240 private static boolean testNexusTreeParsing() {
6242 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6243 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6244 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6245 if ( phylogenies.length != 1 ) {
6248 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6251 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6255 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6256 if ( phylogenies.length != 1 ) {
6259 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6262 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6266 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6267 if ( phylogenies.length != 1 ) {
6270 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6273 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6276 if ( phylogenies[ 0 ].isRooted() ) {
6280 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6281 if ( phylogenies.length != 18 ) {
6284 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6287 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6290 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6293 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6296 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6299 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6302 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6305 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6308 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6311 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6314 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6317 if ( phylogenies[ 8 ].isRooted() ) {
6320 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6323 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6326 if ( !phylogenies[ 9 ].isRooted() ) {
6329 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6332 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6335 if ( !phylogenies[ 10 ].isRooted() ) {
6338 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6341 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6344 if ( phylogenies[ 11 ].isRooted() ) {
6347 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6350 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6353 if ( !phylogenies[ 12 ].isRooted() ) {
6356 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6359 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6362 if ( !phylogenies[ 13 ].isRooted() ) {
6365 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6368 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6371 if ( !phylogenies[ 14 ].isRooted() ) {
6374 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6377 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6380 if ( phylogenies[ 15 ].isRooted() ) {
6383 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6386 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6389 if ( !phylogenies[ 16 ].isRooted() ) {
6392 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6395 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6398 if ( phylogenies[ 17 ].isRooted() ) {
6401 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6405 catch ( final Exception e ) {
6406 e.printStackTrace( System.out );
6412 private static boolean testNexusTreeParsingIterating() {
6414 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6415 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6416 if ( !p.hasNext() ) {
6419 Phylogeny phy = p.next();
6420 if ( phy == null ) {
6423 if ( phy.getNumberOfExternalNodes() != 25 ) {
6426 if ( !phy.getName().equals( "" ) ) {
6429 if ( p.hasNext() ) {
6433 if ( phy != null ) {
6438 if ( !p.hasNext() ) {
6442 if ( phy == null ) {
6445 if ( phy.getNumberOfExternalNodes() != 25 ) {
6448 if ( !phy.getName().equals( "" ) ) {
6451 if ( p.hasNext() ) {
6455 if ( phy != null ) {
6459 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6460 if ( !p.hasNext() ) {
6464 if ( phy == null ) {
6467 if ( phy.getNumberOfExternalNodes() != 10 ) {
6470 if ( !phy.getName().equals( "name" ) ) {
6473 if ( p.hasNext() ) {
6477 if ( phy != null ) {
6482 if ( !p.hasNext() ) {
6486 if ( phy == null ) {
6489 if ( phy.getNumberOfExternalNodes() != 10 ) {
6492 if ( !phy.getName().equals( "name" ) ) {
6495 if ( p.hasNext() ) {
6499 if ( phy != null ) {
6503 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6504 if ( !p.hasNext() ) {
6508 if ( phy == null ) {
6511 if ( phy.getNumberOfExternalNodes() != 3 ) {
6514 if ( !phy.getName().equals( "" ) ) {
6517 if ( phy.isRooted() ) {
6520 if ( p.hasNext() ) {
6524 if ( phy != null ) {
6529 if ( !p.hasNext() ) {
6533 if ( phy == null ) {
6536 if ( phy.getNumberOfExternalNodes() != 3 ) {
6539 if ( !phy.getName().equals( "" ) ) {
6542 if ( p.hasNext() ) {
6546 if ( phy != null ) {
6550 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6551 // if ( phylogenies.length != 18 ) {
6555 if ( !p.hasNext() ) {
6559 if ( phy == null ) {
6562 if ( phy.getNumberOfExternalNodes() != 10 ) {
6565 if ( !phy.getName().equals( "tree 0" ) ) {
6569 if ( !p.hasNext() ) {
6573 if ( phy == null ) {
6576 if ( phy.getNumberOfExternalNodes() != 10 ) {
6579 if ( !phy.getName().equals( "tree 1" ) ) {
6583 if ( !p.hasNext() ) {
6587 if ( phy == null ) {
6590 if ( phy.getNumberOfExternalNodes() != 3 ) {
6593 if ( !phy.getName().equals( "" ) ) {
6596 if ( phy.isRooted() ) {
6600 if ( !p.hasNext() ) {
6604 if ( phy == null ) {
6607 if ( phy.getNumberOfExternalNodes() != 4 ) {
6610 if ( !phy.getName().equals( "" ) ) {
6613 if ( !phy.isRooted() ) {
6617 if ( !p.hasNext() ) {
6621 if ( phy == null ) {
6624 if ( phy.getNumberOfExternalNodes() != 5 ) {
6625 System.out.println( phy.getNumberOfExternalNodes() );
6628 if ( !phy.getName().equals( "" ) ) {
6631 if ( !phy.isRooted() ) {
6635 if ( !p.hasNext() ) {
6639 if ( phy == null ) {
6642 if ( phy.getNumberOfExternalNodes() != 3 ) {
6645 if ( !phy.getName().equals( "" ) ) {
6648 if ( phy.isRooted() ) {
6652 if ( !p.hasNext() ) {
6656 if ( phy == null ) {
6659 if ( phy.getNumberOfExternalNodes() != 2 ) {
6662 if ( !phy.getName().equals( "" ) ) {
6665 if ( !phy.isRooted() ) {
6669 if ( !p.hasNext() ) {
6673 if ( phy.getNumberOfExternalNodes() != 3 ) {
6676 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6679 if ( !phy.isRooted() ) {
6683 if ( !p.hasNext() ) {
6687 if ( phy.getNumberOfExternalNodes() != 3 ) {
6690 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6693 if ( !phy.getName().equals( "tree 8" ) ) {
6697 if ( !p.hasNext() ) {
6701 if ( phy.getNumberOfExternalNodes() != 3 ) {
6704 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6707 if ( !phy.getName().equals( "tree 9" ) ) {
6711 if ( !p.hasNext() ) {
6715 if ( phy.getNumberOfExternalNodes() != 3 ) {
6718 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6721 if ( !phy.getName().equals( "tree 10" ) ) {
6724 if ( !phy.isRooted() ) {
6728 if ( !p.hasNext() ) {
6732 if ( phy.getNumberOfExternalNodes() != 3 ) {
6735 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6738 if ( !phy.getName().equals( "tree 11" ) ) {
6741 if ( phy.isRooted() ) {
6745 if ( !p.hasNext() ) {
6749 if ( phy.getNumberOfExternalNodes() != 3 ) {
6752 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6755 if ( !phy.getName().equals( "tree 12" ) ) {
6758 if ( !phy.isRooted() ) {
6762 if ( !p.hasNext() ) {
6766 if ( phy.getNumberOfExternalNodes() != 3 ) {
6769 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6772 if ( !phy.getName().equals( "tree 13" ) ) {
6775 if ( !phy.isRooted() ) {
6779 if ( !p.hasNext() ) {
6783 if ( phy.getNumberOfExternalNodes() != 10 ) {
6784 System.out.println( phy.getNumberOfExternalNodes() );
6789 .equals( "(1:0.212481,8:0.297838,(9:0.222729,((6:0.201563,7:0.194547):0.282035,(4:1.146091,(3:1.008881,(10:0.384105,(2:0.235682,5:0.353432):0.32368):0.103875):0.41354):0.254687):0.095341):0.079254):0.0;" ) ) {
6790 System.out.println( phy.toNewHampshire() );
6793 if ( !phy.getName().equals( "tree 14" ) ) {
6796 if ( !phy.isRooted() ) {
6800 if ( !p.hasNext() ) {
6804 if ( phy.getNumberOfExternalNodes() != 10 ) {
6805 System.out.println( phy.getNumberOfExternalNodes() );
6810 .equals( "(1:0.212481,8:0.297838,(9:0.222729,((6:0.201563,7:0.194547):0.282035,(4:1.146091,(3:1.008881,(10:0.384105,(2:0.235682,5:0.353432):0.32368):0.103875):0.41354):0.254687):0.095341):0.079254):0.0;" ) ) {
6811 System.out.println( phy.toNewHampshire() );
6814 if ( !phy.getName().equals( "tree 15" ) ) {
6817 if ( phy.isRooted() ) {
6821 if ( !p.hasNext() ) {
6825 if ( phy.getNumberOfExternalNodes() != 10 ) {
6826 System.out.println( phy.getNumberOfExternalNodes() );
6831 .equals( "(1:0.212481,8:0.297838,(9:0.222729,((6:0.201563,7:0.194547):0.282035,(4:1.146091,(3:1.008881,(10:0.384105,(2:0.235682,5:0.353432):0.32368):0.103875):0.41354):0.254687):0.095341):0.079254):0.0;" ) ) {
6832 System.out.println( phy.toNewHampshire() );
6835 if ( !phy.getName().equals( "tree 16" ) ) {
6838 if ( !phy.isRooted() ) {
6842 if ( !p.hasNext() ) {
6846 if ( phy.getNumberOfExternalNodes() != 10 ) {
6847 System.out.println( phy.getNumberOfExternalNodes() );
6852 .equals( "(1:0.212481,8:0.297838,(9:0.222729,((6:0.201563,7:0.194547):0.282035,(4:1.146091,(3:1.008881,(10:0.384105,(2:0.235682,5:0.353432):0.32368):0.103875):0.41354):0.254687):0.095341):0.079254):0.0;" ) ) {
6853 System.out.println( phy.toNewHampshire() );
6856 if ( !phy.getName().equals( "tree 17" ) ) {
6859 if ( phy.isRooted() ) {
6863 if ( p.hasNext() ) {
6867 if ( phy != null ) {
6872 if ( !p.hasNext() ) {
6876 if ( phy == null ) {
6879 if ( phy.getNumberOfExternalNodes() != 10 ) {
6882 if ( !phy.getName().equals( "tree 0" ) ) {
6886 if ( !p.hasNext() ) {
6890 if ( phy == null ) {
6893 if ( phy.getNumberOfExternalNodes() != 10 ) {
6896 if ( !phy.getName().equals( "tree 1" ) ) {
6900 if ( !p.hasNext() ) {
6904 if ( phy == null ) {
6907 if ( phy.getNumberOfExternalNodes() != 3 ) {
6910 if ( !phy.getName().equals( "" ) ) {
6913 if ( phy.isRooted() ) {
6917 if ( !p.hasNext() ) {
6921 if ( phy == null ) {
6924 if ( phy.getNumberOfExternalNodes() != 4 ) {
6927 if ( !phy.getName().equals( "" ) ) {
6930 if ( !phy.isRooted() ) {
6934 if ( !p.hasNext() ) {
6938 if ( phy == null ) {
6941 if ( phy.getNumberOfExternalNodes() != 5 ) {
6942 System.out.println( phy.getNumberOfExternalNodes() );
6945 if ( !phy.getName().equals( "" ) ) {
6948 if ( !phy.isRooted() ) {
6952 if ( !p.hasNext() ) {
6956 if ( phy == null ) {
6959 if ( phy.getNumberOfExternalNodes() != 3 ) {
6962 if ( !phy.getName().equals( "" ) ) {
6965 if ( phy.isRooted() ) {
6969 catch ( final Exception e ) {
6970 e.printStackTrace( System.out );
6976 private static boolean testNexusTreeParsingTranslating() {
6978 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6979 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6980 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6981 if ( phylogenies.length != 1 ) {
6984 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6987 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6990 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6993 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6996 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6997 .equals( "Aranaeus" ) ) {
7001 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7002 if ( phylogenies.length != 3 ) {
7005 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7008 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7011 if ( phylogenies[ 0 ].isRooted() ) {
7014 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7017 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7020 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7021 .equals( "Aranaeus" ) ) {
7024 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7027 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7030 if ( phylogenies[ 1 ].isRooted() ) {
7033 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7036 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7039 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7040 .equals( "Aranaeus" ) ) {
7043 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7046 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7049 if ( !phylogenies[ 2 ].isRooted() ) {
7052 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7055 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7058 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7059 .equals( "Aranaeus" ) ) {
7063 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7064 if ( phylogenies.length != 3 ) {
7067 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7070 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7073 if ( phylogenies[ 0 ].isRooted() ) {
7076 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7079 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7082 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7083 .equals( "Aranaeus" ) ) {
7086 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7089 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7092 if ( phylogenies[ 1 ].isRooted() ) {
7095 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7098 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7101 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7102 .equals( "Aranaeus" ) ) {
7105 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7108 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7111 if ( !phylogenies[ 2 ].isRooted() ) {
7114 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7117 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7120 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7121 .equals( "Aranaeus" ) ) {
7125 catch ( final Exception e ) {
7126 e.printStackTrace( System.out );
7132 private static boolean testNHParsing() {
7134 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7135 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7136 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7139 final NHXParser nhxp = new NHXParser();
7140 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7141 nhxp.setReplaceUnderscores( true );
7142 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7143 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7146 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7149 final Phylogeny p1b = factory
7150 .create( " \n \t \b \r \f ; ( \n \t \b \r \f; A ; \n \t \b \r \f, \n \t \b \r \f; B ; \n \t \b \r \f 1 \n \t \b \r \f ; \n \t \b \r \f );;;;; \n \t \b \r \f;;; \n \t \b \r \f ",
7151 new NHXParser() )[ 0 ];
7152 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7155 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7158 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7159 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7160 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7161 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7162 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7163 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7164 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7165 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7166 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7167 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7168 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7169 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7170 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7172 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7175 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7178 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7181 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7184 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7185 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7186 final String p16_S = "((A,B),C)";
7187 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7188 if ( p16.length != 1 ) {
7191 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7194 final String p17_S = "(C,(A,B))";
7195 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7196 if ( p17.length != 1 ) {
7199 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7202 final String p18_S = "((A,B),(C,D))";
7203 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7204 if ( p18.length != 1 ) {
7207 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7210 final String p19_S = "(((A,B),C),D)";
7211 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7212 if ( p19.length != 1 ) {
7215 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7218 final String p20_S = "(A,(B,(C,D)))";
7219 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7220 if ( p20.length != 1 ) {
7223 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7226 final String p21_S = "(A,(B,(C,(D,E))))";
7227 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7228 if ( p21.length != 1 ) {
7231 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7234 final String p22_S = "((((A,B),C),D),E)";
7235 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7236 if ( p22.length != 1 ) {
7239 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7242 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7243 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7244 if ( p23.length != 1 ) {
7245 System.out.println( "xl=" + p23.length );
7249 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7252 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7253 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7254 if ( p24.length != 1 ) {
7257 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7260 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7261 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7262 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7263 if ( p241.length != 2 ) {
7266 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7269 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7272 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7273 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7274 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7275 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7276 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7277 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7278 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7279 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7280 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7281 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7284 final String p26_S = "(A,B)ab";
7285 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7286 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7289 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7290 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7291 if ( p27s.length != 1 ) {
7292 System.out.println( "xxl=" + p27s.length );
7296 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7297 System.out.println( p27s[ 0 ].toNewHampshireX() );
7301 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7303 if ( p27.length != 1 ) {
7304 System.out.println( "yl=" + p27.length );
7308 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7309 System.out.println( p27[ 0 ].toNewHampshireX() );
7313 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7314 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7315 final String p28_S3 = "(A,B)ab";
7316 final String p28_S4 = "((((A,B),C),D),;E;)";
7317 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7319 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7322 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7325 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7328 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7331 if ( p28.length != 4 ) {
7334 final String p29_S = "((((A:0.01,B:0.684)ab:0.345,C:0.3451)abc:0.3451,D:1.5)abcd:0.134,E:0.32)abcde:0.1345";
7335 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7336 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7339 final String p30_S = "((((A:0.01,B:0.02):0.93,C:0.04):0.05,D:1.4):0.06,E):0.72";
7340 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7341 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7344 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7345 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7346 if ( ( p32.length != 0 ) ) {
7349 final String p33_S = "A";
7350 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7351 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7354 final String p34_S = "B;";
7355 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7356 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7359 final String p35_S = "B:0.2";
7360 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7361 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7364 final String p36_S = "(A)";
7365 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7366 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7369 final String p37_S = "((A))";
7370 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7371 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7374 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7375 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7376 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7379 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7380 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7381 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7384 final String p40_S = "(A,B,C)";
7385 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7386 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7389 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7390 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7391 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7394 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7395 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7396 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7399 final String p43_S = "(A,B,C,(AA,BB,CC,(CCC,DDD,EEE,(FFFF,GGGG)x)y,DD,EE,FF,GG,HH),D,E,(EE,FF),F,G,H,(((((5)4)3)2)1),I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,(XX,(YY)),Y,Z)";
7400 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7401 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7404 final String p44_S = "(((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)))";
7405 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7406 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7409 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7410 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7411 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7414 final String p46_S = "";
7415 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7416 if ( p46.length != 0 ) {
7419 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7420 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7423 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7424 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7427 final Phylogeny p49 = factory
7428 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7429 new NHXParser() )[ 0 ];
7430 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7433 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7434 if ( p50.getNode( "A" ) == null ) {
7437 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7438 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7441 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7444 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7445 .equals( "((A,B)88:2.0,C);" ) ) {
7448 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7449 if ( p51.getNode( "A(A" ) == null ) {
7452 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7453 if ( p52.getNode( "A(A" ) == null ) {
7456 final Phylogeny p53 = factory
7457 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7458 new NHXParser() )[ 0 ];
7459 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7463 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7464 if ( p54.getNode( "A" ) == null ) {
7467 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7468 .equals( "((A,B)[88],C);" ) ) {
7472 catch ( final Exception e ) {
7473 e.printStackTrace( System.out );
7479 private static boolean testNHParsingIter() {
7481 final String p0_str = "(A,B);";
7482 final NHXParser p = new NHXParser();
7483 p.setSource( p0_str );
7484 if ( !p.hasNext() ) {
7487 final Phylogeny p0 = p.next();
7488 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7489 System.out.println( p0.toNewHampshire() );
7492 if ( p.hasNext() ) {
7495 if ( p.next() != null ) {
7499 final String p00_str = "(A,B)root;";
7500 p.setSource( p00_str );
7501 final Phylogeny p00 = p.next();
7502 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7503 System.out.println( p00.toNewHampshire() );
7507 final String p000_str = "A;";
7508 p.setSource( p000_str );
7509 final Phylogeny p000 = p.next();
7510 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7511 System.out.println( p000.toNewHampshire() );
7515 final String p0000_str = "A";
7516 p.setSource( p0000_str );
7517 final Phylogeny p0000 = p.next();
7518 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7519 System.out.println( p0000.toNewHampshire() );
7523 p.setSource( "(A)" );
7524 final Phylogeny p00000 = p.next();
7525 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7526 System.out.println( p00000.toNewHampshire() );
7530 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7531 p.setSource( p1_str );
7532 if ( !p.hasNext() ) {
7535 final Phylogeny p1_0 = p.next();
7536 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7537 System.out.println( p1_0.toNewHampshire() );
7540 if ( !p.hasNext() ) {
7543 final Phylogeny p1_1 = p.next();
7544 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7545 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7548 if ( !p.hasNext() ) {
7551 final Phylogeny p1_2 = p.next();
7552 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7553 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7556 if ( !p.hasNext() ) {
7559 final Phylogeny p1_3 = p.next();
7560 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7561 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7564 if ( p.hasNext() ) {
7567 if ( p.next() != null ) {
7571 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7572 p.setSource( p2_str );
7573 if ( !p.hasNext() ) {
7576 Phylogeny p2_0 = p.next();
7577 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7578 System.out.println( p2_0.toNewHampshire() );
7581 if ( !p.hasNext() ) {
7584 Phylogeny p2_1 = p.next();
7585 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7586 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7589 if ( !p.hasNext() ) {
7592 Phylogeny p2_2 = p.next();
7593 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7594 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7597 if ( !p.hasNext() ) {
7600 Phylogeny p2_3 = p.next();
7601 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7602 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7605 if ( !p.hasNext() ) {
7608 Phylogeny p2_4 = p.next();
7609 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7610 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7613 if ( p.hasNext() ) {
7616 if ( p.next() != null ) {
7621 if ( !p.hasNext() ) {
7625 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7626 System.out.println( p2_0.toNewHampshire() );
7629 if ( !p.hasNext() ) {
7633 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7634 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7637 if ( !p.hasNext() ) {
7641 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7642 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7645 if ( !p.hasNext() ) {
7649 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7650 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7653 if ( !p.hasNext() ) {
7657 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7658 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7661 if ( p.hasNext() ) {
7664 if ( p.next() != null ) {
7668 final String p3_str = "((A,B),C)abc";
7669 p.setSource( p3_str );
7670 if ( !p.hasNext() ) {
7673 final Phylogeny p3_0 = p.next();
7674 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7677 if ( p.hasNext() ) {
7680 if ( p.next() != null ) {
7684 final String p4_str = "((A,B)ab,C)abc";
7685 p.setSource( p4_str );
7686 if ( !p.hasNext() ) {
7689 final Phylogeny p4_0 = p.next();
7690 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7693 if ( p.hasNext() ) {
7696 if ( p.next() != null ) {
7700 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7701 p.setSource( p5_str );
7702 if ( !p.hasNext() ) {
7705 final Phylogeny p5_0 = p.next();
7706 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7709 if ( p.hasNext() ) {
7712 if ( p.next() != null ) {
7716 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7717 p.setSource( p6_str );
7718 if ( !p.hasNext() ) {
7721 Phylogeny p6_0 = p.next();
7722 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7725 if ( p.hasNext() ) {
7728 if ( p.next() != null ) {
7732 if ( !p.hasNext() ) {
7736 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7739 if ( p.hasNext() ) {
7742 if ( p.next() != null ) {
7746 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7747 p.setSource( p7_str );
7748 if ( !p.hasNext() ) {
7751 Phylogeny p7_0 = p.next();
7752 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7755 if ( p.hasNext() ) {
7758 if ( p.next() != null ) {
7762 if ( !p.hasNext() ) {
7766 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7769 if ( p.hasNext() ) {
7772 if ( p.next() != null ) {
7776 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7777 p.setSource( p8_str );
7778 if ( !p.hasNext() ) {
7781 Phylogeny p8_0 = p.next();
7782 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7785 if ( !p.hasNext() ) {
7788 if ( !p.hasNext() ) {
7791 Phylogeny p8_1 = p.next();
7792 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7795 if ( p.hasNext() ) {
7798 if ( p.next() != null ) {
7802 if ( !p.hasNext() ) {
7806 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7809 if ( !p.hasNext() ) {
7813 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7816 if ( p.hasNext() ) {
7819 if ( p.next() != null ) {
7825 if ( p.hasNext() ) {
7829 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7830 if ( !p.hasNext() ) {
7833 Phylogeny p_27 = p.next();
7834 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7835 System.out.println( p_27.toNewHampshireX() );
7839 if ( p.hasNext() ) {
7842 if ( p.next() != null ) {
7846 if ( !p.hasNext() ) {
7850 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7851 System.out.println( p_27.toNewHampshireX() );
7855 if ( p.hasNext() ) {
7858 if ( p.next() != null ) {
7862 final String p30_str = "(A,B);(C,D)";
7863 final NHXParser p30 = new NHXParser();
7864 p30.setSource( p30_str );
7865 if ( !p30.hasNext() ) {
7868 Phylogeny phy30 = p30.next();
7869 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
7870 System.out.println( phy30.toNewHampshire() );
7873 if ( !p30.hasNext() ) {
7876 Phylogeny phy301 = p30.next();
7877 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
7878 System.out.println( phy301.toNewHampshire() );
7881 if ( p30.hasNext() ) {
7884 if ( p30.hasNext() ) {
7887 if ( p30.next() != null ) {
7890 if ( p30.next() != null ) {
7894 if ( !p30.hasNext() ) {
7898 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
7899 System.out.println( phy30.toNewHampshire() );
7902 if ( !p30.hasNext() ) {
7905 phy301 = p30.next();
7906 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
7907 System.out.println( phy301.toNewHampshire() );
7910 if ( p30.hasNext() ) {
7913 if ( p30.hasNext() ) {
7916 if ( p30.next() != null ) {
7919 if ( p30.next() != null ) {
7923 catch ( final Exception e ) {
7924 e.printStackTrace( System.out );
7930 private static boolean testNHXconversion() {
7932 final PhylogenyNode n1 = new PhylogenyNode();
7933 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7934 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7935 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7936 final PhylogenyNode n5 = PhylogenyNode
7937 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7938 final PhylogenyNode n6 = PhylogenyNode
7939 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7940 if ( !n1.toNewHampshireX().equals( "" ) ) {
7943 if ( !n2.toNewHampshireX().equals( "" ) ) {
7946 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7949 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7952 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7955 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7956 System.out.println( n6.toNewHampshireX() );
7960 catch ( final Exception e ) {
7961 e.printStackTrace( System.out );
7967 private static boolean testNHXNodeParsing() {
7969 final PhylogenyNode n1 = new PhylogenyNode();
7970 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7971 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7972 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7973 final PhylogenyNode n5 = PhylogenyNode
7974 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:B=56:T=1:On=22:SOn=33:SNn=44:W=2:C=10.20.30:XN=S=tag1=value1=unit1:XN=S=tag3=value3=unit3]" );
7975 if ( !n3.getName().equals( "n3" ) ) {
7978 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7981 if ( n3.isDuplication() ) {
7984 if ( n3.isHasAssignedEvent() ) {
7987 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7990 if ( !n4.getName().equals( "n4" ) ) {
7993 if ( n4.getDistanceToParent() != 0.01 ) {
7996 if ( !n5.getName().equals( "n5" ) ) {
7999 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8002 if ( n5.getDistanceToParent() != 0.1 ) {
8005 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8008 if ( !n5.isDuplication() ) {
8011 if ( !n5.isHasAssignedEvent() ) {
8014 final PhylogenyNode n8 = PhylogenyNode
8015 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8016 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8017 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8020 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8023 final PhylogenyNode n9 = PhylogenyNode
8024 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8025 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8026 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8029 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8032 final PhylogenyNode n10 = PhylogenyNode
8033 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8034 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8037 final PhylogenyNode n20 = PhylogenyNode
8038 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8039 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8042 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8045 final PhylogenyNode n20x = PhylogenyNode
8046 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8047 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8050 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8053 final PhylogenyNode n20xx = PhylogenyNode
8054 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8055 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8058 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8061 final PhylogenyNode n20xxx = PhylogenyNode
8062 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8063 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8066 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8069 final PhylogenyNode n20xxxx = PhylogenyNode
8070 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8071 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8074 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8077 final PhylogenyNode n21 = PhylogenyNode
8078 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8079 if ( !n21.getName().equals( "N21_PIG" ) ) {
8082 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8085 final PhylogenyNode n21x = PhylogenyNode
8086 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8087 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8090 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8093 final PhylogenyNode n22 = PhylogenyNode
8094 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8095 if ( !n22.getName().equals( "n22/PIG" ) ) {
8098 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8101 final PhylogenyNode n23 = PhylogenyNode
8102 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8103 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8106 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8109 final PhylogenyNode a = PhylogenyNode
8110 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8111 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8114 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8117 final PhylogenyNode c1 = PhylogenyNode
8118 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8119 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8120 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8123 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8126 final PhylogenyNode c2 = PhylogenyNode
8127 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8128 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8129 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8132 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8135 final PhylogenyNode e3 = PhylogenyNode
8136 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8137 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8140 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8143 final PhylogenyNode n11 = PhylogenyNode
8144 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8145 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8146 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8149 if ( n11.getDistanceToParent() != 0.4 ) {
8152 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8155 final PhylogenyNode n12 = PhylogenyNode
8156 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8157 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8158 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8161 if ( n12.getDistanceToParent() != 0.4 ) {
8164 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8167 final PhylogenyNode o = PhylogenyNode
8168 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8169 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8172 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8175 if ( n1.getName().compareTo( "" ) != 0 ) {
8178 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8181 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8184 if ( n2.getName().compareTo( "" ) != 0 ) {
8187 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8190 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8193 final PhylogenyNode n00 = PhylogenyNode
8194 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8195 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8198 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8201 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8202 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8205 final PhylogenyNode n13 = PhylogenyNode
8206 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8207 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
8210 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8213 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8216 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8219 final PhylogenyNode n14 = PhylogenyNode
8220 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8221 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8224 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8227 final PhylogenyNode n15 = PhylogenyNode
8228 .createInstanceFromNhxString( "something_wicked[123]",
8229 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8230 if ( !n15.getName().equals( "something_wicked" ) ) {
8233 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8236 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8239 final PhylogenyNode n16 = PhylogenyNode
8240 .createInstanceFromNhxString( "something_wicked2[9]",
8241 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8242 if ( !n16.getName().equals( "something_wicked2" ) ) {
8245 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8248 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8251 final PhylogenyNode n17 = PhylogenyNode
8252 .createInstanceFromNhxString( "something_wicked3[a]",
8253 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8254 if ( !n17.getName().equals( "something_wicked3" ) ) {
8257 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8260 final PhylogenyNode n18 = PhylogenyNode
8261 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8262 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8265 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8268 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8271 final PhylogenyNode n19 = PhylogenyNode
8272 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8273 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8276 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8279 final PhylogenyNode n30 = PhylogenyNode
8280 .createInstanceFromNhxString( "blah_1234567-roejojoej",
8281 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8282 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8285 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8288 final PhylogenyNode n31 = PhylogenyNode
8289 .createInstanceFromNhxString( "blah_12345678-roejojoej",
8290 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8291 if ( n31.getNodeData().isHasTaxonomy() ) {
8294 final PhylogenyNode n32 = PhylogenyNode
8295 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8296 if ( n32.getNodeData().isHasTaxonomy() ) {
8299 final PhylogenyNode n40 = PhylogenyNode
8300 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8301 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8304 final PhylogenyNode n41 = PhylogenyNode
8305 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8306 if ( n41.getNodeData().isHasTaxonomy() ) {
8309 final PhylogenyNode n42 = PhylogenyNode
8310 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8311 if ( n42.getNodeData().isHasTaxonomy() ) {
8314 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8315 NHXParser.TAXONOMY_EXTRACTION.NO );
8316 if ( n43.getNodeData().isHasTaxonomy() ) {
8319 final PhylogenyNode n44 = PhylogenyNode
8320 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8321 if ( n44.getNodeData().isHasTaxonomy() ) {
8325 catch ( final Exception e ) {
8326 e.printStackTrace( System.out );
8332 private static boolean testNHXParsing() {
8334 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8335 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8336 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8339 final String p2_S = "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]";
8340 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8341 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8344 final String p2b_S = "(((((((A:0.2[&NHX:S=qw,erty]):0.2[&:S=u(io)p]):0.3[&NHX:S=asdf]):0.4[S=zxc]):0.5[]):0.6[&&NH:S=asd]):0.7[&&HX:S=za]):0.8[&&:S=zaq]";
8345 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8346 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8349 final Phylogeny[] p3 = factory
8350 .create( "[ comment&&NHX,())))](((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]",
8352 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8355 final Phylogeny[] p4 = factory
8356 .create( "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(]",
8358 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8361 final Phylogeny[] p5 = factory
8362 .create( "[] ( [][ ][ ] ([((( &&NHXcomment only![[[[[[]([]((((A:0.2[&&NHX:S=q[comment )))]werty][,,,,))]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=a[comment,,))]sdf])[comment(((]:0.4[&&NHX:S=zxc][comment(((][comment(((]):0.5[&&NHX:S=a]):0.6[&&NHX:S=a[comment(((]sd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(((]",
8364 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8367 final String p6_S_C = "(A[][][][1][22][333][4444][55555][666666][&&NHX:S=Aspecies],B[))],C,(AA,BB,CC,(CCC,DDD,EEE,[comment](FFFF,GGGG)x)y,D[comment]D,EE,FF,GG,HH),D,E,(EE,FF),F,G,H,(((((5)4)3)2)1),I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,(XX,(YY)),Y,Z)";
8368 final String p6_S_WO_C = "(A[&&NHX:S=Aspecies],B,C,(AA,BB,CC,(CCC,DDD,EEE,(FFFF,GGGG)x)y,DD,EE,FF,GG,HH),D,E,(EE,FF),F,G,H,(((((5)4)3)2)1),I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,(XX,(YY)),Y,Z)";
8369 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8370 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8373 final String p7_S_C = "(((A [&&NHX:S=species_a], B [&&NHX:S=Vstorri] , C , D),(A,B,C,D[comment])[],[c][]([xxx]A[comment],[comment]B[comment][comment],[comment][comment]C[comment][comment],[comment][comment]D[comment][comment])[comment][comment],[comment] [comment](A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C[comment][comment][comment][comment][comment] [comment],D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),[comment][comment]((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)))";
8374 final String p7_S_WO_C = "(((A[&&NHX:S=species_a],B[&&NHX:S=Vstorri],C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)),((A,B,C,D),(A,B,C,D),(A,B,C,D),(A,B,C,D)))";
8375 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8376 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8379 final String p8_S_C = "[cmt](((([]([))))))](((((A[&&NHX:S= [a comment] a])))))))[too many comments!:)])),(((((((((B[&&NHX[ a comment in a bad place]:S =b])))))[] [] )))),(((((((((C[&&NHX:S=c]) ))[,,, ])))))))";
8380 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8381 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8382 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8385 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8386 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8389 final Phylogeny p10 = factory
8390 .create( " [79] ( (A [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
8391 new NHXParser() )[ 0 ];
8392 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8396 catch ( final Exception e ) {
8397 e.printStackTrace( System.out );
8403 private static boolean testNHXParsingMB() {
8405 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8406 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8407 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8408 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8409 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8410 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8411 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8412 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8413 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8414 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8415 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8418 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8421 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8422 0.1100000000000000e+00 ) ) {
8425 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8428 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8431 final Phylogeny p2 = factory
8432 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8433 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8434 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8435 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8436 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8437 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8438 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8439 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8440 + "7.369400000000000e-02}])",
8441 new NHXParser() )[ 0 ];
8442 if ( p2.getNode( "1" ) == null ) {
8445 if ( p2.getNode( "2" ) == null ) {
8449 catch ( final Exception e ) {
8450 e.printStackTrace( System.out );
8457 private static boolean testNHXParsingQuotes() {
8459 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8460 final NHXParser p = new NHXParser();
8461 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8462 if ( phylogenies_0.length != 5 ) {
8465 final Phylogeny phy = phylogenies_0[ 4 ];
8466 if ( phy.getNumberOfExternalNodes() != 7 ) {
8469 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8472 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8475 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8476 .getScientificName().equals( "hsapiens" ) ) {
8479 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8482 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8485 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8488 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8491 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8494 final NHXParser p1p = new NHXParser();
8495 p1p.setIgnoreQuotes( true );
8496 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8497 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8500 final NHXParser p2p = new NHXParser();
8501 p1p.setIgnoreQuotes( false );
8502 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8503 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8506 final NHXParser p3p = new NHXParser();
8507 p3p.setIgnoreQuotes( false );
8508 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8509 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8512 final NHXParser p4p = new NHXParser();
8513 p4p.setIgnoreQuotes( false );
8514 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8515 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8518 final Phylogeny p10 = factory
8519 .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]",
8520 new NHXParser() )[ 0 ];
8521 final String p10_clean_str = "(('A B':0.2,B:0.3):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]";
8522 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8525 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8526 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8530 final Phylogeny p12 = factory
8531 .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]",
8532 new NHXParser() )[ 0 ];
8533 final String p12_clean_str = "(('A B':0.2[&&NHX:S=monkey!],'BB B':0.03):0.5[&&NHX:B=91],'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1[&&NHX:B=100]";
8534 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8537 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8538 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8541 final String p12_clean_str_nh = "(('A B':0.2,'BB B':0.03):0.5,'C (or D?\\//;,))':0.1)'root is here (cool, was! )':0.1;";
8542 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8545 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8546 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8550 catch ( final Exception e ) {
8551 e.printStackTrace( System.out );
8557 private static boolean testNodeRemoval() {
8559 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8560 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8561 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8562 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8565 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8566 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8567 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8570 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8571 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8572 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8576 catch ( final Exception e ) {
8577 e.printStackTrace( System.out );
8583 private static boolean testPhylogenyBranch() {
8585 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8586 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8587 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8588 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8589 if ( !a1b1.equals( a1b1 ) ) {
8592 if ( !a1b1.equals( b1a1 ) ) {
8595 if ( !b1a1.equals( a1b1 ) ) {
8598 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8599 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8600 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8601 if ( a1_b1.equals( b1_a1 ) ) {
8604 if ( a1_b1.equals( a1_b1_ ) ) {
8607 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8608 if ( !a1_b1.equals( b1_a1_ ) ) {
8611 if ( a1_b1_.equals( b1_a1_ ) ) {
8614 if ( !a1_b1_.equals( b1_a1 ) ) {
8618 catch ( final Exception e ) {
8619 e.printStackTrace( System.out );
8625 private static boolean testPhyloXMLparsingOfDistributionElement() {
8627 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8628 PhyloXmlParser xml_parser = null;
8630 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8632 catch ( final Exception e ) {
8633 // Do nothing -- means were not running from jar.
8635 if ( xml_parser == null ) {
8636 xml_parser = PhyloXmlParser.createPhyloXmlParser();
8637 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8638 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8641 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8644 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8646 if ( xml_parser.getErrorCount() > 0 ) {
8647 System.out.println( xml_parser.getErrorMessages().toString() );
8650 if ( phylogenies_0.length != 1 ) {
8653 final Phylogeny t1 = phylogenies_0[ 0 ];
8654 PhylogenyNode n = null;
8655 Distribution d = null;
8656 n = t1.getNode( "root node" );
8657 if ( !n.getNodeData().isHasDistribution() ) {
8660 if ( n.getNodeData().getDistributions().size() != 1 ) {
8663 d = n.getNodeData().getDistribution();
8664 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8667 if ( d.getPoints().size() != 1 ) {
8670 if ( d.getPolygons() != null ) {
8673 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8676 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8679 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8682 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8685 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8688 n = t1.getNode( "node a" );
8689 if ( !n.getNodeData().isHasDistribution() ) {
8692 if ( n.getNodeData().getDistributions().size() != 2 ) {
8695 d = n.getNodeData().getDistribution( 1 );
8696 if ( !d.getDesc().equals( "San Diego" ) ) {
8699 if ( d.getPoints().size() != 1 ) {
8702 if ( d.getPolygons() != null ) {
8705 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8708 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8711 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8714 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8717 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8720 n = t1.getNode( "node bb" );
8721 if ( !n.getNodeData().isHasDistribution() ) {
8724 if ( n.getNodeData().getDistributions().size() != 1 ) {
8727 d = n.getNodeData().getDistribution( 0 );
8728 if ( d.getPoints().size() != 3 ) {
8731 if ( d.getPolygons().size() != 2 ) {
8734 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8737 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8740 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8743 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8746 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8749 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8752 Polygon p = d.getPolygons().get( 0 );
8753 if ( p.getPoints().size() != 3 ) {
8756 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8759 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8762 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8765 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8768 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8771 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8774 p = d.getPolygons().get( 1 );
8775 if ( p.getPoints().size() != 3 ) {
8778 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8781 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8784 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8788 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8789 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8790 if ( rt.length != 1 ) {
8793 final Phylogeny t1_rt = rt[ 0 ];
8794 n = t1_rt.getNode( "root node" );
8795 if ( !n.getNodeData().isHasDistribution() ) {
8798 if ( n.getNodeData().getDistributions().size() != 1 ) {
8801 d = n.getNodeData().getDistribution();
8802 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8805 if ( d.getPoints().size() != 1 ) {
8808 if ( d.getPolygons() != null ) {
8811 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8814 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8817 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8820 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8823 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8826 n = t1_rt.getNode( "node a" );
8827 if ( !n.getNodeData().isHasDistribution() ) {
8830 if ( n.getNodeData().getDistributions().size() != 2 ) {
8833 d = n.getNodeData().getDistribution( 1 );
8834 if ( !d.getDesc().equals( "San Diego" ) ) {
8837 if ( d.getPoints().size() != 1 ) {
8840 if ( d.getPolygons() != null ) {
8843 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8846 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8849 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8852 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8855 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8858 n = t1_rt.getNode( "node bb" );
8859 if ( !n.getNodeData().isHasDistribution() ) {
8862 if ( n.getNodeData().getDistributions().size() != 1 ) {
8865 d = n.getNodeData().getDistribution( 0 );
8866 if ( d.getPoints().size() != 3 ) {
8869 if ( d.getPolygons().size() != 2 ) {
8872 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8875 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8878 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8881 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8884 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8887 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8890 p = d.getPolygons().get( 0 );
8891 if ( p.getPoints().size() != 3 ) {
8894 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8897 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8900 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8903 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8906 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8909 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8912 p = d.getPolygons().get( 1 );
8913 if ( p.getPoints().size() != 3 ) {
8916 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8919 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8922 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8926 catch ( final Exception e ) {
8927 e.printStackTrace( System.out );
8933 private static boolean testPostOrderIterator() {
8935 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8936 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8937 PhylogenyNodeIterator it0;
8938 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8941 for( it0.reset(); it0.hasNext(); ) {
8944 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8945 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8946 if ( !it.next().getName().equals( "A" ) ) {
8949 if ( !it.next().getName().equals( "B" ) ) {
8952 if ( !it.next().getName().equals( "ab" ) ) {
8955 if ( !it.next().getName().equals( "C" ) ) {
8958 if ( !it.next().getName().equals( "D" ) ) {
8961 if ( !it.next().getName().equals( "cd" ) ) {
8964 if ( !it.next().getName().equals( "abcd" ) ) {
8967 if ( !it.next().getName().equals( "E" ) ) {
8970 if ( !it.next().getName().equals( "F" ) ) {
8973 if ( !it.next().getName().equals( "ef" ) ) {
8976 if ( !it.next().getName().equals( "G" ) ) {
8979 if ( !it.next().getName().equals( "H" ) ) {
8982 if ( !it.next().getName().equals( "gh" ) ) {
8985 if ( !it.next().getName().equals( "efgh" ) ) {
8988 if ( !it.next().getName().equals( "r" ) ) {
8991 if ( it.hasNext() ) {
8995 catch ( final Exception e ) {
8996 e.printStackTrace( System.out );
9002 private static boolean testPreOrderIterator() {
9004 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9005 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9006 PhylogenyNodeIterator it0;
9007 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9010 for( it0.reset(); it0.hasNext(); ) {
9013 PhylogenyNodeIterator it = t0.iteratorPreorder();
9014 if ( !it.next().getName().equals( "r" ) ) {
9017 if ( !it.next().getName().equals( "ab" ) ) {
9020 if ( !it.next().getName().equals( "A" ) ) {
9023 if ( !it.next().getName().equals( "B" ) ) {
9026 if ( !it.next().getName().equals( "cd" ) ) {
9029 if ( !it.next().getName().equals( "C" ) ) {
9032 if ( !it.next().getName().equals( "D" ) ) {
9035 if ( it.hasNext() ) {
9038 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9039 it = t1.iteratorPreorder();
9040 if ( !it.next().getName().equals( "r" ) ) {
9043 if ( !it.next().getName().equals( "abcd" ) ) {
9046 if ( !it.next().getName().equals( "ab" ) ) {
9049 if ( !it.next().getName().equals( "A" ) ) {
9052 if ( !it.next().getName().equals( "B" ) ) {
9055 if ( !it.next().getName().equals( "cd" ) ) {
9058 if ( !it.next().getName().equals( "C" ) ) {
9061 if ( !it.next().getName().equals( "D" ) ) {
9064 if ( !it.next().getName().equals( "efgh" ) ) {
9067 if ( !it.next().getName().equals( "ef" ) ) {
9070 if ( !it.next().getName().equals( "E" ) ) {
9073 if ( !it.next().getName().equals( "F" ) ) {
9076 if ( !it.next().getName().equals( "gh" ) ) {
9079 if ( !it.next().getName().equals( "G" ) ) {
9082 if ( !it.next().getName().equals( "H" ) ) {
9085 if ( it.hasNext() ) {
9089 catch ( final Exception e ) {
9090 e.printStackTrace( System.out );
9096 private static boolean testPropertiesMap() {
9098 final PropertiesMap pm = new PropertiesMap();
9099 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9100 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9101 final Property p2 = new Property( "something:else",
9103 "improbable:research",
9106 pm.addProperty( p0 );
9107 pm.addProperty( p1 );
9108 pm.addProperty( p2 );
9109 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9112 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9115 if ( pm.getProperties().size() != 3 ) {
9118 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9121 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9124 if ( pm.getProperties().size() != 3 ) {
9127 pm.removeProperty( "dimensions:diameter" );
9128 if ( pm.getProperties().size() != 2 ) {
9131 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9134 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9138 catch ( final Exception e ) {
9139 e.printStackTrace( System.out );
9145 private static boolean testProteinId() {
9147 final ProteinId id1 = new ProteinId( "a" );
9148 final ProteinId id2 = new ProteinId( "a" );
9149 final ProteinId id3 = new ProteinId( "A" );
9150 final ProteinId id4 = new ProteinId( "b" );
9151 if ( !id1.equals( id1 ) ) {
9154 if ( id1.getId().equals( "x" ) ) {
9157 if ( id1.getId().equals( null ) ) {
9160 if ( !id1.equals( id2 ) ) {
9163 if ( id1.equals( id3 ) ) {
9166 if ( id1.hashCode() != id1.hashCode() ) {
9169 if ( id1.hashCode() != id2.hashCode() ) {
9172 if ( id1.hashCode() == id3.hashCode() ) {
9175 if ( id1.compareTo( id1 ) != 0 ) {
9178 if ( id1.compareTo( id2 ) != 0 ) {
9181 if ( id1.compareTo( id3 ) != 0 ) {
9184 if ( id1.compareTo( id4 ) >= 0 ) {
9187 if ( id4.compareTo( id1 ) <= 0 ) {
9190 if ( !id4.getId().equals( "b" ) ) {
9193 final ProteinId id5 = new ProteinId( " C " );
9194 if ( !id5.getId().equals( "C" ) ) {
9197 if ( id5.equals( id1 ) ) {
9201 catch ( final Exception e ) {
9202 e.printStackTrace( System.out );
9208 private static boolean testReIdMethods() {
9210 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9211 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9212 final long count = PhylogenyNode.getNodeCount();
9214 if ( p.getNode( "r" ).getId() != count ) {
9217 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9220 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9223 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9226 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9229 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9232 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9235 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9238 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9241 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9244 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9247 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9250 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9253 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9256 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9260 catch ( final Exception e ) {
9261 e.printStackTrace( System.out );
9267 private static boolean testRerooting() {
9269 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9270 final Phylogeny t1 = factory.create( "((A:1,B:2)AB:1[&&NHX:B=55],(C:3,D:5)CD:3[&&NHX:B=10])ABCD:0.5",
9271 new NHXParser() )[ 0 ];
9272 if ( !t1.isRooted() ) {
9275 t1.reRoot( t1.getNode( "D" ) );
9276 t1.reRoot( t1.getNode( "CD" ) );
9277 t1.reRoot( t1.getNode( "A" ) );
9278 t1.reRoot( t1.getNode( "B" ) );
9279 t1.reRoot( t1.getNode( "AB" ) );
9280 t1.reRoot( t1.getNode( "D" ) );
9281 t1.reRoot( t1.getNode( "C" ) );
9282 t1.reRoot( t1.getNode( "CD" ) );
9283 t1.reRoot( t1.getNode( "A" ) );
9284 t1.reRoot( t1.getNode( "B" ) );
9285 t1.reRoot( t1.getNode( "AB" ) );
9286 t1.reRoot( t1.getNode( "D" ) );
9287 t1.reRoot( t1.getNode( "D" ) );
9288 t1.reRoot( t1.getNode( "C" ) );
9289 t1.reRoot( t1.getNode( "A" ) );
9290 t1.reRoot( t1.getNode( "B" ) );
9291 t1.reRoot( t1.getNode( "AB" ) );
9292 t1.reRoot( t1.getNode( "C" ) );
9293 t1.reRoot( t1.getNode( "D" ) );
9294 t1.reRoot( t1.getNode( "CD" ) );
9295 t1.reRoot( t1.getNode( "D" ) );
9296 t1.reRoot( t1.getNode( "A" ) );
9297 t1.reRoot( t1.getNode( "B" ) );
9298 t1.reRoot( t1.getNode( "AB" ) );
9299 t1.reRoot( t1.getNode( "C" ) );
9300 t1.reRoot( t1.getNode( "D" ) );
9301 t1.reRoot( t1.getNode( "CD" ) );
9302 t1.reRoot( t1.getNode( "D" ) );
9303 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9306 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9309 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9312 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9315 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9318 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9321 final Phylogeny t2 = factory.create( "(((A:1,B:2)AB:10[&&NHX:B=55],C)ABC:3[&&NHX:B=33],D:5)ABCD:0.5",
9322 new NHXParser() )[ 0 ];
9323 t2.reRoot( t2.getNode( "A" ) );
9324 t2.reRoot( t2.getNode( "D" ) );
9325 t2.reRoot( t2.getNode( "ABC" ) );
9326 t2.reRoot( t2.getNode( "A" ) );
9327 t2.reRoot( t2.getNode( "B" ) );
9328 t2.reRoot( t2.getNode( "D" ) );
9329 t2.reRoot( t2.getNode( "C" ) );
9330 t2.reRoot( t2.getNode( "ABC" ) );
9331 t2.reRoot( t2.getNode( "A" ) );
9332 t2.reRoot( t2.getNode( "B" ) );
9333 t2.reRoot( t2.getNode( "AB" ) );
9334 t2.reRoot( t2.getNode( "AB" ) );
9335 t2.reRoot( t2.getNode( "D" ) );
9336 t2.reRoot( t2.getNode( "C" ) );
9337 t2.reRoot( t2.getNode( "B" ) );
9338 t2.reRoot( t2.getNode( "AB" ) );
9339 t2.reRoot( t2.getNode( "D" ) );
9340 t2.reRoot( t2.getNode( "D" ) );
9341 t2.reRoot( t2.getNode( "ABC" ) );
9342 t2.reRoot( t2.getNode( "A" ) );
9343 t2.reRoot( t2.getNode( "B" ) );
9344 t2.reRoot( t2.getNode( "AB" ) );
9345 t2.reRoot( t2.getNode( "D" ) );
9346 t2.reRoot( t2.getNode( "C" ) );
9347 t2.reRoot( t2.getNode( "ABC" ) );
9348 t2.reRoot( t2.getNode( "A" ) );
9349 t2.reRoot( t2.getNode( "B" ) );
9350 t2.reRoot( t2.getNode( "AB" ) );
9351 t2.reRoot( t2.getNode( "D" ) );
9352 t2.reRoot( t2.getNode( "D" ) );
9353 t2.reRoot( t2.getNode( "C" ) );
9354 t2.reRoot( t2.getNode( "A" ) );
9355 t2.reRoot( t2.getNode( "B" ) );
9356 t2.reRoot( t2.getNode( "AB" ) );
9357 t2.reRoot( t2.getNode( "C" ) );
9358 t2.reRoot( t2.getNode( "D" ) );
9359 t2.reRoot( t2.getNode( "ABC" ) );
9360 t2.reRoot( t2.getNode( "D" ) );
9361 t2.reRoot( t2.getNode( "A" ) );
9362 t2.reRoot( t2.getNode( "B" ) );
9363 t2.reRoot( t2.getNode( "AB" ) );
9364 t2.reRoot( t2.getNode( "C" ) );
9365 t2.reRoot( t2.getNode( "D" ) );
9366 t2.reRoot( t2.getNode( "ABC" ) );
9367 t2.reRoot( t2.getNode( "D" ) );
9368 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9371 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9374 t2.reRoot( t2.getNode( "ABC" ) );
9375 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9378 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9381 t2.reRoot( t2.getNode( "AB" ) );
9382 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9385 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9388 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9391 t2.reRoot( t2.getNode( "AB" ) );
9392 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9395 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9398 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9401 t2.reRoot( t2.getNode( "D" ) );
9402 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9405 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9408 t2.reRoot( t2.getNode( "ABC" ) );
9409 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9412 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9415 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9416 new NHXParser() )[ 0 ];
9417 t3.reRoot( t3.getNode( "B" ) );
9418 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9421 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9424 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9427 t3.reRoot( t3.getNode( "B" ) );
9428 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9431 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9434 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9437 t3.reRoot( t3.getRoot() );
9438 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9441 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9444 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9448 catch ( final Exception e ) {
9449 e.printStackTrace( System.out );
9455 private static boolean testSDIse() {
9457 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9458 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9459 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9460 gene1.setRooted( true );
9461 species1.setRooted( true );
9462 final SDI sdi = new SDI( gene1, species1 );
9463 if ( !gene1.getRoot().isDuplication() ) {
9466 final Phylogeny species2 = factory
9467 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9468 new NHXParser() )[ 0 ];
9469 final Phylogeny gene2 = factory
9470 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9471 new NHXParser() )[ 0 ];
9472 species2.setRooted( true );
9473 gene2.setRooted( true );
9474 final SDI sdi2 = new SDI( gene2, species2 );
9475 if ( sdi2.getDuplicationsSum() != 0 ) {
9478 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9481 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9484 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9487 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9490 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9493 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9496 final Phylogeny species3 = factory
9497 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9498 new NHXParser() )[ 0 ];
9499 final Phylogeny gene3 = factory
9500 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9501 new NHXParser() )[ 0 ];
9502 species3.setRooted( true );
9503 gene3.setRooted( true );
9504 final SDI sdi3 = new SDI( gene3, species3 );
9505 if ( sdi3.getDuplicationsSum() != 1 ) {
9508 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9511 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9514 final Phylogeny species4 = factory
9515 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9516 new NHXParser() )[ 0 ];
9517 final Phylogeny gene4 = factory
9518 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9519 new NHXParser() )[ 0 ];
9520 species4.setRooted( true );
9521 gene4.setRooted( true );
9522 final SDI sdi4 = new SDI( gene4, species4 );
9523 if ( sdi4.getDuplicationsSum() != 1 ) {
9526 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9529 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9532 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9535 if ( species4.getNumberOfExternalNodes() != 6 ) {
9538 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9541 final Phylogeny species5 = factory
9542 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9543 new NHXParser() )[ 0 ];
9544 final Phylogeny gene5 = factory
9545 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9546 new NHXParser() )[ 0 ];
9547 species5.setRooted( true );
9548 gene5.setRooted( true );
9549 final SDI sdi5 = new SDI( gene5, species5 );
9550 if ( sdi5.getDuplicationsSum() != 2 ) {
9553 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9556 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9559 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9562 if ( species5.getNumberOfExternalNodes() != 6 ) {
9565 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9568 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9569 // Conjecture for Comparing Molecular Phylogenies"
9570 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9571 final Phylogeny species6 = factory
9572 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9573 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9574 new NHXParser() )[ 0 ];
9575 final Phylogeny gene6 = factory
9576 .create( "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1,3:0.1[&&NHX:S=3])1-2-3:0.1,"
9577 + "((4:0.1[&&NHX:S=4],(5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.1)4-5-6:0.1,"
9578 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],9:0.1[&&NHX:S=9])8-9:0.1)7-8-9:0.1)4-5-6-7-8-9:0.1)r;",
9579 new NHXParser() )[ 0 ];
9580 species6.setRooted( true );
9581 gene6.setRooted( true );
9582 final SDI sdi6 = new SDI( gene6, species6 );
9583 if ( sdi6.getDuplicationsSum() != 3 ) {
9586 if ( !gene6.getNode( "r" ).isDuplication() ) {
9589 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9592 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9595 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9598 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9601 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9604 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9607 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9610 sdi6.computeMappingCostL();
9611 if ( sdi6.computeMappingCostL() != 17 ) {
9614 if ( species6.getNumberOfExternalNodes() != 9 ) {
9617 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9620 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9621 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9622 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9623 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9624 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9625 species7.setRooted( true );
9626 final Phylogeny gene7_1 = Test
9627 .createPhylogeny( "((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2]),b1[&&NHX:S=b1]),x[&&NHX:S=x]),m1[&&NHX:S=m1]),i1[&&NHX:S=i1]),e1[&&NHX:S=e1]),y[&&NHX:S=y]),z[&&NHX:S=z])" );
9628 gene7_1.setRooted( true );
9629 final SDI sdi7 = new SDI( gene7_1, species7 );
9630 if ( sdi7.getDuplicationsSum() != 0 ) {
9633 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9636 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9639 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9642 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9645 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9648 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9651 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9654 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9657 final Phylogeny gene7_2 = Test
9658 .createPhylogeny( "(((((((((a1[&&NHX:S=a1],a2[&&NHX:S=a2]),b1[&&NHX:S=b1]),x[&&NHX:S=x]),m1[&&NHX:S=m1]),i1[&&NHX:S=i1]),j2[&&NHX:S=j2]),e1[&&NHX:S=e1]),y[&&NHX:S=y]),z[&&NHX:S=z])" );
9659 gene7_2.setRooted( true );
9660 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9661 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9664 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9667 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9670 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9673 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9676 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9679 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9682 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9685 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9688 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9692 catch ( final Exception e ) {
9698 private static boolean testSDIunrooted() {
9700 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9701 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9702 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9703 final Iterator<PhylogenyBranch> iter = l.iterator();
9704 PhylogenyBranch br = iter.next();
9705 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9708 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9712 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9715 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9719 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9722 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9726 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9729 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9733 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9736 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9740 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9743 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9747 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9750 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9754 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9757 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9761 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9764 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9768 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9771 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9775 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9778 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9782 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9785 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9789 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9792 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9796 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9799 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9803 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9806 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9809 if ( iter.hasNext() ) {
9812 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9813 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9814 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9816 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9819 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9823 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9826 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9830 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9833 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9836 if ( iter1.hasNext() ) {
9839 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9840 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9841 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9843 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9846 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9850 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9853 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9857 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9860 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9863 if ( iter2.hasNext() ) {
9866 final Phylogeny species0 = factory
9867 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9868 new NHXParser() )[ 0 ];
9869 final Phylogeny gene1 = factory
9870 .create( "(((((A:0.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
9871 new NHXParser() )[ 0 ];
9872 species0.setRooted( true );
9873 gene1.setRooted( true );
9874 final SDIR sdi_unrooted = new SDIR();
9875 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9876 if ( sdi_unrooted.getCount() != 1 ) {
9879 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9882 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9885 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9888 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9891 final Phylogeny gene2 = factory
9892 .create( "(((((A:2.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
9893 new NHXParser() )[ 0 ];
9894 gene2.setRooted( true );
9895 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9896 if ( sdi_unrooted.getCount() != 1 ) {
9899 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9902 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9905 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9908 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9911 final Phylogeny species6 = factory
9912 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9913 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9914 new NHXParser() )[ 0 ];
9915 final Phylogeny gene6 = factory
9916 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
9917 + "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1[&&NHX:S=2],3:0.25[&&NHX:S=3])1-2-3:0.2[&&NHX:S=2],"
9918 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9919 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9920 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9921 new NHXParser() )[ 0 ];
9922 species6.setRooted( true );
9923 gene6.setRooted( true );
9924 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9925 if ( sdi_unrooted.getCount() != 1 ) {
9928 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9931 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9934 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9937 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9940 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9943 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9946 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9949 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9952 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9955 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9958 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9961 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9965 final Phylogeny species7 = factory
9966 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
9967 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9968 new NHXParser() )[ 0 ];
9969 final Phylogeny gene7 = factory
9970 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
9971 + "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1[&&NHX:S=2],3:0.25[&&NHX:S=3])1-2-3:0.2[&&NHX:S=2],"
9972 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9973 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9974 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9975 new NHXParser() )[ 0 ];
9976 species7.setRooted( true );
9977 gene7.setRooted( true );
9978 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9979 if ( sdi_unrooted.getCount() != 1 ) {
9982 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9985 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9988 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9991 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9994 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9997 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10000 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10003 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10006 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10009 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10012 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10015 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10019 final Phylogeny species8 = factory
10020 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
10021 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10022 new NHXParser() )[ 0 ];
10023 final Phylogeny gene8 = factory
10024 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
10025 + "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1[&&NHX:S=2],3:0.25[&&NHX:S=3])1-2-3:0.2[&&NHX:S=2],"
10026 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10027 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10028 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10029 new NHXParser() )[ 0 ];
10030 species8.setRooted( true );
10031 gene8.setRooted( true );
10032 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10033 if ( sdi_unrooted.getCount() != 1 ) {
10036 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10039 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10042 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10045 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10048 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10051 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10054 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10057 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10060 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10063 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10066 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10069 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10074 catch ( final Exception e ) {
10075 e.printStackTrace( System.out );
10081 private static boolean testSequenceIdParsing() {
10083 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10084 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10085 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10086 if ( id != null ) {
10087 System.out.println( "value =" + id.getValue() );
10088 System.out.println( "provider=" + id.getSource() );
10093 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10094 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10095 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10096 if ( id != null ) {
10097 System.out.println( "value =" + id.getValue() );
10098 System.out.println( "provider=" + id.getSource() );
10103 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10104 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10105 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10106 if ( id != null ) {
10107 System.out.println( "value =" + id.getValue() );
10108 System.out.println( "provider=" + id.getSource() );
10113 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10114 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10115 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10116 if ( id != null ) {
10117 System.out.println( "value =" + id.getValue() );
10118 System.out.println( "provider=" + id.getSource() );
10123 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10124 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10125 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10126 if ( id != null ) {
10127 System.out.println( "value =" + id.getValue() );
10128 System.out.println( "provider=" + id.getSource() );
10133 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10134 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10135 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10136 if ( id != null ) {
10137 System.out.println( "value =" + id.getValue() );
10138 System.out.println( "provider=" + id.getSource() );
10143 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10144 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10145 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10146 if ( id != null ) {
10147 System.out.println( "value =" + id.getValue() );
10148 System.out.println( "provider=" + id.getSource() );
10153 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10154 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10155 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10156 if ( id != null ) {
10157 System.out.println( "value =" + id.getValue() );
10158 System.out.println( "provider=" + id.getSource() );
10163 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10164 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10165 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10166 if ( id != null ) {
10167 System.out.println( "value =" + id.getValue() );
10168 System.out.println( "provider=" + id.getSource() );
10173 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10174 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10175 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10176 if ( id != null ) {
10177 System.out.println( "value =" + id.getValue() );
10178 System.out.println( "provider=" + id.getSource() );
10182 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10183 if ( id != null ) {
10184 System.out.println( "value =" + id.getValue() );
10185 System.out.println( "provider=" + id.getSource() );
10189 catch ( final Exception e ) {
10190 e.printStackTrace( System.out );
10196 private static boolean testSequenceWriter() {
10198 final String n = ForesterUtil.LINE_SEPARATOR;
10199 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10202 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10205 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10208 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10211 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10212 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10215 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10216 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10220 catch ( final Exception e ) {
10221 e.printStackTrace();
10227 private static boolean testSpecies() {
10229 final Species s1 = new BasicSpecies( "a" );
10230 final Species s2 = new BasicSpecies( "a" );
10231 final Species s3 = new BasicSpecies( "A" );
10232 final Species s4 = new BasicSpecies( "b" );
10233 if ( !s1.equals( s1 ) ) {
10236 if ( s1.getSpeciesId().equals( "x" ) ) {
10239 if ( s1.getSpeciesId().equals( null ) ) {
10242 if ( !s1.equals( s2 ) ) {
10245 if ( s1.equals( s3 ) ) {
10248 if ( s1.hashCode() != s1.hashCode() ) {
10251 if ( s1.hashCode() != s2.hashCode() ) {
10254 if ( s1.hashCode() == s3.hashCode() ) {
10257 if ( s1.compareTo( s1 ) != 0 ) {
10260 if ( s1.compareTo( s2 ) != 0 ) {
10263 if ( s1.compareTo( s3 ) != 0 ) {
10266 if ( s1.compareTo( s4 ) >= 0 ) {
10269 if ( s4.compareTo( s1 ) <= 0 ) {
10272 if ( !s4.getSpeciesId().equals( "b" ) ) {
10275 final Species s5 = new BasicSpecies( " C " );
10276 if ( !s5.getSpeciesId().equals( "C" ) ) {
10279 if ( s5.equals( s1 ) ) {
10283 catch ( final Exception e ) {
10284 e.printStackTrace( System.out );
10290 private static boolean testSplit() {
10292 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10293 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10294 //Archaeopteryx.createApplication( p0 );
10295 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10296 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10297 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10298 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10299 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10300 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10301 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10302 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10303 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10304 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10305 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
10306 // System.out.println( s0.toString() );
10308 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10311 if ( s0.match( query_nodes ) ) {
10314 query_nodes = new HashSet<PhylogenyNode>();
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10320 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10321 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10322 if ( !s0.match( query_nodes ) ) {
10326 query_nodes = new HashSet<PhylogenyNode>();
10327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10330 if ( !s0.match( query_nodes ) ) {
10334 query_nodes = new HashSet<PhylogenyNode>();
10335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10337 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10338 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10339 if ( !s0.match( query_nodes ) ) {
10343 query_nodes = new HashSet<PhylogenyNode>();
10344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10345 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10346 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10348 if ( !s0.match( query_nodes ) ) {
10352 query_nodes = new HashSet<PhylogenyNode>();
10353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10356 if ( !s0.match( query_nodes ) ) {
10360 query_nodes = new HashSet<PhylogenyNode>();
10361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10362 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10363 if ( !s0.match( query_nodes ) ) {
10367 query_nodes = new HashSet<PhylogenyNode>();
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10370 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10371 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10373 if ( !s0.match( query_nodes ) ) {
10377 query_nodes = new HashSet<PhylogenyNode>();
10378 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10381 if ( !s0.match( query_nodes ) ) {
10385 query_nodes = new HashSet<PhylogenyNode>();
10386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10387 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10389 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10390 if ( !s0.match( query_nodes ) ) {
10394 query_nodes = new HashSet<PhylogenyNode>();
10395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10397 if ( s0.match( query_nodes ) ) {
10401 query_nodes = new HashSet<PhylogenyNode>();
10402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10405 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10406 if ( s0.match( query_nodes ) ) {
10410 query_nodes = new HashSet<PhylogenyNode>();
10411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10415 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10416 if ( s0.match( query_nodes ) ) {
10420 query_nodes = new HashSet<PhylogenyNode>();
10421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10423 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10424 if ( s0.match( query_nodes ) ) {
10428 query_nodes = new HashSet<PhylogenyNode>();
10429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10430 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10431 if ( s0.match( query_nodes ) ) {
10435 query_nodes = new HashSet<PhylogenyNode>();
10436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10438 if ( s0.match( query_nodes ) ) {
10442 query_nodes = new HashSet<PhylogenyNode>();
10443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10445 if ( s0.match( query_nodes ) ) {
10449 query_nodes = new HashSet<PhylogenyNode>();
10450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10452 if ( s0.match( query_nodes ) ) {
10456 query_nodes = new HashSet<PhylogenyNode>();
10457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10458 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10459 if ( s0.match( query_nodes ) ) {
10463 query_nodes = new HashSet<PhylogenyNode>();
10464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10466 if ( s0.match( query_nodes ) ) {
10470 query_nodes = new HashSet<PhylogenyNode>();
10471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10474 if ( s0.match( query_nodes ) ) {
10478 query_nodes = new HashSet<PhylogenyNode>();
10479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10482 if ( s0.match( query_nodes ) ) {
10486 query_nodes = new HashSet<PhylogenyNode>();
10487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10490 if ( s0.match( query_nodes ) ) {
10494 query_nodes = new HashSet<PhylogenyNode>();
10495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10499 if ( s0.match( query_nodes ) ) {
10503 // query_nodes = new HashSet<PhylogenyNode>();
10504 // query_nodes.add( new PhylogenyNode( "X" ) );
10505 // query_nodes.add( new PhylogenyNode( "Y" ) );
10506 // query_nodes.add( new PhylogenyNode( "A" ) );
10507 // query_nodes.add( new PhylogenyNode( "B" ) );
10508 // query_nodes.add( new PhylogenyNode( "C" ) );
10509 // query_nodes.add( new PhylogenyNode( "D" ) );
10510 // query_nodes.add( new PhylogenyNode( "E" ) );
10511 // query_nodes.add( new PhylogenyNode( "F" ) );
10512 // query_nodes.add( new PhylogenyNode( "G" ) );
10513 // if ( !s0.match( query_nodes ) ) {
10516 // query_nodes = new HashSet<PhylogenyNode>();
10517 // query_nodes.add( new PhylogenyNode( "X" ) );
10518 // query_nodes.add( new PhylogenyNode( "Y" ) );
10519 // query_nodes.add( new PhylogenyNode( "A" ) );
10520 // query_nodes.add( new PhylogenyNode( "B" ) );
10521 // query_nodes.add( new PhylogenyNode( "C" ) );
10522 // if ( !s0.match( query_nodes ) ) {
10526 // query_nodes = new HashSet<PhylogenyNode>();
10527 // query_nodes.add( new PhylogenyNode( "X" ) );
10528 // query_nodes.add( new PhylogenyNode( "Y" ) );
10529 // query_nodes.add( new PhylogenyNode( "D" ) );
10530 // query_nodes.add( new PhylogenyNode( "E" ) );
10531 // query_nodes.add( new PhylogenyNode( "F" ) );
10532 // query_nodes.add( new PhylogenyNode( "G" ) );
10533 // if ( !s0.match( query_nodes ) ) {
10537 // query_nodes = new HashSet<PhylogenyNode>();
10538 // query_nodes.add( new PhylogenyNode( "X" ) );
10539 // query_nodes.add( new PhylogenyNode( "Y" ) );
10540 // query_nodes.add( new PhylogenyNode( "A" ) );
10541 // query_nodes.add( new PhylogenyNode( "B" ) );
10542 // query_nodes.add( new PhylogenyNode( "C" ) );
10543 // query_nodes.add( new PhylogenyNode( "D" ) );
10544 // if ( !s0.match( query_nodes ) ) {
10548 // query_nodes = new HashSet<PhylogenyNode>();
10549 // query_nodes.add( new PhylogenyNode( "X" ) );
10550 // query_nodes.add( new PhylogenyNode( "Y" ) );
10551 // query_nodes.add( new PhylogenyNode( "E" ) );
10552 // query_nodes.add( new PhylogenyNode( "F" ) );
10553 // query_nodes.add( new PhylogenyNode( "G" ) );
10554 // if ( !s0.match( query_nodes ) ) {
10558 // query_nodes = new HashSet<PhylogenyNode>();
10559 // query_nodes.add( new PhylogenyNode( "X" ) );
10560 // query_nodes.add( new PhylogenyNode( "Y" ) );
10561 // query_nodes.add( new PhylogenyNode( "F" ) );
10562 // query_nodes.add( new PhylogenyNode( "G" ) );
10563 // if ( !s0.match( query_nodes ) ) {
10567 query_nodes = new HashSet<PhylogenyNode>();
10568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10572 if ( s0.match( query_nodes ) ) {
10576 query_nodes = new HashSet<PhylogenyNode>();
10577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10581 if ( s0.match( query_nodes ) ) {
10584 ///////////////////////////
10586 query_nodes = new HashSet<PhylogenyNode>();
10587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10590 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10591 if ( s0.match( query_nodes ) ) {
10595 query_nodes = new HashSet<PhylogenyNode>();
10596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10598 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10599 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10600 if ( s0.match( query_nodes ) ) {
10604 query_nodes = new HashSet<PhylogenyNode>();
10605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10606 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10607 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10608 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10609 if ( s0.match( query_nodes ) ) {
10613 query_nodes = new HashSet<PhylogenyNode>();
10614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10618 if ( s0.match( query_nodes ) ) {
10622 query_nodes = new HashSet<PhylogenyNode>();
10623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10626 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10627 if ( s0.match( query_nodes ) ) {
10631 query_nodes = new HashSet<PhylogenyNode>();
10632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10635 if ( s0.match( query_nodes ) ) {
10639 query_nodes = new HashSet<PhylogenyNode>();
10640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10644 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10645 if ( s0.match( query_nodes ) ) {
10649 query_nodes = new HashSet<PhylogenyNode>();
10650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10655 if ( s0.match( query_nodes ) ) {
10659 query_nodes = new HashSet<PhylogenyNode>();
10660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10665 if ( s0.match( query_nodes ) ) {
10669 query_nodes = new HashSet<PhylogenyNode>();
10670 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10676 if ( s0.match( query_nodes ) ) {
10680 catch ( final Exception e ) {
10681 e.printStackTrace();
10687 private static boolean testSplitStrict() {
10689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10690 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10691 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10692 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10693 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10694 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10695 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10696 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10697 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10698 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10699 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10700 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10703 if ( s0.match( query_nodes ) ) {
10706 query_nodes = new HashSet<PhylogenyNode>();
10707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10714 if ( !s0.match( query_nodes ) ) {
10718 query_nodes = new HashSet<PhylogenyNode>();
10719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10722 if ( !s0.match( query_nodes ) ) {
10726 query_nodes = new HashSet<PhylogenyNode>();
10727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10731 if ( !s0.match( query_nodes ) ) {
10735 query_nodes = new HashSet<PhylogenyNode>();
10736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10740 if ( !s0.match( query_nodes ) ) {
10744 query_nodes = new HashSet<PhylogenyNode>();
10745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10748 if ( !s0.match( query_nodes ) ) {
10752 query_nodes = new HashSet<PhylogenyNode>();
10753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10755 if ( !s0.match( query_nodes ) ) {
10759 query_nodes = new HashSet<PhylogenyNode>();
10760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10761 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10762 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10763 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10765 if ( !s0.match( query_nodes ) ) {
10769 query_nodes = new HashSet<PhylogenyNode>();
10770 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10773 if ( !s0.match( query_nodes ) ) {
10777 query_nodes = new HashSet<PhylogenyNode>();
10778 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10779 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10782 if ( !s0.match( query_nodes ) ) {
10786 query_nodes = new HashSet<PhylogenyNode>();
10787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10789 if ( s0.match( query_nodes ) ) {
10793 query_nodes = new HashSet<PhylogenyNode>();
10794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10798 if ( s0.match( query_nodes ) ) {
10802 query_nodes = new HashSet<PhylogenyNode>();
10803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10808 if ( s0.match( query_nodes ) ) {
10812 query_nodes = new HashSet<PhylogenyNode>();
10813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10816 if ( s0.match( query_nodes ) ) {
10820 query_nodes = new HashSet<PhylogenyNode>();
10821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10823 if ( s0.match( query_nodes ) ) {
10827 query_nodes = new HashSet<PhylogenyNode>();
10828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10830 if ( s0.match( query_nodes ) ) {
10834 query_nodes = new HashSet<PhylogenyNode>();
10835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10836 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10837 if ( s0.match( query_nodes ) ) {
10841 query_nodes = new HashSet<PhylogenyNode>();
10842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10844 if ( s0.match( query_nodes ) ) {
10848 query_nodes = new HashSet<PhylogenyNode>();
10849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10851 if ( s0.match( query_nodes ) ) {
10855 query_nodes = new HashSet<PhylogenyNode>();
10856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10858 if ( s0.match( query_nodes ) ) {
10862 query_nodes = new HashSet<PhylogenyNode>();
10863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10866 if ( s0.match( query_nodes ) ) {
10870 query_nodes = new HashSet<PhylogenyNode>();
10871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10874 if ( s0.match( query_nodes ) ) {
10878 query_nodes = new HashSet<PhylogenyNode>();
10879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10882 if ( s0.match( query_nodes ) ) {
10886 query_nodes = new HashSet<PhylogenyNode>();
10887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10891 if ( s0.match( query_nodes ) ) {
10895 catch ( final Exception e ) {
10896 e.printStackTrace();
10902 private static boolean testSubtreeDeletion() {
10904 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10905 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10906 t1.deleteSubtree( t1.getNode( "A" ), false );
10907 if ( t1.getNumberOfExternalNodes() != 5 ) {
10910 t1.toNewHampshireX();
10911 t1.deleteSubtree( t1.getNode( "E" ), false );
10912 if ( t1.getNumberOfExternalNodes() != 4 ) {
10915 t1.toNewHampshireX();
10916 t1.deleteSubtree( t1.getNode( "F" ), false );
10917 if ( t1.getNumberOfExternalNodes() != 3 ) {
10920 t1.toNewHampshireX();
10921 t1.deleteSubtree( t1.getNode( "D" ), false );
10922 t1.toNewHampshireX();
10923 if ( t1.getNumberOfExternalNodes() != 3 ) {
10926 t1.deleteSubtree( t1.getNode( "def" ), false );
10927 t1.toNewHampshireX();
10928 if ( t1.getNumberOfExternalNodes() != 2 ) {
10931 t1.deleteSubtree( t1.getNode( "B" ), false );
10932 t1.toNewHampshireX();
10933 if ( t1.getNumberOfExternalNodes() != 1 ) {
10936 t1.deleteSubtree( t1.getNode( "C" ), false );
10937 t1.toNewHampshireX();
10938 if ( t1.getNumberOfExternalNodes() != 1 ) {
10941 t1.deleteSubtree( t1.getNode( "abc" ), false );
10942 t1.toNewHampshireX();
10943 if ( t1.getNumberOfExternalNodes() != 1 ) {
10946 t1.deleteSubtree( t1.getNode( "r" ), false );
10947 if ( t1.getNumberOfExternalNodes() != 0 ) {
10950 if ( !t1.isEmpty() ) {
10953 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10954 t2.deleteSubtree( t2.getNode( "A" ), false );
10955 t2.toNewHampshireX();
10956 if ( t2.getNumberOfExternalNodes() != 5 ) {
10959 t2.deleteSubtree( t2.getNode( "abc" ), false );
10960 t2.toNewHampshireX();
10961 if ( t2.getNumberOfExternalNodes() != 3 ) {
10964 t2.deleteSubtree( t2.getNode( "def" ), false );
10965 t2.toNewHampshireX();
10966 if ( t2.getNumberOfExternalNodes() != 1 ) {
10970 catch ( final Exception e ) {
10971 e.printStackTrace( System.out );
10977 private static boolean testSupportCount() {
10979 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10980 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10981 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10982 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10983 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10984 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10985 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10987 SupportCount.count( t0_1, phylogenies_1, true, false );
10988 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10989 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10990 + "(((((A,B),C),D),E),((F,G),X))"
10991 + "(((((A,Y),B),C),D),((F,G),E))"
10992 + "(((((A,B),C),D),E),(F,G))"
10993 + "(((((A,B),C),D),E),(F,G))"
10994 + "(((((A,B),C),D),E),(F,G))"
10995 + "(((((A,B),C),D),E),(F,G),Z)"
10996 + "(((((A,B),C),D),E),(F,G))"
10997 + "((((((A,B),C),D),E),F),G)"
10998 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11000 SupportCount.count( t0_2, phylogenies_2, true, false );
11001 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11002 while ( it.hasNext() ) {
11003 final PhylogenyNode n = it.next();
11004 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11008 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11009 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11010 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11011 SupportCount.count( t0_3, phylogenies_3, true, false );
11012 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11013 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11016 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11019 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11022 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11025 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11028 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11031 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11034 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11037 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11040 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11043 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11044 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11045 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11046 SupportCount.count( t0_4, phylogenies_4, true, false );
11047 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11048 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11051 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11054 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11057 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11060 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11063 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11066 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11069 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11072 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11075 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11078 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11079 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11080 double d = SupportCount.compare( b1, a, true, true, true );
11081 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11084 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11085 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11086 d = SupportCount.compare( b2, a, true, true, true );
11087 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11090 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11091 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11092 d = SupportCount.compare( b3, a, true, true, true );
11093 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11096 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11097 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11098 d = SupportCount.compare( b4, a, true, true, false );
11099 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11103 catch ( final Exception e ) {
11104 e.printStackTrace( System.out );
11110 private static boolean testSupportTransfer() {
11112 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11113 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)",
11114 new NHXParser() )[ 0 ];
11115 final Phylogeny p2 = factory
11116 .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 ];
11117 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11120 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11123 support_transfer.moveBranchLengthsToBootstrap( p1 );
11124 support_transfer.transferSupportValues( p1, p2 );
11125 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11128 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11131 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11134 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11137 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11140 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11143 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11146 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11150 catch ( final Exception e ) {
11151 e.printStackTrace( System.out );
11157 private static boolean testTaxonomyExtraction() {
11159 final PhylogenyNode n0 = PhylogenyNode
11160 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11161 if ( n0.getNodeData().isHasTaxonomy() ) {
11164 final PhylogenyNode n1 = PhylogenyNode
11165 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11166 if ( n1.getNodeData().isHasTaxonomy() ) {
11167 System.out.println( n1.toString() );
11170 final PhylogenyNode n2x = PhylogenyNode
11171 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11172 if ( n2x.getNodeData().isHasTaxonomy() ) {
11175 final PhylogenyNode n3 = PhylogenyNode
11176 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11177 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11178 System.out.println( n3.toString() );
11181 final PhylogenyNode n4 = PhylogenyNode
11182 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11183 if ( n4.getNodeData().isHasTaxonomy() ) {
11184 System.out.println( n4.toString() );
11187 final PhylogenyNode n5 = PhylogenyNode
11188 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11189 if ( n5.getNodeData().isHasTaxonomy() ) {
11190 System.out.println( n5.toString() );
11193 final PhylogenyNode n6 = PhylogenyNode
11194 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11195 if ( n6.getNodeData().isHasTaxonomy() ) {
11196 System.out.println( n6.toString() );
11199 final PhylogenyNode n7 = PhylogenyNode
11200 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11201 if ( n7.getNodeData().isHasTaxonomy() ) {
11202 System.out.println( n7.toString() );
11205 final PhylogenyNode n8 = PhylogenyNode
11206 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11207 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11208 System.out.println( n8.toString() );
11211 final PhylogenyNode n9 = PhylogenyNode
11212 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11213 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11214 System.out.println( n9.toString() );
11217 final PhylogenyNode n10x = PhylogenyNode
11218 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11219 if ( n10x.getNodeData().isHasTaxonomy() ) {
11220 System.out.println( n10x.toString() );
11223 final PhylogenyNode n10xx = PhylogenyNode
11224 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11225 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11226 System.out.println( n10xx.toString() );
11229 final PhylogenyNode n10 = PhylogenyNode
11230 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11231 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11232 System.out.println( n10.toString() );
11235 final PhylogenyNode n11 = PhylogenyNode
11236 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11237 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11238 System.out.println( n11.toString() );
11241 final PhylogenyNode n12 = PhylogenyNode
11242 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11243 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11244 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11245 System.out.println( n12.toString() );
11248 final PhylogenyNode n13 = PhylogenyNode
11249 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11250 if ( n13.getNodeData().isHasTaxonomy() ) {
11251 System.out.println( n13.toString() );
11255 catch ( final Exception e ) {
11256 e.printStackTrace( System.out );
11262 private static boolean testTreeMethods() {
11264 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11265 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
11266 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
11267 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
11268 System.out.println( t0.toNewHampshireX() );
11271 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
11272 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
11273 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
11276 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
11279 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
11283 catch ( final Exception e ) {
11284 e.printStackTrace( System.out );
11290 private static boolean testSequenceDbWsTools1() {
11292 final PhylogenyNode n = new PhylogenyNode();
11293 n.setName( "NP_001025424" );
11294 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11295 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11296 || !acc.getValue().equals( "NP_001025424" ) ) {
11299 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11300 acc = SequenceDbWsTools.obtainSeqAccession( n );
11301 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11302 || !acc.getValue().equals( "NP_001025424" ) ) {
11305 n.setName( "NP_001025424.1" );
11306 acc = SequenceDbWsTools.obtainSeqAccession( n );
11307 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11308 || !acc.getValue().equals( "NP_001025424" ) ) {
11311 n.setName( "NM_001030253" );
11312 acc = SequenceDbWsTools.obtainSeqAccession( n );
11313 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11314 || !acc.getValue().equals( "NM_001030253" ) ) {
11317 n.setName( "BCL2_HUMAN" );
11318 acc = SequenceDbWsTools.obtainSeqAccession( n );
11319 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11320 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11321 System.out.println( acc.toString() );
11324 n.setName( "P10415" );
11325 acc = SequenceDbWsTools.obtainSeqAccession( n );
11326 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11327 || !acc.getValue().equals( "P10415" ) ) {
11328 System.out.println( acc.toString() );
11331 n.setName( " P10415 " );
11332 acc = SequenceDbWsTools.obtainSeqAccession( n );
11333 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11334 || !acc.getValue().equals( "P10415" ) ) {
11335 System.out.println( acc.toString() );
11338 n.setName( "_P10415|" );
11339 acc = SequenceDbWsTools.obtainSeqAccession( n );
11340 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11341 || !acc.getValue().equals( "P10415" ) ) {
11342 System.out.println( acc.toString() );
11345 n.setName( "AY695820" );
11346 acc = SequenceDbWsTools.obtainSeqAccession( n );
11347 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11348 || !acc.getValue().equals( "AY695820" ) ) {
11349 System.out.println( acc.toString() );
11352 n.setName( "_AY695820_" );
11353 acc = SequenceDbWsTools.obtainSeqAccession( n );
11354 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11355 || !acc.getValue().equals( "AY695820" ) ) {
11356 System.out.println( acc.toString() );
11359 n.setName( "AAA59452" );
11360 acc = SequenceDbWsTools.obtainSeqAccession( n );
11361 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11362 || !acc.getValue().equals( "AAA59452" ) ) {
11363 System.out.println( acc.toString() );
11366 n.setName( "_AAA59452_" );
11367 acc = SequenceDbWsTools.obtainSeqAccession( n );
11368 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11369 || !acc.getValue().equals( "AAA59452" ) ) {
11370 System.out.println( acc.toString() );
11373 n.setName( "AAA59452.1" );
11374 acc = SequenceDbWsTools.obtainSeqAccession( n );
11375 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11376 || !acc.getValue().equals( "AAA59452.1" ) ) {
11377 System.out.println( acc.toString() );
11380 n.setName( "_AAA59452.1_" );
11381 acc = SequenceDbWsTools.obtainSeqAccession( n );
11382 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11383 || !acc.getValue().equals( "AAA59452.1" ) ) {
11384 System.out.println( acc.toString() );
11387 n.setName( "GI:94894583" );
11388 acc = SequenceDbWsTools.obtainSeqAccession( n );
11389 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11390 || !acc.getValue().equals( "94894583" ) ) {
11391 System.out.println( acc.toString() );
11394 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11395 acc = SequenceDbWsTools.obtainSeqAccession( n );
11396 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11397 || !acc.getValue().equals( "71845847" ) ) {
11398 System.out.println( acc.toString() );
11401 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11402 acc = SequenceDbWsTools.obtainSeqAccession( n );
11403 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11404 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11405 System.out.println( acc.toString() );
11409 catch ( final Exception e ) {
11415 private static boolean testSequenceDbWsTools2() {
11417 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11418 SequenceDbWsTools.obtainSeqInformation( n1 );
11419 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11422 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11425 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11428 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11431 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11432 SequenceDbWsTools.obtainSeqInformation( n2 );
11433 if ( !n2.getNodeData().getSequence().getName()
11434 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11437 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11440 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11443 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11446 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11447 SequenceDbWsTools.obtainSeqInformation( n3 );
11448 if ( !n3.getNodeData().getSequence().getName()
11449 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11452 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11455 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11458 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11462 catch ( final IOException e ) {
11463 System.out.println();
11464 System.out.println( "the following might be due to absence internet connection:" );
11465 e.printStackTrace( System.out );
11468 catch ( final Exception e ) {
11469 e.printStackTrace();
11475 private static boolean testEbiEntryRetrieval() {
11477 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
11478 if ( !entry.getAccession().equals( "AAK41263" ) ) {
11479 System.out.println( entry.getAccession() );
11482 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
11483 System.out.println( entry.getTaxonomyScientificName() );
11486 if ( !entry.getSequenceName()
11487 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
11488 System.out.println( entry.getSequenceName() );
11491 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
11492 // System.out.println( entry.getSequenceSymbol() );
11495 if ( !entry.getGeneName().equals( "treX-like" ) ) {
11496 System.out.println( entry.getGeneName() );
11499 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
11500 System.out.println( entry.getTaxonomyIdentifier() );
11503 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
11504 System.out.println( entry.getAnnotations().first().getRefValue() );
11507 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
11508 System.out.println( entry.getAnnotations().first().getRefSource() );
11511 if ( entry.getCrossReferences().size() != 5 ) {
11515 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
11516 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
11519 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
11520 System.out.println( entry1.getTaxonomyScientificName() );
11523 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
11524 System.out.println( entry1.getSequenceName() );
11527 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
11528 System.out.println( entry1.getTaxonomyIdentifier() );
11531 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
11532 System.out.println( entry1.getGeneName() );
11535 if ( entry1.getCrossReferences().size() != 6 ) {
11539 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
11540 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
11543 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11544 System.out.println( entry2.getTaxonomyScientificName() );
11547 if ( !entry2.getSequenceName()
11548 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11549 System.out.println( entry2.getSequenceName() );
11552 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
11553 System.out.println( entry2.getTaxonomyIdentifier() );
11556 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
11557 System.out.println( entry2.getGeneName() );
11560 if ( entry2.getCrossReferences().size() != 3 ) {
11564 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
11565 if ( !entry3.getAccession().equals( "HM043801" ) ) {
11568 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
11569 System.out.println( entry3.getTaxonomyScientificName() );
11572 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
11573 System.out.println( entry3.getSequenceName() );
11576 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
11577 System.out.println( entry3.getTaxonomyIdentifier() );
11580 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
11581 System.out.println( entry3.getSequenceSymbol() );
11584 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
11587 if ( entry3.getCrossReferences().size() != 8 ) {
11592 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
11593 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
11596 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11597 System.out.println( entry4.getTaxonomyScientificName() );
11600 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
11601 System.out.println( entry4.getSequenceName() );
11604 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
11605 System.out.println( entry4.getTaxonomyIdentifier() );
11608 if ( !entry4.getGeneName().equals( "ras" ) ) {
11609 System.out.println( entry4.getGeneName() );
11612 // if ( !entry4.getChromosome().equals( "ras" ) ) {
11613 // System.out.println( entry4.getChromosome() );
11616 // if ( !entry4.getMap().equals( "ras" ) ) {
11617 // System.out.println( entry4.getMap() );
11623 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
11624 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
11627 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
11628 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
11631 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
11632 System.out.println( entry5.getTaxonomyScientificName() );
11635 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
11636 System.out.println( entry5.getSequenceName() );
11639 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
11640 System.out.println( entry5.getTaxonomyIdentifier() );
11644 catch ( final IOException e ) {
11645 System.out.println();
11646 System.out.println( "the following might be due to absence internet connection:" );
11647 e.printStackTrace( System.out );
11650 catch ( final Exception e ) {
11651 e.printStackTrace();
11657 private static boolean testUniprotEntryRetrieval() {
11659 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11660 if ( !entry.getAccession().equals( "P12345" ) ) {
11663 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11666 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11669 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11672 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11675 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11679 catch ( final IOException e ) {
11680 System.out.println();
11681 System.out.println( "the following might be due to absence internet connection:" );
11682 e.printStackTrace( System.out );
11685 catch ( final Exception e ) {
11691 private static boolean testUniprotTaxonomySearch() {
11693 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11695 if ( results.size() != 1 ) {
11698 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11701 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11704 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11707 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11710 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11714 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11715 if ( results.size() != 1 ) {
11718 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11721 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11724 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11727 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11730 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11734 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11735 if ( results.size() != 1 ) {
11738 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11741 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11744 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11747 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11750 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11754 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11755 if ( results.size() != 1 ) {
11758 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11761 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11764 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11767 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11770 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11773 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11776 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11779 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11780 .equals( "Nematostella vectensis" ) ) {
11781 System.out.println( results.get( 0 ).getLineage() );
11786 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11787 if ( results.size() != 1 ) {
11790 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11793 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11796 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11799 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11802 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11805 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11806 .equals( "Xenopus tropicalis" ) ) {
11807 System.out.println( results.get( 0 ).getLineage() );
11812 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11813 if ( results.size() != 1 ) {
11816 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11819 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11822 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11825 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11828 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11831 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11832 .equals( "Xenopus tropicalis" ) ) {
11833 System.out.println( results.get( 0 ).getLineage() );
11838 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11839 if ( results.size() != 1 ) {
11842 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11845 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11848 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11851 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11854 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11857 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11858 .equals( "Xenopus tropicalis" ) ) {
11859 System.out.println( results.get( 0 ).getLineage() );
11863 catch ( final IOException e ) {
11864 System.out.println();
11865 System.out.println( "the following might be due to absence internet connection:" );
11866 e.printStackTrace( System.out );
11869 catch ( final Exception e ) {
11875 private static boolean testWabiTxSearch() {
11877 String result = "";
11878 result = TxSearch.searchSimple( "nematostella" );
11879 result = TxSearch.getTxId( "nematostella" );
11880 if ( !result.equals( "45350" ) ) {
11883 result = TxSearch.getTxName( "45350" );
11884 if ( !result.equals( "Nematostella" ) ) {
11887 result = TxSearch.getTxId( "nematostella vectensis" );
11888 if ( !result.equals( "45351" ) ) {
11891 result = TxSearch.getTxName( "45351" );
11892 if ( !result.equals( "Nematostella vectensis" ) ) {
11895 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11896 if ( !result.equals( "536089" ) ) {
11899 result = TxSearch.getTxName( "536089" );
11900 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11903 final List<String> queries = new ArrayList<String>();
11904 queries.add( "Campylobacter coli" );
11905 queries.add( "Escherichia coli" );
11906 queries.add( "Arabidopsis" );
11907 queries.add( "Trichoplax" );
11908 queries.add( "Samanea saman" );
11909 queries.add( "Kluyveromyces marxianus" );
11910 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11911 queries.add( "Bornavirus parrot/PDD/2008" );
11912 final List<RANKS> ranks = new ArrayList<RANKS>();
11913 ranks.add( RANKS.SUPERKINGDOM );
11914 ranks.add( RANKS.KINGDOM );
11915 ranks.add( RANKS.FAMILY );
11916 ranks.add( RANKS.GENUS );
11917 ranks.add( RANKS.TRIBE );
11918 result = TxSearch.searchLineage( queries, ranks );
11919 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11920 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11922 catch ( final Exception e ) {
11923 System.out.println();
11924 System.out.println( "the following might be due to absence internet connection:" );
11925 e.printStackTrace( System.out );