ec44a869201f43afa87e6262d08f18ad233985f3
[jalview.git] / forester / java / src / org / forester / test / Test.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25
26 package org.forester.test;
27
28 import java.io.ByteArrayInputStream;
29 import java.io.File;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.net.URL;
33 import java.util.ArrayList;
34 import java.util.Date;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Locale;
39 import java.util.Set;
40 import java.util.SortedSet;
41
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.archaeopteryx.webservices.WebserviceUtil;
45 import org.forester.development.DevelopmentTools;
46 import org.forester.evoinference.TestPhylogenyReconstruction;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
48 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
49 import org.forester.go.TestGo;
50 import org.forester.io.parsers.FastaParser;
51 import org.forester.io.parsers.GeneralMsaParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser;
53 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
54 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
55 import org.forester.io.parsers.nexus.NexusCharactersParser;
56 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
57 import org.forester.io.parsers.nhx.NHXParser;
58 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
59 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
60 import org.forester.io.parsers.tol.TolParser;
61 import org.forester.io.parsers.util.ParserUtils;
62 import org.forester.io.writers.PhylogenyWriter;
63 import org.forester.io.writers.SequenceWriter;
64 import org.forester.msa.BasicMsa;
65 import org.forester.msa.Mafft;
66 import org.forester.msa.Msa;
67 import org.forester.msa.MsaInferrer;
68 import org.forester.msa.MsaMethods;
69 import org.forester.pccx.TestPccx;
70 import org.forester.phylogeny.Phylogeny;
71 import org.forester.phylogeny.PhylogenyBranch;
72 import org.forester.phylogeny.PhylogenyMethods;
73 import org.forester.phylogeny.PhylogenyNode;
74 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
75 import org.forester.phylogeny.data.Accession;
76 import org.forester.phylogeny.data.Accession.Source;
77 import org.forester.phylogeny.data.BinaryCharacters;
78 import org.forester.phylogeny.data.BranchWidth;
79 import org.forester.phylogeny.data.Confidence;
80 import org.forester.phylogeny.data.Distribution;
81 import org.forester.phylogeny.data.DomainArchitecture;
82 import org.forester.phylogeny.data.Event;
83 import org.forester.phylogeny.data.Identifier;
84 import org.forester.phylogeny.data.PhylogenyData;
85 import org.forester.phylogeny.data.PhylogenyDataUtil;
86 import org.forester.phylogeny.data.Polygon;
87 import org.forester.phylogeny.data.PropertiesMap;
88 import org.forester.phylogeny.data.Property;
89 import org.forester.phylogeny.data.Property.AppliesTo;
90 import org.forester.phylogeny.data.ProteinDomain;
91 import org.forester.phylogeny.data.Taxonomy;
92 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
93 import org.forester.phylogeny.factories.PhylogenyFactory;
94 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
95 import org.forester.protein.BasicDomain;
96 import org.forester.protein.BasicProtein;
97 import org.forester.protein.Domain;
98 import org.forester.protein.Protein;
99 import org.forester.protein.ProteinId;
100 import org.forester.rio.TestRIO;
101 import org.forester.sdi.SDI;
102 import org.forester.sdi.SDIR;
103 import org.forester.sdi.TestGSDI;
104 import org.forester.sequence.BasicSequence;
105 import org.forester.sequence.Sequence;
106 import org.forester.species.BasicSpecies;
107 import org.forester.species.Species;
108 import org.forester.surfacing.TestSurfacing;
109 import org.forester.tools.ConfidenceAssessor;
110 import org.forester.tools.SupportCount;
111 import org.forester.tools.TreeSplitMatrix;
112 import org.forester.util.AsciiHistogram;
113 import org.forester.util.BasicDescriptiveStatistics;
114 import org.forester.util.BasicTable;
115 import org.forester.util.BasicTableParser;
116 import org.forester.util.DescriptiveStatistics;
117 import org.forester.util.ForesterConstants;
118 import org.forester.util.ForesterUtil;
119 import org.forester.util.GeneralTable;
120 import org.forester.util.SequenceAccessionTools;
121 import org.forester.ws.seqdb.SequenceDatabaseEntry;
122 import org.forester.ws.seqdb.SequenceDbWsTools;
123 import org.forester.ws.seqdb.UniProtTaxonomy;
124 import org.forester.ws.wabi.TxSearch;
125 import org.forester.ws.wabi.TxSearch.RANKS;
126 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
127 import org.forester.ws.wabi.TxSearch.TAX_RANK;
128
129 @SuppressWarnings( "unused")
130 public final class Test {
131
132     private final static String  PATH_TO_RESOURCES         = System.getProperty( "user.dir" )
133                                                                    + ForesterUtil.getFileSeparator() + "resources"
134                                                                    + ForesterUtil.getFileSeparator();
135     private final static String  PATH_TO_TEST_DATA         = System.getProperty( "user.dir" )
136                                                                    + ForesterUtil.getFileSeparator() + "test_data"
137                                                                    + ForesterUtil.getFileSeparator();
138     private final static boolean PERFORM_DB_TESTS          = false;
139     private static final boolean PERFORM_WEB_TREE_ACCESS   = true;
140     private static final String  PHYLOXML_LOCAL_XSD        = PATH_TO_RESOURCES + "phyloxml_schema/"
141                                                                    + ForesterConstants.PHYLO_XML_VERSION + "/"
142                                                                    + ForesterConstants.PHYLO_XML_XSD;
143     private static final String  PHYLOXML_REMOTE_XSD       = ForesterConstants.PHYLO_XML_LOCATION + "/"
144                                                                    + ForesterConstants.PHYLO_XML_VERSION + "/"
145                                                                    + ForesterConstants.PHYLO_XML_XSD;
146     private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
147     private final static double  ZERO_DIFF                 = 1.0E-9;
148
149     public static boolean isEqual( final double a, final double b ) {
150         return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
151     }
152
153     public static void main( final String[] args ) {
154         System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
155         System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
156                 + "]" );
157         Locale.setDefault( Locale.US );
158         System.out.println( "[Locale: " + Locale.getDefault() + "]" );
159         int failed = 0;
160         int succeeded = 0;
161         System.out.print( "[Test if directory with files for testing exists/is readable: " );
162         if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
163             System.out.println( "OK.]" );
164         }
165         else {
166             System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
167             System.out.println( "Testing aborted." );
168             System.exit( -1 );
169         }
170         System.out.print( "[Test if resources directory exists/is readable: " );
171         if ( testDir( PATH_TO_RESOURCES ) ) {
172             System.out.println( "OK.]" );
173         }
174         else {
175             System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
176             System.out.println( "Testing aborted." );
177             System.exit( -1 );
178         }
179         final long start_time = new Date().getTime();
180         System.out.print( "Basic node methods: " );
181         if ( Test.testBasicNodeMethods() ) {
182             System.out.println( "OK." );
183             succeeded++;
184         }
185         else {
186             System.out.println( "failed." );
187             failed++;
188         }
189         System.out.print( "Protein id: " );
190         if ( !testProteinId() ) {
191             System.out.println( "failed." );
192             failed++;
193         }
194         else {
195             succeeded++;
196         }
197         System.out.println( "OK." );
198         System.out.print( "Species: " );
199         if ( !testSpecies() ) {
200             System.out.println( "failed." );
201             failed++;
202         }
203         else {
204             succeeded++;
205         }
206         System.out.println( "OK." );
207         System.out.print( "Basic domain: " );
208         if ( !testBasicDomain() ) {
209             System.out.println( "failed." );
210             failed++;
211         }
212         else {
213             succeeded++;
214         }
215         System.out.println( "OK." );
216         System.out.print( "Basic protein: " );
217         if ( !testBasicProtein() ) {
218             System.out.println( "failed." );
219             failed++;
220         }
221         else {
222             succeeded++;
223         }
224         System.out.println( "OK." );
225         System.out.print( "Sequence writer: " );
226         if ( testSequenceWriter() ) {
227             System.out.println( "OK." );
228             succeeded++;
229         }
230         else {
231             System.out.println( "failed." );
232             failed++;
233         }
234         System.out.print( "Sequence id parsing: " );
235         if ( testSequenceIdParsing() ) {
236             System.out.println( "OK." );
237             succeeded++;
238         }
239         else {
240             System.out.println( "failed." );
241             failed++;
242         }
243         System.out.print( "UniProtKB id extraction: " );
244         if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
245             System.out.println( "OK." );
246             succeeded++;
247         }
248         else {
249             System.out.println( "failed." );
250             failed++;
251         }
252         System.out.print( "Sequence DB tools 1: " );
253         if ( testSequenceDbWsTools1() ) {
254             System.out.println( "OK." );
255             succeeded++;
256         }
257         else {
258             System.out.println( "failed." );
259             failed++;
260         }
261         System.out.print( "Hmmscan output parser: " );
262         if ( testHmmscanOutputParser() ) {
263             System.out.println( "OK." );
264             succeeded++;
265         }
266         else {
267             System.out.println( "failed." );
268             failed++;
269         }
270         System.out.print( "Overlap removal: " );
271         if ( !org.forester.test.Test.testOverlapRemoval() ) {
272             System.out.println( "failed." );
273             failed++;
274         }
275         else {
276             succeeded++;
277         }
278         System.out.println( "OK." );
279         System.out.print( "Engulfing overlap removal: " );
280         if ( !Test.testEngulfingOverlapRemoval() ) {
281             System.out.println( "failed." );
282             failed++;
283         }
284         else {
285             succeeded++;
286         }
287         System.out.println( "OK." );
288         System.out.print( "Taxonomy code extraction: " );
289         if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
290             System.out.println( "OK." );
291             succeeded++;
292         }
293         else {
294             System.out.println( "failed." );
295             failed++;
296         }
297         System.out.print( "SN extraction: " );
298         if ( Test.testExtractSNFromNodeName() ) {
299             System.out.println( "OK." );
300             succeeded++;
301         }
302         else {
303             System.out.println( "failed." );
304             failed++;
305         }
306         System.out.print( "Taxonomy extraction (general): " );
307         if ( Test.testTaxonomyExtraction() ) {
308             System.out.println( "OK." );
309             succeeded++;
310         }
311         else {
312             System.out.println( "failed." );
313             failed++;
314         }
315         System.out.print( "Uri for Aptx web sequence accession: " );
316         if ( Test.testCreateUriForSeqWeb() ) {
317             System.out.println( "OK." );
318             succeeded++;
319         }
320         else {
321             System.out.println( "failed." );
322             failed++;
323         }
324         System.out.print( "Basic node construction and parsing of NHX (node level): " );
325         if ( Test.testNHXNodeParsing() ) {
326             System.out.println( "OK." );
327             succeeded++;
328         }
329         else {
330             System.out.println( "failed." );
331             failed++;
332         }
333         System.out.print( "NHX parsing iterating: " );
334         if ( Test.testNHParsingIter() ) {
335             System.out.println( "OK." );
336             succeeded++;
337         }
338         else {
339             System.out.println( "failed." );
340             failed++;
341         }
342         System.out.print( "NH parsing: " );
343         if ( Test.testNHParsing() ) {
344             System.out.println( "OK." );
345             succeeded++;
346         }
347         else {
348             System.out.println( "failed." );
349             failed++;
350         }
351         System.out.print( "Conversion to NHX (node level): " );
352         if ( Test.testNHXconversion() ) {
353             System.out.println( "OK." );
354             succeeded++;
355         }
356         else {
357             System.out.println( "failed." );
358             failed++;
359         }
360         System.out.print( "NHX parsing: " );
361         if ( Test.testNHXParsing() ) {
362             System.out.println( "OK." );
363             succeeded++;
364         }
365         else {
366             System.out.println( "failed." );
367             failed++;
368         }
369         System.out.print( "NHX parsing with quotes: " );
370         if ( Test.testNHXParsingQuotes() ) {
371             System.out.println( "OK." );
372             succeeded++;
373         }
374         else {
375             System.out.println( "failed." );
376             failed++;
377         }
378         System.out.print( "NHX parsing (MrBayes): " );
379         if ( Test.testNHXParsingMB() ) {
380             System.out.println( "OK." );
381             succeeded++;
382         }
383         else {
384             System.out.println( "failed." );
385             failed++;
386         }
387         System.exit( 0 );
388         System.out.print( "Nexus characters parsing: " );
389         if ( Test.testNexusCharactersParsing() ) {
390             System.out.println( "OK." );
391             succeeded++;
392         }
393         else {
394             System.out.println( "failed." );
395             failed++;
396         }
397         System.out.print( "Nexus tree parsing iterating: " );
398         if ( Test.testNexusTreeParsingIterating() ) {
399             System.out.println( "OK." );
400             succeeded++;
401         }
402         else {
403             System.out.println( "failed." );
404             failed++;
405         }
406         System.out.print( "Nexus tree parsing: " );
407         if ( Test.testNexusTreeParsing() ) {
408             System.out.println( "OK." );
409             succeeded++;
410         }
411         else {
412             System.out.println( "failed." );
413             failed++;
414         }
415         System.out.print( "Nexus tree parsing (translating): " );
416         if ( Test.testNexusTreeParsingTranslating() ) {
417             System.out.println( "OK." );
418             succeeded++;
419         }
420         else {
421             System.out.println( "failed." );
422             failed++;
423         }
424         System.out.print( "Nexus matrix parsing: " );
425         if ( Test.testNexusMatrixParsing() ) {
426             System.out.println( "OK." );
427             succeeded++;
428         }
429         else {
430             System.out.println( "failed." );
431             failed++;
432         }
433         System.out.print( "Basic phyloXML parsing: " );
434         if ( Test.testBasicPhyloXMLparsing() ) {
435             System.out.println( "OK." );
436             succeeded++;
437         }
438         else {
439             System.out.println( "failed." );
440             failed++;
441         }
442         System.out.print( "Basic phyloXML parsing (validating against schema): " );
443         if ( testBasicPhyloXMLparsingValidating() ) {
444             System.out.println( "OK." );
445             succeeded++;
446         }
447         else {
448             System.out.println( "failed." );
449             failed++;
450         }
451         System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
452         if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
453             System.out.println( "OK." );
454             succeeded++;
455         }
456         else {
457             System.out.println( "failed." );
458             failed++;
459         }
460         System.out.print( "phyloXML Distribution Element: " );
461         if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
462             System.out.println( "OK." );
463             succeeded++;
464         }
465         else {
466             System.out.println( "failed." );
467             failed++;
468         }
469         System.out.print( "Tol XML parsing: " );
470         if ( Test.testBasicTolXMLparsing() ) {
471             System.out.println( "OK." );
472             succeeded++;
473         }
474         else {
475             System.out.println( "failed." );
476             failed++;
477         }
478         System.out.print( "Copying of node data: " );
479         if ( Test.testCopyOfNodeData() ) {
480             System.out.println( "OK." );
481             succeeded++;
482         }
483         else {
484             System.out.println( "failed." );
485             failed++;
486         }
487         System.out.print( "Tree copy: " );
488         if ( Test.testTreeCopy() ) {
489             System.out.println( "OK." );
490             succeeded++;
491         }
492         else {
493             System.out.println( "failed." );
494             failed++;
495         }
496         System.out.print( "Basic tree methods: " );
497         if ( Test.testBasicTreeMethods() ) {
498             System.out.println( "OK." );
499             succeeded++;
500         }
501         else {
502             System.out.println( "failed." );
503             failed++;
504         }
505         System.out.print( "Tree methods: " );
506         if ( Test.testTreeMethods() ) {
507             System.out.println( "OK." );
508             succeeded++;
509         }
510         else {
511             System.out.println( "failed." );
512             failed++;
513         }
514         System.out.print( "Postorder Iterator: " );
515         if ( Test.testPostOrderIterator() ) {
516             System.out.println( "OK." );
517             succeeded++;
518         }
519         else {
520             System.out.println( "failed." );
521             failed++;
522         }
523         System.out.print( "Preorder Iterator: " );
524         if ( Test.testPreOrderIterator() ) {
525             System.out.println( "OK." );
526             succeeded++;
527         }
528         else {
529             System.out.println( "failed." );
530             failed++;
531         }
532         System.out.print( "Levelorder Iterator: " );
533         if ( Test.testLevelOrderIterator() ) {
534             System.out.println( "OK." );
535             succeeded++;
536         }
537         else {
538             System.out.println( "failed." );
539             failed++;
540         }
541         System.out.print( "Re-id methods: " );
542         if ( Test.testReIdMethods() ) {
543             System.out.println( "OK." );
544             succeeded++;
545         }
546         else {
547             System.out.println( "failed." );
548             failed++;
549         }
550         System.out.print( "Methods on last external nodes: " );
551         if ( Test.testLastExternalNodeMethods() ) {
552             System.out.println( "OK." );
553             succeeded++;
554         }
555         else {
556             System.out.println( "failed." );
557             failed++;
558         }
559         System.out.print( "Methods on external nodes: " );
560         if ( Test.testExternalNodeRelatedMethods() ) {
561             System.out.println( "OK." );
562             succeeded++;
563         }
564         else {
565             System.out.println( "failed." );
566             failed++;
567         }
568         System.out.print( "Deletion of external nodes: " );
569         if ( Test.testDeletionOfExternalNodes() ) {
570             System.out.println( "OK." );
571             succeeded++;
572         }
573         else {
574             System.out.println( "failed." );
575             failed++;
576         }
577         System.out.print( "Subtree deletion: " );
578         if ( Test.testSubtreeDeletion() ) {
579             System.out.println( "OK." );
580             succeeded++;
581         }
582         else {
583             System.out.println( "failed." );
584             failed++;
585         }
586         System.out.print( "Phylogeny branch: " );
587         if ( Test.testPhylogenyBranch() ) {
588             System.out.println( "OK." );
589             succeeded++;
590         }
591         else {
592             System.out.println( "failed." );
593             failed++;
594         }
595         System.out.print( "Rerooting: " );
596         if ( Test.testRerooting() ) {
597             System.out.println( "OK." );
598             succeeded++;
599         }
600         else {
601             System.out.println( "failed." );
602             failed++;
603         }
604         System.out.print( "Mipoint rooting: " );
605         if ( Test.testMidpointrooting() ) {
606             System.out.println( "OK." );
607             succeeded++;
608         }
609         else {
610             System.out.println( "failed." );
611             failed++;
612         }
613         System.out.print( "Node removal: " );
614         if ( Test.testNodeRemoval() ) {
615             System.out.println( "OK." );
616             succeeded++;
617         }
618         else {
619             System.out.println( "failed." );
620             failed++;
621         }
622         System.out.print( "Support count: " );
623         if ( Test.testSupportCount() ) {
624             System.out.println( "OK." );
625             succeeded++;
626         }
627         else {
628             System.out.println( "failed." );
629             failed++;
630         }
631         System.out.print( "Support transfer: " );
632         if ( Test.testSupportTransfer() ) {
633             System.out.println( "OK." );
634             succeeded++;
635         }
636         else {
637             System.out.println( "failed." );
638             failed++;
639         }
640         System.out.print( "Finding of LCA: " );
641         if ( Test.testGetLCA() ) {
642             System.out.println( "OK." );
643             succeeded++;
644         }
645         else {
646             System.out.println( "failed." );
647             failed++;
648         }
649         System.out.print( "Finding of LCA 2: " );
650         if ( Test.testGetLCA2() ) {
651             System.out.println( "OK." );
652             succeeded++;
653         }
654         else {
655             System.out.println( "failed." );
656             failed++;
657         }
658         System.out.print( "Calculation of distance between nodes: " );
659         if ( Test.testGetDistance() ) {
660             System.out.println( "OK." );
661             succeeded++;
662         }
663         else {
664             System.out.println( "failed." );
665             failed++;
666         }
667         System.out.print( "Descriptive statistics: " );
668         if ( Test.testDescriptiveStatistics() ) {
669             System.out.println( "OK." );
670             succeeded++;
671         }
672         else {
673             System.out.println( "failed." );
674             failed++;
675         }
676         System.out.print( "Data objects and methods: " );
677         if ( Test.testDataObjects() ) {
678             System.out.println( "OK." );
679             succeeded++;
680         }
681         else {
682             System.out.println( "failed." );
683             failed++;
684         }
685         System.out.print( "Properties map: " );
686         if ( Test.testPropertiesMap() ) {
687             System.out.println( "OK." );
688             succeeded++;
689         }
690         else {
691             System.out.println( "failed." );
692             failed++;
693         }
694         System.out.print( "SDIse: " );
695         if ( Test.testSDIse() ) {
696             System.out.println( "OK." );
697             succeeded++;
698         }
699         else {
700             System.out.println( "failed." );
701             failed++;
702         }
703         System.out.print( "SDIunrooted: " );
704         if ( Test.testSDIunrooted() ) {
705             System.out.println( "OK." );
706             succeeded++;
707         }
708         else {
709             System.out.println( "failed." );
710             failed++;
711         }
712         System.out.print( "GSDI: " );
713         if ( TestGSDI.test() ) {
714             System.out.println( "OK." );
715             succeeded++;
716         }
717         else {
718             System.out.println( "failed." );
719             failed++;
720         }
721         System.out.print( "RIO: " );
722         if ( TestRIO.test() ) {
723             System.out.println( "OK." );
724             succeeded++;
725         }
726         else {
727             System.out.println( "failed." );
728             failed++;
729         }
730         System.out.print( "Phylogeny reconstruction:" );
731         System.out.println();
732         if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
733             System.out.println( "OK." );
734             succeeded++;
735         }
736         else {
737             System.out.println( "failed." );
738             failed++;
739         }
740         System.out.print( "Analysis of domain architectures: " );
741         System.out.println();
742         if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
743             System.out.println( "OK." );
744             succeeded++;
745         }
746         else {
747             System.out.println( "failed." );
748             failed++;
749         }
750         System.out.print( "GO: " );
751         System.out.println();
752         if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
753             System.out.println( "OK." );
754             succeeded++;
755         }
756         else {
757             System.out.println( "failed." );
758             failed++;
759         }
760         System.out.print( "Modeling tools: " );
761         if ( TestPccx.test() ) {
762             System.out.println( "OK." );
763             succeeded++;
764         }
765         else {
766             System.out.println( "failed." );
767             failed++;
768         }
769         System.out.print( "Split Matrix strict: " );
770         if ( Test.testSplitStrict() ) {
771             System.out.println( "OK." );
772             succeeded++;
773         }
774         else {
775             System.out.println( "failed." );
776             failed++;
777         }
778         System.out.print( "Split Matrix: " );
779         if ( Test.testSplit() ) {
780             System.out.println( "OK." );
781             succeeded++;
782         }
783         else {
784             System.out.println( "failed." );
785             failed++;
786         }
787         System.out.print( "Confidence Assessor: " );
788         if ( Test.testConfidenceAssessor() ) {
789             System.out.println( "OK." );
790             succeeded++;
791         }
792         else {
793             System.out.println( "failed." );
794             failed++;
795         }
796         System.out.print( "Basic table: " );
797         if ( Test.testBasicTable() ) {
798             System.out.println( "OK." );
799             succeeded++;
800         }
801         else {
802             System.out.println( "failed." );
803             failed++;
804         }
805         System.out.print( "General table: " );
806         if ( Test.testGeneralTable() ) {
807             System.out.println( "OK." );
808             succeeded++;
809         }
810         else {
811             System.out.println( "failed." );
812             failed++;
813         }
814         System.out.print( "Amino acid sequence: " );
815         if ( Test.testAminoAcidSequence() ) {
816             System.out.println( "OK." );
817             succeeded++;
818         }
819         else {
820             System.out.println( "failed." );
821             failed++;
822         }
823         System.out.print( "General MSA parser: " );
824         if ( Test.testGeneralMsaParser() ) {
825             System.out.println( "OK." );
826             succeeded++;
827         }
828         else {
829             System.out.println( "failed." );
830             failed++;
831         }
832         System.out.print( "Fasta parser for msa: " );
833         if ( Test.testFastaParser() ) {
834             System.out.println( "OK." );
835             succeeded++;
836         }
837         else {
838             System.out.println( "failed." );
839             failed++;
840         }
841         System.out.print( "Creation of balanced phylogeny: " );
842         if ( Test.testCreateBalancedPhylogeny() ) {
843             System.out.println( "OK." );
844             succeeded++;
845         }
846         else {
847             System.out.println( "failed." );
848             failed++;
849         }
850         System.out.print( "Genbank accessor parsing: " );
851         if ( Test.testGenbankAccessorParsing() ) {
852             System.out.println( "OK." );
853             succeeded++;
854         }
855         else {
856             System.out.println( "failed." );
857             failed++;
858         }
859         String path = "";
860         final String os = ForesterUtil.OS_NAME.toLowerCase();
861         if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
862             path = "/usr/local/bin/mafft";
863         }
864         else if ( os.indexOf( "win" ) >= 0 ) {
865             path = "C:\\Program Files\\mafft-win\\mafft.bat";
866         }
867         else {
868             path = "mafft";
869             if ( !MsaInferrer.isInstalled( path ) ) {
870                 path = "/usr/bin/mafft";
871             }
872             if ( !MsaInferrer.isInstalled( path ) ) {
873                 path = "/usr/local/bin/mafft";
874             }
875         }
876         if ( MsaInferrer.isInstalled( path ) ) {
877             System.out.print( "MAFFT (external program): " );
878             if ( Test.testMafft( path ) ) {
879                 System.out.println( "OK." );
880                 succeeded++;
881             }
882             else {
883                 System.out.println( "failed [will not count towards failed tests]" );
884             }
885         }
886         System.out.print( "Next nodes with collapsed: " );
887         if ( Test.testNextNodeWithCollapsing() ) {
888             System.out.println( "OK." );
889             succeeded++;
890         }
891         else {
892             System.out.println( "failed." );
893             failed++;
894         }
895         System.out.print( "Simple MSA quality: " );
896         if ( Test.testMsaQualityMethod() ) {
897             System.out.println( "OK." );
898             succeeded++;
899         }
900         else {
901             System.out.println( "failed." );
902             failed++;
903         }
904         if ( PERFORM_DB_TESTS ) {
905             System.out.print( "Uniprot Entry Retrieval: " );
906             if ( Test.testUniprotEntryRetrieval() ) {
907                 System.out.println( "OK." );
908                 succeeded++;
909             }
910             else {
911                 System.out.println( "failed." );
912                 failed++;
913             }
914             System.out.print( "Ebi Entry Retrieval: " );
915             if ( Test.testEbiEntryRetrieval() ) {
916                 System.out.println( "OK." );
917                 succeeded++;
918             }
919             else {
920                 System.out.println( "failed." );
921                 failed++;
922             }
923             System.out.print( "Sequence DB tools 2: " );
924             if ( testSequenceDbWsTools2() ) {
925                 System.out.println( "OK." );
926                 succeeded++;
927             }
928             else {
929                 System.out.println( "failed." );
930                 failed++;
931                 System.exit( -1 );
932             }
933             System.out.print( "Uniprot Taxonomy Search: " );
934             if ( Test.testUniprotTaxonomySearch() ) {
935                 System.out.println( "OK." );
936                 succeeded++;
937             }
938             else {
939                 System.out.println( "failed." );
940                 failed++;
941             }
942         }
943         if ( PERFORM_WEB_TREE_ACCESS ) {
944             System.out.print( "NHX parsing from URL: " );
945             if ( Test.testNHXparsingFromURL() ) {
946                 System.out.println( "OK." );
947                 succeeded++;
948             }
949             else {
950                 System.out.println( "failed." );
951                 failed++;
952             }
953             System.out.print( "phyloXML parsing from URL: " );
954             if ( Test.testPhyloXMLparsingFromURL() ) {
955                 System.out.println( "OK." );
956                 succeeded++;
957             }
958             else {
959                 System.out.println( "failed." );
960                 failed++;
961             }
962             System.out.print( "TreeBase acccess: " );
963             if ( Test.testTreeBaseReading() ) {
964                 System.out.println( "OK." );
965                 succeeded++;
966             }
967             else {
968                 System.out.println( "failed." );
969                 failed++;
970             }
971             //
972             System.out.print( "ToL access: " );
973             if ( Test.testToLReading() ) {
974                 System.out.println( "OK." );
975                 succeeded++;
976             }
977             else {
978                 System.out.println( "failed." );
979                 failed++;
980             }
981             //
982             System.out.print( "TreeFam access: " );
983             if ( Test.testTreeFamReading() ) {
984                 System.out.println( "OK." );
985                 succeeded++;
986             }
987             else {
988                 System.out.println( "failed." );
989                 failed++;
990             }
991             //
992             //
993             System.out.print( "Pfam tree access: " );
994             if ( Test.testPfamTreeReading() ) {
995                 System.out.println( "OK." );
996                 succeeded++;
997             }
998             else {
999                 System.out.println( "failed." );
1000                 failed++;
1001             }
1002         }
1003         System.out.println();
1004         final Runtime rt = java.lang.Runtime.getRuntime();
1005         final long free_memory = rt.freeMemory() / 1000000;
1006         final long total_memory = rt.totalMemory() / 1000000;
1007         System.out.println( "Running time    : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1008                 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1009         System.out.println();
1010         System.out.println( "Successful tests: " + succeeded );
1011         System.out.println( "Failed     tests: " + failed );
1012         System.out.println();
1013         if ( failed < 1 ) {
1014             System.out.println( "OK." );
1015         }
1016         else {
1017             System.out.println( "Not OK." );
1018         }
1019     }
1020
1021     public static boolean testEngulfingOverlapRemoval() {
1022         try {
1023             final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1024             final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1025             final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1026             final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1027             final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1028             final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1029             final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1030             final List<Boolean> covered = new ArrayList<Boolean>();
1031             covered.add( true ); // 0
1032             covered.add( false ); // 1
1033             covered.add( true ); // 2
1034             covered.add( false ); // 3
1035             covered.add( true ); // 4
1036             covered.add( true ); // 5
1037             covered.add( false ); // 6
1038             covered.add( true ); // 7
1039             covered.add( true ); // 8
1040             if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1041                 return false;
1042             }
1043             if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1044                 return false;
1045             }
1046             if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1047                 return false;
1048             }
1049             if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1050                 return false;
1051             }
1052             if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1053                 return false;
1054             }
1055             if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1056                 return false;
1057             }
1058             if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1059                 return false;
1060             }
1061             final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1062             final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1063             final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1064             final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1065             abc.addProteinDomain( a );
1066             abc.addProteinDomain( b );
1067             abc.addProteinDomain( c );
1068             final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1069             final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1070             if ( abc.getNumberOfProteinDomains() != 3 ) {
1071                 return false;
1072             }
1073             if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1074                 return false;
1075             }
1076             if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1077                 return false;
1078             }
1079             if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1080                 return false;
1081             }
1082             if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1083                 return false;
1084             }
1085             final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1086             final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1087             final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1088             final Protein def = new BasicProtein( "def", "nemve", 0 );
1089             def.addProteinDomain( d );
1090             def.addProteinDomain( e );
1091             def.addProteinDomain( f );
1092             final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1093             final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1094             if ( def.getNumberOfProteinDomains() != 3 ) {
1095                 return false;
1096             }
1097             if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1098                 return false;
1099             }
1100             if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1101                 return false;
1102             }
1103             if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1104                 return false;
1105             }
1106             if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1107                 return false;
1108             }
1109             if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1110                 return false;
1111             }
1112         }
1113         catch ( final Exception e ) {
1114             e.printStackTrace( System.out );
1115             return false;
1116         }
1117         return true;
1118     }
1119
1120     public static final boolean testNHXparsingFromURL() {
1121         try {
1122             final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1123             final URL u = new URL( s );
1124             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1125             final Phylogeny[] phys = factory.create( u, new NHXParser() );
1126             if ( ( phys == null ) || ( phys.length != 5 ) ) {
1127                 return false;
1128             }
1129             if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1130                 System.out.println( phys[ 0 ].toNewHampshire() );
1131                 return false;
1132             }
1133             if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1134                 System.out.println( phys[ 1 ].toNewHampshire() );
1135                 return false;
1136             }
1137             final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1138             if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1139                 return false;
1140             }
1141             if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1142                 System.out.println( phys2[ 0 ].toNewHampshire() );
1143                 return false;
1144             }
1145             final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1146             final NHXParser p = new NHXParser();
1147             final URL u2 = new URL( s );
1148             p.setSource( u2 );
1149             if ( !p.hasNext() ) {
1150                 return false;
1151             }
1152             if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1153                 return false;
1154             }
1155             if ( !p.hasNext() ) {
1156                 return false;
1157             }
1158             p.reset();
1159             if ( !p.hasNext() ) {
1160                 return false;
1161             }
1162             if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1163                 return false;
1164             }
1165             if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1166                 return false;
1167             }
1168             p.reset();
1169             if ( !p.hasNext() ) {
1170                 return false;
1171             }
1172             if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1173                 return false;
1174             }
1175             if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1176                 return false;
1177             }
1178         }
1179         catch ( final Exception e ) {
1180             e.printStackTrace();
1181         }
1182         return true;
1183     }
1184
1185     public static boolean testOverlapRemoval() {
1186         try {
1187             final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1188             final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1189             final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1190             final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1191             final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1192             final List<Boolean> covered = new ArrayList<Boolean>();
1193             covered.add( true ); // 0
1194             covered.add( false ); // 1
1195             covered.add( true ); // 2
1196             covered.add( false ); // 3
1197             covered.add( true ); // 4
1198             covered.add( true ); // 5
1199             covered.add( false ); // 6
1200             covered.add( true ); // 7
1201             covered.add( true ); // 8
1202             if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1203                 return false;
1204             }
1205             if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1206                 return false;
1207             }
1208             if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1209                 return false;
1210             }
1211             if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1212                 return false;
1213             }
1214             if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1215                 return false;
1216             }
1217             final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1218             final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1219             final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1220             ab.addProteinDomain( a );
1221             ab.addProteinDomain( b );
1222             final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1223             if ( ab.getNumberOfProteinDomains() != 2 ) {
1224                 return false;
1225             }
1226             if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1227                 return false;
1228             }
1229             if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1230                 return false;
1231             }
1232             final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1233             if ( ab.getNumberOfProteinDomains() != 2 ) {
1234                 return false;
1235             }
1236             if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1237                 return false;
1238             }
1239             final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1240             final Domain d = new BasicDomain( "d",
1241                                               ( short ) 10000,
1242                                               ( short ) 10500,
1243                                               ( short ) 1,
1244                                               ( short ) 1,
1245                                               0.0000001,
1246                                               1 );
1247             final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1248             final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1249             cde.addProteinDomain( c );
1250             cde.addProteinDomain( d );
1251             cde.addProteinDomain( e );
1252             final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1253             if ( cde.getNumberOfProteinDomains() != 3 ) {
1254                 return false;
1255             }
1256             if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1257                 return false;
1258             }
1259             final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1260             final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1261             final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1262             final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1263             final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1264             final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1265             fghi.addProteinDomain( f );
1266             fghi.addProteinDomain( g );
1267             fghi.addProteinDomain( h );
1268             fghi.addProteinDomain( i );
1269             fghi.addProteinDomain( i );
1270             fghi.addProteinDomain( i );
1271             fghi.addProteinDomain( i2 );
1272             final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1273             if ( fghi.getNumberOfProteinDomains() != 7 ) {
1274                 return false;
1275             }
1276             if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1277                 return false;
1278             }
1279             if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1280                 return false;
1281             }
1282             final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1283             if ( fghi.getNumberOfProteinDomains() != 7 ) {
1284                 return false;
1285             }
1286             if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1287                 return false;
1288             }
1289             final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1290             final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1291             final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1292             final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1293             final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1294             final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1295             final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1296             final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1297             jklm.addProteinDomain( j );
1298             jklm.addProteinDomain( k );
1299             jklm.addProteinDomain( l );
1300             jklm.addProteinDomain( m );
1301             jklm.addProteinDomain( m0 );
1302             jklm.addProteinDomain( m1 );
1303             jklm.addProteinDomain( m2 );
1304             final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1305             if ( jklm.getNumberOfProteinDomains() != 7 ) {
1306                 return false;
1307             }
1308             if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1309                 return false;
1310             }
1311             if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1312                 return false;
1313             }
1314             final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1315             if ( jklm.getNumberOfProteinDomains() != 7 ) {
1316                 return false;
1317             }
1318             if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1319                 return false;
1320             }
1321             final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1322             final Protein od = new BasicProtein( "od", "varanus", 0 );
1323             od.addProteinDomain( only );
1324             final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1325             if ( od.getNumberOfProteinDomains() != 1 ) {
1326                 return false;
1327             }
1328             if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1329                 return false;
1330             }
1331         }
1332         catch ( final Exception e ) {
1333             e.printStackTrace( System.out );
1334             return false;
1335         }
1336         return true;
1337     }
1338
1339     public static final boolean testPfamTreeReading() {
1340         try {
1341             final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1342             final NHXParser parser = new NHXParser();
1343             parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1344             parser.setReplaceUnderscores( false );
1345             parser.setGuessRootedness( true );
1346             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1347             final Phylogeny[] phys = factory.create( u.openStream(), parser );
1348             if ( ( phys == null ) || ( phys.length != 1 ) ) {
1349                 return false;
1350             }
1351             if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1352                 return false;
1353             }
1354         }
1355         catch ( final Exception e ) {
1356             e.printStackTrace();
1357         }
1358         return true;
1359     }
1360
1361     public static final boolean testPhyloXMLparsingFromURL() {
1362         try {
1363             final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1364             final URL u = new URL( s );
1365             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1366             final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1367             if ( ( phys == null ) || ( phys.length != 2 ) ) {
1368                 return false;
1369             }
1370         }
1371         catch ( final Exception e ) {
1372             e.printStackTrace();
1373         }
1374         return true;
1375     }
1376
1377     public static final boolean testToLReading() {
1378         try {
1379             final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1380             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1381             final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1382             if ( ( phys == null ) || ( phys.length != 1 ) ) {
1383                 return false;
1384             }
1385             if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1386                 return false;
1387             }
1388             if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1389                 return false;
1390             }
1391             if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1392                 return false;
1393             }
1394         }
1395         catch ( final Exception e ) {
1396             e.printStackTrace();
1397         }
1398         return true;
1399     }
1400
1401     public static final boolean testTreeBaseReading() {
1402         try {
1403             final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1404             final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1405             parser.setReplaceUnderscores( true );
1406             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1407             final Phylogeny[] phys = factory.create( u.openStream(), parser );
1408             if ( ( phys == null ) || ( phys.length != 1 ) ) {
1409                 return false;
1410             }
1411             final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1412             final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1413             parser2.setReplaceUnderscores( true );
1414             final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1415             final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1416             if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1417                 return false;
1418             }
1419         }
1420         catch ( final Exception e ) {
1421             e.printStackTrace();
1422         }
1423         return true;
1424     }
1425
1426     public static final boolean testTreeFamReading() {
1427         try {
1428             final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1429             final NHXParser parser = new NHXParser();
1430             parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1431             parser.setReplaceUnderscores( false );
1432             parser.setGuessRootedness( true );
1433             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1434             final Phylogeny[] phys = factory.create( u.openStream(), parser );
1435             if ( ( phys == null ) || ( phys.length != 1 ) ) {
1436                 return false;
1437             }
1438             if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1439                 return false;
1440             }
1441         }
1442         catch ( final Exception e ) {
1443             e.printStackTrace();
1444         }
1445         return true;
1446     }
1447
1448     private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1449         final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1450         return p;
1451     }
1452
1453     private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1454         return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1455     }
1456
1457     private static boolean testAminoAcidSequence() {
1458         try {
1459             final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1460             if ( aa1.getLength() != 13 ) {
1461                 return false;
1462             }
1463             if ( aa1.getResidueAt( 0 ) != 'A' ) {
1464                 return false;
1465             }
1466             if ( aa1.getResidueAt( 2 ) != 'K' ) {
1467                 return false;
1468             }
1469             if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1470                 return false;
1471             }
1472             final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1473             if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1474                 return false;
1475             }
1476             final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1477             if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1478                 return false;
1479             }
1480             final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1481             if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1482                 return false;
1483             }
1484         }
1485         catch ( final Exception e ) {
1486             e.printStackTrace();
1487             return false;
1488         }
1489         return true;
1490     }
1491
1492     private static boolean testBasicDomain() {
1493         try {
1494             final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1495             if ( !pd.getDomainId().equals( "id" ) ) {
1496                 return false;
1497             }
1498             if ( pd.getNumber() != 1 ) {
1499                 return false;
1500             }
1501             if ( pd.getTotalCount() != 4 ) {
1502                 return false;
1503             }
1504             if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1505                 return false;
1506             }
1507             final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1508             final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1509             final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1510             final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1511             final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1512             if ( !a1.equals( a1 ) ) {
1513                 return false;
1514             }
1515             if ( !a1.equals( a1_copy ) ) {
1516                 return false;
1517             }
1518             if ( !a1.equals( a1_equal ) ) {
1519                 return false;
1520             }
1521             if ( !a1.equals( a2 ) ) {
1522                 return false;
1523             }
1524             if ( a1.equals( a3 ) ) {
1525                 return false;
1526             }
1527             if ( a1.compareTo( a1 ) != 0 ) {
1528                 return false;
1529             }
1530             if ( a1.compareTo( a1_copy ) != 0 ) {
1531                 return false;
1532             }
1533             if ( a1.compareTo( a1_equal ) != 0 ) {
1534                 return false;
1535             }
1536             if ( a1.compareTo( a2 ) != 0 ) {
1537                 return false;
1538             }
1539             if ( a1.compareTo( a3 ) == 0 ) {
1540                 return false;
1541             }
1542         }
1543         catch ( final Exception e ) {
1544             e.printStackTrace( System.out );
1545             return false;
1546         }
1547         return true;
1548     }
1549
1550     private static boolean testBasicNodeMethods() {
1551         try {
1552             if ( PhylogenyNode.getNodeCount() != 0 ) {
1553                 return false;
1554             }
1555             final PhylogenyNode n1 = new PhylogenyNode();
1556             final PhylogenyNode n2 = PhylogenyNode
1557                     .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1558             final PhylogenyNode n3 = PhylogenyNode
1559                     .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1560             final PhylogenyNode n4 = PhylogenyNode
1561                     .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1562             if ( n1.isHasAssignedEvent() ) {
1563                 return false;
1564             }
1565             if ( PhylogenyNode.getNodeCount() != 4 ) {
1566                 return false;
1567             }
1568             if ( n3.getIndicator() != 0 ) {
1569                 return false;
1570             }
1571             if ( n3.getNumberOfExternalNodes() != 1 ) {
1572                 return false;
1573             }
1574             if ( !n3.isExternal() ) {
1575                 return false;
1576             }
1577             if ( !n3.isRoot() ) {
1578                 return false;
1579             }
1580             if ( !n4.getName().equals( "n4" ) ) {
1581                 return false;
1582             }
1583         }
1584         catch ( final Exception e ) {
1585             e.printStackTrace( System.out );
1586             return false;
1587         }
1588         return true;
1589     }
1590
1591     private static boolean testBasicPhyloXMLparsing() {
1592         try {
1593             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1594             final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1595             final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1596                                                               xml_parser );
1597             if ( xml_parser.getErrorCount() > 0 ) {
1598                 System.out.println( xml_parser.getErrorMessages().toString() );
1599                 return false;
1600             }
1601             if ( phylogenies_0.length != 4 ) {
1602                 return false;
1603             }
1604             final Phylogeny t1 = phylogenies_0[ 0 ];
1605             final Phylogeny t2 = phylogenies_0[ 1 ];
1606             final Phylogeny t3 = phylogenies_0[ 2 ];
1607             final Phylogeny t4 = phylogenies_0[ 3 ];
1608             if ( t1.getNumberOfExternalNodes() != 1 ) {
1609                 return false;
1610             }
1611             if ( !t1.isRooted() ) {
1612                 return false;
1613             }
1614             if ( t1.isRerootable() ) {
1615                 return false;
1616             }
1617             if ( !t1.getType().equals( "gene_tree" ) ) {
1618                 return false;
1619             }
1620             if ( t2.getNumberOfExternalNodes() != 2 ) {
1621                 return false;
1622             }
1623             if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1624                 return false;
1625             }
1626             if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1627                 return false;
1628             }
1629             if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1630                 return false;
1631             }
1632             if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1633                 return false;
1634             }
1635             if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1636                 return false;
1637             }
1638             if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1639                 return false;
1640             }
1641             if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1642                     .startsWith( "actgtgggggt" ) ) {
1643                 return false;
1644             }
1645             if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1646                     .startsWith( "ctgtgatgcat" ) ) {
1647                 return false;
1648             }
1649             if ( t3.getNumberOfExternalNodes() != 4 ) {
1650                 return false;
1651             }
1652             if ( !t1.getName().equals( "t1" ) ) {
1653                 return false;
1654             }
1655             if ( !t2.getName().equals( "t2" ) ) {
1656                 return false;
1657             }
1658             if ( !t3.getName().equals( "t3" ) ) {
1659                 return false;
1660             }
1661             if ( !t4.getName().equals( "t4" ) ) {
1662                 return false;
1663             }
1664             if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1665                 return false;
1666             }
1667             if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1668                 return false;
1669             }
1670             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1671                 return false;
1672             }
1673             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1674                     .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1675                 return false;
1676             }
1677             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1678                 return false;
1679             }
1680             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1681                 return false;
1682             }
1683             if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1684                 return false;
1685             }
1686             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1687                     .equals( "apoptosis" ) ) {
1688                 return false;
1689             }
1690             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1691                     .equals( "GO:0006915" ) ) {
1692                 return false;
1693             }
1694             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1695                     .equals( "UniProtKB" ) ) {
1696                 return false;
1697             }
1698             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1699                     .equals( "experimental" ) ) {
1700                 return false;
1701             }
1702             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1703                     .equals( "function" ) ) {
1704                 return false;
1705             }
1706             if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1707                     .getValue() != 1 ) {
1708                 return false;
1709             }
1710             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1711                     .getType().equals( "ml" ) ) {
1712                 return false;
1713             }
1714             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1715                     .equals( "apoptosis" ) ) {
1716                 return false;
1717             }
1718             if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1719                     .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1720                 return false;
1721             }
1722             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1723                     .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1724                 return false;
1725             }
1726             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1727                     .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1728                 return false;
1729             }
1730             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1731                     .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1732                 return false;
1733             }
1734             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1735                     .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1736                 return false;
1737             }
1738             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1739                     .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1740                 return false;
1741             }
1742             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1743                     .equals( "GO:0005829" ) ) {
1744                 return false;
1745             }
1746             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1747                     .equals( "intracellular organelle" ) ) {
1748                 return false;
1749             }
1750             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1751                 return false;
1752             }
1753             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1754                     .equals( "UniProt link" ) ) ) {
1755                 return false;
1756             }
1757             if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1758                 return false;
1759             }
1760             final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1761             if ( x.size() != 4 ) {
1762                 return false;
1763             }
1764             int c = 0;
1765             for( final Accession acc : x ) {
1766                 if ( c == 0 ) {
1767                     if ( !acc.getSource().equals( "KEGG" ) ) {
1768                         return false;
1769                     }
1770                     if ( !acc.getValue().equals( "hsa:596" ) ) {
1771                         return false;
1772                     }
1773                 }
1774                 c++;
1775             }
1776         }
1777         catch ( final Exception e ) {
1778             e.printStackTrace( System.out );
1779             return false;
1780         }
1781         return true;
1782     }
1783
1784     private static boolean testBasicPhyloXMLparsingRoundtrip() {
1785         try {
1786             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1787             final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1788             if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1789                 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1790             }
1791             else {
1792                 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1793             }
1794             final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1795                                                               xml_parser );
1796             if ( xml_parser.getErrorCount() > 0 ) {
1797                 System.out.println( xml_parser.getErrorMessages().toString() );
1798                 return false;
1799             }
1800             if ( phylogenies_0.length != 4 ) {
1801                 return false;
1802             }
1803             final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1804             final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1805             if ( phylogenies_t1.length != 1 ) {
1806                 return false;
1807             }
1808             final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1809             if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1810                 return false;
1811             }
1812             if ( !t1_rt.isRooted() ) {
1813                 return false;
1814             }
1815             if ( t1_rt.isRerootable() ) {
1816                 return false;
1817             }
1818             if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1819                 return false;
1820             }
1821             final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1822             final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1823             final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1824             if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1825                 return false;
1826             }
1827             if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1828                 return false;
1829             }
1830             if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1831                 return false;
1832             }
1833             if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1834                 return false;
1835             }
1836             if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1837                     .startsWith( "actgtgggggt" ) ) {
1838                 return false;
1839             }
1840             if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1841                     .startsWith( "ctgtgatgcat" ) ) {
1842                 return false;
1843             }
1844             final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1845             final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1846             final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1847             final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1848             if ( phylogenies_1.length != 1 ) {
1849                 return false;
1850             }
1851             final Phylogeny t3_rt = phylogenies_1[ 0 ];
1852             if ( !t3_rt.getName().equals( "t3" ) ) {
1853                 return false;
1854             }
1855             if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1856                 return false;
1857             }
1858             if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1859                 return false;
1860             }
1861             if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1862                 return false;
1863             }
1864             if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1865                 return false;
1866             }
1867             if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1868                     .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1869                 return false;
1870             }
1871             if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1872                 return false;
1873             }
1874             if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1875                 return false;
1876             }
1877             if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1878                     .equals( "UniProtKB" ) ) {
1879                 return false;
1880             }
1881             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1882                     .equals( "apoptosis" ) ) {
1883                 return false;
1884             }
1885             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1886                     .equals( "GO:0006915" ) ) {
1887                 return false;
1888             }
1889             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1890                     .equals( "UniProtKB" ) ) {
1891                 return false;
1892             }
1893             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1894                     .equals( "experimental" ) ) {
1895                 return false;
1896             }
1897             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1898                     .equals( "function" ) ) {
1899                 return false;
1900             }
1901             if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1902                     .getValue() != 1 ) {
1903                 return false;
1904             }
1905             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1906                     .getType().equals( "ml" ) ) {
1907                 return false;
1908             }
1909             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1910                     .equals( "apoptosis" ) ) {
1911                 return false;
1912             }
1913             if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1914                     .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1915                 return false;
1916             }
1917             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1918                     .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1919                 return false;
1920             }
1921             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1922                     .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1923                 return false;
1924             }
1925             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1926                     .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1927                 return false;
1928             }
1929             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1930                     .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1931                 return false;
1932             }
1933             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1934                     .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1935                 return false;
1936             }
1937             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1938                     .equals( "GO:0005829" ) ) {
1939                 return false;
1940             }
1941             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1942                     .equals( "intracellular organelle" ) ) {
1943                 return false;
1944             }
1945             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1946                 return false;
1947             }
1948             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1949                     .equals( "UniProt link" ) ) ) {
1950                 return false;
1951             }
1952             if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1953                 return false;
1954             }
1955             if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1956                 return false;
1957             }
1958             if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1959                     .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." ) ) ) {
1960                 return false;
1961             }
1962             if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1963                 return false;
1964             }
1965             if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1966                 return false;
1967             }
1968             if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1969                 return false;
1970             }
1971             if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1972                 return false;
1973             }
1974             if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1975                     .equals( "ncbi" ) ) {
1976                 return false;
1977             }
1978             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1979                 return false;
1980             }
1981             if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1982                     .getName().equals( "B" ) ) {
1983                 return false;
1984             }
1985             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1986                     .getFrom() != 21 ) {
1987                 return false;
1988             }
1989             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1990                 return false;
1991             }
1992             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1993                     .getLength() != 24 ) {
1994                 return false;
1995             }
1996             if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1997                     .getConfidence() != 2144 ) {
1998                 return false;
1999             }
2000             if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2001                     .equals( "pfam" ) ) {
2002                 return false;
2003             }
2004             if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2005                 return false;
2006             }
2007             if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2008                 return false;
2009             }
2010             if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2011                 return false;
2012             }
2013             if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2014                 return false;
2015             }
2016             final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2017             if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2018                 return false;
2019             }
2020             if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2021                 return false;
2022             }
2023             if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2024                 return false;
2025             }
2026             if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2027                 return false;
2028             }
2029             if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2030                 return false;
2031             }
2032             if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2033                 return false;
2034             }
2035             if ( taxbb.getSynonyms().size() != 2 ) {
2036                 return false;
2037             }
2038             if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2039                 return false;
2040             }
2041             if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2042                 return false;
2043             }
2044             if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2045                 return false;
2046             }
2047             if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2048                 return false;
2049             }
2050             if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2051                 return false;
2052             }
2053             if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2054                     .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2055                 return false;
2056             }
2057             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2058                 return false;
2059             }
2060             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2061                 return false;
2062             }
2063             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2064                 return false;
2065             }
2066             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2067                 return false;
2068             }
2069             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2070                 return false;
2071             }
2072             if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2073                 return false;
2074             }
2075             if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2076                 return false;
2077             }
2078             //
2079             if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2080                 return false;
2081             }
2082             if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2083                     .equalsIgnoreCase( "435" ) ) {
2084                 return false;
2085             }
2086             if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2087                 return false;
2088             }
2089             if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2090                     .equalsIgnoreCase( "443.7" ) ) {
2091                 return false;
2092             }
2093             if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2094                 return false;
2095             }
2096             if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2097                 return false;
2098             }
2099             if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2100                     .equalsIgnoreCase( "433" ) ) {
2101                 return false;
2102             }
2103             final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2104                     .getCrossReferences();
2105             if ( x.size() != 4 ) {
2106                 return false;
2107             }
2108             int c = 0;
2109             for( final Accession acc : x ) {
2110                 if ( c == 0 ) {
2111                     if ( !acc.getSource().equals( "KEGG" ) ) {
2112                         return false;
2113                     }
2114                     if ( !acc.getValue().equals( "hsa:596" ) ) {
2115                         return false;
2116                     }
2117                 }
2118                 c++;
2119             }
2120         }
2121         catch ( final Exception e ) {
2122             e.printStackTrace( System.out );
2123             return false;
2124         }
2125         return true;
2126     }
2127
2128     private static boolean testBasicPhyloXMLparsingValidating() {
2129         try {
2130             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2131             PhyloXmlParser xml_parser = null;
2132             try {
2133                 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2134             }
2135             catch ( final Exception e ) {
2136                 // Do nothing -- means were not running from jar.
2137             }
2138             if ( xml_parser == null ) {
2139                 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2140                 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2141                     xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2142                 }
2143                 else {
2144                     xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2145                 }
2146             }
2147             final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2148                                                               xml_parser );
2149             if ( xml_parser.getErrorCount() > 0 ) {
2150                 System.out.println( xml_parser.getErrorMessages().toString() );
2151                 return false;
2152             }
2153             if ( phylogenies_0.length != 4 ) {
2154                 return false;
2155             }
2156             final Phylogeny t1 = phylogenies_0[ 0 ];
2157             final Phylogeny t2 = phylogenies_0[ 1 ];
2158             final Phylogeny t3 = phylogenies_0[ 2 ];
2159             final Phylogeny t4 = phylogenies_0[ 3 ];
2160             if ( !t1.getName().equals( "t1" ) ) {
2161                 return false;
2162             }
2163             if ( !t2.getName().equals( "t2" ) ) {
2164                 return false;
2165             }
2166             if ( !t3.getName().equals( "t3" ) ) {
2167                 return false;
2168             }
2169             if ( !t4.getName().equals( "t4" ) ) {
2170                 return false;
2171             }
2172             if ( t1.getNumberOfExternalNodes() != 1 ) {
2173                 return false;
2174             }
2175             if ( t2.getNumberOfExternalNodes() != 2 ) {
2176                 return false;
2177             }
2178             if ( t3.getNumberOfExternalNodes() != 4 ) {
2179                 return false;
2180             }
2181             final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2182             final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2183             if ( xml_parser.getErrorCount() > 0 ) {
2184                 System.out.println( "errors:" );
2185                 System.out.println( xml_parser.getErrorMessages().toString() );
2186                 return false;
2187             }
2188             if ( phylogenies_1.length != 4 ) {
2189                 return false;
2190             }
2191             final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2192                                                               xml_parser );
2193             if ( xml_parser.getErrorCount() > 0 ) {
2194                 System.out.println( "errors:" );
2195                 System.out.println( xml_parser.getErrorMessages().toString() );
2196                 return false;
2197             }
2198             if ( phylogenies_2.length != 1 ) {
2199                 return false;
2200             }
2201             if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2202                 return false;
2203             }
2204             final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2205                                                               xml_parser );
2206             if ( xml_parser.getErrorCount() > 0 ) {
2207                 System.out.println( xml_parser.getErrorMessages().toString() );
2208                 return false;
2209             }
2210             if ( phylogenies_3.length != 2 ) {
2211                 return false;
2212             }
2213             final Phylogeny a = phylogenies_3[ 0 ];
2214             if ( !a.getName().equals( "tree 4" ) ) {
2215                 return false;
2216             }
2217             if ( a.getNumberOfExternalNodes() != 3 ) {
2218                 return false;
2219             }
2220             if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2221                 return false;
2222             }
2223             if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2224                 return false;
2225             }
2226             final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2227                                                               xml_parser );
2228             if ( xml_parser.getErrorCount() > 0 ) {
2229                 System.out.println( xml_parser.getErrorMessages().toString() );
2230                 return false;
2231             }
2232             if ( phylogenies_4.length != 1 ) {
2233                 return false;
2234             }
2235             final Phylogeny s = phylogenies_4[ 0 ];
2236             if ( s.getNumberOfExternalNodes() != 6 ) {
2237                 return false;
2238             }
2239             s.getNode( "first" );
2240             s.getNode( "<>" );
2241             s.getNode( "\"<a'b&c'd\">\"" );
2242             s.getNode( "'''\"" );
2243             s.getNode( "\"\"\"" );
2244             s.getNode( "dick & doof" );
2245         }
2246         catch ( final Exception e ) {
2247             e.printStackTrace( System.out );
2248             return false;
2249         }
2250         return true;
2251     }
2252
2253     private static boolean testBasicProtein() {
2254         try {
2255             final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2256             final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2257             final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2258             final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2259             final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2260             final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2261             final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2262             final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2263             p0.addProteinDomain( y );
2264             p0.addProteinDomain( e );
2265             p0.addProteinDomain( b );
2266             p0.addProteinDomain( c );
2267             p0.addProteinDomain( d );
2268             p0.addProteinDomain( a );
2269             p0.addProteinDomain( x );
2270             if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2271                 return false;
2272             }
2273             if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2274                 return false;
2275             }
2276             //
2277             final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2278             final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2279             aa0.addProteinDomain( a1 );
2280             if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2281                 return false;
2282             }
2283             if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2284                 return false;
2285             }
2286             //
2287             final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2288             final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2289             final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2290             aa1.addProteinDomain( a11 );
2291             aa1.addProteinDomain( a12 );
2292             if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2293                 return false;
2294             }
2295             if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2296                 return false;
2297             }
2298             aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2299             if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2300                 return false;
2301             }
2302             if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2303                 return false;
2304             }
2305             if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2306                 return false;
2307             }
2308             aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2309             if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2310                 return false;
2311             }
2312             if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2313                 return false;
2314             }
2315             if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2316                 return false;
2317             }
2318             if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2319                 return false;
2320             }
2321             aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2322             if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2323                 return false;
2324             }
2325             if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2326                 return false;
2327             }
2328             if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2329                 return false;
2330             }
2331             if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2332                 return false;
2333             }
2334             aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2335             if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2336                 return false;
2337             }
2338             if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2339                 return false;
2340             }
2341             if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2342                 return false;
2343             }
2344             if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2345                 return false;
2346             }
2347             //
2348             final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2349             final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2350             final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2351             final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2352             final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2353             final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2354             final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2355             final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2356             final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2357             final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2358             final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2359             final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2360             final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2361             final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2362             final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2363             final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2364             final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2365             final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2366             final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2367             final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2368             final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2369             p00.addProteinDomain( y0 );
2370             p00.addProteinDomain( e0 );
2371             p00.addProteinDomain( b0 );
2372             p00.addProteinDomain( c0 );
2373             p00.addProteinDomain( d0 );
2374             p00.addProteinDomain( a0 );
2375             p00.addProteinDomain( x0 );
2376             p00.addProteinDomain( y1 );
2377             p00.addProteinDomain( y2 );
2378             p00.addProteinDomain( y3 );
2379             p00.addProteinDomain( e1 );
2380             p00.addProteinDomain( e2 );
2381             p00.addProteinDomain( e3 );
2382             p00.addProteinDomain( e4 );
2383             p00.addProteinDomain( e5 );
2384             p00.addProteinDomain( z0 );
2385             p00.addProteinDomain( z1 );
2386             p00.addProteinDomain( z2 );
2387             p00.addProteinDomain( zz0 );
2388             p00.addProteinDomain( zz1 );
2389             if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2390                 return false;
2391             }
2392             if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2393                 return false;
2394             }
2395             if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2396                 return false;
2397             }
2398             if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2399                 return false;
2400             }
2401             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" ) ) {
2402                 return false;
2403             }
2404             // A0  A10  B15  A20  B25  A30  B35  B40  C50  A60  C70  D80
2405             final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2406             final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2407             final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2408             final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2409             final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2410             final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2411             final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2412             final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2413             final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2414             final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2415             final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2416             final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2417             final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2418             p.addProteinDomain( B15 );
2419             p.addProteinDomain( C50 );
2420             p.addProteinDomain( A60 );
2421             p.addProteinDomain( A30 );
2422             p.addProteinDomain( C70 );
2423             p.addProteinDomain( B35 );
2424             p.addProteinDomain( B40 );
2425             p.addProteinDomain( A0 );
2426             p.addProteinDomain( A10 );
2427             p.addProteinDomain( A20 );
2428             p.addProteinDomain( B25 );
2429             p.addProteinDomain( D80 );
2430             List<String> domains_ids = new ArrayList<String>();
2431             domains_ids.add( "A" );
2432             domains_ids.add( "B" );
2433             domains_ids.add( "C" );
2434             if ( !p.contains( domains_ids, false ) ) {
2435                 return false;
2436             }
2437             if ( !p.contains( domains_ids, true ) ) {
2438                 return false;
2439             }
2440             domains_ids.add( "X" );
2441             if ( p.contains( domains_ids, false ) ) {
2442                 return false;
2443             }
2444             if ( p.contains( domains_ids, true ) ) {
2445                 return false;
2446             }
2447             domains_ids = new ArrayList<String>();
2448             domains_ids.add( "A" );
2449             domains_ids.add( "C" );
2450             domains_ids.add( "D" );
2451             if ( !p.contains( domains_ids, false ) ) {
2452                 return false;
2453             }
2454             if ( !p.contains( domains_ids, true ) ) {
2455                 return false;
2456             }
2457             domains_ids = new ArrayList<String>();
2458             domains_ids.add( "A" );
2459             domains_ids.add( "D" );
2460             domains_ids.add( "C" );
2461             if ( !p.contains( domains_ids, false ) ) {
2462                 return false;
2463             }
2464             if ( p.contains( domains_ids, true ) ) {
2465                 return false;
2466             }
2467             domains_ids = new ArrayList<String>();
2468             domains_ids.add( "A" );
2469             domains_ids.add( "A" );
2470             domains_ids.add( "B" );
2471             if ( !p.contains( domains_ids, false ) ) {
2472                 return false;
2473             }
2474             if ( !p.contains( domains_ids, true ) ) {
2475                 return false;
2476             }
2477             domains_ids = new ArrayList<String>();
2478             domains_ids.add( "A" );
2479             domains_ids.add( "A" );
2480             domains_ids.add( "A" );
2481             domains_ids.add( "B" );
2482             domains_ids.add( "B" );
2483             if ( !p.contains( domains_ids, false ) ) {
2484                 return false;
2485             }
2486             if ( !p.contains( domains_ids, true ) ) {
2487                 return false;
2488             }
2489             domains_ids = new ArrayList<String>();
2490             domains_ids.add( "A" );
2491             domains_ids.add( "A" );
2492             domains_ids.add( "B" );
2493             domains_ids.add( "A" );
2494             domains_ids.add( "B" );
2495             domains_ids.add( "B" );
2496             domains_ids.add( "A" );
2497             domains_ids.add( "B" );
2498             domains_ids.add( "C" );
2499             domains_ids.add( "A" );
2500             domains_ids.add( "C" );
2501             domains_ids.add( "D" );
2502             if ( !p.contains( domains_ids, false ) ) {
2503                 return false;
2504             }
2505             if ( p.contains( domains_ids, true ) ) {
2506                 return false;
2507             }
2508         }
2509         catch ( final Exception e ) {
2510             e.printStackTrace( System.out );
2511             return false;
2512         }
2513         return true;
2514     }
2515
2516     private static boolean testBasicTable() {
2517         try {
2518             final BasicTable<String> t0 = new BasicTable<String>();
2519             if ( t0.getNumberOfColumns() != 0 ) {
2520                 return false;
2521             }
2522             if ( t0.getNumberOfRows() != 0 ) {
2523                 return false;
2524             }
2525             t0.setValue( 3, 2, "23" );
2526             t0.setValue( 10, 1, "error" );
2527             t0.setValue( 10, 1, "110" );
2528             t0.setValue( 9, 1, "19" );
2529             t0.setValue( 1, 10, "101" );
2530             t0.setValue( 10, 10, "1010" );
2531             t0.setValue( 100, 10, "10100" );
2532             t0.setValue( 0, 0, "00" );
2533             if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2534                 return false;
2535             }
2536             if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2537                 return false;
2538             }
2539             if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2540                 return false;
2541             }
2542             if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2543                 return false;
2544             }
2545             if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2546                 return false;
2547             }
2548             if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2549                 return false;
2550             }
2551             if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2552                 return false;
2553             }
2554             if ( t0.getNumberOfColumns() != 101 ) {
2555                 return false;
2556             }
2557             if ( t0.getNumberOfRows() != 11 ) {
2558                 return false;
2559             }
2560             if ( t0.getValueAsString( 49, 4 ) != null ) {
2561                 return false;
2562             }
2563             final String l = ForesterUtil.getLineSeparator();
2564             final StringBuffer source = new StringBuffer();
2565             source.append( "" + l );
2566             source.append( "# 1 1 1 1 1 1 1 1" + l );
2567             source.append( " 00 01 02 03" + l );
2568             source.append( "   10 11 12 13  " + l );
2569             source.append( "20 21 22 23 " + l );
2570             source.append( "    30  31    32 33" + l );
2571             source.append( "40 41 42 43" + l );
2572             source.append( "  # 1 1 1 1 1 " + l );
2573             source.append( "50 51 52 53 54" + l );
2574             final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2575             if ( t1.getNumberOfColumns() != 5 ) {
2576                 return false;
2577             }
2578             if ( t1.getNumberOfRows() != 6 ) {
2579                 return false;
2580             }
2581             if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2582                 return false;
2583             }
2584             if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2585                 return false;
2586             }
2587             if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2588                 return false;
2589             }
2590             if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2591                 return false;
2592             }
2593             final StringBuffer source1 = new StringBuffer();
2594             source1.append( "" + l );
2595             source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2596             source1.append( " 00; 01 ;02;03" + l );
2597             source1.append( "   10; 11; 12; 13  " + l );
2598             source1.append( "20; 21; 22; 23 " + l );
2599             source1.append( "    30;  31;    32; 33" + l );
2600             source1.append( "40;41;42;43" + l );
2601             source1.append( "  # 1 1 1 1 1 " + l );
2602             source1.append( ";;;50  ;  ;52; 53;;54   " + l );
2603             final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2604             if ( t2.getNumberOfColumns() != 5 ) {
2605                 return false;
2606             }
2607             if ( t2.getNumberOfRows() != 6 ) {
2608                 return false;
2609             }
2610             if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2611                 return false;
2612             }
2613             if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2614                 return false;
2615             }
2616             if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2617                 return false;
2618             }
2619             if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2620                 return false;
2621             }
2622             if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2623                 return false;
2624             }
2625             if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2626                 return false;
2627             }
2628             final StringBuffer source2 = new StringBuffer();
2629             source2.append( "" + l );
2630             source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2631             source2.append( " 00; 01 ;02;03" + l );
2632             source2.append( "   10; 11; 12; 13  " + l );
2633             source2.append( "20; 21; 22; 23 " + l );
2634             source2.append( "                     " + l );
2635             source2.append( "    30;  31;    32; 33" + l );
2636             source2.append( "40;41;42;43" + l );
2637             source2.append( "  comment: 1 1 1 1 1 " + l );
2638             source2.append( ";;;50  ;   52; 53;;54   " + l );
2639             final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2640                                                                         ';',
2641                                                                         false,
2642                                                                         false,
2643                                                                         "comment:",
2644                                                                         false );
2645             if ( tl.size() != 2 ) {
2646                 return false;
2647             }
2648             final BasicTable<String> t3 = tl.get( 0 );
2649             final BasicTable<String> t4 = tl.get( 1 );
2650             if ( t3.getNumberOfColumns() != 4 ) {
2651                 return false;
2652             }
2653             if ( t3.getNumberOfRows() != 3 ) {
2654                 return false;
2655             }
2656             if ( t4.getNumberOfColumns() != 4 ) {
2657                 return false;
2658             }
2659             if ( t4.getNumberOfRows() != 3 ) {
2660                 return false;
2661             }
2662             if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2663                 return false;
2664             }
2665             if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2666                 return false;
2667             }
2668         }
2669         catch ( final Exception e ) {
2670             e.printStackTrace( System.out );
2671             return false;
2672         }
2673         return true;
2674     }
2675
2676     private static boolean testBasicTolXMLparsing() {
2677         try {
2678             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2679             final TolParser parser = new TolParser();
2680             final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2681             if ( parser.getErrorCount() > 0 ) {
2682                 System.out.println( parser.getErrorMessages().toString() );
2683                 return false;
2684             }
2685             if ( phylogenies_0.length != 1 ) {
2686                 return false;
2687             }
2688             final Phylogeny t1 = phylogenies_0[ 0 ];
2689             if ( t1.getNumberOfExternalNodes() != 5 ) {
2690                 return false;
2691             }
2692             if ( !t1.isRooted() ) {
2693                 return false;
2694             }
2695             if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2696                 return false;
2697             }
2698             if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2699                 return false;
2700             }
2701             if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2702                 return false;
2703             }
2704             if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2705                 return false;
2706             }
2707             final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2708             if ( parser.getErrorCount() > 0 ) {
2709                 System.out.println( parser.getErrorMessages().toString() );
2710                 return false;
2711             }
2712             if ( phylogenies_1.length != 1 ) {
2713                 return false;
2714             }
2715             final Phylogeny t2 = phylogenies_1[ 0 ];
2716             if ( t2.getNumberOfExternalNodes() != 664 ) {
2717                 return false;
2718             }
2719             if ( !t2.isRooted() ) {
2720                 return false;
2721             }
2722             if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2723                 return false;
2724             }
2725             if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2726                 return false;
2727             }
2728             if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2729                 return false;
2730             }
2731             if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2732                 return false;
2733             }
2734             if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2735                 return false;
2736             }
2737             if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2738                     .equals( "Aquifex" ) ) {
2739                 return false;
2740             }
2741             final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2742             if ( parser.getErrorCount() > 0 ) {
2743                 System.out.println( parser.getErrorMessages().toString() );
2744                 return false;
2745             }
2746             if ( phylogenies_2.length != 1 ) {
2747                 return false;
2748             }
2749             final Phylogeny t3 = phylogenies_2[ 0 ];
2750             if ( t3.getNumberOfExternalNodes() != 184 ) {
2751                 return false;
2752             }
2753             if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2754                 return false;
2755             }
2756             if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2757                 return false;
2758             }
2759             if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2760                 return false;
2761             }
2762             final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2763             if ( parser.getErrorCount() > 0 ) {
2764                 System.out.println( parser.getErrorMessages().toString() );
2765                 return false;
2766             }
2767             if ( phylogenies_3.length != 1 ) {
2768                 return false;
2769             }
2770             final Phylogeny t4 = phylogenies_3[ 0 ];
2771             if ( t4.getNumberOfExternalNodes() != 1 ) {
2772                 return false;
2773             }
2774             if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2775                 return false;
2776             }
2777             if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2778                 return false;
2779             }
2780             if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2781                 return false;
2782             }
2783             final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2784             if ( parser.getErrorCount() > 0 ) {
2785                 System.out.println( parser.getErrorMessages().toString() );
2786                 return false;
2787             }
2788             if ( phylogenies_4.length != 1 ) {
2789                 return false;
2790             }
2791             final Phylogeny t5 = phylogenies_4[ 0 ];
2792             if ( t5.getNumberOfExternalNodes() != 13 ) {
2793                 return false;
2794             }
2795             if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2796                 return false;
2797             }
2798             if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2799                 return false;
2800             }
2801             if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2802                 return false;
2803             }
2804         }
2805         catch ( final Exception e ) {
2806             e.printStackTrace( System.out );
2807             return false;
2808         }
2809         return true;
2810     }
2811
2812     private static boolean testBasicTreeMethods() {
2813         try {
2814             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2815             final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2816             if ( t2.getNumberOfExternalNodes() != 4 ) {
2817                 return false;
2818             }
2819             if ( t2.getHeight() != 8.5 ) {
2820                 return false;
2821             }
2822             if ( !t2.isCompletelyBinary() ) {
2823                 return false;
2824             }
2825             if ( t2.isEmpty() ) {
2826                 return false;
2827             }
2828             final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2829             if ( t3.getNumberOfExternalNodes() != 5 ) {
2830                 return false;
2831             }
2832             if ( t3.getHeight() != 11 ) {
2833                 return false;
2834             }
2835             if ( t3.isCompletelyBinary() ) {
2836                 return false;
2837             }
2838             final PhylogenyNode n = t3.getNode( "ABC" );
2839             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 ];
2840             if ( t4.getNumberOfExternalNodes() != 9 ) {
2841                 return false;
2842             }
2843             if ( t4.getHeight() != 11 ) {
2844                 return false;
2845             }
2846             if ( t4.isCompletelyBinary() ) {
2847                 return false;
2848             }
2849             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)" );
2850             final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2851             if ( t5.getNumberOfExternalNodes() != 8 ) {
2852                 return false;
2853             }
2854             if ( t5.getHeight() != 15 ) {
2855                 return false;
2856             }
2857             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)" );
2858             final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2859             if ( t6.getHeight() != 15 ) {
2860                 return false;
2861             }
2862             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)" );
2863             final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2864             if ( t7.getHeight() != 15 ) {
2865                 return false;
2866             }
2867             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)" );
2868             final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2869             if ( t8.getNumberOfExternalNodes() != 10 ) {
2870                 return false;
2871             }
2872             if ( t8.getHeight() != 15 ) {
2873                 return false;
2874             }
2875             final char[] a9 = new char[] { 'a' };
2876             final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2877             if ( t9.getHeight() != 0 ) {
2878                 return false;
2879             }
2880             final char[] a10 = new char[] { 'a', ':', '6' };
2881             final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2882             if ( t10.getHeight() != 6 ) {
2883                 return false;
2884             }
2885         }
2886         catch ( final Exception e ) {
2887             e.printStackTrace( System.out );
2888             return false;
2889         }
2890         return true;
2891     }
2892
2893     private static boolean testConfidenceAssessor() {
2894         try {
2895             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2896             final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2897             final Phylogeny[] ev0 = factory
2898                     .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2899                              new NHXParser() );
2900             ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2901             if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2902                 return false;
2903             }
2904             if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2905                 return false;
2906             }
2907             final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2908             final Phylogeny[] ev1 = factory
2909                     .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)));",
2910                              new NHXParser() );
2911             ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2912             if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2913                 return false;
2914             }
2915             if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2916                 return false;
2917             }
2918             final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2919             final Phylogeny[] ev_b = factory
2920                     .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",
2921                              new NHXParser() );
2922             ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2923             if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2924                 return false;
2925             }
2926             if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2927                 return false;
2928             }
2929             //
2930             final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2931             final Phylogeny[] ev1x = factory
2932                     .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)));",
2933                              new NHXParser() );
2934             ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2935             if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2936                 return false;
2937             }
2938             if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2939                 return false;
2940             }
2941             final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2942             final Phylogeny[] ev_bx = factory
2943                     .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",
2944                              new NHXParser() );
2945             ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2946             if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2947                 return false;
2948             }
2949             if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2950                 return false;
2951             }
2952             //
2953             final Phylogeny[] t2 = factory
2954                     .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);",
2955                              new NHXParser() );
2956             final Phylogeny[] ev2 = factory
2957                     .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);",
2958                              new NHXParser() );
2959             for( final Phylogeny target : t2 ) {
2960                 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2961             }
2962             //
2963             final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2964                                                  new NHXParser() )[ 0 ];
2965             final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2966             ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2967             if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2968                 return false;
2969             }
2970             if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2971                 return false;
2972             }
2973             if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2974                 return false;
2975             }
2976         }
2977         catch ( final Exception e ) {
2978             e.printStackTrace();
2979             return false;
2980         }
2981         return true;
2982     }
2983
2984     private static boolean testCopyOfNodeData() {
2985         try {
2986             final PhylogenyNode n1 = PhylogenyNode
2987                     .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]" );
2988             final PhylogenyNode n2 = n1.copyNodeData();
2989             if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2990                 return false;
2991             }
2992         }
2993         catch ( final Exception e ) {
2994             e.printStackTrace();
2995             return false;
2996         }
2997         return true;
2998     }
2999
3000     private static boolean testCreateBalancedPhylogeny() {
3001         try {
3002             final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3003             if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3004                 return false;
3005             }
3006             if ( p0.getNumberOfExternalNodes() != 15625 ) {
3007                 return false;
3008             }
3009             final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3010             if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3011                 return false;
3012             }
3013             if ( p1.getNumberOfExternalNodes() != 100 ) {
3014                 return false;
3015             }
3016         }
3017         catch ( final Exception e ) {
3018             e.printStackTrace();
3019             return false;
3020         }
3021         return true;
3022     }
3023
3024     private static boolean testCreateUriForSeqWeb() {
3025         try {
3026             final PhylogenyNode n = new PhylogenyNode();
3027             n.setName( "tr|B3RJ64" );
3028             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3029                 return false;
3030             }
3031             n.setName( "B0LM41_HUMAN" );
3032             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3033                 return false;
3034             }
3035             n.setName( "NP_001025424" );
3036             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3037                 return false;
3038             }
3039             n.setName( "_NM_001030253-" );
3040             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3041                 return false;
3042             }
3043             n.setName( "XM_002122186" );
3044             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3045                 return false;
3046             }
3047             n.setName( "dgh_AAA34956_gdg" );
3048             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3049                 return false;
3050             }
3051             n.setName( "AAA34956" );
3052             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3053                 return false;
3054             }
3055             n.setName( "GI:394892" );
3056             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3057                 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3058                 return false;
3059             }
3060             n.setName( "gi_394892" );
3061             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3062                 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3063                 return false;
3064             }
3065             n.setName( "gi6335_gi_394892_56635_Gi_43" );
3066             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3067                 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3068                 return false;
3069             }
3070             n.setName( "P12345" );
3071             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3072                 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3073                 return false;
3074             }
3075             n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3076             if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3077                 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3078                 return false;
3079             }
3080         }
3081         catch ( final Exception e ) {
3082             e.printStackTrace( System.out );
3083             return false;
3084         }
3085         return true;
3086     }
3087
3088     private static boolean testDataObjects() {
3089         try {
3090             final Confidence s0 = new Confidence();
3091             final Confidence s1 = new Confidence();
3092             if ( !s0.isEqual( s1 ) ) {
3093                 return false;
3094             }
3095             final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3096             final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3097             if ( s2.isEqual( s1 ) ) {
3098                 return false;
3099             }
3100             if ( !s2.isEqual( s3 ) ) {
3101                 return false;
3102             }
3103             final Confidence s4 = ( Confidence ) s3.copy();
3104             if ( !s4.isEqual( s3 ) ) {
3105                 return false;
3106             }
3107             s3.asSimpleText();
3108             s3.asText();
3109             // Taxonomy
3110             // ----------
3111             final Taxonomy t1 = new Taxonomy();
3112             final Taxonomy t2 = new Taxonomy();
3113             final Taxonomy t3 = new Taxonomy();
3114             final Taxonomy t4 = new Taxonomy();
3115             final Taxonomy t5 = new Taxonomy();
3116             t1.setIdentifier( new Identifier( "ecoli" ) );
3117             t1.setTaxonomyCode( "ECOLI" );
3118             t1.setScientificName( "E. coli" );
3119             t1.setCommonName( "coli" );
3120             final Taxonomy t0 = ( Taxonomy ) t1.copy();
3121             if ( !t1.isEqual( t0 ) ) {
3122                 return false;
3123             }
3124             t2.setIdentifier( new Identifier( "ecoli" ) );
3125             t2.setTaxonomyCode( "OTHER" );
3126             t2.setScientificName( "what" );
3127             t2.setCommonName( "something" );
3128             if ( !t1.isEqual( t2 ) ) {
3129                 return false;
3130             }
3131             t2.setIdentifier( new Identifier( "nemve" ) );
3132             if ( t1.isEqual( t2 ) ) {
3133                 return false;
3134             }
3135             t1.setIdentifier( null );
3136             t3.setTaxonomyCode( "ECOLI" );
3137             t3.setScientificName( "what" );
3138             t3.setCommonName( "something" );
3139             if ( !t1.isEqual( t3 ) ) {
3140                 return false;
3141             }
3142             t1.setIdentifier( null );
3143             t1.setTaxonomyCode( "" );
3144             t4.setScientificName( "E. ColI" );
3145             t4.setCommonName( "something" );
3146             if ( !t1.isEqual( t4 ) ) {
3147                 return false;
3148             }
3149             t4.setScientificName( "B. subtilis" );
3150             t4.setCommonName( "something" );
3151             if ( t1.isEqual( t4 ) ) {
3152                 return false;
3153             }
3154             t1.setIdentifier( null );
3155             t1.setTaxonomyCode( "" );
3156             t1.setScientificName( "" );
3157             t5.setCommonName( "COLI" );
3158             if ( !t1.isEqual( t5 ) ) {
3159                 return false;
3160             }
3161             t5.setCommonName( "vibrio" );
3162             if ( t1.isEqual( t5 ) ) {
3163                 return false;
3164             }
3165             // Identifier
3166             // ----------
3167             final Identifier id0 = new Identifier( "123", "pfam" );
3168             final Identifier id1 = ( Identifier ) id0.copy();
3169             if ( !id1.isEqual( id1 ) ) {
3170                 return false;
3171             }
3172             if ( !id1.isEqual( id0 ) ) {
3173                 return false;
3174             }
3175             if ( !id0.isEqual( id1 ) ) {
3176                 return false;
3177             }
3178             id1.asSimpleText();
3179             id1.asText();
3180             // ProteinDomain
3181             // ---------------
3182             final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3183             final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3184             if ( !pd1.isEqual( pd1 ) ) {
3185                 return false;
3186             }
3187             if ( !pd1.isEqual( pd0 ) ) {
3188                 return false;
3189             }
3190             pd1.asSimpleText();
3191             pd1.asText();
3192             final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3193             final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3194             if ( !pd3.isEqual( pd3 ) ) {
3195                 return false;
3196             }
3197             if ( !pd2.isEqual( pd3 ) ) {
3198                 return false;
3199             }
3200             if ( !pd0.isEqual( pd3 ) ) {
3201                 return false;
3202             }
3203             pd3.asSimpleText();
3204             pd3.asText();
3205             // DomainArchitecture
3206             // ------------------
3207             final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3208             final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3209             final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3210             final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3211             final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3212             final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3213             domains0.add( d2 );
3214             domains0.add( d0 );
3215             domains0.add( d3 );
3216             domains0.add( d1 );
3217             final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3218             if ( ds0.getNumberOfDomains() != 4 ) {
3219                 return false;
3220             }
3221             final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3222             if ( !ds0.isEqual( ds0 ) ) {
3223                 return false;
3224             }
3225             if ( !ds0.isEqual( ds1 ) ) {
3226                 return false;
3227             }
3228             if ( ds1.getNumberOfDomains() != 4 ) {
3229                 return false;
3230             }
3231             final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3232             domains1.add( d1 );
3233             domains1.add( d2 );
3234             domains1.add( d4 );
3235             domains1.add( d0 );
3236             final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3237             if ( ds0.isEqual( ds2 ) ) {
3238                 return false;
3239             }
3240             ds1.asSimpleText();
3241             ds1.asText();
3242             ds1.toNHX();
3243             final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3244             if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3245                 System.out.println( ds3.toNHX() );
3246                 return false;
3247             }
3248             if ( ds3.getNumberOfDomains() != 3 ) {
3249                 return false;
3250             }
3251             // Event
3252             // -----
3253             final Event e1 = new Event( Event.EventType.fusion );
3254             if ( e1.isDuplication() ) {
3255                 return false;
3256             }
3257             if ( !e1.isFusion() ) {
3258                 return false;
3259             }
3260             if ( !e1.asText().toString().equals( "fusion" ) ) {
3261                 return false;
3262             }
3263             if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3264                 return false;
3265             }
3266             final Event e11 = new Event( Event.EventType.fusion );
3267             if ( !e11.isEqual( e1 ) ) {
3268                 return false;
3269             }
3270             if ( !e11.toNHX().toString().equals( "" ) ) {
3271                 return false;
3272             }
3273             final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3274             if ( e2.isDuplication() ) {
3275                 return false;
3276             }
3277             if ( !e2.isSpeciationOrDuplication() ) {
3278                 return false;
3279             }
3280             if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3281                 return false;
3282             }
3283             if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3284                 return false;
3285             }
3286             if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3287                 return false;
3288             }
3289             if ( e11.isEqual( e2 ) ) {
3290                 return false;
3291             }
3292             final Event e2c = ( Event ) e2.copy();
3293             if ( !e2c.isEqual( e2 ) ) {
3294                 return false;
3295             }
3296             Event e3 = new Event( 1, 2, 3 );
3297             if ( e3.isDuplication() ) {
3298                 return false;
3299             }
3300             if ( e3.isSpeciation() ) {
3301                 return false;
3302             }
3303             if ( e3.isGeneLoss() ) {
3304                 return false;
3305             }
3306             if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3307                 return false;
3308             }
3309             final Event e3c = ( Event ) e3.copy();
3310             final Event e3cc = ( Event ) e3c.copy();
3311             if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3312                 return false;
3313             }
3314             e3 = null;
3315             if ( !e3c.isEqual( e3cc ) ) {
3316                 return false;
3317             }
3318             Event e4 = new Event( 1, 2, 3 );
3319             if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3320                 return false;
3321             }
3322             if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3323                 return false;
3324             }
3325             final Event e4c = ( Event ) e4.copy();
3326             e4 = null;
3327             final Event e4cc = ( Event ) e4c.copy();
3328             if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3329                 return false;
3330             }
3331             if ( !e4c.isEqual( e4cc ) ) {
3332                 return false;
3333             }
3334             final Event e5 = new Event();
3335             if ( !e5.isUnassigned() ) {
3336                 return false;
3337             }
3338             if ( !e5.asText().toString().equals( "unassigned" ) ) {
3339                 return false;
3340             }
3341             if ( !e5.asSimpleText().toString().equals( "" ) ) {
3342                 return false;
3343             }
3344             final Event e6 = new Event( 1, 0, 0 );
3345             if ( !e6.asText().toString().equals( "duplication" ) ) {
3346                 return false;
3347             }
3348             if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3349                 return false;
3350             }
3351             final Event e7 = new Event( 0, 1, 0 );
3352             if ( !e7.asText().toString().equals( "speciation" ) ) {
3353                 return false;
3354             }
3355             if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3356                 return false;
3357             }
3358             final Event e8 = new Event( 0, 0, 1 );
3359             if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3360                 return false;
3361             }
3362             if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3363                 return false;
3364             }
3365         }
3366         catch ( final Exception e ) {
3367             e.printStackTrace( System.out );
3368             return false;
3369         }
3370         return true;
3371     }
3372
3373     private static boolean testDeletionOfExternalNodes() {
3374         try {
3375             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3376             final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3377             final PhylogenyWriter w = new PhylogenyWriter();
3378             if ( t0.isEmpty() ) {
3379                 return false;
3380             }
3381             if ( t0.getNumberOfExternalNodes() != 1 ) {
3382                 return false;
3383             }
3384             t0.deleteSubtree( t0.getNode( "A" ), false );
3385             if ( t0.getNumberOfExternalNodes() != 0 ) {
3386                 return false;
3387             }
3388             if ( !t0.isEmpty() ) {
3389                 return false;
3390             }
3391             final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3392             if ( t1.getNumberOfExternalNodes() != 2 ) {
3393                 return false;
3394             }
3395             t1.deleteSubtree( t1.getNode( "A" ), false );
3396             if ( t1.getNumberOfExternalNodes() != 1 ) {
3397                 return false;
3398             }
3399             if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3400                 return false;
3401             }
3402             t1.deleteSubtree( t1.getNode( "B" ), false );
3403             if ( t1.getNumberOfExternalNodes() != 1 ) {
3404                 return false;
3405             }
3406             t1.deleteSubtree( t1.getNode( "r" ), false );
3407             if ( !t1.isEmpty() ) {
3408                 return false;
3409             }
3410             final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3411             if ( t2.getNumberOfExternalNodes() != 3 ) {
3412                 return false;
3413             }
3414             t2.deleteSubtree( t2.getNode( "B" ), false );
3415             if ( t2.getNumberOfExternalNodes() != 2 ) {
3416                 return false;
3417             }
3418             t2.toNewHampshireX();
3419             PhylogenyNode n = t2.getNode( "A" );
3420             if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3421                 return false;
3422             }
3423             t2.deleteSubtree( t2.getNode( "A" ), false );
3424             if ( t2.getNumberOfExternalNodes() != 2 ) {
3425                 return false;
3426             }
3427             t2.deleteSubtree( t2.getNode( "C" ), true );
3428             if ( t2.getNumberOfExternalNodes() != 1 ) {
3429                 return false;
3430             }
3431             final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3432             if ( t3.getNumberOfExternalNodes() != 4 ) {
3433                 return false;
3434             }
3435             t3.deleteSubtree( t3.getNode( "B" ), true );
3436             if ( t3.getNumberOfExternalNodes() != 3 ) {
3437                 return false;
3438             }
3439             n = t3.getNode( "A" );
3440             if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3441                 return false;
3442             }
3443             n = n.getNextExternalNode();
3444             if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3445                 return false;
3446             }
3447             t3.deleteSubtree( t3.getNode( "A" ), true );
3448             if ( t3.getNumberOfExternalNodes() != 2 ) {
3449                 return false;
3450             }
3451             n = t3.getNode( "C" );
3452             if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3453                 return false;
3454             }
3455             t3.deleteSubtree( t3.getNode( "C" ), true );
3456             if ( t3.getNumberOfExternalNodes() != 1 ) {
3457                 return false;
3458             }
3459             t3.deleteSubtree( t3.getNode( "D" ), true );
3460             if ( t3.getNumberOfExternalNodes() != 0 ) {
3461                 return false;
3462             }
3463             final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3464             if ( t4.getNumberOfExternalNodes() != 6 ) {
3465                 return false;
3466             }
3467             t4.deleteSubtree( t4.getNode( "B2" ), true );
3468             if ( t4.getNumberOfExternalNodes() != 5 ) {
3469                 return false;
3470             }
3471             String s = w.toNewHampshire( t4, true ).toString();
3472             if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3473                 return false;
3474             }
3475             t4.deleteSubtree( t4.getNode( "B11" ), true );
3476             if ( t4.getNumberOfExternalNodes() != 4 ) {
3477                 return false;
3478             }
3479             t4.deleteSubtree( t4.getNode( "C" ), true );
3480             if ( t4.getNumberOfExternalNodes() != 3 ) {
3481                 return false;
3482             }
3483             n = t4.getNode( "A" );
3484             n = n.getNextExternalNode();
3485             if ( !n.getName().equals( "B12" ) ) {
3486                 return false;
3487             }
3488             n = n.getNextExternalNode();
3489             if ( !n.getName().equals( "D" ) ) {
3490                 return false;
3491             }
3492             s = w.toNewHampshire( t4, true ).toString();
3493             if ( !s.equals( "((A,B12),D);" ) ) {
3494                 return false;
3495             }
3496             final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3497             t5.deleteSubtree( t5.getNode( "A" ), true );
3498             if ( t5.getNumberOfExternalNodes() != 5 ) {
3499                 return false;
3500             }
3501             s = w.toNewHampshire( t5, true ).toString();
3502             if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3503                 return false;
3504             }
3505             final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3506             t6.deleteSubtree( t6.getNode( "B11" ), true );
3507             if ( t6.getNumberOfExternalNodes() != 5 ) {
3508                 return false;
3509             }
3510             s = w.toNewHampshire( t6, false ).toString();
3511             if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3512                 return false;
3513             }
3514             final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3515             t7.deleteSubtree( t7.getNode( "B12" ), true );
3516             if ( t7.getNumberOfExternalNodes() != 5 ) {
3517                 return false;
3518             }
3519             s = w.toNewHampshire( t7, true ).toString();
3520             if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3521                 return false;
3522             }
3523             final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3524             t8.deleteSubtree( t8.getNode( "B2" ), true );
3525             if ( t8.getNumberOfExternalNodes() != 5 ) {
3526                 return false;
3527             }
3528             s = w.toNewHampshire( t8, false ).toString();
3529             if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3530                 return false;
3531             }
3532             final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3533             t9.deleteSubtree( t9.getNode( "C" ), true );
3534             if ( t9.getNumberOfExternalNodes() != 5 ) {
3535                 return false;
3536             }
3537             s = w.toNewHampshire( t9, true ).toString();
3538             if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3539                 return false;
3540             }
3541             final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3542             t10.deleteSubtree( t10.getNode( "D" ), true );
3543             if ( t10.getNumberOfExternalNodes() != 5 ) {
3544                 return false;
3545             }
3546             s = w.toNewHampshire( t10, true ).toString();
3547             if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3548                 return false;
3549             }
3550             final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3551             t11.deleteSubtree( t11.getNode( "A" ), true );
3552             if ( t11.getNumberOfExternalNodes() != 2 ) {
3553                 return false;
3554             }
3555             s = w.toNewHampshire( t11, true ).toString();
3556             if ( !s.equals( "(B,C);" ) ) {
3557                 return false;
3558             }
3559             t11.deleteSubtree( t11.getNode( "C" ), true );
3560             if ( t11.getNumberOfExternalNodes() != 1 ) {
3561                 return false;
3562             }
3563             s = w.toNewHampshire( t11, false ).toString();
3564             if ( !s.equals( "B;" ) ) {
3565                 return false;
3566             }
3567             final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3568             t12.deleteSubtree( t12.getNode( "B2" ), true );
3569             if ( t12.getNumberOfExternalNodes() != 8 ) {
3570                 return false;
3571             }
3572             s = w.toNewHampshire( t12, true ).toString();
3573             if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3574                 return false;
3575             }
3576             t12.deleteSubtree( t12.getNode( "B3" ), true );
3577             if ( t12.getNumberOfExternalNodes() != 7 ) {
3578                 return false;
3579             }
3580             s = w.toNewHampshire( t12, true ).toString();
3581             if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3582                 return false;
3583             }
3584             t12.deleteSubtree( t12.getNode( "C3" ), true );
3585             if ( t12.getNumberOfExternalNodes() != 6 ) {
3586                 return false;
3587             }
3588             s = w.toNewHampshire( t12, true ).toString();
3589             if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3590                 return false;
3591             }
3592             t12.deleteSubtree( t12.getNode( "A1" ), true );
3593             if ( t12.getNumberOfExternalNodes() != 5 ) {
3594                 return false;
3595             }
3596             s = w.toNewHampshire( t12, true ).toString();
3597             if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3598                 return false;
3599             }
3600             t12.deleteSubtree( t12.getNode( "B1" ), true );
3601             if ( t12.getNumberOfExternalNodes() != 4 ) {
3602                 return false;
3603             }
3604             s = w.toNewHampshire( t12, true ).toString();
3605             if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3606                 return false;
3607             }
3608             t12.deleteSubtree( t12.getNode( "A3" ), true );
3609             if ( t12.getNumberOfExternalNodes() != 3 ) {
3610                 return false;
3611             }
3612             s = w.toNewHampshire( t12, true ).toString();
3613             if ( !s.equals( "(A2,(C1,C2));" ) ) {
3614                 return false;
3615             }
3616             t12.deleteSubtree( t12.getNode( "A2" ), true );
3617             if ( t12.getNumberOfExternalNodes() != 2 ) {
3618                 return false;
3619             }
3620             s = w.toNewHampshire( t12, true ).toString();
3621             if ( !s.equals( "(C1,C2);" ) ) {
3622                 return false;
3623             }
3624             final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3625             t13.deleteSubtree( t13.getNode( "D" ), true );
3626             if ( t13.getNumberOfExternalNodes() != 4 ) {
3627                 return false;
3628             }
3629             s = w.toNewHampshire( t13, true ).toString();
3630             if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3631                 return false;
3632             }
3633             final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3634             t14.deleteSubtree( t14.getNode( "E" ), true );
3635             if ( t14.getNumberOfExternalNodes() != 5 ) {
3636                 return false;
3637             }
3638             s = w.toNewHampshire( t14, true ).toString();
3639             if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3640                 return false;
3641             }
3642             final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3643             t15.deleteSubtree( t15.getNode( "B2" ), true );
3644             if ( t15.getNumberOfExternalNodes() != 11 ) {
3645                 return false;
3646             }
3647             t15.deleteSubtree( t15.getNode( "B1" ), true );
3648             if ( t15.getNumberOfExternalNodes() != 10 ) {
3649                 return false;
3650             }
3651             t15.deleteSubtree( t15.getNode( "B3" ), true );
3652             if ( t15.getNumberOfExternalNodes() != 9 ) {
3653                 return false;
3654             }
3655             t15.deleteSubtree( t15.getNode( "B4" ), true );
3656             if ( t15.getNumberOfExternalNodes() != 8 ) {
3657                 return false;
3658             }
3659             t15.deleteSubtree( t15.getNode( "A1" ), true );
3660             if ( t15.getNumberOfExternalNodes() != 7 ) {
3661                 return false;
3662             }
3663             t15.deleteSubtree( t15.getNode( "C4" ), true );
3664             if ( t15.getNumberOfExternalNodes() != 6 ) {
3665                 return false;
3666             }
3667         }
3668         catch ( final Exception e ) {
3669             e.printStackTrace( System.out );
3670             return false;
3671         }
3672         return true;
3673     }
3674
3675     private static boolean testDescriptiveStatistics() {
3676         try {
3677             final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3678             dss1.addValue( 82 );
3679             dss1.addValue( 78 );
3680             dss1.addValue( 70 );
3681             dss1.addValue( 58 );
3682             dss1.addValue( 42 );
3683             if ( dss1.getN() != 5 ) {
3684                 return false;
3685             }
3686             if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3687                 return false;
3688             }
3689             if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3690                 return false;
3691             }
3692             if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3693                 return false;
3694             }
3695             if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3696                 return false;
3697             }
3698             if ( !Test.isEqual( dss1.median(), 70 ) ) {
3699                 return false;
3700             }
3701             if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3702                 return false;
3703             }
3704             if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3705                 return false;
3706             }
3707             if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3708                 return false;
3709             }
3710             if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3711                 return false;
3712             }
3713             if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3714                 return false;
3715             }
3716             if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3717                 return false;
3718             }
3719             dss1.addValue( 123 );
3720             if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3721                 return false;
3722             }
3723             if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3724                 return false;
3725             }
3726             if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3727                 return false;
3728             }
3729             final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3730             dss2.addValue( -1.85 );
3731             dss2.addValue( 57.5 );
3732             dss2.addValue( 92.78 );
3733             dss2.addValue( 57.78 );
3734             if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3735                 return false;
3736             }
3737             if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3738                 return false;
3739             }
3740             final double[] a = dss2.getDataAsDoubleArray();
3741             if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3742                 return false;
3743             }
3744             dss2.addValue( -100 );
3745             if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3746                 return false;
3747             }
3748             if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3749                 return false;
3750             }
3751             final double[] ds = new double[ 14 ];
3752             ds[ 0 ] = 34;
3753             ds[ 1 ] = 23;
3754             ds[ 2 ] = 1;
3755             ds[ 3 ] = 32;
3756             ds[ 4 ] = 11;
3757             ds[ 5 ] = 2;
3758             ds[ 6 ] = 12;
3759             ds[ 7 ] = 33;
3760             ds[ 8 ] = 13;
3761             ds[ 9 ] = 22;
3762             ds[ 10 ] = 21;
3763             ds[ 11 ] = 35;
3764             ds[ 12 ] = 24;
3765             ds[ 13 ] = 31;
3766             final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3767             if ( bins.length != 4 ) {
3768                 return false;
3769             }
3770             if ( bins[ 0 ] != 2 ) {
3771                 return false;
3772             }
3773             if ( bins[ 1 ] != 3 ) {
3774                 return false;
3775             }
3776             if ( bins[ 2 ] != 4 ) {
3777                 return false;
3778             }
3779             if ( bins[ 3 ] != 5 ) {
3780                 return false;
3781             }
3782             final double[] ds1 = new double[ 9 ];
3783             ds1[ 0 ] = 10.0;
3784             ds1[ 1 ] = 19.0;
3785             ds1[ 2 ] = 9.999;
3786             ds1[ 3 ] = 0.0;
3787             ds1[ 4 ] = 39.9;
3788             ds1[ 5 ] = 39.999;
3789             ds1[ 6 ] = 30.0;
3790             ds1[ 7 ] = 19.999;
3791             ds1[ 8 ] = 30.1;
3792             final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3793             if ( bins1.length != 4 ) {
3794                 return false;
3795             }
3796             if ( bins1[ 0 ] != 2 ) {
3797                 return false;
3798             }
3799             if ( bins1[ 1 ] != 3 ) {
3800                 return false;
3801             }
3802             if ( bins1[ 2 ] != 0 ) {
3803                 return false;
3804             }
3805             if ( bins1[ 3 ] != 4 ) {
3806                 return false;
3807             }
3808             final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3809             if ( bins1_1.length != 3 ) {
3810                 return false;
3811             }
3812             if ( bins1_1[ 0 ] != 3 ) {
3813                 return false;
3814             }
3815             if ( bins1_1[ 1 ] != 2 ) {
3816                 return false;
3817             }
3818             if ( bins1_1[ 2 ] != 4 ) {
3819                 return false;
3820             }
3821             final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3822             if ( bins1_2.length != 3 ) {
3823                 return false;
3824             }
3825             if ( bins1_2[ 0 ] != 2 ) {
3826                 return false;
3827             }
3828             if ( bins1_2[ 1 ] != 2 ) {
3829                 return false;
3830             }
3831             if ( bins1_2[ 2 ] != 2 ) {
3832                 return false;
3833             }
3834             final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3835             dss3.addValue( 1 );
3836             dss3.addValue( 1 );
3837             dss3.addValue( 1 );
3838             dss3.addValue( 2 );
3839             dss3.addValue( 3 );
3840             dss3.addValue( 4 );
3841             dss3.addValue( 5 );
3842             dss3.addValue( 5 );
3843             dss3.addValue( 5 );
3844             dss3.addValue( 6 );
3845             dss3.addValue( 7 );
3846             dss3.addValue( 8 );
3847             dss3.addValue( 9 );
3848             dss3.addValue( 10 );
3849             dss3.addValue( 10 );
3850             dss3.addValue( 10 );
3851             final AsciiHistogram histo = new AsciiHistogram( dss3 );
3852             histo.toStringBuffer( 10, '=', 40, 5 );
3853             histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3854         }
3855         catch ( final Exception e ) {
3856             e.printStackTrace( System.out );
3857             return false;
3858         }
3859         return true;
3860     }
3861
3862     private static boolean testDir( final String file ) {
3863         try {
3864             final File f = new File( file );
3865             if ( !f.exists() ) {
3866                 return false;
3867             }
3868             if ( !f.isDirectory() ) {
3869                 return false;
3870             }
3871             if ( !f.canRead() ) {
3872                 return false;
3873             }
3874         }
3875         catch ( final Exception e ) {
3876             return false;
3877         }
3878         return true;
3879     }
3880
3881     private static boolean testEbiEntryRetrieval() {
3882         try {
3883             final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3884             if ( !entry.getAccession().equals( "AAK41263" ) ) {
3885                 System.out.println( entry.getAccession() );
3886                 return false;
3887             }
3888             if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3889                 System.out.println( entry.getTaxonomyScientificName() );
3890                 return false;
3891             }
3892             if ( !entry.getSequenceName()
3893                     .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3894                 System.out.println( entry.getSequenceName() );
3895                 return false;
3896             }
3897             // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3898             //     System.out.println( entry.getSequenceSymbol() );
3899             //     return false;
3900             // }
3901             if ( !entry.getGeneName().equals( "treX-like" ) ) {
3902                 System.out.println( entry.getGeneName() );
3903                 return false;
3904             }
3905             if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3906                 System.out.println( entry.getTaxonomyIdentifier() );
3907                 return false;
3908             }
3909             if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3910                 System.out.println( entry.getAnnotations().first().getRefValue() );
3911                 return false;
3912             }
3913             if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3914                 System.out.println( entry.getAnnotations().first().getRefSource() );
3915                 return false;
3916             }
3917             if ( entry.getCrossReferences().size() != 5 ) {
3918                 return false;
3919             }
3920             //
3921             final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3922             if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3923                 return false;
3924             }
3925             if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3926                 System.out.println( entry1.getTaxonomyScientificName() );
3927                 return false;
3928             }
3929             if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3930                 System.out.println( entry1.getSequenceName() );
3931                 return false;
3932             }
3933             if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3934                 System.out.println( entry1.getTaxonomyIdentifier() );
3935                 return false;
3936             }
3937             if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3938                 System.out.println( entry1.getGeneName() );
3939                 return false;
3940             }
3941             if ( entry1.getCrossReferences().size() != 6 ) {
3942                 return false;
3943             }
3944             //
3945             final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3946             if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3947                 return false;
3948             }
3949             if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3950                 System.out.println( entry2.getTaxonomyScientificName() );
3951                 return false;
3952             }
3953             if ( !entry2.getSequenceName()
3954                     .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3955                 System.out.println( entry2.getSequenceName() );
3956                 return false;
3957             }
3958             if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3959                 System.out.println( entry2.getTaxonomyIdentifier() );
3960                 return false;
3961             }
3962             if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3963                 System.out.println( entry2.getGeneName() );
3964                 return false;
3965             }
3966             if ( entry2.getCrossReferences().size() != 3 ) {
3967                 return false;
3968             }
3969             //
3970             final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3971             if ( !entry3.getAccession().equals( "HM043801" ) ) {
3972                 return false;
3973             }
3974             if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3975                 System.out.println( entry3.getTaxonomyScientificName() );
3976                 return false;
3977             }
3978             if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3979                 System.out.println( entry3.getSequenceName() );
3980                 return false;
3981             }
3982             if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3983                 System.out.println( entry3.getTaxonomyIdentifier() );
3984                 return false;
3985             }
3986             if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3987                 System.out.println( entry3.getSequenceSymbol() );
3988                 return false;
3989             }
3990             if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3991                 return false;
3992             }
3993             if ( entry3.getCrossReferences().size() != 8 ) {
3994                 return false;
3995             }
3996             //
3997             //
3998             final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3999             if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4000                 return false;
4001             }
4002             if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4003                 System.out.println( entry4.getTaxonomyScientificName() );
4004                 return false;
4005             }
4006             if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4007                 System.out.println( entry4.getSequenceName() );
4008                 return false;
4009             }
4010             if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4011                 System.out.println( entry4.getTaxonomyIdentifier() );
4012                 return false;
4013             }
4014             if ( !entry4.getGeneName().equals( "ras" ) ) {
4015                 System.out.println( entry4.getGeneName() );
4016                 return false;
4017             }
4018             //   if ( !entry4.getChromosome().equals( "ras" ) ) {
4019             //     System.out.println( entry4.getChromosome() );
4020             //     return false;
4021             // }
4022             // if ( !entry4.getMap().equals( "ras" ) ) {
4023             //     System.out.println( entry4.getMap() );
4024             //     return false;
4025             // }
4026             //TODO FIXME gi...
4027             //
4028             //TODO fails:
4029             //            final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4030             //            if ( !entry5.getAccession().equals( "HM043801" ) ) {
4031             //                return false;
4032             //            }
4033             final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4034             if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4035                 return false;
4036             }
4037             if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4038                 System.out.println( entry5.getTaxonomyScientificName() );
4039                 return false;
4040             }
4041             if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4042                 System.out.println( entry5.getSequenceName() );
4043                 return false;
4044             }
4045             if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4046                 System.out.println( entry5.getTaxonomyIdentifier() );
4047                 return false;
4048             }
4049         }
4050         catch ( final IOException e ) {
4051             System.out.println();
4052             System.out.println( "the following might be due to absence internet connection:" );
4053             e.printStackTrace( System.out );
4054             return true;
4055         }
4056         catch ( final Exception e ) {
4057             e.printStackTrace();
4058             return false;
4059         }
4060         return true;
4061     }
4062
4063     private static boolean testExternalNodeRelatedMethods() {
4064         try {
4065             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4066             final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4067             PhylogenyNode n = t1.getNode( "A" );
4068             n = n.getNextExternalNode();
4069             if ( !n.getName().equals( "B" ) ) {
4070                 return false;
4071             }
4072             n = n.getNextExternalNode();
4073             if ( !n.getName().equals( "C" ) ) {
4074                 return false;
4075             }
4076             n = n.getNextExternalNode();
4077             if ( !n.getName().equals( "D" ) ) {
4078                 return false;
4079             }
4080             n = t1.getNode( "B" );
4081             while ( !n.isLastExternalNode() ) {
4082                 n = n.getNextExternalNode();
4083             }
4084             final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4085             n = t2.getNode( "A" );
4086             n = n.getNextExternalNode();
4087             if ( !n.getName().equals( "B" ) ) {
4088                 return false;
4089             }
4090             n = n.getNextExternalNode();
4091             if ( !n.getName().equals( "C" ) ) {
4092                 return false;
4093             }
4094             n = n.getNextExternalNode();
4095             if ( !n.getName().equals( "D" ) ) {
4096                 return false;
4097             }
4098             n = t2.getNode( "B" );
4099             while ( !n.isLastExternalNode() ) {
4100                 n = n.getNextExternalNode();
4101             }
4102             final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4103             n = t3.getNode( "A" );
4104             n = n.getNextExternalNode();
4105             if ( !n.getName().equals( "B" ) ) {
4106                 return false;
4107             }
4108             n = n.getNextExternalNode();
4109             if ( !n.getName().equals( "C" ) ) {
4110                 return false;
4111             }
4112             n = n.getNextExternalNode();
4113             if ( !n.getName().equals( "D" ) ) {
4114                 return false;
4115             }
4116             n = n.getNextExternalNode();
4117             if ( !n.getName().equals( "E" ) ) {
4118                 return false;
4119             }
4120             n = n.getNextExternalNode();
4121             if ( !n.getName().equals( "F" ) ) {
4122                 return false;
4123             }
4124             n = n.getNextExternalNode();
4125             if ( !n.getName().equals( "G" ) ) {
4126                 return false;
4127             }
4128             n = n.getNextExternalNode();
4129             if ( !n.getName().equals( "H" ) ) {
4130                 return false;
4131             }
4132             n = t3.getNode( "B" );
4133             while ( !n.isLastExternalNode() ) {
4134                 n = n.getNextExternalNode();
4135             }
4136             final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4137             for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4138                 final PhylogenyNode node = iter.next();
4139             }
4140             final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4141             for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4142                 final PhylogenyNode node = iter.next();
4143             }
4144             final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4145             final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4146             if ( !iter.next().getName().equals( "A" ) ) {
4147                 return false;
4148             }
4149             if ( !iter.next().getName().equals( "B" ) ) {
4150                 return false;
4151             }
4152             if ( !iter.next().getName().equals( "C" ) ) {
4153                 return false;
4154             }
4155             if ( !iter.next().getName().equals( "D" ) ) {
4156                 return false;
4157             }
4158             if ( !iter.next().getName().equals( "E" ) ) {
4159                 return false;
4160             }
4161             if ( !iter.next().getName().equals( "F" ) ) {
4162                 return false;
4163             }
4164             if ( iter.hasNext() ) {
4165                 return false;
4166             }
4167         }
4168         catch ( final Exception e ) {
4169             e.printStackTrace( System.out );
4170             return false;
4171         }
4172         return true;
4173     }
4174
4175     private static boolean testExtractSNFromNodeName() {
4176         try {
4177             if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4178                 return false;
4179             }
4180             if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4181                 return false;
4182             }
4183             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4184                 return false;
4185             }
4186             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4187                     .equals( "Mus musculus musculus" ) ) {
4188                 return false;
4189             }
4190             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4191                     .equals( "Mus musculus musculus" ) ) {
4192                 return false;
4193             }
4194             if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4195                     .equals( "Mus musculus musculus" ) ) {
4196                 return false;
4197             }
4198             if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4199                     .equals( "Mus musculus musculus" ) ) {
4200                 return false;
4201             }
4202             if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4203                 return false;
4204             }
4205             if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4206                     .equals( "Mus musculus musculus" ) ) {
4207                 return false;
4208             }
4209             if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4210                     .equals( "Mus musculus musculus" ) ) {
4211                 return false;
4212             }
4213             if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4214                 return false;
4215             }
4216             if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4217                 return false;
4218             }
4219             if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4220                 return false;
4221             }
4222             if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4223                 return false;
4224             }
4225             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4226                     .equals( "Mus musculus musculus" ) ) {
4227                 return false;
4228             }
4229             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4230                 return false;
4231             }
4232             if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4233                 return false;
4234             }
4235             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4236                 return false;
4237             }
4238             if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4239                 return false;
4240             }
4241             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4242                 return false;
4243             }
4244             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4245                 return false;
4246             }
4247             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4248                 return false;
4249             }
4250             if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4251                 return false;
4252             }
4253             if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4254                     .equals( "Mus musculus" ) ) {
4255                 return false;
4256             }
4257             if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4258                     .equals( "Mus musculus" ) ) {
4259                 return false;
4260             }
4261             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4262                 return false;
4263             }
4264             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4265                     .equals( "Mus musculus musculus" ) ) {
4266                 return false;
4267             }
4268             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4269                     .equals( "Mus musculus musculus" ) ) {
4270                 return false;
4271             }
4272             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4273                     .equals( "Mus musculus musculus" ) ) {
4274                 return false;
4275             }
4276             if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4277                 return false;
4278             }
4279             if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4280                     .equals( "Pilostyles mexicana" ) ) {
4281                 return false;
4282             }
4283             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4284                     .equals( "Escherichia coli strain K12/DH10B" ) ) {
4285                 return false;
4286             }
4287             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4288                     .equals( "Escherichia coli str. K12/DH10B" ) ) {
4289                 return false;
4290             }
4291             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4292                     .equals( "Escherichia coli str. K12/DH10B" ) ) {
4293                 return false;
4294             }
4295             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4296                     .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4297                 return false;
4298             }
4299             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4300                     .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4301                 return false;
4302             }
4303             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4304                     .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4305                 return false;
4306             }
4307             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4308                     .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4309                 return false;
4310             }
4311             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4312                     .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4313                 return false;
4314             }
4315             if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4316                     .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4317                 return false;
4318             }
4319             if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4320                     .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4321                 return false;
4322             }
4323             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4324                     .equals( "Escherichia coli (strain K12)" ) ) {
4325                 return false;
4326             }
4327             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4328                     .equals( "Escherichia coli (strain K12)" ) ) {
4329                 return false;
4330             }
4331             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4332                     .equals( "Escherichia coli (str. K12)" ) ) {
4333                 return false;
4334             }
4335             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4336                     .equals( "Escherichia coli (str. K12)" ) ) {
4337                 return false;
4338             }
4339             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4340                     .equals( "Escherichia coli (str. K12)" ) ) {
4341                 return false;
4342             }
4343             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4344                     .equals( "Escherichia coli (var. K12)" ) ) {
4345                 return false;
4346             }
4347             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4348                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4349                 return false;
4350             }
4351             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4352                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4353                 return false;
4354             }
4355             if ( !ParserUtils
4356                     .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4357                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4358                 return false;
4359             }
4360             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4361                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4362                 return false;
4363             }
4364             if ( !ParserUtils
4365                     .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4366                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4367                 return false;
4368             }
4369             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4370                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4371                 return false;
4372             }
4373             if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4374                     .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4375                 return false;
4376             }
4377             //
4378             if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4379                 return false;
4380             }
4381             if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4382                 return false;
4383             }
4384             if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4385                 return false;
4386             }
4387             if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4388                     .equals( "Macrocera sp." ) ) {
4389                 return false;
4390             }
4391             if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp" ) ) {
4392                 return false;
4393             }
4394         }
4395         catch ( final Exception e ) {
4396             e.printStackTrace( System.out );
4397             return false;
4398         }
4399         return true;
4400     }
4401
4402     private static boolean testExtractTaxonomyCodeFromNodeName() {
4403         try {
4404             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4405                 return false;
4406             }
4407             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4408                     .equals( "SOYBN" ) ) {
4409                 return false;
4410             }
4411             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4412                     .equals( "ARATH" ) ) {
4413                 return false;
4414             }
4415             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4416                     .equals( "ARATH" ) ) {
4417                 return false;
4418             }
4419             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4420                 return false;
4421             }
4422             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4423                 return false;
4424             }
4425             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4426                 return false;
4427             }
4428             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4429                     .equals( "SOYBN" ) ) {
4430                 return false;
4431             }
4432             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4433                     .equals( "SOYBN" ) ) {
4434                 return false;
4435             }
4436             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4437                     .equals( "SOYBN" ) ) {
4438                 return false;
4439             }
4440             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4441                     .equals( "SOYBN" ) ) {
4442                 return false;
4443             }
4444             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4445                     .equals( "SOYBN" ) ) {
4446                 return false;
4447             }
4448             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4449                     .equals( "SOYBN" ) ) {
4450                 return false;
4451             }
4452             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4453                     .equals( "SOYBN" ) ) {
4454                 return false;
4455             }
4456             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4457                     .equals( "SOYBN" ) ) {
4458                 return false;
4459             }
4460             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4461                 return false;
4462             }
4463             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4464                     .equals( "SOYBN" ) ) {
4465                 return false;
4466             }
4467             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4468                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4469                 return false;
4470             }
4471             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4472                     .equals( "9YX45" ) ) {
4473                 return false;
4474             }
4475             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4476                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4477                     .equals( "MOUSE" ) ) {
4478                 return false;
4479             }
4480             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4481                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4482                     .equals( "MOUSE" ) ) {
4483                 return false;
4484             }
4485             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4486                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4487                     .equals( "MOUSE" ) ) {
4488                 return false;
4489             }
4490             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4491                                                               TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4492                 return false;
4493             }
4494             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4495                                                               TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4496                 return false;
4497             }
4498             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4499                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4500                 return false;
4501             }
4502             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4503                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4504                 return false;
4505             }
4506             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4507                                                                TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4508                 return false;
4509             }
4510             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4511                                                               TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4512                 return false;
4513             }
4514             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4515                                                               TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4516                 return false;
4517             }
4518             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4519                     .equals( "RAT" ) ) {
4520                 return false;
4521             }
4522             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4523                     .equals( "PIG" ) ) {
4524                 return false;
4525             }
4526             if ( !ParserUtils
4527                     .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4528                     .equals( "MOUSE" ) ) {
4529                 return false;
4530             }
4531             if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4532                     .equals( "MOUSE" ) ) {
4533                 return false;
4534             }
4535             if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4536                 return false;
4537             }
4538         }
4539         catch ( final Exception e ) {
4540             e.printStackTrace( System.out );
4541             return false;
4542         }
4543         return true;
4544     }
4545
4546     private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4547         try {
4548             PhylogenyNode n = new PhylogenyNode();
4549             n.setName( "tr|B3RJ64" );
4550             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4551                 return false;
4552             }
4553             n.setName( "tr.B3RJ64" );
4554             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4555                 return false;
4556             }
4557             n.setName( "tr=B3RJ64" );
4558             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4559                 return false;
4560             }
4561             n.setName( "tr-B3RJ64" );
4562             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4563                 return false;
4564             }
4565             n.setName( "tr/B3RJ64" );
4566             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4567                 return false;
4568             }
4569             n.setName( "tr\\B3RJ64" );
4570             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4571                 return false;
4572             }
4573             n.setName( "tr_B3RJ64" );
4574             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4575                 return false;
4576             }
4577             n.setName( " tr|B3RJ64 " );
4578             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4579                 return false;
4580             }
4581             n.setName( "-tr|B3RJ64-" );
4582             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4583                 return false;
4584             }
4585             n.setName( "-tr=B3RJ64-" );
4586             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4587                 return false;
4588             }
4589             n.setName( "_tr=B3RJ64_" );
4590             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4591                 return false;
4592             }
4593             n.setName( " tr_tr|B3RJ64_sp|123 " );
4594             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4595                 return false;
4596             }
4597             n.setName( "B3RJ64" );
4598             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4599                 return false;
4600             }
4601             n.setName( "sp|B3RJ64" );
4602             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4603                 return false;
4604             }
4605             n.setName( "sp|B3RJ64C" );
4606             if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4607                 return false;
4608             }
4609             n.setName( "sp B3RJ64" );
4610             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4611                 return false;
4612             }
4613             n.setName( "sp|B3RJ6X" );
4614             if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4615                 return false;
4616             }
4617             n.setName( "sp|B3RJ6" );
4618             if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4619                 return false;
4620             }
4621             n.setName( "K1PYK7_CRAGI" );
4622             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4623                 return false;
4624             }
4625             n.setName( "K1PYK7_PEA" );
4626             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4627                 return false;
4628             }
4629             n.setName( "K1PYK7_RAT" );
4630             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4631                 return false;
4632             }
4633             n.setName( "K1PYK7_PIG" );
4634             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4635                 return false;
4636             }
4637             n.setName( "~K1PYK7_PIG~" );
4638             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4639                 return false;
4640             }
4641             n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4642             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4643                 return false;
4644             }
4645             n.setName( "K1PYKX_CRAGI" );
4646             if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4647                 return false;
4648             }
4649             n.setName( "XXXXX_CRAGI" );
4650             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4651                 return false;
4652             }
4653             n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4654             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4655                 return false;
4656             }
4657             n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4658             if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4659                 return false;
4660             }
4661             n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4662             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4663                 return false;
4664             }
4665             n = new PhylogenyNode();
4666             org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4667             seq.setSymbol( "K1PYK7_CRAGI" );
4668             n.getNodeData().addSequence( seq );
4669             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4670                 return false;
4671             }
4672             seq.setSymbol( "tr|B3RJ64" );
4673             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4674                 return false;
4675             }
4676             n = new PhylogenyNode();
4677             seq = new org.forester.phylogeny.data.Sequence();
4678             seq.setName( "K1PYK7_CRAGI" );
4679             n.getNodeData().addSequence( seq );
4680             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4681                 return false;
4682             }
4683             seq.setName( "tr|B3RJ64" );
4684             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4685                 return false;
4686             }
4687             n = new PhylogenyNode();
4688             seq = new org.forester.phylogeny.data.Sequence();
4689             seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4690             n.getNodeData().addSequence( seq );
4691             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4692                 return false;
4693             }
4694             n = new PhylogenyNode();
4695             seq = new org.forester.phylogeny.data.Sequence();
4696             seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4697             n.getNodeData().addSequence( seq );
4698             if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4699                 return false;
4700             }
4701             //
4702             n = new PhylogenyNode();
4703             n.setName( "ACP19736" );
4704             if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4705                 return false;
4706             }
4707             n = new PhylogenyNode();
4708             n.setName( "|ACP19736|" );
4709             if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4710                 return false;
4711             }
4712         }
4713         catch ( final Exception e ) {
4714             e.printStackTrace( System.out );
4715             return false;
4716         }
4717         return true;
4718     }
4719
4720     private static boolean testFastaParser() {
4721         try {
4722             if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4723                 return false;
4724             }
4725             if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4726                 return false;
4727             }
4728             final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4729             if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4730                 return false;
4731             }
4732             if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4733                 return false;
4734             }
4735             if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4736                 return false;
4737             }
4738             if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4739                 return false;
4740             }
4741             if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4742                 return false;
4743             }
4744             if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4745                 return false;
4746             }
4747         }
4748         catch ( final Exception e ) {
4749             e.printStackTrace();
4750             return false;
4751         }
4752         return true;
4753     }
4754
4755     private static boolean testGenbankAccessorParsing() {
4756         //The format for GenBank Accession numbers are:
4757         //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4758         //Protein:    3 letters + 5 numerals
4759         //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4760         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4761             return false;
4762         }
4763         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4764             return false;
4765         }
4766         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4767             return false;
4768         }
4769         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4770             return false;
4771         }
4772         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4773             return false;
4774         }
4775         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4776             return false;
4777         }
4778         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4779             return false;
4780         }
4781         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4782             return false;
4783         }
4784         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4785             return false;
4786         }
4787         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4788             return false;
4789         }
4790         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4791             return false;
4792         }
4793         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4794             return false;
4795         }
4796         if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4797             return false;
4798         }
4799         if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4800             return false;
4801         }
4802         return true;
4803     }
4804
4805     private static boolean testGeneralMsaParser() {
4806         try {
4807             final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4808             final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4809             final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4810             final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4811             final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4812             final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4813             final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4814             final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4815             if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4816                 return false;
4817             }
4818             if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4819                 return false;
4820             }
4821             if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4822                 return false;
4823             }
4824             if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4825                 return false;
4826             }
4827             if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4828                 return false;
4829             }
4830             if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4831                 return false;
4832             }
4833             if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4834                 return false;
4835             }
4836             if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4837                 return false;
4838             }
4839             if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4840                 return false;
4841             }
4842             if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4843                 return false;
4844             }
4845             if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4846                 return false;
4847             }
4848             if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4849                 return false;
4850             }
4851             final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4852             if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4853                 return false;
4854             }
4855             if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4856                 return false;
4857             }
4858             if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4859                 return false;
4860             }
4861             final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4862             if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4863                 return false;
4864             }
4865             if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4866                 return false;
4867             }
4868             if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4869                 return false;
4870             }
4871             final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4872             if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4873                 return false;
4874             }
4875             if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4876                 return false;
4877             }
4878             if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4879                 return false;
4880             }
4881         }
4882         catch ( final Exception e ) {
4883             e.printStackTrace();
4884             return false;
4885         }
4886         return true;
4887     }
4888
4889     private static boolean testGeneralTable() {
4890         try {
4891             final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4892             t0.setValue( 3, 2, "23" );
4893             t0.setValue( 10, 1, "error" );
4894             t0.setValue( 10, 1, "110" );
4895             t0.setValue( 9, 1, "19" );
4896             t0.setValue( 1, 10, "101" );
4897             t0.setValue( 10, 10, "1010" );
4898             t0.setValue( 100, 10, "10100" );
4899             t0.setValue( 0, 0, "00" );
4900             if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4901                 return false;
4902             }
4903             if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4904                 return false;
4905             }
4906             if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4907                 return false;
4908             }
4909             if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4910                 return false;
4911             }
4912             if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4913                 return false;
4914             }
4915             if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4916                 return false;
4917             }
4918             if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4919                 return false;
4920             }
4921             if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4922                 return false;
4923             }
4924             if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4925                 return false;
4926             }
4927             final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4928             t1.setValue( "3", "2", "23" );
4929             t1.setValue( "10", "1", "error" );
4930             t1.setValue( "10", "1", "110" );
4931             t1.setValue( "9", "1", "19" );
4932             t1.setValue( "1", "10", "101" );
4933             t1.setValue( "10", "10", "1010" );
4934             t1.setValue( "100", "10", "10100" );
4935             t1.setValue( "0", "0", "00" );
4936             t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4937             if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4938                 return false;
4939             }
4940             if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4941                 return false;
4942             }
4943             if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4944                 return false;
4945             }
4946             if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4947                 return false;
4948             }
4949             if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4950                 return false;
4951             }
4952             if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4953                 return false;
4954             }
4955             if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4956                 return false;
4957             }
4958             if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4959                 return false;
4960             }
4961             if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4962                 return false;
4963             }
4964             if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4965                 return false;
4966             }
4967         }
4968         catch ( final Exception e ) {
4969             e.printStackTrace( System.out );
4970             return false;
4971         }
4972         return true;
4973     }
4974
4975     private static boolean testGetDistance() {
4976         try {
4977             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4978             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",
4979                                                  new NHXParser() )[ 0 ];
4980             if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4981                 return false;
4982             }
4983             if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4984                 return false;
4985             }
4986             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4987                 return false;
4988             }
4989             if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4990                 return false;
4991             }
4992             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4993                 return false;
4994             }
4995             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4996                 return false;
4997             }
4998             if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4999                 return false;
5000             }
5001             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5002                 return false;
5003             }
5004             if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5005                 return false;
5006             }
5007             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5008                 return false;
5009             }
5010             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5011                 return false;
5012             }
5013             if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5014                 return false;
5015             }
5016             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5017                 return false;
5018             }
5019             if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5020                 return false;
5021             }
5022             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5023                 return false;
5024             }
5025             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5026                 return false;
5027             }
5028             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5029                 return false;
5030             }
5031             if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5032                 return false;
5033             }
5034             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5035                 return false;
5036             }
5037             if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5038                 return false;
5039             }
5040             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5041                 return false;
5042             }
5043             if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5044                 return false;
5045             }
5046             if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5047                 return false;
5048             }
5049             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5050                 return false;
5051             }
5052             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5053                 return false;
5054             }
5055             if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5056                 return false;
5057             }
5058             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5059                 return false;
5060             }
5061             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5062                 return false;
5063             }
5064             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5065                 return false;
5066             }
5067             if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5068                 return false;
5069             }
5070             if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5071                 return false;
5072             }
5073             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",
5074                                                  new NHXParser() )[ 0 ];
5075             if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5076                 return false;
5077             }
5078             if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5079                 return false;
5080             }
5081             if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5082                 return false;
5083             }
5084             if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5085                 return false;
5086             }
5087             if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5088                 return false;
5089             }
5090             if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5091                 return false;
5092             }
5093             if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5094                 return false;
5095             }
5096             if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5097                 return false;
5098             }
5099             if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5100                 return false;
5101             }
5102             if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5103                 return false;
5104             }
5105             if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5106                 return false;
5107             }
5108         }
5109         catch ( final Exception e ) {
5110             e.printStackTrace( System.out );
5111             return false;
5112         }
5113         return true;
5114     }
5115
5116     private static boolean testGetLCA() {
5117         try {
5118             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5119             final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5120                                                  new NHXParser() )[ 0 ];
5121             final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5122             if ( !A.getName().equals( "A" ) ) {
5123                 return false;
5124             }
5125             final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5126             if ( !gh.getName().equals( "gh" ) ) {
5127                 return false;
5128             }
5129             final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5130             if ( !ab.getName().equals( "ab" ) ) {
5131                 return false;
5132             }
5133             final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5134             if ( !ab2.getName().equals( "ab" ) ) {
5135                 return false;
5136             }
5137             final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5138             if ( !gh2.getName().equals( "gh" ) ) {
5139                 return false;
5140             }
5141             final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5142             if ( !gh3.getName().equals( "gh" ) ) {
5143                 return false;
5144             }
5145             final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5146             if ( !abc.getName().equals( "abc" ) ) {
5147                 return false;
5148             }
5149             final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5150             if ( !abc2.getName().equals( "abc" ) ) {
5151                 return false;
5152             }
5153             final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5154             if ( !abcd.getName().equals( "abcd" ) ) {
5155                 return false;
5156             }
5157             final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5158             if ( !abcd2.getName().equals( "abcd" ) ) {
5159                 return false;
5160             }
5161             final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5162             if ( !abcdef.getName().equals( "abcdef" ) ) {
5163                 return false;
5164             }
5165             final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5166             if ( !abcdef2.getName().equals( "abcdef" ) ) {
5167                 return false;
5168             }
5169             final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5170             if ( !abcdef3.getName().equals( "abcdef" ) ) {
5171                 return false;
5172             }
5173             final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5174             if ( !abcdef4.getName().equals( "abcdef" ) ) {
5175                 return false;
5176             }
5177             final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5178             if ( !abcde.getName().equals( "abcde" ) ) {
5179                 return false;
5180             }
5181             final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5182             if ( !abcde2.getName().equals( "abcde" ) ) {
5183                 return false;
5184             }
5185             final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5186             if ( !r.getName().equals( "abcdefgh" ) ) {
5187                 return false;
5188             }
5189             final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5190             if ( !r2.getName().equals( "abcdefgh" ) ) {
5191                 return false;
5192             }
5193             final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5194             if ( !r3.getName().equals( "abcdefgh" ) ) {
5195                 return false;
5196             }
5197             final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5198             if ( !abcde3.getName().equals( "abcde" ) ) {
5199                 return false;
5200             }
5201             final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5202             if ( !abcde4.getName().equals( "abcde" ) ) {
5203                 return false;
5204             }
5205             final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5206             if ( !ab3.getName().equals( "ab" ) ) {
5207                 return false;
5208             }
5209             final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5210             if ( !ab4.getName().equals( "ab" ) ) {
5211                 return false;
5212             }
5213             final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5214             final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5215             if ( !cd.getName().equals( "cd" ) ) {
5216                 return false;
5217             }
5218             final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5219             if ( !cd2.getName().equals( "cd" ) ) {
5220                 return false;
5221             }
5222             final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5223             if ( !cde.getName().equals( "cde" ) ) {
5224                 return false;
5225             }
5226             final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5227             if ( !cde2.getName().equals( "cde" ) ) {
5228                 return false;
5229             }
5230             final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5231             if ( !cdef.getName().equals( "cdef" ) ) {
5232                 return false;
5233             }
5234             final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5235             if ( !cdef2.getName().equals( "cdef" ) ) {
5236                 return false;
5237             }
5238             final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5239             if ( !cdef3.getName().equals( "cdef" ) ) {
5240                 return false;
5241             }
5242             final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5243             if ( !rt.getName().equals( "r" ) ) {
5244                 return false;
5245             }
5246             final Phylogeny p3 = factory
5247                     .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5248                              new NHXParser() )[ 0 ];
5249             final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5250             if ( !bc_3.getName().equals( "bc" ) ) {
5251                 return false;
5252             }
5253             final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5254             if ( !ac_3.getName().equals( "abc" ) ) {
5255                 return false;
5256             }
5257             final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5258             if ( !ad_3.getName().equals( "abcde" ) ) {
5259                 return false;
5260             }
5261             final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5262             if ( !af_3.getName().equals( "abcdef" ) ) {
5263                 return false;
5264             }
5265             final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5266             if ( !ag_3.getName().equals( "" ) ) {
5267                 return false;
5268             }
5269             if ( !ag_3.isRoot() ) {
5270                 return false;
5271             }
5272             final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5273             if ( !al_3.getName().equals( "" ) ) {
5274                 return false;
5275             }
5276             if ( !al_3.isRoot() ) {
5277                 return false;
5278             }
5279             final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5280             if ( !kl_3.getName().equals( "" ) ) {
5281                 return false;
5282             }
5283             if ( !kl_3.isRoot() ) {
5284                 return false;
5285             }
5286             final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5287             if ( !fl_3.getName().equals( "" ) ) {
5288                 return false;
5289             }
5290             if ( !fl_3.isRoot() ) {
5291                 return false;
5292             }
5293             final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5294             if ( !gk_3.getName().equals( "ghijk" ) ) {
5295                 return false;
5296             }
5297             final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5298             final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5299             if ( !r_4.getName().equals( "r" ) ) {
5300                 return false;
5301             }
5302             final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5303             final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5304             if ( !r_5.getName().equals( "root" ) ) {
5305                 return false;
5306             }
5307             final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5308             final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5309             if ( !r_6.getName().equals( "rot" ) ) {
5310                 return false;
5311             }
5312             final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5313             final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5314             if ( !r_7.getName().equals( "rott" ) ) {
5315                 return false;
5316             }
5317         }
5318         catch ( final Exception e ) {
5319             e.printStackTrace( System.out );
5320             return false;
5321         }
5322         return true;
5323     }
5324
5325     private static boolean testGetLCA2() {
5326         try {
5327             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5328             // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5329             final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5330             PhylogenyMethods.preOrderReId( p_a );
5331             final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5332                                                                                               p_a.getNode( "a" ) );
5333             if ( !p_a_1.getName().equals( "a" ) ) {
5334                 return false;
5335             }
5336             final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5337             PhylogenyMethods.preOrderReId( p_b );
5338             final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5339                                                                                               p_b.getNode( "a" ) );
5340             if ( !p_b_1.getName().equals( "b" ) ) {
5341                 return false;
5342             }
5343             final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5344                                                                                               p_b.getNode( "b" ) );
5345             if ( !p_b_2.getName().equals( "b" ) ) {
5346                 return false;
5347             }
5348             final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5349             PhylogenyMethods.preOrderReId( p_c );
5350             final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5351                                                                                               p_c.getNode( "a" ) );
5352             if ( !p_c_1.getName().equals( "b" ) ) {
5353                 return false;
5354             }
5355             final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5356                                                                                               p_c.getNode( "c" ) );
5357             if ( !p_c_2.getName().equals( "c" ) ) {
5358                 System.out.println( p_c_2.getName() );
5359                 System.exit( -1 );
5360                 return false;
5361             }
5362             final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5363                                                                                               p_c.getNode( "b" ) );
5364             if ( !p_c_3.getName().equals( "b" ) ) {
5365                 return false;
5366             }
5367             final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5368                                                                                               p_c.getNode( "a" ) );
5369             if ( !p_c_4.getName().equals( "c" ) ) {
5370                 return false;
5371             }
5372             final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5373                                                  new NHXParser() )[ 0 ];
5374             PhylogenyMethods.preOrderReId( p1 );
5375             final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5376                                                                                           p1.getNode( "A" ) );
5377             if ( !A.getName().equals( "A" ) ) {
5378                 return false;
5379             }
5380             final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5381                                                                                            p1.getNode( "gh" ) );
5382             if ( !gh.getName().equals( "gh" ) ) {
5383                 return false;
5384             }
5385             final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5386                                                                                            p1.getNode( "B" ) );
5387             if ( !ab.getName().equals( "ab" ) ) {
5388                 return false;
5389             }
5390             final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5391                                                                                             p1.getNode( "A" ) );
5392             if ( !ab2.getName().equals( "ab" ) ) {
5393                 return false;
5394             }
5395             final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5396                                                                                             p1.getNode( "G" ) );
5397             if ( !gh2.getName().equals( "gh" ) ) {
5398                 return false;
5399             }
5400             final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5401                                                                                             p1.getNode( "H" ) );
5402             if ( !gh3.getName().equals( "gh" ) ) {
5403                 return false;
5404             }
5405             final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5406                                                                                             p1.getNode( "A" ) );
5407             if ( !abc.getName().equals( "abc" ) ) {
5408                 return false;
5409             }
5410             final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5411                                                                                              p1.getNode( "C" ) );
5412             if ( !abc2.getName().equals( "abc" ) ) {
5413                 return false;
5414             }
5415             final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5416                                                                                              p1.getNode( "D" ) );
5417             if ( !abcd.getName().equals( "abcd" ) ) {
5418                 return false;
5419             }
5420             final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5421                                                                                               p1.getNode( "A" ) );
5422             if ( !abcd2.getName().equals( "abcd" ) ) {
5423                 return false;
5424             }
5425             final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5426                                                                                                p1.getNode( "F" ) );
5427             if ( !abcdef.getName().equals( "abcdef" ) ) {
5428                 return false;
5429             }
5430             final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5431                                                                                                 p1.getNode( "A" ) );
5432             if ( !abcdef2.getName().equals( "abcdef" ) ) {
5433                 return false;
5434             }
5435             final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5436                                                                                                 p1.getNode( "F" ) );
5437             if ( !abcdef3.getName().equals( "abcdef" ) ) {
5438                 return false;
5439             }
5440             final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5441                                                                                                 p1.getNode( "ab" ) );
5442             if ( !abcdef4.getName().equals( "abcdef" ) ) {
5443                 return false;
5444             }
5445             final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5446                                                                                               p1.getNode( "E" ) );
5447             if ( !abcde.getName().equals( "abcde" ) ) {
5448                 return false;
5449             }
5450             final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5451                                                                                                p1.getNode( "A" ) );
5452             if ( !abcde2.getName().equals( "abcde" ) ) {
5453                 return false;
5454             }
5455             final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5456                                                                                           p1.getNode( "abcdefgh" ) );
5457             if ( !r.getName().equals( "abcdefgh" ) ) {
5458                 return false;
5459             }
5460             final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5461                                                                                            p1.getNode( "H" ) );
5462             if ( !r2.getName().equals( "abcdefgh" ) ) {
5463                 return false;
5464             }
5465             final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5466                                                                                            p1.getNode( "A" ) );
5467             if ( !r3.getName().equals( "abcdefgh" ) ) {
5468                 return false;
5469             }
5470             final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5471                                                                                                p1.getNode( "abcde" ) );
5472             if ( !abcde3.getName().equals( "abcde" ) ) {
5473                 return false;
5474             }
5475             final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5476                                                                                                p1.getNode( "E" ) );
5477             if ( !abcde4.getName().equals( "abcde" ) ) {
5478                 return false;
5479             }
5480             final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5481                                                                                             p1.getNode( "B" ) );
5482             if ( !ab3.getName().equals( "ab" ) ) {
5483                 return false;
5484             }
5485             final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5486                                                                                             p1.getNode( "ab" ) );
5487             if ( !ab4.getName().equals( "ab" ) ) {
5488                 return false;
5489             }
5490             final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5491             PhylogenyMethods.preOrderReId( p2 );
5492             final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5493                                                                                            p2.getNode( "d" ) );
5494             if ( !cd.getName().equals( "cd" ) ) {
5495                 return false;
5496             }
5497             final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5498                                                                                             p2.getNode( "c" ) );
5499             if ( !cd2.getName().equals( "cd" ) ) {
5500                 return false;
5501             }
5502             final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5503                                                                                             p2.getNode( "e" ) );
5504             if ( !cde.getName().equals( "cde" ) ) {
5505                 return false;
5506             }
5507             final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5508                                                                                              p2.getNode( "c" ) );
5509             if ( !cde2.getName().equals( "cde" ) ) {
5510                 return false;
5511             }
5512             final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5513                                                                                              p2.getNode( "f" ) );
5514             if ( !cdef.getName().equals( "cdef" ) ) {
5515                 return false;
5516             }
5517             final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5518                                                                                               p2.getNode( "f" ) );
5519             if ( !cdef2.getName().equals( "cdef" ) ) {
5520                 return false;
5521             }
5522             final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5523                                                                                               p2.getNode( "d" ) );
5524             if ( !cdef3.getName().equals( "cdef" ) ) {
5525                 return false;
5526             }
5527             final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5528                                                                                            p2.getNode( "a" ) );
5529             if ( !rt.getName().equals( "r" ) ) {
5530                 return false;
5531             }
5532             final Phylogeny p3 = factory
5533                     .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5534                              new NHXParser() )[ 0 ];
5535             PhylogenyMethods.preOrderReId( p3 );
5536             final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5537                                                                                              p3.getNode( "c" ) );
5538             if ( !bc_3.getName().equals( "bc" ) ) {
5539                 return false;
5540             }
5541             final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5542                                                                                              p3.getNode( "c" ) );
5543             if ( !ac_3.getName().equals( "abc" ) ) {
5544                 return false;
5545             }
5546             final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5547                                                                                              p3.getNode( "d" ) );
5548             if ( !ad_3.getName().equals( "abcde" ) ) {
5549                 return false;
5550             }
5551             final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5552                                                                                              p3.getNode( "f" ) );
5553             if ( !af_3.getName().equals( "abcdef" ) ) {
5554                 return false;
5555             }
5556             final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5557                                                                                              p3.getNode( "g" ) );
5558             if ( !ag_3.getName().equals( "" ) ) {
5559                 return false;
5560             }
5561             if ( !ag_3.isRoot() ) {
5562                 return false;
5563             }
5564             final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5565                                                                                              p3.getNode( "l" ) );
5566             if ( !al_3.getName().equals( "" ) ) {
5567                 return false;
5568             }
5569             if ( !al_3.isRoot() ) {
5570                 return false;
5571             }
5572             final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5573                                                                                              p3.getNode( "l" ) );
5574             if ( !kl_3.getName().equals( "" ) ) {
5575                 return false;
5576             }
5577             if ( !kl_3.isRoot() ) {
5578                 return false;
5579             }
5580             final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5581                                                                                              p3.getNode( "l" ) );
5582             if ( !fl_3.getName().equals( "" ) ) {
5583                 return false;
5584             }
5585             if ( !fl_3.isRoot() ) {
5586                 return false;
5587             }
5588             final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5589                                                                                              p3.getNode( "k" ) );
5590             if ( !gk_3.getName().equals( "ghijk" ) ) {
5591                 return false;
5592             }
5593             final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5594             PhylogenyMethods.preOrderReId( p4 );
5595             final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5596                                                                                             p4.getNode( "c" ) );
5597             if ( !r_4.getName().equals( "r" ) ) {
5598                 return false;
5599             }
5600             final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5601             PhylogenyMethods.preOrderReId( p5 );
5602             final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5603                                                                                             p5.getNode( "c" ) );
5604             if ( !r_5.getName().equals( "root" ) ) {
5605                 return false;
5606             }
5607             final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5608             PhylogenyMethods.preOrderReId( p6 );
5609             final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5610                                                                                             p6.getNode( "a" ) );
5611             if ( !r_6.getName().equals( "rot" ) ) {
5612                 return false;
5613             }
5614             final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5615             PhylogenyMethods.preOrderReId( p7 );
5616             final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5617                                                                                             p7.getNode( "e" ) );
5618             if ( !r_7.getName().equals( "rott" ) ) {
5619                 return false;
5620             }
5621             final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5622                                                                                              p7.getNode( "a" ) );
5623             if ( !r_71.getName().equals( "rott" ) ) {
5624                 return false;
5625             }
5626             final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5627                                                                                              p7.getNode( "rott" ) );
5628             if ( !r_72.getName().equals( "rott" ) ) {
5629                 return false;
5630             }
5631             final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5632                                                                                              p7.getNode( "a" ) );
5633             if ( !r_73.getName().equals( "rott" ) ) {
5634                 return false;
5635             }
5636             final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5637                                                                                              p7.getNode( "rott" ) );
5638             if ( !r_74.getName().equals( "rott" ) ) {
5639                 return false;
5640             }
5641             final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5642                                                                                              p7.getNode( "e" ) );
5643             if ( !r_75.getName().equals( "e" ) ) {
5644                 return false;
5645             }
5646         }
5647         catch ( final Exception e ) {
5648             e.printStackTrace( System.out );
5649             return false;
5650         }
5651         return true;
5652     }
5653
5654     private static boolean testHmmscanOutputParser() {
5655         final String test_dir = Test.PATH_TO_TEST_DATA;
5656         try {
5657             final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5658                     + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5659             parser1.parse();
5660             final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5661                     + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5662             final List<Protein> proteins = parser2.parse();
5663             if ( parser2.getProteinsEncountered() != 4 ) {
5664                 return false;
5665             }
5666             if ( proteins.size() != 4 ) {
5667                 return false;
5668             }
5669             if ( parser2.getDomainsEncountered() != 69 ) {
5670                 return false;
5671             }
5672             if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5673                 return false;
5674             }
5675             if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5676                 return false;
5677             }
5678             if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5679                 return false;
5680             }
5681             final Protein p1 = proteins.get( 0 );
5682             if ( p1.getNumberOfProteinDomains() != 15 ) {
5683                 return false;
5684             }
5685             if ( p1.getLength() != 850 ) {
5686                 return false;
5687             }
5688             final Protein p2 = proteins.get( 1 );
5689             if ( p2.getNumberOfProteinDomains() != 51 ) {
5690                 return false;
5691             }
5692             if ( p2.getLength() != 1291 ) {
5693                 return false;
5694             }
5695             final Protein p3 = proteins.get( 2 );
5696             if ( p3.getNumberOfProteinDomains() != 2 ) {
5697                 return false;
5698             }
5699             final Protein p4 = proteins.get( 3 );
5700             if ( p4.getNumberOfProteinDomains() != 1 ) {
5701                 return false;
5702             }
5703             if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5704                 return false;
5705             }
5706             if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5707                 return false;
5708             }
5709             if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5710                 return false;
5711             }
5712             if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5713                 return false;
5714             }
5715             if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5716                 return false;
5717             }
5718             if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5719                 return false;
5720             }
5721             if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5722                 return false;
5723             }
5724         }
5725         catch ( final Exception e ) {
5726             e.printStackTrace( System.out );
5727             return false;
5728         }
5729         return true;
5730     }
5731
5732     private static boolean testLastExternalNodeMethods() {
5733         try {
5734             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5735             final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5736             final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5737             final PhylogenyNode n1 = t0.getNode( "A" );
5738             if ( n1.isLastExternalNode() ) {
5739                 return false;
5740             }
5741             final PhylogenyNode n2 = t0.getNode( "B" );
5742             if ( n2.isLastExternalNode() ) {
5743                 return false;
5744             }
5745             final PhylogenyNode n3 = t0.getNode( "C" );
5746             if ( n3.isLastExternalNode() ) {
5747                 return false;
5748             }
5749             final PhylogenyNode n4 = t0.getNode( "D" );
5750             if ( !n4.isLastExternalNode() ) {
5751                 return false;
5752             }
5753         }
5754         catch ( final Exception e ) {
5755             e.printStackTrace( System.out );
5756             return false;
5757         }
5758         return true;
5759     }
5760
5761     private static boolean testLevelOrderIterator() {
5762         try {
5763             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5764             final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5765             PhylogenyNodeIterator it0;
5766             for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5767                 it0.next();
5768             }
5769             for( it0.reset(); it0.hasNext(); ) {
5770                 it0.next();
5771             }
5772             final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5773             if ( !it.next().getName().equals( "r" ) ) {
5774                 return false;
5775             }
5776             if ( !it.next().getName().equals( "ab" ) ) {
5777                 return false;
5778             }
5779             if ( !it.next().getName().equals( "cd" ) ) {
5780                 return false;
5781             }
5782             if ( !it.next().getName().equals( "A" ) ) {
5783                 return false;
5784             }
5785             if ( !it.next().getName().equals( "B" ) ) {
5786                 return false;
5787             }
5788             if ( !it.next().getName().equals( "C" ) ) {
5789                 return false;
5790             }
5791             if ( !it.next().getName().equals( "D" ) ) {
5792                 return false;
5793             }
5794             if ( it.hasNext() ) {
5795                 return false;
5796             }
5797             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",
5798                                                  new NHXParser() )[ 0 ];
5799             PhylogenyNodeIterator it2;
5800             for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5801                 it2.next();
5802             }
5803             for( it2.reset(); it2.hasNext(); ) {
5804                 it2.next();
5805             }
5806             final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5807             if ( !it3.next().getName().equals( "r" ) ) {
5808                 return false;
5809             }
5810             if ( !it3.next().getName().equals( "abc" ) ) {
5811                 return false;
5812             }
5813             if ( !it3.next().getName().equals( "defg" ) ) {
5814                 return false;
5815             }
5816             if ( !it3.next().getName().equals( "A" ) ) {
5817                 return false;
5818             }
5819             if ( !it3.next().getName().equals( "B" ) ) {
5820                 return false;
5821             }
5822             if ( !it3.next().getName().equals( "C" ) ) {
5823                 return false;
5824             }
5825             if ( !it3.next().getName().equals( "D" ) ) {
5826                 return false;
5827             }
5828             if ( !it3.next().getName().equals( "E" ) ) {
5829                 return false;
5830             }
5831             if ( !it3.next().getName().equals( "F" ) ) {
5832                 return false;
5833             }
5834             if ( !it3.next().getName().equals( "G" ) ) {
5835                 return false;
5836             }
5837             if ( !it3.next().getName().equals( "1" ) ) {
5838                 return false;
5839             }
5840             if ( !it3.next().getName().equals( "2" ) ) {
5841                 return false;
5842             }
5843             if ( !it3.next().getName().equals( "3" ) ) {
5844                 return false;
5845             }
5846             if ( !it3.next().getName().equals( "4" ) ) {
5847                 return false;
5848             }
5849             if ( !it3.next().getName().equals( "5" ) ) {
5850                 return false;
5851             }
5852             if ( !it3.next().getName().equals( "6" ) ) {
5853                 return false;
5854             }
5855             if ( !it3.next().getName().equals( "f1" ) ) {
5856                 return false;
5857             }
5858             if ( !it3.next().getName().equals( "f2" ) ) {
5859                 return false;
5860             }
5861             if ( !it3.next().getName().equals( "f3" ) ) {
5862                 return false;
5863             }
5864             if ( !it3.next().getName().equals( "a" ) ) {
5865                 return false;
5866             }
5867             if ( !it3.next().getName().equals( "b" ) ) {
5868                 return false;
5869             }
5870             if ( !it3.next().getName().equals( "f21" ) ) {
5871                 return false;
5872             }
5873             if ( !it3.next().getName().equals( "X" ) ) {
5874                 return false;
5875             }
5876             if ( !it3.next().getName().equals( "Y" ) ) {
5877                 return false;
5878             }
5879             if ( !it3.next().getName().equals( "Z" ) ) {
5880                 return false;
5881             }
5882             if ( it3.hasNext() ) {
5883                 return false;
5884             }
5885             final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5886             PhylogenyNodeIterator it4;
5887             for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5888                 it4.next();
5889             }
5890             for( it4.reset(); it4.hasNext(); ) {
5891                 it4.next();
5892             }
5893             final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5894             if ( !it5.next().getName().equals( "r" ) ) {
5895                 return false;
5896             }
5897             if ( !it5.next().getName().equals( "A" ) ) {
5898                 return false;
5899             }
5900             if ( !it5.next().getName().equals( "B" ) ) {
5901                 return false;
5902             }
5903             if ( !it5.next().getName().equals( "C" ) ) {
5904                 return false;
5905             }
5906             if ( !it5.next().getName().equals( "D" ) ) {
5907                 return false;
5908             }
5909             final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5910             PhylogenyNodeIterator it6;
5911             for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5912                 it6.next();
5913             }
5914             for( it6.reset(); it6.hasNext(); ) {
5915                 it6.next();
5916             }
5917             final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5918             if ( !it7.next().getName().equals( "A" ) ) {
5919                 return false;
5920             }
5921             if ( it.hasNext() ) {
5922                 return false;
5923             }
5924         }
5925         catch ( final Exception e ) {
5926             e.printStackTrace( System.out );
5927             return false;
5928         }
5929         return true;
5930     }
5931
5932     private static boolean testMafft( final String path ) {
5933         try {
5934             final List<String> opts = new ArrayList<String>();
5935             opts.add( "--maxiterate" );
5936             opts.add( "1000" );
5937             opts.add( "--localpair" );
5938             opts.add( "--quiet" );
5939             Msa msa = null;
5940             final MsaInferrer mafft = Mafft.createInstance( path );
5941             msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5942             if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5943                 return false;
5944             }
5945             if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5946                 return false;
5947             }
5948         }
5949         catch ( final Exception e ) {
5950             e.printStackTrace( System.out );
5951             return false;
5952         }
5953         return true;
5954     }
5955
5956     private static boolean testMidpointrooting() {
5957         try {
5958             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5959             final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5960             PhylogenyMethods.midpointRoot( t0 );
5961             if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5962                 return false;
5963             }
5964             if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5965                 return false;
5966             }
5967             if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5968                            1 ) ) {
5969                 return false;
5970             }
5971             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",
5972                                                  new NHXParser() )[ 0 ];
5973             if ( !t1.isRooted() ) {
5974                 return false;
5975             }
5976             PhylogenyMethods.midpointRoot( t1 );
5977             if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5978                 return false;
5979             }
5980             if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5981                 return false;
5982             }
5983             if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5984                 return false;
5985             }
5986             if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5987                 return false;
5988             }
5989             if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5990                 return false;
5991             }
5992             if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5993                 return false;
5994             }
5995             t1.reRoot( t1.getNode( "A" ) );
5996             PhylogenyMethods.midpointRoot( t1 );
5997             if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5998                 return false;
5999             }
6000             if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6001                 return false;
6002             }
6003             if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6004                 return false;
6005             }
6006             if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6007                 return false;
6008             }
6009             if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6010                 System.exit( -1 );
6011                 return false;
6012             }
6013             if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6014                 return false;
6015             }
6016         }
6017         catch ( final Exception e ) {
6018             e.printStackTrace( System.out );
6019             return false;
6020         }
6021         return true;
6022     }
6023
6024     private static boolean testMsaQualityMethod() {
6025         try {
6026             final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6027             final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6028             final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6029             final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6030             final List<Sequence> l = new ArrayList<Sequence>();
6031             l.add( s0 );
6032             l.add( s1 );
6033             l.add( s2 );
6034             l.add( s3 );
6035             final Msa msa = BasicMsa.createInstance( l );
6036             if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6037                 return false;
6038             }
6039             if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6040                 return false;
6041             }
6042             if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6043                 return false;
6044             }
6045             if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6046                 return false;
6047             }
6048             if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6049                 return false;
6050             }
6051             if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6052                 return false;
6053             }
6054             if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6055                 return false;
6056             }
6057         }
6058         catch ( final Exception e ) {
6059             e.printStackTrace( System.out );
6060             return false;
6061         }
6062         return true;
6063     }
6064
6065     private static boolean testNextNodeWithCollapsing() {
6066         try {
6067             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6068             PhylogenyNode n;
6069             List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6070             final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6071             final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6072             t0.getNode( "cd" ).setCollapse( true );
6073             t0.getNode( "cde" ).setCollapse( true );
6074             n = t0.getFirstExternalNode();
6075             while ( n != null ) {
6076                 ext.add( n );
6077                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6078             }
6079             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6080                 return false;
6081             }
6082             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6083                 return false;
6084             }
6085             if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6086                 return false;
6087             }
6088             if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6089                 return false;
6090             }
6091             if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6092                 return false;
6093             }
6094             if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6095                 return false;
6096             }
6097             ext.clear();
6098             final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6099             final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6100             t1.getNode( "ab" ).setCollapse( true );
6101             t1.getNode( "cd" ).setCollapse( true );
6102             t1.getNode( "cde" ).setCollapse( true );
6103             n = t1.getNode( "ab" );
6104             ext = new ArrayList<PhylogenyNode>();
6105             while ( n != null ) {
6106                 ext.add( n );
6107                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6108             }
6109             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6110                 return false;
6111             }
6112             if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6113                 return false;
6114             }
6115             if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6116                 return false;
6117             }
6118             if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6119                 return false;
6120             }
6121             if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6122                 return false;
6123             }
6124             //
6125             //
6126             ext.clear();
6127             final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6128             final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6129             t2.getNode( "ab" ).setCollapse( true );
6130             t2.getNode( "cd" ).setCollapse( true );
6131             t2.getNode( "cde" ).setCollapse( true );
6132             t2.getNode( "c" ).setCollapse( true );
6133             t2.getNode( "d" ).setCollapse( true );
6134             t2.getNode( "e" ).setCollapse( true );
6135             t2.getNode( "gh" ).setCollapse( true );
6136             n = t2.getNode( "ab" );
6137             ext = new ArrayList<PhylogenyNode>();
6138             while ( n != null ) {
6139                 ext.add( n );
6140                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6141             }
6142             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6143                 return false;
6144             }
6145             if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6146                 return false;
6147             }
6148             if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6149                 return false;
6150             }
6151             if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6152                 return false;
6153             }
6154             //
6155             //
6156             ext.clear();
6157             final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6158             final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6159             t3.getNode( "ab" ).setCollapse( true );
6160             t3.getNode( "cd" ).setCollapse( true );
6161             t3.getNode( "cde" ).setCollapse( true );
6162             t3.getNode( "c" ).setCollapse( true );
6163             t3.getNode( "d" ).setCollapse( true );
6164             t3.getNode( "e" ).setCollapse( true );
6165             t3.getNode( "gh" ).setCollapse( true );
6166             t3.getNode( "fgh" ).setCollapse( true );
6167             n = t3.getNode( "ab" );
6168             ext = new ArrayList<PhylogenyNode>();
6169             while ( n != null ) {
6170                 ext.add( n );
6171                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6172             }
6173             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6174                 return false;
6175             }
6176             if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6177                 return false;
6178             }
6179             if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6180                 return false;
6181             }
6182             //
6183             //
6184             ext.clear();
6185             final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6186             final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6187             t4.getNode( "ab" ).setCollapse( true );
6188             t4.getNode( "cd" ).setCollapse( true );
6189             t4.getNode( "cde" ).setCollapse( true );
6190             t4.getNode( "c" ).setCollapse( true );
6191             t4.getNode( "d" ).setCollapse( true );
6192             t4.getNode( "e" ).setCollapse( true );
6193             t4.getNode( "gh" ).setCollapse( true );
6194             t4.getNode( "fgh" ).setCollapse( true );
6195             t4.getNode( "abcdefgh" ).setCollapse( true );
6196             n = t4.getNode( "abcdefgh" );
6197             if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6198                 return false;
6199             }
6200             //
6201             //
6202             final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6203             final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6204             ext.clear();
6205             n = t5.getFirstExternalNode();
6206             while ( n != null ) {
6207                 ext.add( n );
6208                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6209             }
6210             if ( ext.size() != 8 ) {
6211                 return false;
6212             }
6213             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6214                 return false;
6215             }
6216             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6217                 return false;
6218             }
6219             if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6220                 return false;
6221             }
6222             if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6223                 return false;
6224             }
6225             if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6226                 return false;
6227             }
6228             if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6229                 return false;
6230             }
6231             if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6232                 return false;
6233             }
6234             if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6235                 return false;
6236             }
6237             //
6238             //
6239             final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6240             final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6241             ext.clear();
6242             t6.getNode( "ab" ).setCollapse( true );
6243             n = t6.getNode( "ab" );
6244             while ( n != null ) {
6245                 ext.add( n );
6246                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6247             }
6248             if ( ext.size() != 7 ) {
6249                 return false;
6250             }
6251             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6252                 return false;
6253             }
6254             if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6255                 return false;
6256             }
6257             if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6258                 return false;
6259             }
6260             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6261                 return false;
6262             }
6263             if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6264                 return false;
6265             }
6266             if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6267                 return false;
6268             }
6269             if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6270                 return false;
6271             }
6272             //
6273             //
6274             final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6275             final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6276             ext.clear();
6277             t7.getNode( "cd" ).setCollapse( true );
6278             n = t7.getNode( "a" );
6279             while ( n != null ) {
6280                 ext.add( n );
6281                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6282             }
6283             if ( ext.size() != 7 ) {
6284                 return false;
6285             }
6286             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6287                 return false;
6288             }
6289             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6290                 return false;
6291             }
6292             if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6293                 return false;
6294             }
6295             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6296                 return false;
6297             }
6298             if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6299                 return false;
6300             }
6301             if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6302                 return false;
6303             }
6304             if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6305                 return false;
6306             }
6307             //
6308             //
6309             final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6310             final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6311             ext.clear();
6312             t8.getNode( "cd" ).setCollapse( true );
6313             t8.getNode( "c" ).setCollapse( true );
6314             t8.getNode( "d" ).setCollapse( true );
6315             n = t8.getNode( "a" );
6316             while ( n != null ) {
6317                 ext.add( n );
6318                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6319             }
6320             if ( ext.size() != 7 ) {
6321                 return false;
6322             }
6323             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6324                 return false;
6325             }
6326             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6327                 return false;
6328             }
6329             if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6330                 System.out.println( "2 fail" );
6331                 return false;
6332             }
6333             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6334                 return false;
6335             }
6336             if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6337                 return false;
6338             }
6339             if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6340                 return false;
6341             }
6342             if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6343                 return false;
6344             }
6345             //
6346             //
6347             final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6348             final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6349             ext.clear();
6350             t9.getNode( "gh" ).setCollapse( true );
6351             n = t9.getNode( "a" );
6352             while ( n != null ) {
6353                 ext.add( n );
6354                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6355             }
6356             if ( ext.size() != 7 ) {
6357                 return false;
6358             }
6359             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6360                 return false;
6361             }
6362             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6363                 return false;
6364             }
6365             if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6366                 return false;
6367             }
6368             if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6369                 return false;
6370             }
6371             if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6372                 return false;
6373             }
6374             if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6375                 return false;
6376             }
6377             if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6378                 return false;
6379             }
6380             //
6381             //
6382             final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6383             final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6384             ext.clear();
6385             t10.getNode( "gh" ).setCollapse( true );
6386             t10.getNode( "g" ).setCollapse( true );
6387             t10.getNode( "h" ).setCollapse( true );
6388             n = t10.getNode( "a" );
6389             while ( n != null ) {
6390                 ext.add( n );
6391                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6392             }
6393             if ( ext.size() != 7 ) {
6394                 return false;
6395             }
6396             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6397                 return false;
6398             }
6399             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6400                 return false;
6401             }
6402             if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6403                 return false;
6404             }
6405             if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6406                 return false;
6407             }
6408             if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6409                 return false;
6410             }
6411             if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6412                 return false;
6413             }
6414             if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6415                 return false;
6416             }
6417             //
6418             //
6419             final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6420             final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6421             ext.clear();
6422             t11.getNode( "gh" ).setCollapse( true );
6423             t11.getNode( "fgh" ).setCollapse( true );
6424             n = t11.getNode( "a" );
6425             while ( n != null ) {
6426                 ext.add( n );
6427                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6428             }
6429             if ( ext.size() != 6 ) {
6430                 return false;
6431             }
6432             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6433                 return false;
6434             }
6435             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6436                 return false;
6437             }
6438             if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6439                 return false;
6440             }
6441             if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6442                 return false;
6443             }
6444             if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6445                 return false;
6446             }
6447             if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6448                 return false;
6449             }
6450             //
6451             //
6452             final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6453             final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6454             ext.clear();
6455             t12.getNode( "gh" ).setCollapse( true );
6456             t12.getNode( "fgh" ).setCollapse( true );
6457             t12.getNode( "g" ).setCollapse( true );
6458             t12.getNode( "h" ).setCollapse( true );
6459             t12.getNode( "f" ).setCollapse( true );
6460             n = t12.getNode( "a" );
6461             while ( n != null ) {
6462                 ext.add( n );
6463                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6464             }
6465             if ( ext.size() != 6 ) {
6466                 return false;
6467             }
6468             if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6469                 return false;
6470             }
6471             if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6472                 return false;
6473             }
6474             if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6475                 return false;
6476             }
6477             if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6478                 return false;
6479             }
6480             if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6481                 return false;
6482             }
6483             if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6484                 return false;
6485             }
6486             //
6487             //
6488             final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6489             final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6490             ext.clear();
6491             t13.getNode( "ab" ).setCollapse( true );
6492             t13.getNode( "b" ).setCollapse( true );
6493             t13.getNode( "fgh" ).setCollapse( true );
6494             t13.getNode( "gh" ).setCollapse( true );
6495             n = t13.getNode( "ab" );
6496             while ( n != null ) {
6497                 ext.add( n );
6498                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6499             }
6500             if ( ext.size() != 5 ) {
6501                 return false;
6502             }
6503             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6504                 return false;
6505             }
6506             if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6507                 return false;
6508             }
6509             if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6510                 return false;
6511             }
6512             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6513                 return false;
6514             }
6515             if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6516                 return false;
6517             }
6518             //
6519             //
6520             final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6521             final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6522             ext.clear();
6523             t14.getNode( "ab" ).setCollapse( true );
6524             t14.getNode( "a" ).setCollapse( true );
6525             t14.getNode( "fgh" ).setCollapse( true );
6526             t14.getNode( "gh" ).setCollapse( true );
6527             n = t14.getNode( "ab" );
6528             while ( n != null ) {
6529                 ext.add( n );
6530                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6531             }
6532             if ( ext.size() != 5 ) {
6533                 return false;
6534             }
6535             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6536                 return false;
6537             }
6538             if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6539                 return false;
6540             }
6541             if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6542                 return false;
6543             }
6544             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6545                 return false;
6546             }
6547             if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6548                 return false;
6549             }
6550             //
6551             //
6552             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" );
6553             final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6554             ext.clear();
6555             t15.getNode( "ab" ).setCollapse( true );
6556             t15.getNode( "a" ).setCollapse( true );
6557             t15.getNode( "fgh" ).setCollapse( true );
6558             t15.getNode( "gh" ).setCollapse( true );
6559             n = t15.getNode( "ab" );
6560             while ( n != null ) {
6561                 ext.add( n );
6562                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6563             }
6564             if ( ext.size() != 6 ) {
6565                 return false;
6566             }
6567             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6568                 return false;
6569             }
6570             if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6571                 return false;
6572             }
6573             if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6574                 return false;
6575             }
6576             if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6577                 return false;
6578             }
6579             if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6580                 return false;
6581             }
6582             if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6583                 return false;
6584             }
6585             //
6586             //
6587             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" );
6588             final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6589             ext.clear();
6590             t16.getNode( "ab" ).setCollapse( true );
6591             t16.getNode( "a" ).setCollapse( true );
6592             t16.getNode( "fgh" ).setCollapse( true );
6593             t16.getNode( "gh" ).setCollapse( true );
6594             t16.getNode( "cd" ).setCollapse( true );
6595             t16.getNode( "cde" ).setCollapse( true );
6596             t16.getNode( "d" ).setCollapse( true );
6597             t16.getNode( "x" ).setCollapse( true );
6598             n = t16.getNode( "ab" );
6599             while ( n != null ) {
6600                 ext.add( n );
6601                 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6602             }
6603             if ( ext.size() != 4 ) {
6604                 return false;
6605             }
6606             if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6607                 return false;
6608             }
6609             if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6610                 return false;
6611             }
6612             if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6613                 return false;
6614             }
6615             if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6616                 return false;
6617             }
6618         }
6619         catch ( final Exception e ) {
6620             e.printStackTrace( System.out );
6621             return false;
6622         }
6623         return true;
6624     }
6625
6626     private static boolean testNexusCharactersParsing() {
6627         try {
6628             final NexusCharactersParser parser = new NexusCharactersParser();
6629             parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6630             parser.parse();
6631             String[] labels = parser.getCharStateLabels();
6632             if ( labels.length != 7 ) {
6633                 return false;
6634             }
6635             if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6636                 return false;
6637             }
6638             if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6639                 return false;
6640             }
6641             if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6642                 return false;
6643             }
6644             if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6645                 return false;
6646             }
6647             if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6648                 return false;
6649             }
6650             if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6651                 return false;
6652             }
6653             if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6654                 return false;
6655             }
6656             parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6657             parser.parse();
6658             labels = parser.getCharStateLabels();
6659             if ( labels.length != 7 ) {
6660                 return false;
6661             }
6662             if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6663                 return false;
6664             }
6665             if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6666                 return false;
6667             }
6668             if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6669                 return false;
6670             }
6671             if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6672                 return false;
6673             }
6674             if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6675                 return false;
6676             }
6677             if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6678                 return false;
6679             }
6680             if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6681                 return false;
6682             }
6683         }
6684         catch ( final Exception e ) {
6685             e.printStackTrace( System.out );
6686             return false;
6687         }
6688         return true;
6689     }
6690
6691     private static boolean testNexusMatrixParsing() {
6692         try {
6693             final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6694             parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6695             parser.parse();
6696             final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6697             if ( m.getNumberOfCharacters() != 9 ) {
6698                 return false;
6699             }
6700             if ( m.getNumberOfIdentifiers() != 5 ) {
6701                 return false;
6702             }
6703             if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6704                 return false;
6705             }
6706             if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6707                 return false;
6708             }
6709             if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6710                 return false;
6711             }
6712             if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6713                 return false;
6714             }
6715             if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6716                 return false;
6717             }
6718             if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6719                 return false;
6720             }
6721             if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6722                 return false;
6723             }
6724             //            if ( labels.length != 7 ) {
6725             //                return false;
6726             //            }
6727             //            if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6728             //                return false;
6729             //            }
6730             //            if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6731             //                return false;
6732             //            }
6733             //            if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6734             //                return false;
6735             //            }
6736             //            if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6737             //                return false;
6738             //            }
6739             //            if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6740             //                return false;
6741             //            }
6742             //            if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6743             //                return false;
6744             //            }
6745             //            if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6746             //                return false;
6747             //            }
6748             //            parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6749             //            parser.parse();
6750             //            labels = parser.getCharStateLabels();
6751             //            if ( labels.length != 7 ) {
6752             //                return false;
6753             //            }
6754             //            if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6755             //                return false;
6756             //            }
6757             //            if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6758             //                return false;
6759             //            }
6760             //            if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6761             //                return false;
6762             //            }
6763             //            if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6764             //                return false;
6765             //            }
6766             //            if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6767             //                return false;
6768             //            }
6769             //            if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6770             //                return false;
6771             //            }
6772             //            if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6773             //                return false;
6774             //            }
6775         }
6776         catch ( final Exception e ) {
6777             e.printStackTrace( System.out );
6778             return false;
6779         }
6780         return true;
6781     }
6782
6783     private static boolean testNexusTreeParsing() {
6784         try {
6785             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6786             final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6787             Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6788             if ( phylogenies.length != 1 ) {
6789                 return false;
6790             }
6791             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6792                 return false;
6793             }
6794             if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6795                 return false;
6796             }
6797             phylogenies = null;
6798             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6799             if ( phylogenies.length != 1 ) {
6800                 return false;
6801             }
6802             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6803                 return false;
6804             }
6805             if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6806                 return false;
6807             }
6808             phylogenies = null;
6809             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6810             if ( phylogenies.length != 1 ) {
6811                 return false;
6812             }
6813             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6814                 return false;
6815             }
6816             if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6817                 return false;
6818             }
6819             if ( phylogenies[ 0 ].isRooted() ) {
6820                 return false;
6821             }
6822             phylogenies = null;
6823             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6824             if ( phylogenies.length != 18 ) {
6825                 return false;
6826             }
6827             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6828                 return false;
6829             }
6830             if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6831                 return false;
6832             }
6833             if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6834                 return false;
6835             }
6836             if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6837                 return false;
6838             }
6839             if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6840                 return false;
6841             }
6842             if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6843                 return false;
6844             }
6845             if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6846                 return false;
6847             }
6848             if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6849                 return false;
6850             }
6851             if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6852                 return false;
6853             }
6854             if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6855                 return false;
6856             }
6857             if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6858                 return false;
6859             }
6860             if ( phylogenies[ 8 ].isRooted() ) {
6861                 return false;
6862             }
6863             if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6864                 return false;
6865             }
6866             if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6867                 return false;
6868             }
6869             if ( !phylogenies[ 9 ].isRooted() ) {
6870                 return false;
6871             }
6872             if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6873                 return false;
6874             }
6875             if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6876                 return false;
6877             }
6878             if ( !phylogenies[ 10 ].isRooted() ) {
6879                 return false;
6880             }
6881             if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6882                 return false;
6883             }
6884             if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6885                 return false;
6886             }
6887             if ( phylogenies[ 11 ].isRooted() ) {
6888                 return false;
6889             }
6890             if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6891                 return false;
6892             }
6893             if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6894                 return false;
6895             }
6896             if ( !phylogenies[ 12 ].isRooted() ) {
6897                 return false;
6898             }
6899             if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6900                 return false;
6901             }
6902             if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6903                 return false;
6904             }
6905             if ( !phylogenies[ 13 ].isRooted() ) {
6906                 return false;
6907             }
6908             if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6909                 return false;
6910             }
6911             if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6912                 return false;
6913             }
6914             if ( !phylogenies[ 14 ].isRooted() ) {
6915                 return false;
6916             }
6917             if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6918                 return false;
6919             }
6920             if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6921                 return false;
6922             }
6923             if ( phylogenies[ 15 ].isRooted() ) {
6924                 return false;
6925             }
6926             if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6927                 return false;
6928             }
6929             if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6930                 return false;
6931             }
6932             if ( !phylogenies[ 16 ].isRooted() ) {
6933                 return false;
6934             }
6935             if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6936                 return false;
6937             }
6938             if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6939                 return false;
6940             }
6941             if ( phylogenies[ 17 ].isRooted() ) {
6942                 return false;
6943             }
6944             if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6945                 return false;
6946             }
6947             final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
6948             phylogenies = null;
6949             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
6950             if ( phylogenies.length != 9 ) {
6951                 return false;
6952             }
6953             if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
6954                     .getDistanceToParent() ) ) {
6955                 return false;
6956             }
6957             if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
6958                     .getDistanceToParent() ) ) {
6959                 return false;
6960             }
6961             if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
6962                 return false;
6963             }
6964             if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6965                 return false;
6966             }
6967             if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6968                 return false;
6969             }
6970             if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6971                 return false;
6972             }
6973             if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6974                 return false;
6975             }
6976         }
6977         catch ( final Exception e ) {
6978             e.printStackTrace( System.out );
6979             return false;
6980         }
6981         return true;
6982     }
6983
6984     private static boolean testNexusTreeParsingIterating() {
6985         try {
6986             final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6987             p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6988             if ( !p.hasNext() ) {
6989                 return false;
6990             }
6991             Phylogeny phy = p.next();
6992             if ( phy == null ) {
6993                 return false;
6994             }
6995             if ( phy.getNumberOfExternalNodes() != 25 ) {
6996                 return false;
6997             }
6998             if ( !phy.getName().equals( "" ) ) {
6999                 return false;
7000             }
7001             if ( p.hasNext() ) {
7002                 return false;
7003             }
7004             phy = p.next();
7005             if ( phy != null ) {
7006                 return false;
7007             }
7008             //
7009             p.reset();
7010             if ( !p.hasNext() ) {
7011                 return false;
7012             }
7013             phy = p.next();
7014             if ( phy == null ) {
7015                 return false;
7016             }
7017             if ( phy.getNumberOfExternalNodes() != 25 ) {
7018                 return false;
7019             }
7020             if ( !phy.getName().equals( "" ) ) {
7021                 return false;
7022             }
7023             if ( p.hasNext() ) {
7024                 return false;
7025             }
7026             phy = p.next();
7027             if ( phy != null ) {
7028                 return false;
7029             }
7030             ////
7031             p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7032             if ( !p.hasNext() ) {
7033                 return false;
7034             }
7035             phy = p.next();
7036             if ( phy == null ) {
7037                 return false;
7038             }
7039             if ( phy.getNumberOfExternalNodes() != 10 ) {
7040                 return false;
7041             }
7042             if ( !phy.getName().equals( "name" ) ) {
7043                 return false;
7044             }
7045             if ( p.hasNext() ) {
7046                 return false;
7047             }
7048             phy = p.next();
7049             if ( phy != null ) {
7050                 return false;
7051             }
7052             //
7053             p.reset();
7054             if ( !p.hasNext() ) {
7055                 return false;
7056             }
7057             phy = p.next();
7058             if ( phy == null ) {
7059                 return false;
7060             }
7061             if ( phy.getNumberOfExternalNodes() != 10 ) {
7062                 return false;
7063             }
7064             if ( !phy.getName().equals( "name" ) ) {
7065                 return false;
7066             }
7067             if ( p.hasNext() ) {
7068                 return false;
7069             }
7070             phy = p.next();
7071             if ( phy != null ) {
7072                 return false;
7073             }
7074             //
7075             p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7076             if ( !p.hasNext() ) {
7077                 return false;
7078             }
7079             phy = p.next();
7080             if ( phy == null ) {
7081                 return false;
7082             }
7083             if ( phy.getNumberOfExternalNodes() != 3 ) {
7084                 return false;
7085             }
7086             if ( !phy.getName().equals( "" ) ) {
7087                 return false;
7088             }
7089             if ( phy.isRooted() ) {
7090                 return false;
7091             }
7092             if ( p.hasNext() ) {
7093                 return false;
7094             }
7095             phy = p.next();
7096             if ( phy != null ) {
7097                 return false;
7098             }
7099             //
7100             p.reset();
7101             if ( !p.hasNext() ) {
7102                 return false;
7103             }
7104             phy = p.next();
7105             if ( phy == null ) {
7106                 return false;
7107             }
7108             if ( phy.getNumberOfExternalNodes() != 3 ) {
7109                 return false;
7110             }
7111             if ( !phy.getName().equals( "" ) ) {
7112                 return false;
7113             }
7114             if ( p.hasNext() ) {
7115                 return false;
7116             }
7117             phy = p.next();
7118             if ( phy != null ) {
7119                 return false;
7120             }
7121             //
7122             p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7123             if ( !p.hasNext() ) {
7124                 return false;
7125             }
7126             //0
7127             phy = p.next();
7128             if ( phy == null ) {
7129                 return false;
7130             }
7131             if ( phy.getNumberOfExternalNodes() != 10 ) {
7132                 return false;
7133             }
7134             if ( !phy.getName().equals( "tree 0" ) ) {
7135                 return false;
7136             }
7137             //1
7138             if ( !p.hasNext() ) {
7139                 return false;
7140             }
7141             phy = p.next();
7142             if ( phy == null ) {
7143                 return false;
7144             }
7145             if ( phy.getNumberOfExternalNodes() != 10 ) {
7146                 return false;
7147             }
7148             if ( !phy.getName().equals( "tree 1" ) ) {
7149                 return false;
7150             }
7151             //2
7152             if ( !p.hasNext() ) {
7153                 return false;
7154             }
7155             phy = p.next();
7156             if ( phy == null ) {
7157                 return false;
7158             }
7159             if ( phy.getNumberOfExternalNodes() != 3 ) {
7160                 System.out.println( phy.toString() );
7161                 return false;
7162             }
7163             if ( !phy.getName().equals( "" ) ) {
7164                 return false;
7165             }
7166             if ( phy.isRooted() ) {
7167                 return false;
7168             }
7169             //3
7170             if ( !p.hasNext() ) {
7171                 return false;
7172             }
7173             phy = p.next();
7174             if ( phy == null ) {
7175                 return false;
7176             }
7177             if ( phy.getNumberOfExternalNodes() != 4 ) {
7178                 return false;
7179             }
7180             if ( !phy.getName().equals( "" ) ) {
7181                 return false;
7182             }
7183             if ( !phy.isRooted() ) {
7184                 return false;
7185             }
7186             //4
7187             if ( !p.hasNext() ) {
7188                 return false;
7189             }
7190             phy = p.next();
7191             if ( phy == null ) {
7192                 return false;
7193             }
7194             if ( phy.getNumberOfExternalNodes() != 5 ) {
7195                 System.out.println( phy.getNumberOfExternalNodes() );
7196                 return false;
7197             }
7198             if ( !phy.getName().equals( "" ) ) {
7199                 return false;
7200             }
7201             if ( !phy.isRooted() ) {
7202                 return false;
7203             }
7204             //5
7205             if ( !p.hasNext() ) {
7206                 return false;
7207             }
7208             phy = p.next();
7209             if ( phy == null ) {
7210                 return false;
7211             }
7212             if ( phy.getNumberOfExternalNodes() != 3 ) {
7213                 return false;
7214             }
7215             if ( !phy.getName().equals( "" ) ) {
7216                 return false;
7217             }
7218             if ( phy.isRooted() ) {
7219                 return false;
7220             }
7221             //6
7222             if ( !p.hasNext() ) {
7223                 return false;
7224             }
7225             phy = p.next();
7226             if ( phy == null ) {
7227                 return false;
7228             }
7229             if ( phy.getNumberOfExternalNodes() != 2 ) {
7230                 return false;
7231             }
7232             if ( !phy.getName().equals( "" ) ) {
7233                 return false;
7234             }
7235             if ( !phy.isRooted() ) {
7236                 return false;
7237             }
7238             //7
7239             if ( !p.hasNext() ) {
7240                 return false;
7241             }
7242             phy = p.next();
7243             if ( phy.getNumberOfExternalNodes() != 3 ) {
7244                 return false;
7245             }
7246             if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7247                 return false;
7248             }
7249             if ( !phy.isRooted() ) {
7250                 return false;
7251             }
7252             //8
7253             if ( !p.hasNext() ) {
7254                 return false;
7255             }
7256             phy = p.next();
7257             if ( phy.getNumberOfExternalNodes() != 3 ) {
7258                 return false;
7259             }
7260             if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7261                 return false;
7262             }
7263             if ( !phy.getName().equals( "tree 8" ) ) {
7264                 return false;
7265             }
7266             //9
7267             if ( !p.hasNext() ) {
7268                 return false;
7269             }
7270             phy = p.next();
7271             if ( phy.getNumberOfExternalNodes() != 3 ) {
7272                 return false;
7273             }
7274             if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7275                 return false;
7276             }
7277             if ( !phy.getName().equals( "tree 9" ) ) {
7278                 return false;
7279             }
7280             //10
7281             if ( !p.hasNext() ) {
7282                 return false;
7283             }
7284             phy = p.next();
7285             if ( phy.getNumberOfExternalNodes() != 3 ) {
7286                 return false;
7287             }
7288             if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7289                 return false;
7290             }
7291             if ( !phy.getName().equals( "tree 10" ) ) {
7292                 return false;
7293             }
7294             if ( !phy.isRooted() ) {
7295                 return false;
7296             }
7297             //11
7298             if ( !p.hasNext() ) {
7299                 return false;
7300             }
7301             phy = p.next();
7302             if ( phy.getNumberOfExternalNodes() != 3 ) {
7303                 return false;
7304             }
7305             if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7306                 return false;
7307             }
7308             if ( !phy.getName().equals( "tree 11" ) ) {
7309                 return false;
7310             }
7311             if ( phy.isRooted() ) {
7312                 return false;
7313             }
7314             //12
7315             if ( !p.hasNext() ) {
7316                 return false;
7317             }
7318             phy = p.next();
7319             if ( phy.getNumberOfExternalNodes() != 3 ) {
7320                 return false;
7321             }
7322             if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7323                 return false;
7324             }
7325             if ( !phy.getName().equals( "tree 12" ) ) {
7326                 return false;
7327             }
7328             if ( !phy.isRooted() ) {
7329                 return false;
7330             }
7331             //13
7332             if ( !p.hasNext() ) {
7333                 return false;
7334             }
7335             phy = p.next();
7336             if ( phy.getNumberOfExternalNodes() != 3 ) {
7337                 return false;
7338             }
7339             if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7340                 return false;
7341             }
7342             if ( !phy.getName().equals( "tree 13" ) ) {
7343                 return false;
7344             }
7345             if ( !phy.isRooted() ) {
7346                 return false;
7347             }
7348             //14
7349             if ( !p.hasNext() ) {
7350                 return false;
7351             }
7352             phy = p.next();
7353             if ( phy.getNumberOfExternalNodes() != 10 ) {
7354                 System.out.println( phy.getNumberOfExternalNodes() );
7355                 return false;
7356             }
7357             if ( !phy
7358                     .toNewHampshire()
7359                     .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;" ) ) {
7360                 System.out.println( phy.toNewHampshire() );
7361                 return false;
7362             }
7363             if ( !phy.getName().equals( "tree 14" ) ) {
7364                 return false;
7365             }
7366             if ( !phy.isRooted() ) {
7367                 return false;
7368             }
7369             //15
7370             if ( !p.hasNext() ) {
7371                 return false;
7372             }
7373             phy = p.next();
7374             if ( phy.getNumberOfExternalNodes() != 10 ) {
7375                 System.out.println( phy.getNumberOfExternalNodes() );
7376                 return false;
7377             }
7378             if ( !phy
7379                     .toNewHampshire()
7380                     .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;" ) ) {
7381                 System.out.println( phy.toNewHampshire() );
7382                 return false;
7383             }
7384             if ( !phy.getName().equals( "tree 15" ) ) {
7385                 return false;
7386             }
7387             if ( phy.isRooted() ) {
7388                 return false;
7389             }
7390             //16
7391             if ( !p.hasNext() ) {
7392                 return false;
7393             }
7394             phy = p.next();
7395             if ( phy.getNumberOfExternalNodes() != 10 ) {
7396                 System.out.println( phy.getNumberOfExternalNodes() );
7397                 return false;
7398             }
7399             if ( !phy
7400                     .toNewHampshire()
7401                     .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;" ) ) {
7402                 System.out.println( phy.toNewHampshire() );
7403                 return false;
7404             }
7405             if ( !phy.getName().equals( "tree 16" ) ) {
7406                 return false;
7407             }
7408             if ( !phy.isRooted() ) {
7409                 return false;
7410             }
7411             //17
7412             if ( !p.hasNext() ) {
7413                 return false;
7414             }
7415             phy = p.next();
7416             if ( phy.getNumberOfExternalNodes() != 10 ) {
7417                 System.out.println( phy.getNumberOfExternalNodes() );
7418                 return false;
7419             }
7420             if ( !phy
7421                     .toNewHampshire()
7422                     .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;" ) ) {
7423                 System.out.println( phy.toNewHampshire() );
7424                 return false;
7425             }
7426             if ( !phy.getName().equals( "tree 17" ) ) {
7427                 return false;
7428             }
7429             if ( phy.isRooted() ) {
7430                 return false;
7431             }
7432             //
7433             if ( p.hasNext() ) {
7434                 return false;
7435             }
7436             phy = p.next();
7437             if ( phy != null ) {
7438                 return false;
7439             }
7440             p.reset();
7441             //0
7442             if ( !p.hasNext() ) {
7443                 return false;
7444             }
7445             phy = p.next();
7446             if ( phy == null ) {
7447                 return false;
7448             }
7449             if ( phy.getNumberOfExternalNodes() != 10 ) {
7450                 return false;
7451             }
7452             if ( !phy.getName().equals( "tree 0" ) ) {
7453                 return false;
7454             }
7455             //1
7456             if ( !p.hasNext() ) {
7457                 return false;
7458             }
7459             phy = p.next();
7460             if ( phy == null ) {
7461                 return false;
7462             }
7463             if ( phy.getNumberOfExternalNodes() != 10 ) {
7464                 return false;
7465             }
7466             if ( !phy.getName().equals( "tree 1" ) ) {
7467                 return false;
7468             }
7469             //2
7470             if ( !p.hasNext() ) {
7471                 return false;
7472             }
7473             phy = p.next();
7474             if ( phy == null ) {
7475                 return false;
7476             }
7477             if ( phy.getNumberOfExternalNodes() != 3 ) {
7478                 return false;
7479             }
7480             if ( !phy.getName().equals( "" ) ) {
7481                 return false;
7482             }
7483             if ( phy.isRooted() ) {
7484                 return false;
7485             }
7486             //3
7487             if ( !p.hasNext() ) {
7488                 return false;
7489             }
7490             phy = p.next();
7491             if ( phy == null ) {
7492                 return false;
7493             }
7494             if ( phy.getNumberOfExternalNodes() != 4 ) {
7495                 return false;
7496             }
7497             if ( !phy.getName().equals( "" ) ) {
7498                 return false;
7499             }
7500             if ( !phy.isRooted() ) {
7501                 return false;
7502             }
7503             //4
7504             if ( !p.hasNext() ) {
7505                 return false;
7506             }
7507             phy = p.next();
7508             if ( phy == null ) {
7509                 return false;
7510             }
7511             if ( phy.getNumberOfExternalNodes() != 5 ) {
7512                 System.out.println( phy.getNumberOfExternalNodes() );
7513                 return false;
7514             }
7515             if ( !phy.getName().equals( "" ) ) {
7516                 return false;
7517             }
7518             if ( !phy.isRooted() ) {
7519                 return false;
7520             }
7521             //5
7522             if ( !p.hasNext() ) {
7523                 return false;
7524             }
7525             phy = p.next();
7526             if ( phy == null ) {
7527                 return false;
7528             }
7529             if ( phy.getNumberOfExternalNodes() != 3 ) {
7530                 return false;
7531             }
7532             if ( !phy.getName().equals( "" ) ) {
7533                 return false;
7534             }
7535             if ( phy.isRooted() ) {
7536                 return false;
7537             }
7538             //
7539             final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7540             p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7541             // 0
7542             if ( !p2.hasNext() ) {
7543                 return false;
7544             }
7545             phy = p2.next();
7546             if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7547                 return false;
7548             }
7549             if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7550                 return false;
7551             }
7552             // 1
7553             if ( !p2.hasNext() ) {
7554                 return false;
7555             }
7556             phy = p2.next();
7557             // 2
7558             if ( !p2.hasNext() ) {
7559                 return false;
7560             }
7561             phy = p2.next();
7562             // 3
7563             if ( !p2.hasNext() ) {
7564                 return false;
7565             }
7566             phy = p2.next();
7567             // 4
7568             if ( !p2.hasNext() ) {
7569                 return false;
7570             }
7571             phy = p2.next();
7572             // 5
7573             if ( !p2.hasNext() ) {
7574                 return false;
7575             }
7576             phy = p2.next();
7577             // 6
7578             if ( !p2.hasNext() ) {
7579                 return false;
7580             }
7581             phy = p2.next();
7582             // 7
7583             if ( !p2.hasNext() ) {
7584                 return false;
7585             }
7586             phy = p2.next();
7587             // 8
7588             if ( !p2.hasNext() ) {
7589                 return false;
7590             }
7591             phy = p2.next();
7592             if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7593                 return false;
7594             }
7595             if ( p2.hasNext() ) {
7596                 return false;
7597             }
7598             phy = p2.next();
7599             if ( phy != null ) {
7600                 return false;
7601             }
7602             // 0
7603             p2.reset();
7604             if ( !p2.hasNext() ) {
7605                 return false;
7606             }
7607             phy = p2.next();
7608             if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7609                 return false;
7610             }
7611             if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7612                 return false;
7613             }
7614         }
7615         catch ( final Exception e ) {
7616             e.printStackTrace( System.out );
7617             return false;
7618         }
7619         return true;
7620     }
7621
7622     private static boolean testNexusTreeParsingTranslating() {
7623         try {
7624             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7625             final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7626             Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7627             if ( phylogenies.length != 1 ) {
7628                 return false;
7629             }
7630             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7631                 return false;
7632             }
7633             if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7634                 return false;
7635             }
7636             if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7637                 return false;
7638             }
7639             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7640                 return false;
7641             }
7642             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7643                     .equals( "Aranaeus" ) ) {
7644                 return false;
7645             }
7646             phylogenies = null;
7647             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7648             if ( phylogenies.length != 3 ) {
7649                 return false;
7650             }
7651             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7652                 return false;
7653             }
7654             if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7655                 return false;
7656             }
7657             if ( phylogenies[ 0 ].isRooted() ) {
7658                 return false;
7659             }
7660             if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7661                 return false;
7662             }
7663             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7664                 return false;
7665             }
7666             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7667                     .equals( "Aranaeus" ) ) {
7668                 return false;
7669             }
7670             if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7671                 return false;
7672             }
7673             if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7674                 return false;
7675             }
7676             if ( phylogenies[ 1 ].isRooted() ) {
7677                 return false;
7678             }
7679             if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7680                 return false;
7681             }
7682             if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7683                 return false;
7684             }
7685             if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7686                     .equals( "Aranaeus" ) ) {
7687                 return false;
7688             }
7689             if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7690                 return false;
7691             }
7692             if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7693                 return false;
7694             }
7695             if ( !phylogenies[ 2 ].isRooted() ) {
7696                 return false;
7697             }
7698             if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7699                 return false;
7700             }
7701             if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7702                 return false;
7703             }
7704             if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7705                     .equals( "Aranaeus" ) ) {
7706                 return false;
7707             }
7708             phylogenies = null;
7709             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7710             if ( phylogenies.length != 3 ) {
7711                 return false;
7712             }
7713             if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7714                 return false;
7715             }
7716             if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7717                 return false;
7718             }
7719             if ( phylogenies[ 0 ].isRooted() ) {
7720                 return false;
7721             }
7722             if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7723                 return false;
7724             }
7725             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7726                 return false;
7727             }
7728             if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7729                     .equals( "Aranaeus" ) ) {
7730                 return false;
7731             }
7732             if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7733                 return false;
7734             }
7735             if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7736                 return false;
7737             }
7738             if ( phylogenies[ 1 ].isRooted() ) {
7739                 return false;
7740             }
7741             if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7742                 return false;
7743             }
7744             if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7745                 return false;
7746             }
7747             if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7748                     .equals( "Aranaeus" ) ) {
7749                 return false;
7750             }
7751             if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7752                 return false;
7753             }
7754             if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7755                 return false;
7756             }
7757             if ( !phylogenies[ 2 ].isRooted() ) {
7758                 return false;
7759             }
7760             if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7761                 return false;
7762             }
7763             if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7764                 return false;
7765             }
7766             if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7767                     .equals( "Aranaeus" ) ) {
7768                 return false;
7769             }
7770             phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7771             if ( phylogenies.length != 3 ) {
7772                 return false;
7773             }
7774             if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7775                            0.00100049 ) ) {
7776                 return false;
7777             }
7778         }
7779         catch ( final Exception e ) {
7780             e.printStackTrace( System.out );
7781             return false;
7782         }
7783         return true;
7784     }
7785
7786     private static boolean testNHParsing() {
7787         try {
7788             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7789             final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7790             if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7791                 return false;
7792             }
7793             final NHXParser nhxp = new NHXParser();
7794             nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7795             nhxp.setReplaceUnderscores( true );
7796             final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7797             if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7798                 return false;
7799             }
7800             if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7801                 return false;
7802             }
7803             final Phylogeny p1b = factory
7804                     .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 ",
7805                              new NHXParser() )[ 0 ];
7806             if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7807                 return false;
7808             }
7809             if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7810                 return false;
7811             }
7812             final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7813             final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7814             final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7815             final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7816             final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7817             final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7818             final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7819             final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7820             final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7821             final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7822             final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1  3 ; \n)\t ( \n ;"
7823                                                             + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7824                                                             + "; ; ( \t\n\r\b; G ;, ;H ;1 3; )  ;  ;   ;",
7825                                                     new NHXParser() );
7826             if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7827                 return false;
7828             }
7829             if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7830                 return false;
7831             }
7832             if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7833                 return false;
7834             }
7835             if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7836                 return false;
7837             }
7838             final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7839             final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7840             final String p16_S = "((A,B),C)";
7841             final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7842             if ( p16.length != 1 ) {
7843                 return false;
7844             }
7845             if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7846                 return false;
7847             }
7848             final String p17_S = "(C,(A,B))";
7849             final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7850             if ( p17.length != 1 ) {
7851                 return false;
7852             }
7853             if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7854                 return false;
7855             }
7856             final String p18_S = "((A,B),(C,D))";
7857             final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7858             if ( p18.length != 1 ) {
7859                 return false;
7860             }
7861             if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7862                 return false;
7863             }
7864             final String p19_S = "(((A,B),C),D)";
7865             final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7866             if ( p19.length != 1 ) {
7867                 return false;
7868             }
7869             if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7870                 return false;
7871             }
7872             final String p20_S = "(A,(B,(C,D)))";
7873             final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7874             if ( p20.length != 1 ) {
7875                 return false;
7876             }
7877             if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7878                 return false;
7879             }
7880             final String p21_S = "(A,(B,(C,(D,E))))";
7881             final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7882             if ( p21.length != 1 ) {
7883                 return false;
7884             }
7885             if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7886                 return false;
7887             }
7888             final String p22_S = "((((A,B),C),D),E)";
7889             final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7890             if ( p22.length != 1 ) {
7891                 return false;
7892             }
7893             if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7894                 return false;
7895             }
7896             final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7897             final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7898             if ( p23.length != 1 ) {
7899                 System.out.println( "xl=" + p23.length );
7900                 System.exit( -1 );
7901                 return false;
7902             }
7903             if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7904                 return false;
7905             }
7906             final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7907             final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7908             if ( p24.length != 1 ) {
7909                 return false;
7910             }
7911             if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7912                 return false;
7913             }
7914             final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7915             final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7916             final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7917             if ( p241.length != 2 ) {
7918                 return false;
7919             }
7920             if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7921                 return false;
7922             }
7923             if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7924                 return false;
7925             }
7926             final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7927                     + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7928                     + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7929                     + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7930                     + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7931                     + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7932                     + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7933                     + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7934             final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7935             if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7936                 return false;
7937             }
7938             final String p26_S = "(A,B)ab";
7939             final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7940             if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7941                 return false;
7942             }
7943             final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7944             final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7945             if ( p27s.length != 1 ) {
7946                 System.out.println( "xxl=" + p27s.length );
7947                 System.exit( -1 );
7948                 return false;
7949             }
7950             if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7951                 System.out.println( p27s[ 0 ].toNewHampshireX() );
7952                 System.exit( -1 );
7953                 return false;
7954             }
7955             final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7956                                                     new NHXParser() );
7957             if ( p27.length != 1 ) {
7958                 System.out.println( "yl=" + p27.length );
7959                 System.exit( -1 );
7960                 return false;
7961             }
7962             if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7963                 System.out.println( p27[ 0 ].toNewHampshireX() );
7964                 System.exit( -1 );
7965                 return false;
7966             }
7967             final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7968             final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7969             final String p28_S3 = "(A,B)ab";
7970             final String p28_S4 = "((((A,B),C),D),;E;)";
7971             final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7972                                                     new NHXParser() );
7973             if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7974                 return false;
7975             }
7976             if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7977                 return false;
7978             }
7979             if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7980                 return false;
7981             }
7982             if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7983                 return false;
7984             }
7985             if ( p28.length != 4 ) {
7986                 return false;
7987             }
7988             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";
7989             final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7990             if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7991                 return false;
7992             }
7993             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";
7994             final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7995             if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7996                 return false;
7997             }
7998             final String p32_S = " ;   ;        \n  \t  \b   \f  \r  ;;;;;; ";
7999             final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8000             if ( ( p32.length != 0 ) ) {
8001                 return false;
8002             }
8003             final String p33_S = "A";
8004             final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8005             if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8006                 return false;
8007             }
8008             final String p34_S = "B;";
8009             final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8010             if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8011                 return false;
8012             }
8013             final String p35_S = "B:0.2";
8014             final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8015             if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8016                 return false;
8017             }
8018             final String p36_S = "(A)";
8019             final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8020             if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8021                 return false;
8022             }
8023             final String p37_S = "((A))";
8024             final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8025             if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8026                 return false;
8027             }
8028             final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8029             final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8030             if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8031                 return false;
8032             }
8033             final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8034             final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8035             if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8036                 return false;
8037             }
8038             final String p40_S = "(A,B,C)";
8039             final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8040             if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8041                 return false;
8042             }
8043             final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8044             final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8045             if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8046                 return false;
8047             }
8048             final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8049             final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8050             if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8051                 return false;
8052             }
8053             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)";
8054             final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8055             if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8056                 return false;
8057             }
8058             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)))";
8059             final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8060             if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8061                 return false;
8062             }
8063             final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8064             final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8065             if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8066                 return false;
8067             }
8068             final String p46_S = "";
8069             final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8070             if ( p46.length != 0 ) {
8071                 return false;
8072             }
8073             final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8074             if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8075                 return false;
8076             }
8077             final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8078             if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8079                 return false;
8080             }
8081             final Phylogeny p49 = factory
8082                     .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8083                              new NHXParser() )[ 0 ];
8084             if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8085                 return false;
8086             }
8087             final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8088             if ( p50.getNode( "A" ) == null ) {
8089                 return false;
8090             }
8091             if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8092                     .equals( "((A,B)ab:2.0[88],C);" ) ) {
8093                 return false;
8094             }
8095             if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8096                 return false;
8097             }
8098             if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8099                     .equals( "((A,B)88:2.0,C);" ) ) {
8100                 return false;
8101             }
8102             final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8103             if ( p51.getNode( "A(A" ) == null ) {
8104                 return false;
8105             }
8106             final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8107             if ( p52.getNode( "A(A" ) == null ) {
8108                 return false;
8109             }
8110             final Phylogeny p53 = factory
8111                     .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8112                              new NHXParser() )[ 0 ];
8113             if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8114                 return false;
8115             }
8116             final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8117             if ( p54.getNode( "A" ) == null ) {
8118                 return false;
8119             }
8120             if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8121                 return false;
8122             }
8123             // 
8124             final Phylogeny p55 = factory
8125                     .create( new StringBuffer( "((\"lcl|HPV32_L1.:1  s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1x\":0.0798012);" ),
8126                              new NHXParser() )[ 0 ];
8127             if ( !p55
8128                     .toNewHampshire()
8129                     .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,lcl|HPV66_L1.1x:0.0798012);" ) ) {
8130                 System.out.println( p55.toNewHampshire() );
8131                 return false;
8132             }
8133             final Phylogeny p56 = factory
8134                     .create( new StringBuffer( "((\"lcl|HPV32_L1.:1      s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8135                              new NHXParser() )[ 0 ];
8136             if ( !p56
8137                     .toNewHampshire()
8138                     .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8139                 System.out.println( p56.toNewHampshire() );
8140                 return false;
8141             }
8142             final Phylogeny p57 = factory
8143                     .create( new StringBuffer( "((\"lcl|HPV32_L1.:1      s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8144                              new NHXParser() )[ 0 ];
8145             if ( !p57
8146                     .toNewHampshire()
8147                     .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8148                 System.out.println( p56.toNewHampshire() );
8149                 return false;
8150             }
8151         }
8152         catch ( final Exception e ) {
8153             e.printStackTrace( System.out );
8154             return false;
8155         }
8156         return true;
8157     }
8158
8159     private static boolean testNHParsingIter() {
8160         try {
8161             final String p0_str = "(A,B);";
8162             final NHXParser p = new NHXParser();
8163             p.setSource( p0_str );
8164             if ( !p.hasNext() ) {
8165                 return false;
8166             }
8167             final Phylogeny p0 = p.next();
8168             if ( !p0.toNewHampshire().equals( p0_str ) ) {
8169                 System.out.println( p0.toNewHampshire() );
8170                 return false;
8171             }
8172             if ( p.hasNext() ) {
8173                 return false;
8174             }
8175             if ( p.next() != null ) {
8176                 return false;
8177             }
8178             //
8179             final String p00_str = "(A,B)root;";
8180             p.setSource( p00_str );
8181             final Phylogeny p00 = p.next();
8182             if ( !p00.toNewHampshire().equals( p00_str ) ) {
8183                 System.out.println( p00.toNewHampshire() );
8184                 return false;
8185             }
8186             //
8187             final String p000_str = "A;";
8188             p.setSource( p000_str );
8189             final Phylogeny p000 = p.next();
8190             if ( !p000.toNewHampshire().equals( p000_str ) ) {
8191                 System.out.println( p000.toNewHampshire() );
8192                 return false;
8193             }
8194             //
8195             final String p0000_str = "A";
8196             p.setSource( p0000_str );
8197             final Phylogeny p0000 = p.next();
8198             if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8199                 System.out.println( p0000.toNewHampshire() );
8200                 return false;
8201             }
8202             //
8203             p.setSource( "(A)" );
8204             final Phylogeny p00000 = p.next();
8205             if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8206                 System.out.println( p00000.toNewHampshire() );
8207                 return false;
8208             }
8209             //
8210             final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8211             p.setSource( p1_str );
8212             if ( !p.hasNext() ) {
8213                 return false;
8214             }
8215             final Phylogeny p1_0 = p.next();
8216             if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8217                 System.out.println( p1_0.toNewHampshire() );
8218                 return false;
8219             }
8220             if ( !p.hasNext() ) {
8221                 return false;
8222             }
8223             final Phylogeny p1_1 = p.next();
8224             if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8225                 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8226                 return false;
8227             }
8228             if ( !p.hasNext() ) {
8229                 return false;
8230             }
8231             final Phylogeny p1_2 = p.next();
8232             if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8233                 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8234                 return false;
8235             }
8236             if ( !p.hasNext() ) {
8237                 return false;
8238             }
8239             final Phylogeny p1_3 = p.next();
8240             if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8241                 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8242                 return false;
8243             }
8244             if ( p.hasNext() ) {
8245                 return false;
8246             }
8247             if ( p.next() != null ) {
8248                 return false;
8249             }
8250             //
8251             final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8252             p.setSource( p2_str );
8253             if ( !p.hasNext() ) {
8254                 return false;
8255             }
8256             Phylogeny p2_0 = p.next();
8257             if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8258                 System.out.println( p2_0.toNewHampshire() );
8259                 return false;
8260             }
8261             if ( !p.hasNext() ) {
8262                 return false;
8263             }
8264             Phylogeny p2_1 = p.next();
8265             if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8266                 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8267                 return false;
8268             }
8269             if ( !p.hasNext() ) {
8270                 return false;
8271             }
8272             Phylogeny p2_2 = p.next();
8273             if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8274                 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8275                 return false;
8276             }
8277             if ( !p.hasNext() ) {
8278                 return false;
8279             }
8280             Phylogeny p2_3 = p.next();
8281             if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8282                 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8283                 return false;
8284             }
8285             if ( !p.hasNext() ) {
8286                 return false;
8287             }
8288             Phylogeny p2_4 = p.next();
8289             if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8290                 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8291                 return false;
8292             }
8293             if ( p.hasNext() ) {
8294                 return false;
8295             }
8296             if ( p.next() != null ) {
8297                 return false;
8298             }
8299             ////
8300             p.reset();
8301             if ( !p.hasNext() ) {
8302                 return false;
8303             }
8304             p2_0 = p.next();
8305             if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8306                 System.out.println( p2_0.toNewHampshire() );
8307                 return false;
8308             }
8309             if ( !p.hasNext() ) {
8310                 return false;
8311             }
8312             p2_1 = p.next();
8313             if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8314                 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8315                 return false;
8316             }
8317             if ( !p.hasNext() ) {
8318                 return false;
8319             }
8320             p2_2 = p.next();
8321             if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8322                 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8323                 return false;
8324             }
8325             if ( !p.hasNext() ) {
8326                 return false;
8327             }
8328             p2_3 = p.next();
8329             if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8330                 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8331                 return false;
8332             }
8333             if ( !p.hasNext() ) {
8334                 return false;
8335             }
8336             p2_4 = p.next();
8337             if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8338                 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8339                 return false;
8340             }
8341             if ( p.hasNext() ) {
8342                 return false;
8343             }
8344             if ( p.next() != null ) {
8345                 return false;
8346             }
8347             //
8348             final String p3_str = "((A,B),C)abc";
8349             p.setSource( p3_str );
8350             if ( !p.hasNext() ) {
8351                 return false;
8352             }
8353             final Phylogeny p3_0 = p.next();
8354             if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8355                 return false;
8356             }
8357             if ( p.hasNext() ) {
8358                 return false;
8359             }
8360             if ( p.next() != null ) {
8361                 return false;
8362             }
8363             //
8364             final String p4_str = "((A,B)ab,C)abc";
8365             p.setSource( p4_str );
8366             if ( !p.hasNext() ) {
8367                 return false;
8368             }
8369             final Phylogeny p4_0 = p.next();
8370             if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8371                 return false;
8372             }
8373             if ( p.hasNext() ) {
8374                 return false;
8375             }
8376             if ( p.next() != null ) {
8377                 return false;
8378             }
8379             //
8380             final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8381             p.setSource( p5_str );
8382             if ( !p.hasNext() ) {
8383                 return false;
8384             }
8385             final Phylogeny p5_0 = p.next();
8386             if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8387                 return false;
8388             }
8389             if ( p.hasNext() ) {
8390                 return false;
8391             }
8392             if ( p.next() != null ) {
8393                 return false;
8394             }
8395             //
8396             final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8397             p.setSource( p6_str );
8398             if ( !p.hasNext() ) {
8399                 return false;
8400             }
8401             Phylogeny p6_0 = p.next();
8402             if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8403                 return false;
8404             }
8405             if ( p.hasNext() ) {
8406                 return false;
8407             }
8408             if ( p.next() != null ) {
8409                 return false;
8410             }
8411             p.reset();
8412             if ( !p.hasNext() ) {
8413                 return false;
8414             }
8415             p6_0 = p.next();
8416             if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8417                 return false;
8418             }
8419             if ( p.hasNext() ) {
8420                 return false;
8421             }
8422             if ( p.next() != null ) {
8423                 return false;
8424             }
8425             //
8426             final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8427             p.setSource( p7_str );
8428             if ( !p.hasNext() ) {
8429                 return false;
8430             }
8431             Phylogeny p7_0 = p.next();
8432             if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8433                 return false;
8434             }
8435             if ( p.hasNext() ) {
8436                 return false;
8437             }
8438             if ( p.next() != null ) {
8439                 return false;
8440             }
8441             p.reset();
8442             if ( !p.hasNext() ) {
8443                 return false;
8444             }
8445             p7_0 = p.next();
8446             if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8447                 return false;
8448             }
8449             if ( p.hasNext() ) {
8450                 return false;
8451             }
8452             if ( p.next() != null ) {
8453                 return false;
8454             }
8455             //
8456             final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8457             p.setSource( p8_str );
8458             if ( !p.hasNext() ) {
8459                 return false;
8460             }
8461             Phylogeny p8_0 = p.next();
8462             if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8463                 return false;
8464             }
8465             if ( !p.hasNext() ) {
8466                 return false;
8467             }
8468             if ( !p.hasNext() ) {
8469                 return false;
8470             }
8471             Phylogeny p8_1 = p.next();
8472             if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8473                 return false;
8474             }
8475             if ( p.hasNext() ) {
8476                 return false;
8477             }
8478             if ( p.next() != null ) {
8479                 return false;
8480             }
8481             p.reset();
8482             if ( !p.hasNext() ) {
8483                 return false;
8484             }
8485             p8_0 = p.next();
8486             if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8487                 return false;
8488             }
8489             if ( !p.hasNext() ) {
8490                 return false;
8491             }
8492             p8_1 = p.next();
8493             if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8494                 return false;
8495             }
8496             if ( p.hasNext() ) {
8497                 return false;
8498             }
8499             if ( p.next() != null ) {
8500                 return false;
8501             }
8502             p.reset();
8503             //
8504             p.setSource( "" );
8505             if ( p.hasNext() ) {
8506                 return false;
8507             }
8508             //
8509             p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8510             if ( !p.hasNext() ) {
8511                 return false;
8512             }
8513             Phylogeny p_27 = p.next();
8514             if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8515                 System.out.println( p_27.toNewHampshireX() );
8516                 System.exit( -1 );
8517                 return false;
8518             }
8519             if ( p.hasNext() ) {
8520                 return false;
8521             }
8522             if ( p.next() != null ) {
8523                 return false;
8524             }
8525             p.reset();
8526             if ( !p.hasNext() ) {
8527                 return false;
8528             }
8529             p_27 = p.next();
8530             if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8531                 System.out.println( p_27.toNewHampshireX() );
8532                 System.exit( -1 );
8533                 return false;
8534             }
8535             if ( p.hasNext() ) {
8536                 return false;
8537             }
8538             if ( p.next() != null ) {
8539                 return false;
8540             }
8541             //
8542             final String p30_str = "(A,B);(C,D)";
8543             final NHXParser p30 = new NHXParser();
8544             p30.setSource( p30_str );
8545             if ( !p30.hasNext() ) {
8546                 return false;
8547             }
8548             Phylogeny phy30 = p30.next();
8549             if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8550                 System.out.println( phy30.toNewHampshire() );
8551                 return false;
8552             }
8553             if ( !p30.hasNext() ) {
8554                 return false;
8555             }
8556             Phylogeny phy301 = p30.next();
8557             if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8558                 System.out.println( phy301.toNewHampshire() );
8559                 return false;
8560             }
8561             if ( p30.hasNext() ) {
8562                 return false;
8563             }
8564             if ( p30.hasNext() ) {
8565                 return false;
8566             }
8567             if ( p30.next() != null ) {
8568                 return false;
8569             }
8570             if ( p30.next() != null ) {
8571                 return false;
8572             }
8573             p30.reset();
8574             if ( !p30.hasNext() ) {
8575                 return false;
8576             }
8577             phy30 = p30.next();
8578             if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8579                 System.out.println( phy30.toNewHampshire() );
8580                 return false;
8581             }
8582             if ( !p30.hasNext() ) {
8583                 return false;
8584             }
8585             phy301 = p30.next();
8586             if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8587                 System.out.println( phy301.toNewHampshire() );
8588                 return false;
8589             }
8590             if ( p30.hasNext() ) {
8591                 return false;
8592             }
8593             if ( p30.hasNext() ) {
8594                 return false;
8595             }
8596             if ( p30.next() != null ) {
8597                 return false;
8598             }
8599             if ( p30.next() != null ) {
8600                 return false;
8601             }
8602         }
8603         catch ( final Exception e ) {
8604             e.printStackTrace( System.out );
8605             return false;
8606         }
8607         return true;
8608     }
8609
8610     private static boolean testNHXconversion() {
8611         try {
8612             final PhylogenyNode n1 = new PhylogenyNode();
8613             final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8614             final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8615             final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8616             final PhylogenyNode n5 = PhylogenyNode
8617                     .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8618             final PhylogenyNode n6 = PhylogenyNode
8619                     .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8620             if ( !n1.toNewHampshireX().equals( "" ) ) {
8621                 return false;
8622             }
8623             if ( !n2.toNewHampshireX().equals( "" ) ) {
8624                 return false;
8625             }
8626             if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8627                 return false;
8628             }
8629             if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8630                 return false;
8631             }
8632             if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8633                 return false;
8634             }
8635             if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8636                 System.out.println( n6.toNewHampshireX() );
8637                 return false;
8638             }
8639         }
8640         catch ( final Exception e ) {
8641             e.printStackTrace( System.out );
8642             return false;
8643         }
8644         return true;
8645     }
8646
8647     private static boolean testNHXNodeParsing() {
8648         try {
8649             final PhylogenyNode n1 = new PhylogenyNode();
8650             final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8651             final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8652             final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8653             final PhylogenyNode n5 = PhylogenyNode
8654                     .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]" );
8655             if ( !n3.getName().equals( "n3" ) ) {
8656                 return false;
8657             }
8658             if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8659                 return false;
8660             }
8661             if ( n3.isDuplication() ) {
8662                 return false;
8663             }
8664             if ( n3.isHasAssignedEvent() ) {
8665                 return false;
8666             }
8667             if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8668                 return false;
8669             }
8670             if ( !n4.getName().equals( "n4" ) ) {
8671                 return false;
8672             }
8673             if ( n4.getDistanceToParent() != 0.01 ) {
8674                 return false;
8675             }
8676             if ( !n5.getName().equals( "n5" ) ) {
8677                 return false;
8678             }
8679             if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8680                 return false;
8681             }
8682             if ( n5.getDistanceToParent() != 0.1 ) {
8683                 return false;
8684             }
8685             if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8686                 return false;
8687             }
8688             if ( !n5.isDuplication() ) {
8689                 return false;
8690             }
8691             if ( !n5.isHasAssignedEvent() ) {
8692                 return false;
8693             }
8694             final PhylogenyNode n8 = PhylogenyNode
8695                     .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8696                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8697             if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8698                 return false;
8699             }
8700             if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8701                 return false;
8702             }
8703             final PhylogenyNode n9 = PhylogenyNode
8704                     .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8705                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8706             if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8707                 return false;
8708             }
8709             if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8710                 return false;
8711             }
8712             final PhylogenyNode n10 = PhylogenyNode
8713                     .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8714             if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8715                 return false;
8716             }
8717             final PhylogenyNode n20 = PhylogenyNode
8718                     .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8719             if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8720                 return false;
8721             }
8722             if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8723                 return false;
8724             }
8725             final PhylogenyNode n20x = PhylogenyNode
8726                     .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8727             if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8728                 return false;
8729             }
8730             if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8731                 return false;
8732             }
8733             final PhylogenyNode n20xx = PhylogenyNode
8734                     .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8735             if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8736                 return false;
8737             }
8738             if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8739                 return false;
8740             }
8741             final PhylogenyNode n20xxx = PhylogenyNode
8742                     .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8743             if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8744                 return false;
8745             }
8746             if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8747                 return false;
8748             }
8749             final PhylogenyNode n20xxxx = PhylogenyNode
8750                     .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8751             if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8752                 return false;
8753             }
8754             if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8755                 return false;
8756             }
8757             final PhylogenyNode n21 = PhylogenyNode
8758                     .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8759             if ( !n21.getName().equals( "N21_PIG" ) ) {
8760                 return false;
8761             }
8762             if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8763                 return false;
8764             }
8765             final PhylogenyNode n21x = PhylogenyNode
8766                     .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8767             if ( !n21x.getName().equals( "n21_PIG" ) ) {
8768                 return false;
8769             }
8770             if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8771                 return false;
8772             }
8773             final PhylogenyNode n22 = PhylogenyNode
8774                     .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8775             if ( !n22.getName().equals( "n22/PIG" ) ) {
8776                 return false;
8777             }
8778             if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8779                 return false;
8780             }
8781             final PhylogenyNode n23 = PhylogenyNode
8782                     .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8783             if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8784                 return false;
8785             }
8786             if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8787                 return false;
8788             }
8789             final PhylogenyNode a = PhylogenyNode
8790                     .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8791             if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8792                 return false;
8793             }
8794             if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8795                 return false;
8796             }
8797             final PhylogenyNode c1 = PhylogenyNode
8798                     .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8799                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8800             if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8801                 return false;
8802             }
8803             if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8804                 return false;
8805             }
8806             final PhylogenyNode c2 = PhylogenyNode
8807                     .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8808                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8809             if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8810                 return false;
8811             }
8812             if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8813                 return false;
8814             }
8815             final PhylogenyNode e3 = PhylogenyNode
8816                     .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8817             if ( !e3.getName().equals( "n10_RAT~" ) ) {
8818                 return false;
8819             }
8820             if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8821                 return false;
8822             }
8823             final PhylogenyNode n11 = PhylogenyNode
8824                     .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8825                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8826             if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8827                 return false;
8828             }
8829             if ( n11.getDistanceToParent() != 0.4 ) {
8830                 return false;
8831             }
8832             if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8833                 return false;
8834             }
8835             final PhylogenyNode n12 = PhylogenyNode
8836                     .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8837                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8838             if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8839                 return false;
8840             }
8841             if ( n12.getDistanceToParent() != 0.4 ) {
8842                 return false;
8843             }
8844             if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8845                 return false;
8846             }
8847             final PhylogenyNode o = PhylogenyNode
8848                     .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8849             if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8850                 return false;
8851             }
8852             if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8853                 return false;
8854             }
8855             if ( n1.getName().compareTo( "" ) != 0 ) {
8856                 return false;
8857             }
8858             if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8859                 return false;
8860             }
8861             if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8862                 return false;
8863             }
8864             if ( n2.getName().compareTo( "" ) != 0 ) {
8865                 return false;
8866             }
8867             if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8868                 return false;
8869             }
8870             if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8871                 return false;
8872             }
8873             final PhylogenyNode n00 = PhylogenyNode
8874                     .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8875             if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8876                 return false;
8877             }
8878             if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8879                 return false;
8880             }
8881             final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8882             if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8883                 return false;
8884             }
8885             final PhylogenyNode n13 = PhylogenyNode
8886                     .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8887             if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
8888                 return false;
8889             }
8890             if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8891                 return false;
8892             }
8893             if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8894                 return false;
8895             }
8896             if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8897                 return false;
8898             }
8899             final PhylogenyNode n14 = PhylogenyNode
8900                     .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8901             if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8902                 return false;
8903             }
8904             if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8905                 return false;
8906             }
8907             final PhylogenyNode n15 = PhylogenyNode
8908                     .createInstanceFromNhxString( "something_wicked[123]",
8909                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8910             if ( !n15.getName().equals( "something_wicked" ) ) {
8911                 return false;
8912             }
8913             if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8914                 return false;
8915             }
8916             if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8917                 return false;
8918             }
8919             final PhylogenyNode n16 = PhylogenyNode
8920                     .createInstanceFromNhxString( "something_wicked2[9]",
8921                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8922             if ( !n16.getName().equals( "something_wicked2" ) ) {
8923                 return false;
8924             }
8925             if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8926                 return false;
8927             }
8928             if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8929                 return false;
8930             }
8931             final PhylogenyNode n17 = PhylogenyNode
8932                     .createInstanceFromNhxString( "something_wicked3[a]",
8933                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8934             if ( !n17.getName().equals( "something_wicked3" ) ) {
8935                 return false;
8936             }
8937             if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8938                 return false;
8939             }
8940             final PhylogenyNode n18 = PhylogenyNode
8941                     .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8942             if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8943                 return false;
8944             }
8945             if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8946                 return false;
8947             }
8948             if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8949                 return false;
8950             }
8951             final PhylogenyNode n19 = PhylogenyNode
8952                     .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8953             if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8954                 return false;
8955             }
8956             if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8957                 return false;
8958             }
8959             final PhylogenyNode n30 = PhylogenyNode
8960                     .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
8961                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8962             if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8963                 return false;
8964             }
8965             if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8966                 return false;
8967             }
8968             final PhylogenyNode n31 = PhylogenyNode
8969                     .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
8970                                                   NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8971             if ( n31.getNodeData().isHasTaxonomy() ) {
8972                 return false;
8973             }
8974             final PhylogenyNode n32 = PhylogenyNode
8975                     .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8976             if ( n32.getNodeData().isHasTaxonomy() ) {
8977                 return false;
8978             }
8979             final PhylogenyNode n40 = PhylogenyNode
8980                     .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8981             if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8982                 return false;
8983             }
8984             final PhylogenyNode n41 = PhylogenyNode
8985                     .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8986             if ( n41.getNodeData().isHasTaxonomy() ) {
8987                 return false;
8988             }
8989             final PhylogenyNode n42 = PhylogenyNode
8990                     .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8991             if ( n42.getNodeData().isHasTaxonomy() ) {
8992                 return false;
8993             }
8994             final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8995                                                                                  NHXParser.TAXONOMY_EXTRACTION.NO );
8996             if ( n43.getNodeData().isHasTaxonomy() ) {
8997                 return false;
8998             }
8999             final PhylogenyNode n44 = PhylogenyNode
9000                     .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9001             if ( n44.getNodeData().isHasTaxonomy() ) {
9002                 return false;
9003             }
9004         }
9005         catch ( final Exception e ) {
9006             e.printStackTrace( System.out );
9007             return false;
9008         }
9009         return true;
9010     }
9011
9012     private static boolean testNHXParsing() {
9013         try {
9014             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9015             final Phylogeny p1 = factory.create( "(A     [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9016             if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9017                 return false;
9018             }
9019             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]";
9020             final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9021             if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9022                 return false;
9023             }
9024             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]";
9025             final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9026             if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9027                 return false;
9028             }
9029             final Phylogeny[] p3 = factory
9030                     .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]",
9031                              new NHXParser() );
9032             if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9033                 return false;
9034             }
9035             final Phylogeny[] p4 = factory
9036                     .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(]",
9037                              new NHXParser() );
9038             if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9039                 return false;
9040             }
9041             final Phylogeny[] p5 = factory
9042                     .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(((]",
9043                              new NHXParser() );
9044             if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9045                 return false;
9046             }
9047             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)";
9048             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)";
9049             final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9050             if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9051                 return false;
9052             }
9053             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)))";
9054             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)))";
9055             final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9056             if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9057                 return false;
9058             }
9059             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])   ))[,,, ])))))))";
9060             final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9061             final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9062             if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9063                 return false;
9064             }
9065             final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9066             if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9067                 return false;
9068             }
9069             final Phylogeny p10 = factory
9070                     .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]",
9071                              new NHXParser() )[ 0 ];
9072             if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9073                 return false;
9074             }
9075         }
9076         catch ( final Exception e ) {
9077             e.printStackTrace( System.out );
9078             return false;
9079         }
9080         return true;
9081     }
9082
9083     private static boolean testNHXParsingMB() {
9084         try {
9085             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9086             final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9087                     + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9088                     + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9089                     + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9090                     + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9091                     + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9092                     + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9093                     + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9094                     + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9095             if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9096                 return false;
9097             }
9098             if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9099                 return false;
9100             }
9101             if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9102                            0.1100000000000000e+00 ) ) {
9103                 return false;
9104             }
9105             if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9106                 return false;
9107             }
9108             if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9109                 return false;
9110             }
9111             final Phylogeny p2 = factory
9112                     .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9113                                      + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9114                                      + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9115                                      + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9116                                      + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9117                                      + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9118                                      + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9119                                      + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9120                                      + "7.369400000000000e-02}])",
9121                              new NHXParser() )[ 0 ];
9122             if ( p2.getNode( "1" ) == null ) {
9123                 return false;
9124             }
9125             if ( p2.getNode( "2" ) == null ) {
9126                 return false;
9127             }
9128         }
9129         catch ( final Exception e ) {
9130             e.printStackTrace( System.out );
9131             System.exit( -1 );
9132             return false;
9133         }
9134         return true;
9135     }
9136
9137     private static boolean testNHXParsingQuotes() {
9138         try {
9139             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9140             final NHXParser p = new NHXParser();
9141             final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9142             if ( phylogenies_0.length != 5 ) {
9143                 return false;
9144             }
9145             final Phylogeny phy = phylogenies_0[ 4 ];
9146             if ( phy.getNumberOfExternalNodes() != 7 ) {
9147                 return false;
9148             }
9149             if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9150                 return false;
9151             }
9152             if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9153                 return false;
9154             }
9155             if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9156                     .getScientificName().equals( "hsapiens" ) ) {
9157                 return false;
9158             }
9159             if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9160                 return false;
9161             }
9162             if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9163                 return false;
9164             }
9165             if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
9166                 return false;
9167             }
9168             if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9169                 return false;
9170             }
9171             if ( phy.getNodes( "A   (  B    C '" ).size() != 1 ) {
9172                 return false;
9173             }
9174             final NHXParser p1p = new NHXParser();
9175             p1p.setIgnoreQuotes( true );
9176             final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9177             if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9178                 return false;
9179             }
9180             final NHXParser p2p = new NHXParser();
9181             p1p.setIgnoreQuotes( false );
9182             final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9183             if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9184                 return false;
9185             }
9186             final NHXParser p3p = new NHXParser();
9187             p3p.setIgnoreQuotes( false );
9188             final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9189             if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9190                 return false;
9191             }
9192             final NHXParser p4p = new NHXParser();
9193             p4p.setIgnoreQuotes( false );
9194             final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9195             if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9196                 return false;
9197             }
9198             final Phylogeny p10 = factory
9199                     .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]",
9200                              new NHXParser() )[ 0 ];
9201             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]";
9202             if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9203                 return false;
9204             }
9205             final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9206             if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9207                 return false;
9208             }
9209             //
9210             final Phylogeny p12 = factory
9211                     .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]",
9212                              new NHXParser() )[ 0 ];
9213             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]";
9214             if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9215                 return false;
9216             }
9217             final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9218             if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9219                 return false;
9220             }
9221             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;";
9222             if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9223                 return false;
9224             }
9225             final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9226             if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9227                 return false;
9228             }
9229         }
9230         catch ( final Exception e ) {
9231             e.printStackTrace( System.out );
9232             return false;
9233         }
9234         return true;
9235     }
9236
9237     private static boolean testNodeRemoval() {
9238         try {
9239             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9240             final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9241             PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9242             if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9243                 return false;
9244             }
9245             final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9246             PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9247             if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9248                 return false;
9249             }
9250             final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9251             PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9252             if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9253                 return false;
9254             }
9255         }
9256         catch ( final Exception e ) {
9257             e.printStackTrace( System.out );
9258             return false;
9259         }
9260         return true;
9261     }
9262
9263     private static boolean testPhylogenyBranch() {
9264         try {
9265             final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9266             final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9267             final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9268             final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9269             if ( !a1b1.equals( a1b1 ) ) {
9270                 return false;
9271             }
9272             if ( !a1b1.equals( b1a1 ) ) {
9273                 return false;
9274             }
9275             if ( !b1a1.equals( a1b1 ) ) {
9276                 return false;
9277             }
9278             final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9279             final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9280             final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9281             if ( a1_b1.equals( b1_a1 ) ) {
9282                 return false;
9283             }
9284             if ( a1_b1.equals( a1_b1_ ) ) {
9285                 return false;
9286             }
9287             final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9288             if ( !a1_b1.equals( b1_a1_ ) ) {
9289                 return false;
9290             }
9291             if ( a1_b1_.equals( b1_a1_ ) ) {
9292                 return false;
9293             }
9294             if ( !a1_b1_.equals( b1_a1 ) ) {
9295                 return false;
9296             }
9297         }
9298         catch ( final Exception e ) {
9299             e.printStackTrace( System.out );
9300             return false;
9301         }
9302         return true;
9303     }
9304
9305     private static boolean testPhyloXMLparsingOfDistributionElement() {
9306         try {
9307             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9308             PhyloXmlParser xml_parser = null;
9309             try {
9310                 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9311             }
9312             catch ( final Exception e ) {
9313                 // Do nothing -- means were not running from jar.
9314             }
9315             if ( xml_parser == null ) {
9316                 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9317                 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9318                     xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9319                 }
9320                 else {
9321                     xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9322                 }
9323             }
9324             final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9325                                                               xml_parser );
9326             if ( xml_parser.getErrorCount() > 0 ) {
9327                 System.out.println( xml_parser.getErrorMessages().toString() );
9328                 return false;
9329             }
9330             if ( phylogenies_0.length != 1 ) {
9331                 return false;
9332             }
9333             final Phylogeny t1 = phylogenies_0[ 0 ];
9334             PhylogenyNode n = null;
9335             Distribution d = null;
9336             n = t1.getNode( "root node" );
9337             if ( !n.getNodeData().isHasDistribution() ) {
9338                 return false;
9339             }
9340             if ( n.getNodeData().getDistributions().size() != 1 ) {
9341                 return false;
9342             }
9343             d = n.getNodeData().getDistribution();
9344             if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9345                 return false;
9346             }
9347             if ( d.getPoints().size() != 1 ) {
9348                 return false;
9349             }
9350             if ( d.getPolygons() != null ) {
9351                 return false;
9352             }
9353             if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9354                 return false;
9355             }
9356             if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9357                 return false;
9358             }
9359             if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9360                 return false;
9361             }
9362             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9363                 return false;
9364             }
9365             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9366                 return false;
9367             }
9368             n = t1.getNode( "node a" );
9369             if ( !n.getNodeData().isHasDistribution() ) {
9370                 return false;
9371             }
9372             if ( n.getNodeData().getDistributions().size() != 2 ) {
9373                 return false;
9374             }
9375             d = n.getNodeData().getDistribution( 1 );
9376             if ( !d.getDesc().equals( "San Diego" ) ) {
9377                 return false;
9378             }
9379             if ( d.getPoints().size() != 1 ) {
9380                 return false;
9381             }
9382             if ( d.getPolygons() != null ) {
9383                 return false;
9384             }
9385             if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9386                 return false;
9387             }
9388             if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9389                 return false;
9390             }
9391             if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9392                 return false;
9393             }
9394             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9395                 return false;
9396             }
9397             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9398                 return false;
9399             }
9400             n = t1.getNode( "node bb" );
9401             if ( !n.getNodeData().isHasDistribution() ) {
9402                 return false;
9403             }
9404             if ( n.getNodeData().getDistributions().size() != 1 ) {
9405                 return false;
9406             }
9407             d = n.getNodeData().getDistribution( 0 );
9408             if ( d.getPoints().size() != 3 ) {
9409                 return false;
9410             }
9411             if ( d.getPolygons().size() != 2 ) {
9412                 return false;
9413             }
9414             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9415                 return false;
9416             }
9417             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9418                 return false;
9419             }
9420             if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9421                 return false;
9422             }
9423             if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9424                 return false;
9425             }
9426             if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9427                 return false;
9428             }
9429             if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9430                 return false;
9431             }
9432             Polygon p = d.getPolygons().get( 0 );
9433             if ( p.getPoints().size() != 3 ) {
9434                 return false;
9435             }
9436             if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9437                 return false;
9438             }
9439             if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9440                 return false;
9441             }
9442             if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9443                 return false;
9444             }
9445             if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9446                 return false;
9447             }
9448             if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9449                 return false;
9450             }
9451             if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9452                 return false;
9453             }
9454             p = d.getPolygons().get( 1 );
9455             if ( p.getPoints().size() != 3 ) {
9456                 return false;
9457             }
9458             if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9459                 return false;
9460             }
9461             if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9462                 return false;
9463             }
9464             if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9465                 return false;
9466             }
9467             // Roundtrip:
9468             final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9469             final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9470             if ( rt.length != 1 ) {
9471                 return false;
9472             }
9473             final Phylogeny t1_rt = rt[ 0 ];
9474             n = t1_rt.getNode( "root node" );
9475             if ( !n.getNodeData().isHasDistribution() ) {
9476                 return false;
9477             }
9478             if ( n.getNodeData().getDistributions().size() != 1 ) {
9479                 return false;
9480             }
9481             d = n.getNodeData().getDistribution();
9482             if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9483                 return false;
9484             }
9485             if ( d.getPoints().size() != 1 ) {
9486                 return false;
9487             }
9488             if ( d.getPolygons() != null ) {
9489                 return false;
9490             }
9491             if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9492                 return false;
9493             }
9494             if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9495                 return false;
9496             }
9497             if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9498                 return false;
9499             }
9500             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9501                 return false;
9502             }
9503             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9504                 return false;
9505             }
9506             n = t1_rt.getNode( "node a" );
9507             if ( !n.getNodeData().isHasDistribution() ) {
9508                 return false;
9509             }
9510             if ( n.getNodeData().getDistributions().size() != 2 ) {
9511                 return false;
9512             }
9513             d = n.getNodeData().getDistribution( 1 );
9514             if ( !d.getDesc().equals( "San Diego" ) ) {
9515                 return false;
9516             }
9517             if ( d.getPoints().size() != 1 ) {
9518                 return false;
9519             }
9520             if ( d.getPolygons() != null ) {
9521                 return false;
9522             }
9523             if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9524                 return false;
9525             }
9526             if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9527                 return false;
9528             }
9529             if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9530                 return false;
9531             }
9532             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9533                 return false;
9534             }
9535             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9536                 return false;
9537             }
9538             n = t1_rt.getNode( "node bb" );
9539             if ( !n.getNodeData().isHasDistribution() ) {
9540                 return false;
9541             }
9542             if ( n.getNodeData().getDistributions().size() != 1 ) {
9543                 return false;
9544             }
9545             d = n.getNodeData().getDistribution( 0 );
9546             if ( d.getPoints().size() != 3 ) {
9547                 return false;
9548             }
9549             if ( d.getPolygons().size() != 2 ) {
9550                 return false;
9551             }
9552             if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9553                 return false;
9554             }
9555             if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9556                 return false;
9557             }
9558             if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9559                 return false;
9560             }
9561             if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9562                 return false;
9563             }
9564             if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9565                 return false;
9566             }
9567             if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9568                 return false;
9569             }
9570             p = d.getPolygons().get( 0 );
9571             if ( p.getPoints().size() != 3 ) {
9572                 return false;
9573             }
9574             if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9575                 return false;
9576             }
9577             if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9578                 return false;
9579             }
9580             if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9581                 return false;
9582             }
9583             if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9584                 return false;
9585             }
9586             if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9587                 return false;
9588             }
9589             if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9590                 return false;
9591             }
9592             p = d.getPolygons().get( 1 );
9593             if ( p.getPoints().size() != 3 ) {
9594                 return false;
9595             }
9596             if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9597                 return false;
9598             }
9599             if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9600                 return false;
9601             }
9602             if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9603                 return false;
9604             }
9605         }
9606         catch ( final Exception e ) {
9607             e.printStackTrace( System.out );
9608             return false;
9609         }
9610         return true;
9611     }
9612
9613     private static boolean testPostOrderIterator() {
9614         try {
9615             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9616             final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9617             PhylogenyNodeIterator it0;
9618             for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9619                 it0.next();
9620             }
9621             for( it0.reset(); it0.hasNext(); ) {
9622                 it0.next();
9623             }
9624             final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9625             final PhylogenyNodeIterator it = t1.iteratorPostorder();
9626             if ( !it.next().getName().equals( "A" ) ) {
9627                 return false;
9628             }
9629             if ( !it.next().getName().equals( "B" ) ) {
9630                 return false;
9631             }
9632             if ( !it.next().getName().equals( "ab" ) ) {
9633                 return false;
9634             }
9635             if ( !it.next().getName().equals( "C" ) ) {
9636                 return false;
9637             }
9638             if ( !it.next().getName().equals( "D" ) ) {
9639                 return false;
9640             }
9641             if ( !it.next().getName().equals( "cd" ) ) {
9642                 return false;
9643             }
9644             if ( !it.next().getName().equals( "abcd" ) ) {
9645                 return false;
9646             }
9647             if ( !it.next().getName().equals( "E" ) ) {
9648                 return false;
9649             }
9650             if ( !it.next().getName().equals( "F" ) ) {
9651                 return false;
9652             }
9653             if ( !it.next().getName().equals( "ef" ) ) {
9654                 return false;
9655             }
9656             if ( !it.next().getName().equals( "G" ) ) {
9657                 return false;
9658             }
9659             if ( !it.next().getName().equals( "H" ) ) {
9660                 return false;
9661             }
9662             if ( !it.next().getName().equals( "gh" ) ) {
9663                 return false;
9664             }
9665             if ( !it.next().getName().equals( "efgh" ) ) {
9666                 return false;
9667             }
9668             if ( !it.next().getName().equals( "r" ) ) {
9669                 return false;
9670             }
9671             if ( it.hasNext() ) {
9672                 return false;
9673             }
9674         }
9675         catch ( final Exception e ) {
9676             e.printStackTrace( System.out );
9677             return false;
9678         }
9679         return true;
9680     }
9681
9682     private static boolean testPreOrderIterator() {
9683         try {
9684             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9685             final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9686             PhylogenyNodeIterator it0;
9687             for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9688                 it0.next();
9689             }
9690             for( it0.reset(); it0.hasNext(); ) {
9691                 it0.next();
9692             }
9693             PhylogenyNodeIterator it = t0.iteratorPreorder();
9694             if ( !it.next().getName().equals( "r" ) ) {
9695                 return false;
9696             }
9697             if ( !it.next().getName().equals( "ab" ) ) {
9698                 return false;
9699             }
9700             if ( !it.next().getName().equals( "A" ) ) {
9701                 return false;
9702             }
9703             if ( !it.next().getName().equals( "B" ) ) {
9704                 return false;
9705             }
9706             if ( !it.next().getName().equals( "cd" ) ) {
9707                 return false;
9708             }
9709             if ( !it.next().getName().equals( "C" ) ) {
9710                 return false;
9711             }
9712             if ( !it.next().getName().equals( "D" ) ) {
9713                 return false;
9714             }
9715             if ( it.hasNext() ) {
9716                 return false;
9717             }
9718             final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9719             it = t1.iteratorPreorder();
9720             if ( !it.next().getName().equals( "r" ) ) {
9721                 return false;
9722             }
9723             if ( !it.next().getName().equals( "abcd" ) ) {
9724                 return false;
9725             }
9726             if ( !it.next().getName().equals( "ab" ) ) {
9727                 return false;
9728             }
9729             if ( !it.next().getName().equals( "A" ) ) {
9730                 return false;
9731             }
9732             if ( !it.next().getName().equals( "B" ) ) {
9733                 return false;
9734             }
9735             if ( !it.next().getName().equals( "cd" ) ) {
9736                 return false;
9737             }
9738             if ( !it.next().getName().equals( "C" ) ) {
9739                 return false;
9740             }
9741             if ( !it.next().getName().equals( "D" ) ) {
9742                 return false;
9743             }
9744             if ( !it.next().getName().equals( "efgh" ) ) {
9745                 return false;
9746             }
9747             if ( !it.next().getName().equals( "ef" ) ) {
9748                 return false;
9749             }
9750             if ( !it.next().getName().equals( "E" ) ) {
9751                 return false;
9752             }
9753             if ( !it.next().getName().equals( "F" ) ) {
9754                 return false;
9755             }
9756             if ( !it.next().getName().equals( "gh" ) ) {
9757                 return false;
9758             }
9759             if ( !it.next().getName().equals( "G" ) ) {
9760                 return false;
9761             }
9762             if ( !it.next().getName().equals( "H" ) ) {
9763                 return false;
9764             }
9765             if ( it.hasNext() ) {
9766                 return false;
9767             }
9768         }
9769         catch ( final Exception e ) {
9770             e.printStackTrace( System.out );
9771             return false;
9772         }
9773         return true;
9774     }
9775
9776     private static boolean testPropertiesMap() {
9777         try {
9778             final PropertiesMap pm = new PropertiesMap();
9779             final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9780             final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9781             final Property p2 = new Property( "something:else",
9782                                               "?",
9783                                               "improbable:research",
9784                                               "xsd:decimal",
9785                                               AppliesTo.NODE );
9786             pm.addProperty( p0 );
9787             pm.addProperty( p1 );
9788             pm.addProperty( p2 );
9789             if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9790                 return false;
9791             }
9792             if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9793                 return false;
9794             }
9795             if ( pm.getProperties().size() != 3 ) {
9796                 return false;
9797             }
9798             if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9799                 return false;
9800             }
9801             if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9802                 return false;
9803             }
9804             if ( pm.getProperties().size() != 3 ) {
9805                 return false;
9806             }
9807             pm.removeProperty( "dimensions:diameter" );
9808             if ( pm.getProperties().size() != 2 ) {
9809                 return false;
9810             }
9811             if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9812                 return false;
9813             }
9814             if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9815                 return false;
9816             }
9817         }
9818         catch ( final Exception e ) {
9819             e.printStackTrace( System.out );
9820             return false;
9821         }
9822         return true;
9823     }
9824
9825     private static boolean testProteinId() {
9826         try {
9827             final ProteinId id1 = new ProteinId( "a" );
9828             final ProteinId id2 = new ProteinId( "a" );
9829             final ProteinId id3 = new ProteinId( "A" );
9830             final ProteinId id4 = new ProteinId( "b" );
9831             if ( !id1.equals( id1 ) ) {
9832                 return false;
9833             }
9834             if ( id1.getId().equals( "x" ) ) {
9835                 return false;
9836             }
9837             if ( id1.getId().equals( null ) ) {
9838                 return false;
9839             }
9840             if ( !id1.equals( id2 ) ) {
9841                 return false;
9842             }
9843             if ( id1.equals( id3 ) ) {
9844                 return false;
9845             }
9846             if ( id1.hashCode() != id1.hashCode() ) {
9847                 return false;
9848             }
9849             if ( id1.hashCode() != id2.hashCode() ) {
9850                 return false;
9851             }
9852             if ( id1.hashCode() == id3.hashCode() ) {
9853                 return false;
9854             }
9855             if ( id1.compareTo( id1 ) != 0 ) {
9856                 return false;
9857             }
9858             if ( id1.compareTo( id2 ) != 0 ) {
9859                 return false;
9860             }
9861             if ( id1.compareTo( id3 ) != 0 ) {
9862                 return false;
9863             }
9864             if ( id1.compareTo( id4 ) >= 0 ) {
9865                 return false;
9866             }
9867             if ( id4.compareTo( id1 ) <= 0 ) {
9868                 return false;
9869             }
9870             if ( !id4.getId().equals( "b" ) ) {
9871                 return false;
9872             }
9873             final ProteinId id5 = new ProteinId( " C " );
9874             if ( !id5.getId().equals( "C" ) ) {
9875                 return false;
9876             }
9877             if ( id5.equals( id1 ) ) {
9878                 return false;
9879             }
9880         }
9881         catch ( final Exception e ) {
9882             e.printStackTrace( System.out );
9883             return false;
9884         }
9885         return true;
9886     }
9887
9888     private static boolean testReIdMethods() {
9889         try {
9890             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9891             final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9892             final long count = PhylogenyNode.getNodeCount();
9893             p.levelOrderReID();
9894             if ( p.getNode( "r" ).getId() != count ) {
9895                 return false;
9896             }
9897             if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9898                 return false;
9899             }
9900             if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9901                 return false;
9902             }
9903             if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9904                 return false;
9905             }
9906             if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9907                 return false;
9908             }
9909             if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9910                 return false;
9911             }
9912             if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9913                 return false;
9914             }
9915             if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9916                 return false;
9917             }
9918             if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9919                 return false;
9920             }
9921             if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9922                 return false;
9923             }
9924             if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9925                 return false;
9926             }
9927             if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9928                 return false;
9929             }
9930             if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9931                 return false;
9932             }
9933             if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9934                 return false;
9935             }
9936             if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9937                 return false;
9938             }
9939         }
9940         catch ( final Exception e ) {
9941             e.printStackTrace( System.out );
9942             return false;
9943         }
9944         return true;
9945     }
9946
9947     private static boolean testRerooting() {
9948         try {
9949             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9950             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",
9951                                                  new NHXParser() )[ 0 ];
9952             if ( !t1.isRooted() ) {
9953                 return false;
9954             }
9955             t1.reRoot( t1.getNode( "D" ) );
9956             t1.reRoot( t1.getNode( "CD" ) );
9957             t1.reRoot( t1.getNode( "A" ) );
9958             t1.reRoot( t1.getNode( "B" ) );
9959             t1.reRoot( t1.getNode( "AB" ) );
9960             t1.reRoot( t1.getNode( "D" ) );
9961             t1.reRoot( t1.getNode( "C" ) );
9962             t1.reRoot( t1.getNode( "CD" ) );
9963             t1.reRoot( t1.getNode( "A" ) );
9964             t1.reRoot( t1.getNode( "B" ) );
9965             t1.reRoot( t1.getNode( "AB" ) );
9966             t1.reRoot( t1.getNode( "D" ) );
9967             t1.reRoot( t1.getNode( "D" ) );
9968             t1.reRoot( t1.getNode( "C" ) );
9969             t1.reRoot( t1.getNode( "A" ) );
9970             t1.reRoot( t1.getNode( "B" ) );
9971             t1.reRoot( t1.getNode( "AB" ) );
9972             t1.reRoot( t1.getNode( "C" ) );
9973             t1.reRoot( t1.getNode( "D" ) );
9974             t1.reRoot( t1.getNode( "CD" ) );
9975             t1.reRoot( t1.getNode( "D" ) );
9976             t1.reRoot( t1.getNode( "A" ) );
9977             t1.reRoot( t1.getNode( "B" ) );
9978             t1.reRoot( t1.getNode( "AB" ) );
9979             t1.reRoot( t1.getNode( "C" ) );
9980             t1.reRoot( t1.getNode( "D" ) );
9981             t1.reRoot( t1.getNode( "CD" ) );
9982             t1.reRoot( t1.getNode( "D" ) );
9983             if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9984                 return false;
9985             }
9986             if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9987                 return false;
9988             }
9989             if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9990                 return false;
9991             }
9992             if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9993                 return false;
9994             }
9995             if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9996                 return false;
9997             }
9998             if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9999                 return false;
10000             }
10001             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",
10002                                                  new NHXParser() )[ 0 ];
10003             t2.reRoot( t2.getNode( "A" ) );
10004             t2.reRoot( t2.getNode( "D" ) );
10005             t2.reRoot( t2.getNode( "ABC" ) );
10006             t2.reRoot( t2.getNode( "A" ) );
10007             t2.reRoot( t2.getNode( "B" ) );
10008             t2.reRoot( t2.getNode( "D" ) );
10009             t2.reRoot( t2.getNode( "C" ) );
10010             t2.reRoot( t2.getNode( "ABC" ) );
10011             t2.reRoot( t2.getNode( "A" ) );
10012             t2.reRoot( t2.getNode( "B" ) );
10013             t2.reRoot( t2.getNode( "AB" ) );
10014             t2.reRoot( t2.getNode( "AB" ) );
10015             t2.reRoot( t2.getNode( "D" ) );
10016             t2.reRoot( t2.getNode( "C" ) );
10017             t2.reRoot( t2.getNode( "B" ) );
10018             t2.reRoot( t2.getNode( "AB" ) );
10019             t2.reRoot( t2.getNode( "D" ) );
10020             t2.reRoot( t2.getNode( "D" ) );
10021             t2.reRoot( t2.getNode( "ABC" ) );
10022             t2.reRoot( t2.getNode( "A" ) );
10023             t2.reRoot( t2.getNode( "B" ) );
10024             t2.reRoot( t2.getNode( "AB" ) );
10025             t2.reRoot( t2.getNode( "D" ) );
10026             t2.reRoot( t2.getNode( "C" ) );
10027             t2.reRoot( t2.getNode( "ABC" ) );
10028             t2.reRoot( t2.getNode( "A" ) );
10029             t2.reRoot( t2.getNode( "B" ) );
10030             t2.reRoot( t2.getNode( "AB" ) );
10031             t2.reRoot( t2.getNode( "D" ) );
10032             t2.reRoot( t2.getNode( "D" ) );
10033             t2.reRoot( t2.getNode( "C" ) );
10034             t2.reRoot( t2.getNode( "A" ) );
10035             t2.reRoot( t2.getNode( "B" ) );
10036             t2.reRoot( t2.getNode( "AB" ) );
10037             t2.reRoot( t2.getNode( "C" ) );
10038             t2.reRoot( t2.getNode( "D" ) );
10039             t2.reRoot( t2.getNode( "ABC" ) );
10040             t2.reRoot( t2.getNode( "D" ) );
10041             t2.reRoot( t2.getNode( "A" ) );
10042             t2.reRoot( t2.getNode( "B" ) );
10043             t2.reRoot( t2.getNode( "AB" ) );
10044             t2.reRoot( t2.getNode( "C" ) );
10045             t2.reRoot( t2.getNode( "D" ) );
10046             t2.reRoot( t2.getNode( "ABC" ) );
10047             t2.reRoot( t2.getNode( "D" ) );
10048             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10049                 return false;
10050             }
10051             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10052                 return false;
10053             }
10054             t2.reRoot( t2.getNode( "ABC" ) );
10055             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10056                 return false;
10057             }
10058             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10059                 return false;
10060             }
10061             t2.reRoot( t2.getNode( "AB" ) );
10062             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10063                 return false;
10064             }
10065             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10066                 return false;
10067             }
10068             if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10069                 return false;
10070             }
10071             t2.reRoot( t2.getNode( "AB" ) );
10072             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10073                 return false;
10074             }
10075             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10076                 return false;
10077             }
10078             if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10079                 return false;
10080             }
10081             t2.reRoot( t2.getNode( "D" ) );
10082             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10083                 return false;
10084             }
10085             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10086                 return false;
10087             }
10088             t2.reRoot( t2.getNode( "ABC" ) );
10089             if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10090                 return false;
10091             }
10092             if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10093                 return false;
10094             }
10095             final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10096                                                  new NHXParser() )[ 0 ];
10097             t3.reRoot( t3.getNode( "B" ) );
10098             if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10099                 return false;
10100             }
10101             if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10102                 return false;
10103             }
10104             if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10105                 return false;
10106             }
10107             t3.reRoot( t3.getNode( "B" ) );
10108             if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10109                 return false;
10110             }
10111             if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10112                 return false;
10113             }
10114             if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10115                 return false;
10116             }
10117             t3.reRoot( t3.getRoot() );
10118             if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10119                 return false;
10120             }
10121             if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10122                 return false;
10123             }
10124             if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10125                 return false;
10126             }
10127         }
10128         catch ( final Exception e ) {
10129             e.printStackTrace( System.out );
10130             return false;
10131         }
10132         return true;
10133     }
10134
10135     private static boolean testSDIse() {
10136         try {
10137             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10138             final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10139             final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10140             gene1.setRooted( true );
10141             species1.setRooted( true );
10142             final SDI sdi = new SDI( gene1, species1 );
10143             if ( !gene1.getRoot().isDuplication() ) {
10144                 return false;
10145             }
10146             final Phylogeny species2 = factory
10147                     .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10148                              new NHXParser() )[ 0 ];
10149             final Phylogeny gene2 = factory
10150                     .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10151                              new NHXParser() )[ 0 ];
10152             species2.setRooted( true );
10153             gene2.setRooted( true );
10154             final SDI sdi2 = new SDI( gene2, species2 );
10155             if ( sdi2.getDuplicationsSum() != 0 ) {
10156                 return false;
10157             }
10158             if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10159                 return false;
10160             }
10161             if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10162                 return false;
10163             }
10164             if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10165                 return false;
10166             }
10167             if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10168                 return false;
10169             }
10170             if ( !gene2.getNode( "r" ).isSpeciation() ) {
10171                 return false;
10172             }
10173             if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10174                 return false;
10175             }
10176             final Phylogeny species3 = factory
10177                     .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10178                              new NHXParser() )[ 0 ];
10179             final Phylogeny gene3 = factory
10180                     .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10181                              new NHXParser() )[ 0 ];
10182             species3.setRooted( true );
10183             gene3.setRooted( true );
10184             final SDI sdi3 = new SDI( gene3, species3 );
10185             if ( sdi3.getDuplicationsSum() != 1 ) {
10186                 return false;
10187             }
10188             if ( !gene3.getNode( "aa" ).isDuplication() ) {
10189                 return false;
10190             }
10191             if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10192                 return false;
10193             }
10194             final Phylogeny species4 = factory
10195                     .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10196                              new NHXParser() )[ 0 ];
10197             final Phylogeny gene4 = factory
10198                     .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10199                              new NHXParser() )[ 0 ];
10200             species4.setRooted( true );
10201             gene4.setRooted( true );
10202             final SDI sdi4 = new SDI( gene4, species4 );
10203             if ( sdi4.getDuplicationsSum() != 1 ) {
10204                 return false;
10205             }
10206             if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10207                 return false;
10208             }
10209             if ( !gene4.getNode( "abc" ).isDuplication() ) {
10210                 return false;
10211             }
10212             if ( gene4.getNode( "abcd" ).isDuplication() ) {
10213                 return false;
10214             }
10215             if ( species4.getNumberOfExternalNodes() != 6 ) {
10216                 return false;
10217             }
10218             if ( gene4.getNumberOfExternalNodes() != 6 ) {
10219                 return false;
10220             }
10221             final Phylogeny species5 = factory
10222                     .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10223                              new NHXParser() )[ 0 ];
10224             final Phylogeny gene5 = factory
10225                     .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10226                              new NHXParser() )[ 0 ];
10227             species5.setRooted( true );
10228             gene5.setRooted( true );
10229             final SDI sdi5 = new SDI( gene5, species5 );
10230             if ( sdi5.getDuplicationsSum() != 2 ) {
10231                 return false;
10232             }
10233             if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10234                 return false;
10235             }
10236             if ( !gene5.getNode( "adc" ).isDuplication() ) {
10237                 return false;
10238             }
10239             if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10240                 return false;
10241             }
10242             if ( species5.getNumberOfExternalNodes() != 6 ) {
10243                 return false;
10244             }
10245             if ( gene5.getNumberOfExternalNodes() != 6 ) {
10246                 return false;
10247             }
10248             // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10249             // Conjecture for Comparing Molecular Phylogenies"
10250             // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10251             final Phylogeny species6 = factory
10252                     .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,"
10253                                      + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10254                              new NHXParser() )[ 0 ];
10255             final Phylogeny gene6 = factory
10256                     .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,"
10257                                      + "((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,"
10258                                      + "(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;",
10259                              new NHXParser() )[ 0 ];
10260             species6.setRooted( true );
10261             gene6.setRooted( true );
10262             final SDI sdi6 = new SDI( gene6, species6 );
10263             if ( sdi6.getDuplicationsSum() != 3 ) {
10264                 return false;
10265             }
10266             if ( !gene6.getNode( "r" ).isDuplication() ) {
10267                 return false;
10268             }
10269             if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10270                 return false;
10271             }
10272             if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10273                 return false;
10274             }
10275             if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10276                 return false;
10277             }
10278             if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10279                 return false;
10280             }
10281             if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10282                 return false;
10283             }
10284             if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10285                 return false;
10286             }
10287             if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10288                 return false;
10289             }
10290             sdi6.computeMappingCostL();
10291             if ( sdi6.computeMappingCostL() != 17 ) {
10292                 return false;
10293             }
10294             if ( species6.getNumberOfExternalNodes() != 9 ) {
10295                 return false;
10296             }
10297             if ( gene6.getNumberOfExternalNodes() != 9 ) {
10298                 return false;
10299             }
10300             final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10301                     + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10302                     + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10303                     + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10304                     + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10305             species7.setRooted( true );
10306             final Phylogeny gene7_1 = Test
10307                     .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])" );
10308             gene7_1.setRooted( true );
10309             final SDI sdi7 = new SDI( gene7_1, species7 );
10310             if ( sdi7.getDuplicationsSum() != 0 ) {
10311                 return false;
10312             }
10313             if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10314                 return false;
10315             }
10316             if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10317                 return false;
10318             }
10319             if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10320                 return false;
10321             }
10322             if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10323                 return false;
10324             }
10325             if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10326                 return false;
10327             }
10328             if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10329                 return false;
10330             }
10331             if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10332                 return false;
10333             }
10334             if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10335                 return false;
10336             }
10337             final Phylogeny gene7_2 = Test
10338                     .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])" );
10339             gene7_2.setRooted( true );
10340             final SDI sdi7_2 = new SDI( gene7_2, species7 );
10341             if ( sdi7_2.getDuplicationsSum() != 1 ) {
10342                 return false;
10343             }
10344             if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10345                 return false;
10346             }
10347             if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10348                 return false;
10349             }
10350             if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10351                 return false;
10352             }
10353             if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10354                 return false;
10355             }
10356             if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10357                 return false;
10358             }
10359             if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10360                 return false;
10361             }
10362             if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10363                 return false;
10364             }
10365             if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10366                 return false;
10367             }
10368             if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10369                 return false;
10370             }
10371         }
10372         catch ( final Exception e ) {
10373             return false;
10374         }
10375         return true;
10376     }
10377
10378     private static boolean testSDIunrooted() {
10379         try {
10380             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10381             final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10382             final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10383             final Iterator<PhylogenyBranch> iter = l.iterator();
10384             PhylogenyBranch br = iter.next();
10385             if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10386                 return false;
10387             }
10388             if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10389                 return false;
10390             }
10391             br = iter.next();
10392             if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10393                 return false;
10394             }
10395             if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10396                 return false;
10397             }
10398             br = iter.next();
10399             if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10400                 return false;
10401             }
10402             if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10403                 return false;
10404             }
10405             br = iter.next();
10406             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10407                 return false;
10408             }
10409             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10410                 return false;
10411             }
10412             br = iter.next();
10413             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10414                 return false;
10415             }
10416             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10417                 return false;
10418             }
10419             br = iter.next();
10420             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10421                 return false;
10422             }
10423             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10424                 return false;
10425             }
10426             br = iter.next();
10427             if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10428                 return false;
10429             }
10430             if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10431                 return false;
10432             }
10433             br = iter.next();
10434             if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10435                 return false;
10436             }
10437             if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10438                 return false;
10439             }
10440             br = iter.next();
10441             if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10442                 return false;
10443             }
10444             if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10445                 return false;
10446             }
10447             br = iter.next();
10448             if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10449                 return false;
10450             }
10451             if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10452                 return false;
10453             }
10454             br = iter.next();
10455             if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10456                 return false;
10457             }
10458             if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10459                 return false;
10460             }
10461             br = iter.next();
10462             if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10463                 return false;
10464             }
10465             if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10466                 return false;
10467             }
10468             br = iter.next();
10469             if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10470                 return false;
10471             }
10472             if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10473                 return false;
10474             }
10475             br = iter.next();
10476             if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10477                 return false;
10478             }
10479             if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10480                 return false;
10481             }
10482             br = iter.next();
10483             if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10484                 return false;
10485             }
10486             if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10487                 return false;
10488             }
10489             if ( iter.hasNext() ) {
10490                 return false;
10491             }
10492             final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10493             final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10494             final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10495             br = iter1.next();
10496             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10497                 return false;
10498             }
10499             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10500                 return false;
10501             }
10502             br = iter1.next();
10503             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10504                 return false;
10505             }
10506             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10507                 return false;
10508             }
10509             br = iter1.next();
10510             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10511                 return false;
10512             }
10513             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10514                 return false;
10515             }
10516             if ( iter1.hasNext() ) {
10517                 return false;
10518             }
10519             final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10520             final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10521             final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10522             br = iter2.next();
10523             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10524                 return false;
10525             }
10526             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10527                 return false;
10528             }
10529             br = iter2.next();
10530             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10531                 return false;
10532             }
10533             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10534                 return false;
10535             }
10536             br = iter2.next();
10537             if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10538                 return false;
10539             }
10540             if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10541                 return false;
10542             }
10543             if ( iter2.hasNext() ) {
10544                 return false;
10545             }
10546             final Phylogeny species0 = factory
10547                     .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10548                              new NHXParser() )[ 0 ];
10549             final Phylogeny gene1 = factory
10550                     .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])",
10551                              new NHXParser() )[ 0 ];
10552             species0.setRooted( true );
10553             gene1.setRooted( true );
10554             final SDIR sdi_unrooted = new SDIR();
10555             sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10556             if ( sdi_unrooted.getCount() != 1 ) {
10557                 return false;
10558             }
10559             if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10560                 return false;
10561             }
10562             if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10563                 return false;
10564             }
10565             if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10566                 return false;
10567             }
10568             if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10569                 return false;
10570             }
10571             final Phylogeny gene2 = factory
10572                     .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])",
10573                              new NHXParser() )[ 0 ];
10574             gene2.setRooted( true );
10575             sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10576             if ( sdi_unrooted.getCount() != 1 ) {
10577                 return false;
10578             }
10579             if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10580                 return false;
10581             }
10582             if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10583                 return false;
10584             }
10585             if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10586                 return false;
10587             }
10588             if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10589                 return false;
10590             }
10591             final Phylogeny species6 = factory
10592                     .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,"
10593                                      + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10594                              new NHXParser() )[ 0 ];
10595             final Phylogeny gene6 = factory
10596                     .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],"
10597                                      + "(((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],"
10598                                      + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10599                                      + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10600                                      + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10601                              new NHXParser() )[ 0 ];
10602             species6.setRooted( true );
10603             gene6.setRooted( true );
10604             Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10605             if ( sdi_unrooted.getCount() != 1 ) {
10606                 return false;
10607             }
10608             if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10609                 return false;
10610             }
10611             if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10612                 return false;
10613             }
10614             if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10615                 return false;
10616             }
10617             if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10618                 return false;
10619             }
10620             if ( !p6[ 0 ].getRoot().isDuplication() ) {
10621                 return false;
10622             }
10623             if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10624                 return false;
10625             }
10626             if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10627                 return false;
10628             }
10629             if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10630                 return false;
10631             }
10632             if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10633                 return false;
10634             }
10635             if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10636                 return false;
10637             }
10638             if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10639                 return false;
10640             }
10641             if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10642                 return false;
10643             }
10644             p6 = null;
10645             final Phylogeny species7 = factory
10646                     .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,"
10647                                      + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10648                              new NHXParser() )[ 0 ];
10649             final Phylogeny gene7 = factory
10650                     .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],"
10651                                      + "(((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],"
10652                                      + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10653                                      + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10654                                      + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10655                              new NHXParser() )[ 0 ];
10656             species7.setRooted( true );
10657             gene7.setRooted( true );
10658             Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10659             if ( sdi_unrooted.getCount() != 1 ) {
10660                 return false;
10661             }
10662             if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10663                 return false;
10664             }
10665             if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10666                 return false;
10667             }
10668             if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10669                 return false;
10670             }
10671             if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10672                 return false;
10673             }
10674             if ( !p7[ 0 ].getRoot().isDuplication() ) {
10675                 return false;
10676             }
10677             if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10678                 return false;
10679             }
10680             if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10681                 return false;
10682             }
10683             if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10684                 return false;
10685             }
10686             if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10687                 return false;
10688             }
10689             if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10690                 return false;
10691             }
10692             if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10693                 return false;
10694             }
10695             if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10696                 return false;
10697             }
10698             p7 = null;
10699             final Phylogeny species8 = factory
10700                     .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,"
10701                                      + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10702                              new NHXParser() )[ 0 ];
10703             final Phylogeny gene8 = factory
10704                     .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],"
10705                                      + "(((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],"
10706                                      + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10707                                      + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10708                                      + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10709                              new NHXParser() )[ 0 ];
10710             species8.setRooted( true );
10711             gene8.setRooted( true );
10712             Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10713             if ( sdi_unrooted.getCount() != 1 ) {
10714                 return false;
10715             }
10716             if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10717                 return false;
10718             }
10719             if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10720                 return false;
10721             }
10722             if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10723                 return false;
10724             }
10725             if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10726                 return false;
10727             }
10728             if ( !p8[ 0 ].getRoot().isDuplication() ) {
10729                 return false;
10730             }
10731             if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10732                 return false;
10733             }
10734             if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10735                 return false;
10736             }
10737             if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10738                 return false;
10739             }
10740             if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10741                 return false;
10742             }
10743             if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10744                 return false;
10745             }
10746             if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10747                 return false;
10748             }
10749             if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10750                 return false;
10751             }
10752             p8 = null;
10753         }
10754         catch ( final Exception e ) {
10755             e.printStackTrace( System.out );
10756             return false;
10757         }
10758         return true;
10759     }
10760
10761     private static boolean testSequenceDbWsTools1() {
10762         try {
10763             final PhylogenyNode n = new PhylogenyNode();
10764             n.setName( "NP_001025424" );
10765             Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10766             if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10767                     || !acc.getValue().equals( "NP_001025424" ) ) {
10768                 return false;
10769             }
10770             n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10771             acc = SequenceDbWsTools.obtainSeqAccession( n );
10772             if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10773                     || !acc.getValue().equals( "NP_001025424" ) ) {
10774                 return false;
10775             }
10776             n.setName( "NP_001025424.1" );
10777             acc = SequenceDbWsTools.obtainSeqAccession( n );
10778             if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10779                     || !acc.getValue().equals( "NP_001025424" ) ) {
10780                 return false;
10781             }
10782             n.setName( "NM_001030253" );
10783             acc = SequenceDbWsTools.obtainSeqAccession( n );
10784             if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10785                     || !acc.getValue().equals( "NM_001030253" ) ) {
10786                 return false;
10787             }
10788             n.setName( "BCL2_HUMAN" );
10789             acc = SequenceDbWsTools.obtainSeqAccession( n );
10790             if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10791                     || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10792                 System.out.println( acc.toString() );
10793                 return false;
10794             }
10795             n.setName( "P10415" );
10796             acc = SequenceDbWsTools.obtainSeqAccession( n );
10797             if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10798                     || !acc.getValue().equals( "P10415" ) ) {
10799                 System.out.println( acc.toString() );
10800                 return false;
10801             }
10802             n.setName( " P10415 " );
10803             acc = SequenceDbWsTools.obtainSeqAccession( n );
10804             if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10805                     || !acc.getValue().equals( "P10415" ) ) {
10806                 System.out.println( acc.toString() );
10807                 return false;
10808             }
10809             n.setName( "_P10415|" );
10810             acc = SequenceDbWsTools.obtainSeqAccession( n );
10811             if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10812                     || !acc.getValue().equals( "P10415" ) ) {
10813                 System.out.println( acc.toString() );
10814                 return false;
10815             }
10816             n.setName( "AY695820" );
10817             acc = SequenceDbWsTools.obtainSeqAccession( n );
10818             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10819                     || !acc.getValue().equals( "AY695820" ) ) {
10820                 System.out.println( acc.toString() );
10821                 return false;
10822             }
10823             n.setName( "_AY695820_" );
10824             acc = SequenceDbWsTools.obtainSeqAccession( n );
10825             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10826                     || !acc.getValue().equals( "AY695820" ) ) {
10827                 System.out.println( acc.toString() );
10828                 return false;
10829             }
10830             n.setName( "AAA59452" );
10831             acc = SequenceDbWsTools.obtainSeqAccession( n );
10832             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10833                     || !acc.getValue().equals( "AAA59452" ) ) {
10834                 System.out.println( acc.toString() );
10835                 return false;
10836             }
10837             n.setName( "_AAA59452_" );
10838             acc = SequenceDbWsTools.obtainSeqAccession( n );
10839             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10840                     || !acc.getValue().equals( "AAA59452" ) ) {
10841                 System.out.println( acc.toString() );
10842                 return false;
10843             }
10844             n.setName( "AAA59452.1" );
10845             acc = SequenceDbWsTools.obtainSeqAccession( n );
10846             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10847                     || !acc.getValue().equals( "AAA59452.1" ) ) {
10848                 System.out.println( acc.toString() );
10849                 return false;
10850             }
10851             n.setName( "_AAA59452.1_" );
10852             acc = SequenceDbWsTools.obtainSeqAccession( n );
10853             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10854                     || !acc.getValue().equals( "AAA59452.1" ) ) {
10855                 System.out.println( acc.toString() );
10856                 return false;
10857             }
10858             n.setName( "GI:94894583" );
10859             acc = SequenceDbWsTools.obtainSeqAccession( n );
10860             if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10861                     || !acc.getValue().equals( "94894583" ) ) {
10862                 System.out.println( acc.toString() );
10863                 return false;
10864             }
10865             n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10866             acc = SequenceDbWsTools.obtainSeqAccession( n );
10867             if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10868                     || !acc.getValue().equals( "71845847" ) ) {
10869                 System.out.println( acc.toString() );
10870                 return false;
10871             }
10872             n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10873             acc = SequenceDbWsTools.obtainSeqAccession( n );
10874             if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10875                     || !acc.getValue().equals( "AAZ45343.1" ) ) {
10876                 System.out.println( acc.toString() );
10877                 return false;
10878             }
10879         }
10880         catch ( final Exception e ) {
10881             return false;
10882         }
10883         return true;
10884     }
10885
10886     private static boolean testSequenceDbWsTools2() {
10887         try {
10888             final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10889             SequenceDbWsTools.obtainSeqInformation( n1 );
10890             if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10891                 return false;
10892             }
10893             if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10894                 return false;
10895             }
10896             if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10897                 return false;
10898             }
10899             if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10900                 return false;
10901             }
10902             final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10903             SequenceDbWsTools.obtainSeqInformation( n2 );
10904             if ( !n2.getNodeData().getSequence().getName()
10905                     .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10906                 return false;
10907             }
10908             if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10909                 return false;
10910             }
10911             if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10912                 return false;
10913             }
10914             if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10915                 return false;
10916             }
10917             final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10918             SequenceDbWsTools.obtainSeqInformation( n3 );
10919             if ( !n3.getNodeData().getSequence().getName()
10920                     .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10921                 return false;
10922             }
10923             if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10924                 return false;
10925             }
10926             if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10927                 return false;
10928             }
10929             if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10930                 return false;
10931             }
10932         }
10933         catch ( final IOException e ) {
10934             System.out.println();
10935             System.out.println( "the following might be due to absence internet connection:" );
10936             e.printStackTrace( System.out );
10937             return true;
10938         }
10939         catch ( final Exception e ) {
10940             e.printStackTrace();
10941             return false;
10942         }
10943         return true;
10944     }
10945
10946     private static boolean testSequenceIdParsing() {
10947         try {
10948             Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10949             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10950                     || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10951                 if ( id != null ) {
10952                     System.out.println( "value   =" + id.getValue() );
10953                     System.out.println( "provider=" + id.getSource() );
10954                 }
10955                 return false;
10956             }
10957             //
10958             id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10959             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10960                     || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10961                 if ( id != null ) {
10962                     System.out.println( "value   =" + id.getValue() );
10963                     System.out.println( "provider=" + id.getSource() );
10964                 }
10965                 return false;
10966             }
10967             //
10968             id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10969             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10970                     || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10971                 if ( id != null ) {
10972                     System.out.println( "value   =" + id.getValue() );
10973                     System.out.println( "provider=" + id.getSource() );
10974                 }
10975                 return false;
10976             }
10977             // 
10978             id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10979             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10980                     || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10981                 if ( id != null ) {
10982                     System.out.println( "value   =" + id.getValue() );
10983                     System.out.println( "provider=" + id.getSource() );
10984                 }
10985                 return false;
10986             }
10987             // 
10988             id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10989             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10990                     || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10991                 if ( id != null ) {
10992                     System.out.println( "value   =" + id.getValue() );
10993                     System.out.println( "provider=" + id.getSource() );
10994                 }
10995                 return false;
10996             }
10997             // 
10998             id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10999             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11000                     || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11001                 if ( id != null ) {
11002                     System.out.println( "value   =" + id.getValue() );
11003                     System.out.println( "provider=" + id.getSource() );
11004                 }
11005                 return false;
11006             }
11007             // 
11008             id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11009             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11010                     || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11011                 if ( id != null ) {
11012                     System.out.println( "value   =" + id.getValue() );
11013                     System.out.println( "provider=" + id.getSource() );
11014                 }
11015                 return false;
11016             }
11017             // 
11018             id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11019             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11020                     || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11021                 if ( id != null ) {
11022                     System.out.println( "value   =" + id.getValue() );
11023                     System.out.println( "provider=" + id.getSource() );
11024                 }
11025                 return false;
11026             }
11027             // 
11028             id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11029             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11030                     || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11031                 if ( id != null ) {
11032                     System.out.println( "value   =" + id.getValue() );
11033                     System.out.println( "provider=" + id.getSource() );
11034                 }
11035                 return false;
11036             }
11037             // 
11038             id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11039             if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11040                     || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11041                 if ( id != null ) {
11042                     System.out.println( "value   =" + id.getValue() );
11043                     System.out.println( "provider=" + id.getSource() );
11044                 }
11045                 return false;
11046             }
11047             id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11048             if ( id != null ) {
11049                 System.out.println( "value   =" + id.getValue() );
11050                 System.out.println( "provider=" + id.getSource() );
11051                 return false;
11052             }
11053         }
11054         catch ( final Exception e ) {
11055             e.printStackTrace( System.out );
11056             return false;
11057         }
11058         return true;
11059     }
11060
11061     private static boolean testSequenceWriter() {
11062         try {
11063             final String n = ForesterUtil.LINE_SEPARATOR;
11064             if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11065                 return false;
11066             }
11067             if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11068                 return false;
11069             }
11070             if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11071                 return false;
11072             }
11073             if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11074                 return false;
11075             }
11076             if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11077                     .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11078                 return false;
11079             }
11080             if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11081                     .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11082                 return false;
11083             }
11084         }
11085         catch ( final Exception e ) {
11086             e.printStackTrace();
11087             return false;
11088         }
11089         return true;
11090     }
11091
11092     private static boolean testSpecies() {
11093         try {
11094             final Species s1 = new BasicSpecies( "a" );
11095             final Species s2 = new BasicSpecies( "a" );
11096             final Species s3 = new BasicSpecies( "A" );
11097             final Species s4 = new BasicSpecies( "b" );
11098             if ( !s1.equals( s1 ) ) {
11099                 return false;
11100             }
11101             if ( s1.getSpeciesId().equals( "x" ) ) {
11102                 return false;
11103             }
11104             if ( s1.getSpeciesId().equals( null ) ) {
11105                 return false;
11106             }
11107             if ( !s1.equals( s2 ) ) {
11108                 return false;
11109             }
11110             if ( s1.equals( s3 ) ) {
11111                 return false;
11112             }
11113             if ( s1.hashCode() != s1.hashCode() ) {
11114                 return false;
11115             }
11116             if ( s1.hashCode() != s2.hashCode() ) {
11117                 return false;
11118             }
11119             if ( s1.hashCode() == s3.hashCode() ) {
11120                 return false;
11121             }
11122             if ( s1.compareTo( s1 ) != 0 ) {
11123                 return false;
11124             }
11125             if ( s1.compareTo( s2 ) != 0 ) {
11126                 return false;
11127             }
11128             if ( s1.compareTo( s3 ) != 0 ) {
11129                 return false;
11130             }
11131             if ( s1.compareTo( s4 ) >= 0 ) {
11132                 return false;
11133             }
11134             if ( s4.compareTo( s1 ) <= 0 ) {
11135                 return false;
11136             }
11137             if ( !s4.getSpeciesId().equals( "b" ) ) {
11138                 return false;
11139             }
11140             final Species s5 = new BasicSpecies( " C " );
11141             if ( !s5.getSpeciesId().equals( "C" ) ) {
11142                 return false;
11143             }
11144             if ( s5.equals( s1 ) ) {
11145                 return false;
11146             }
11147         }
11148         catch ( final Exception e ) {
11149             e.printStackTrace( System.out );
11150             return false;
11151         }
11152         return true;
11153     }
11154
11155     private static boolean testSplit() {
11156         try {
11157             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11158             final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11159             //Archaeopteryx.createApplication( p0 );
11160             final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11161             ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11162             ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11163             ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11164             ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11165             ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11166             ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11167             ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11168             ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11169             ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11170             final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11171             // System.out.println( s0.toString() );
11172             //
11173             Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11174             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11175             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11176             if ( s0.match( query_nodes ) ) {
11177                 return false;
11178             }
11179             query_nodes = new HashSet<PhylogenyNode>();
11180             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11181             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11182             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11183             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11184             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11185             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11186             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11187             if ( !s0.match( query_nodes ) ) {
11188                 return false;
11189             }
11190             //
11191             query_nodes = new HashSet<PhylogenyNode>();
11192             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11193             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11194             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11195             if ( !s0.match( query_nodes ) ) {
11196                 return false;
11197             }
11198             //
11199             query_nodes = new HashSet<PhylogenyNode>();
11200             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11201             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11202             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11203             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11204             if ( !s0.match( query_nodes ) ) {
11205                 return false;
11206             }
11207             //
11208             query_nodes = new HashSet<PhylogenyNode>();
11209             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11210             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11211             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11212             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11213             if ( !s0.match( query_nodes ) ) {
11214                 return false;
11215             }
11216             //
11217             query_nodes = new HashSet<PhylogenyNode>();
11218             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11219             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11220             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11221             if ( !s0.match( query_nodes ) ) {
11222                 return false;
11223             }
11224             //
11225             query_nodes = new HashSet<PhylogenyNode>();
11226             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11227             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11228             if ( !s0.match( query_nodes ) ) {
11229                 return false;
11230             }
11231             //
11232             query_nodes = new HashSet<PhylogenyNode>();
11233             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11234             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11235             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11236             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11237             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11238             if ( !s0.match( query_nodes ) ) {
11239                 return false;
11240             }
11241             //
11242             query_nodes = new HashSet<PhylogenyNode>();
11243             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11244             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11245             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11246             if ( !s0.match( query_nodes ) ) {
11247                 return false;
11248             }
11249             //
11250             query_nodes = new HashSet<PhylogenyNode>();
11251             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11252             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11253             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11254             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11255             if ( !s0.match( query_nodes ) ) {
11256                 return false;
11257             }
11258             //
11259             query_nodes = new HashSet<PhylogenyNode>();
11260             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11261             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11262             if ( s0.match( query_nodes ) ) {
11263                 return false;
11264             }
11265             //
11266             query_nodes = new HashSet<PhylogenyNode>();
11267             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11268             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11269             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11270             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11271             if ( s0.match( query_nodes ) ) {
11272                 return false;
11273             }
11274             //
11275             query_nodes = new HashSet<PhylogenyNode>();
11276             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11277             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11278             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11279             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11280             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11281             if ( s0.match( query_nodes ) ) {
11282                 return false;
11283             }
11284             //
11285             query_nodes = new HashSet<PhylogenyNode>();
11286             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11287             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11288             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11289             if ( s0.match( query_nodes ) ) {
11290                 return false;
11291             }
11292             //
11293             query_nodes = new HashSet<PhylogenyNode>();
11294             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11295             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11296             if ( s0.match( query_nodes ) ) {
11297                 return false;
11298             }
11299             //
11300             query_nodes = new HashSet<PhylogenyNode>();
11301             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11302             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11303             if ( s0.match( query_nodes ) ) {
11304                 return false;
11305             }
11306             //
11307             query_nodes = new HashSet<PhylogenyNode>();
11308             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11309             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11310             if ( s0.match( query_nodes ) ) {
11311                 return false;
11312             }
11313             //
11314             query_nodes = new HashSet<PhylogenyNode>();
11315             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11316             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11317             if ( s0.match( query_nodes ) ) {
11318                 return false;
11319             }
11320             //
11321             query_nodes = new HashSet<PhylogenyNode>();
11322             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11323             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11324             if ( s0.match( query_nodes ) ) {
11325                 return false;
11326             }
11327             //
11328             query_nodes = new HashSet<PhylogenyNode>();
11329             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11330             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11331             if ( s0.match( query_nodes ) ) {
11332                 return false;
11333             }
11334             //
11335             query_nodes = new HashSet<PhylogenyNode>();
11336             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11337             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11338             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11339             if ( s0.match( query_nodes ) ) {
11340                 return false;
11341             }
11342             //
11343             query_nodes = new HashSet<PhylogenyNode>();
11344             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11345             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11346             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11347             if ( s0.match( query_nodes ) ) {
11348                 return false;
11349             }
11350             //
11351             query_nodes = new HashSet<PhylogenyNode>();
11352             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11353             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11354             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11355             if ( s0.match( query_nodes ) ) {
11356                 return false;
11357             }
11358             //
11359             query_nodes = new HashSet<PhylogenyNode>();
11360             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11361             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11362             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11363             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11364             if ( s0.match( query_nodes ) ) {
11365                 return false;
11366             }
11367             /////////
11368             //            query_nodes = new HashSet<PhylogenyNode>();
11369             //            query_nodes.add( new PhylogenyNode( "X" ) );
11370             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11371             //            query_nodes.add( new PhylogenyNode( "A" ) );
11372             //            query_nodes.add( new PhylogenyNode( "B" ) );
11373             //            query_nodes.add( new PhylogenyNode( "C" ) );
11374             //            query_nodes.add( new PhylogenyNode( "D" ) );
11375             //            query_nodes.add( new PhylogenyNode( "E" ) );
11376             //            query_nodes.add( new PhylogenyNode( "F" ) );
11377             //            query_nodes.add( new PhylogenyNode( "G" ) );
11378             //            if ( !s0.match( query_nodes ) ) {
11379             //                return false;
11380             //            }
11381             //            query_nodes = new HashSet<PhylogenyNode>();
11382             //            query_nodes.add( new PhylogenyNode( "X" ) );
11383             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11384             //            query_nodes.add( new PhylogenyNode( "A" ) );
11385             //            query_nodes.add( new PhylogenyNode( "B" ) );
11386             //            query_nodes.add( new PhylogenyNode( "C" ) );
11387             //            if ( !s0.match( query_nodes ) ) {
11388             //                return false;
11389             //            }
11390             //            //
11391             //            query_nodes = new HashSet<PhylogenyNode>();
11392             //            query_nodes.add( new PhylogenyNode( "X" ) );
11393             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11394             //            query_nodes.add( new PhylogenyNode( "D" ) );
11395             //            query_nodes.add( new PhylogenyNode( "E" ) );
11396             //            query_nodes.add( new PhylogenyNode( "F" ) );
11397             //            query_nodes.add( new PhylogenyNode( "G" ) );
11398             //            if ( !s0.match( query_nodes ) ) {
11399             //                return false;
11400             //            }
11401             //            //
11402             //            query_nodes = new HashSet<PhylogenyNode>();
11403             //            query_nodes.add( new PhylogenyNode( "X" ) );
11404             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11405             //            query_nodes.add( new PhylogenyNode( "A" ) );
11406             //            query_nodes.add( new PhylogenyNode( "B" ) );
11407             //            query_nodes.add( new PhylogenyNode( "C" ) );
11408             //            query_nodes.add( new PhylogenyNode( "D" ) );
11409             //            if ( !s0.match( query_nodes ) ) {
11410             //                return false;
11411             //            }
11412             //            //
11413             //            query_nodes = new HashSet<PhylogenyNode>();
11414             //            query_nodes.add( new PhylogenyNode( "X" ) );
11415             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11416             //            query_nodes.add( new PhylogenyNode( "E" ) );
11417             //            query_nodes.add( new PhylogenyNode( "F" ) );
11418             //            query_nodes.add( new PhylogenyNode( "G" ) );
11419             //            if ( !s0.match( query_nodes ) ) {
11420             //                return false;
11421             //            }
11422             //            //
11423             //            query_nodes = new HashSet<PhylogenyNode>();
11424             //            query_nodes.add( new PhylogenyNode( "X" ) );
11425             //            query_nodes.add( new PhylogenyNode( "Y" ) );
11426             //            query_nodes.add( new PhylogenyNode( "F" ) );
11427             //            query_nodes.add( new PhylogenyNode( "G" ) );
11428             //            if ( !s0.match( query_nodes ) ) {
11429             //                return false;
11430             //            }
11431             //
11432             query_nodes = new HashSet<PhylogenyNode>();
11433             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11434             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11435             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11436             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11437             if ( s0.match( query_nodes ) ) {
11438                 return false;
11439             }
11440             //
11441             query_nodes = new HashSet<PhylogenyNode>();
11442             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11443             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11444             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11445             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11446             if ( s0.match( query_nodes ) ) {
11447                 return false;
11448             }
11449             ///////////////////////////
11450             //
11451             query_nodes = new HashSet<PhylogenyNode>();
11452             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11453             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11454             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11455             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11456             if ( s0.match( query_nodes ) ) {
11457                 return false;
11458             }
11459             //
11460             query_nodes = new HashSet<PhylogenyNode>();
11461             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11462             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11463             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11464             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11465             if ( s0.match( query_nodes ) ) {
11466                 return false;
11467             }
11468             //
11469             query_nodes = new HashSet<PhylogenyNode>();
11470             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11471             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11472             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11473             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11474             if ( s0.match( query_nodes ) ) {
11475                 return false;
11476             }
11477             //
11478             query_nodes = new HashSet<PhylogenyNode>();
11479             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11480             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11481             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11482             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11483             if ( s0.match( query_nodes ) ) {
11484                 return false;
11485             }
11486             //
11487             query_nodes = new HashSet<PhylogenyNode>();
11488             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11489             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11490             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11491             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11492             if ( s0.match( query_nodes ) ) {
11493                 return false;
11494             }
11495             //
11496             query_nodes = new HashSet<PhylogenyNode>();
11497             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11498             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11499             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11500             if ( s0.match( query_nodes ) ) {
11501                 return false;
11502             }
11503             //
11504             query_nodes = new HashSet<PhylogenyNode>();
11505             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11506             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11507             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11508             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11509             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11510             if ( s0.match( query_nodes ) ) {
11511                 return false;
11512             }
11513             //
11514             query_nodes = new HashSet<PhylogenyNode>();
11515             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11516             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11517             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11518             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11519             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11520             if ( s0.match( query_nodes ) ) {
11521                 return false;
11522             }
11523             //
11524             query_nodes = new HashSet<PhylogenyNode>();
11525             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11526             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11527             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11528             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11529             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11530             if ( s0.match( query_nodes ) ) {
11531                 return false;
11532             }
11533             //
11534             query_nodes = new HashSet<PhylogenyNode>();
11535             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11536             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11537             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11538             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11539             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11540             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11541             if ( s0.match( query_nodes ) ) {
11542                 return false;
11543             }
11544         }
11545         catch ( final Exception e ) {
11546             e.printStackTrace();
11547             return false;
11548         }
11549         return true;
11550     }
11551
11552     private static boolean testSplitStrict() {
11553         try {
11554             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11555             final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11556             final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11557             ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11558             ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11559             ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11560             ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11561             ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11562             ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11563             ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11564             final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11565             Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11566             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11567             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11568             if ( s0.match( query_nodes ) ) {
11569                 return false;
11570             }
11571             query_nodes = new HashSet<PhylogenyNode>();
11572             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11573             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11574             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11575             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11576             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11577             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11578             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11579             if ( !s0.match( query_nodes ) ) {
11580                 return false;
11581             }
11582             //
11583             query_nodes = new HashSet<PhylogenyNode>();
11584             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11585             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11586             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11587             if ( !s0.match( query_nodes ) ) {
11588                 return false;
11589             }
11590             //
11591             query_nodes = new HashSet<PhylogenyNode>();
11592             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11593             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11594             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11595             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11596             if ( !s0.match( query_nodes ) ) {
11597                 return false;
11598             }
11599             //
11600             query_nodes = new HashSet<PhylogenyNode>();
11601             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11602             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11603             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11604             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11605             if ( !s0.match( query_nodes ) ) {
11606                 return false;
11607             }
11608             //
11609             query_nodes = new HashSet<PhylogenyNode>();
11610             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11611             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11612             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11613             if ( !s0.match( query_nodes ) ) {
11614                 return false;
11615             }
11616             //
11617             query_nodes = new HashSet<PhylogenyNode>();
11618             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11619             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11620             if ( !s0.match( query_nodes ) ) {
11621                 return false;
11622             }
11623             //
11624             query_nodes = new HashSet<PhylogenyNode>();
11625             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11626             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11627             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11628             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11629             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11630             if ( !s0.match( query_nodes ) ) {
11631                 return false;
11632             }
11633             //
11634             query_nodes = new HashSet<PhylogenyNode>();
11635             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11636             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11637             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11638             if ( !s0.match( query_nodes ) ) {
11639                 return false;
11640             }
11641             //
11642             query_nodes = new HashSet<PhylogenyNode>();
11643             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11644             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11645             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11646             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11647             if ( !s0.match( query_nodes ) ) {
11648                 return false;
11649             }
11650             //
11651             query_nodes = new HashSet<PhylogenyNode>();
11652             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11653             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11654             if ( s0.match( query_nodes ) ) {
11655                 return false;
11656             }
11657             //
11658             query_nodes = new HashSet<PhylogenyNode>();
11659             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11660             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11661             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11662             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11663             if ( s0.match( query_nodes ) ) {
11664                 return false;
11665             }
11666             //
11667             query_nodes = new HashSet<PhylogenyNode>();
11668             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11669             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11670             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11671             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11672             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11673             if ( s0.match( query_nodes ) ) {
11674                 return false;
11675             }
11676             //
11677             query_nodes = new HashSet<PhylogenyNode>();
11678             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11679             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11680             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11681             if ( s0.match( query_nodes ) ) {
11682                 return false;
11683             }
11684             //
11685             query_nodes = new HashSet<PhylogenyNode>();
11686             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11687             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11688             if ( s0.match( query_nodes ) ) {
11689                 return false;
11690             }
11691             //
11692             query_nodes = new HashSet<PhylogenyNode>();
11693             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11694             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11695             if ( s0.match( query_nodes ) ) {
11696                 return false;
11697             }
11698             //
11699             query_nodes = new HashSet<PhylogenyNode>();
11700             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11701             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11702             if ( s0.match( query_nodes ) ) {
11703                 return false;
11704             }
11705             //
11706             query_nodes = new HashSet<PhylogenyNode>();
11707             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11708             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11709             if ( s0.match( query_nodes ) ) {
11710                 return false;
11711             }
11712             //
11713             query_nodes = new HashSet<PhylogenyNode>();
11714             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11715             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11716             if ( s0.match( query_nodes ) ) {
11717                 return false;
11718             }
11719             //
11720             query_nodes = new HashSet<PhylogenyNode>();
11721             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11722             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11723             if ( s0.match( query_nodes ) ) {
11724                 return false;
11725             }
11726             //
11727             query_nodes = new HashSet<PhylogenyNode>();
11728             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11729             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11730             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11731             if ( s0.match( query_nodes ) ) {
11732                 return false;
11733             }
11734             //
11735             query_nodes = new HashSet<PhylogenyNode>();
11736             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11737             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11738             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11739             if ( s0.match( query_nodes ) ) {
11740                 return false;
11741             }
11742             //
11743             query_nodes = new HashSet<PhylogenyNode>();
11744             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11745             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11746             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11747             if ( s0.match( query_nodes ) ) {
11748                 return false;
11749             }
11750             //
11751             query_nodes = new HashSet<PhylogenyNode>();
11752             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11753             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11754             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11755             query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11756             if ( s0.match( query_nodes ) ) {
11757                 return false;
11758             }
11759         }
11760         catch ( final Exception e ) {
11761             e.printStackTrace();
11762             return false;
11763         }
11764         return true;
11765     }
11766
11767     private static boolean testSubtreeDeletion() {
11768         try {
11769             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11770             final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11771             t1.deleteSubtree( t1.getNode( "A" ), false );
11772             if ( t1.getNumberOfExternalNodes() != 5 ) {
11773                 return false;
11774             }
11775             t1.toNewHampshireX();
11776             t1.deleteSubtree( t1.getNode( "E" ), false );
11777             if ( t1.getNumberOfExternalNodes() != 4 ) {
11778                 return false;
11779             }
11780             t1.toNewHampshireX();
11781             t1.deleteSubtree( t1.getNode( "F" ), false );
11782             if ( t1.getNumberOfExternalNodes() != 3 ) {
11783                 return false;
11784             }
11785             t1.toNewHampshireX();
11786             t1.deleteSubtree( t1.getNode( "D" ), false );
11787             t1.toNewHampshireX();
11788             if ( t1.getNumberOfExternalNodes() != 3 ) {
11789                 return false;
11790             }
11791             t1.deleteSubtree( t1.getNode( "def" ), false );
11792             t1.toNewHampshireX();
11793             if ( t1.getNumberOfExternalNodes() != 2 ) {
11794                 return false;
11795             }
11796             t1.deleteSubtree( t1.getNode( "B" ), false );
11797             t1.toNewHampshireX();
11798             if ( t1.getNumberOfExternalNodes() != 1 ) {
11799                 return false;
11800             }
11801             t1.deleteSubtree( t1.getNode( "C" ), false );
11802             t1.toNewHampshireX();
11803             if ( t1.getNumberOfExternalNodes() != 1 ) {
11804                 return false;
11805             }
11806             t1.deleteSubtree( t1.getNode( "abc" ), false );
11807             t1.toNewHampshireX();
11808             if ( t1.getNumberOfExternalNodes() != 1 ) {
11809                 return false;
11810             }
11811             t1.deleteSubtree( t1.getNode( "r" ), false );
11812             if ( t1.getNumberOfExternalNodes() != 0 ) {
11813                 return false;
11814             }
11815             if ( !t1.isEmpty() ) {
11816                 return false;
11817             }
11818             final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11819             t2.deleteSubtree( t2.getNode( "A" ), false );
11820             t2.toNewHampshireX();
11821             if ( t2.getNumberOfExternalNodes() != 5 ) {
11822                 return false;
11823             }
11824             t2.deleteSubtree( t2.getNode( "abc" ), false );
11825             t2.toNewHampshireX();
11826             if ( t2.getNumberOfExternalNodes() != 3 ) {
11827                 return false;
11828             }
11829             t2.deleteSubtree( t2.getNode( "def" ), false );
11830             t2.toNewHampshireX();
11831             if ( t2.getNumberOfExternalNodes() != 1 ) {
11832                 return false;
11833             }
11834         }
11835         catch ( final Exception e ) {
11836             e.printStackTrace( System.out );
11837             return false;
11838         }
11839         return true;
11840     }
11841
11842     private static boolean testSupportCount() {
11843         try {
11844             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11845             final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11846             final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11847                                                                       + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11848                                                                       + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11849                                                                       + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11850                                                                       + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11851                                                               new NHXParser() );
11852             SupportCount.count( t0_1, phylogenies_1, true, false );
11853             final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11854             final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11855                                                                       + "(((((A,B),C),D),E),((F,G),X))"
11856                                                                       + "(((((A,Y),B),C),D),((F,G),E))"
11857                                                                       + "(((((A,B),C),D),E),(F,G))"
11858                                                                       + "(((((A,B),C),D),E),(F,G))"
11859                                                                       + "(((((A,B),C),D),E),(F,G))"
11860                                                                       + "(((((A,B),C),D),E),(F,G),Z)"
11861                                                                       + "(((((A,B),C),D),E),(F,G))"
11862                                                                       + "((((((A,B),C),D),E),F),G)"
11863                                                                       + "(((((X,Y),F,G),E),((A,B),C)),D)",
11864                                                               new NHXParser() );
11865             SupportCount.count( t0_2, phylogenies_2, true, false );
11866             final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11867             while ( it.hasNext() ) {
11868                 final PhylogenyNode n = it.next();
11869                 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11870                     return false;
11871                 }
11872             }
11873             final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11874             final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11875                     + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11876             SupportCount.count( t0_3, phylogenies_3, true, false );
11877             t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11878             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11879                 return false;
11880             }
11881             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11882                 return false;
11883             }
11884             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11885                 return false;
11886             }
11887             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11888                 return false;
11889             }
11890             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11891                 return false;
11892             }
11893             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11894                 return false;
11895             }
11896             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11897                 return false;
11898             }
11899             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11900                 return false;
11901             }
11902             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11903                 return false;
11904             }
11905             if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11906                 return false;
11907             }
11908             final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11909             final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11910                     + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11911             SupportCount.count( t0_4, phylogenies_4, true, false );
11912             t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11913             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11914                 return false;
11915             }
11916             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11917                 return false;
11918             }
11919             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11920                 return false;
11921             }
11922             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11923                 return false;
11924             }
11925             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11926                 return false;
11927             }
11928             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11929                 return false;
11930             }
11931             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11932                 return false;
11933             }
11934             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11935                 return false;
11936             }
11937             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11938                 return false;
11939             }
11940             if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11941                 return false;
11942             }
11943             Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11944             final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11945             double d = SupportCount.compare( b1, a, true, true, true );
11946             if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11947                 return false;
11948             }
11949             a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11950             final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11951             d = SupportCount.compare( b2, a, true, true, true );
11952             if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11953                 return false;
11954             }
11955             a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11956             final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11957             d = SupportCount.compare( b3, a, true, true, true );
11958             if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11959                 return false;
11960             }
11961             a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11962             final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11963             d = SupportCount.compare( b4, a, true, true, false );
11964             if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11965                 return false;
11966             }
11967         }
11968         catch ( final Exception e ) {
11969             e.printStackTrace( System.out );
11970             return false;
11971         }
11972         return true;
11973     }
11974
11975     private static boolean testSupportTransfer() {
11976         try {
11977             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11978             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)",
11979                                                  new NHXParser() )[ 0 ];
11980             final Phylogeny p2 = factory
11981                     .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 ];
11982             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11983                 return false;
11984             }
11985             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11986                 return false;
11987             }
11988             support_transfer.moveBranchLengthsToBootstrap( p1 );
11989             support_transfer.transferSupportValues( p1, p2 );
11990             if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11991                 return false;
11992             }
11993             if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11994                 return false;
11995             }
11996             if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11997                 return false;
11998             }
11999             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12000                 return false;
12001             }
12002             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12003                 return false;
12004             }
12005             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12006                 return false;
12007             }
12008             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12009                 return false;
12010             }
12011             if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12012                 return false;
12013             }
12014         }
12015         catch ( final Exception e ) {
12016             e.printStackTrace( System.out );
12017             return false;
12018         }
12019         return true;
12020     }
12021
12022     private static boolean testTaxonomyExtraction() {
12023         try {
12024             final PhylogenyNode n0 = PhylogenyNode
12025                     .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12026             if ( n0.getNodeData().isHasTaxonomy() ) {
12027                 return false;
12028             }
12029             final PhylogenyNode n1 = PhylogenyNode
12030                     .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12031             if ( n1.getNodeData().isHasTaxonomy() ) {
12032                 System.out.println( n1.toString() );
12033                 return false;
12034             }
12035             final PhylogenyNode n2x = PhylogenyNode
12036                     .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12037             if ( n2x.getNodeData().isHasTaxonomy() ) {
12038                 return false;
12039             }
12040             final PhylogenyNode n3 = PhylogenyNode
12041                     .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12042             if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12043                 System.out.println( n3.toString() );
12044                 return false;
12045             }
12046             final PhylogenyNode n4 = PhylogenyNode
12047                     .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12048             if ( n4.getNodeData().isHasTaxonomy() ) {
12049                 System.out.println( n4.toString() );
12050                 return false;
12051             }
12052             final PhylogenyNode n5 = PhylogenyNode
12053                     .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12054             if ( n5.getNodeData().isHasTaxonomy() ) {
12055                 System.out.println( n5.toString() );
12056                 return false;
12057             }
12058             final PhylogenyNode n6 = PhylogenyNode
12059                     .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12060             if ( n6.getNodeData().isHasTaxonomy() ) {
12061                 System.out.println( n6.toString() );
12062                 return false;
12063             }
12064             final PhylogenyNode n7 = PhylogenyNode
12065                     .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12066             if ( n7.getNodeData().isHasTaxonomy() ) {
12067                 System.out.println( n7.toString() );
12068                 return false;
12069             }
12070             final PhylogenyNode n8 = PhylogenyNode
12071                     .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12072             if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12073                 System.out.println( n8.toString() );
12074                 return false;
12075             }
12076             final PhylogenyNode n9 = PhylogenyNode
12077                     .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12078             if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12079                 System.out.println( n9.toString() );
12080                 return false;
12081             }
12082             final PhylogenyNode n10x = PhylogenyNode
12083                     .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12084             if ( n10x.getNodeData().isHasTaxonomy() ) {
12085                 System.out.println( n10x.toString() );
12086                 return false;
12087             }
12088             final PhylogenyNode n10xx = PhylogenyNode
12089                     .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12090             if ( n10xx.getNodeData().isHasTaxonomy() ) {
12091                 System.out.println( n10xx.toString() );
12092                 return false;
12093             }
12094             final PhylogenyNode n10 = PhylogenyNode
12095                     .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12096             if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12097                 System.out.println( n10.toString() );
12098                 return false;
12099             }
12100             final PhylogenyNode n11 = PhylogenyNode
12101                     .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12102             if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12103                 System.out.println( n11.toString() );
12104                 return false;
12105             }
12106             final PhylogenyNode n12 = PhylogenyNode
12107                     .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12108                                                   NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12109             if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12110                 System.out.println( n12.toString() );
12111                 return false;
12112             }
12113             final PhylogenyNode n13 = PhylogenyNode
12114                     .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12115             if ( n13.getNodeData().isHasTaxonomy() ) {
12116                 System.out.println( n13.toString() );
12117                 return false;
12118             }
12119             final PhylogenyNode n14 = PhylogenyNode
12120                     .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12121             if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12122                 System.out.println( n14.toString() );
12123                 return false;
12124             }
12125             final PhylogenyNode n15 = PhylogenyNode
12126                     .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12127             if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12128                 System.out.println( n15.toString() );
12129                 return false;
12130             }
12131             final PhylogenyNode n16 = PhylogenyNode
12132                     .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12133             if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12134                 System.out.println( n16.toString() );
12135                 return false;
12136             }
12137             final PhylogenyNode n17 = PhylogenyNode
12138                     .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12139             if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12140                 System.out.println( n17.toString() );
12141                 return false;
12142             }
12143             //
12144             final PhylogenyNode n18 = PhylogenyNode
12145                     .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12146             if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12147                 System.out.println( n18.toString() );
12148                 return false;
12149             }
12150             final PhylogenyNode n19 = PhylogenyNode
12151                     .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12152                                                   NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12153             if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12154                 System.out.println( n19.toString() );
12155                 return false;
12156             }
12157             final PhylogenyNode n20 = PhylogenyNode
12158                     .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12159             if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12160                 System.out.println( n20.toString() );
12161                 return false;
12162             }
12163             final PhylogenyNode n21 = PhylogenyNode
12164                     .createInstanceFromNhxString( "Mus musculus musculus K392",
12165                                                   NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12166             if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12167                 System.out.println( n21.toString() );
12168                 return false;
12169             }
12170         }
12171         catch ( final Exception e ) {
12172             e.printStackTrace( System.out );
12173             return false;
12174         }
12175         return true;
12176     }
12177
12178     private static boolean testTreeCopy() {
12179         try {
12180             final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12181             final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12182             final Phylogeny t1 = t0.copy();
12183             if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12184                 return false;
12185             }
12186             if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12187                 return false;
12188             }
12189             t0.deleteSubtree( t0.getNode( "c" ), true );
12190             t0.deleteSubtree( t0.getNode( "a" ), true );
12191             t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12192             t0.getNode( "b" ).setName( "Bee" );
12193             if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12194                 return false;
12195             }
12196             if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12197                 return false;
12198             }
12199             t0.deleteSubtree( t0.getNode( "e" ), true );
12200             t0.deleteSubtree( t0.getNode( "Bee" ), true );
12201             t0.deleteSubtree( t0.getNode( "d" ), true );
12202             if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12203                 return false;
12204             }
12205         }
12206         catch ( final Exception e ) {
12207             e.printStackTrace();
12208             return false;
12209         }
12210         return true;
12211     }
12212
12213     private static boolean testTreeMethods() {
12214         try {
12215             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12216             final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12217             PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12218             if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12219                 System.out.println( t0.toNewHampshireX() );
12220                 return false;
12221             }
12222             final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12223             PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12224             if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12225                 return false;
12226             }
12227             if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12228                 return false;
12229             }
12230             if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12231                 return false;
12232             }
12233         }
12234         catch ( final Exception e ) {
12235             e.printStackTrace( System.out );
12236             return false;
12237         }
12238         return true;
12239     }
12240
12241     private static boolean testUniprotEntryRetrieval() {
12242         try {
12243             final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12244             if ( !entry.getAccession().equals( "P12345" ) ) {
12245                 return false;
12246             }
12247             if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12248                 return false;
12249             }
12250             if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12251                 return false;
12252             }
12253             if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12254                 return false;
12255             }
12256             if ( !entry.getGeneName().equals( "GOT2" ) ) {
12257                 return false;
12258             }
12259             if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12260                 return false;
12261             }
12262         }
12263         catch ( final IOException e ) {
12264             System.out.println();
12265             System.out.println( "the following might be due to absence internet connection:" );
12266             e.printStackTrace( System.out );
12267             return true;
12268         }
12269         catch ( final Exception e ) {
12270             return false;
12271         }
12272         return true;
12273     }
12274
12275     private static boolean testUniprotTaxonomySearch() {
12276         try {
12277             List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12278                                                                                                  10 );
12279             if ( results.size() != 1 ) {
12280                 return false;
12281             }
12282             if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12283                 return false;
12284             }
12285             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12286                 return false;
12287             }
12288             if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12289                 return false;
12290             }
12291             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12292                 return false;
12293             }
12294             if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12295                 return false;
12296             }
12297             results = null;
12298             results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12299             if ( results.size() != 1 ) {
12300                 return false;
12301             }
12302             if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12303                 return false;
12304             }
12305             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12306                 return false;
12307             }
12308             if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12309                 return false;
12310             }
12311             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12312                 return false;
12313             }
12314             if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12315                 return false;
12316             }
12317             results = null;
12318             results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12319             if ( results.size() != 1 ) {
12320                 return false;
12321             }
12322             if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12323                 return false;
12324             }
12325             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12326                 return false;
12327             }
12328             if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12329                 return false;
12330             }
12331             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12332                 return false;
12333             }
12334             if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12335                 return false;
12336             }
12337             results = null;
12338             results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12339             if ( results.size() != 1 ) {
12340                 return false;
12341             }
12342             if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12343                 return false;
12344             }
12345             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12346                 return false;
12347             }
12348             if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12349                 return false;
12350             }
12351             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12352                 return false;
12353             }
12354             if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12355                 return false;
12356             }
12357             if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12358                 return false;
12359             }
12360             if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12361                 return false;
12362             }
12363             if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12364                     .equals( "Nematostella vectensis" ) ) {
12365                 System.out.println( results.get( 0 ).getLineage() );
12366                 return false;
12367             }
12368             //
12369             results = null;
12370             results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12371             if ( results.size() != 1 ) {
12372                 return false;
12373             }
12374             if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12375                 return false;
12376             }
12377             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12378                 return false;
12379             }
12380             if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12381                 return false;
12382             }
12383             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12384                 return false;
12385             }
12386             if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12387                 return false;
12388             }
12389             if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12390                     .equals( "Xenopus tropicalis" ) ) {
12391                 System.out.println( results.get( 0 ).getLineage() );
12392                 return false;
12393             }
12394             //
12395             results = null;
12396             results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12397             if ( results.size() != 1 ) {
12398                 return false;
12399             }
12400             if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12401                 return false;
12402             }
12403             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12404                 return false;
12405             }
12406             if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12407                 return false;
12408             }
12409             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12410                 return false;
12411             }
12412             if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12413                 return false;
12414             }
12415             if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12416                     .equals( "Xenopus tropicalis" ) ) {
12417                 System.out.println( results.get( 0 ).getLineage() );
12418                 return false;
12419             }
12420             //
12421             results = null;
12422             results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12423             if ( results.size() != 1 ) {
12424                 return false;
12425             }
12426             if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12427                 return false;
12428             }
12429             if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12430                 return false;
12431             }
12432             if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12433                 return false;
12434             }
12435             if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12436                 return false;
12437             }
12438             if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12439                 return false;
12440             }
12441             if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12442                     .equals( "Xenopus tropicalis" ) ) {
12443                 System.out.println( results.get( 0 ).getLineage() );
12444                 return false;
12445             }
12446         }
12447         catch ( final IOException e ) {
12448             System.out.println();
12449             System.out.println( "the following might be due to absence internet connection:" );
12450             e.printStackTrace( System.out );
12451             return true;
12452         }
12453         catch ( final Exception e ) {
12454             return false;
12455         }
12456         return true;
12457     }
12458
12459     private static boolean testWabiTxSearch() {
12460         try {
12461             String result = "";
12462             result = TxSearch.searchSimple( "nematostella" );
12463             result = TxSearch.getTxId( "nematostella" );
12464             if ( !result.equals( "45350" ) ) {
12465                 return false;
12466             }
12467             result = TxSearch.getTxName( "45350" );
12468             if ( !result.equals( "Nematostella" ) ) {
12469                 return false;
12470             }
12471             result = TxSearch.getTxId( "nematostella vectensis" );
12472             if ( !result.equals( "45351" ) ) {
12473                 return false;
12474             }
12475             result = TxSearch.getTxName( "45351" );
12476             if ( !result.equals( "Nematostella vectensis" ) ) {
12477                 return false;
12478             }
12479             result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12480             if ( !result.equals( "536089" ) ) {
12481                 return false;
12482             }
12483             result = TxSearch.getTxName( "536089" );
12484             if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12485                 return false;
12486             }
12487             final List<String> queries = new ArrayList<String>();
12488             queries.add( "Campylobacter coli" );
12489             queries.add( "Escherichia coli" );
12490             queries.add( "Arabidopsis" );
12491             queries.add( "Trichoplax" );
12492             queries.add( "Samanea saman" );
12493             queries.add( "Kluyveromyces marxianus" );
12494             queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12495             queries.add( "Bornavirus parrot/PDD/2008" );
12496             final List<RANKS> ranks = new ArrayList<RANKS>();
12497             ranks.add( RANKS.SUPERKINGDOM );
12498             ranks.add( RANKS.KINGDOM );
12499             ranks.add( RANKS.FAMILY );
12500             ranks.add( RANKS.GENUS );
12501             ranks.add( RANKS.TRIBE );
12502             result = TxSearch.searchLineage( queries, ranks );
12503             result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12504             result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12505         }
12506         catch ( final Exception e ) {
12507             System.out.println();
12508             System.out.println( "the following might be due to absence internet connection:" );
12509             e.printStackTrace( System.out );
12510             return false;
12511         }
12512         return true;
12513     }
12514 }