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;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.development.DevelopmentTools;
44 import org.forester.evoinference.TestPhylogenyReconstruction;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
47 import org.forester.go.TestGo;
48 import org.forester.io.parsers.FastaParser;
49 import org.forester.io.parsers.GeneralMsaParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
52 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
53 import org.forester.io.parsers.nexus.NexusCharactersParser;
54 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
55 import org.forester.io.parsers.nhx.NHXParser;
56 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
57 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
58 import org.forester.io.parsers.tol.TolParser;
59 import org.forester.io.parsers.util.ParserUtils;
60 import org.forester.io.writers.PhylogenyWriter;
61 import org.forester.io.writers.SequenceWriter;
62 import org.forester.msa.BasicMsa;
63 import org.forester.msa.Mafft;
64 import org.forester.msa.Msa;
65 import org.forester.msa.MsaInferrer;
66 import org.forester.msa.MsaMethods;
67 import org.forester.pccx.TestPccx;
68 import org.forester.phylogeny.Phylogeny;
69 import org.forester.phylogeny.PhylogenyBranch;
70 import org.forester.phylogeny.PhylogenyMethods;
71 import org.forester.phylogeny.PhylogenyNode;
72 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
73 import org.forester.phylogeny.data.Accession;
74 import org.forester.phylogeny.data.Accession.Source;
75 import org.forester.phylogeny.data.BinaryCharacters;
76 import org.forester.phylogeny.data.BranchWidth;
77 import org.forester.phylogeny.data.Confidence;
78 import org.forester.phylogeny.data.Distribution;
79 import org.forester.phylogeny.data.DomainArchitecture;
80 import org.forester.phylogeny.data.Event;
81 import org.forester.phylogeny.data.Identifier;
82 import org.forester.phylogeny.data.PhylogenyData;
83 import org.forester.phylogeny.data.PhylogenyDataUtil;
84 import org.forester.phylogeny.data.Polygon;
85 import org.forester.phylogeny.data.PropertiesMap;
86 import org.forester.phylogeny.data.Property;
87 import org.forester.phylogeny.data.Property.AppliesTo;
88 import org.forester.phylogeny.data.ProteinDomain;
89 import org.forester.phylogeny.data.Taxonomy;
90 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
91 import org.forester.phylogeny.factories.PhylogenyFactory;
92 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
93 import org.forester.protein.BasicDomain;
94 import org.forester.protein.BasicProtein;
95 import org.forester.protein.Domain;
96 import org.forester.protein.Protein;
97 import org.forester.protein.ProteinId;
98 import org.forester.rio.TestRIO;
99 import org.forester.sdi.SDI;
100 import org.forester.sdi.SDIR;
101 import org.forester.sdi.TestGSDI;
102 import org.forester.sequence.BasicSequence;
103 import org.forester.sequence.Sequence;
104 import org.forester.species.BasicSpecies;
105 import org.forester.species.Species;
106 import org.forester.surfacing.TestSurfacing;
107 import org.forester.tools.ConfidenceAssessor;
108 import org.forester.tools.SupportCount;
109 import org.forester.tools.TreeSplitMatrix;
110 import org.forester.util.AsciiHistogram;
111 import org.forester.util.BasicDescriptiveStatistics;
112 import org.forester.util.BasicTable;
113 import org.forester.util.BasicTableParser;
114 import org.forester.util.DescriptiveStatistics;
115 import org.forester.util.ForesterConstants;
116 import org.forester.util.ForesterUtil;
117 import org.forester.util.GeneralTable;
118 import org.forester.util.SequenceAccessionTools;
119 import org.forester.ws.seqdb.SequenceDatabaseEntry;
120 import org.forester.ws.seqdb.SequenceDbWsTools;
121 import org.forester.ws.seqdb.UniProtTaxonomy;
122 import org.forester.ws.wabi.TxSearch;
123 import org.forester.ws.wabi.TxSearch.RANKS;
124 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
125 import org.forester.ws.wabi.TxSearch.TAX_RANK;
127 @SuppressWarnings( "unused")
128 public final class Test {
130 private final static boolean PERFORM_DB_TESTS = false;
131 private final static double ZERO_DIFF = 1.0E-9;
132 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "test_data"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
139 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
142 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
143 + ForesterConstants.PHYLO_XML_VERSION + "/"
144 + ForesterConstants.PHYLO_XML_XSD;
146 public static boolean testOverlapRemoval() {
148 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
149 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
150 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
151 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
152 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
153 final List<Boolean> covered = new ArrayList<Boolean>();
154 covered.add( true ); // 0
155 covered.add( false ); // 1
156 covered.add( true ); // 2
157 covered.add( false ); // 3
158 covered.add( true ); // 4
159 covered.add( true ); // 5
160 covered.add( false ); // 6
161 covered.add( true ); // 7
162 covered.add( true ); // 8
163 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
166 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
169 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
172 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
175 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
178 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
179 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
180 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
181 ab.addProteinDomain( a );
182 ab.addProteinDomain( b );
183 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
184 if ( ab.getNumberOfProteinDomains() != 2 ) {
187 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
190 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
193 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
194 if ( ab.getNumberOfProteinDomains() != 2 ) {
197 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
200 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
201 final Domain d = new BasicDomain( "d",
208 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
209 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
210 cde.addProteinDomain( c );
211 cde.addProteinDomain( d );
212 cde.addProteinDomain( e );
213 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
214 if ( cde.getNumberOfProteinDomains() != 3 ) {
217 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
220 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
221 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
222 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
223 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
224 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
225 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
226 fghi.addProteinDomain( f );
227 fghi.addProteinDomain( g );
228 fghi.addProteinDomain( h );
229 fghi.addProteinDomain( i );
230 fghi.addProteinDomain( i );
231 fghi.addProteinDomain( i );
232 fghi.addProteinDomain( i2 );
233 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
234 if ( fghi.getNumberOfProteinDomains() != 7 ) {
237 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
240 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
243 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
244 if ( fghi.getNumberOfProteinDomains() != 7 ) {
247 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
250 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
251 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
252 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
253 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
254 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
255 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
256 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
257 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
258 jklm.addProteinDomain( j );
259 jklm.addProteinDomain( k );
260 jklm.addProteinDomain( l );
261 jklm.addProteinDomain( m );
262 jklm.addProteinDomain( m0 );
263 jklm.addProteinDomain( m1 );
264 jklm.addProteinDomain( m2 );
265 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
266 if ( jklm.getNumberOfProteinDomains() != 7 ) {
269 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
272 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
275 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
276 if ( jklm.getNumberOfProteinDomains() != 7 ) {
279 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
282 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
283 final Protein od = new BasicProtein( "od", "varanus", 0 );
284 od.addProteinDomain( only );
285 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
286 if ( od.getNumberOfProteinDomains() != 1 ) {
289 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
293 catch ( final Exception e ) {
294 e.printStackTrace( System.out );
300 public static boolean testEngulfingOverlapRemoval() {
302 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
303 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
304 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
305 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
306 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
307 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
308 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
309 final List<Boolean> covered = new ArrayList<Boolean>();
310 covered.add( true ); // 0
311 covered.add( false ); // 1
312 covered.add( true ); // 2
313 covered.add( false ); // 3
314 covered.add( true ); // 4
315 covered.add( true ); // 5
316 covered.add( false ); // 6
317 covered.add( true ); // 7
318 covered.add( true ); // 8
319 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
322 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
325 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
328 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
331 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
334 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
337 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
340 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
341 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
342 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
343 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
344 abc.addProteinDomain( a );
345 abc.addProteinDomain( b );
346 abc.addProteinDomain( c );
347 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
348 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
349 if ( abc.getNumberOfProteinDomains() != 3 ) {
352 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
355 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
358 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
361 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
364 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
365 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
366 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
367 final Protein def = new BasicProtein( "def", "nemve", 0 );
368 def.addProteinDomain( d );
369 def.addProteinDomain( e );
370 def.addProteinDomain( f );
371 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
372 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
373 if ( def.getNumberOfProteinDomains() != 3 ) {
376 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
379 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
382 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
385 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
388 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
392 catch ( final Exception e ) {
393 e.printStackTrace( System.out );
399 public static boolean isEqual( final double a, final double b ) {
400 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
403 public static void main( final String[] args ) {
404 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
405 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
407 Locale.setDefault( Locale.US );
408 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
411 System.out.print( "[Test if directory with files for testing exists/is readable: " );
412 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
413 System.out.println( "OK.]" );
416 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
417 System.out.println( "Testing aborted." );
420 System.out.print( "[Test if resources directory exists/is readable: " );
421 if ( testDir( PATH_TO_RESOURCES ) ) {
422 System.out.println( "OK.]" );
425 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
426 System.out.println( "Testing aborted." );
429 final long start_time = new Date().getTime();
430 System.out.print( "Basic node methods: " );
431 if ( Test.testBasicNodeMethods() ) {
432 System.out.println( "OK." );
436 System.out.println( "failed." );
439 System.out.print( "Protein id: " );
440 if ( !testProteinId() ) {
441 System.out.println( "failed." );
447 System.out.println( "OK." );
448 System.out.print( "Species: " );
449 if ( !testSpecies() ) {
450 System.out.println( "failed." );
456 System.out.println( "OK." );
457 System.out.print( "Basic domain: " );
458 if ( !testBasicDomain() ) {
459 System.out.println( "failed." );
465 System.out.println( "OK." );
466 System.out.print( "Basic protein: " );
467 if ( !testBasicProtein() ) {
468 System.out.println( "failed." );
474 System.out.println( "OK." );
475 System.out.print( "Sequence writer: " );
476 if ( testSequenceWriter() ) {
477 System.out.println( "OK." );
481 System.out.println( "failed." );
484 System.out.print( "Sequence id parsing: " );
485 if ( testSequenceIdParsing() ) {
486 System.out.println( "OK." );
490 System.out.println( "failed." );
493 if ( PERFORM_DB_TESTS ) {
494 System.out.print( "Ebi Entry Retrieval: " );
495 if ( Test.testEbiEntryRetrieval() ) {
496 System.out.println( "OK." );
500 System.out.println( "failed." );
504 ///////////////////////////////////////// System.exit( 0 );
505 System.out.print( "UniProtKB id extraction: " );
506 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
507 System.out.println( "OK." );
511 System.out.println( "failed." );
514 System.out.print( "Sequence DB tools 1: " );
515 if ( testSequenceDbWsTools1() ) {
516 System.out.println( "OK." );
520 System.out.println( "failed." );
523 if ( PERFORM_DB_TESTS ) {
524 System.out.print( "Sequence DB tools 2: " );
525 if ( testSequenceDbWsTools2() ) {
526 System.out.println( "OK." );
530 System.out.println( "failed." );
535 System.out.print( "Hmmscan output parser: " );
536 if ( testHmmscanOutputParser() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
545 System.out.print( "Overlap removal: " );
546 if ( !org.forester.test.Test.testOverlapRemoval() ) {
547 System.out.println( "failed." );
553 System.out.println( "OK." );
554 System.out.print( "Engulfing overlap removal: " );
555 if ( !Test.testEngulfingOverlapRemoval() ) {
556 System.out.println( "failed." );
562 System.out.println( "OK." );
564 System.out.print( "Taxonomy code extraction: " );
565 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
566 System.out.println( "OK." );
570 System.out.println( "failed." );
573 System.out.print( "SN extraction: " );
574 if ( Test.testExtractSNFromNodeName() ) {
575 System.out.println( "OK." );
579 System.out.println( "failed." );
582 System.out.print( "Taxonomy extraction (general): " );
583 if ( Test.testTaxonomyExtraction() ) {
584 System.out.println( "OK." );
588 System.out.println( "failed." );
591 System.out.print( "Uri for Aptx web sequence accession: " );
592 if ( Test.testCreateUriForSeqWeb() ) {
593 System.out.println( "OK." );
597 System.out.println( "failed." );
600 System.out.print( "Basic node construction and parsing of NHX (node level): " );
601 if ( Test.testNHXNodeParsing() ) {
602 System.out.println( "OK." );
606 System.out.println( "failed." );
609 System.out.print( "NHX parsing iterating: " );
610 if ( Test.testNHParsingIter() ) {
611 System.out.println( "OK." );
615 System.out.println( "failed." );
618 System.out.print( "NH parsing: " );
619 if ( Test.testNHParsing() ) {
620 System.out.println( "OK." );
624 System.out.println( "failed." );
627 System.out.print( "Conversion to NHX (node level): " );
628 if ( Test.testNHXconversion() ) {
629 System.out.println( "OK." );
633 System.out.println( "failed." );
636 System.out.print( "NHX parsing: " );
637 if ( Test.testNHXParsing() ) {
638 System.out.println( "OK." );
642 System.out.println( "failed." );
645 System.out.print( "NHX parsing with quotes: " );
646 if ( Test.testNHXParsingQuotes() ) {
647 System.out.println( "OK." );
651 System.out.println( "failed." );
654 System.out.print( "NHX parsing (MrBayes): " );
655 if ( Test.testNHXParsingMB() ) {
656 System.out.println( "OK." );
660 System.out.println( "failed." );
663 System.out.print( "Nexus characters parsing: " );
664 if ( Test.testNexusCharactersParsing() ) {
665 System.out.println( "OK." );
669 System.out.println( "failed." );
672 System.out.print( "Nexus tree parsing iterating: " );
673 if ( Test.testNexusTreeParsingIterating() ) {
674 System.out.println( "OK." );
678 System.out.println( "failed." );
681 System.out.print( "Nexus tree parsing: " );
682 if ( Test.testNexusTreeParsing() ) {
683 System.out.println( "OK." );
687 System.out.println( "failed." );
690 System.out.print( "Nexus tree parsing (translating): " );
691 if ( Test.testNexusTreeParsingTranslating() ) {
692 System.out.println( "OK." );
696 System.out.println( "failed." );
699 System.out.print( "Nexus matrix parsing: " );
700 if ( Test.testNexusMatrixParsing() ) {
701 System.out.println( "OK." );
705 System.out.println( "failed." );
708 System.out.print( "Basic phyloXML parsing: " );
709 if ( Test.testBasicPhyloXMLparsing() ) {
710 System.out.println( "OK." );
714 System.out.println( "failed." );
717 System.out.print( "Basic phyloXML parsing (validating against schema): " );
718 if ( testBasicPhyloXMLparsingValidating() ) {
719 System.out.println( "OK." );
723 System.out.println( "failed." );
726 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
727 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
728 System.out.println( "OK." );
732 System.out.println( "failed." );
735 System.out.print( "phyloXML Distribution Element: " );
736 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
737 System.out.println( "OK." );
741 System.out.println( "failed." );
744 System.out.print( "Tol XML parsing: " );
745 if ( Test.testBasicTolXMLparsing() ) {
746 System.out.println( "OK." );
750 System.out.println( "failed." );
753 System.out.print( "Copying of node data: " );
754 if ( Test.testCopyOfNodeData() ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "Tree copy: " );
763 if ( Test.testTreeCopy() ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "Basic tree methods: " );
772 if ( Test.testBasicTreeMethods() ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "Tree methods: " );
781 if ( Test.testTreeMethods() ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "Postorder Iterator: " );
790 if ( Test.testPostOrderIterator() ) {
791 System.out.println( "OK." );
795 System.out.println( "failed." );
798 System.out.print( "Preorder Iterator: " );
799 if ( Test.testPreOrderIterator() ) {
800 System.out.println( "OK." );
804 System.out.println( "failed." );
807 System.out.print( "Levelorder Iterator: " );
808 if ( Test.testLevelOrderIterator() ) {
809 System.out.println( "OK." );
813 System.out.println( "failed." );
816 System.out.print( "Re-id methods: " );
817 if ( Test.testReIdMethods() ) {
818 System.out.println( "OK." );
822 System.out.println( "failed." );
825 System.out.print( "Methods on last external nodes: " );
826 if ( Test.testLastExternalNodeMethods() ) {
827 System.out.println( "OK." );
831 System.out.println( "failed." );
834 System.out.print( "Methods on external nodes: " );
835 if ( Test.testExternalNodeRelatedMethods() ) {
836 System.out.println( "OK." );
840 System.out.println( "failed." );
843 System.out.print( "Deletion of external nodes: " );
844 if ( Test.testDeletionOfExternalNodes() ) {
845 System.out.println( "OK." );
849 System.out.println( "failed." );
852 System.out.print( "Subtree deletion: " );
853 if ( Test.testSubtreeDeletion() ) {
854 System.out.println( "OK." );
858 System.out.println( "failed." );
861 System.out.print( "Phylogeny branch: " );
862 if ( Test.testPhylogenyBranch() ) {
863 System.out.println( "OK." );
867 System.out.println( "failed." );
870 System.out.print( "Rerooting: " );
871 if ( Test.testRerooting() ) {
872 System.out.println( "OK." );
876 System.out.println( "failed." );
879 System.out.print( "Mipoint rooting: " );
880 if ( Test.testMidpointrooting() ) {
881 System.out.println( "OK." );
885 System.out.println( "failed." );
888 System.out.print( "Node removal: " );
889 if ( Test.testNodeRemoval() ) {
890 System.out.println( "OK." );
894 System.out.println( "failed." );
897 System.out.print( "Support count: " );
898 if ( Test.testSupportCount() ) {
899 System.out.println( "OK." );
903 System.out.println( "failed." );
906 System.out.print( "Support transfer: " );
907 if ( Test.testSupportTransfer() ) {
908 System.out.println( "OK." );
912 System.out.println( "failed." );
915 System.out.print( "Finding of LCA: " );
916 if ( Test.testGetLCA() ) {
917 System.out.println( "OK." );
921 System.out.println( "failed." );
924 System.out.print( "Finding of LCA 2: " );
925 if ( Test.testGetLCA2() ) {
926 System.out.println( "OK." );
930 System.out.println( "failed." );
933 System.out.print( "Calculation of distance between nodes: " );
934 if ( Test.testGetDistance() ) {
935 System.out.println( "OK." );
939 System.out.println( "failed." );
942 System.out.print( "Descriptive statistics: " );
943 if ( Test.testDescriptiveStatistics() ) {
944 System.out.println( "OK." );
948 System.out.println( "failed." );
951 System.out.print( "Data objects and methods: " );
952 if ( Test.testDataObjects() ) {
953 System.out.println( "OK." );
957 System.out.println( "failed." );
960 System.out.print( "Properties map: " );
961 if ( Test.testPropertiesMap() ) {
962 System.out.println( "OK." );
966 System.out.println( "failed." );
969 System.out.print( "SDIse: " );
970 if ( Test.testSDIse() ) {
971 System.out.println( "OK." );
975 System.out.println( "failed." );
978 System.out.print( "SDIunrooted: " );
979 if ( Test.testSDIunrooted() ) {
980 System.out.println( "OK." );
984 System.out.println( "failed." );
987 System.out.print( "GSDI: " );
988 if ( TestGSDI.test() ) {
989 System.out.println( "OK." );
993 System.out.println( "failed." );
996 System.out.print( "RIO: " );
997 if ( TestRIO.test() ) {
998 System.out.println( "OK." );
1002 System.out.println( "failed." );
1005 System.out.print( "Phylogeny reconstruction:" );
1006 System.out.println();
1007 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
1008 System.out.println( "OK." );
1012 System.out.println( "failed." );
1015 System.out.print( "Analysis of domain architectures: " );
1016 System.out.println();
1017 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
1018 System.out.println( "OK." );
1022 System.out.println( "failed." );
1025 System.out.print( "GO: " );
1026 System.out.println();
1027 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
1028 System.out.println( "OK." );
1032 System.out.println( "failed." );
1035 System.out.print( "Modeling tools: " );
1036 if ( TestPccx.test() ) {
1037 System.out.println( "OK." );
1041 System.out.println( "failed." );
1044 System.out.print( "Split Matrix strict: " );
1045 if ( Test.testSplitStrict() ) {
1046 System.out.println( "OK." );
1050 System.out.println( "failed." );
1053 System.out.print( "Split Matrix: " );
1054 if ( Test.testSplit() ) {
1055 System.out.println( "OK." );
1059 System.out.println( "failed." );
1062 System.out.print( "Confidence Assessor: " );
1063 if ( Test.testConfidenceAssessor() ) {
1064 System.out.println( "OK." );
1068 System.out.println( "failed." );
1071 System.out.print( "Basic table: " );
1072 if ( Test.testBasicTable() ) {
1073 System.out.println( "OK." );
1077 System.out.println( "failed." );
1080 System.out.print( "General table: " );
1081 if ( Test.testGeneralTable() ) {
1082 System.out.println( "OK." );
1086 System.out.println( "failed." );
1089 System.out.print( "Amino acid sequence: " );
1090 if ( Test.testAminoAcidSequence() ) {
1091 System.out.println( "OK." );
1095 System.out.println( "failed." );
1098 System.out.print( "General MSA parser: " );
1099 if ( Test.testGeneralMsaParser() ) {
1100 System.out.println( "OK." );
1104 System.out.println( "failed." );
1107 System.out.print( "Fasta parser for msa: " );
1108 if ( Test.testFastaParser() ) {
1109 System.out.println( "OK." );
1113 System.out.println( "failed." );
1116 System.out.print( "Creation of balanced phylogeny: " );
1117 if ( Test.testCreateBalancedPhylogeny() ) {
1118 System.out.println( "OK." );
1122 System.out.println( "failed." );
1125 System.out.print( "Genbank accessor parsing: " );
1126 if ( Test.testGenbankAccessorParsing() ) {
1127 System.out.println( "OK." );
1131 System.out.println( "failed." );
1134 if ( PERFORM_DB_TESTS ) {
1135 System.out.print( "Uniprot Entry Retrieval: " );
1136 if ( Test.testUniprotEntryRetrieval() ) {
1137 System.out.println( "OK." );
1141 System.out.println( "failed." );
1145 if ( PERFORM_DB_TESTS ) {
1146 System.out.print( "Uniprot Taxonomy Search: " );
1147 if ( Test.testUniprotTaxonomySearch() ) {
1148 System.out.println( "OK." );
1152 System.out.println( "failed." );
1158 final String os = ForesterUtil.OS_NAME.toLowerCase();
1159 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
1160 path = "/usr/local/bin/mafft";
1162 else if ( os.indexOf( "win" ) >= 0 ) {
1163 path = "C:\\Program Files\\mafft-win\\mafft.bat";
1166 path = "/home/czmasek/bin/mafft";
1168 if ( !MsaInferrer.isInstalled( path ) ) {
1171 if ( !MsaInferrer.isInstalled( path ) ) {
1172 path = "/usr/local/bin/mafft";
1174 if ( MsaInferrer.isInstalled( path ) ) {
1175 System.out.print( "MAFFT (external program): " );
1176 if ( Test.testMafft( path ) ) {
1177 System.out.println( "OK." );
1181 System.out.println( "failed [will not count towards failed tests]" );
1185 System.out.print( "Next nodes with collapsed: " );
1186 if ( Test.testNextNodeWithCollapsing() ) {
1187 System.out.println( "OK." );
1191 System.out.println( "failed." );
1194 System.out.print( "Simple MSA quality: " );
1195 if ( Test.testMsaQualityMethod() ) {
1196 System.out.println( "OK." );
1200 System.out.println( "failed." );
1203 System.out.println();
1204 final Runtime rt = java.lang.Runtime.getRuntime();
1205 final long free_memory = rt.freeMemory() / 1000000;
1206 final long total_memory = rt.totalMemory() / 1000000;
1207 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1208 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1209 System.out.println();
1210 System.out.println( "Successful tests: " + succeeded );
1211 System.out.println( "Failed tests: " + failed );
1212 System.out.println();
1214 System.out.println( "OK." );
1217 System.out.println( "Not OK." );
1221 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1222 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1226 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1227 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1230 private static boolean testAminoAcidSequence() {
1232 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1233 if ( aa1.getLength() != 13 ) {
1236 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1239 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1242 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1245 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1246 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1249 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1250 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1253 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1254 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1258 catch ( final Exception e ) {
1259 e.printStackTrace();
1265 private static boolean testBasicDomain() {
1267 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1268 if ( !pd.getDomainId().equals( "id" ) ) {
1271 if ( pd.getNumber() != 1 ) {
1274 if ( pd.getTotalCount() != 4 ) {
1277 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1280 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1281 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1282 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1283 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1284 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1285 if ( !a1.equals( a1 ) ) {
1288 if ( !a1.equals( a1_copy ) ) {
1291 if ( !a1.equals( a1_equal ) ) {
1294 if ( !a1.equals( a2 ) ) {
1297 if ( a1.equals( a3 ) ) {
1300 if ( a1.compareTo( a1 ) != 0 ) {
1303 if ( a1.compareTo( a1_copy ) != 0 ) {
1306 if ( a1.compareTo( a1_equal ) != 0 ) {
1309 if ( a1.compareTo( a2 ) != 0 ) {
1312 if ( a1.compareTo( a3 ) == 0 ) {
1316 catch ( final Exception e ) {
1317 e.printStackTrace( System.out );
1323 private static boolean testBasicNodeMethods() {
1325 if ( PhylogenyNode.getNodeCount() != 0 ) {
1328 final PhylogenyNode n1 = new PhylogenyNode();
1329 final PhylogenyNode n2 = PhylogenyNode
1330 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1331 final PhylogenyNode n3 = PhylogenyNode
1332 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1333 final PhylogenyNode n4 = PhylogenyNode
1334 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1335 if ( n1.isHasAssignedEvent() ) {
1338 if ( PhylogenyNode.getNodeCount() != 4 ) {
1341 if ( n3.getIndicator() != 0 ) {
1344 if ( n3.getNumberOfExternalNodes() != 1 ) {
1347 if ( !n3.isExternal() ) {
1350 if ( !n3.isRoot() ) {
1353 if ( !n4.getName().equals( "n4" ) ) {
1357 catch ( final Exception e ) {
1358 e.printStackTrace( System.out );
1364 private static boolean testBasicPhyloXMLparsing() {
1366 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1367 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1368 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1370 if ( xml_parser.getErrorCount() > 0 ) {
1371 System.out.println( xml_parser.getErrorMessages().toString() );
1374 if ( phylogenies_0.length != 4 ) {
1377 final Phylogeny t1 = phylogenies_0[ 0 ];
1378 final Phylogeny t2 = phylogenies_0[ 1 ];
1379 final Phylogeny t3 = phylogenies_0[ 2 ];
1380 final Phylogeny t4 = phylogenies_0[ 3 ];
1381 if ( t1.getNumberOfExternalNodes() != 1 ) {
1384 if ( !t1.isRooted() ) {
1387 if ( t1.isRerootable() ) {
1390 if ( !t1.getType().equals( "gene_tree" ) ) {
1393 if ( t2.getNumberOfExternalNodes() != 2 ) {
1396 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1399 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1402 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1405 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1408 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1411 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1414 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1415 .startsWith( "actgtgggggt" ) ) {
1418 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1419 .startsWith( "ctgtgatgcat" ) ) {
1422 if ( t3.getNumberOfExternalNodes() != 4 ) {
1425 if ( !t1.getName().equals( "t1" ) ) {
1428 if ( !t2.getName().equals( "t2" ) ) {
1431 if ( !t3.getName().equals( "t3" ) ) {
1434 if ( !t4.getName().equals( "t4" ) ) {
1437 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1440 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1443 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1446 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1447 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1450 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1453 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1456 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1459 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1460 .equals( "apoptosis" ) ) {
1463 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1464 .equals( "GO:0006915" ) ) {
1467 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1468 .equals( "UniProtKB" ) ) {
1471 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1472 .equals( "experimental" ) ) {
1475 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1476 .equals( "function" ) ) {
1479 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1480 .getValue() != 1 ) {
1483 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1484 .getType().equals( "ml" ) ) {
1487 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1488 .equals( "apoptosis" ) ) {
1491 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1492 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1495 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1496 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1499 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1500 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1503 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1504 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1507 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1508 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1511 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1512 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1515 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1516 .equals( "GO:0005829" ) ) {
1519 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1520 .equals( "intracellular organelle" ) ) {
1523 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1526 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1527 .equals( "UniProt link" ) ) ) {
1530 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1533 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1534 if ( x.size() != 4 ) {
1538 for( final Accession acc : x ) {
1540 if ( !acc.getSource().equals( "KEGG" ) ) {
1543 if ( !acc.getValue().equals( "hsa:596" ) ) {
1550 catch ( final Exception e ) {
1551 e.printStackTrace( System.out );
1557 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1559 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1560 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1561 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1562 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1565 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1567 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1569 if ( xml_parser.getErrorCount() > 0 ) {
1570 System.out.println( xml_parser.getErrorMessages().toString() );
1573 if ( phylogenies_0.length != 4 ) {
1576 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1577 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1578 if ( phylogenies_t1.length != 1 ) {
1581 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1582 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1585 if ( !t1_rt.isRooted() ) {
1588 if ( t1_rt.isRerootable() ) {
1591 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1594 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1595 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1596 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1597 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1600 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1603 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1606 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1609 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1610 .startsWith( "actgtgggggt" ) ) {
1613 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1614 .startsWith( "ctgtgatgcat" ) ) {
1617 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1618 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1619 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1620 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1621 if ( phylogenies_1.length != 1 ) {
1624 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1625 if ( !t3_rt.getName().equals( "t3" ) ) {
1628 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1631 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1634 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1637 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1640 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1641 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1644 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1647 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1650 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1651 .equals( "UniProtKB" ) ) {
1654 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1655 .equals( "apoptosis" ) ) {
1658 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1659 .equals( "GO:0006915" ) ) {
1662 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1663 .equals( "UniProtKB" ) ) {
1666 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1667 .equals( "experimental" ) ) {
1670 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1671 .equals( "function" ) ) {
1674 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1675 .getValue() != 1 ) {
1678 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1679 .getType().equals( "ml" ) ) {
1682 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1683 .equals( "apoptosis" ) ) {
1686 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1687 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1690 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1691 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1694 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1695 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1698 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1699 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1702 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1703 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1706 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1707 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1710 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1711 .equals( "GO:0005829" ) ) {
1714 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1715 .equals( "intracellular organelle" ) ) {
1718 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1721 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1722 .equals( "UniProt link" ) ) ) {
1725 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1728 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1731 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1732 .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." ) ) ) {
1735 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1738 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1741 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1744 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1747 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1748 .equals( "ncbi" ) ) {
1751 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1754 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1755 .getName().equals( "B" ) ) {
1758 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1759 .getFrom() != 21 ) {
1762 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1765 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1766 .getLength() != 24 ) {
1769 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1770 .getConfidence() != 2144 ) {
1773 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1774 .equals( "pfam" ) ) {
1777 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1780 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1783 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1786 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1789 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1790 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1793 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1796 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1799 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1802 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1805 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1808 if ( taxbb.getSynonyms().size() != 2 ) {
1811 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1814 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1817 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1820 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1823 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1826 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1827 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1830 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1833 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1836 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1839 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1842 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1845 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1848 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1852 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1855 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1856 .equalsIgnoreCase( "435" ) ) {
1859 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1862 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1863 .equalsIgnoreCase( "443.7" ) ) {
1866 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1869 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1872 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1873 .equalsIgnoreCase( "433" ) ) {
1876 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1877 .getCrossReferences();
1878 if ( x.size() != 4 ) {
1882 for( final Accession acc : x ) {
1884 if ( !acc.getSource().equals( "KEGG" ) ) {
1887 if ( !acc.getValue().equals( "hsa:596" ) ) {
1894 catch ( final Exception e ) {
1895 e.printStackTrace( System.out );
1901 private static boolean testBasicPhyloXMLparsingValidating() {
1903 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1904 PhyloXmlParser xml_parser = null;
1906 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1908 catch ( final Exception e ) {
1909 // Do nothing -- means were not running from jar.
1911 if ( xml_parser == null ) {
1912 xml_parser = new PhyloXmlParser();
1913 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1914 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1917 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1920 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1922 if ( xml_parser.getErrorCount() > 0 ) {
1923 System.out.println( xml_parser.getErrorMessages().toString() );
1926 if ( phylogenies_0.length != 4 ) {
1929 final Phylogeny t1 = phylogenies_0[ 0 ];
1930 final Phylogeny t2 = phylogenies_0[ 1 ];
1931 final Phylogeny t3 = phylogenies_0[ 2 ];
1932 final Phylogeny t4 = phylogenies_0[ 3 ];
1933 if ( !t1.getName().equals( "t1" ) ) {
1936 if ( !t2.getName().equals( "t2" ) ) {
1939 if ( !t3.getName().equals( "t3" ) ) {
1942 if ( !t4.getName().equals( "t4" ) ) {
1945 if ( t1.getNumberOfExternalNodes() != 1 ) {
1948 if ( t2.getNumberOfExternalNodes() != 2 ) {
1951 if ( t3.getNumberOfExternalNodes() != 4 ) {
1954 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1955 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1956 if ( xml_parser.getErrorCount() > 0 ) {
1957 System.out.println( "errors:" );
1958 System.out.println( xml_parser.getErrorMessages().toString() );
1961 if ( phylogenies_1.length != 4 ) {
1964 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1966 if ( xml_parser.getErrorCount() > 0 ) {
1967 System.out.println( "errors:" );
1968 System.out.println( xml_parser.getErrorMessages().toString() );
1971 if ( phylogenies_2.length != 1 ) {
1974 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1977 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1979 if ( xml_parser.getErrorCount() > 0 ) {
1980 System.out.println( xml_parser.getErrorMessages().toString() );
1983 if ( phylogenies_3.length != 2 ) {
1986 final Phylogeny a = phylogenies_3[ 0 ];
1987 if ( !a.getName().equals( "tree 4" ) ) {
1990 if ( a.getNumberOfExternalNodes() != 3 ) {
1993 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1996 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1999 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2001 if ( xml_parser.getErrorCount() > 0 ) {
2002 System.out.println( xml_parser.getErrorMessages().toString() );
2005 if ( phylogenies_4.length != 1 ) {
2008 final Phylogeny s = phylogenies_4[ 0 ];
2009 if ( s.getNumberOfExternalNodes() != 6 ) {
2012 s.getNode( "first" );
2014 s.getNode( "\"<a'b&c'd\">\"" );
2015 s.getNode( "'''\"" );
2016 s.getNode( "\"\"\"" );
2017 s.getNode( "dick & doof" );
2019 catch ( final Exception e ) {
2020 e.printStackTrace( System.out );
2026 private static boolean testBasicProtein() {
2028 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2029 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2030 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2031 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2032 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2033 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2034 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2035 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2036 p0.addProteinDomain( y );
2037 p0.addProteinDomain( e );
2038 p0.addProteinDomain( b );
2039 p0.addProteinDomain( c );
2040 p0.addProteinDomain( d );
2041 p0.addProteinDomain( a );
2042 p0.addProteinDomain( x );
2043 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2046 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2050 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2051 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2052 aa0.addProteinDomain( a1 );
2053 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2056 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2060 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2061 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2062 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2063 aa1.addProteinDomain( a11 );
2064 aa1.addProteinDomain( a12 );
2065 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2068 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2071 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2072 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2075 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2078 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2081 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2082 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2085 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2088 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2091 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2094 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2095 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2098 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2101 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2104 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2107 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2108 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2111 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2114 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2117 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2121 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2122 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2123 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2124 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2125 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2126 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2127 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2128 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2129 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2130 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2131 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2132 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2133 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2134 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2135 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2136 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2137 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2138 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2139 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2140 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2141 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2142 p00.addProteinDomain( y0 );
2143 p00.addProteinDomain( e0 );
2144 p00.addProteinDomain( b0 );
2145 p00.addProteinDomain( c0 );
2146 p00.addProteinDomain( d0 );
2147 p00.addProteinDomain( a0 );
2148 p00.addProteinDomain( x0 );
2149 p00.addProteinDomain( y1 );
2150 p00.addProteinDomain( y2 );
2151 p00.addProteinDomain( y3 );
2152 p00.addProteinDomain( e1 );
2153 p00.addProteinDomain( e2 );
2154 p00.addProteinDomain( e3 );
2155 p00.addProteinDomain( e4 );
2156 p00.addProteinDomain( e5 );
2157 p00.addProteinDomain( z0 );
2158 p00.addProteinDomain( z1 );
2159 p00.addProteinDomain( z2 );
2160 p00.addProteinDomain( zz0 );
2161 p00.addProteinDomain( zz1 );
2162 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2165 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2168 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2171 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2174 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" ) ) {
2177 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2178 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2179 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2180 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2181 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2182 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2183 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2184 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2185 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2186 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2187 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2188 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2189 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2190 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2191 p.addProteinDomain( B15 );
2192 p.addProteinDomain( C50 );
2193 p.addProteinDomain( A60 );
2194 p.addProteinDomain( A30 );
2195 p.addProteinDomain( C70 );
2196 p.addProteinDomain( B35 );
2197 p.addProteinDomain( B40 );
2198 p.addProteinDomain( A0 );
2199 p.addProteinDomain( A10 );
2200 p.addProteinDomain( A20 );
2201 p.addProteinDomain( B25 );
2202 p.addProteinDomain( D80 );
2203 List<String> domains_ids = new ArrayList<String>();
2204 domains_ids.add( "A" );
2205 domains_ids.add( "B" );
2206 domains_ids.add( "C" );
2207 if ( !p.contains( domains_ids, false ) ) {
2210 if ( !p.contains( domains_ids, true ) ) {
2213 domains_ids.add( "X" );
2214 if ( p.contains( domains_ids, false ) ) {
2217 if ( p.contains( domains_ids, true ) ) {
2220 domains_ids = new ArrayList<String>();
2221 domains_ids.add( "A" );
2222 domains_ids.add( "C" );
2223 domains_ids.add( "D" );
2224 if ( !p.contains( domains_ids, false ) ) {
2227 if ( !p.contains( domains_ids, true ) ) {
2230 domains_ids = new ArrayList<String>();
2231 domains_ids.add( "A" );
2232 domains_ids.add( "D" );
2233 domains_ids.add( "C" );
2234 if ( !p.contains( domains_ids, false ) ) {
2237 if ( p.contains( domains_ids, true ) ) {
2240 domains_ids = new ArrayList<String>();
2241 domains_ids.add( "A" );
2242 domains_ids.add( "A" );
2243 domains_ids.add( "B" );
2244 if ( !p.contains( domains_ids, false ) ) {
2247 if ( !p.contains( domains_ids, true ) ) {
2250 domains_ids = new ArrayList<String>();
2251 domains_ids.add( "A" );
2252 domains_ids.add( "A" );
2253 domains_ids.add( "A" );
2254 domains_ids.add( "B" );
2255 domains_ids.add( "B" );
2256 if ( !p.contains( domains_ids, false ) ) {
2259 if ( !p.contains( domains_ids, true ) ) {
2262 domains_ids = new ArrayList<String>();
2263 domains_ids.add( "A" );
2264 domains_ids.add( "A" );
2265 domains_ids.add( "B" );
2266 domains_ids.add( "A" );
2267 domains_ids.add( "B" );
2268 domains_ids.add( "B" );
2269 domains_ids.add( "A" );
2270 domains_ids.add( "B" );
2271 domains_ids.add( "C" );
2272 domains_ids.add( "A" );
2273 domains_ids.add( "C" );
2274 domains_ids.add( "D" );
2275 if ( !p.contains( domains_ids, false ) ) {
2278 if ( p.contains( domains_ids, true ) ) {
2282 catch ( final Exception e ) {
2283 e.printStackTrace( System.out );
2289 private static boolean testBasicTable() {
2291 final BasicTable<String> t0 = new BasicTable<String>();
2292 if ( t0.getNumberOfColumns() != 0 ) {
2295 if ( t0.getNumberOfRows() != 0 ) {
2298 t0.setValue( 3, 2, "23" );
2299 t0.setValue( 10, 1, "error" );
2300 t0.setValue( 10, 1, "110" );
2301 t0.setValue( 9, 1, "19" );
2302 t0.setValue( 1, 10, "101" );
2303 t0.setValue( 10, 10, "1010" );
2304 t0.setValue( 100, 10, "10100" );
2305 t0.setValue( 0, 0, "00" );
2306 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2309 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2312 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2315 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2318 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2321 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2324 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2327 if ( t0.getNumberOfColumns() != 101 ) {
2330 if ( t0.getNumberOfRows() != 11 ) {
2333 if ( t0.getValueAsString( 49, 4 ) != null ) {
2336 final String l = ForesterUtil.getLineSeparator();
2337 final StringBuffer source = new StringBuffer();
2338 source.append( "" + l );
2339 source.append( "# 1 1 1 1 1 1 1 1" + l );
2340 source.append( " 00 01 02 03" + l );
2341 source.append( " 10 11 12 13 " + l );
2342 source.append( "20 21 22 23 " + l );
2343 source.append( " 30 31 32 33" + l );
2344 source.append( "40 41 42 43" + l );
2345 source.append( " # 1 1 1 1 1 " + l );
2346 source.append( "50 51 52 53 54" + l );
2347 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2348 if ( t1.getNumberOfColumns() != 5 ) {
2351 if ( t1.getNumberOfRows() != 6 ) {
2354 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2357 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2360 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2363 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2366 final StringBuffer source1 = new StringBuffer();
2367 source1.append( "" + l );
2368 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2369 source1.append( " 00; 01 ;02;03" + l );
2370 source1.append( " 10; 11; 12; 13 " + l );
2371 source1.append( "20; 21; 22; 23 " + l );
2372 source1.append( " 30; 31; 32; 33" + l );
2373 source1.append( "40;41;42;43" + l );
2374 source1.append( " # 1 1 1 1 1 " + l );
2375 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2376 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2377 if ( t2.getNumberOfColumns() != 5 ) {
2380 if ( t2.getNumberOfRows() != 6 ) {
2383 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2386 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2389 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2392 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2395 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2398 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2401 final StringBuffer source2 = new StringBuffer();
2402 source2.append( "" + l );
2403 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2404 source2.append( " 00; 01 ;02;03" + l );
2405 source2.append( " 10; 11; 12; 13 " + l );
2406 source2.append( "20; 21; 22; 23 " + l );
2407 source2.append( " " + l );
2408 source2.append( " 30; 31; 32; 33" + l );
2409 source2.append( "40;41;42;43" + l );
2410 source2.append( " comment: 1 1 1 1 1 " + l );
2411 source2.append( ";;;50 ; 52; 53;;54 " + l );
2412 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2418 if ( tl.size() != 2 ) {
2421 final BasicTable<String> t3 = tl.get( 0 );
2422 final BasicTable<String> t4 = tl.get( 1 );
2423 if ( t3.getNumberOfColumns() != 4 ) {
2426 if ( t3.getNumberOfRows() != 3 ) {
2429 if ( t4.getNumberOfColumns() != 4 ) {
2432 if ( t4.getNumberOfRows() != 3 ) {
2435 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2438 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2442 catch ( final Exception e ) {
2443 e.printStackTrace( System.out );
2449 private static boolean testBasicTolXMLparsing() {
2451 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2452 final TolParser parser = new TolParser();
2453 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2454 if ( parser.getErrorCount() > 0 ) {
2455 System.out.println( parser.getErrorMessages().toString() );
2458 if ( phylogenies_0.length != 1 ) {
2461 final Phylogeny t1 = phylogenies_0[ 0 ];
2462 if ( t1.getNumberOfExternalNodes() != 5 ) {
2465 if ( !t1.isRooted() ) {
2468 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2471 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2474 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2477 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2480 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2481 if ( parser.getErrorCount() > 0 ) {
2482 System.out.println( parser.getErrorMessages().toString() );
2485 if ( phylogenies_1.length != 1 ) {
2488 final Phylogeny t2 = phylogenies_1[ 0 ];
2489 if ( t2.getNumberOfExternalNodes() != 664 ) {
2492 if ( !t2.isRooted() ) {
2495 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2498 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2501 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2504 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2507 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2510 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2511 .equals( "Aquifex" ) ) {
2514 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2515 if ( parser.getErrorCount() > 0 ) {
2516 System.out.println( parser.getErrorMessages().toString() );
2519 if ( phylogenies_2.length != 1 ) {
2522 final Phylogeny t3 = phylogenies_2[ 0 ];
2523 if ( t3.getNumberOfExternalNodes() != 184 ) {
2526 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2529 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2532 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2535 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2536 if ( parser.getErrorCount() > 0 ) {
2537 System.out.println( parser.getErrorMessages().toString() );
2540 if ( phylogenies_3.length != 1 ) {
2543 final Phylogeny t4 = phylogenies_3[ 0 ];
2544 if ( t4.getNumberOfExternalNodes() != 1 ) {
2547 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2550 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2553 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2556 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2557 if ( parser.getErrorCount() > 0 ) {
2558 System.out.println( parser.getErrorMessages().toString() );
2561 if ( phylogenies_4.length != 1 ) {
2564 final Phylogeny t5 = phylogenies_4[ 0 ];
2565 if ( t5.getNumberOfExternalNodes() != 13 ) {
2568 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2571 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2574 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2578 catch ( final Exception e ) {
2579 e.printStackTrace( System.out );
2585 private static boolean testBasicTreeMethods() {
2587 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2588 final Phylogeny t1 = factory.create();
2589 if ( !t1.isEmpty() ) {
2592 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2593 if ( t2.getNumberOfExternalNodes() != 4 ) {
2596 if ( t2.getHeight() != 8.5 ) {
2599 if ( !t2.isCompletelyBinary() ) {
2602 if ( t2.isEmpty() ) {
2605 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2606 if ( t3.getNumberOfExternalNodes() != 5 ) {
2609 if ( t3.getHeight() != 11 ) {
2612 if ( t3.isCompletelyBinary() ) {
2615 final PhylogenyNode n = t3.getNode( "ABC" );
2616 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 ];
2617 if ( t4.getNumberOfExternalNodes() != 9 ) {
2620 if ( t4.getHeight() != 11 ) {
2623 if ( t4.isCompletelyBinary() ) {
2626 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)" );
2627 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2628 if ( t5.getNumberOfExternalNodes() != 8 ) {
2631 if ( t5.getHeight() != 15 ) {
2634 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)" );
2635 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2636 if ( t6.getHeight() != 15 ) {
2639 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)" );
2640 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2641 if ( t7.getHeight() != 15 ) {
2644 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)" );
2645 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2646 if ( t8.getNumberOfExternalNodes() != 10 ) {
2649 if ( t8.getHeight() != 15 ) {
2652 final char[] a9 = new char[] { 'a' };
2653 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2654 if ( t9.getHeight() != 0 ) {
2657 final char[] a10 = new char[] { 'a', ':', '6' };
2658 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2659 if ( t10.getHeight() != 6 ) {
2663 catch ( final Exception e ) {
2664 e.printStackTrace( System.out );
2670 private static boolean testConfidenceAssessor() {
2672 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2673 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2674 final Phylogeny[] ev0 = factory
2675 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2677 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2678 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2681 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2684 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2685 final Phylogeny[] ev1 = factory
2686 .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)));",
2688 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2689 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2692 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2695 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2696 final Phylogeny[] ev_b = factory
2697 .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",
2699 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2700 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2703 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2707 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2708 final Phylogeny[] ev1x = factory
2709 .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)));",
2711 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2712 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2715 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2718 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2719 final Phylogeny[] ev_bx = factory
2720 .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",
2722 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2723 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2726 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2730 final Phylogeny[] t2 = factory
2731 .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);",
2733 final Phylogeny[] ev2 = factory
2734 .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);",
2736 for( final Phylogeny target : t2 ) {
2737 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2740 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2741 new NHXParser() )[ 0 ];
2742 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2743 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2744 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2747 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2750 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2754 catch ( final Exception e ) {
2755 e.printStackTrace();
2761 private static boolean testCopyOfNodeData() {
2763 final PhylogenyNode n1 = PhylogenyNode
2764 .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]" );
2765 final PhylogenyNode n2 = n1.copyNodeData();
2766 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2770 catch ( final Exception e ) {
2771 e.printStackTrace();
2777 private static boolean testTreeCopy() {
2779 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])";
2780 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
2781 final Phylogeny t1 = t0.copy();
2782 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
2785 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2788 t0.deleteSubtree( t0.getNode( "c" ), true );
2789 t0.deleteSubtree( t0.getNode( "a" ), true );
2790 t0.deleteSubtree( t0.getNode( "e" ), true );
2791 if ( !t0.toNewHampshireX().equals( "(b,d)[&&NHX:S=lizards]" ) ) {
2794 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2797 t0.deleteSubtree( t0.getNode( "b" ), true );
2798 t0.deleteSubtree( t0.getNode( "d" ), true );
2799 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
2803 catch ( final Exception e ) {
2804 e.printStackTrace();
2810 private static boolean testCreateBalancedPhylogeny() {
2812 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2813 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2816 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2819 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2820 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2823 if ( p1.getNumberOfExternalNodes() != 100 ) {
2827 catch ( final Exception e ) {
2828 e.printStackTrace();
2834 private static boolean testCreateUriForSeqWeb() {
2836 final PhylogenyNode n = new PhylogenyNode();
2837 n.setName( "tr|B3RJ64" );
2838 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2841 n.setName( "B0LM41_HUMAN" );
2842 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2845 n.setName( "NP_001025424" );
2846 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2849 n.setName( "_NM_001030253-" );
2850 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2853 n.setName( "XM_002122186" );
2854 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2857 n.setName( "dgh_AAA34956_gdg" );
2858 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2861 n.setName( "AAA34956" );
2862 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2865 n.setName( "GI:394892" );
2866 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2867 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2870 n.setName( "gi_394892" );
2871 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2872 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2875 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2876 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2877 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2880 n.setName( "P12345" );
2881 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2882 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2885 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2886 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2887 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2891 catch ( final Exception e ) {
2892 e.printStackTrace( System.out );
2898 private static boolean testDataObjects() {
2900 final Confidence s0 = new Confidence();
2901 final Confidence s1 = new Confidence();
2902 if ( !s0.isEqual( s1 ) ) {
2905 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2906 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2907 if ( s2.isEqual( s1 ) ) {
2910 if ( !s2.isEqual( s3 ) ) {
2913 final Confidence s4 = ( Confidence ) s3.copy();
2914 if ( !s4.isEqual( s3 ) ) {
2921 final Taxonomy t1 = new Taxonomy();
2922 final Taxonomy t2 = new Taxonomy();
2923 final Taxonomy t3 = new Taxonomy();
2924 final Taxonomy t4 = new Taxonomy();
2925 final Taxonomy t5 = new Taxonomy();
2926 t1.setIdentifier( new Identifier( "ecoli" ) );
2927 t1.setTaxonomyCode( "ECOLI" );
2928 t1.setScientificName( "E. coli" );
2929 t1.setCommonName( "coli" );
2930 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2931 if ( !t1.isEqual( t0 ) ) {
2934 t2.setIdentifier( new Identifier( "ecoli" ) );
2935 t2.setTaxonomyCode( "OTHER" );
2936 t2.setScientificName( "what" );
2937 t2.setCommonName( "something" );
2938 if ( !t1.isEqual( t2 ) ) {
2941 t2.setIdentifier( new Identifier( "nemve" ) );
2942 if ( t1.isEqual( t2 ) ) {
2945 t1.setIdentifier( null );
2946 t3.setTaxonomyCode( "ECOLI" );
2947 t3.setScientificName( "what" );
2948 t3.setCommonName( "something" );
2949 if ( !t1.isEqual( t3 ) ) {
2952 t1.setIdentifier( null );
2953 t1.setTaxonomyCode( "" );
2954 t4.setScientificName( "E. ColI" );
2955 t4.setCommonName( "something" );
2956 if ( !t1.isEqual( t4 ) ) {
2959 t4.setScientificName( "B. subtilis" );
2960 t4.setCommonName( "something" );
2961 if ( t1.isEqual( t4 ) ) {
2964 t1.setIdentifier( null );
2965 t1.setTaxonomyCode( "" );
2966 t1.setScientificName( "" );
2967 t5.setCommonName( "COLI" );
2968 if ( !t1.isEqual( t5 ) ) {
2971 t5.setCommonName( "vibrio" );
2972 if ( t1.isEqual( t5 ) ) {
2977 final Identifier id0 = new Identifier( "123", "pfam" );
2978 final Identifier id1 = ( Identifier ) id0.copy();
2979 if ( !id1.isEqual( id1 ) ) {
2982 if ( !id1.isEqual( id0 ) ) {
2985 if ( !id0.isEqual( id1 ) ) {
2992 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2993 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2994 if ( !pd1.isEqual( pd1 ) ) {
2997 if ( !pd1.isEqual( pd0 ) ) {
3002 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3003 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3004 if ( !pd3.isEqual( pd3 ) ) {
3007 if ( !pd2.isEqual( pd3 ) ) {
3010 if ( !pd0.isEqual( pd3 ) ) {
3015 // DomainArchitecture
3016 // ------------------
3017 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3018 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3019 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3020 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3021 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3022 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3027 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3028 if ( ds0.getNumberOfDomains() != 4 ) {
3031 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3032 if ( !ds0.isEqual( ds0 ) ) {
3035 if ( !ds0.isEqual( ds1 ) ) {
3038 if ( ds1.getNumberOfDomains() != 4 ) {
3041 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3046 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3047 if ( ds0.isEqual( ds2 ) ) {
3053 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3054 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3055 System.out.println( ds3.toNHX() );
3058 if ( ds3.getNumberOfDomains() != 3 ) {
3063 final Event e1 = new Event( Event.EventType.fusion );
3064 if ( e1.isDuplication() ) {
3067 if ( !e1.isFusion() ) {
3070 if ( !e1.asText().toString().equals( "fusion" ) ) {
3073 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3076 final Event e11 = new Event( Event.EventType.fusion );
3077 if ( !e11.isEqual( e1 ) ) {
3080 if ( !e11.toNHX().toString().equals( "" ) ) {
3083 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3084 if ( e2.isDuplication() ) {
3087 if ( !e2.isSpeciationOrDuplication() ) {
3090 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3093 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3096 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3099 if ( e11.isEqual( e2 ) ) {
3102 final Event e2c = ( Event ) e2.copy();
3103 if ( !e2c.isEqual( e2 ) ) {
3106 Event e3 = new Event( 1, 2, 3 );
3107 if ( e3.isDuplication() ) {
3110 if ( e3.isSpeciation() ) {
3113 if ( e3.isGeneLoss() ) {
3116 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3119 final Event e3c = ( Event ) e3.copy();
3120 final Event e3cc = ( Event ) e3c.copy();
3121 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3125 if ( !e3c.isEqual( e3cc ) ) {
3128 Event e4 = new Event( 1, 2, 3 );
3129 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3132 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3135 final Event e4c = ( Event ) e4.copy();
3137 final Event e4cc = ( Event ) e4c.copy();
3138 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3141 if ( !e4c.isEqual( e4cc ) ) {
3144 final Event e5 = new Event();
3145 if ( !e5.isUnassigned() ) {
3148 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3151 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3154 final Event e6 = new Event( 1, 0, 0 );
3155 if ( !e6.asText().toString().equals( "duplication" ) ) {
3158 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3161 final Event e7 = new Event( 0, 1, 0 );
3162 if ( !e7.asText().toString().equals( "speciation" ) ) {
3165 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3168 final Event e8 = new Event( 0, 0, 1 );
3169 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3172 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3176 catch ( final Exception e ) {
3177 e.printStackTrace( System.out );
3183 private static boolean testDeletionOfExternalNodes() {
3185 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3186 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3187 final PhylogenyWriter w = new PhylogenyWriter();
3188 if ( t0.isEmpty() ) {
3191 if ( t0.getNumberOfExternalNodes() != 1 ) {
3194 t0.deleteSubtree( t0.getNode( "A" ), false );
3195 if ( t0.getNumberOfExternalNodes() != 0 ) {
3198 if ( !t0.isEmpty() ) {
3201 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3202 if ( t1.getNumberOfExternalNodes() != 2 ) {
3205 t1.deleteSubtree( t1.getNode( "A" ), false );
3206 if ( t1.getNumberOfExternalNodes() != 1 ) {
3209 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3212 t1.deleteSubtree( t1.getNode( "B" ), false );
3213 if ( t1.getNumberOfExternalNodes() != 1 ) {
3216 t1.deleteSubtree( t1.getNode( "r" ), false );
3217 if ( !t1.isEmpty() ) {
3220 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3221 if ( t2.getNumberOfExternalNodes() != 3 ) {
3224 t2.deleteSubtree( t2.getNode( "B" ), false );
3225 if ( t2.getNumberOfExternalNodes() != 2 ) {
3228 t2.toNewHampshireX();
3229 PhylogenyNode n = t2.getNode( "A" );
3230 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3233 t2.deleteSubtree( t2.getNode( "A" ), false );
3234 if ( t2.getNumberOfExternalNodes() != 2 ) {
3237 t2.deleteSubtree( t2.getNode( "C" ), true );
3238 if ( t2.getNumberOfExternalNodes() != 1 ) {
3241 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3242 if ( t3.getNumberOfExternalNodes() != 4 ) {
3245 t3.deleteSubtree( t3.getNode( "B" ), true );
3246 if ( t3.getNumberOfExternalNodes() != 3 ) {
3249 n = t3.getNode( "A" );
3250 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3253 n = n.getNextExternalNode();
3254 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3257 t3.deleteSubtree( t3.getNode( "A" ), true );
3258 if ( t3.getNumberOfExternalNodes() != 2 ) {
3261 n = t3.getNode( "C" );
3262 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3265 t3.deleteSubtree( t3.getNode( "C" ), true );
3266 if ( t3.getNumberOfExternalNodes() != 1 ) {
3269 t3.deleteSubtree( t3.getNode( "D" ), true );
3270 if ( t3.getNumberOfExternalNodes() != 0 ) {
3273 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3274 if ( t4.getNumberOfExternalNodes() != 6 ) {
3277 t4.deleteSubtree( t4.getNode( "B2" ), true );
3278 if ( t4.getNumberOfExternalNodes() != 5 ) {
3281 String s = w.toNewHampshire( t4, false, true ).toString();
3282 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3285 t4.deleteSubtree( t4.getNode( "B11" ), true );
3286 if ( t4.getNumberOfExternalNodes() != 4 ) {
3289 t4.deleteSubtree( t4.getNode( "C" ), true );
3290 if ( t4.getNumberOfExternalNodes() != 3 ) {
3293 n = t4.getNode( "A" );
3294 n = n.getNextExternalNode();
3295 if ( !n.getName().equals( "B12" ) ) {
3298 n = n.getNextExternalNode();
3299 if ( !n.getName().equals( "D" ) ) {
3302 s = w.toNewHampshire( t4, false, true ).toString();
3303 if ( !s.equals( "((A,B12),D);" ) ) {
3306 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3307 t5.deleteSubtree( t5.getNode( "A" ), true );
3308 if ( t5.getNumberOfExternalNodes() != 5 ) {
3311 s = w.toNewHampshire( t5, false, true ).toString();
3312 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3315 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3316 t6.deleteSubtree( t6.getNode( "B11" ), true );
3317 if ( t6.getNumberOfExternalNodes() != 5 ) {
3320 s = w.toNewHampshire( t6, false, false ).toString();
3321 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3324 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3325 t7.deleteSubtree( t7.getNode( "B12" ), true );
3326 if ( t7.getNumberOfExternalNodes() != 5 ) {
3329 s = w.toNewHampshire( t7, false, true ).toString();
3330 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3333 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3334 t8.deleteSubtree( t8.getNode( "B2" ), true );
3335 if ( t8.getNumberOfExternalNodes() != 5 ) {
3338 s = w.toNewHampshire( t8, false, false ).toString();
3339 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3342 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3343 t9.deleteSubtree( t9.getNode( "C" ), true );
3344 if ( t9.getNumberOfExternalNodes() != 5 ) {
3347 s = w.toNewHampshire( t9, false, true ).toString();
3348 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3351 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3352 t10.deleteSubtree( t10.getNode( "D" ), true );
3353 if ( t10.getNumberOfExternalNodes() != 5 ) {
3356 s = w.toNewHampshire( t10, false, true ).toString();
3357 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3360 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3361 t11.deleteSubtree( t11.getNode( "A" ), true );
3362 if ( t11.getNumberOfExternalNodes() != 2 ) {
3365 s = w.toNewHampshire( t11, false, true ).toString();
3366 if ( !s.equals( "(B,C);" ) ) {
3369 t11.deleteSubtree( t11.getNode( "C" ), true );
3370 if ( t11.getNumberOfExternalNodes() != 1 ) {
3373 s = w.toNewHampshire( t11, false, false ).toString();
3374 if ( !s.equals( "B;" ) ) {
3377 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3378 t12.deleteSubtree( t12.getNode( "B2" ), true );
3379 if ( t12.getNumberOfExternalNodes() != 8 ) {
3382 s = w.toNewHampshire( t12, false, true ).toString();
3383 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3386 t12.deleteSubtree( t12.getNode( "B3" ), true );
3387 if ( t12.getNumberOfExternalNodes() != 7 ) {
3390 s = w.toNewHampshire( t12, false, true ).toString();
3391 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3394 t12.deleteSubtree( t12.getNode( "C3" ), true );
3395 if ( t12.getNumberOfExternalNodes() != 6 ) {
3398 s = w.toNewHampshire( t12, false, true ).toString();
3399 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3402 t12.deleteSubtree( t12.getNode( "A1" ), true );
3403 if ( t12.getNumberOfExternalNodes() != 5 ) {
3406 s = w.toNewHampshire( t12, false, true ).toString();
3407 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3410 t12.deleteSubtree( t12.getNode( "B1" ), true );
3411 if ( t12.getNumberOfExternalNodes() != 4 ) {
3414 s = w.toNewHampshire( t12, false, true ).toString();
3415 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3418 t12.deleteSubtree( t12.getNode( "A3" ), true );
3419 if ( t12.getNumberOfExternalNodes() != 3 ) {
3422 s = w.toNewHampshire( t12, false, true ).toString();
3423 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3426 t12.deleteSubtree( t12.getNode( "A2" ), true );
3427 if ( t12.getNumberOfExternalNodes() != 2 ) {
3430 s = w.toNewHampshire( t12, false, true ).toString();
3431 if ( !s.equals( "(C1,C2);" ) ) {
3434 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3435 t13.deleteSubtree( t13.getNode( "D" ), true );
3436 if ( t13.getNumberOfExternalNodes() != 4 ) {
3439 s = w.toNewHampshire( t13, false, true ).toString();
3440 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3443 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3444 t14.deleteSubtree( t14.getNode( "E" ), true );
3445 if ( t14.getNumberOfExternalNodes() != 5 ) {
3448 s = w.toNewHampshire( t14, false, true ).toString();
3449 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3452 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3453 t15.deleteSubtree( t15.getNode( "B2" ), true );
3454 if ( t15.getNumberOfExternalNodes() != 11 ) {
3457 t15.deleteSubtree( t15.getNode( "B1" ), true );
3458 if ( t15.getNumberOfExternalNodes() != 10 ) {
3461 t15.deleteSubtree( t15.getNode( "B3" ), true );
3462 if ( t15.getNumberOfExternalNodes() != 9 ) {
3465 t15.deleteSubtree( t15.getNode( "B4" ), true );
3466 if ( t15.getNumberOfExternalNodes() != 8 ) {
3469 t15.deleteSubtree( t15.getNode( "A1" ), true );
3470 if ( t15.getNumberOfExternalNodes() != 7 ) {
3473 t15.deleteSubtree( t15.getNode( "C4" ), true );
3474 if ( t15.getNumberOfExternalNodes() != 6 ) {
3478 catch ( final Exception e ) {
3479 e.printStackTrace( System.out );
3485 private static boolean testDescriptiveStatistics() {
3487 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3488 dss1.addValue( 82 );
3489 dss1.addValue( 78 );
3490 dss1.addValue( 70 );
3491 dss1.addValue( 58 );
3492 dss1.addValue( 42 );
3493 if ( dss1.getN() != 5 ) {
3496 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3499 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3502 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3505 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3508 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3511 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3514 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3517 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3520 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3523 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3526 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3529 dss1.addValue( 123 );
3530 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3533 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3536 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3539 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3540 dss2.addValue( -1.85 );
3541 dss2.addValue( 57.5 );
3542 dss2.addValue( 92.78 );
3543 dss2.addValue( 57.78 );
3544 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3547 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3550 final double[] a = dss2.getDataAsDoubleArray();
3551 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3554 dss2.addValue( -100 );
3555 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3558 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3561 final double[] ds = new double[ 14 ];
3576 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3577 if ( bins.length != 4 ) {
3580 if ( bins[ 0 ] != 2 ) {
3583 if ( bins[ 1 ] != 3 ) {
3586 if ( bins[ 2 ] != 4 ) {
3589 if ( bins[ 3 ] != 5 ) {
3592 final double[] ds1 = new double[ 9 ];
3602 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3603 if ( bins1.length != 4 ) {
3606 if ( bins1[ 0 ] != 2 ) {
3609 if ( bins1[ 1 ] != 3 ) {
3612 if ( bins1[ 2 ] != 0 ) {
3615 if ( bins1[ 3 ] != 4 ) {
3618 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3619 if ( bins1_1.length != 3 ) {
3622 if ( bins1_1[ 0 ] != 3 ) {
3625 if ( bins1_1[ 1 ] != 2 ) {
3628 if ( bins1_1[ 2 ] != 4 ) {
3631 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3632 if ( bins1_2.length != 3 ) {
3635 if ( bins1_2[ 0 ] != 2 ) {
3638 if ( bins1_2[ 1 ] != 2 ) {
3641 if ( bins1_2[ 2 ] != 2 ) {
3644 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3658 dss3.addValue( 10 );
3659 dss3.addValue( 10 );
3660 dss3.addValue( 10 );
3661 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3662 histo.toStringBuffer( 10, '=', 40, 5 );
3663 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3665 catch ( final Exception e ) {
3666 e.printStackTrace( System.out );
3672 private static boolean testDir( final String file ) {
3674 final File f = new File( file );
3675 if ( !f.exists() ) {
3678 if ( !f.isDirectory() ) {
3681 if ( !f.canRead() ) {
3685 catch ( final Exception e ) {
3691 private static boolean testGenbankAccessorParsing() {
3692 //The format for GenBank Accession numbers are:
3693 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3694 //Protein: 3 letters + 5 numerals
3695 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3696 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3699 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3702 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3705 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3708 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3711 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3714 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3717 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3720 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3723 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3726 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3729 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3732 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3735 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3741 private static boolean testExternalNodeRelatedMethods() {
3743 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3744 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3745 PhylogenyNode n = t1.getNode( "A" );
3746 n = n.getNextExternalNode();
3747 if ( !n.getName().equals( "B" ) ) {
3750 n = n.getNextExternalNode();
3751 if ( !n.getName().equals( "C" ) ) {
3754 n = n.getNextExternalNode();
3755 if ( !n.getName().equals( "D" ) ) {
3758 n = t1.getNode( "B" );
3759 while ( !n.isLastExternalNode() ) {
3760 n = n.getNextExternalNode();
3762 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3763 n = t2.getNode( "A" );
3764 n = n.getNextExternalNode();
3765 if ( !n.getName().equals( "B" ) ) {
3768 n = n.getNextExternalNode();
3769 if ( !n.getName().equals( "C" ) ) {
3772 n = n.getNextExternalNode();
3773 if ( !n.getName().equals( "D" ) ) {
3776 n = t2.getNode( "B" );
3777 while ( !n.isLastExternalNode() ) {
3778 n = n.getNextExternalNode();
3780 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3781 n = t3.getNode( "A" );
3782 n = n.getNextExternalNode();
3783 if ( !n.getName().equals( "B" ) ) {
3786 n = n.getNextExternalNode();
3787 if ( !n.getName().equals( "C" ) ) {
3790 n = n.getNextExternalNode();
3791 if ( !n.getName().equals( "D" ) ) {
3794 n = n.getNextExternalNode();
3795 if ( !n.getName().equals( "E" ) ) {
3798 n = n.getNextExternalNode();
3799 if ( !n.getName().equals( "F" ) ) {
3802 n = n.getNextExternalNode();
3803 if ( !n.getName().equals( "G" ) ) {
3806 n = n.getNextExternalNode();
3807 if ( !n.getName().equals( "H" ) ) {
3810 n = t3.getNode( "B" );
3811 while ( !n.isLastExternalNode() ) {
3812 n = n.getNextExternalNode();
3814 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3815 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3816 final PhylogenyNode node = iter.next();
3818 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3819 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3820 final PhylogenyNode node = iter.next();
3822 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3823 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3824 if ( !iter.next().getName().equals( "A" ) ) {
3827 if ( !iter.next().getName().equals( "B" ) ) {
3830 if ( !iter.next().getName().equals( "C" ) ) {
3833 if ( !iter.next().getName().equals( "D" ) ) {
3836 if ( !iter.next().getName().equals( "E" ) ) {
3839 if ( !iter.next().getName().equals( "F" ) ) {
3842 if ( iter.hasNext() ) {
3846 catch ( final Exception e ) {
3847 e.printStackTrace( System.out );
3853 private static boolean testExtractSNFromNodeName() {
3855 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3858 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3859 .equals( "Mus musculus musculus" ) ) {
3862 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3863 .equals( "Mus musculus musculus" ) ) {
3866 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3869 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3870 .equals( "Mus musculus" ) ) {
3874 catch ( final Exception e ) {
3875 e.printStackTrace( System.out );
3881 private static boolean testExtractTaxonomyCodeFromNodeName() {
3883 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3886 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3887 .equals( "SOYBN" ) ) {
3890 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3891 .equals( "ARATH" ) ) {
3894 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3895 .equals( "ARATH" ) ) {
3898 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3901 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3904 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3907 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3908 .equals( "SOYBN" ) ) {
3911 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3912 .equals( "SOYBN" ) ) {
3915 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3916 .equals( "SOYBN" ) ) {
3919 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3920 .equals( "SOYBN" ) ) {
3923 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3924 .equals( "SOYBN" ) ) {
3927 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3928 .equals( "SOYBN" ) ) {
3931 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3932 .equals( "SOYBN" ) ) {
3935 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3936 .equals( "SOYBN" ) ) {
3939 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3942 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3943 .equals( "SOYBN" ) ) {
3946 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3947 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3950 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3951 .equals( "9YX45" ) ) {
3954 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3955 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3956 .equals( "MOUSE" ) ) {
3959 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3960 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3961 .equals( "MOUSE" ) ) {
3964 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3965 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3966 .equals( "MOUSE" ) ) {
3969 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3970 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3973 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3974 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3977 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3978 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3981 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3982 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3985 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3986 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3989 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3990 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3993 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3994 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3997 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3998 .equals( "RAT" ) ) {
4001 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4002 .equals( "PIG" ) ) {
4006 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4007 .equals( "MOUSE" ) ) {
4010 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4011 .equals( "MOUSE" ) ) {
4014 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4018 catch ( final Exception e ) {
4019 e.printStackTrace( System.out );
4025 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4027 PhylogenyNode n = new PhylogenyNode();
4028 n.setName( "tr|B3RJ64" );
4029 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4032 n.setName( "tr.B3RJ64" );
4033 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4036 n.setName( "tr=B3RJ64" );
4037 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4040 n.setName( "tr-B3RJ64" );
4041 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4044 n.setName( "tr/B3RJ64" );
4045 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4048 n.setName( "tr\\B3RJ64" );
4049 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4052 n.setName( "tr_B3RJ64" );
4053 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4056 n.setName( " tr|B3RJ64 " );
4057 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4060 n.setName( "-tr|B3RJ64-" );
4061 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4064 n.setName( "-tr=B3RJ64-" );
4065 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4068 n.setName( "_tr=B3RJ64_" );
4069 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4072 n.setName( " tr_tr|B3RJ64_sp|123 " );
4073 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4076 n.setName( "B3RJ64" );
4077 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4080 n.setName( "sp|B3RJ64" );
4081 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4084 n.setName( "sp|B3RJ64C" );
4085 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4088 n.setName( "sp B3RJ64" );
4089 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4092 n.setName( "sp|B3RJ6X" );
4093 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4096 n.setName( "sp|B3RJ6" );
4097 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4100 n.setName( "K1PYK7_CRAGI" );
4101 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4104 n.setName( "K1PYK7_PEA" );
4105 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4108 n.setName( "K1PYK7_RAT" );
4109 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4112 n.setName( "K1PYK7_PIG" );
4113 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4116 n.setName( "~K1PYK7_PIG~" );
4117 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4120 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4121 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4124 n.setName( "K1PYKX_CRAGI" );
4125 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4128 n.setName( "XXXXX_CRAGI" );
4129 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4132 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4133 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4136 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4137 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4140 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4141 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4144 n = new PhylogenyNode();
4145 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4146 seq.setSymbol( "K1PYK7_CRAGI" );
4147 n.getNodeData().addSequence( seq );
4148 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4151 seq.setSymbol( "tr|B3RJ64" );
4152 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4155 n = new PhylogenyNode();
4156 seq = new org.forester.phylogeny.data.Sequence();
4157 seq.setName( "K1PYK7_CRAGI" );
4158 n.getNodeData().addSequence( seq );
4159 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4162 seq.setName( "tr|B3RJ64" );
4163 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4166 n = new PhylogenyNode();
4167 seq = new org.forester.phylogeny.data.Sequence();
4168 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4169 n.getNodeData().addSequence( seq );
4170 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4173 n = new PhylogenyNode();
4174 seq = new org.forester.phylogeny.data.Sequence();
4175 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4176 n.getNodeData().addSequence( seq );
4177 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4181 n = new PhylogenyNode();
4182 n.setName( "ACP19736" );
4183 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4186 n = new PhylogenyNode();
4187 n.setName( "|ACP19736|" );
4188 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4192 catch ( final Exception e ) {
4193 e.printStackTrace( System.out );
4199 private static boolean testFastaParser() {
4201 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4204 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4207 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4208 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4211 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4214 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4217 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4220 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4223 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4227 catch ( final Exception e ) {
4228 e.printStackTrace();
4234 private static boolean testGeneralMsaParser() {
4236 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4237 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4238 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4239 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4240 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4241 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4242 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4243 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4244 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4247 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4250 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4253 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4256 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4259 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4262 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4265 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4268 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4271 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4274 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4277 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4280 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4281 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4284 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4287 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4290 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4291 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4294 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4297 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4300 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4301 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4304 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4307 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4311 catch ( final Exception e ) {
4312 e.printStackTrace();
4318 private static boolean testGeneralTable() {
4320 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4321 t0.setValue( 3, 2, "23" );
4322 t0.setValue( 10, 1, "error" );
4323 t0.setValue( 10, 1, "110" );
4324 t0.setValue( 9, 1, "19" );
4325 t0.setValue( 1, 10, "101" );
4326 t0.setValue( 10, 10, "1010" );
4327 t0.setValue( 100, 10, "10100" );
4328 t0.setValue( 0, 0, "00" );
4329 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4332 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4335 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4338 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4341 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4344 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4347 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4350 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4353 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4356 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4357 t1.setValue( "3", "2", "23" );
4358 t1.setValue( "10", "1", "error" );
4359 t1.setValue( "10", "1", "110" );
4360 t1.setValue( "9", "1", "19" );
4361 t1.setValue( "1", "10", "101" );
4362 t1.setValue( "10", "10", "1010" );
4363 t1.setValue( "100", "10", "10100" );
4364 t1.setValue( "0", "0", "00" );
4365 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4366 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4369 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4372 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4375 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4378 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4381 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4384 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4387 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4390 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4393 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4397 catch ( final Exception e ) {
4398 e.printStackTrace( System.out );
4404 private static boolean testGetDistance() {
4406 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4407 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",
4408 new NHXParser() )[ 0 ];
4409 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4412 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4415 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4418 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4421 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4424 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4427 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4430 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4433 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4436 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4439 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4442 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4445 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4448 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4451 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4454 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4457 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4460 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4463 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4466 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4469 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4472 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4475 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4478 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4481 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4484 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4487 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4490 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4493 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4496 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4499 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4502 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",
4503 new NHXParser() )[ 0 ];
4504 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4507 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4510 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4513 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4516 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4519 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4522 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4525 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4528 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4531 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4534 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4538 catch ( final Exception e ) {
4539 e.printStackTrace( System.out );
4545 private static boolean testGetLCA() {
4547 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4548 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4549 new NHXParser() )[ 0 ];
4550 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4551 if ( !A.getName().equals( "A" ) ) {
4554 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4555 if ( !gh.getName().equals( "gh" ) ) {
4558 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4559 if ( !ab.getName().equals( "ab" ) ) {
4562 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4563 if ( !ab2.getName().equals( "ab" ) ) {
4566 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4567 if ( !gh2.getName().equals( "gh" ) ) {
4570 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4571 if ( !gh3.getName().equals( "gh" ) ) {
4574 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4575 if ( !abc.getName().equals( "abc" ) ) {
4578 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4579 if ( !abc2.getName().equals( "abc" ) ) {
4582 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4583 if ( !abcd.getName().equals( "abcd" ) ) {
4586 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4587 if ( !abcd2.getName().equals( "abcd" ) ) {
4590 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4591 if ( !abcdef.getName().equals( "abcdef" ) ) {
4594 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4595 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4598 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4599 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4602 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4603 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4606 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4607 if ( !abcde.getName().equals( "abcde" ) ) {
4610 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4611 if ( !abcde2.getName().equals( "abcde" ) ) {
4614 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4615 if ( !r.getName().equals( "abcdefgh" ) ) {
4618 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4619 if ( !r2.getName().equals( "abcdefgh" ) ) {
4622 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4623 if ( !r3.getName().equals( "abcdefgh" ) ) {
4626 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4627 if ( !abcde3.getName().equals( "abcde" ) ) {
4630 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4631 if ( !abcde4.getName().equals( "abcde" ) ) {
4634 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4635 if ( !ab3.getName().equals( "ab" ) ) {
4638 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4639 if ( !ab4.getName().equals( "ab" ) ) {
4642 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4643 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4644 if ( !cd.getName().equals( "cd" ) ) {
4647 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4648 if ( !cd2.getName().equals( "cd" ) ) {
4651 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4652 if ( !cde.getName().equals( "cde" ) ) {
4655 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4656 if ( !cde2.getName().equals( "cde" ) ) {
4659 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4660 if ( !cdef.getName().equals( "cdef" ) ) {
4663 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4664 if ( !cdef2.getName().equals( "cdef" ) ) {
4667 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4668 if ( !cdef3.getName().equals( "cdef" ) ) {
4671 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4672 if ( !rt.getName().equals( "r" ) ) {
4675 final Phylogeny p3 = factory
4676 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4677 new NHXParser() )[ 0 ];
4678 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4679 if ( !bc_3.getName().equals( "bc" ) ) {
4682 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4683 if ( !ac_3.getName().equals( "abc" ) ) {
4686 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4687 if ( !ad_3.getName().equals( "abcde" ) ) {
4690 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4691 if ( !af_3.getName().equals( "abcdef" ) ) {
4694 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4695 if ( !ag_3.getName().equals( "" ) ) {
4698 if ( !ag_3.isRoot() ) {
4701 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4702 if ( !al_3.getName().equals( "" ) ) {
4705 if ( !al_3.isRoot() ) {
4708 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4709 if ( !kl_3.getName().equals( "" ) ) {
4712 if ( !kl_3.isRoot() ) {
4715 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4716 if ( !fl_3.getName().equals( "" ) ) {
4719 if ( !fl_3.isRoot() ) {
4722 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4723 if ( !gk_3.getName().equals( "ghijk" ) ) {
4726 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4727 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4728 if ( !r_4.getName().equals( "r" ) ) {
4731 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4732 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4733 if ( !r_5.getName().equals( "root" ) ) {
4736 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4737 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4738 if ( !r_6.getName().equals( "rot" ) ) {
4741 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4742 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4743 if ( !r_7.getName().equals( "rott" ) ) {
4747 catch ( final Exception e ) {
4748 e.printStackTrace( System.out );
4754 private static boolean testGetLCA2() {
4756 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4757 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4758 PhylogenyMethods.preOrderReId( p_a );
4759 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4760 p_a.getNode( "a" ) );
4761 if ( !p_a_1.getName().equals( "a" ) ) {
4764 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4765 PhylogenyMethods.preOrderReId( p_b );
4766 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4767 p_b.getNode( "a" ) );
4768 if ( !p_b_1.getName().equals( "b" ) ) {
4771 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4772 p_b.getNode( "b" ) );
4773 if ( !p_b_2.getName().equals( "b" ) ) {
4776 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4777 PhylogenyMethods.preOrderReId( p_c );
4778 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4779 p_c.getNode( "a" ) );
4780 if ( !p_c_1.getName().equals( "b" ) ) {
4783 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4784 p_c.getNode( "c" ) );
4785 if ( !p_c_2.getName().equals( "c" ) ) {
4786 System.out.println( p_c_2.getName() );
4790 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4791 p_c.getNode( "b" ) );
4792 if ( !p_c_3.getName().equals( "b" ) ) {
4795 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4796 p_c.getNode( "a" ) );
4797 if ( !p_c_4.getName().equals( "c" ) ) {
4800 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4801 new NHXParser() )[ 0 ];
4802 PhylogenyMethods.preOrderReId( p1 );
4803 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4804 p1.getNode( "A" ) );
4805 if ( !A.getName().equals( "A" ) ) {
4808 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4809 p1.getNode( "gh" ) );
4810 if ( !gh.getName().equals( "gh" ) ) {
4813 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4814 p1.getNode( "B" ) );
4815 if ( !ab.getName().equals( "ab" ) ) {
4818 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4819 p1.getNode( "A" ) );
4820 if ( !ab2.getName().equals( "ab" ) ) {
4823 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4824 p1.getNode( "G" ) );
4825 if ( !gh2.getName().equals( "gh" ) ) {
4828 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4829 p1.getNode( "H" ) );
4830 if ( !gh3.getName().equals( "gh" ) ) {
4833 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4834 p1.getNode( "A" ) );
4835 if ( !abc.getName().equals( "abc" ) ) {
4838 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4839 p1.getNode( "C" ) );
4840 if ( !abc2.getName().equals( "abc" ) ) {
4843 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4844 p1.getNode( "D" ) );
4845 if ( !abcd.getName().equals( "abcd" ) ) {
4848 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4849 p1.getNode( "A" ) );
4850 if ( !abcd2.getName().equals( "abcd" ) ) {
4853 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4854 p1.getNode( "F" ) );
4855 if ( !abcdef.getName().equals( "abcdef" ) ) {
4858 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4859 p1.getNode( "A" ) );
4860 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4863 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4864 p1.getNode( "F" ) );
4865 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4868 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4869 p1.getNode( "ab" ) );
4870 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4873 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4874 p1.getNode( "E" ) );
4875 if ( !abcde.getName().equals( "abcde" ) ) {
4878 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4879 p1.getNode( "A" ) );
4880 if ( !abcde2.getName().equals( "abcde" ) ) {
4883 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4884 p1.getNode( "abcdefgh" ) );
4885 if ( !r.getName().equals( "abcdefgh" ) ) {
4888 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4889 p1.getNode( "H" ) );
4890 if ( !r2.getName().equals( "abcdefgh" ) ) {
4893 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4894 p1.getNode( "A" ) );
4895 if ( !r3.getName().equals( "abcdefgh" ) ) {
4898 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4899 p1.getNode( "abcde" ) );
4900 if ( !abcde3.getName().equals( "abcde" ) ) {
4903 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4904 p1.getNode( "E" ) );
4905 if ( !abcde4.getName().equals( "abcde" ) ) {
4908 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4909 p1.getNode( "B" ) );
4910 if ( !ab3.getName().equals( "ab" ) ) {
4913 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4914 p1.getNode( "ab" ) );
4915 if ( !ab4.getName().equals( "ab" ) ) {
4918 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4919 PhylogenyMethods.preOrderReId( p2 );
4920 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4921 p2.getNode( "d" ) );
4922 if ( !cd.getName().equals( "cd" ) ) {
4925 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4926 p2.getNode( "c" ) );
4927 if ( !cd2.getName().equals( "cd" ) ) {
4930 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4931 p2.getNode( "e" ) );
4932 if ( !cde.getName().equals( "cde" ) ) {
4935 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4936 p2.getNode( "c" ) );
4937 if ( !cde2.getName().equals( "cde" ) ) {
4940 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4941 p2.getNode( "f" ) );
4942 if ( !cdef.getName().equals( "cdef" ) ) {
4945 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4946 p2.getNode( "f" ) );
4947 if ( !cdef2.getName().equals( "cdef" ) ) {
4950 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4951 p2.getNode( "d" ) );
4952 if ( !cdef3.getName().equals( "cdef" ) ) {
4955 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4956 p2.getNode( "a" ) );
4957 if ( !rt.getName().equals( "r" ) ) {
4960 final Phylogeny p3 = factory
4961 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4962 new NHXParser() )[ 0 ];
4963 PhylogenyMethods.preOrderReId( p3 );
4964 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4965 p3.getNode( "c" ) );
4966 if ( !bc_3.getName().equals( "bc" ) ) {
4969 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4970 p3.getNode( "c" ) );
4971 if ( !ac_3.getName().equals( "abc" ) ) {
4974 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4975 p3.getNode( "d" ) );
4976 if ( !ad_3.getName().equals( "abcde" ) ) {
4979 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4980 p3.getNode( "f" ) );
4981 if ( !af_3.getName().equals( "abcdef" ) ) {
4984 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4985 p3.getNode( "g" ) );
4986 if ( !ag_3.getName().equals( "" ) ) {
4989 if ( !ag_3.isRoot() ) {
4992 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4993 p3.getNode( "l" ) );
4994 if ( !al_3.getName().equals( "" ) ) {
4997 if ( !al_3.isRoot() ) {
5000 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5001 p3.getNode( "l" ) );
5002 if ( !kl_3.getName().equals( "" ) ) {
5005 if ( !kl_3.isRoot() ) {
5008 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5009 p3.getNode( "l" ) );
5010 if ( !fl_3.getName().equals( "" ) ) {
5013 if ( !fl_3.isRoot() ) {
5016 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5017 p3.getNode( "k" ) );
5018 if ( !gk_3.getName().equals( "ghijk" ) ) {
5021 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5022 PhylogenyMethods.preOrderReId( p4 );
5023 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5024 p4.getNode( "c" ) );
5025 if ( !r_4.getName().equals( "r" ) ) {
5028 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5029 PhylogenyMethods.preOrderReId( p5 );
5030 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5031 p5.getNode( "c" ) );
5032 if ( !r_5.getName().equals( "root" ) ) {
5035 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5036 PhylogenyMethods.preOrderReId( p6 );
5037 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5038 p6.getNode( "a" ) );
5039 if ( !r_6.getName().equals( "rot" ) ) {
5042 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5043 PhylogenyMethods.preOrderReId( p7 );
5044 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5045 p7.getNode( "e" ) );
5046 if ( !r_7.getName().equals( "rott" ) ) {
5049 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5050 p7.getNode( "a" ) );
5051 if ( !r_71.getName().equals( "rott" ) ) {
5054 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5055 p7.getNode( "rott" ) );
5056 if ( !r_72.getName().equals( "rott" ) ) {
5059 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5060 p7.getNode( "a" ) );
5061 if ( !r_73.getName().equals( "rott" ) ) {
5064 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5065 p7.getNode( "rott" ) );
5066 if ( !r_74.getName().equals( "rott" ) ) {
5069 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5070 p7.getNode( "e" ) );
5071 if ( !r_75.getName().equals( "e" ) ) {
5075 catch ( final Exception e ) {
5076 e.printStackTrace( System.out );
5082 private static boolean testHmmscanOutputParser() {
5083 final String test_dir = Test.PATH_TO_TEST_DATA;
5085 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5086 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5088 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5089 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5090 final List<Protein> proteins = parser2.parse();
5091 if ( parser2.getProteinsEncountered() != 4 ) {
5094 if ( proteins.size() != 4 ) {
5097 if ( parser2.getDomainsEncountered() != 69 ) {
5100 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5103 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
5106 final Protein p1 = proteins.get( 0 );
5107 if ( p1.getNumberOfProteinDomains() != 15 ) {
5110 if ( p1.getLength() != 850 ) {
5113 final Protein p2 = proteins.get( 1 );
5114 if ( p2.getNumberOfProteinDomains() != 51 ) {
5117 if ( p2.getLength() != 1291 ) {
5120 final Protein p3 = proteins.get( 2 );
5121 if ( p3.getNumberOfProteinDomains() != 2 ) {
5124 final Protein p4 = proteins.get( 3 );
5125 if ( p4.getNumberOfProteinDomains() != 1 ) {
5128 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5131 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5134 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5137 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5140 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5143 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
5146 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
5149 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5152 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5156 catch ( final Exception e ) {
5157 e.printStackTrace( System.out );
5163 private static boolean testLastExternalNodeMethods() {
5165 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5166 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5167 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5168 final PhylogenyNode n1 = t0.getNode( "A" );
5169 if ( n1.isLastExternalNode() ) {
5172 final PhylogenyNode n2 = t0.getNode( "B" );
5173 if ( n2.isLastExternalNode() ) {
5176 final PhylogenyNode n3 = t0.getNode( "C" );
5177 if ( n3.isLastExternalNode() ) {
5180 final PhylogenyNode n4 = t0.getNode( "D" );
5181 if ( !n4.isLastExternalNode() ) {
5185 catch ( final Exception e ) {
5186 e.printStackTrace( System.out );
5192 private static boolean testLevelOrderIterator() {
5194 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5195 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5196 PhylogenyNodeIterator it0;
5197 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5200 for( it0.reset(); it0.hasNext(); ) {
5203 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5204 if ( !it.next().getName().equals( "r" ) ) {
5207 if ( !it.next().getName().equals( "ab" ) ) {
5210 if ( !it.next().getName().equals( "cd" ) ) {
5213 if ( !it.next().getName().equals( "A" ) ) {
5216 if ( !it.next().getName().equals( "B" ) ) {
5219 if ( !it.next().getName().equals( "C" ) ) {
5222 if ( !it.next().getName().equals( "D" ) ) {
5225 if ( it.hasNext() ) {
5228 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",
5229 new NHXParser() )[ 0 ];
5230 PhylogenyNodeIterator it2;
5231 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5234 for( it2.reset(); it2.hasNext(); ) {
5237 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5238 if ( !it3.next().getName().equals( "r" ) ) {
5241 if ( !it3.next().getName().equals( "abc" ) ) {
5244 if ( !it3.next().getName().equals( "defg" ) ) {
5247 if ( !it3.next().getName().equals( "A" ) ) {
5250 if ( !it3.next().getName().equals( "B" ) ) {
5253 if ( !it3.next().getName().equals( "C" ) ) {
5256 if ( !it3.next().getName().equals( "D" ) ) {
5259 if ( !it3.next().getName().equals( "E" ) ) {
5262 if ( !it3.next().getName().equals( "F" ) ) {
5265 if ( !it3.next().getName().equals( "G" ) ) {
5268 if ( !it3.next().getName().equals( "1" ) ) {
5271 if ( !it3.next().getName().equals( "2" ) ) {
5274 if ( !it3.next().getName().equals( "3" ) ) {
5277 if ( !it3.next().getName().equals( "4" ) ) {
5280 if ( !it3.next().getName().equals( "5" ) ) {
5283 if ( !it3.next().getName().equals( "6" ) ) {
5286 if ( !it3.next().getName().equals( "f1" ) ) {
5289 if ( !it3.next().getName().equals( "f2" ) ) {
5292 if ( !it3.next().getName().equals( "f3" ) ) {
5295 if ( !it3.next().getName().equals( "a" ) ) {
5298 if ( !it3.next().getName().equals( "b" ) ) {
5301 if ( !it3.next().getName().equals( "f21" ) ) {
5304 if ( !it3.next().getName().equals( "X" ) ) {
5307 if ( !it3.next().getName().equals( "Y" ) ) {
5310 if ( !it3.next().getName().equals( "Z" ) ) {
5313 if ( it3.hasNext() ) {
5316 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5317 PhylogenyNodeIterator it4;
5318 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5321 for( it4.reset(); it4.hasNext(); ) {
5324 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5325 if ( !it5.next().getName().equals( "r" ) ) {
5328 if ( !it5.next().getName().equals( "A" ) ) {
5331 if ( !it5.next().getName().equals( "B" ) ) {
5334 if ( !it5.next().getName().equals( "C" ) ) {
5337 if ( !it5.next().getName().equals( "D" ) ) {
5340 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5341 PhylogenyNodeIterator it6;
5342 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5345 for( it6.reset(); it6.hasNext(); ) {
5348 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5349 if ( !it7.next().getName().equals( "A" ) ) {
5352 if ( it.hasNext() ) {
5356 catch ( final Exception e ) {
5357 e.printStackTrace( System.out );
5363 private static boolean testMafft( final String path ) {
5365 final List<String> opts = new ArrayList<String>();
5366 opts.add( "--maxiterate" );
5368 opts.add( "--localpair" );
5369 opts.add( "--quiet" );
5371 final MsaInferrer mafft = Mafft.createInstance( path );
5372 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5373 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5376 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5380 catch ( final Exception e ) {
5381 e.printStackTrace( System.out );
5387 private static boolean testMidpointrooting() {
5389 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5390 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5391 PhylogenyMethods.midpointRoot( t0 );
5392 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5395 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5398 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5402 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",
5403 new NHXParser() )[ 0 ];
5404 if ( !t1.isRooted() ) {
5407 PhylogenyMethods.midpointRoot( t1 );
5408 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5411 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5414 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5417 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5420 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5423 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5426 t1.reRoot( t1.getNode( "A" ) );
5427 PhylogenyMethods.midpointRoot( t1 );
5428 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5431 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5434 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5437 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5440 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5444 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5448 catch ( final Exception e ) {
5449 e.printStackTrace( System.out );
5455 private static boolean testMsaQualityMethod() {
5457 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5458 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5459 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5460 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5461 final List<Sequence> l = new ArrayList<Sequence>();
5466 final Msa msa = BasicMsa.createInstance( l );
5467 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5470 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5473 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5476 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5480 catch ( final Exception e ) {
5481 e.printStackTrace( System.out );
5487 private static boolean testNextNodeWithCollapsing() {
5489 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5491 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5492 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5493 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5494 t0.getNode( "cd" ).setCollapse( true );
5495 t0.getNode( "cde" ).setCollapse( true );
5496 n = t0.getFirstExternalNode();
5497 while ( n != null ) {
5499 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5501 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5504 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5507 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5510 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5513 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5516 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5520 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5521 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5522 t1.getNode( "ab" ).setCollapse( true );
5523 t1.getNode( "cd" ).setCollapse( true );
5524 t1.getNode( "cde" ).setCollapse( true );
5525 n = t1.getNode( "ab" );
5526 ext = new ArrayList<PhylogenyNode>();
5527 while ( n != null ) {
5529 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5531 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5534 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5537 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5540 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5543 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5549 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5550 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5551 t2.getNode( "ab" ).setCollapse( true );
5552 t2.getNode( "cd" ).setCollapse( true );
5553 t2.getNode( "cde" ).setCollapse( true );
5554 t2.getNode( "c" ).setCollapse( true );
5555 t2.getNode( "d" ).setCollapse( true );
5556 t2.getNode( "e" ).setCollapse( true );
5557 t2.getNode( "gh" ).setCollapse( true );
5558 n = t2.getNode( "ab" );
5559 ext = new ArrayList<PhylogenyNode>();
5560 while ( n != null ) {
5562 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5564 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5567 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5570 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5573 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5579 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5580 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5581 t3.getNode( "ab" ).setCollapse( true );
5582 t3.getNode( "cd" ).setCollapse( true );
5583 t3.getNode( "cde" ).setCollapse( true );
5584 t3.getNode( "c" ).setCollapse( true );
5585 t3.getNode( "d" ).setCollapse( true );
5586 t3.getNode( "e" ).setCollapse( true );
5587 t3.getNode( "gh" ).setCollapse( true );
5588 t3.getNode( "fgh" ).setCollapse( true );
5589 n = t3.getNode( "ab" );
5590 ext = new ArrayList<PhylogenyNode>();
5591 while ( n != null ) {
5593 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5595 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5598 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5601 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5607 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5608 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5609 t4.getNode( "ab" ).setCollapse( true );
5610 t4.getNode( "cd" ).setCollapse( true );
5611 t4.getNode( "cde" ).setCollapse( true );
5612 t4.getNode( "c" ).setCollapse( true );
5613 t4.getNode( "d" ).setCollapse( true );
5614 t4.getNode( "e" ).setCollapse( true );
5615 t4.getNode( "gh" ).setCollapse( true );
5616 t4.getNode( "fgh" ).setCollapse( true );
5617 t4.getNode( "abcdefgh" ).setCollapse( true );
5618 n = t4.getNode( "abcdefgh" );
5619 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5624 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5625 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5627 n = t5.getFirstExternalNode();
5628 while ( n != null ) {
5630 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5632 if ( ext.size() != 8 ) {
5635 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5638 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5641 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5644 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5647 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5650 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5653 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5656 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5661 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5662 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5664 t6.getNode( "ab" ).setCollapse( true );
5665 n = t6.getNode( "ab" );
5666 while ( n != null ) {
5668 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5670 if ( ext.size() != 7 ) {
5673 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5676 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5679 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5682 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5685 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5688 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5691 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5696 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5697 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5699 t7.getNode( "cd" ).setCollapse( true );
5700 n = t7.getNode( "a" );
5701 while ( n != null ) {
5703 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5705 if ( ext.size() != 7 ) {
5708 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5711 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5714 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
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 sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5732 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5734 t8.getNode( "cd" ).setCollapse( true );
5735 t8.getNode( "c" ).setCollapse( true );
5736 t8.getNode( "d" ).setCollapse( true );
5737 n = t8.getNode( "a" );
5738 while ( n != null ) {
5740 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5742 if ( ext.size() != 7 ) {
5745 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5748 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5751 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5752 System.out.println( "2 fail" );
5755 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5758 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5761 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5764 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5769 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5770 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5772 t9.getNode( "gh" ).setCollapse( true );
5773 n = t9.getNode( "a" );
5774 while ( n != null ) {
5776 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5778 if ( ext.size() != 7 ) {
5781 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5784 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5787 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5790 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5793 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5796 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5799 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5804 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5805 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5807 t10.getNode( "gh" ).setCollapse( true );
5808 t10.getNode( "g" ).setCollapse( true );
5809 t10.getNode( "h" ).setCollapse( true );
5810 n = t10.getNode( "a" );
5811 while ( n != null ) {
5813 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5815 if ( ext.size() != 7 ) {
5818 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5821 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5824 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5827 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5830 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5833 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5836 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5841 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5842 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5844 t11.getNode( "gh" ).setCollapse( true );
5845 t11.getNode( "fgh" ).setCollapse( true );
5846 n = t11.getNode( "a" );
5847 while ( n != null ) {
5849 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5851 if ( ext.size() != 6 ) {
5854 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5857 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5860 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5863 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5866 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5869 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5874 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5875 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5877 t12.getNode( "gh" ).setCollapse( true );
5878 t12.getNode( "fgh" ).setCollapse( true );
5879 t12.getNode( "g" ).setCollapse( true );
5880 t12.getNode( "h" ).setCollapse( true );
5881 t12.getNode( "f" ).setCollapse( true );
5882 n = t12.getNode( "a" );
5883 while ( n != null ) {
5885 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5887 if ( ext.size() != 6 ) {
5890 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5893 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5896 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5899 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5902 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5905 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5910 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5911 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5913 t13.getNode( "ab" ).setCollapse( true );
5914 t13.getNode( "b" ).setCollapse( true );
5915 t13.getNode( "fgh" ).setCollapse( true );
5916 t13.getNode( "gh" ).setCollapse( true );
5917 n = t13.getNode( "ab" );
5918 while ( n != null ) {
5920 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5922 if ( ext.size() != 5 ) {
5925 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5928 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5931 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5934 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5937 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5942 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5943 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5945 t14.getNode( "ab" ).setCollapse( true );
5946 t14.getNode( "a" ).setCollapse( true );
5947 t14.getNode( "fgh" ).setCollapse( true );
5948 t14.getNode( "gh" ).setCollapse( true );
5949 n = t14.getNode( "ab" );
5950 while ( n != null ) {
5952 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5954 if ( ext.size() != 5 ) {
5957 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5960 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5963 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5966 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5969 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5974 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" );
5975 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5977 t15.getNode( "ab" ).setCollapse( true );
5978 t15.getNode( "a" ).setCollapse( true );
5979 t15.getNode( "fgh" ).setCollapse( true );
5980 t15.getNode( "gh" ).setCollapse( true );
5981 n = t15.getNode( "ab" );
5982 while ( n != null ) {
5984 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5986 if ( ext.size() != 6 ) {
5989 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5992 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5995 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5998 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6001 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6004 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6009 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" );
6010 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6012 t16.getNode( "ab" ).setCollapse( true );
6013 t16.getNode( "a" ).setCollapse( true );
6014 t16.getNode( "fgh" ).setCollapse( true );
6015 t16.getNode( "gh" ).setCollapse( true );
6016 t16.getNode( "cd" ).setCollapse( true );
6017 t16.getNode( "cde" ).setCollapse( true );
6018 t16.getNode( "d" ).setCollapse( true );
6019 t16.getNode( "x" ).setCollapse( true );
6020 n = t16.getNode( "ab" );
6021 while ( n != null ) {
6023 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6025 if ( ext.size() != 4 ) {
6028 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6031 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6034 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6037 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6041 catch ( final Exception e ) {
6042 e.printStackTrace( System.out );
6048 private static boolean testNexusCharactersParsing() {
6050 final NexusCharactersParser parser = new NexusCharactersParser();
6051 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6053 String[] labels = parser.getCharStateLabels();
6054 if ( labels.length != 7 ) {
6057 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6060 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6063 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6066 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6069 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6072 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6075 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6078 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6080 labels = parser.getCharStateLabels();
6081 if ( labels.length != 7 ) {
6084 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6087 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6090 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6093 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6096 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6099 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6102 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6106 catch ( final Exception e ) {
6107 e.printStackTrace( System.out );
6113 private static boolean testNexusMatrixParsing() {
6115 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6116 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6118 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6119 if ( m.getNumberOfCharacters() != 9 ) {
6122 if ( m.getNumberOfIdentifiers() != 5 ) {
6125 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6128 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6131 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6134 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6137 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6140 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6143 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6146 // if ( labels.length != 7 ) {
6149 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6152 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6155 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6158 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6161 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6164 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6167 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6170 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6172 // labels = parser.getCharStateLabels();
6173 // if ( labels.length != 7 ) {
6176 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6179 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6182 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6185 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6188 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6191 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6194 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6198 catch ( final Exception e ) {
6199 e.printStackTrace( System.out );
6205 private static boolean testNexusTreeParsing() {
6207 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6208 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6209 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6210 if ( phylogenies.length != 1 ) {
6213 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6216 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6220 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6221 if ( phylogenies.length != 1 ) {
6224 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6227 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6231 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6232 if ( phylogenies.length != 1 ) {
6235 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6238 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6241 if ( phylogenies[ 0 ].isRooted() ) {
6245 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6246 if ( phylogenies.length != 18 ) {
6249 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6252 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6255 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6258 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6261 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6264 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6267 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6270 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6273 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6276 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6279 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6282 if ( phylogenies[ 8 ].isRooted() ) {
6285 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6288 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6291 if ( !phylogenies[ 9 ].isRooted() ) {
6294 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6297 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6300 if ( !phylogenies[ 10 ].isRooted() ) {
6303 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6306 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6309 if ( phylogenies[ 11 ].isRooted() ) {
6312 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6315 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6318 if ( !phylogenies[ 12 ].isRooted() ) {
6321 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6324 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6327 if ( !phylogenies[ 13 ].isRooted() ) {
6330 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6333 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6336 if ( !phylogenies[ 14 ].isRooted() ) {
6339 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6342 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6345 if ( phylogenies[ 15 ].isRooted() ) {
6348 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6351 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6354 if ( !phylogenies[ 16 ].isRooted() ) {
6357 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6360 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6363 if ( phylogenies[ 17 ].isRooted() ) {
6366 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6370 catch ( final Exception e ) {
6371 e.printStackTrace( System.out );
6377 private static boolean testNexusTreeParsingIterating() {
6379 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6380 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6381 if ( !p.hasNext() ) {
6384 Phylogeny phy = p.next();
6385 if ( phy == null ) {
6388 if ( phy.getNumberOfExternalNodes() != 25 ) {
6391 if ( !phy.getName().equals( "" ) ) {
6394 if ( p.hasNext() ) {
6398 if ( phy != null ) {
6403 if ( !p.hasNext() ) {
6407 if ( phy == null ) {
6410 if ( phy.getNumberOfExternalNodes() != 25 ) {
6413 if ( !phy.getName().equals( "" ) ) {
6416 if ( p.hasNext() ) {
6420 if ( phy != null ) {
6424 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6425 if ( !p.hasNext() ) {
6429 if ( phy == null ) {
6432 if ( phy.getNumberOfExternalNodes() != 10 ) {
6435 if ( !phy.getName().equals( "name" ) ) {
6438 if ( p.hasNext() ) {
6442 if ( phy != null ) {
6447 if ( !p.hasNext() ) {
6451 if ( phy == null ) {
6454 if ( phy.getNumberOfExternalNodes() != 10 ) {
6457 if ( !phy.getName().equals( "name" ) ) {
6460 if ( p.hasNext() ) {
6464 if ( phy != null ) {
6468 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6469 if ( !p.hasNext() ) {
6473 if ( phy == null ) {
6476 if ( phy.getNumberOfExternalNodes() != 3 ) {
6479 if ( !phy.getName().equals( "" ) ) {
6482 if ( phy.isRooted() ) {
6485 if ( p.hasNext() ) {
6489 if ( phy != null ) {
6494 if ( !p.hasNext() ) {
6498 if ( phy == null ) {
6501 if ( phy.getNumberOfExternalNodes() != 3 ) {
6504 if ( !phy.getName().equals( "" ) ) {
6507 if ( p.hasNext() ) {
6511 if ( phy != null ) {
6515 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6516 // if ( phylogenies.length != 18 ) {
6520 if ( !p.hasNext() ) {
6524 if ( phy == null ) {
6527 if ( phy.getNumberOfExternalNodes() != 10 ) {
6530 if ( !phy.getName().equals( "tree 0" ) ) {
6534 if ( !p.hasNext() ) {
6538 if ( phy == null ) {
6541 if ( phy.getNumberOfExternalNodes() != 10 ) {
6544 if ( !phy.getName().equals( "tree 1" ) ) {
6548 if ( !p.hasNext() ) {
6552 if ( phy == null ) {
6555 if ( phy.getNumberOfExternalNodes() != 3 ) {
6558 if ( !phy.getName().equals( "" ) ) {
6561 if ( phy.isRooted() ) {
6565 if ( !p.hasNext() ) {
6569 if ( phy == null ) {
6572 if ( phy.getNumberOfExternalNodes() != 4 ) {
6575 if ( !phy.getName().equals( "" ) ) {
6578 if ( !phy.isRooted() ) {
6582 if ( !p.hasNext() ) {
6586 if ( phy == null ) {
6589 if ( phy.getNumberOfExternalNodes() != 5 ) {
6590 System.out.println( phy.getNumberOfExternalNodes() );
6593 if ( !phy.getName().equals( "" ) ) {
6596 if ( !phy.isRooted() ) {
6600 if ( !p.hasNext() ) {
6604 if ( phy == null ) {
6607 if ( phy.getNumberOfExternalNodes() != 3 ) {
6610 if ( !phy.getName().equals( "" ) ) {
6613 if ( phy.isRooted() ) {
6617 if ( !p.hasNext() ) {
6621 if ( phy == null ) {
6624 if ( phy.getNumberOfExternalNodes() != 2 ) {
6627 if ( !phy.getName().equals( "" ) ) {
6630 if ( !phy.isRooted() ) {
6634 if ( !p.hasNext() ) {
6638 if ( phy.getNumberOfExternalNodes() != 3 ) {
6641 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6644 if ( !phy.isRooted() ) {
6648 if ( !p.hasNext() ) {
6652 if ( phy.getNumberOfExternalNodes() != 3 ) {
6655 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6658 if ( !phy.getName().equals( "tree 8" ) ) {
6662 if ( !p.hasNext() ) {
6666 if ( phy.getNumberOfExternalNodes() != 3 ) {
6669 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6672 if ( !phy.getName().equals( "tree 9" ) ) {
6676 if ( !p.hasNext() ) {
6680 if ( phy.getNumberOfExternalNodes() != 3 ) {
6683 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6686 if ( !phy.getName().equals( "tree 10" ) ) {
6689 if ( !phy.isRooted() ) {
6693 if ( !p.hasNext() ) {
6697 if ( phy.getNumberOfExternalNodes() != 3 ) {
6700 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6703 if ( !phy.getName().equals( "tree 11" ) ) {
6706 if ( phy.isRooted() ) {
6710 if ( !p.hasNext() ) {
6714 if ( phy.getNumberOfExternalNodes() != 3 ) {
6717 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6720 if ( !phy.getName().equals( "tree 12" ) ) {
6723 if ( !phy.isRooted() ) {
6727 if ( !p.hasNext() ) {
6731 if ( phy.getNumberOfExternalNodes() != 3 ) {
6734 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6737 if ( !phy.getName().equals( "tree 13" ) ) {
6740 if ( !phy.isRooted() ) {
6744 if ( !p.hasNext() ) {
6748 if ( phy.getNumberOfExternalNodes() != 10 ) {
6749 System.out.println( phy.getNumberOfExternalNodes() );
6754 .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;" ) ) {
6755 System.out.println( phy.toNewHampshire() );
6758 if ( !phy.getName().equals( "tree 14" ) ) {
6761 if ( !phy.isRooted() ) {
6765 if ( !p.hasNext() ) {
6769 if ( phy.getNumberOfExternalNodes() != 10 ) {
6770 System.out.println( phy.getNumberOfExternalNodes() );
6775 .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;" ) ) {
6776 System.out.println( phy.toNewHampshire() );
6779 if ( !phy.getName().equals( "tree 15" ) ) {
6782 if ( phy.isRooted() ) {
6786 if ( !p.hasNext() ) {
6790 if ( phy.getNumberOfExternalNodes() != 10 ) {
6791 System.out.println( phy.getNumberOfExternalNodes() );
6796 .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;" ) ) {
6797 System.out.println( phy.toNewHampshire() );
6800 if ( !phy.getName().equals( "tree 16" ) ) {
6803 if ( !phy.isRooted() ) {
6807 if ( !p.hasNext() ) {
6811 if ( phy.getNumberOfExternalNodes() != 10 ) {
6812 System.out.println( phy.getNumberOfExternalNodes() );
6817 .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;" ) ) {
6818 System.out.println( phy.toNewHampshire() );
6821 if ( !phy.getName().equals( "tree 17" ) ) {
6824 if ( phy.isRooted() ) {
6828 if ( p.hasNext() ) {
6832 if ( phy != null ) {
6837 if ( !p.hasNext() ) {
6841 if ( phy == null ) {
6844 if ( phy.getNumberOfExternalNodes() != 10 ) {
6847 if ( !phy.getName().equals( "tree 0" ) ) {
6851 if ( !p.hasNext() ) {
6855 if ( phy == null ) {
6858 if ( phy.getNumberOfExternalNodes() != 10 ) {
6861 if ( !phy.getName().equals( "tree 1" ) ) {
6865 if ( !p.hasNext() ) {
6869 if ( phy == null ) {
6872 if ( phy.getNumberOfExternalNodes() != 3 ) {
6875 if ( !phy.getName().equals( "" ) ) {
6878 if ( phy.isRooted() ) {
6882 if ( !p.hasNext() ) {
6886 if ( phy == null ) {
6889 if ( phy.getNumberOfExternalNodes() != 4 ) {
6892 if ( !phy.getName().equals( "" ) ) {
6895 if ( !phy.isRooted() ) {
6899 if ( !p.hasNext() ) {
6903 if ( phy == null ) {
6906 if ( phy.getNumberOfExternalNodes() != 5 ) {
6907 System.out.println( phy.getNumberOfExternalNodes() );
6910 if ( !phy.getName().equals( "" ) ) {
6913 if ( !phy.isRooted() ) {
6917 if ( !p.hasNext() ) {
6921 if ( phy == null ) {
6924 if ( phy.getNumberOfExternalNodes() != 3 ) {
6927 if ( !phy.getName().equals( "" ) ) {
6930 if ( phy.isRooted() ) {
6934 catch ( final Exception e ) {
6935 e.printStackTrace( System.out );
6941 private static boolean testNexusTreeParsingTranslating() {
6943 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6944 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6945 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6946 if ( phylogenies.length != 1 ) {
6949 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6952 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6955 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6958 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6961 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6962 .equals( "Aranaeus" ) ) {
6966 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6967 if ( phylogenies.length != 3 ) {
6970 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6973 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6976 if ( phylogenies[ 0 ].isRooted() ) {
6979 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6982 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6985 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6986 .equals( "Aranaeus" ) ) {
6989 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6992 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6995 if ( phylogenies[ 1 ].isRooted() ) {
6998 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7001 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7004 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7005 .equals( "Aranaeus" ) ) {
7008 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7011 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7014 if ( !phylogenies[ 2 ].isRooted() ) {
7017 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7020 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7023 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7024 .equals( "Aranaeus" ) ) {
7028 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7029 if ( phylogenies.length != 3 ) {
7032 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7035 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7038 if ( phylogenies[ 0 ].isRooted() ) {
7041 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7044 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7047 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7048 .equals( "Aranaeus" ) ) {
7051 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7054 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7057 if ( phylogenies[ 1 ].isRooted() ) {
7060 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7063 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7066 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7067 .equals( "Aranaeus" ) ) {
7070 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7073 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7076 if ( !phylogenies[ 2 ].isRooted() ) {
7079 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7082 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7085 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7086 .equals( "Aranaeus" ) ) {
7090 catch ( final Exception e ) {
7091 e.printStackTrace( System.out );
7097 private static boolean testNHParsing() {
7099 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7100 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7101 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7104 final NHXParser nhxp = new NHXParser();
7105 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7106 nhxp.setReplaceUnderscores( true );
7107 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7108 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7111 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7114 final Phylogeny p1b = factory
7115 .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 ",
7116 new NHXParser() )[ 0 ];
7117 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7120 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7123 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7124 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7125 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7126 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7127 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7128 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7129 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7130 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7131 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7132 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7133 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7134 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7135 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7137 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7140 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7143 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7146 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7149 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7150 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7151 final String p16_S = "((A,B),C)";
7152 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7153 if ( p16.length != 1 ) {
7156 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7159 final String p17_S = "(C,(A,B))";
7160 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7161 if ( p17.length != 1 ) {
7164 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7167 final String p18_S = "((A,B),(C,D))";
7168 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7169 if ( p18.length != 1 ) {
7172 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7175 final String p19_S = "(((A,B),C),D)";
7176 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7177 if ( p19.length != 1 ) {
7180 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7183 final String p20_S = "(A,(B,(C,D)))";
7184 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7185 if ( p20.length != 1 ) {
7188 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7191 final String p21_S = "(A,(B,(C,(D,E))))";
7192 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7193 if ( p21.length != 1 ) {
7196 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7199 final String p22_S = "((((A,B),C),D),E)";
7200 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7201 if ( p22.length != 1 ) {
7204 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7207 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7208 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7209 if ( p23.length != 1 ) {
7210 System.out.println( "xl=" + p23.length );
7214 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7217 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7218 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7219 if ( p24.length != 1 ) {
7222 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7225 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7226 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7227 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7228 if ( p241.length != 2 ) {
7231 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7234 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7237 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7238 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7239 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7240 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7241 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7242 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7243 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7244 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7245 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7246 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7249 final String p26_S = "(A,B)ab";
7250 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7251 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7254 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7255 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7256 if ( p27s.length != 1 ) {
7257 System.out.println( "xxl=" + p27s.length );
7261 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7262 System.out.println( p27s[ 0 ].toNewHampshireX() );
7266 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7268 if ( p27.length != 1 ) {
7269 System.out.println( "yl=" + p27.length );
7273 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7274 System.out.println( p27[ 0 ].toNewHampshireX() );
7278 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7279 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7280 final String p28_S3 = "(A,B)ab";
7281 final String p28_S4 = "((((A,B),C),D),;E;)";
7282 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7284 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7287 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7290 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7293 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7296 if ( p28.length != 4 ) {
7299 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";
7300 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7301 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7304 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";
7305 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7306 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7309 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7310 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7311 if ( ( p32.length != 0 ) ) {
7314 final String p33_S = "A";
7315 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7316 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7319 final String p34_S = "B;";
7320 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7321 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7324 final String p35_S = "B:0.2";
7325 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7326 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7329 final String p36_S = "(A)";
7330 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7331 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7334 final String p37_S = "((A))";
7335 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7336 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7339 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7340 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7341 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7344 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7345 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7346 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7349 final String p40_S = "(A,B,C)";
7350 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7351 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7354 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7355 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7356 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7359 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7360 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7361 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7364 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)";
7365 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7366 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7369 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)))";
7370 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7371 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7374 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7375 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7376 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7379 final String p46_S = "";
7380 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7381 if ( p46.length != 0 ) {
7384 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7385 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7388 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7389 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7392 final Phylogeny p49 = factory
7393 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7394 new NHXParser() )[ 0 ];
7395 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7398 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7399 if ( p50.getNode( "A" ) == null ) {
7402 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7403 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7406 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7409 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7410 .equals( "((A,B)88:2.0,C);" ) ) {
7413 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7414 if ( p51.getNode( "A(A" ) == null ) {
7417 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7418 if ( p52.getNode( "A(A" ) == null ) {
7421 final Phylogeny p53 = factory
7422 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7423 new NHXParser() )[ 0 ];
7424 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7428 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7429 if ( p54.getNode( "A" ) == null ) {
7432 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7433 .equals( "((A,B)[88],C);" ) ) {
7437 catch ( final Exception e ) {
7438 e.printStackTrace( System.out );
7444 private static boolean testNHParsingIter() {
7446 final String p0_str = "(A,B);";
7447 final NHXParser p = new NHXParser();
7448 p.setSource( p0_str );
7449 if ( !p.hasNext() ) {
7452 final Phylogeny p0 = p.next();
7453 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7454 System.out.println( p0.toNewHampshire() );
7457 if ( p.hasNext() ) {
7460 if ( p.next() != null ) {
7464 final String p00_str = "(A,B)root;";
7465 p.setSource( p00_str );
7466 final Phylogeny p00 = p.next();
7467 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7468 System.out.println( p00.toNewHampshire() );
7472 final String p000_str = "A;";
7473 p.setSource( p000_str );
7474 final Phylogeny p000 = p.next();
7475 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7476 System.out.println( p000.toNewHampshire() );
7480 final String p0000_str = "A";
7481 p.setSource( p0000_str );
7482 final Phylogeny p0000 = p.next();
7483 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7484 System.out.println( p0000.toNewHampshire() );
7488 p.setSource( "(A)" );
7489 final Phylogeny p00000 = p.next();
7490 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7491 System.out.println( p00000.toNewHampshire() );
7495 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7496 p.setSource( p1_str );
7497 if ( !p.hasNext() ) {
7500 final Phylogeny p1_0 = p.next();
7501 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7502 System.out.println( p1_0.toNewHampshire() );
7505 if ( !p.hasNext() ) {
7508 final Phylogeny p1_1 = p.next();
7509 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7510 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7513 if ( !p.hasNext() ) {
7516 final Phylogeny p1_2 = p.next();
7517 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7518 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7521 if ( !p.hasNext() ) {
7524 final Phylogeny p1_3 = p.next();
7525 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7526 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7529 if ( p.hasNext() ) {
7532 if ( p.next() != null ) {
7536 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7537 p.setSource( p2_str );
7538 if ( !p.hasNext() ) {
7541 Phylogeny p2_0 = p.next();
7542 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7543 System.out.println( p2_0.toNewHampshire() );
7546 if ( !p.hasNext() ) {
7549 Phylogeny p2_1 = p.next();
7550 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7551 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7554 if ( !p.hasNext() ) {
7557 Phylogeny p2_2 = p.next();
7558 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7559 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7562 if ( !p.hasNext() ) {
7565 Phylogeny p2_3 = p.next();
7566 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7567 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7570 if ( !p.hasNext() ) {
7573 Phylogeny p2_4 = p.next();
7574 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7575 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7578 if ( p.hasNext() ) {
7581 if ( p.next() != null ) {
7586 if ( !p.hasNext() ) {
7590 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7591 System.out.println( p2_0.toNewHampshire() );
7594 if ( !p.hasNext() ) {
7598 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7599 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7602 if ( !p.hasNext() ) {
7606 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7607 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7610 if ( !p.hasNext() ) {
7614 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7615 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7618 if ( !p.hasNext() ) {
7622 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7623 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7626 if ( p.hasNext() ) {
7629 if ( p.next() != null ) {
7633 final String p3_str = "((A,B),C)abc";
7634 p.setSource( p3_str );
7635 if ( !p.hasNext() ) {
7638 final Phylogeny p3_0 = p.next();
7639 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7642 if ( p.hasNext() ) {
7645 if ( p.next() != null ) {
7649 final String p4_str = "((A,B)ab,C)abc";
7650 p.setSource( p4_str );
7651 if ( !p.hasNext() ) {
7654 final Phylogeny p4_0 = p.next();
7655 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7658 if ( p.hasNext() ) {
7661 if ( p.next() != null ) {
7665 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7666 p.setSource( p5_str );
7667 if ( !p.hasNext() ) {
7670 final Phylogeny p5_0 = p.next();
7671 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7674 if ( p.hasNext() ) {
7677 if ( p.next() != null ) {
7681 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7682 p.setSource( p6_str );
7683 if ( !p.hasNext() ) {
7686 Phylogeny p6_0 = p.next();
7687 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7690 if ( p.hasNext() ) {
7693 if ( p.next() != null ) {
7697 if ( !p.hasNext() ) {
7701 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7704 if ( p.hasNext() ) {
7707 if ( p.next() != null ) {
7711 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7712 p.setSource( p7_str );
7713 if ( !p.hasNext() ) {
7716 Phylogeny p7_0 = p.next();
7717 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7720 if ( p.hasNext() ) {
7723 if ( p.next() != null ) {
7727 if ( !p.hasNext() ) {
7731 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7734 if ( p.hasNext() ) {
7737 if ( p.next() != null ) {
7741 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7742 p.setSource( p8_str );
7743 if ( !p.hasNext() ) {
7746 Phylogeny p8_0 = p.next();
7747 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7750 if ( !p.hasNext() ) {
7753 if ( !p.hasNext() ) {
7756 Phylogeny p8_1 = p.next();
7757 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7760 if ( p.hasNext() ) {
7763 if ( p.next() != null ) {
7767 if ( !p.hasNext() ) {
7771 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7774 if ( !p.hasNext() ) {
7778 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7781 if ( p.hasNext() ) {
7784 if ( p.next() != null ) {
7790 if ( p.hasNext() ) {
7794 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7795 if ( !p.hasNext() ) {
7798 Phylogeny p_27 = p.next();
7799 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7800 System.out.println( p_27.toNewHampshireX() );
7804 if ( p.hasNext() ) {
7807 if ( p.next() != null ) {
7811 if ( !p.hasNext() ) {
7815 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7816 System.out.println( p_27.toNewHampshireX() );
7820 if ( p.hasNext() ) {
7823 if ( p.next() != null ) {
7827 catch ( final Exception e ) {
7828 e.printStackTrace( System.out );
7834 private static boolean testNHXconversion() {
7836 final PhylogenyNode n1 = new PhylogenyNode();
7837 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7838 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7839 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7840 final PhylogenyNode n5 = PhylogenyNode
7841 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7842 final PhylogenyNode n6 = PhylogenyNode
7843 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7844 if ( !n1.toNewHampshireX().equals( "" ) ) {
7847 if ( !n2.toNewHampshireX().equals( "" ) ) {
7850 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7853 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7856 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7859 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7860 System.out.println( n6.toNewHampshireX() );
7864 catch ( final Exception e ) {
7865 e.printStackTrace( System.out );
7871 private static boolean testNHXNodeParsing() {
7873 final PhylogenyNode n1 = new PhylogenyNode();
7874 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7875 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7876 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7877 final PhylogenyNode n5 = PhylogenyNode
7878 .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]" );
7879 if ( !n3.getName().equals( "n3" ) ) {
7882 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7885 if ( n3.isDuplication() ) {
7888 if ( n3.isHasAssignedEvent() ) {
7891 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7894 if ( !n4.getName().equals( "n4" ) ) {
7897 if ( n4.getDistanceToParent() != 0.01 ) {
7900 if ( !n5.getName().equals( "n5" ) ) {
7903 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7906 if ( n5.getDistanceToParent() != 0.1 ) {
7909 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7912 if ( !n5.isDuplication() ) {
7915 if ( !n5.isHasAssignedEvent() ) {
7918 final PhylogenyNode n8 = PhylogenyNode
7919 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7920 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7921 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7924 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7927 final PhylogenyNode n9 = PhylogenyNode
7928 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7929 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7930 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7933 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7936 final PhylogenyNode n10 = PhylogenyNode
7937 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7938 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7941 final PhylogenyNode n20 = PhylogenyNode
7942 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7943 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7946 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7949 final PhylogenyNode n20x = PhylogenyNode
7950 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7951 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7954 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7957 final PhylogenyNode n20xx = PhylogenyNode
7958 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7959 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7962 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7965 final PhylogenyNode n20xxx = PhylogenyNode
7966 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7967 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7970 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7973 final PhylogenyNode n20xxxx = PhylogenyNode
7974 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7975 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7978 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7981 final PhylogenyNode n21 = PhylogenyNode
7982 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7983 if ( !n21.getName().equals( "N21_PIG" ) ) {
7986 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7989 final PhylogenyNode n21x = PhylogenyNode
7990 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7991 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7994 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7997 final PhylogenyNode n22 = PhylogenyNode
7998 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7999 if ( !n22.getName().equals( "n22/PIG" ) ) {
8002 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8005 final PhylogenyNode n23 = PhylogenyNode
8006 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8007 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8010 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8013 final PhylogenyNode a = PhylogenyNode
8014 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8015 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8018 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8021 final PhylogenyNode c1 = PhylogenyNode
8022 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8023 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8024 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8027 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8030 final PhylogenyNode c2 = PhylogenyNode
8031 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8032 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8033 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8036 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8039 final PhylogenyNode e3 = PhylogenyNode
8040 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8041 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8044 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8047 final PhylogenyNode n11 = PhylogenyNode
8048 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8049 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8050 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8053 if ( n11.getDistanceToParent() != 0.4 ) {
8056 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8059 final PhylogenyNode n12 = PhylogenyNode
8060 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8061 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8062 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8065 if ( n12.getDistanceToParent() != 0.4 ) {
8068 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8071 final PhylogenyNode o = PhylogenyNode
8072 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8073 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8076 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8079 if ( n1.getName().compareTo( "" ) != 0 ) {
8082 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8085 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8088 if ( n2.getName().compareTo( "" ) != 0 ) {
8091 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8094 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8097 final PhylogenyNode n00 = PhylogenyNode
8098 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8099 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8102 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8105 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8106 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8109 final PhylogenyNode n13 = PhylogenyNode
8110 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8111 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
8114 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8117 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8120 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8123 final PhylogenyNode n14 = PhylogenyNode
8124 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8125 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8128 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8131 final PhylogenyNode n15 = PhylogenyNode
8132 .createInstanceFromNhxString( "something_wicked[123]",
8133 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8134 if ( !n15.getName().equals( "something_wicked" ) ) {
8137 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8140 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8143 final PhylogenyNode n16 = PhylogenyNode
8144 .createInstanceFromNhxString( "something_wicked2[9]",
8145 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8146 if ( !n16.getName().equals( "something_wicked2" ) ) {
8149 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8152 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8155 final PhylogenyNode n17 = PhylogenyNode
8156 .createInstanceFromNhxString( "something_wicked3[a]",
8157 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8158 if ( !n17.getName().equals( "something_wicked3" ) ) {
8161 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8164 final PhylogenyNode n18 = PhylogenyNode
8165 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8166 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8169 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8172 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8175 final PhylogenyNode n19 = PhylogenyNode
8176 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8177 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8180 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8183 final PhylogenyNode n30 = PhylogenyNode
8184 .createInstanceFromNhxString( "blah_1234567-roejojoej",
8185 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8186 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8189 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8192 final PhylogenyNode n31 = PhylogenyNode
8193 .createInstanceFromNhxString( "blah_12345678-roejojoej",
8194 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8195 if ( n31.getNodeData().isHasTaxonomy() ) {
8198 final PhylogenyNode n32 = PhylogenyNode
8199 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8200 if ( n32.getNodeData().isHasTaxonomy() ) {
8203 final PhylogenyNode n40 = PhylogenyNode
8204 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8205 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8208 final PhylogenyNode n41 = PhylogenyNode
8209 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8210 if ( n41.getNodeData().isHasTaxonomy() ) {
8213 final PhylogenyNode n42 = PhylogenyNode
8214 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8215 if ( n42.getNodeData().isHasTaxonomy() ) {
8218 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8219 NHXParser.TAXONOMY_EXTRACTION.NO );
8220 if ( n43.getNodeData().isHasTaxonomy() ) {
8223 final PhylogenyNode n44 = PhylogenyNode
8224 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8225 if ( n44.getNodeData().isHasTaxonomy() ) {
8229 catch ( final Exception e ) {
8230 e.printStackTrace( System.out );
8236 private static boolean testNHXParsing() {
8238 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8239 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8240 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8243 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]";
8244 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8245 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8248 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]";
8249 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8250 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8253 final Phylogeny[] p3 = factory
8254 .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]",
8256 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8259 final Phylogeny[] p4 = factory
8260 .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(]",
8262 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8265 final Phylogeny[] p5 = factory
8266 .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(((]",
8268 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8271 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)";
8272 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)";
8273 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8274 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8277 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)))";
8278 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)))";
8279 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8280 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8283 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]) ))[,,, ])))))))";
8284 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8285 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8286 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8289 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8290 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8293 final Phylogeny p10 = factory
8294 .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]",
8295 new NHXParser() )[ 0 ];
8296 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8300 catch ( final Exception e ) {
8301 e.printStackTrace( System.out );
8307 private static boolean testNHXParsingMB() {
8309 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8310 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8311 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8312 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8313 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8314 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8315 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8316 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8317 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8318 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8319 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8322 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8325 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8326 0.1100000000000000e+00 ) ) {
8329 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8332 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8335 final Phylogeny p2 = factory
8336 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8337 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8338 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8339 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8340 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8341 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8342 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8343 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8344 + "7.369400000000000e-02}])",
8345 new NHXParser() )[ 0 ];
8346 if ( p2.getNode( "1" ) == null ) {
8349 if ( p2.getNode( "2" ) == null ) {
8353 catch ( final Exception e ) {
8354 e.printStackTrace( System.out );
8361 private static boolean testNHXParsingQuotes() {
8363 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8364 final NHXParser p = new NHXParser();
8365 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8366 if ( phylogenies_0.length != 5 ) {
8369 final Phylogeny phy = phylogenies_0[ 4 ];
8370 if ( phy.getNumberOfExternalNodes() != 7 ) {
8373 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8376 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8379 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8380 .getScientificName().equals( "hsapiens" ) ) {
8383 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8386 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8389 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8392 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8395 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8398 final NHXParser p1p = new NHXParser();
8399 p1p.setIgnoreQuotes( true );
8400 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8401 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8404 final NHXParser p2p = new NHXParser();
8405 p1p.setIgnoreQuotes( false );
8406 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8407 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8410 final NHXParser p3p = new NHXParser();
8411 p3p.setIgnoreQuotes( false );
8412 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8413 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8416 final NHXParser p4p = new NHXParser();
8417 p4p.setIgnoreQuotes( false );
8418 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8419 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8422 final Phylogeny p10 = factory
8423 .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]",
8424 new NHXParser() )[ 0 ];
8425 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]";
8426 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8429 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8430 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8434 final Phylogeny p12 = factory
8435 .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]",
8436 new NHXParser() )[ 0 ];
8437 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]";
8438 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8441 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8442 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8445 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;";
8446 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8449 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8450 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8454 catch ( final Exception e ) {
8455 e.printStackTrace( System.out );
8461 private static boolean testNodeRemoval() {
8463 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8464 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8465 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8466 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8469 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8470 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8471 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8474 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8475 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8476 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8480 catch ( final Exception e ) {
8481 e.printStackTrace( System.out );
8487 private static boolean testPhylogenyBranch() {
8489 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8490 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8491 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8492 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8493 if ( !a1b1.equals( a1b1 ) ) {
8496 if ( !a1b1.equals( b1a1 ) ) {
8499 if ( !b1a1.equals( a1b1 ) ) {
8502 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8503 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8504 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8505 if ( a1_b1.equals( b1_a1 ) ) {
8508 if ( a1_b1.equals( a1_b1_ ) ) {
8511 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8512 if ( !a1_b1.equals( b1_a1_ ) ) {
8515 if ( a1_b1_.equals( b1_a1_ ) ) {
8518 if ( !a1_b1_.equals( b1_a1 ) ) {
8522 catch ( final Exception e ) {
8523 e.printStackTrace( System.out );
8529 private static boolean testPhyloXMLparsingOfDistributionElement() {
8531 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8532 PhyloXmlParser xml_parser = null;
8534 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8536 catch ( final Exception e ) {
8537 // Do nothing -- means were not running from jar.
8539 if ( xml_parser == null ) {
8540 xml_parser = new PhyloXmlParser();
8541 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8542 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8545 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8548 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8550 if ( xml_parser.getErrorCount() > 0 ) {
8551 System.out.println( xml_parser.getErrorMessages().toString() );
8554 if ( phylogenies_0.length != 1 ) {
8557 final Phylogeny t1 = phylogenies_0[ 0 ];
8558 PhylogenyNode n = null;
8559 Distribution d = null;
8560 n = t1.getNode( "root node" );
8561 if ( !n.getNodeData().isHasDistribution() ) {
8564 if ( n.getNodeData().getDistributions().size() != 1 ) {
8567 d = n.getNodeData().getDistribution();
8568 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8571 if ( d.getPoints().size() != 1 ) {
8574 if ( d.getPolygons() != null ) {
8577 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8580 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8583 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8586 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8589 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8592 n = t1.getNode( "node a" );
8593 if ( !n.getNodeData().isHasDistribution() ) {
8596 if ( n.getNodeData().getDistributions().size() != 2 ) {
8599 d = n.getNodeData().getDistribution( 1 );
8600 if ( !d.getDesc().equals( "San Diego" ) ) {
8603 if ( d.getPoints().size() != 1 ) {
8606 if ( d.getPolygons() != null ) {
8609 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8612 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8615 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8618 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8621 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8624 n = t1.getNode( "node bb" );
8625 if ( !n.getNodeData().isHasDistribution() ) {
8628 if ( n.getNodeData().getDistributions().size() != 1 ) {
8631 d = n.getNodeData().getDistribution( 0 );
8632 if ( d.getPoints().size() != 3 ) {
8635 if ( d.getPolygons().size() != 2 ) {
8638 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8641 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8644 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8647 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8650 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8653 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8656 Polygon p = d.getPolygons().get( 0 );
8657 if ( p.getPoints().size() != 3 ) {
8660 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8663 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8666 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8669 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8672 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8675 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8678 p = d.getPolygons().get( 1 );
8679 if ( p.getPoints().size() != 3 ) {
8682 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8685 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8688 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8692 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8693 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8694 if ( rt.length != 1 ) {
8697 final Phylogeny t1_rt = rt[ 0 ];
8698 n = t1_rt.getNode( "root node" );
8699 if ( !n.getNodeData().isHasDistribution() ) {
8702 if ( n.getNodeData().getDistributions().size() != 1 ) {
8705 d = n.getNodeData().getDistribution();
8706 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8709 if ( d.getPoints().size() != 1 ) {
8712 if ( d.getPolygons() != null ) {
8715 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8718 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8721 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8724 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8727 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8730 n = t1_rt.getNode( "node a" );
8731 if ( !n.getNodeData().isHasDistribution() ) {
8734 if ( n.getNodeData().getDistributions().size() != 2 ) {
8737 d = n.getNodeData().getDistribution( 1 );
8738 if ( !d.getDesc().equals( "San Diego" ) ) {
8741 if ( d.getPoints().size() != 1 ) {
8744 if ( d.getPolygons() != null ) {
8747 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8750 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8753 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8756 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8759 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8762 n = t1_rt.getNode( "node bb" );
8763 if ( !n.getNodeData().isHasDistribution() ) {
8766 if ( n.getNodeData().getDistributions().size() != 1 ) {
8769 d = n.getNodeData().getDistribution( 0 );
8770 if ( d.getPoints().size() != 3 ) {
8773 if ( d.getPolygons().size() != 2 ) {
8776 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8779 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8782 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8785 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8788 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8791 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8794 p = d.getPolygons().get( 0 );
8795 if ( p.getPoints().size() != 3 ) {
8798 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8801 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8804 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8807 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8810 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8813 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8816 p = d.getPolygons().get( 1 );
8817 if ( p.getPoints().size() != 3 ) {
8820 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8823 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8826 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8830 catch ( final Exception e ) {
8831 e.printStackTrace( System.out );
8837 private static boolean testPostOrderIterator() {
8839 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8840 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8841 PhylogenyNodeIterator it0;
8842 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8845 for( it0.reset(); it0.hasNext(); ) {
8848 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8849 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8850 if ( !it.next().getName().equals( "A" ) ) {
8853 if ( !it.next().getName().equals( "B" ) ) {
8856 if ( !it.next().getName().equals( "ab" ) ) {
8859 if ( !it.next().getName().equals( "C" ) ) {
8862 if ( !it.next().getName().equals( "D" ) ) {
8865 if ( !it.next().getName().equals( "cd" ) ) {
8868 if ( !it.next().getName().equals( "abcd" ) ) {
8871 if ( !it.next().getName().equals( "E" ) ) {
8874 if ( !it.next().getName().equals( "F" ) ) {
8877 if ( !it.next().getName().equals( "ef" ) ) {
8880 if ( !it.next().getName().equals( "G" ) ) {
8883 if ( !it.next().getName().equals( "H" ) ) {
8886 if ( !it.next().getName().equals( "gh" ) ) {
8889 if ( !it.next().getName().equals( "efgh" ) ) {
8892 if ( !it.next().getName().equals( "r" ) ) {
8895 if ( it.hasNext() ) {
8899 catch ( final Exception e ) {
8900 e.printStackTrace( System.out );
8906 private static boolean testPreOrderIterator() {
8908 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8909 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8910 PhylogenyNodeIterator it0;
8911 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8914 for( it0.reset(); it0.hasNext(); ) {
8917 PhylogenyNodeIterator it = t0.iteratorPreorder();
8918 if ( !it.next().getName().equals( "r" ) ) {
8921 if ( !it.next().getName().equals( "ab" ) ) {
8924 if ( !it.next().getName().equals( "A" ) ) {
8927 if ( !it.next().getName().equals( "B" ) ) {
8930 if ( !it.next().getName().equals( "cd" ) ) {
8933 if ( !it.next().getName().equals( "C" ) ) {
8936 if ( !it.next().getName().equals( "D" ) ) {
8939 if ( it.hasNext() ) {
8942 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8943 it = t1.iteratorPreorder();
8944 if ( !it.next().getName().equals( "r" ) ) {
8947 if ( !it.next().getName().equals( "abcd" ) ) {
8950 if ( !it.next().getName().equals( "ab" ) ) {
8953 if ( !it.next().getName().equals( "A" ) ) {
8956 if ( !it.next().getName().equals( "B" ) ) {
8959 if ( !it.next().getName().equals( "cd" ) ) {
8962 if ( !it.next().getName().equals( "C" ) ) {
8965 if ( !it.next().getName().equals( "D" ) ) {
8968 if ( !it.next().getName().equals( "efgh" ) ) {
8971 if ( !it.next().getName().equals( "ef" ) ) {
8974 if ( !it.next().getName().equals( "E" ) ) {
8977 if ( !it.next().getName().equals( "F" ) ) {
8980 if ( !it.next().getName().equals( "gh" ) ) {
8983 if ( !it.next().getName().equals( "G" ) ) {
8986 if ( !it.next().getName().equals( "H" ) ) {
8989 if ( it.hasNext() ) {
8993 catch ( final Exception e ) {
8994 e.printStackTrace( System.out );
9000 private static boolean testPropertiesMap() {
9002 final PropertiesMap pm = new PropertiesMap();
9003 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9004 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9005 final Property p2 = new Property( "something:else",
9007 "improbable:research",
9010 pm.addProperty( p0 );
9011 pm.addProperty( p1 );
9012 pm.addProperty( p2 );
9013 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9016 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9019 if ( pm.getProperties().size() != 3 ) {
9022 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9025 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9028 if ( pm.getProperties().size() != 3 ) {
9031 pm.removeProperty( "dimensions:diameter" );
9032 if ( pm.getProperties().size() != 2 ) {
9035 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9038 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9042 catch ( final Exception e ) {
9043 e.printStackTrace( System.out );
9049 private static boolean testProteinId() {
9051 final ProteinId id1 = new ProteinId( "a" );
9052 final ProteinId id2 = new ProteinId( "a" );
9053 final ProteinId id3 = new ProteinId( "A" );
9054 final ProteinId id4 = new ProteinId( "b" );
9055 if ( !id1.equals( id1 ) ) {
9058 if ( id1.getId().equals( "x" ) ) {
9061 if ( id1.getId().equals( null ) ) {
9064 if ( !id1.equals( id2 ) ) {
9067 if ( id1.equals( id3 ) ) {
9070 if ( id1.hashCode() != id1.hashCode() ) {
9073 if ( id1.hashCode() != id2.hashCode() ) {
9076 if ( id1.hashCode() == id3.hashCode() ) {
9079 if ( id1.compareTo( id1 ) != 0 ) {
9082 if ( id1.compareTo( id2 ) != 0 ) {
9085 if ( id1.compareTo( id3 ) != 0 ) {
9088 if ( id1.compareTo( id4 ) >= 0 ) {
9091 if ( id4.compareTo( id1 ) <= 0 ) {
9094 if ( !id4.getId().equals( "b" ) ) {
9097 final ProteinId id5 = new ProteinId( " C " );
9098 if ( !id5.getId().equals( "C" ) ) {
9101 if ( id5.equals( id1 ) ) {
9105 catch ( final Exception e ) {
9106 e.printStackTrace( System.out );
9112 private static boolean testReIdMethods() {
9114 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9115 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9116 final long count = PhylogenyNode.getNodeCount();
9118 if ( p.getNode( "r" ).getId() != count ) {
9121 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9124 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9127 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9130 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9133 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9136 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9139 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9142 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9145 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9148 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9151 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9154 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9157 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9160 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9164 catch ( final Exception e ) {
9165 e.printStackTrace( System.out );
9171 private static boolean testRerooting() {
9173 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9174 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",
9175 new NHXParser() )[ 0 ];
9176 if ( !t1.isRooted() ) {
9179 t1.reRoot( t1.getNode( "D" ) );
9180 t1.reRoot( t1.getNode( "CD" ) );
9181 t1.reRoot( t1.getNode( "A" ) );
9182 t1.reRoot( t1.getNode( "B" ) );
9183 t1.reRoot( t1.getNode( "AB" ) );
9184 t1.reRoot( t1.getNode( "D" ) );
9185 t1.reRoot( t1.getNode( "C" ) );
9186 t1.reRoot( t1.getNode( "CD" ) );
9187 t1.reRoot( t1.getNode( "A" ) );
9188 t1.reRoot( t1.getNode( "B" ) );
9189 t1.reRoot( t1.getNode( "AB" ) );
9190 t1.reRoot( t1.getNode( "D" ) );
9191 t1.reRoot( t1.getNode( "D" ) );
9192 t1.reRoot( t1.getNode( "C" ) );
9193 t1.reRoot( t1.getNode( "A" ) );
9194 t1.reRoot( t1.getNode( "B" ) );
9195 t1.reRoot( t1.getNode( "AB" ) );
9196 t1.reRoot( t1.getNode( "C" ) );
9197 t1.reRoot( t1.getNode( "D" ) );
9198 t1.reRoot( t1.getNode( "CD" ) );
9199 t1.reRoot( t1.getNode( "D" ) );
9200 t1.reRoot( t1.getNode( "A" ) );
9201 t1.reRoot( t1.getNode( "B" ) );
9202 t1.reRoot( t1.getNode( "AB" ) );
9203 t1.reRoot( t1.getNode( "C" ) );
9204 t1.reRoot( t1.getNode( "D" ) );
9205 t1.reRoot( t1.getNode( "CD" ) );
9206 t1.reRoot( t1.getNode( "D" ) );
9207 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9210 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9213 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9216 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9219 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9222 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9225 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",
9226 new NHXParser() )[ 0 ];
9227 t2.reRoot( t2.getNode( "A" ) );
9228 t2.reRoot( t2.getNode( "D" ) );
9229 t2.reRoot( t2.getNode( "ABC" ) );
9230 t2.reRoot( t2.getNode( "A" ) );
9231 t2.reRoot( t2.getNode( "B" ) );
9232 t2.reRoot( t2.getNode( "D" ) );
9233 t2.reRoot( t2.getNode( "C" ) );
9234 t2.reRoot( t2.getNode( "ABC" ) );
9235 t2.reRoot( t2.getNode( "A" ) );
9236 t2.reRoot( t2.getNode( "B" ) );
9237 t2.reRoot( t2.getNode( "AB" ) );
9238 t2.reRoot( t2.getNode( "AB" ) );
9239 t2.reRoot( t2.getNode( "D" ) );
9240 t2.reRoot( t2.getNode( "C" ) );
9241 t2.reRoot( t2.getNode( "B" ) );
9242 t2.reRoot( t2.getNode( "AB" ) );
9243 t2.reRoot( t2.getNode( "D" ) );
9244 t2.reRoot( t2.getNode( "D" ) );
9245 t2.reRoot( t2.getNode( "ABC" ) );
9246 t2.reRoot( t2.getNode( "A" ) );
9247 t2.reRoot( t2.getNode( "B" ) );
9248 t2.reRoot( t2.getNode( "AB" ) );
9249 t2.reRoot( t2.getNode( "D" ) );
9250 t2.reRoot( t2.getNode( "C" ) );
9251 t2.reRoot( t2.getNode( "ABC" ) );
9252 t2.reRoot( t2.getNode( "A" ) );
9253 t2.reRoot( t2.getNode( "B" ) );
9254 t2.reRoot( t2.getNode( "AB" ) );
9255 t2.reRoot( t2.getNode( "D" ) );
9256 t2.reRoot( t2.getNode( "D" ) );
9257 t2.reRoot( t2.getNode( "C" ) );
9258 t2.reRoot( t2.getNode( "A" ) );
9259 t2.reRoot( t2.getNode( "B" ) );
9260 t2.reRoot( t2.getNode( "AB" ) );
9261 t2.reRoot( t2.getNode( "C" ) );
9262 t2.reRoot( t2.getNode( "D" ) );
9263 t2.reRoot( t2.getNode( "ABC" ) );
9264 t2.reRoot( t2.getNode( "D" ) );
9265 t2.reRoot( t2.getNode( "A" ) );
9266 t2.reRoot( t2.getNode( "B" ) );
9267 t2.reRoot( t2.getNode( "AB" ) );
9268 t2.reRoot( t2.getNode( "C" ) );
9269 t2.reRoot( t2.getNode( "D" ) );
9270 t2.reRoot( t2.getNode( "ABC" ) );
9271 t2.reRoot( t2.getNode( "D" ) );
9272 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9275 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9278 t2.reRoot( t2.getNode( "ABC" ) );
9279 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9282 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9285 t2.reRoot( t2.getNode( "AB" ) );
9286 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9289 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9292 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9295 t2.reRoot( t2.getNode( "AB" ) );
9296 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9299 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9302 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9305 t2.reRoot( t2.getNode( "D" ) );
9306 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9309 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9312 t2.reRoot( t2.getNode( "ABC" ) );
9313 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9316 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9319 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9320 new NHXParser() )[ 0 ];
9321 t3.reRoot( t3.getNode( "B" ) );
9322 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9325 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9328 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9331 t3.reRoot( t3.getNode( "B" ) );
9332 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9335 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9338 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9341 t3.reRoot( t3.getRoot() );
9342 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9345 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9348 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9352 catch ( final Exception e ) {
9353 e.printStackTrace( System.out );
9359 private static boolean testSDIse() {
9361 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9362 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9363 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9364 gene1.setRooted( true );
9365 species1.setRooted( true );
9366 final SDI sdi = new SDI( gene1, species1 );
9367 if ( !gene1.getRoot().isDuplication() ) {
9370 final Phylogeny species2 = factory
9371 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9372 new NHXParser() )[ 0 ];
9373 final Phylogeny gene2 = factory
9374 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9375 new NHXParser() )[ 0 ];
9376 species2.setRooted( true );
9377 gene2.setRooted( true );
9378 final SDI sdi2 = new SDI( gene2, species2 );
9379 if ( sdi2.getDuplicationsSum() != 0 ) {
9382 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9385 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9388 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9391 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9394 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9397 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9400 final Phylogeny species3 = factory
9401 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9402 new NHXParser() )[ 0 ];
9403 final Phylogeny gene3 = factory
9404 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9405 new NHXParser() )[ 0 ];
9406 species3.setRooted( true );
9407 gene3.setRooted( true );
9408 final SDI sdi3 = new SDI( gene3, species3 );
9409 if ( sdi3.getDuplicationsSum() != 1 ) {
9412 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9415 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9418 final Phylogeny species4 = factory
9419 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9420 new NHXParser() )[ 0 ];
9421 final Phylogeny gene4 = factory
9422 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9423 new NHXParser() )[ 0 ];
9424 species4.setRooted( true );
9425 gene4.setRooted( true );
9426 final SDI sdi4 = new SDI( gene4, species4 );
9427 if ( sdi4.getDuplicationsSum() != 1 ) {
9430 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9433 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9436 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9439 if ( species4.getNumberOfExternalNodes() != 6 ) {
9442 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9445 final Phylogeny species5 = factory
9446 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9447 new NHXParser() )[ 0 ];
9448 final Phylogeny gene5 = factory
9449 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9450 new NHXParser() )[ 0 ];
9451 species5.setRooted( true );
9452 gene5.setRooted( true );
9453 final SDI sdi5 = new SDI( gene5, species5 );
9454 if ( sdi5.getDuplicationsSum() != 2 ) {
9457 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9460 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9463 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9466 if ( species5.getNumberOfExternalNodes() != 6 ) {
9469 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9472 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9473 // Conjecture for Comparing Molecular Phylogenies"
9474 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9475 final Phylogeny species6 = factory
9476 .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,"
9477 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9478 new NHXParser() )[ 0 ];
9479 final Phylogeny gene6 = factory
9480 .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,"
9481 + "((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,"
9482 + "(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;",
9483 new NHXParser() )[ 0 ];
9484 species6.setRooted( true );
9485 gene6.setRooted( true );
9486 final SDI sdi6 = new SDI( gene6, species6 );
9487 if ( sdi6.getDuplicationsSum() != 3 ) {
9490 if ( !gene6.getNode( "r" ).isDuplication() ) {
9493 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9496 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9499 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9502 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9505 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9508 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9511 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9514 sdi6.computeMappingCostL();
9515 if ( sdi6.computeMappingCostL() != 17 ) {
9518 if ( species6.getNumberOfExternalNodes() != 9 ) {
9521 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9524 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9525 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9526 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9527 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9528 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9529 species7.setRooted( true );
9530 final Phylogeny gene7_1 = Test
9531 .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])" );
9532 gene7_1.setRooted( true );
9533 final SDI sdi7 = new SDI( gene7_1, species7 );
9534 if ( sdi7.getDuplicationsSum() != 0 ) {
9537 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9540 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9543 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9546 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9549 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9552 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9555 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9558 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9561 final Phylogeny gene7_2 = Test
9562 .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])" );
9563 gene7_2.setRooted( true );
9564 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9565 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9568 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9571 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9574 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9577 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9580 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9583 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9586 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9589 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9592 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9596 catch ( final Exception e ) {
9602 private static boolean testSDIunrooted() {
9604 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9605 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9606 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9607 final Iterator<PhylogenyBranch> iter = l.iterator();
9608 PhylogenyBranch br = iter.next();
9609 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9612 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9616 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9619 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9623 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9626 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9630 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9633 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9637 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9640 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9644 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9647 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9651 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9654 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9658 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9661 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9665 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9668 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9672 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9675 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9679 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9682 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9686 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9689 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9693 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9696 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9700 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9703 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9707 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9710 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9713 if ( iter.hasNext() ) {
9716 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9717 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9718 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9720 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9723 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9727 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9730 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9734 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9737 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9740 if ( iter1.hasNext() ) {
9743 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9744 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9745 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9747 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9750 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9754 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9757 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9761 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9764 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9767 if ( iter2.hasNext() ) {
9770 final Phylogeny species0 = factory
9771 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9772 new NHXParser() )[ 0 ];
9773 final Phylogeny gene1 = factory
9774 .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])",
9775 new NHXParser() )[ 0 ];
9776 species0.setRooted( true );
9777 gene1.setRooted( true );
9778 final SDIR sdi_unrooted = new SDIR();
9779 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9780 if ( sdi_unrooted.getCount() != 1 ) {
9783 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9786 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9789 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9792 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9795 final Phylogeny gene2 = factory
9796 .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])",
9797 new NHXParser() )[ 0 ];
9798 gene2.setRooted( true );
9799 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9800 if ( sdi_unrooted.getCount() != 1 ) {
9803 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9806 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9809 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9812 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9815 final Phylogeny species6 = factory
9816 .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,"
9817 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9818 new NHXParser() )[ 0 ];
9819 final Phylogeny gene6 = factory
9820 .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],"
9821 + "(((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],"
9822 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9823 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9824 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9825 new NHXParser() )[ 0 ];
9826 species6.setRooted( true );
9827 gene6.setRooted( true );
9828 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9829 if ( sdi_unrooted.getCount() != 1 ) {
9832 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9835 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9838 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9841 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9844 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9847 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9850 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9853 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9856 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9859 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9862 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9865 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9869 final Phylogeny species7 = factory
9870 .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,"
9871 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9872 new NHXParser() )[ 0 ];
9873 final Phylogeny gene7 = factory
9874 .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],"
9875 + "(((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],"
9876 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9877 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9878 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9879 new NHXParser() )[ 0 ];
9880 species7.setRooted( true );
9881 gene7.setRooted( true );
9882 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9883 if ( sdi_unrooted.getCount() != 1 ) {
9886 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9889 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9892 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9895 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9898 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9901 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9904 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9907 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9910 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9913 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9916 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9919 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9923 final Phylogeny species8 = factory
9924 .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,"
9925 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9926 new NHXParser() )[ 0 ];
9927 final Phylogeny gene8 = factory
9928 .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],"
9929 + "(((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],"
9930 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9931 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9932 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9933 new NHXParser() )[ 0 ];
9934 species8.setRooted( true );
9935 gene8.setRooted( true );
9936 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9937 if ( sdi_unrooted.getCount() != 1 ) {
9940 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9943 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9946 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9949 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9952 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9955 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9958 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9961 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9964 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9967 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9970 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9973 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9978 catch ( final Exception e ) {
9979 e.printStackTrace( System.out );
9985 private static boolean testSequenceIdParsing() {
9987 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
9988 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9989 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9991 System.out.println( "value =" + id.getValue() );
9992 System.out.println( "provider=" + id.getSource() );
9997 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
9998 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9999 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10000 if ( id != null ) {
10001 System.out.println( "value =" + id.getValue() );
10002 System.out.println( "provider=" + id.getSource() );
10007 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10008 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10009 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10010 if ( id != null ) {
10011 System.out.println( "value =" + id.getValue() );
10012 System.out.println( "provider=" + id.getSource() );
10017 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10018 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10019 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10020 if ( id != null ) {
10021 System.out.println( "value =" + id.getValue() );
10022 System.out.println( "provider=" + id.getSource() );
10027 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10028 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10029 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10030 if ( id != null ) {
10031 System.out.println( "value =" + id.getValue() );
10032 System.out.println( "provider=" + id.getSource() );
10037 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10038 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10039 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10040 if ( id != null ) {
10041 System.out.println( "value =" + id.getValue() );
10042 System.out.println( "provider=" + id.getSource() );
10047 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10048 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10049 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10050 if ( id != null ) {
10051 System.out.println( "value =" + id.getValue() );
10052 System.out.println( "provider=" + id.getSource() );
10057 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10058 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10059 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10060 if ( id != null ) {
10061 System.out.println( "value =" + id.getValue() );
10062 System.out.println( "provider=" + id.getSource() );
10067 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10068 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10069 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10070 if ( id != null ) {
10071 System.out.println( "value =" + id.getValue() );
10072 System.out.println( "provider=" + id.getSource() );
10077 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10078 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10079 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10080 if ( id != null ) {
10081 System.out.println( "value =" + id.getValue() );
10082 System.out.println( "provider=" + id.getSource() );
10086 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10087 if ( id != null ) {
10088 System.out.println( "value =" + id.getValue() );
10089 System.out.println( "provider=" + id.getSource() );
10093 catch ( final Exception e ) {
10094 e.printStackTrace( System.out );
10100 private static boolean testSequenceWriter() {
10102 final String n = ForesterUtil.LINE_SEPARATOR;
10103 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10106 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10109 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10112 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10115 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10116 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10119 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10120 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10124 catch ( final Exception e ) {
10125 e.printStackTrace();
10131 private static boolean testSpecies() {
10133 final Species s1 = new BasicSpecies( "a" );
10134 final Species s2 = new BasicSpecies( "a" );
10135 final Species s3 = new BasicSpecies( "A" );
10136 final Species s4 = new BasicSpecies( "b" );
10137 if ( !s1.equals( s1 ) ) {
10140 if ( s1.getSpeciesId().equals( "x" ) ) {
10143 if ( s1.getSpeciesId().equals( null ) ) {
10146 if ( !s1.equals( s2 ) ) {
10149 if ( s1.equals( s3 ) ) {
10152 if ( s1.hashCode() != s1.hashCode() ) {
10155 if ( s1.hashCode() != s2.hashCode() ) {
10158 if ( s1.hashCode() == s3.hashCode() ) {
10161 if ( s1.compareTo( s1 ) != 0 ) {
10164 if ( s1.compareTo( s2 ) != 0 ) {
10167 if ( s1.compareTo( s3 ) != 0 ) {
10170 if ( s1.compareTo( s4 ) >= 0 ) {
10173 if ( s4.compareTo( s1 ) <= 0 ) {
10176 if ( !s4.getSpeciesId().equals( "b" ) ) {
10179 final Species s5 = new BasicSpecies( " C " );
10180 if ( !s5.getSpeciesId().equals( "C" ) ) {
10183 if ( s5.equals( s1 ) ) {
10187 catch ( final Exception e ) {
10188 e.printStackTrace( System.out );
10194 private static boolean testSplit() {
10196 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10197 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10198 //Archaeopteryx.createApplication( p0 );
10199 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10200 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10201 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10202 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10203 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10204 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10205 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10206 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10207 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10208 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10209 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
10210 // System.out.println( s0.toString() );
10212 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10215 if ( s0.match( query_nodes ) ) {
10218 query_nodes = new HashSet<PhylogenyNode>();
10219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10226 if ( !s0.match( query_nodes ) ) {
10230 query_nodes = new HashSet<PhylogenyNode>();
10231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10234 if ( !s0.match( query_nodes ) ) {
10238 query_nodes = new HashSet<PhylogenyNode>();
10239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10243 if ( !s0.match( query_nodes ) ) {
10247 query_nodes = new HashSet<PhylogenyNode>();
10248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10252 if ( !s0.match( query_nodes ) ) {
10256 query_nodes = new HashSet<PhylogenyNode>();
10257 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10258 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10260 if ( !s0.match( query_nodes ) ) {
10264 query_nodes = new HashSet<PhylogenyNode>();
10265 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10267 if ( !s0.match( query_nodes ) ) {
10271 query_nodes = new HashSet<PhylogenyNode>();
10272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10276 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10277 if ( !s0.match( query_nodes ) ) {
10281 query_nodes = new HashSet<PhylogenyNode>();
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10285 if ( !s0.match( query_nodes ) ) {
10289 query_nodes = new HashSet<PhylogenyNode>();
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10294 if ( !s0.match( query_nodes ) ) {
10298 query_nodes = new HashSet<PhylogenyNode>();
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10301 if ( s0.match( query_nodes ) ) {
10305 query_nodes = new HashSet<PhylogenyNode>();
10306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10307 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10310 if ( s0.match( query_nodes ) ) {
10314 query_nodes = new HashSet<PhylogenyNode>();
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10320 if ( s0.match( query_nodes ) ) {
10324 query_nodes = new HashSet<PhylogenyNode>();
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10328 if ( s0.match( query_nodes ) ) {
10332 query_nodes = new HashSet<PhylogenyNode>();
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10335 if ( s0.match( query_nodes ) ) {
10339 query_nodes = new HashSet<PhylogenyNode>();
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10342 if ( s0.match( query_nodes ) ) {
10346 query_nodes = new HashSet<PhylogenyNode>();
10347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10349 if ( s0.match( query_nodes ) ) {
10353 query_nodes = new HashSet<PhylogenyNode>();
10354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10356 if ( s0.match( query_nodes ) ) {
10360 query_nodes = new HashSet<PhylogenyNode>();
10361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10362 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10363 if ( s0.match( query_nodes ) ) {
10367 query_nodes = new HashSet<PhylogenyNode>();
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10370 if ( s0.match( query_nodes ) ) {
10374 query_nodes = new HashSet<PhylogenyNode>();
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10378 if ( s0.match( query_nodes ) ) {
10382 query_nodes = new HashSet<PhylogenyNode>();
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10386 if ( s0.match( query_nodes ) ) {
10390 query_nodes = new HashSet<PhylogenyNode>();
10391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10394 if ( s0.match( query_nodes ) ) {
10398 query_nodes = new HashSet<PhylogenyNode>();
10399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10403 if ( s0.match( query_nodes ) ) {
10407 // query_nodes = new HashSet<PhylogenyNode>();
10408 // query_nodes.add( new PhylogenyNode( "X" ) );
10409 // query_nodes.add( new PhylogenyNode( "Y" ) );
10410 // query_nodes.add( new PhylogenyNode( "A" ) );
10411 // query_nodes.add( new PhylogenyNode( "B" ) );
10412 // query_nodes.add( new PhylogenyNode( "C" ) );
10413 // query_nodes.add( new PhylogenyNode( "D" ) );
10414 // query_nodes.add( new PhylogenyNode( "E" ) );
10415 // query_nodes.add( new PhylogenyNode( "F" ) );
10416 // query_nodes.add( new PhylogenyNode( "G" ) );
10417 // if ( !s0.match( query_nodes ) ) {
10420 // query_nodes = new HashSet<PhylogenyNode>();
10421 // query_nodes.add( new PhylogenyNode( "X" ) );
10422 // query_nodes.add( new PhylogenyNode( "Y" ) );
10423 // query_nodes.add( new PhylogenyNode( "A" ) );
10424 // query_nodes.add( new PhylogenyNode( "B" ) );
10425 // query_nodes.add( new PhylogenyNode( "C" ) );
10426 // if ( !s0.match( query_nodes ) ) {
10430 // query_nodes = new HashSet<PhylogenyNode>();
10431 // query_nodes.add( new PhylogenyNode( "X" ) );
10432 // query_nodes.add( new PhylogenyNode( "Y" ) );
10433 // query_nodes.add( new PhylogenyNode( "D" ) );
10434 // query_nodes.add( new PhylogenyNode( "E" ) );
10435 // query_nodes.add( new PhylogenyNode( "F" ) );
10436 // query_nodes.add( new PhylogenyNode( "G" ) );
10437 // if ( !s0.match( query_nodes ) ) {
10441 // query_nodes = new HashSet<PhylogenyNode>();
10442 // query_nodes.add( new PhylogenyNode( "X" ) );
10443 // query_nodes.add( new PhylogenyNode( "Y" ) );
10444 // query_nodes.add( new PhylogenyNode( "A" ) );
10445 // query_nodes.add( new PhylogenyNode( "B" ) );
10446 // query_nodes.add( new PhylogenyNode( "C" ) );
10447 // query_nodes.add( new PhylogenyNode( "D" ) );
10448 // if ( !s0.match( query_nodes ) ) {
10452 // query_nodes = new HashSet<PhylogenyNode>();
10453 // query_nodes.add( new PhylogenyNode( "X" ) );
10454 // query_nodes.add( new PhylogenyNode( "Y" ) );
10455 // query_nodes.add( new PhylogenyNode( "E" ) );
10456 // query_nodes.add( new PhylogenyNode( "F" ) );
10457 // query_nodes.add( new PhylogenyNode( "G" ) );
10458 // if ( !s0.match( query_nodes ) ) {
10462 // query_nodes = new HashSet<PhylogenyNode>();
10463 // query_nodes.add( new PhylogenyNode( "X" ) );
10464 // query_nodes.add( new PhylogenyNode( "Y" ) );
10465 // query_nodes.add( new PhylogenyNode( "F" ) );
10466 // query_nodes.add( new PhylogenyNode( "G" ) );
10467 // if ( !s0.match( query_nodes ) ) {
10471 query_nodes = new HashSet<PhylogenyNode>();
10472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10475 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10476 if ( s0.match( query_nodes ) ) {
10480 query_nodes = new HashSet<PhylogenyNode>();
10481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10482 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10483 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10484 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10485 if ( s0.match( query_nodes ) ) {
10488 ///////////////////////////
10490 query_nodes = new HashSet<PhylogenyNode>();
10491 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10495 if ( s0.match( query_nodes ) ) {
10499 query_nodes = new HashSet<PhylogenyNode>();
10500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10504 if ( s0.match( query_nodes ) ) {
10508 query_nodes = new HashSet<PhylogenyNode>();
10509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10513 if ( s0.match( query_nodes ) ) {
10517 query_nodes = new HashSet<PhylogenyNode>();
10518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10522 if ( s0.match( query_nodes ) ) {
10526 query_nodes = new HashSet<PhylogenyNode>();
10527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10531 if ( s0.match( query_nodes ) ) {
10535 query_nodes = new HashSet<PhylogenyNode>();
10536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10537 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10539 if ( s0.match( query_nodes ) ) {
10543 query_nodes = new HashSet<PhylogenyNode>();
10544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10548 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10549 if ( s0.match( query_nodes ) ) {
10553 query_nodes = new HashSet<PhylogenyNode>();
10554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10558 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10559 if ( s0.match( query_nodes ) ) {
10563 query_nodes = new HashSet<PhylogenyNode>();
10564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10569 if ( s0.match( query_nodes ) ) {
10573 query_nodes = new HashSet<PhylogenyNode>();
10574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10580 if ( s0.match( query_nodes ) ) {
10584 catch ( final Exception e ) {
10585 e.printStackTrace();
10591 private static boolean testSplitStrict() {
10593 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10594 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10595 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10596 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10597 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10598 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10599 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10600 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10601 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10602 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10603 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10604 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10606 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10607 if ( s0.match( query_nodes ) ) {
10610 query_nodes = new HashSet<PhylogenyNode>();
10611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10618 if ( !s0.match( query_nodes ) ) {
10622 query_nodes = new HashSet<PhylogenyNode>();
10623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10626 if ( !s0.match( query_nodes ) ) {
10630 query_nodes = new HashSet<PhylogenyNode>();
10631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
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( "A" ) );
10641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10644 if ( !s0.match( query_nodes ) ) {
10648 query_nodes = new HashSet<PhylogenyNode>();
10649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10652 if ( !s0.match( query_nodes ) ) {
10656 query_nodes = new HashSet<PhylogenyNode>();
10657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10659 if ( !s0.match( query_nodes ) ) {
10663 query_nodes = new HashSet<PhylogenyNode>();
10664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10668 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10669 if ( !s0.match( query_nodes ) ) {
10673 query_nodes = new HashSet<PhylogenyNode>();
10674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10677 if ( !s0.match( query_nodes ) ) {
10681 query_nodes = new HashSet<PhylogenyNode>();
10682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10686 if ( !s0.match( query_nodes ) ) {
10690 query_nodes = new HashSet<PhylogenyNode>();
10691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10693 if ( s0.match( query_nodes ) ) {
10697 query_nodes = new HashSet<PhylogenyNode>();
10698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10702 if ( s0.match( query_nodes ) ) {
10706 query_nodes = new HashSet<PhylogenyNode>();
10707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10712 if ( s0.match( query_nodes ) ) {
10716 query_nodes = new HashSet<PhylogenyNode>();
10717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10720 if ( s0.match( query_nodes ) ) {
10724 query_nodes = new HashSet<PhylogenyNode>();
10725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10727 if ( s0.match( query_nodes ) ) {
10731 query_nodes = new HashSet<PhylogenyNode>();
10732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10733 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10734 if ( s0.match( query_nodes ) ) {
10738 query_nodes = new HashSet<PhylogenyNode>();
10739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10740 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10741 if ( s0.match( query_nodes ) ) {
10745 query_nodes = new HashSet<PhylogenyNode>();
10746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10748 if ( s0.match( query_nodes ) ) {
10752 query_nodes = new HashSet<PhylogenyNode>();
10753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10755 if ( s0.match( query_nodes ) ) {
10759 query_nodes = new HashSet<PhylogenyNode>();
10760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10761 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10762 if ( s0.match( query_nodes ) ) {
10766 query_nodes = new HashSet<PhylogenyNode>();
10767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10769 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10770 if ( s0.match( query_nodes ) ) {
10774 query_nodes = new HashSet<PhylogenyNode>();
10775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10777 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10778 if ( s0.match( query_nodes ) ) {
10782 query_nodes = new HashSet<PhylogenyNode>();
10783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10785 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10786 if ( s0.match( query_nodes ) ) {
10790 query_nodes = new HashSet<PhylogenyNode>();
10791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10795 if ( s0.match( query_nodes ) ) {
10799 catch ( final Exception e ) {
10800 e.printStackTrace();
10806 private static boolean testSubtreeDeletion() {
10808 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10809 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10810 t1.deleteSubtree( t1.getNode( "A" ), false );
10811 if ( t1.getNumberOfExternalNodes() != 5 ) {
10814 t1.toNewHampshireX();
10815 t1.deleteSubtree( t1.getNode( "E" ), false );
10816 if ( t1.getNumberOfExternalNodes() != 4 ) {
10819 t1.toNewHampshireX();
10820 t1.deleteSubtree( t1.getNode( "F" ), false );
10821 if ( t1.getNumberOfExternalNodes() != 3 ) {
10824 t1.toNewHampshireX();
10825 t1.deleteSubtree( t1.getNode( "D" ), false );
10826 t1.toNewHampshireX();
10827 if ( t1.getNumberOfExternalNodes() != 3 ) {
10830 t1.deleteSubtree( t1.getNode( "def" ), false );
10831 t1.toNewHampshireX();
10832 if ( t1.getNumberOfExternalNodes() != 2 ) {
10835 t1.deleteSubtree( t1.getNode( "B" ), false );
10836 t1.toNewHampshireX();
10837 if ( t1.getNumberOfExternalNodes() != 1 ) {
10840 t1.deleteSubtree( t1.getNode( "C" ), false );
10841 t1.toNewHampshireX();
10842 if ( t1.getNumberOfExternalNodes() != 1 ) {
10845 t1.deleteSubtree( t1.getNode( "abc" ), false );
10846 t1.toNewHampshireX();
10847 if ( t1.getNumberOfExternalNodes() != 1 ) {
10850 t1.deleteSubtree( t1.getNode( "r" ), false );
10851 if ( t1.getNumberOfExternalNodes() != 0 ) {
10854 if ( !t1.isEmpty() ) {
10857 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10858 t2.deleteSubtree( t2.getNode( "A" ), false );
10859 t2.toNewHampshireX();
10860 if ( t2.getNumberOfExternalNodes() != 5 ) {
10863 t2.deleteSubtree( t2.getNode( "abc" ), false );
10864 t2.toNewHampshireX();
10865 if ( t2.getNumberOfExternalNodes() != 3 ) {
10868 t2.deleteSubtree( t2.getNode( "def" ), false );
10869 t2.toNewHampshireX();
10870 if ( t2.getNumberOfExternalNodes() != 1 ) {
10874 catch ( final Exception e ) {
10875 e.printStackTrace( System.out );
10881 private static boolean testSupportCount() {
10883 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10884 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10885 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10886 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10887 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10888 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10889 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10891 SupportCount.count( t0_1, phylogenies_1, true, false );
10892 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10893 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10894 + "(((((A,B),C),D),E),((F,G),X))"
10895 + "(((((A,Y),B),C),D),((F,G),E))"
10896 + "(((((A,B),C),D),E),(F,G))"
10897 + "(((((A,B),C),D),E),(F,G))"
10898 + "(((((A,B),C),D),E),(F,G))"
10899 + "(((((A,B),C),D),E),(F,G),Z)"
10900 + "(((((A,B),C),D),E),(F,G))"
10901 + "((((((A,B),C),D),E),F),G)"
10902 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10904 SupportCount.count( t0_2, phylogenies_2, true, false );
10905 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10906 while ( it.hasNext() ) {
10907 final PhylogenyNode n = it.next();
10908 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10912 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10913 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10914 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10915 SupportCount.count( t0_3, phylogenies_3, true, false );
10916 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10917 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10920 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10923 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10926 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10929 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10932 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10935 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10938 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10941 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10944 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10947 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10948 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10949 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10950 SupportCount.count( t0_4, phylogenies_4, true, false );
10951 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10952 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10955 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10958 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10961 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10964 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10967 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10970 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10973 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10976 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10979 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10982 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10983 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10984 double d = SupportCount.compare( b1, a, true, true, true );
10985 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10988 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10989 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10990 d = SupportCount.compare( b2, a, true, true, true );
10991 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10994 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10995 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10996 d = SupportCount.compare( b3, a, true, true, true );
10997 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11000 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11001 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11002 d = SupportCount.compare( b4, a, true, true, false );
11003 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11007 catch ( final Exception e ) {
11008 e.printStackTrace( System.out );
11014 private static boolean testSupportTransfer() {
11016 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11017 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)",
11018 new NHXParser() )[ 0 ];
11019 final Phylogeny p2 = factory
11020 .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 ];
11021 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11024 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11027 support_transfer.moveBranchLengthsToBootstrap( p1 );
11028 support_transfer.transferSupportValues( p1, p2 );
11029 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11032 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11035 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11038 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11041 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11044 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11047 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11050 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11054 catch ( final Exception e ) {
11055 e.printStackTrace( System.out );
11061 private static boolean testTaxonomyExtraction() {
11063 final PhylogenyNode n0 = PhylogenyNode
11064 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11065 if ( n0.getNodeData().isHasTaxonomy() ) {
11068 final PhylogenyNode n1 = PhylogenyNode
11069 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11070 if ( n1.getNodeData().isHasTaxonomy() ) {
11071 System.out.println( n1.toString() );
11074 final PhylogenyNode n2x = PhylogenyNode
11075 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11076 if ( n2x.getNodeData().isHasTaxonomy() ) {
11079 final PhylogenyNode n3 = PhylogenyNode
11080 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11081 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11082 System.out.println( n3.toString() );
11085 final PhylogenyNode n4 = PhylogenyNode
11086 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11087 if ( n4.getNodeData().isHasTaxonomy() ) {
11088 System.out.println( n4.toString() );
11091 final PhylogenyNode n5 = PhylogenyNode
11092 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11093 if ( n5.getNodeData().isHasTaxonomy() ) {
11094 System.out.println( n5.toString() );
11097 final PhylogenyNode n6 = PhylogenyNode
11098 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11099 if ( n6.getNodeData().isHasTaxonomy() ) {
11100 System.out.println( n6.toString() );
11103 final PhylogenyNode n7 = PhylogenyNode
11104 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11105 if ( n7.getNodeData().isHasTaxonomy() ) {
11106 System.out.println( n7.toString() );
11109 final PhylogenyNode n8 = PhylogenyNode
11110 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11111 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11112 System.out.println( n8.toString() );
11115 final PhylogenyNode n9 = PhylogenyNode
11116 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11117 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11118 System.out.println( n9.toString() );
11121 final PhylogenyNode n10x = PhylogenyNode
11122 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11123 if ( n10x.getNodeData().isHasTaxonomy() ) {
11124 System.out.println( n10x.toString() );
11127 final PhylogenyNode n10xx = PhylogenyNode
11128 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11129 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11130 System.out.println( n10xx.toString() );
11133 final PhylogenyNode n10 = PhylogenyNode
11134 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11135 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11136 System.out.println( n10.toString() );
11139 final PhylogenyNode n11 = PhylogenyNode
11140 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11141 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11142 System.out.println( n11.toString() );
11145 final PhylogenyNode n12 = PhylogenyNode
11146 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11147 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11148 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11149 System.out.println( n12.toString() );
11152 final PhylogenyNode n13 = PhylogenyNode
11153 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11154 if ( n13.getNodeData().isHasTaxonomy() ) {
11155 System.out.println( n13.toString() );
11159 catch ( final Exception e ) {
11160 e.printStackTrace( System.out );
11166 private static boolean testTreeMethods() {
11168 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11169 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
11170 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
11171 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
11172 System.out.println( t0.toNewHampshireX() );
11175 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
11176 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
11177 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
11180 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
11183 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
11187 catch ( final Exception e ) {
11188 e.printStackTrace( System.out );
11194 private static boolean testSequenceDbWsTools1() {
11196 final PhylogenyNode n = new PhylogenyNode();
11197 n.setName( "NP_001025424" );
11198 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11199 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11200 || !acc.getValue().equals( "NP_001025424" ) ) {
11203 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11204 acc = SequenceDbWsTools.obtainSeqAccession( n );
11205 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11206 || !acc.getValue().equals( "NP_001025424" ) ) {
11209 n.setName( "NP_001025424.1" );
11210 acc = SequenceDbWsTools.obtainSeqAccession( n );
11211 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11212 || !acc.getValue().equals( "NP_001025424" ) ) {
11215 n.setName( "NM_001030253" );
11216 acc = SequenceDbWsTools.obtainSeqAccession( n );
11217 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11218 || !acc.getValue().equals( "NM_001030253" ) ) {
11221 n.setName( "BCL2_HUMAN" );
11222 acc = SequenceDbWsTools.obtainSeqAccession( n );
11223 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11224 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11225 System.out.println( acc.toString() );
11228 n.setName( "P10415" );
11229 acc = SequenceDbWsTools.obtainSeqAccession( n );
11230 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11231 || !acc.getValue().equals( "P10415" ) ) {
11232 System.out.println( acc.toString() );
11235 n.setName( " P10415 " );
11236 acc = SequenceDbWsTools.obtainSeqAccession( n );
11237 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11238 || !acc.getValue().equals( "P10415" ) ) {
11239 System.out.println( acc.toString() );
11242 n.setName( "_P10415|" );
11243 acc = SequenceDbWsTools.obtainSeqAccession( n );
11244 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11245 || !acc.getValue().equals( "P10415" ) ) {
11246 System.out.println( acc.toString() );
11249 n.setName( "AY695820" );
11250 acc = SequenceDbWsTools.obtainSeqAccession( n );
11251 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11252 || !acc.getValue().equals( "AY695820" ) ) {
11253 System.out.println( acc.toString() );
11256 n.setName( "_AY695820_" );
11257 acc = SequenceDbWsTools.obtainSeqAccession( n );
11258 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11259 || !acc.getValue().equals( "AY695820" ) ) {
11260 System.out.println( acc.toString() );
11263 n.setName( "AAA59452" );
11264 acc = SequenceDbWsTools.obtainSeqAccession( n );
11265 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11266 || !acc.getValue().equals( "AAA59452" ) ) {
11267 System.out.println( acc.toString() );
11270 n.setName( "_AAA59452_" );
11271 acc = SequenceDbWsTools.obtainSeqAccession( n );
11272 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11273 || !acc.getValue().equals( "AAA59452" ) ) {
11274 System.out.println( acc.toString() );
11277 n.setName( "AAA59452.1" );
11278 acc = SequenceDbWsTools.obtainSeqAccession( n );
11279 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11280 || !acc.getValue().equals( "AAA59452.1" ) ) {
11281 System.out.println( acc.toString() );
11284 n.setName( "_AAA59452.1_" );
11285 acc = SequenceDbWsTools.obtainSeqAccession( n );
11286 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11287 || !acc.getValue().equals( "AAA59452.1" ) ) {
11288 System.out.println( acc.toString() );
11291 n.setName( "GI:94894583" );
11292 acc = SequenceDbWsTools.obtainSeqAccession( n );
11293 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11294 || !acc.getValue().equals( "94894583" ) ) {
11295 System.out.println( acc.toString() );
11299 catch ( final Exception e ) {
11305 private static boolean testSequenceDbWsTools2() {
11307 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11308 SequenceDbWsTools.obtainSeqInformation( n1 );
11309 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11312 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11315 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11318 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11321 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11322 SequenceDbWsTools.obtainSeqInformation( n2 );
11323 System.out.println( n2.toString() );
11324 if ( !n2.getNodeData().getSequence().getName()
11325 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11328 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11331 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11334 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11337 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11338 SequenceDbWsTools.obtainSeqInformation( n3 );
11339 System.out.println( "n=" + n3.toString() );
11340 if ( !n3.getNodeData().getSequence().getName()
11341 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11344 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11347 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11350 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11354 catch ( final IOException e ) {
11355 System.out.println();
11356 System.out.println( "the following might be due to absence internet connection:" );
11357 e.printStackTrace( System.out );
11360 catch ( final Exception e ) {
11361 e.printStackTrace();
11367 private static boolean testEbiEntryRetrieval() {
11369 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
11370 if ( !entry.getAccession().equals( "AAK41263" ) ) {
11371 System.out.println( entry.getAccession() );
11374 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
11375 System.out.println( entry.getTaxonomyScientificName() );
11378 if ( !entry.getSequenceName()
11379 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
11380 System.out.println( entry.getSequenceName() );
11383 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
11384 // System.out.println( entry.getSequenceSymbol() );
11387 if ( !entry.getGeneName().equals( "treX-like" ) ) {
11388 System.out.println( entry.getGeneName() );
11391 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
11392 System.out.println( entry.getTaxonomyIdentifier() );
11395 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
11396 System.out.println( entry.getAnnotations().first().getRefValue() );
11399 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
11400 System.out.println( entry.getAnnotations().first().getRefSource() );
11403 if ( entry.getCrossReferences().size() != 5 ) {
11407 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
11408 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
11411 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
11412 System.out.println( entry1.getTaxonomyScientificName() );
11415 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
11416 System.out.println( entry1.getSequenceName() );
11419 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
11420 System.out.println( entry1.getTaxonomyIdentifier() );
11423 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
11424 System.out.println( entry1.getGeneName() );
11427 if ( entry1.getCrossReferences().size() != 6 ) {
11431 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
11432 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
11435 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11436 System.out.println( entry2.getTaxonomyScientificName() );
11439 if ( !entry2.getSequenceName()
11440 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11441 System.out.println( entry2.getSequenceName() );
11444 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
11445 System.out.println( entry2.getTaxonomyIdentifier() );
11448 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
11449 System.out.println( entry2.getGeneName() );
11452 if ( entry2.getCrossReferences().size() != 3 ) {
11456 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
11457 if ( !entry3.getAccession().equals( "HM043801" ) ) {
11460 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
11461 System.out.println( entry3.getTaxonomyScientificName() );
11464 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
11465 System.out.println( entry3.getSequenceName() );
11468 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
11469 System.out.println( entry3.getTaxonomyIdentifier() );
11472 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
11473 System.out.println( entry3.getSequenceSymbol() );
11476 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
11479 if ( entry3.getCrossReferences().size() != 8 ) {
11484 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
11485 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
11488 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11489 System.out.println( entry4.getTaxonomyScientificName() );
11492 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
11493 System.out.println( entry4.getSequenceName() );
11496 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
11497 System.out.println( entry4.getTaxonomyIdentifier() );
11500 if ( !entry4.getGeneName().equals( "ras" ) ) {
11501 System.out.println( entry4.getGeneName() );
11504 // if ( !entry4.getChromosome().equals( "ras" ) ) {
11505 // System.out.println( entry4.getChromosome() );
11508 // if ( !entry4.getMap().equals( "ras" ) ) {
11509 // System.out.println( entry4.getMap() );
11514 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
11515 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
11519 catch ( final IOException e ) {
11520 System.out.println();
11521 System.out.println( "the following might be due to absence internet connection:" );
11522 e.printStackTrace( System.out );
11525 catch ( final Exception e ) {
11526 e.printStackTrace();
11532 private static boolean testUniprotEntryRetrieval() {
11534 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11535 if ( !entry.getAccession().equals( "P12345" ) ) {
11538 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11541 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11544 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11547 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11550 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11554 catch ( final IOException e ) {
11555 System.out.println();
11556 System.out.println( "the following might be due to absence internet connection:" );
11557 e.printStackTrace( System.out );
11560 catch ( final Exception e ) {
11566 private static boolean testUniprotTaxonomySearch() {
11568 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11570 if ( results.size() != 1 ) {
11573 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11576 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11579 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11582 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11585 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11589 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11590 if ( results.size() != 1 ) {
11593 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11596 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11599 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11602 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11605 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11609 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11610 if ( results.size() != 1 ) {
11613 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11616 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11619 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11622 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11625 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11629 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11630 if ( results.size() != 1 ) {
11633 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11636 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11639 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11642 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11645 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11648 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11651 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11654 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11655 .equals( "Nematostella vectensis" ) ) {
11656 System.out.println( results.get( 0 ).getLineage() );
11661 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11662 if ( results.size() != 1 ) {
11665 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11668 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11671 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11674 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11677 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11680 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11681 .equals( "Xenopus tropicalis" ) ) {
11682 System.out.println( results.get( 0 ).getLineage() );
11687 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11688 if ( results.size() != 1 ) {
11691 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11694 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11697 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11700 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11703 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11706 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11707 .equals( "Xenopus tropicalis" ) ) {
11708 System.out.println( results.get( 0 ).getLineage() );
11713 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11714 if ( results.size() != 1 ) {
11717 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11720 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11723 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11726 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11729 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11732 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11733 .equals( "Xenopus tropicalis" ) ) {
11734 System.out.println( results.get( 0 ).getLineage() );
11738 catch ( final IOException e ) {
11739 System.out.println();
11740 System.out.println( "the following might be due to absence internet connection:" );
11741 e.printStackTrace( System.out );
11744 catch ( final Exception e ) {
11750 private static boolean testWabiTxSearch() {
11752 String result = "";
11753 result = TxSearch.searchSimple( "nematostella" );
11754 result = TxSearch.getTxId( "nematostella" );
11755 if ( !result.equals( "45350" ) ) {
11758 result = TxSearch.getTxName( "45350" );
11759 if ( !result.equals( "Nematostella" ) ) {
11762 result = TxSearch.getTxId( "nematostella vectensis" );
11763 if ( !result.equals( "45351" ) ) {
11766 result = TxSearch.getTxName( "45351" );
11767 if ( !result.equals( "Nematostella vectensis" ) ) {
11770 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11771 if ( !result.equals( "536089" ) ) {
11774 result = TxSearch.getTxName( "536089" );
11775 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11778 final List<String> queries = new ArrayList<String>();
11779 queries.add( "Campylobacter coli" );
11780 queries.add( "Escherichia coli" );
11781 queries.add( "Arabidopsis" );
11782 queries.add( "Trichoplax" );
11783 queries.add( "Samanea saman" );
11784 queries.add( "Kluyveromyces marxianus" );
11785 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11786 queries.add( "Bornavirus parrot/PDD/2008" );
11787 final List<RANKS> ranks = new ArrayList<RANKS>();
11788 ranks.add( RANKS.SUPERKINGDOM );
11789 ranks.add( RANKS.KINGDOM );
11790 ranks.add( RANKS.FAMILY );
11791 ranks.add( RANKS.GENUS );
11792 ranks.add( RANKS.TRIBE );
11793 result = TxSearch.searchLineage( queries, ranks );
11794 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11795 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11797 catch ( final Exception e ) {
11798 System.out.println();
11799 System.out.println( "the following might be due to absence internet connection:" );
11800 e.printStackTrace( System.out );