2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
40 import org.forester.application.support_transfer;
41 import org.forester.archaeopteryx.AptxUtil;
42 import org.forester.development.DevelopmentTools;
43 import org.forester.evoinference.TestPhylogenyReconstruction;
44 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
46 import org.forester.go.TestGo;
47 import org.forester.io.parsers.FastaParser;
48 import org.forester.io.parsers.GeneralMsaParser;
49 import org.forester.io.parsers.HmmscanPerDomainTableParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
51 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
52 import org.forester.io.parsers.nexus.NexusCharactersParser;
53 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
54 import org.forester.io.parsers.nhx.NHXParser;
55 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
56 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
57 import org.forester.io.parsers.tol.TolParser;
58 import org.forester.io.parsers.util.ParserUtils;
59 import org.forester.io.writers.PhylogenyWriter;
60 import org.forester.io.writers.SequenceWriter;
61 import org.forester.msa.BasicMsa;
62 import org.forester.msa.Mafft;
63 import org.forester.msa.Msa;
64 import org.forester.msa.MsaInferrer;
65 import org.forester.msa.MsaMethods;
66 import org.forester.pccx.TestPccx;
67 import org.forester.phylogeny.Phylogeny;
68 import org.forester.phylogeny.PhylogenyBranch;
69 import org.forester.phylogeny.PhylogenyMethods;
70 import org.forester.phylogeny.PhylogenyNode;
71 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
72 import org.forester.phylogeny.data.Accession;
73 import org.forester.phylogeny.data.BinaryCharacters;
74 import org.forester.phylogeny.data.BranchWidth;
75 import org.forester.phylogeny.data.Confidence;
76 import org.forester.phylogeny.data.Distribution;
77 import org.forester.phylogeny.data.DomainArchitecture;
78 import org.forester.phylogeny.data.Event;
79 import org.forester.phylogeny.data.Identifier;
80 import org.forester.phylogeny.data.PhylogenyData;
81 import org.forester.phylogeny.data.PhylogenyDataUtil;
82 import org.forester.phylogeny.data.Polygon;
83 import org.forester.phylogeny.data.PropertiesMap;
84 import org.forester.phylogeny.data.Property;
85 import org.forester.phylogeny.data.Property.AppliesTo;
86 import org.forester.phylogeny.data.ProteinDomain;
87 import org.forester.phylogeny.data.Taxonomy;
88 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
89 import org.forester.phylogeny.factories.PhylogenyFactory;
90 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
91 import org.forester.protein.Protein;
92 import org.forester.rio.TestRIO;
93 import org.forester.sdi.SDI;
94 import org.forester.sdi.SDIR;
95 import org.forester.sdi.TestGSDI;
96 import org.forester.sequence.BasicSequence;
97 import org.forester.sequence.Sequence;
98 import org.forester.surfacing.TestSurfacing;
99 import org.forester.tools.ConfidenceAssessor;
100 import org.forester.tools.SupportCount;
101 import org.forester.tools.TreeSplitMatrix;
102 import org.forester.util.AsciiHistogram;
103 import org.forester.util.BasicDescriptiveStatistics;
104 import org.forester.util.BasicTable;
105 import org.forester.util.BasicTableParser;
106 import org.forester.util.DescriptiveStatistics;
107 import org.forester.util.ForesterConstants;
108 import org.forester.util.ForesterUtil;
109 import org.forester.util.GeneralTable;
110 import org.forester.util.SequenceIdParser;
111 import org.forester.ws.seqdb.SequenceDatabaseEntry;
112 import org.forester.ws.seqdb.SequenceDbWsTools;
113 import org.forester.ws.seqdb.UniProtTaxonomy;
114 import org.forester.ws.wabi.TxSearch;
115 import org.forester.ws.wabi.TxSearch.RANKS;
116 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
117 import org.forester.ws.wabi.TxSearch.TAX_RANK;
119 @SuppressWarnings( "unused")
120 public final class Test {
122 private final static double ZERO_DIFF = 1.0E-9;
123 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
124 + ForesterUtil.getFileSeparator() + "test_data"
125 + ForesterUtil.getFileSeparator();
126 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
127 + ForesterUtil.getFileSeparator() + "resources"
128 + ForesterUtil.getFileSeparator();
129 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
130 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
131 + ForesterConstants.PHYLO_XML_VERSION + "/"
132 + ForesterConstants.PHYLO_XML_XSD;
133 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
134 + ForesterConstants.PHYLO_XML_VERSION + "/"
135 + ForesterConstants.PHYLO_XML_XSD;
137 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
138 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
142 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
143 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
146 public static boolean isEqual( final double a, final double b ) {
147 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
150 public static void main( final String[] args ) {
151 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
152 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
154 Locale.setDefault( Locale.US );
155 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
158 System.out.print( "[Test if directory with files for testing exists/is readable: " );
159 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
160 System.out.println( "OK.]" );
163 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
164 System.out.println( "Testing aborted." );
167 System.out.print( "[Test if resources directory exists/is readable: " );
168 if ( testDir( PATH_TO_RESOURCES ) ) {
169 System.out.println( "OK.]" );
172 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
173 System.out.println( "Testing aborted." );
176 final long start_time = new Date().getTime();
177 System.out.print( "Sequence writer: " );
178 if ( testSequenceWriter() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Sequence id parsing: " );
187 if ( testSequenceIdParsing() ) {
188 System.out.println( "OK." );
192 System.out.println( "failed." );
195 System.out.print( "Hmmscan output parser: " );
196 if ( testHmmscanOutputParser() ) {
197 System.out.println( "OK." );
201 System.out.println( "failed." );
204 System.out.print( "Basic node methods: " );
205 if ( Test.testBasicNodeMethods() ) {
206 System.out.println( "OK." );
210 System.out.println( "failed." );
213 System.out.print( "Taxonomy code extraction: " );
214 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
215 System.out.println( "OK." );
219 System.out.println( "failed." );
222 System.out.print( "SN extraction: " );
223 if ( Test.testExtractSNFromNodeName() ) {
224 System.out.println( "OK." );
228 System.out.println( "failed." );
231 System.out.print( "Taxonomy extraction (general): " );
232 if ( Test.testTaxonomyExtraction() ) {
233 System.out.println( "OK." );
237 System.out.println( "failed." );
241 System.out.print( "UniProtKB id extraction: " );
242 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
243 System.out.println( "OK." );
247 System.out.println( "failed." );
250 System.out.print( "Uri for Aptx web sequence accession: " );
251 if ( Test.testCreateUriForSeqWeb() ) {
252 System.out.println( "OK." );
256 System.out.println( "failed." );
259 System.out.print( "Basic node construction and parsing of NHX (node level): " );
260 if ( Test.testNHXNodeParsing() ) {
261 System.out.println( "OK." );
265 System.out.println( "failed." );
268 System.out.print( "NHX parsing iterating: " );
269 if ( Test.testNHParsingIter() ) {
270 System.out.println( "OK." );
274 System.out.println( "failed." );
277 System.out.print( "NH parsing: " );
278 if ( Test.testNHParsing() ) {
279 System.out.println( "OK." );
283 System.out.println( "failed." );
286 System.out.print( "Conversion to NHX (node level): " );
287 if ( Test.testNHXconversion() ) {
288 System.out.println( "OK." );
292 System.out.println( "failed." );
295 System.out.print( "NHX parsing: " );
296 if ( Test.testNHXParsing() ) {
297 System.out.println( "OK." );
301 System.out.println( "failed." );
304 System.out.print( "NHX parsing with quotes: " );
305 if ( Test.testNHXParsingQuotes() ) {
306 System.out.println( "OK." );
310 System.out.println( "failed." );
313 System.out.print( "NHX parsing (MrBayes): " );
314 if ( Test.testNHXParsingMB() ) {
315 System.out.println( "OK." );
319 System.out.println( "failed." );
322 System.out.print( "Nexus characters parsing: " );
323 if ( Test.testNexusCharactersParsing() ) {
324 System.out.println( "OK." );
328 System.out.println( "failed." );
331 System.out.print( "Nexus tree parsing iterating: " );
332 if ( Test.testNexusTreeParsingIterating() ) {
333 System.out.println( "OK." );
337 System.out.println( "failed." );
340 System.out.print( "Nexus tree parsing: " );
341 if ( Test.testNexusTreeParsing() ) {
342 System.out.println( "OK." );
346 System.out.println( "failed." );
349 System.out.print( "Nexus tree parsing (translating): " );
350 if ( Test.testNexusTreeParsingTranslating() ) {
351 System.out.println( "OK." );
355 System.out.println( "failed." );
358 System.out.print( "Nexus matrix parsing: " );
359 if ( Test.testNexusMatrixParsing() ) {
360 System.out.println( "OK." );
364 System.out.println( "failed." );
367 System.out.print( "Basic phyloXML parsing: " );
368 if ( Test.testBasicPhyloXMLparsing() ) {
369 System.out.println( "OK." );
373 System.out.println( "failed." );
376 System.out.print( "Basic phyloXML parsing (validating against schema): " );
377 if ( testBasicPhyloXMLparsingValidating() ) {
378 System.out.println( "OK." );
382 System.out.println( "failed." );
385 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
386 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
387 System.out.println( "OK." );
391 System.out.println( "failed." );
394 System.out.print( "phyloXML Distribution Element: " );
395 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
396 System.out.println( "OK." );
400 System.out.println( "failed." );
403 System.out.print( "Tol XML parsing: " );
404 if ( Test.testBasicTolXMLparsing() ) {
405 System.out.println( "OK." );
409 System.out.println( "failed." );
412 System.out.print( "Copying of node data: " );
413 if ( Test.testCopyOfNodeData() ) {
414 System.out.println( "OK." );
418 System.out.println( "failed." );
421 System.out.print( "Basic tree methods: " );
422 if ( Test.testBasicTreeMethods() ) {
423 System.out.println( "OK." );
427 System.out.println( "failed." );
430 System.out.print( "Tree methods: " );
431 if ( Test.testTreeMethods() ) {
432 System.out.println( "OK." );
436 System.out.println( "failed." );
439 System.out.print( "Postorder Iterator: " );
440 if ( Test.testPostOrderIterator() ) {
441 System.out.println( "OK." );
445 System.out.println( "failed." );
448 System.out.print( "Preorder Iterator: " );
449 if ( Test.testPreOrderIterator() ) {
450 System.out.println( "OK." );
454 System.out.println( "failed." );
457 System.out.print( "Levelorder Iterator: " );
458 if ( Test.testLevelOrderIterator() ) {
459 System.out.println( "OK." );
463 System.out.println( "failed." );
466 System.out.print( "Re-id methods: " );
467 if ( Test.testReIdMethods() ) {
468 System.out.println( "OK." );
472 System.out.println( "failed." );
475 System.out.print( "Methods on last external nodes: " );
476 if ( Test.testLastExternalNodeMethods() ) {
477 System.out.println( "OK." );
481 System.out.println( "failed." );
484 System.out.print( "Methods on external nodes: " );
485 if ( Test.testExternalNodeRelatedMethods() ) {
486 System.out.println( "OK." );
490 System.out.println( "failed." );
493 System.out.print( "Deletion of external nodes: " );
494 if ( Test.testDeletionOfExternalNodes() ) {
495 System.out.println( "OK." );
499 System.out.println( "failed." );
502 System.out.print( "Subtree deletion: " );
503 if ( Test.testSubtreeDeletion() ) {
504 System.out.println( "OK." );
508 System.out.println( "failed." );
511 System.out.print( "Phylogeny branch: " );
512 if ( Test.testPhylogenyBranch() ) {
513 System.out.println( "OK." );
517 System.out.println( "failed." );
520 System.out.print( "Rerooting: " );
521 if ( Test.testRerooting() ) {
522 System.out.println( "OK." );
526 System.out.println( "failed." );
529 System.out.print( "Mipoint rooting: " );
530 if ( Test.testMidpointrooting() ) {
531 System.out.println( "OK." );
535 System.out.println( "failed." );
538 System.out.print( "Node removal: " );
539 if ( Test.testNodeRemoval() ) {
540 System.out.println( "OK." );
544 System.out.println( "failed." );
547 System.out.print( "Support count: " );
548 if ( Test.testSupportCount() ) {
549 System.out.println( "OK." );
553 System.out.println( "failed." );
556 System.out.print( "Support transfer: " );
557 if ( Test.testSupportTransfer() ) {
558 System.out.println( "OK." );
562 System.out.println( "failed." );
565 System.out.print( "Finding of LCA: " );
566 if ( Test.testGetLCA() ) {
567 System.out.println( "OK." );
571 System.out.println( "failed." );
574 System.out.print( "Finding of LCA 2: " );
575 if ( Test.testGetLCA2() ) {
576 System.out.println( "OK." );
580 System.out.println( "failed." );
583 System.out.print( "Calculation of distance between nodes: " );
584 if ( Test.testGetDistance() ) {
585 System.out.println( "OK." );
589 System.out.println( "failed." );
592 System.out.print( "Descriptive statistics: " );
593 if ( Test.testDescriptiveStatistics() ) {
594 System.out.println( "OK." );
598 System.out.println( "failed." );
601 System.out.print( "Data objects and methods: " );
602 if ( Test.testDataObjects() ) {
603 System.out.println( "OK." );
607 System.out.println( "failed." );
610 System.out.print( "Properties map: " );
611 if ( Test.testPropertiesMap() ) {
612 System.out.println( "OK." );
616 System.out.println( "failed." );
619 System.out.print( "SDIse: " );
620 if ( Test.testSDIse() ) {
621 System.out.println( "OK." );
625 System.out.println( "failed." );
628 System.out.print( "SDIunrooted: " );
629 if ( Test.testSDIunrooted() ) {
630 System.out.println( "OK." );
634 System.out.println( "failed." );
637 System.out.print( "GSDI: " );
638 if ( TestGSDI.test() ) {
639 System.out.println( "OK." );
643 System.out.println( "failed." );
646 System.out.print( "RIO: " );
647 if ( TestRIO.test() ) {
648 System.out.println( "OK." );
652 System.out.println( "failed." );
655 System.out.print( "Phylogeny reconstruction:" );
656 System.out.println();
657 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
658 System.out.println( "OK." );
662 System.out.println( "failed." );
665 System.out.print( "Analysis of domain architectures: " );
666 System.out.println();
667 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
668 System.out.println( "OK." );
672 System.out.println( "failed." );
675 System.out.print( "GO: " );
676 System.out.println();
677 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
678 System.out.println( "OK." );
682 System.out.println( "failed." );
685 System.out.print( "Modeling tools: " );
686 if ( TestPccx.test() ) {
687 System.out.println( "OK." );
691 System.out.println( "failed." );
694 System.out.print( "Split Matrix strict: " );
695 if ( Test.testSplitStrict() ) {
696 System.out.println( "OK." );
700 System.out.println( "failed." );
703 System.out.print( "Split Matrix: " );
704 if ( Test.testSplit() ) {
705 System.out.println( "OK." );
709 System.out.println( "failed." );
712 System.out.print( "Confidence Assessor: " );
713 if ( Test.testConfidenceAssessor() ) {
714 System.out.println( "OK." );
718 System.out.println( "failed." );
721 System.out.print( "Basic table: " );
722 if ( Test.testBasicTable() ) {
723 System.out.println( "OK." );
727 System.out.println( "failed." );
730 System.out.print( "General table: " );
731 if ( Test.testGeneralTable() ) {
732 System.out.println( "OK." );
736 System.out.println( "failed." );
739 System.out.print( "Amino acid sequence: " );
740 if ( Test.testAminoAcidSequence() ) {
741 System.out.println( "OK." );
745 System.out.println( "failed." );
748 System.out.print( "General MSA parser: " );
749 if ( Test.testGeneralMsaParser() ) {
750 System.out.println( "OK." );
754 System.out.println( "failed." );
757 System.out.print( "Fasta parser for msa: " );
758 if ( Test.testFastaParser() ) {
759 System.out.println( "OK." );
763 System.out.println( "failed." );
766 System.out.print( "Creation of balanced phylogeny: " );
767 if ( Test.testCreateBalancedPhylogeny() ) {
768 System.out.println( "OK." );
772 System.out.println( "failed." );
775 System.out.print( "EMBL Entry Retrieval: " );
776 if ( Test.testEmblEntryRetrieval() ) {
777 System.out.println( "OK." );
781 System.out.println( "failed." );
784 System.out.print( "Uniprot Entry Retrieval: " );
785 if ( Test.testUniprotEntryRetrieval() ) {
786 System.out.println( "OK." );
790 System.out.println( "failed." );
793 System.out.print( "Uniprot Taxonomy Search: " );
794 if ( Test.testUniprotTaxonomySearch() ) {
795 System.out.println( "OK." );
799 System.out.println( "failed." );
804 final String os = ForesterUtil.OS_NAME.toLowerCase();
805 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
806 path = "/usr/local/bin/mafft";
808 else if ( os.indexOf( "win" ) >= 0 ) {
809 path = "C:\\Program Files\\mafft-win\\mafft.bat";
812 path = "/home/czmasek/bin/mafft";
814 if ( !MsaInferrer.isInstalled( path ) ) {
817 if ( !MsaInferrer.isInstalled( path ) ) {
818 path = "/usr/local/bin/mafft";
820 if ( MsaInferrer.isInstalled( path ) ) {
821 System.out.print( "MAFFT (external program): " );
822 if ( Test.testMafft( path ) ) {
823 System.out.println( "OK." );
827 System.out.println( "failed [will not count towards failed tests]" );
831 System.out.print( "Next nodes with collapsed: " );
832 if ( Test.testNextNodeWithCollapsing() ) {
833 System.out.println( "OK." );
837 System.out.println( "failed." );
840 System.out.print( "Simple MSA quality: " );
841 if ( Test.testMsaQualityMethod() ) {
842 System.out.println( "OK." );
846 System.out.println( "failed." );
849 System.out.println();
850 final Runtime rt = java.lang.Runtime.getRuntime();
851 final long free_memory = rt.freeMemory() / 1000000;
852 final long total_memory = rt.totalMemory() / 1000000;
853 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
854 + free_memory + "MB, total memory: " + total_memory + "MB)" );
855 System.out.println();
856 System.out.println( "Successful tests: " + succeeded );
857 System.out.println( "Failed tests: " + failed );
858 System.out.println();
860 System.out.println( "OK." );
863 System.out.println( "Not OK." );
867 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
869 PhylogenyNode n = new PhylogenyNode();
870 n.setName( "tr|B3RJ64" );
871 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
874 n.setName( "tr.B3RJ64" );
875 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
878 n.setName( "tr=B3RJ64" );
879 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
882 n.setName( "tr-B3RJ64" );
883 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
886 n.setName( "tr/B3RJ64" );
887 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
890 n.setName( "tr\\B3RJ64" );
891 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
894 n.setName( "tr_B3RJ64" );
895 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
898 n.setName( " tr|B3RJ64 " );
899 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
902 n.setName( "-tr|B3RJ64-" );
903 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
906 n.setName( "-tr=B3RJ64-" );
907 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
910 n.setName( "_tr=B3RJ64_" );
911 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
914 n.setName( " tr_tr|B3RJ64_sp|123 " );
915 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
918 n.setName( "sp|B3RJ64" );
919 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
922 n.setName( "ssp|B3RJ64" );
923 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
926 n.setName( "sp|B3RJ64C" );
927 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
930 n.setName( "sp B3RJ64" );
931 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
934 n.setName( "sp|B3RJ6X" );
935 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
938 n.setName( "sp|B3RJ6" );
939 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
942 n.setName( "K1PYK7_CRAGI" );
943 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
946 n.setName( "K1PYK7_PEA" );
947 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PEA" ) ) {
950 n.setName( "K1PYK7_RAT" );
951 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_RAT" ) ) {
954 n.setName( "K1PYK7_PIG" );
955 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
958 n.setName( "~K1PYK7_PIG~" );
959 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
962 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
963 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
966 n.setName( "K1PYKX_CRAGI" );
967 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
970 n.setName( "XXXXX_CRAGI" );
971 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "XXXXX_CRAGI" ) ) {
974 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
975 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "H3IB65" ) ) {
978 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
979 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
982 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
983 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "Q86U06" ) ) {
986 n = new PhylogenyNode();
987 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
988 seq.setSymbol( "K1PYK7_CRAGI" );
989 n.getNodeData().addSequence( seq );
990 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
993 seq.setSymbol( "tr|B3RJ64" );
994 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
997 n = new PhylogenyNode();
998 seq = new org.forester.phylogeny.data.Sequence();
999 seq.setName( "K1PYK7_CRAGI" );
1000 n.getNodeData().addSequence( seq );
1001 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
1004 seq.setName( "tr|B3RJ64" );
1005 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
1008 n = new PhylogenyNode();
1009 seq = new org.forester.phylogeny.data.Sequence();
1010 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
1011 n.getNodeData().addSequence( seq );
1012 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK8_CRAGI" ) ) {
1015 n = new PhylogenyNode();
1016 seq = new org.forester.phylogeny.data.Sequence();
1017 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
1018 n.getNodeData().addSequence( seq );
1019 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
1023 n = new PhylogenyNode();
1024 n.setName( "ACP19736" );
1025 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
1028 n = new PhylogenyNode();
1029 n.setName( "_ACP19736_" );
1030 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
1034 catch ( final Exception e ) {
1035 e.printStackTrace( System.out );
1041 private static boolean testCreateUriForSeqWeb() {
1043 final PhylogenyNode n = new PhylogenyNode();
1044 n.setName( "tr|B3RJ64" );
1045 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
1048 n.setName( "B0LM41_HUMAN" );
1049 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
1052 n.setName( "NP_001025424" );
1053 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
1056 n.setName( "_NM_001030253-" );
1057 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
1060 n.setName( "XM_002122186" );
1061 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
1064 n.setName( "dgh_AAA34956_gdg" );
1065 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
1068 n.setName( "j40f4_Q06891.1_fndn2 fnr3" );
1069 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "Q06891.1" ) ) {
1072 n.setName( "GI:394892" );
1073 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1074 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1077 n.setName( "gi_394892" );
1078 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1079 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1082 n.setName( "gi6335_gi_394892_56635_Gi_43" );
1083 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
1084 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
1088 catch ( final Exception e ) {
1089 e.printStackTrace( System.out );
1095 private static boolean testExtractSNFromNodeName() {
1097 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
1100 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
1101 .equals( "Mus musculus musculus" ) ) {
1104 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
1105 .equals( "Mus musculus musculus" ) ) {
1108 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
1111 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS_Mus_musculus-12 affrre e" )
1112 .equals( "Mus musculus" ) ) {
1116 catch ( final Exception e ) {
1117 e.printStackTrace( System.out );
1123 private static boolean testExtractTaxonomyCodeFromNodeName() {
1125 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1126 .equals( "MOUSE" ) ) {
1129 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
1130 .equals( "SOYBN" ) ) {
1133 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1134 .equals( "ARATH" ) ) {
1137 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
1138 .equals( "ARATH" ) ) {
1141 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1142 .equals( "RAT" ) ) {
1145 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
1148 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1151 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1152 .equals( "MOUSE" ) ) {
1155 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
1156 .equals( "SOYBN" ) ) {
1159 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1160 .equals( "SOYBN" ) ) {
1163 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1164 .equals( "SOYBN" ) ) {
1167 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "_SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1168 .equals( "SOYBN" ) ) {
1171 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1172 .equals( "SOYBN" ) ) {
1175 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1176 .equals( "SOYBN" ) ) {
1179 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1180 .equals( "SOYBN" ) ) {
1183 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1184 .equals( "SOYBN" ) ) {
1187 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN qwerty", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1188 .equals( "SOYBN" ) ) {
1191 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN qwerty", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1192 .equals( "SOYBN" ) ) {
1195 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1196 .equals( "SOYBN" ) ) {
1199 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1200 .equals( "SOYBN" ) ) {
1203 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1206 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1207 .equals( "SOYBN" ) ) {
1210 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "N8_ECOLI/1-2:0.01",
1211 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
1214 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag",
1215 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1216 .equals( "9YX45" ) ) {
1219 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
1220 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1221 .equals( "MOUSE" ) ) {
1224 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
1225 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1226 .equals( "MOUSE" ) ) {
1229 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
1230 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1231 .equals( "MOUSE" ) ) {
1234 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
1235 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1238 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
1239 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1242 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
1243 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1246 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
1247 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1250 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
1251 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
1254 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
1255 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1258 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
1259 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
1262 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1263 .equals( "RAT" ) ) {
1266 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
1267 .equals( "PIG" ) ) {
1271 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1272 .equals( "MOUSE" ) ) {
1275 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
1276 .equals( "MOUSE" ) ) {
1279 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1280 .equals( "MOUSE" ) ) {
1283 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE^", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1284 .equals( "MOUSE" ) ) {
1287 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE*", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ) != null ) {
1290 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "x_MOUSE=x", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
1291 .equals( "MOUSE" ) ) {
1295 catch ( final Exception e ) {
1296 e.printStackTrace( System.out );
1302 private static boolean testBasicNodeMethods() {
1304 if ( PhylogenyNode.getNodeCount() != 0 ) {
1307 final PhylogenyNode n1 = new PhylogenyNode();
1308 final PhylogenyNode n2 = PhylogenyNode
1309 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1310 final PhylogenyNode n3 = PhylogenyNode
1311 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1312 final PhylogenyNode n4 = PhylogenyNode
1313 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1314 if ( n1.isHasAssignedEvent() ) {
1317 if ( PhylogenyNode.getNodeCount() != 4 ) {
1320 if ( n3.getIndicator() != 0 ) {
1323 if ( n3.getNumberOfExternalNodes() != 1 ) {
1326 if ( !n3.isExternal() ) {
1329 if ( !n3.isRoot() ) {
1332 if ( !n4.getName().equals( "n4" ) ) {
1336 catch ( final Exception e ) {
1337 e.printStackTrace( System.out );
1343 private static boolean testBasicPhyloXMLparsing() {
1345 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1346 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1347 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1349 if ( xml_parser.getErrorCount() > 0 ) {
1350 System.out.println( xml_parser.getErrorMessages().toString() );
1353 if ( phylogenies_0.length != 4 ) {
1356 final Phylogeny t1 = phylogenies_0[ 0 ];
1357 final Phylogeny t2 = phylogenies_0[ 1 ];
1358 final Phylogeny t3 = phylogenies_0[ 2 ];
1359 final Phylogeny t4 = phylogenies_0[ 3 ];
1360 if ( t1.getNumberOfExternalNodes() != 1 ) {
1363 if ( !t1.isRooted() ) {
1366 if ( t1.isRerootable() ) {
1369 if ( !t1.getType().equals( "gene_tree" ) ) {
1372 if ( t2.getNumberOfExternalNodes() != 2 ) {
1375 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1378 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1381 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1384 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1387 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1390 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1393 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1394 .startsWith( "actgtgggggt" ) ) {
1397 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1398 .startsWith( "ctgtgatgcat" ) ) {
1401 if ( t3.getNumberOfExternalNodes() != 4 ) {
1404 if ( !t1.getName().equals( "t1" ) ) {
1407 if ( !t2.getName().equals( "t2" ) ) {
1410 if ( !t3.getName().equals( "t3" ) ) {
1413 if ( !t4.getName().equals( "t4" ) ) {
1416 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1419 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1422 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1425 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1426 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1429 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1432 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1435 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1438 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1439 .equals( "apoptosis" ) ) {
1442 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1443 .equals( "GO:0006915" ) ) {
1446 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1447 .equals( "UniProtKB" ) ) {
1450 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1451 .equals( "experimental" ) ) {
1454 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1455 .equals( "function" ) ) {
1458 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1459 .getValue() != 1 ) {
1462 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1463 .getType().equals( "ml" ) ) {
1466 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1467 .equals( "apoptosis" ) ) {
1470 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1471 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1474 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1475 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1478 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1479 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1482 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1483 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1486 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1487 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1490 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1491 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1494 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1495 .equals( "GO:0005829" ) ) {
1498 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1499 .equals( "intracellular organelle" ) ) {
1502 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1505 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1506 .equals( "UniProt link" ) ) ) {
1509 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1513 catch ( final Exception e ) {
1514 e.printStackTrace( System.out );
1520 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1522 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1523 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1524 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1525 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1528 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1530 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1532 if ( xml_parser.getErrorCount() > 0 ) {
1533 System.out.println( xml_parser.getErrorMessages().toString() );
1536 if ( phylogenies_0.length != 4 ) {
1539 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1540 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1541 if ( phylogenies_t1.length != 1 ) {
1544 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1545 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1548 if ( !t1_rt.isRooted() ) {
1551 if ( t1_rt.isRerootable() ) {
1554 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1557 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1558 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1559 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1560 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1563 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1566 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1569 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1572 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1573 .startsWith( "actgtgggggt" ) ) {
1576 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1577 .startsWith( "ctgtgatgcat" ) ) {
1580 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1581 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1582 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1583 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1584 if ( phylogenies_1.length != 1 ) {
1587 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1588 if ( !t3_rt.getName().equals( "t3" ) ) {
1591 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1594 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1597 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1600 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1603 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1604 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1607 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1610 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1613 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1614 .equals( "UniProtKB" ) ) {
1617 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1618 .equals( "apoptosis" ) ) {
1621 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1622 .equals( "GO:0006915" ) ) {
1625 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1626 .equals( "UniProtKB" ) ) {
1629 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1630 .equals( "experimental" ) ) {
1633 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1634 .equals( "function" ) ) {
1637 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1638 .getValue() != 1 ) {
1641 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1642 .getType().equals( "ml" ) ) {
1645 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1646 .equals( "apoptosis" ) ) {
1649 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1650 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1653 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1654 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1657 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1658 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1661 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1662 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1665 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1666 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1669 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1670 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1673 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1674 .equals( "GO:0005829" ) ) {
1677 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1678 .equals( "intracellular organelle" ) ) {
1681 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1684 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1685 .equals( "UniProt link" ) ) ) {
1688 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1691 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1694 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1695 .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." ) ) ) {
1698 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1701 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1704 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1707 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1710 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1711 .equals( "ncbi" ) ) {
1714 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1717 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1718 .getName().equals( "B" ) ) {
1721 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1722 .getFrom() != 21 ) {
1725 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1728 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1729 .getLength() != 24 ) {
1732 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1733 .getConfidence() != 2144 ) {
1736 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1737 .equals( "pfam" ) ) {
1740 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1743 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1746 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1749 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1752 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1753 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1756 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1759 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1762 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1765 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1768 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1771 if ( taxbb.getSynonyms().size() != 2 ) {
1774 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1777 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1780 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1783 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1786 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1789 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1790 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1794 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1797 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1800 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1803 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1806 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1809 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1812 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1816 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1819 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1820 .equalsIgnoreCase( "435" ) ) {
1823 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1826 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1827 .equalsIgnoreCase( "443.7" ) ) {
1830 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1833 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1836 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1837 .equalsIgnoreCase( "433" ) ) {
1841 catch ( final Exception e ) {
1842 e.printStackTrace( System.out );
1848 private static boolean testBasicPhyloXMLparsingValidating() {
1850 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1851 PhyloXmlParser xml_parser = null;
1853 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1855 catch ( final Exception e ) {
1856 // Do nothing -- means were not running from jar.
1858 if ( xml_parser == null ) {
1859 xml_parser = new PhyloXmlParser();
1860 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1861 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1864 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1867 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1869 if ( xml_parser.getErrorCount() > 0 ) {
1870 System.out.println( xml_parser.getErrorMessages().toString() );
1873 if ( phylogenies_0.length != 4 ) {
1876 final Phylogeny t1 = phylogenies_0[ 0 ];
1877 final Phylogeny t2 = phylogenies_0[ 1 ];
1878 final Phylogeny t3 = phylogenies_0[ 2 ];
1879 final Phylogeny t4 = phylogenies_0[ 3 ];
1880 if ( !t1.getName().equals( "t1" ) ) {
1883 if ( !t2.getName().equals( "t2" ) ) {
1886 if ( !t3.getName().equals( "t3" ) ) {
1889 if ( !t4.getName().equals( "t4" ) ) {
1892 if ( t1.getNumberOfExternalNodes() != 1 ) {
1895 if ( t2.getNumberOfExternalNodes() != 2 ) {
1898 if ( t3.getNumberOfExternalNodes() != 4 ) {
1901 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1902 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1903 if ( xml_parser.getErrorCount() > 0 ) {
1904 System.out.println( "errors:" );
1905 System.out.println( xml_parser.getErrorMessages().toString() );
1908 if ( phylogenies_1.length != 4 ) {
1911 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1913 if ( xml_parser.getErrorCount() > 0 ) {
1914 System.out.println( "errors:" );
1915 System.out.println( xml_parser.getErrorMessages().toString() );
1918 if ( phylogenies_2.length != 1 ) {
1921 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1924 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1926 if ( xml_parser.getErrorCount() > 0 ) {
1927 System.out.println( xml_parser.getErrorMessages().toString() );
1930 if ( phylogenies_3.length != 2 ) {
1933 final Phylogeny a = phylogenies_3[ 0 ];
1934 if ( !a.getName().equals( "tree 4" ) ) {
1937 if ( a.getNumberOfExternalNodes() != 3 ) {
1940 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1943 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1946 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1948 if ( xml_parser.getErrorCount() > 0 ) {
1949 System.out.println( xml_parser.getErrorMessages().toString() );
1952 if ( phylogenies_4.length != 1 ) {
1955 final Phylogeny s = phylogenies_4[ 0 ];
1956 if ( s.getNumberOfExternalNodes() != 6 ) {
1959 s.getNode( "first" );
1961 s.getNode( "\"<a'b&c'd\">\"" );
1962 s.getNode( "'''\"" );
1963 s.getNode( "\"\"\"" );
1964 s.getNode( "dick & doof" );
1966 catch ( final Exception e ) {
1967 e.printStackTrace( System.out );
1973 private static boolean testBasicTable() {
1975 final BasicTable<String> t0 = new BasicTable<String>();
1976 if ( t0.getNumberOfColumns() != 0 ) {
1979 if ( t0.getNumberOfRows() != 0 ) {
1982 t0.setValue( 3, 2, "23" );
1983 t0.setValue( 10, 1, "error" );
1984 t0.setValue( 10, 1, "110" );
1985 t0.setValue( 9, 1, "19" );
1986 t0.setValue( 1, 10, "101" );
1987 t0.setValue( 10, 10, "1010" );
1988 t0.setValue( 100, 10, "10100" );
1989 t0.setValue( 0, 0, "00" );
1990 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1993 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1996 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
1999 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2002 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2005 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2008 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2011 if ( t0.getNumberOfColumns() != 101 ) {
2014 if ( t0.getNumberOfRows() != 11 ) {
2017 if ( t0.getValueAsString( 49, 4 ) != null ) {
2020 final String l = ForesterUtil.getLineSeparator();
2021 final StringBuffer source = new StringBuffer();
2022 source.append( "" + l );
2023 source.append( "# 1 1 1 1 1 1 1 1" + l );
2024 source.append( " 00 01 02 03" + l );
2025 source.append( " 10 11 12 13 " + l );
2026 source.append( "20 21 22 23 " + l );
2027 source.append( " 30 31 32 33" + l );
2028 source.append( "40 41 42 43" + l );
2029 source.append( " # 1 1 1 1 1 " + l );
2030 source.append( "50 51 52 53 54" + l );
2031 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2032 if ( t1.getNumberOfColumns() != 5 ) {
2035 if ( t1.getNumberOfRows() != 6 ) {
2038 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2041 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2044 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2047 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2050 final StringBuffer source1 = new StringBuffer();
2051 source1.append( "" + l );
2052 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2053 source1.append( " 00; 01 ;02;03" + l );
2054 source1.append( " 10; 11; 12; 13 " + l );
2055 source1.append( "20; 21; 22; 23 " + l );
2056 source1.append( " 30; 31; 32; 33" + l );
2057 source1.append( "40;41;42;43" + l );
2058 source1.append( " # 1 1 1 1 1 " + l );
2059 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2060 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2061 if ( t2.getNumberOfColumns() != 5 ) {
2064 if ( t2.getNumberOfRows() != 6 ) {
2067 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2070 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2073 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2076 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2079 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2082 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2085 final StringBuffer source2 = new StringBuffer();
2086 source2.append( "" + l );
2087 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2088 source2.append( " 00; 01 ;02;03" + l );
2089 source2.append( " 10; 11; 12; 13 " + l );
2090 source2.append( "20; 21; 22; 23 " + l );
2091 source2.append( " " + l );
2092 source2.append( " 30; 31; 32; 33" + l );
2093 source2.append( "40;41;42;43" + l );
2094 source2.append( " comment: 1 1 1 1 1 " + l );
2095 source2.append( ";;;50 ; 52; 53;;54 " + l );
2096 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2102 if ( tl.size() != 2 ) {
2105 final BasicTable<String> t3 = tl.get( 0 );
2106 final BasicTable<String> t4 = tl.get( 1 );
2107 if ( t3.getNumberOfColumns() != 4 ) {
2110 if ( t3.getNumberOfRows() != 3 ) {
2113 if ( t4.getNumberOfColumns() != 4 ) {
2116 if ( t4.getNumberOfRows() != 3 ) {
2119 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2122 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2126 catch ( final Exception e ) {
2127 e.printStackTrace( System.out );
2133 private static boolean testBasicTolXMLparsing() {
2135 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2136 final TolParser parser = new TolParser();
2137 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2138 if ( parser.getErrorCount() > 0 ) {
2139 System.out.println( parser.getErrorMessages().toString() );
2142 if ( phylogenies_0.length != 1 ) {
2145 final Phylogeny t1 = phylogenies_0[ 0 ];
2146 if ( t1.getNumberOfExternalNodes() != 5 ) {
2149 if ( !t1.isRooted() ) {
2152 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2155 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2158 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2161 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2164 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2165 if ( parser.getErrorCount() > 0 ) {
2166 System.out.println( parser.getErrorMessages().toString() );
2169 if ( phylogenies_1.length != 1 ) {
2172 final Phylogeny t2 = phylogenies_1[ 0 ];
2173 if ( t2.getNumberOfExternalNodes() != 664 ) {
2176 if ( !t2.isRooted() ) {
2179 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2182 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2185 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2188 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2191 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2194 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2195 .equals( "Aquifex" ) ) {
2198 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2199 if ( parser.getErrorCount() > 0 ) {
2200 System.out.println( parser.getErrorMessages().toString() );
2203 if ( phylogenies_2.length != 1 ) {
2206 final Phylogeny t3 = phylogenies_2[ 0 ];
2207 if ( t3.getNumberOfExternalNodes() != 184 ) {
2210 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2213 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2216 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2219 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2220 if ( parser.getErrorCount() > 0 ) {
2221 System.out.println( parser.getErrorMessages().toString() );
2224 if ( phylogenies_3.length != 1 ) {
2227 final Phylogeny t4 = phylogenies_3[ 0 ];
2228 if ( t4.getNumberOfExternalNodes() != 1 ) {
2231 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2234 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2237 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2240 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2241 if ( parser.getErrorCount() > 0 ) {
2242 System.out.println( parser.getErrorMessages().toString() );
2245 if ( phylogenies_4.length != 1 ) {
2248 final Phylogeny t5 = phylogenies_4[ 0 ];
2249 if ( t5.getNumberOfExternalNodes() != 13 ) {
2252 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2255 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2258 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2262 catch ( final Exception e ) {
2263 e.printStackTrace( System.out );
2269 private static boolean testBasicTreeMethods() {
2271 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2272 final Phylogeny t1 = factory.create();
2273 if ( !t1.isEmpty() ) {
2276 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2277 if ( t2.getNumberOfExternalNodes() != 4 ) {
2280 if ( t2.getHeight() != 8.5 ) {
2283 if ( !t2.isCompletelyBinary() ) {
2286 if ( t2.isEmpty() ) {
2289 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2290 if ( t3.getNumberOfExternalNodes() != 5 ) {
2293 if ( t3.getHeight() != 11 ) {
2296 if ( t3.isCompletelyBinary() ) {
2299 final PhylogenyNode n = t3.getNode( "ABC" );
2300 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 ];
2301 if ( t4.getNumberOfExternalNodes() != 9 ) {
2304 if ( t4.getHeight() != 11 ) {
2307 if ( t4.isCompletelyBinary() ) {
2310 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)" );
2311 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2312 if ( t5.getNumberOfExternalNodes() != 8 ) {
2315 if ( t5.getHeight() != 15 ) {
2318 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)" );
2319 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2320 if ( t6.getHeight() != 15 ) {
2323 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)" );
2324 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2325 if ( t7.getHeight() != 15 ) {
2328 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)" );
2329 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2330 if ( t8.getNumberOfExternalNodes() != 10 ) {
2333 if ( t8.getHeight() != 15 ) {
2336 final char[] a9 = new char[] { 'a' };
2337 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2338 if ( t9.getHeight() != 0 ) {
2341 final char[] a10 = new char[] { 'a', ':', '6' };
2342 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2343 if ( t10.getHeight() != 6 ) {
2347 catch ( final Exception e ) {
2348 e.printStackTrace( System.out );
2354 private static boolean testTreeMethods() {
2356 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2357 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
2358 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
2359 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
2360 System.out.println( t0.toNewHampshireX() );
2363 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
2364 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
2365 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
2368 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
2371 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
2375 catch ( final Exception e ) {
2376 e.printStackTrace( System.out );
2382 private static boolean testConfidenceAssessor() {
2384 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2385 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2386 final Phylogeny[] ev0 = factory
2387 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2389 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2390 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2393 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2396 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2397 final Phylogeny[] ev1 = factory
2398 .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)));",
2400 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2401 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2404 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2407 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2408 final Phylogeny[] ev_b = factory
2409 .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",
2411 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2412 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2415 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2419 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2420 final Phylogeny[] ev1x = factory
2421 .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)));",
2423 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2424 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2427 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2430 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2431 final Phylogeny[] ev_bx = factory
2432 .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",
2434 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2435 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2438 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2442 final Phylogeny[] t2 = factory
2443 .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);",
2445 final Phylogeny[] ev2 = factory
2446 .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);",
2448 for( final Phylogeny target : t2 ) {
2449 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2452 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2453 new NHXParser() )[ 0 ];
2454 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2455 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2456 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2459 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2462 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2466 catch ( final Exception e ) {
2467 e.printStackTrace();
2473 private static boolean testCopyOfNodeData() {
2475 final PhylogenyNode n1 = PhylogenyNode
2476 .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]" );
2477 final PhylogenyNode n2 = n1.copyNodeData();
2478 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2482 catch ( final Exception e ) {
2483 e.printStackTrace();
2489 private static boolean testDataObjects() {
2491 final Confidence s0 = new Confidence();
2492 final Confidence s1 = new Confidence();
2493 if ( !s0.isEqual( s1 ) ) {
2496 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2497 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2498 if ( s2.isEqual( s1 ) ) {
2501 if ( !s2.isEqual( s3 ) ) {
2504 final Confidence s4 = ( Confidence ) s3.copy();
2505 if ( !s4.isEqual( s3 ) ) {
2512 final Taxonomy t1 = new Taxonomy();
2513 final Taxonomy t2 = new Taxonomy();
2514 final Taxonomy t3 = new Taxonomy();
2515 final Taxonomy t4 = new Taxonomy();
2516 final Taxonomy t5 = new Taxonomy();
2517 t1.setIdentifier( new Identifier( "ecoli" ) );
2518 t1.setTaxonomyCode( "ECOLI" );
2519 t1.setScientificName( "E. coli" );
2520 t1.setCommonName( "coli" );
2521 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2522 if ( !t1.isEqual( t0 ) ) {
2525 t2.setIdentifier( new Identifier( "ecoli" ) );
2526 t2.setTaxonomyCode( "OTHER" );
2527 t2.setScientificName( "what" );
2528 t2.setCommonName( "something" );
2529 if ( !t1.isEqual( t2 ) ) {
2532 t2.setIdentifier( new Identifier( "nemve" ) );
2533 if ( t1.isEqual( t2 ) ) {
2536 t1.setIdentifier( null );
2537 t3.setTaxonomyCode( "ECOLI" );
2538 t3.setScientificName( "what" );
2539 t3.setCommonName( "something" );
2540 if ( !t1.isEqual( t3 ) ) {
2543 t1.setIdentifier( null );
2544 t1.setTaxonomyCode( "" );
2545 t4.setScientificName( "E. ColI" );
2546 t4.setCommonName( "something" );
2547 if ( !t1.isEqual( t4 ) ) {
2550 t4.setScientificName( "B. subtilis" );
2551 t4.setCommonName( "something" );
2552 if ( t1.isEqual( t4 ) ) {
2555 t1.setIdentifier( null );
2556 t1.setTaxonomyCode( "" );
2557 t1.setScientificName( "" );
2558 t5.setCommonName( "COLI" );
2559 if ( !t1.isEqual( t5 ) ) {
2562 t5.setCommonName( "vibrio" );
2563 if ( t1.isEqual( t5 ) ) {
2568 final Identifier id0 = new Identifier( "123", "pfam" );
2569 final Identifier id1 = ( Identifier ) id0.copy();
2570 if ( !id1.isEqual( id1 ) ) {
2573 if ( !id1.isEqual( id0 ) ) {
2576 if ( !id0.isEqual( id1 ) ) {
2583 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2584 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2585 if ( !pd1.isEqual( pd1 ) ) {
2588 if ( !pd1.isEqual( pd0 ) ) {
2593 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2594 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2595 if ( !pd3.isEqual( pd3 ) ) {
2598 if ( !pd2.isEqual( pd3 ) ) {
2601 if ( !pd0.isEqual( pd3 ) ) {
2606 // DomainArchitecture
2607 // ------------------
2608 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2609 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2610 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2611 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2612 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2613 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2618 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2619 if ( ds0.getNumberOfDomains() != 4 ) {
2622 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2623 if ( !ds0.isEqual( ds0 ) ) {
2626 if ( !ds0.isEqual( ds1 ) ) {
2629 if ( ds1.getNumberOfDomains() != 4 ) {
2632 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2637 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2638 if ( ds0.isEqual( ds2 ) ) {
2644 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2645 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2646 System.out.println( ds3.toNHX() );
2649 if ( ds3.getNumberOfDomains() != 3 ) {
2654 final Event e1 = new Event( Event.EventType.fusion );
2655 if ( e1.isDuplication() ) {
2658 if ( !e1.isFusion() ) {
2661 if ( !e1.asText().toString().equals( "fusion" ) ) {
2664 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2667 final Event e11 = new Event( Event.EventType.fusion );
2668 if ( !e11.isEqual( e1 ) ) {
2671 if ( !e11.toNHX().toString().equals( "" ) ) {
2674 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2675 if ( e2.isDuplication() ) {
2678 if ( !e2.isSpeciationOrDuplication() ) {
2681 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2684 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2687 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2690 if ( e11.isEqual( e2 ) ) {
2693 final Event e2c = ( Event ) e2.copy();
2694 if ( !e2c.isEqual( e2 ) ) {
2697 Event e3 = new Event( 1, 2, 3 );
2698 if ( e3.isDuplication() ) {
2701 if ( e3.isSpeciation() ) {
2704 if ( e3.isGeneLoss() ) {
2707 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2710 final Event e3c = ( Event ) e3.copy();
2711 final Event e3cc = ( Event ) e3c.copy();
2712 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2716 if ( !e3c.isEqual( e3cc ) ) {
2719 Event e4 = new Event( 1, 2, 3 );
2720 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2723 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2726 final Event e4c = ( Event ) e4.copy();
2728 final Event e4cc = ( Event ) e4c.copy();
2729 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2732 if ( !e4c.isEqual( e4cc ) ) {
2735 final Event e5 = new Event();
2736 if ( !e5.isUnassigned() ) {
2739 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2742 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2745 final Event e6 = new Event( 1, 0, 0 );
2746 if ( !e6.asText().toString().equals( "duplication" ) ) {
2749 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2752 final Event e7 = new Event( 0, 1, 0 );
2753 if ( !e7.asText().toString().equals( "speciation" ) ) {
2756 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2759 final Event e8 = new Event( 0, 0, 1 );
2760 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2763 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2767 catch ( final Exception e ) {
2768 e.printStackTrace( System.out );
2774 private static boolean testDeletionOfExternalNodes() {
2776 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2777 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2778 final PhylogenyWriter w = new PhylogenyWriter();
2779 if ( t0.isEmpty() ) {
2782 if ( t0.getNumberOfExternalNodes() != 1 ) {
2785 t0.deleteSubtree( t0.getNode( "A" ), false );
2786 if ( t0.getNumberOfExternalNodes() != 0 ) {
2789 if ( !t0.isEmpty() ) {
2792 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2793 if ( t1.getNumberOfExternalNodes() != 2 ) {
2796 t1.deleteSubtree( t1.getNode( "A" ), false );
2797 if ( t1.getNumberOfExternalNodes() != 1 ) {
2800 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2803 t1.deleteSubtree( t1.getNode( "B" ), false );
2804 if ( t1.getNumberOfExternalNodes() != 1 ) {
2807 t1.deleteSubtree( t1.getNode( "r" ), false );
2808 if ( !t1.isEmpty() ) {
2811 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2812 if ( t2.getNumberOfExternalNodes() != 3 ) {
2815 t2.deleteSubtree( t2.getNode( "B" ), false );
2816 if ( t2.getNumberOfExternalNodes() != 2 ) {
2819 t2.toNewHampshireX();
2820 PhylogenyNode n = t2.getNode( "A" );
2821 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2824 t2.deleteSubtree( t2.getNode( "A" ), false );
2825 if ( t2.getNumberOfExternalNodes() != 2 ) {
2828 t2.deleteSubtree( t2.getNode( "C" ), true );
2829 if ( t2.getNumberOfExternalNodes() != 1 ) {
2832 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2833 if ( t3.getNumberOfExternalNodes() != 4 ) {
2836 t3.deleteSubtree( t3.getNode( "B" ), true );
2837 if ( t3.getNumberOfExternalNodes() != 3 ) {
2840 n = t3.getNode( "A" );
2841 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2844 n = n.getNextExternalNode();
2845 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2848 t3.deleteSubtree( t3.getNode( "A" ), true );
2849 if ( t3.getNumberOfExternalNodes() != 2 ) {
2852 n = t3.getNode( "C" );
2853 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2856 t3.deleteSubtree( t3.getNode( "C" ), true );
2857 if ( t3.getNumberOfExternalNodes() != 1 ) {
2860 t3.deleteSubtree( t3.getNode( "D" ), true );
2861 if ( t3.getNumberOfExternalNodes() != 0 ) {
2864 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2865 if ( t4.getNumberOfExternalNodes() != 6 ) {
2868 t4.deleteSubtree( t4.getNode( "B2" ), true );
2869 if ( t4.getNumberOfExternalNodes() != 5 ) {
2872 String s = w.toNewHampshire( t4, false, true ).toString();
2873 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2876 t4.deleteSubtree( t4.getNode( "B11" ), true );
2877 if ( t4.getNumberOfExternalNodes() != 4 ) {
2880 t4.deleteSubtree( t4.getNode( "C" ), true );
2881 if ( t4.getNumberOfExternalNodes() != 3 ) {
2884 n = t4.getNode( "A" );
2885 n = n.getNextExternalNode();
2886 if ( !n.getName().equals( "B12" ) ) {
2889 n = n.getNextExternalNode();
2890 if ( !n.getName().equals( "D" ) ) {
2893 s = w.toNewHampshire( t4, false, true ).toString();
2894 if ( !s.equals( "((A,B12),D);" ) ) {
2897 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2898 t5.deleteSubtree( t5.getNode( "A" ), true );
2899 if ( t5.getNumberOfExternalNodes() != 5 ) {
2902 s = w.toNewHampshire( t5, false, true ).toString();
2903 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2906 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2907 t6.deleteSubtree( t6.getNode( "B11" ), true );
2908 if ( t6.getNumberOfExternalNodes() != 5 ) {
2911 s = w.toNewHampshire( t6, false, false ).toString();
2912 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2915 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2916 t7.deleteSubtree( t7.getNode( "B12" ), true );
2917 if ( t7.getNumberOfExternalNodes() != 5 ) {
2920 s = w.toNewHampshire( t7, false, true ).toString();
2921 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2924 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2925 t8.deleteSubtree( t8.getNode( "B2" ), true );
2926 if ( t8.getNumberOfExternalNodes() != 5 ) {
2929 s = w.toNewHampshire( t8, false, false ).toString();
2930 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2933 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2934 t9.deleteSubtree( t9.getNode( "C" ), true );
2935 if ( t9.getNumberOfExternalNodes() != 5 ) {
2938 s = w.toNewHampshire( t9, false, true ).toString();
2939 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2942 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2943 t10.deleteSubtree( t10.getNode( "D" ), true );
2944 if ( t10.getNumberOfExternalNodes() != 5 ) {
2947 s = w.toNewHampshire( t10, false, true ).toString();
2948 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
2951 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
2952 t11.deleteSubtree( t11.getNode( "A" ), true );
2953 if ( t11.getNumberOfExternalNodes() != 2 ) {
2956 s = w.toNewHampshire( t11, false, true ).toString();
2957 if ( !s.equals( "(B,C);" ) ) {
2960 t11.deleteSubtree( t11.getNode( "C" ), true );
2961 if ( t11.getNumberOfExternalNodes() != 1 ) {
2964 s = w.toNewHampshire( t11, false, false ).toString();
2965 if ( !s.equals( "B;" ) ) {
2968 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
2969 t12.deleteSubtree( t12.getNode( "B2" ), true );
2970 if ( t12.getNumberOfExternalNodes() != 8 ) {
2973 s = w.toNewHampshire( t12, false, true ).toString();
2974 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
2977 t12.deleteSubtree( t12.getNode( "B3" ), true );
2978 if ( t12.getNumberOfExternalNodes() != 7 ) {
2981 s = w.toNewHampshire( t12, false, true ).toString();
2982 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
2985 t12.deleteSubtree( t12.getNode( "C3" ), true );
2986 if ( t12.getNumberOfExternalNodes() != 6 ) {
2989 s = w.toNewHampshire( t12, false, true ).toString();
2990 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
2993 t12.deleteSubtree( t12.getNode( "A1" ), true );
2994 if ( t12.getNumberOfExternalNodes() != 5 ) {
2997 s = w.toNewHampshire( t12, false, true ).toString();
2998 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3001 t12.deleteSubtree( t12.getNode( "B1" ), true );
3002 if ( t12.getNumberOfExternalNodes() != 4 ) {
3005 s = w.toNewHampshire( t12, false, true ).toString();
3006 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3009 t12.deleteSubtree( t12.getNode( "A3" ), true );
3010 if ( t12.getNumberOfExternalNodes() != 3 ) {
3013 s = w.toNewHampshire( t12, false, true ).toString();
3014 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3017 t12.deleteSubtree( t12.getNode( "A2" ), true );
3018 if ( t12.getNumberOfExternalNodes() != 2 ) {
3021 s = w.toNewHampshire( t12, false, true ).toString();
3022 if ( !s.equals( "(C1,C2);" ) ) {
3025 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3026 t13.deleteSubtree( t13.getNode( "D" ), true );
3027 if ( t13.getNumberOfExternalNodes() != 4 ) {
3030 s = w.toNewHampshire( t13, false, true ).toString();
3031 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3034 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3035 t14.deleteSubtree( t14.getNode( "E" ), true );
3036 if ( t14.getNumberOfExternalNodes() != 5 ) {
3039 s = w.toNewHampshire( t14, false, true ).toString();
3040 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3043 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3044 t15.deleteSubtree( t15.getNode( "B2" ), true );
3045 if ( t15.getNumberOfExternalNodes() != 11 ) {
3048 t15.deleteSubtree( t15.getNode( "B1" ), true );
3049 if ( t15.getNumberOfExternalNodes() != 10 ) {
3052 t15.deleteSubtree( t15.getNode( "B3" ), true );
3053 if ( t15.getNumberOfExternalNodes() != 9 ) {
3056 t15.deleteSubtree( t15.getNode( "B4" ), true );
3057 if ( t15.getNumberOfExternalNodes() != 8 ) {
3060 t15.deleteSubtree( t15.getNode( "A1" ), true );
3061 if ( t15.getNumberOfExternalNodes() != 7 ) {
3064 t15.deleteSubtree( t15.getNode( "C4" ), true );
3065 if ( t15.getNumberOfExternalNodes() != 6 ) {
3069 catch ( final Exception e ) {
3070 e.printStackTrace( System.out );
3076 private static boolean testDescriptiveStatistics() {
3078 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3079 dss1.addValue( 82 );
3080 dss1.addValue( 78 );
3081 dss1.addValue( 70 );
3082 dss1.addValue( 58 );
3083 dss1.addValue( 42 );
3084 if ( dss1.getN() != 5 ) {
3087 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3090 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3093 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3096 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3099 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3102 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3105 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3108 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3111 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3114 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3117 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3120 dss1.addValue( 123 );
3121 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3124 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3127 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3130 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3131 dss2.addValue( -1.85 );
3132 dss2.addValue( 57.5 );
3133 dss2.addValue( 92.78 );
3134 dss2.addValue( 57.78 );
3135 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3138 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3141 final double[] a = dss2.getDataAsDoubleArray();
3142 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3145 dss2.addValue( -100 );
3146 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3149 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3152 final double[] ds = new double[ 14 ];
3167 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3168 if ( bins.length != 4 ) {
3171 if ( bins[ 0 ] != 2 ) {
3174 if ( bins[ 1 ] != 3 ) {
3177 if ( bins[ 2 ] != 4 ) {
3180 if ( bins[ 3 ] != 5 ) {
3183 final double[] ds1 = new double[ 9 ];
3193 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3194 if ( bins1.length != 4 ) {
3197 if ( bins1[ 0 ] != 2 ) {
3200 if ( bins1[ 1 ] != 3 ) {
3203 if ( bins1[ 2 ] != 0 ) {
3206 if ( bins1[ 3 ] != 4 ) {
3209 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3210 if ( bins1_1.length != 3 ) {
3213 if ( bins1_1[ 0 ] != 3 ) {
3216 if ( bins1_1[ 1 ] != 2 ) {
3219 if ( bins1_1[ 2 ] != 4 ) {
3222 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3223 if ( bins1_2.length != 3 ) {
3226 if ( bins1_2[ 0 ] != 2 ) {
3229 if ( bins1_2[ 1 ] != 2 ) {
3232 if ( bins1_2[ 2 ] != 2 ) {
3235 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3249 dss3.addValue( 10 );
3250 dss3.addValue( 10 );
3251 dss3.addValue( 10 );
3252 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3253 histo.toStringBuffer( 10, '=', 40, 5 );
3254 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3256 catch ( final Exception e ) {
3257 e.printStackTrace( System.out );
3263 private static boolean testDir( final String file ) {
3265 final File f = new File( file );
3266 if ( !f.exists() ) {
3269 if ( !f.isDirectory() ) {
3272 if ( !f.canRead() ) {
3276 catch ( final Exception e ) {
3282 private static boolean testExternalNodeRelatedMethods() {
3284 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3285 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3286 PhylogenyNode n = t1.getNode( "A" );
3287 n = n.getNextExternalNode();
3288 if ( !n.getName().equals( "B" ) ) {
3291 n = n.getNextExternalNode();
3292 if ( !n.getName().equals( "C" ) ) {
3295 n = n.getNextExternalNode();
3296 if ( !n.getName().equals( "D" ) ) {
3299 n = t1.getNode( "B" );
3300 while ( !n.isLastExternalNode() ) {
3301 n = n.getNextExternalNode();
3303 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3304 n = t2.getNode( "A" );
3305 n = n.getNextExternalNode();
3306 if ( !n.getName().equals( "B" ) ) {
3309 n = n.getNextExternalNode();
3310 if ( !n.getName().equals( "C" ) ) {
3313 n = n.getNextExternalNode();
3314 if ( !n.getName().equals( "D" ) ) {
3317 n = t2.getNode( "B" );
3318 while ( !n.isLastExternalNode() ) {
3319 n = n.getNextExternalNode();
3321 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3322 n = t3.getNode( "A" );
3323 n = n.getNextExternalNode();
3324 if ( !n.getName().equals( "B" ) ) {
3327 n = n.getNextExternalNode();
3328 if ( !n.getName().equals( "C" ) ) {
3331 n = n.getNextExternalNode();
3332 if ( !n.getName().equals( "D" ) ) {
3335 n = n.getNextExternalNode();
3336 if ( !n.getName().equals( "E" ) ) {
3339 n = n.getNextExternalNode();
3340 if ( !n.getName().equals( "F" ) ) {
3343 n = n.getNextExternalNode();
3344 if ( !n.getName().equals( "G" ) ) {
3347 n = n.getNextExternalNode();
3348 if ( !n.getName().equals( "H" ) ) {
3351 n = t3.getNode( "B" );
3352 while ( !n.isLastExternalNode() ) {
3353 n = n.getNextExternalNode();
3355 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3356 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3357 final PhylogenyNode node = iter.next();
3359 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3360 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3361 final PhylogenyNode node = iter.next();
3363 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3364 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3365 if ( !iter.next().getName().equals( "A" ) ) {
3368 if ( !iter.next().getName().equals( "B" ) ) {
3371 if ( !iter.next().getName().equals( "C" ) ) {
3374 if ( !iter.next().getName().equals( "D" ) ) {
3377 if ( !iter.next().getName().equals( "E" ) ) {
3380 if ( !iter.next().getName().equals( "F" ) ) {
3383 if ( iter.hasNext() ) {
3387 catch ( final Exception e ) {
3388 e.printStackTrace( System.out );
3394 private static boolean testGeneralTable() {
3396 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3397 t0.setValue( 3, 2, "23" );
3398 t0.setValue( 10, 1, "error" );
3399 t0.setValue( 10, 1, "110" );
3400 t0.setValue( 9, 1, "19" );
3401 t0.setValue( 1, 10, "101" );
3402 t0.setValue( 10, 10, "1010" );
3403 t0.setValue( 100, 10, "10100" );
3404 t0.setValue( 0, 0, "00" );
3405 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3408 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3411 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3414 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3417 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3420 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3423 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3426 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
3429 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
3432 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
3433 t1.setValue( "3", "2", "23" );
3434 t1.setValue( "10", "1", "error" );
3435 t1.setValue( "10", "1", "110" );
3436 t1.setValue( "9", "1", "19" );
3437 t1.setValue( "1", "10", "101" );
3438 t1.setValue( "10", "10", "1010" );
3439 t1.setValue( "100", "10", "10100" );
3440 t1.setValue( "0", "0", "00" );
3441 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
3442 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
3445 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
3448 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
3451 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
3454 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
3457 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
3460 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
3463 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
3466 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
3469 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
3473 catch ( final Exception e ) {
3474 e.printStackTrace( System.out );
3480 private static boolean testGetDistance() {
3482 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3483 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",
3484 new NHXParser() )[ 0 ];
3485 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
3488 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
3491 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
3494 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
3497 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
3500 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
3503 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
3506 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
3509 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
3512 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
3515 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
3518 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
3521 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
3524 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
3527 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
3530 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
3533 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
3536 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
3539 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
3542 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
3545 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
3548 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
3551 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
3554 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
3557 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
3560 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
3563 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
3566 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
3569 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
3572 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
3575 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
3578 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",
3579 new NHXParser() )[ 0 ];
3580 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
3583 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
3586 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
3589 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
3592 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
3595 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
3598 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
3601 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
3604 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
3607 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
3610 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
3614 catch ( final Exception e ) {
3615 e.printStackTrace( System.out );
3621 private static boolean testGetLCA() {
3623 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3624 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3625 new NHXParser() )[ 0 ];
3626 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
3627 if ( !A.getName().equals( "A" ) ) {
3630 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
3631 if ( !gh.getName().equals( "gh" ) ) {
3634 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
3635 if ( !ab.getName().equals( "ab" ) ) {
3638 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
3639 if ( !ab2.getName().equals( "ab" ) ) {
3642 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
3643 if ( !gh2.getName().equals( "gh" ) ) {
3646 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
3647 if ( !gh3.getName().equals( "gh" ) ) {
3650 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
3651 if ( !abc.getName().equals( "abc" ) ) {
3654 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
3655 if ( !abc2.getName().equals( "abc" ) ) {
3658 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
3659 if ( !abcd.getName().equals( "abcd" ) ) {
3662 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
3663 if ( !abcd2.getName().equals( "abcd" ) ) {
3666 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
3667 if ( !abcdef.getName().equals( "abcdef" ) ) {
3670 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
3671 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3674 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
3675 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3678 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
3679 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3682 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
3683 if ( !abcde.getName().equals( "abcde" ) ) {
3686 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
3687 if ( !abcde2.getName().equals( "abcde" ) ) {
3690 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
3691 if ( !r.getName().equals( "abcdefgh" ) ) {
3694 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
3695 if ( !r2.getName().equals( "abcdefgh" ) ) {
3698 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
3699 if ( !r3.getName().equals( "abcdefgh" ) ) {
3702 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
3703 if ( !abcde3.getName().equals( "abcde" ) ) {
3706 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
3707 if ( !abcde4.getName().equals( "abcde" ) ) {
3710 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
3711 if ( !ab3.getName().equals( "ab" ) ) {
3714 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
3715 if ( !ab4.getName().equals( "ab" ) ) {
3718 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3719 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
3720 if ( !cd.getName().equals( "cd" ) ) {
3723 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
3724 if ( !cd2.getName().equals( "cd" ) ) {
3727 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
3728 if ( !cde.getName().equals( "cde" ) ) {
3731 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
3732 if ( !cde2.getName().equals( "cde" ) ) {
3735 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
3736 if ( !cdef.getName().equals( "cdef" ) ) {
3739 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
3740 if ( !cdef2.getName().equals( "cdef" ) ) {
3743 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
3744 if ( !cdef3.getName().equals( "cdef" ) ) {
3747 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
3748 if ( !rt.getName().equals( "r" ) ) {
3751 final Phylogeny p3 = factory
3752 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
3753 new NHXParser() )[ 0 ];
3754 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
3755 if ( !bc_3.getName().equals( "bc" ) ) {
3758 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
3759 if ( !ac_3.getName().equals( "abc" ) ) {
3762 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
3763 if ( !ad_3.getName().equals( "abcde" ) ) {
3766 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
3767 if ( !af_3.getName().equals( "abcdef" ) ) {
3770 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
3771 if ( !ag_3.getName().equals( "" ) ) {
3774 if ( !ag_3.isRoot() ) {
3777 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
3778 if ( !al_3.getName().equals( "" ) ) {
3781 if ( !al_3.isRoot() ) {
3784 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
3785 if ( !kl_3.getName().equals( "" ) ) {
3788 if ( !kl_3.isRoot() ) {
3791 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
3792 if ( !fl_3.getName().equals( "" ) ) {
3795 if ( !fl_3.isRoot() ) {
3798 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
3799 if ( !gk_3.getName().equals( "ghijk" ) ) {
3802 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
3803 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
3804 if ( !r_4.getName().equals( "r" ) ) {
3807 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
3808 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
3809 if ( !r_5.getName().equals( "root" ) ) {
3812 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
3813 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
3814 if ( !r_6.getName().equals( "rot" ) ) {
3817 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
3818 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
3819 if ( !r_7.getName().equals( "rott" ) ) {
3823 catch ( final Exception e ) {
3824 e.printStackTrace( System.out );
3830 private static boolean testGetLCA2() {
3832 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3833 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
3834 PhylogenyMethods.preOrderReId( p_a );
3835 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
3836 p_a.getNode( "a" ) );
3837 if ( !p_a_1.getName().equals( "a" ) ) {
3840 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
3841 PhylogenyMethods.preOrderReId( p_b );
3842 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
3843 p_b.getNode( "a" ) );
3844 if ( !p_b_1.getName().equals( "b" ) ) {
3847 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
3848 p_b.getNode( "b" ) );
3849 if ( !p_b_2.getName().equals( "b" ) ) {
3852 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
3853 PhylogenyMethods.preOrderReId( p_c );
3854 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
3855 p_c.getNode( "a" ) );
3856 if ( !p_c_1.getName().equals( "b" ) ) {
3859 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
3860 p_c.getNode( "c" ) );
3861 if ( !p_c_2.getName().equals( "c" ) ) {
3862 System.out.println( p_c_2.getName() );
3866 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
3867 p_c.getNode( "b" ) );
3868 if ( !p_c_3.getName().equals( "b" ) ) {
3871 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
3872 p_c.getNode( "a" ) );
3873 if ( !p_c_4.getName().equals( "c" ) ) {
3876 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
3877 new NHXParser() )[ 0 ];
3878 PhylogenyMethods.preOrderReId( p1 );
3879 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3880 p1.getNode( "A" ) );
3881 if ( !A.getName().equals( "A" ) ) {
3884 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
3885 p1.getNode( "gh" ) );
3886 if ( !gh.getName().equals( "gh" ) ) {
3889 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3890 p1.getNode( "B" ) );
3891 if ( !ab.getName().equals( "ab" ) ) {
3894 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3895 p1.getNode( "A" ) );
3896 if ( !ab2.getName().equals( "ab" ) ) {
3899 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3900 p1.getNode( "G" ) );
3901 if ( !gh2.getName().equals( "gh" ) ) {
3904 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
3905 p1.getNode( "H" ) );
3906 if ( !gh3.getName().equals( "gh" ) ) {
3909 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
3910 p1.getNode( "A" ) );
3911 if ( !abc.getName().equals( "abc" ) ) {
3914 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3915 p1.getNode( "C" ) );
3916 if ( !abc2.getName().equals( "abc" ) ) {
3919 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3920 p1.getNode( "D" ) );
3921 if ( !abcd.getName().equals( "abcd" ) ) {
3924 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
3925 p1.getNode( "A" ) );
3926 if ( !abcd2.getName().equals( "abcd" ) ) {
3929 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3930 p1.getNode( "F" ) );
3931 if ( !abcdef.getName().equals( "abcdef" ) ) {
3934 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3935 p1.getNode( "A" ) );
3936 if ( !abcdef2.getName().equals( "abcdef" ) ) {
3939 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3940 p1.getNode( "F" ) );
3941 if ( !abcdef3.getName().equals( "abcdef" ) ) {
3944 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
3945 p1.getNode( "ab" ) );
3946 if ( !abcdef4.getName().equals( "abcdef" ) ) {
3949 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3950 p1.getNode( "E" ) );
3951 if ( !abcde.getName().equals( "abcde" ) ) {
3954 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3955 p1.getNode( "A" ) );
3956 if ( !abcde2.getName().equals( "abcde" ) ) {
3959 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
3960 p1.getNode( "abcdefgh" ) );
3961 if ( !r.getName().equals( "abcdefgh" ) ) {
3964 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
3965 p1.getNode( "H" ) );
3966 if ( !r2.getName().equals( "abcdefgh" ) ) {
3969 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
3970 p1.getNode( "A" ) );
3971 if ( !r3.getName().equals( "abcdefgh" ) ) {
3974 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
3975 p1.getNode( "abcde" ) );
3976 if ( !abcde3.getName().equals( "abcde" ) ) {
3979 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
3980 p1.getNode( "E" ) );
3981 if ( !abcde4.getName().equals( "abcde" ) ) {
3984 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
3985 p1.getNode( "B" ) );
3986 if ( !ab3.getName().equals( "ab" ) ) {
3989 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
3990 p1.getNode( "ab" ) );
3991 if ( !ab4.getName().equals( "ab" ) ) {
3994 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
3995 PhylogenyMethods.preOrderReId( p2 );
3996 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
3997 p2.getNode( "d" ) );
3998 if ( !cd.getName().equals( "cd" ) ) {
4001 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4002 p2.getNode( "c" ) );
4003 if ( !cd2.getName().equals( "cd" ) ) {
4006 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4007 p2.getNode( "e" ) );
4008 if ( !cde.getName().equals( "cde" ) ) {
4011 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4012 p2.getNode( "c" ) );
4013 if ( !cde2.getName().equals( "cde" ) ) {
4016 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4017 p2.getNode( "f" ) );
4018 if ( !cdef.getName().equals( "cdef" ) ) {
4021 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4022 p2.getNode( "f" ) );
4023 if ( !cdef2.getName().equals( "cdef" ) ) {
4026 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4027 p2.getNode( "d" ) );
4028 if ( !cdef3.getName().equals( "cdef" ) ) {
4031 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4032 p2.getNode( "a" ) );
4033 if ( !rt.getName().equals( "r" ) ) {
4036 final Phylogeny p3 = factory
4037 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4038 new NHXParser() )[ 0 ];
4039 PhylogenyMethods.preOrderReId( p3 );
4040 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4041 p3.getNode( "c" ) );
4042 if ( !bc_3.getName().equals( "bc" ) ) {
4045 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4046 p3.getNode( "c" ) );
4047 if ( !ac_3.getName().equals( "abc" ) ) {
4050 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4051 p3.getNode( "d" ) );
4052 if ( !ad_3.getName().equals( "abcde" ) ) {
4055 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4056 p3.getNode( "f" ) );
4057 if ( !af_3.getName().equals( "abcdef" ) ) {
4060 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4061 p3.getNode( "g" ) );
4062 if ( !ag_3.getName().equals( "" ) ) {
4065 if ( !ag_3.isRoot() ) {
4068 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4069 p3.getNode( "l" ) );
4070 if ( !al_3.getName().equals( "" ) ) {
4073 if ( !al_3.isRoot() ) {
4076 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4077 p3.getNode( "l" ) );
4078 if ( !kl_3.getName().equals( "" ) ) {
4081 if ( !kl_3.isRoot() ) {
4084 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4085 p3.getNode( "l" ) );
4086 if ( !fl_3.getName().equals( "" ) ) {
4089 if ( !fl_3.isRoot() ) {
4092 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4093 p3.getNode( "k" ) );
4094 if ( !gk_3.getName().equals( "ghijk" ) ) {
4097 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4098 PhylogenyMethods.preOrderReId( p4 );
4099 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4100 p4.getNode( "c" ) );
4101 if ( !r_4.getName().equals( "r" ) ) {
4104 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4105 PhylogenyMethods.preOrderReId( p5 );
4106 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4107 p5.getNode( "c" ) );
4108 if ( !r_5.getName().equals( "root" ) ) {
4111 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4112 PhylogenyMethods.preOrderReId( p6 );
4113 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4114 p6.getNode( "a" ) );
4115 if ( !r_6.getName().equals( "rot" ) ) {
4118 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4119 PhylogenyMethods.preOrderReId( p7 );
4120 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4121 p7.getNode( "e" ) );
4122 if ( !r_7.getName().equals( "rott" ) ) {
4125 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4126 p7.getNode( "a" ) );
4127 if ( !r_71.getName().equals( "rott" ) ) {
4130 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4131 p7.getNode( "rott" ) );
4132 if ( !r_72.getName().equals( "rott" ) ) {
4135 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4136 p7.getNode( "a" ) );
4137 if ( !r_73.getName().equals( "rott" ) ) {
4140 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4141 p7.getNode( "rott" ) );
4142 if ( !r_74.getName().equals( "rott" ) ) {
4145 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4146 p7.getNode( "e" ) );
4147 if ( !r_75.getName().equals( "e" ) ) {
4151 catch ( final Exception e ) {
4152 e.printStackTrace( System.out );
4158 private static boolean testHmmscanOutputParser() {
4159 final String test_dir = Test.PATH_TO_TEST_DATA;
4161 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4162 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4164 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4165 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4166 final List<Protein> proteins = parser2.parse();
4167 if ( parser2.getProteinsEncountered() != 4 ) {
4170 if ( proteins.size() != 4 ) {
4173 if ( parser2.getDomainsEncountered() != 69 ) {
4176 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4179 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4182 final Protein p1 = proteins.get( 0 );
4183 if ( p1.getNumberOfProteinDomains() != 15 ) {
4186 if ( p1.getLength() != 850 ) {
4189 final Protein p2 = proteins.get( 1 );
4190 if ( p2.getNumberOfProteinDomains() != 51 ) {
4193 if ( p2.getLength() != 1291 ) {
4196 final Protein p3 = proteins.get( 2 );
4197 if ( p3.getNumberOfProteinDomains() != 2 ) {
4200 final Protein p4 = proteins.get( 3 );
4201 if ( p4.getNumberOfProteinDomains() != 1 ) {
4204 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4207 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4210 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4213 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4216 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4219 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4222 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4225 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4228 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4232 catch ( final Exception e ) {
4233 e.printStackTrace( System.out );
4239 private static boolean testLastExternalNodeMethods() {
4241 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4242 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4243 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4244 final PhylogenyNode n1 = t0.getNode( "A" );
4245 if ( n1.isLastExternalNode() ) {
4248 final PhylogenyNode n2 = t0.getNode( "B" );
4249 if ( n2.isLastExternalNode() ) {
4252 final PhylogenyNode n3 = t0.getNode( "C" );
4253 if ( n3.isLastExternalNode() ) {
4256 final PhylogenyNode n4 = t0.getNode( "D" );
4257 if ( !n4.isLastExternalNode() ) {
4261 catch ( final Exception e ) {
4262 e.printStackTrace( System.out );
4268 private static boolean testLevelOrderIterator() {
4270 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4271 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4272 PhylogenyNodeIterator it0;
4273 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4276 for( it0.reset(); it0.hasNext(); ) {
4279 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4280 if ( !it.next().getName().equals( "r" ) ) {
4283 if ( !it.next().getName().equals( "ab" ) ) {
4286 if ( !it.next().getName().equals( "cd" ) ) {
4289 if ( !it.next().getName().equals( "A" ) ) {
4292 if ( !it.next().getName().equals( "B" ) ) {
4295 if ( !it.next().getName().equals( "C" ) ) {
4298 if ( !it.next().getName().equals( "D" ) ) {
4301 if ( it.hasNext() ) {
4304 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",
4305 new NHXParser() )[ 0 ];
4306 PhylogenyNodeIterator it2;
4307 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4310 for( it2.reset(); it2.hasNext(); ) {
4313 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4314 if ( !it3.next().getName().equals( "r" ) ) {
4317 if ( !it3.next().getName().equals( "abc" ) ) {
4320 if ( !it3.next().getName().equals( "defg" ) ) {
4323 if ( !it3.next().getName().equals( "A" ) ) {
4326 if ( !it3.next().getName().equals( "B" ) ) {
4329 if ( !it3.next().getName().equals( "C" ) ) {
4332 if ( !it3.next().getName().equals( "D" ) ) {
4335 if ( !it3.next().getName().equals( "E" ) ) {
4338 if ( !it3.next().getName().equals( "F" ) ) {
4341 if ( !it3.next().getName().equals( "G" ) ) {
4344 if ( !it3.next().getName().equals( "1" ) ) {
4347 if ( !it3.next().getName().equals( "2" ) ) {
4350 if ( !it3.next().getName().equals( "3" ) ) {
4353 if ( !it3.next().getName().equals( "4" ) ) {
4356 if ( !it3.next().getName().equals( "5" ) ) {
4359 if ( !it3.next().getName().equals( "6" ) ) {
4362 if ( !it3.next().getName().equals( "f1" ) ) {
4365 if ( !it3.next().getName().equals( "f2" ) ) {
4368 if ( !it3.next().getName().equals( "f3" ) ) {
4371 if ( !it3.next().getName().equals( "a" ) ) {
4374 if ( !it3.next().getName().equals( "b" ) ) {
4377 if ( !it3.next().getName().equals( "f21" ) ) {
4380 if ( !it3.next().getName().equals( "X" ) ) {
4383 if ( !it3.next().getName().equals( "Y" ) ) {
4386 if ( !it3.next().getName().equals( "Z" ) ) {
4389 if ( it3.hasNext() ) {
4392 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4393 PhylogenyNodeIterator it4;
4394 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4397 for( it4.reset(); it4.hasNext(); ) {
4400 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4401 if ( !it5.next().getName().equals( "r" ) ) {
4404 if ( !it5.next().getName().equals( "A" ) ) {
4407 if ( !it5.next().getName().equals( "B" ) ) {
4410 if ( !it5.next().getName().equals( "C" ) ) {
4413 if ( !it5.next().getName().equals( "D" ) ) {
4416 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
4417 PhylogenyNodeIterator it6;
4418 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
4421 for( it6.reset(); it6.hasNext(); ) {
4424 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
4425 if ( !it7.next().getName().equals( "A" ) ) {
4428 if ( it.hasNext() ) {
4432 catch ( final Exception e ) {
4433 e.printStackTrace( System.out );
4439 private static boolean testNodeRemoval() {
4441 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4442 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4443 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
4444 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
4447 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
4448 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
4449 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
4452 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
4453 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
4454 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
4458 catch ( final Exception e ) {
4459 e.printStackTrace( System.out );
4465 private static boolean testMidpointrooting() {
4467 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4468 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
4469 PhylogenyMethods.midpointRoot( t0 );
4470 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
4473 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
4476 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
4480 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",
4481 new NHXParser() )[ 0 ];
4482 if ( !t1.isRooted() ) {
4485 PhylogenyMethods.midpointRoot( t1 );
4486 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
4489 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
4492 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
4495 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
4498 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
4501 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
4504 t1.reRoot( t1.getNode( "A" ) );
4505 PhylogenyMethods.midpointRoot( t1 );
4506 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
4509 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
4512 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
4515 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
4518 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
4522 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
4526 catch ( final Exception e ) {
4527 e.printStackTrace( System.out );
4533 private static boolean testNexusCharactersParsing() {
4535 final NexusCharactersParser parser = new NexusCharactersParser();
4536 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
4538 String[] labels = parser.getCharStateLabels();
4539 if ( labels.length != 7 ) {
4542 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4545 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4548 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4551 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4554 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4557 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4560 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4563 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
4565 labels = parser.getCharStateLabels();
4566 if ( labels.length != 7 ) {
4569 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4572 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4575 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4578 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4581 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4584 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4587 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4591 catch ( final Exception e ) {
4592 e.printStackTrace( System.out );
4598 private static boolean testNexusMatrixParsing() {
4600 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
4601 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
4603 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
4604 if ( m.getNumberOfCharacters() != 9 ) {
4607 if ( m.getNumberOfIdentifiers() != 5 ) {
4610 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
4613 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
4616 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
4619 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
4622 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
4625 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
4628 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
4631 // if ( labels.length != 7 ) {
4634 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4637 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4640 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4643 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4646 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4649 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4652 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4655 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
4657 // labels = parser.getCharStateLabels();
4658 // if ( labels.length != 7 ) {
4661 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
4664 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
4667 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
4670 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
4673 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
4676 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
4679 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
4683 catch ( final Exception e ) {
4684 e.printStackTrace( System.out );
4690 private static boolean testNexusTreeParsing() {
4692 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4693 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
4694 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
4695 if ( phylogenies.length != 1 ) {
4698 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
4701 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4705 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
4706 if ( phylogenies.length != 1 ) {
4709 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4712 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
4716 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
4717 if ( phylogenies.length != 1 ) {
4720 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
4723 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
4726 if ( phylogenies[ 0 ].isRooted() ) {
4730 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
4731 if ( phylogenies.length != 18 ) {
4734 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
4737 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
4740 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
4743 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
4746 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
4749 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
4752 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
4755 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
4758 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
4761 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
4764 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
4767 if ( phylogenies[ 8 ].isRooted() ) {
4770 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
4773 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
4776 if ( !phylogenies[ 9 ].isRooted() ) {
4779 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
4782 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
4785 if ( !phylogenies[ 10 ].isRooted() ) {
4788 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
4791 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
4794 if ( phylogenies[ 11 ].isRooted() ) {
4797 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
4800 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
4803 if ( !phylogenies[ 12 ].isRooted() ) {
4806 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
4809 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
4812 if ( !phylogenies[ 13 ].isRooted() ) {
4815 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
4818 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
4821 if ( !phylogenies[ 14 ].isRooted() ) {
4824 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
4827 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
4830 if ( phylogenies[ 15 ].isRooted() ) {
4833 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
4836 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
4839 if ( !phylogenies[ 16 ].isRooted() ) {
4842 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
4845 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
4848 if ( phylogenies[ 17 ].isRooted() ) {
4851 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
4855 catch ( final Exception e ) {
4856 e.printStackTrace( System.out );
4862 private static boolean testNexusTreeParsingIterating() {
4864 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
4865 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
4866 if ( !p.hasNext() ) {
4869 Phylogeny phy = p.next();
4870 if ( phy == null ) {
4873 if ( phy.getNumberOfExternalNodes() != 25 ) {
4876 if ( !phy.getName().equals( "" ) ) {
4879 if ( p.hasNext() ) {
4883 if ( phy != null ) {
4888 if ( !p.hasNext() ) {
4892 if ( phy == null ) {
4895 if ( phy.getNumberOfExternalNodes() != 25 ) {
4898 if ( !phy.getName().equals( "" ) ) {
4901 if ( p.hasNext() ) {
4905 if ( phy != null ) {
4909 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
4910 if ( !p.hasNext() ) {
4914 if ( phy == null ) {
4917 if ( phy.getNumberOfExternalNodes() != 10 ) {
4920 if ( !phy.getName().equals( "name" ) ) {
4923 if ( p.hasNext() ) {
4927 if ( phy != null ) {
4932 if ( !p.hasNext() ) {
4936 if ( phy == null ) {
4939 if ( phy.getNumberOfExternalNodes() != 10 ) {
4942 if ( !phy.getName().equals( "name" ) ) {
4945 if ( p.hasNext() ) {
4949 if ( phy != null ) {
4953 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
4954 if ( !p.hasNext() ) {
4958 if ( phy == null ) {
4961 if ( phy.getNumberOfExternalNodes() != 3 ) {
4964 if ( !phy.getName().equals( "" ) ) {
4967 if ( phy.isRooted() ) {
4970 if ( p.hasNext() ) {
4974 if ( phy != null ) {
4979 if ( !p.hasNext() ) {
4983 if ( phy == null ) {
4986 if ( phy.getNumberOfExternalNodes() != 3 ) {
4989 if ( !phy.getName().equals( "" ) ) {
4992 if ( p.hasNext() ) {
4996 if ( phy != null ) {
5000 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
5001 // if ( phylogenies.length != 18 ) {
5005 if ( !p.hasNext() ) {
5009 if ( phy == null ) {
5012 if ( phy.getNumberOfExternalNodes() != 10 ) {
5015 if ( !phy.getName().equals( "tree 0" ) ) {
5019 if ( !p.hasNext() ) {
5023 if ( phy == null ) {
5026 if ( phy.getNumberOfExternalNodes() != 10 ) {
5029 if ( !phy.getName().equals( "tree 1" ) ) {
5033 if ( !p.hasNext() ) {
5037 if ( phy == null ) {
5040 if ( phy.getNumberOfExternalNodes() != 3 ) {
5043 if ( !phy.getName().equals( "" ) ) {
5046 if ( phy.isRooted() ) {
5050 if ( !p.hasNext() ) {
5054 if ( phy == null ) {
5057 if ( phy.getNumberOfExternalNodes() != 4 ) {
5060 if ( !phy.getName().equals( "" ) ) {
5063 if ( !phy.isRooted() ) {
5067 if ( !p.hasNext() ) {
5071 if ( phy == null ) {
5074 if ( phy.getNumberOfExternalNodes() != 5 ) {
5075 System.out.println( phy.getNumberOfExternalNodes() );
5078 if ( !phy.getName().equals( "" ) ) {
5081 if ( !phy.isRooted() ) {
5085 if ( !p.hasNext() ) {
5089 if ( phy == null ) {
5092 if ( phy.getNumberOfExternalNodes() != 3 ) {
5095 if ( !phy.getName().equals( "" ) ) {
5098 if ( phy.isRooted() ) {
5102 if ( !p.hasNext() ) {
5106 if ( phy == null ) {
5109 if ( phy.getNumberOfExternalNodes() != 2 ) {
5112 if ( !phy.getName().equals( "" ) ) {
5115 if ( !phy.isRooted() ) {
5119 if ( !p.hasNext() ) {
5123 if ( phy.getNumberOfExternalNodes() != 3 ) {
5126 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5129 if ( !phy.isRooted() ) {
5133 if ( !p.hasNext() ) {
5137 if ( phy.getNumberOfExternalNodes() != 3 ) {
5140 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
5143 if ( !phy.getName().equals( "tree 8" ) ) {
5147 if ( !p.hasNext() ) {
5151 if ( phy.getNumberOfExternalNodes() != 3 ) {
5154 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
5157 if ( !phy.getName().equals( "tree 9" ) ) {
5161 if ( !p.hasNext() ) {
5165 if ( phy.getNumberOfExternalNodes() != 3 ) {
5168 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5171 if ( !phy.getName().equals( "tree 10" ) ) {
5174 if ( !phy.isRooted() ) {
5178 if ( !p.hasNext() ) {
5182 if ( phy.getNumberOfExternalNodes() != 3 ) {
5185 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
5188 if ( !phy.getName().equals( "tree 11" ) ) {
5191 if ( phy.isRooted() ) {
5195 if ( !p.hasNext() ) {
5199 if ( phy.getNumberOfExternalNodes() != 3 ) {
5202 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
5205 if ( !phy.getName().equals( "tree 12" ) ) {
5208 if ( !phy.isRooted() ) {
5212 if ( !p.hasNext() ) {
5216 if ( phy.getNumberOfExternalNodes() != 3 ) {
5219 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
5222 if ( !phy.getName().equals( "tree 13" ) ) {
5225 if ( !phy.isRooted() ) {
5229 if ( !p.hasNext() ) {
5233 if ( phy.getNumberOfExternalNodes() != 10 ) {
5234 System.out.println( phy.getNumberOfExternalNodes() );
5239 .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;" ) ) {
5240 System.out.println( phy.toNewHampshire() );
5243 if ( !phy.getName().equals( "tree 14" ) ) {
5246 if ( !phy.isRooted() ) {
5250 if ( !p.hasNext() ) {
5254 if ( phy.getNumberOfExternalNodes() != 10 ) {
5255 System.out.println( phy.getNumberOfExternalNodes() );
5260 .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;" ) ) {
5261 System.out.println( phy.toNewHampshire() );
5264 if ( !phy.getName().equals( "tree 15" ) ) {
5267 if ( phy.isRooted() ) {
5271 if ( !p.hasNext() ) {
5275 if ( phy.getNumberOfExternalNodes() != 10 ) {
5276 System.out.println( phy.getNumberOfExternalNodes() );
5281 .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;" ) ) {
5282 System.out.println( phy.toNewHampshire() );
5285 if ( !phy.getName().equals( "tree 16" ) ) {
5288 if ( !phy.isRooted() ) {
5292 if ( !p.hasNext() ) {
5296 if ( phy.getNumberOfExternalNodes() != 10 ) {
5297 System.out.println( phy.getNumberOfExternalNodes() );
5302 .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;" ) ) {
5303 System.out.println( phy.toNewHampshire() );
5306 if ( !phy.getName().equals( "tree 17" ) ) {
5309 if ( phy.isRooted() ) {
5313 if ( p.hasNext() ) {
5317 if ( phy != null ) {
5322 if ( !p.hasNext() ) {
5326 if ( phy == null ) {
5329 if ( phy.getNumberOfExternalNodes() != 10 ) {
5332 if ( !phy.getName().equals( "tree 0" ) ) {
5336 if ( !p.hasNext() ) {
5340 if ( phy == null ) {
5343 if ( phy.getNumberOfExternalNodes() != 10 ) {
5346 if ( !phy.getName().equals( "tree 1" ) ) {
5350 if ( !p.hasNext() ) {
5354 if ( phy == null ) {
5357 if ( phy.getNumberOfExternalNodes() != 3 ) {
5360 if ( !phy.getName().equals( "" ) ) {
5363 if ( phy.isRooted() ) {
5367 if ( !p.hasNext() ) {
5371 if ( phy == null ) {
5374 if ( phy.getNumberOfExternalNodes() != 4 ) {
5377 if ( !phy.getName().equals( "" ) ) {
5380 if ( !phy.isRooted() ) {
5384 if ( !p.hasNext() ) {
5388 if ( phy == null ) {
5391 if ( phy.getNumberOfExternalNodes() != 5 ) {
5392 System.out.println( phy.getNumberOfExternalNodes() );
5395 if ( !phy.getName().equals( "" ) ) {
5398 if ( !phy.isRooted() ) {
5402 if ( !p.hasNext() ) {
5406 if ( phy == null ) {
5409 if ( phy.getNumberOfExternalNodes() != 3 ) {
5412 if ( !phy.getName().equals( "" ) ) {
5415 if ( phy.isRooted() ) {
5419 catch ( final Exception e ) {
5420 e.printStackTrace( System.out );
5426 private static boolean testNexusTreeParsingTranslating() {
5428 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5429 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5430 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
5431 if ( phylogenies.length != 1 ) {
5434 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5437 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5440 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5443 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5446 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5447 .equals( "Aranaeus" ) ) {
5451 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
5452 if ( phylogenies.length != 3 ) {
5455 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5458 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5461 if ( phylogenies[ 0 ].isRooted() ) {
5464 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5467 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5470 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5471 .equals( "Aranaeus" ) ) {
5474 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
5477 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
5480 if ( phylogenies[ 1 ].isRooted() ) {
5483 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5486 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5489 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5490 .equals( "Aranaeus" ) ) {
5493 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5496 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
5499 if ( !phylogenies[ 2 ].isRooted() ) {
5502 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5505 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5508 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5509 .equals( "Aranaeus" ) ) {
5513 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
5514 if ( phylogenies.length != 3 ) {
5517 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5520 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
5523 if ( phylogenies[ 0 ].isRooted() ) {
5526 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5529 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5532 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5533 .equals( "Aranaeus" ) ) {
5536 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
5539 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
5542 if ( phylogenies[ 1 ].isRooted() ) {
5545 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5548 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5551 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5552 .equals( "Aranaeus" ) ) {
5555 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5558 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
5561 if ( !phylogenies[ 2 ].isRooted() ) {
5564 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
5567 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
5570 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
5571 .equals( "Aranaeus" ) ) {
5575 catch ( final Exception e ) {
5576 e.printStackTrace( System.out );
5582 private static boolean testNHParsing() {
5584 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5585 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
5586 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
5589 final NHXParser nhxp = new NHXParser();
5590 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
5591 nhxp.setReplaceUnderscores( true );
5592 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
5593 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
5596 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
5599 final Phylogeny p1b = factory
5600 .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 ",
5601 new NHXParser() )[ 0 ];
5602 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
5605 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
5608 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
5609 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
5610 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
5611 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
5612 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
5613 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
5614 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
5615 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
5616 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
5617 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
5618 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
5619 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
5620 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
5622 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
5625 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
5628 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
5631 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
5634 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
5635 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
5636 final String p16_S = "((A,B),C)";
5637 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
5638 if ( p16.length != 1 ) {
5641 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
5644 final String p17_S = "(C,(A,B))";
5645 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
5646 if ( p17.length != 1 ) {
5649 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
5652 final String p18_S = "((A,B),(C,D))";
5653 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
5654 if ( p18.length != 1 ) {
5657 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
5660 final String p19_S = "(((A,B),C),D)";
5661 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
5662 if ( p19.length != 1 ) {
5665 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
5668 final String p20_S = "(A,(B,(C,D)))";
5669 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
5670 if ( p20.length != 1 ) {
5673 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
5676 final String p21_S = "(A,(B,(C,(D,E))))";
5677 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
5678 if ( p21.length != 1 ) {
5681 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
5684 final String p22_S = "((((A,B),C),D),E)";
5685 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
5686 if ( p22.length != 1 ) {
5689 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
5692 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5693 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
5694 if ( p23.length != 1 ) {
5695 System.out.println( "xl=" + p23.length );
5699 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
5702 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5703 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
5704 if ( p24.length != 1 ) {
5707 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
5710 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5711 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5712 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
5713 if ( p241.length != 2 ) {
5716 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
5719 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
5722 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
5723 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
5724 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
5725 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
5726 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
5727 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
5728 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
5729 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
5730 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
5731 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
5734 final String p26_S = "(A,B)ab";
5735 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
5736 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
5739 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5740 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
5741 if ( p27s.length != 1 ) {
5742 System.out.println( "xxl=" + p27s.length );
5746 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
5747 System.out.println( p27s[ 0 ].toNewHampshireX() );
5751 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
5753 if ( p27.length != 1 ) {
5754 System.out.println( "yl=" + p27.length );
5758 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
5759 System.out.println( p27[ 0 ].toNewHampshireX() );
5763 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
5764 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
5765 final String p28_S3 = "(A,B)ab";
5766 final String p28_S4 = "((((A,B),C),D),;E;)";
5767 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
5769 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
5772 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
5775 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
5778 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
5781 if ( p28.length != 4 ) {
5784 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";
5785 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
5786 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
5789 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";
5790 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
5791 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
5794 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
5795 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
5796 if ( ( p32.length != 0 ) ) {
5799 final String p33_S = "A";
5800 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
5801 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
5804 final String p34_S = "B;";
5805 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
5806 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
5809 final String p35_S = "B:0.2";
5810 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
5811 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
5814 final String p36_S = "(A)";
5815 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
5816 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
5819 final String p37_S = "((A))";
5820 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
5821 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
5824 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
5825 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
5826 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
5829 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
5830 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
5831 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
5834 final String p40_S = "(A,B,C)";
5835 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
5836 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
5839 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
5840 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
5841 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
5844 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
5845 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
5846 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
5849 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)";
5850 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
5851 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
5854 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)))";
5855 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
5856 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
5859 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
5860 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
5861 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
5864 final String p46_S = "";
5865 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
5866 if ( p46.length != 0 ) {
5869 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
5870 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5873 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5874 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5877 final Phylogeny p49 = factory
5878 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
5879 new NHXParser() )[ 0 ];
5880 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
5883 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5884 if ( p50.getNode( "A" ) == null ) {
5887 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
5888 .equals( "((A,B)ab:2.0[88],C);" ) ) {
5891 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
5894 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
5895 .equals( "((A,B)88:2.0,C);" ) ) {
5898 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5899 if ( p51.getNode( "A(A" ) == null ) {
5902 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
5903 if ( p52.getNode( "A(A" ) == null ) {
5906 final Phylogeny p53 = factory
5907 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
5908 new NHXParser() )[ 0 ];
5909 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
5913 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
5914 if ( p54.getNode( "A" ) == null ) {
5917 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
5918 .equals( "((A,B)[88],C);" ) ) {
5922 catch ( final Exception e ) {
5923 e.printStackTrace( System.out );
5929 private static boolean testNHParsingIter() {
5931 final String p0_str = "(A,B);";
5932 final NHXParser p = new NHXParser();
5933 p.setSource( p0_str );
5934 if ( !p.hasNext() ) {
5937 final Phylogeny p0 = p.next();
5938 if ( !p0.toNewHampshire().equals( p0_str ) ) {
5939 System.out.println( p0.toNewHampshire() );
5942 if ( p.hasNext() ) {
5945 if ( p.next() != null ) {
5949 final String p00_str = "(A,B)root;";
5950 p.setSource( p00_str );
5951 final Phylogeny p00 = p.next();
5952 if ( !p00.toNewHampshire().equals( p00_str ) ) {
5953 System.out.println( p00.toNewHampshire() );
5957 final String p000_str = "A;";
5958 p.setSource( p000_str );
5959 final Phylogeny p000 = p.next();
5960 if ( !p000.toNewHampshire().equals( p000_str ) ) {
5961 System.out.println( p000.toNewHampshire() );
5965 final String p0000_str = "A";
5966 p.setSource( p0000_str );
5967 final Phylogeny p0000 = p.next();
5968 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
5969 System.out.println( p0000.toNewHampshire() );
5973 p.setSource( "(A)" );
5974 final Phylogeny p00000 = p.next();
5975 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
5976 System.out.println( p00000.toNewHampshire() );
5980 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
5981 p.setSource( p1_str );
5982 if ( !p.hasNext() ) {
5985 final Phylogeny p1_0 = p.next();
5986 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
5987 System.out.println( p1_0.toNewHampshire() );
5990 if ( !p.hasNext() ) {
5993 final Phylogeny p1_1 = p.next();
5994 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
5995 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
5998 if ( !p.hasNext() ) {
6001 final Phylogeny p1_2 = p.next();
6002 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
6003 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
6006 if ( !p.hasNext() ) {
6009 final Phylogeny p1_3 = p.next();
6010 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
6011 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
6014 if ( p.hasNext() ) {
6017 if ( p.next() != null ) {
6021 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
6022 p.setSource( p2_str );
6023 if ( !p.hasNext() ) {
6026 Phylogeny p2_0 = p.next();
6027 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
6028 System.out.println( p2_0.toNewHampshire() );
6031 if ( !p.hasNext() ) {
6034 Phylogeny p2_1 = p.next();
6035 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
6036 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
6039 if ( !p.hasNext() ) {
6042 Phylogeny p2_2 = p.next();
6043 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
6044 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
6047 if ( !p.hasNext() ) {
6050 Phylogeny p2_3 = p.next();
6051 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
6052 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
6055 if ( !p.hasNext() ) {
6058 Phylogeny p2_4 = p.next();
6059 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
6060 System.out.println( "(X) != " + p2_4.toNewHampshire() );
6063 if ( p.hasNext() ) {
6066 if ( p.next() != null ) {
6071 if ( !p.hasNext() ) {
6075 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
6076 System.out.println( p2_0.toNewHampshire() );
6079 if ( !p.hasNext() ) {
6083 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
6084 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
6087 if ( !p.hasNext() ) {
6091 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
6092 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
6095 if ( !p.hasNext() ) {
6099 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
6100 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
6103 if ( !p.hasNext() ) {
6107 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
6108 System.out.println( "(X) != " + p2_4.toNewHampshire() );
6111 if ( p.hasNext() ) {
6114 if ( p.next() != null ) {
6118 final String p3_str = "((A,B),C)abc";
6119 p.setSource( p3_str );
6120 if ( !p.hasNext() ) {
6123 final Phylogeny p3_0 = p.next();
6124 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
6127 if ( p.hasNext() ) {
6130 if ( p.next() != null ) {
6134 final String p4_str = "((A,B)ab,C)abc";
6135 p.setSource( p4_str );
6136 if ( !p.hasNext() ) {
6139 final Phylogeny p4_0 = p.next();
6140 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
6143 if ( p.hasNext() ) {
6146 if ( p.next() != null ) {
6150 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
6151 p.setSource( p5_str );
6152 if ( !p.hasNext() ) {
6155 final Phylogeny p5_0 = p.next();
6156 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
6159 if ( p.hasNext() ) {
6162 if ( p.next() != null ) {
6166 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6167 p.setSource( p6_str );
6168 if ( !p.hasNext() ) {
6171 Phylogeny p6_0 = p.next();
6172 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
6175 if ( p.hasNext() ) {
6178 if ( p.next() != null ) {
6182 if ( !p.hasNext() ) {
6186 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
6189 if ( p.hasNext() ) {
6192 if ( p.next() != null ) {
6196 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6197 p.setSource( p7_str );
6198 if ( !p.hasNext() ) {
6201 Phylogeny p7_0 = p.next();
6202 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6205 if ( p.hasNext() ) {
6208 if ( p.next() != null ) {
6212 if ( !p.hasNext() ) {
6216 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6219 if ( p.hasNext() ) {
6222 if ( p.next() != null ) {
6226 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
6227 p.setSource( p8_str );
6228 if ( !p.hasNext() ) {
6231 Phylogeny p8_0 = p.next();
6232 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6235 if ( !p.hasNext() ) {
6238 if ( !p.hasNext() ) {
6241 Phylogeny p8_1 = p.next();
6242 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
6245 if ( p.hasNext() ) {
6248 if ( p.next() != null ) {
6252 if ( !p.hasNext() ) {
6256 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
6259 if ( !p.hasNext() ) {
6263 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
6266 if ( p.hasNext() ) {
6269 if ( p.next() != null ) {
6275 if ( p.hasNext() ) {
6279 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
6280 if ( !p.hasNext() ) {
6283 Phylogeny p_27 = p.next();
6284 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
6285 System.out.println( p_27.toNewHampshireX() );
6289 if ( p.hasNext() ) {
6292 if ( p.next() != null ) {
6296 if ( !p.hasNext() ) {
6300 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
6301 System.out.println( p_27.toNewHampshireX() );
6305 if ( p.hasNext() ) {
6308 if ( p.next() != null ) {
6312 catch ( final Exception e ) {
6313 e.printStackTrace( System.out );
6319 private static boolean testNHXconversion() {
6321 final PhylogenyNode n1 = new PhylogenyNode();
6322 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
6323 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
6324 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
6325 final PhylogenyNode n5 = PhylogenyNode
6326 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
6327 final PhylogenyNode n6 = PhylogenyNode
6328 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
6329 if ( !n1.toNewHampshireX().equals( "" ) ) {
6332 if ( !n2.toNewHampshireX().equals( "" ) ) {
6335 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
6338 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
6341 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
6344 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
6345 System.out.println( n6.toNewHampshireX() );
6349 catch ( final Exception e ) {
6350 e.printStackTrace( System.out );
6356 private static boolean testTaxonomyExtraction() {
6358 final PhylogenyNode n0 = PhylogenyNode
6359 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6360 if ( n0.getNodeData().isHasTaxonomy() ) {
6363 final PhylogenyNode n1 = PhylogenyNode
6364 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6365 if ( n1.getNodeData().isHasTaxonomy() ) {
6366 System.out.println( n1.toString() );
6369 final PhylogenyNode n2x = PhylogenyNode
6370 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6371 if ( n2x.getNodeData().isHasTaxonomy() ) {
6374 final PhylogenyNode n3 = PhylogenyNode
6375 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6376 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6377 System.out.println( n3.toString() );
6380 final PhylogenyNode n4 = PhylogenyNode
6381 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6382 if ( n4.getNodeData().isHasTaxonomy() ) {
6383 System.out.println( n4.toString() );
6386 final PhylogenyNode n5 = PhylogenyNode
6387 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6388 if ( n5.getNodeData().isHasTaxonomy() ) {
6389 System.out.println( n5.toString() );
6392 final PhylogenyNode n6 = PhylogenyNode
6393 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6394 if ( n6.getNodeData().isHasTaxonomy() ) {
6395 System.out.println( n6.toString() );
6398 final PhylogenyNode n7 = PhylogenyNode
6399 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6400 if ( n7.getNodeData().isHasTaxonomy() ) {
6401 System.out.println( n7.toString() );
6404 final PhylogenyNode n8 = PhylogenyNode
6405 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6406 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6407 System.out.println( n8.toString() );
6410 final PhylogenyNode n9 = PhylogenyNode
6411 .createInstanceFromNhxString( "blag_12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6412 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6413 System.out.println( n9.toString() );
6416 final PhylogenyNode n10x = PhylogenyNode
6417 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6418 if ( n10x.getNodeData().isHasTaxonomy() ) {
6419 System.out.println( n10x.toString() );
6422 final PhylogenyNode n10xx = PhylogenyNode
6423 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6424 if ( n10xx.getNodeData().isHasTaxonomy() ) {
6425 System.out.println( n10xx.toString() );
6428 final PhylogenyNode n10 = PhylogenyNode
6429 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6430 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
6431 System.out.println( n10.toString() );
6434 final PhylogenyNode n11 = PhylogenyNode
6435 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6436 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
6437 System.out.println( n11.toString() );
6440 final PhylogenyNode n12 = PhylogenyNode
6441 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
6442 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6443 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
6444 System.out.println( n12.toString() );
6447 final PhylogenyNode n13 = PhylogenyNode
6448 .createInstanceFromNhxString( "BLAG_Mus_musculus1",
6449 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6450 if ( n13.getNodeData().isHasTaxonomy() ) {
6451 System.out.println( n13.toString() );
6454 final PhylogenyNode n14 = PhylogenyNode
6455 .createInstanceFromNhxString( "BLAG_Mus_musculus_11",
6456 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6457 if ( n14.getNodeData().isHasTaxonomy() ) {
6458 System.out.println( n14.toString() );
6461 final PhylogenyNode n16 = PhylogenyNode
6462 .createInstanceFromNhxString( "BLAG_Mus_musculus_/11",
6463 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6464 if ( n16.getNodeData().isHasTaxonomy() ) {
6465 System.out.println( n16.toString() );
6469 catch ( final Exception e ) {
6470 e.printStackTrace( System.out );
6476 private static boolean testNHXNodeParsing() {
6478 final PhylogenyNode n1 = new PhylogenyNode();
6479 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
6480 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
6481 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
6482 final PhylogenyNode n5 = PhylogenyNode
6483 .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]" );
6484 if ( !n3.getName().equals( "n3" ) ) {
6487 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6490 if ( n3.isDuplication() ) {
6493 if ( n3.isHasAssignedEvent() ) {
6496 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
6499 if ( !n4.getName().equals( "n4" ) ) {
6502 if ( n4.getDistanceToParent() != 0.01 ) {
6505 if ( !n5.getName().equals( "n5" ) ) {
6508 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
6511 if ( n5.getDistanceToParent() != 0.1 ) {
6514 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
6517 if ( !n5.isDuplication() ) {
6520 if ( !n5.isHasAssignedEvent() ) {
6523 final PhylogenyNode n8 = PhylogenyNode
6524 .createInstanceFromNhxString( "N8_ECOLI/1-2:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6525 if ( !n8.getName().equals( "N8_ECOLI/1-2" ) ) {
6528 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
6531 final PhylogenyNode n9 = PhylogenyNode
6532 .createInstanceFromNhxString( "N9_ECOLI/1-12:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6533 if ( !n9.getName().equals( "N9_ECOLI/1-12" ) ) {
6536 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
6539 final PhylogenyNode n10 = PhylogenyNode
6540 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6541 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
6544 final PhylogenyNode n20 = PhylogenyNode
6545 .createInstanceFromNhxString( "N20_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6546 if ( !n20.getName().equals( "N20_ECOLI/1-2" ) ) {
6549 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
6552 final PhylogenyNode n20x = PhylogenyNode
6553 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6554 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
6557 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
6560 final PhylogenyNode n20xx = PhylogenyNode
6561 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6562 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
6565 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
6568 final PhylogenyNode n20xxx = PhylogenyNode
6569 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6570 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
6573 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
6576 final PhylogenyNode n20xxxx = PhylogenyNode
6577 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6578 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
6581 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
6584 final PhylogenyNode n21 = PhylogenyNode
6585 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6586 if ( !n21.getName().equals( "N21_PIG" ) ) {
6589 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
6592 final PhylogenyNode n21x = PhylogenyNode
6593 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6594 if ( !n21x.getName().equals( "n21_PIG" ) ) {
6597 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
6600 final PhylogenyNode n22 = PhylogenyNode
6601 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6602 if ( !n22.getName().equals( "n22/PIG" ) ) {
6605 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
6608 final PhylogenyNode n23 = PhylogenyNode
6609 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6610 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
6613 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
6616 final PhylogenyNode a = PhylogenyNode
6617 .createInstanceFromNhxString( "N10_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6618 if ( !a.getName().equals( "N10_ECOLI/1-2" ) ) {
6621 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
6624 final PhylogenyNode c1 = PhylogenyNode
6625 .createInstanceFromNhxString( "n10_BOVIN_1/1000-2000",
6626 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6627 if ( !c1.getName().equals( "n10_BOVIN_1/1000-2000" ) ) {
6630 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
6633 final PhylogenyNode c2 = PhylogenyNode
6634 .createInstanceFromNhxString( "n10_Bovin_1/1000-2000",
6635 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6636 if ( !c2.getName().equals( "n10_Bovin_1/1000-2000" ) ) {
6639 if ( !PhylogenyMethods.getSpecies( c2 ).equals( "" ) ) {
6642 final PhylogenyNode e3 = PhylogenyNode
6643 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6644 if ( !e3.getName().equals( "n10_RAT~" ) ) {
6647 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
6650 final PhylogenyNode n11 = PhylogenyNode
6651 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
6652 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6653 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
6656 if ( n11.getDistanceToParent() != 0.4 ) {
6659 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
6662 final PhylogenyNode n12 = PhylogenyNode
6663 .createInstanceFromNhxString( "n111111-ECOLI---/jdj:0.4",
6664 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6665 if ( !n12.getName().equals( "n111111-ECOLI---/jdj" ) ) {
6668 if ( n12.getDistanceToParent() != 0.4 ) {
6671 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
6674 final PhylogenyNode o = PhylogenyNode
6675 .createInstanceFromNhxString( "n10_MOUSE_", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6676 if ( !o.getName().equals( "n10_MOUSE_" ) ) {
6679 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
6682 if ( n1.getName().compareTo( "" ) != 0 ) {
6685 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
6688 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6691 if ( n2.getName().compareTo( "" ) != 0 ) {
6694 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
6697 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
6700 final PhylogenyNode n00 = PhylogenyNode
6701 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
6702 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
6705 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
6708 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
6709 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
6712 final PhylogenyNode n13 = PhylogenyNode
6713 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6714 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
6717 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
6720 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6723 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6726 final PhylogenyNode n14 = PhylogenyNode
6727 .createInstanceFromNhxString( "BLA_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6728 if ( !n14.getName().equals( "BLA_9QX45/1-2" ) ) {
6731 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
6734 final PhylogenyNode n15 = PhylogenyNode
6735 .createInstanceFromNhxString( "something_wicked[123]",
6736 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6737 if ( !n15.getName().equals( "something_wicked" ) ) {
6740 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
6743 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
6746 final PhylogenyNode n16 = PhylogenyNode
6747 .createInstanceFromNhxString( "something_wicked2[9]",
6748 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6749 if ( !n16.getName().equals( "something_wicked2" ) ) {
6752 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
6755 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
6758 final PhylogenyNode n17 = PhylogenyNode
6759 .createInstanceFromNhxString( "something_wicked3[a]",
6760 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6761 if ( !n17.getName().equals( "something_wicked3" ) ) {
6764 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
6767 final PhylogenyNode n18 = PhylogenyNode
6768 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6769 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
6772 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
6775 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
6778 final PhylogenyNode n19 = PhylogenyNode
6779 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6780 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
6783 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6786 final PhylogenyNode n30 = PhylogenyNode
6787 .createInstanceFromNhxString( "blah_1234567-roejojoej",
6788 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6789 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
6792 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
6795 final PhylogenyNode n31 = PhylogenyNode
6796 .createInstanceFromNhxString( "blah_12345678-roejojoej",
6797 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6798 if ( n31.getNodeData().isHasTaxonomy() ) {
6801 final PhylogenyNode n32 = PhylogenyNode
6802 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6803 if ( n32.getNodeData().isHasTaxonomy() ) {
6806 final PhylogenyNode n40 = PhylogenyNode
6807 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6808 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
6811 final PhylogenyNode n41 = PhylogenyNode
6812 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6813 if ( n41.getNodeData().isHasTaxonomy() ) {
6816 final PhylogenyNode n42 = PhylogenyNode
6817 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
6818 if ( n42.getNodeData().isHasTaxonomy() ) {
6821 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
6822 NHXParser.TAXONOMY_EXTRACTION.NO );
6823 if ( n43.getNodeData().isHasTaxonomy() ) {
6826 final PhylogenyNode n44 = PhylogenyNode
6827 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
6828 if ( n44.getNodeData().isHasTaxonomy() ) {
6832 catch ( final Exception e ) {
6833 e.printStackTrace( System.out );
6839 private static boolean testNHXParsing() {
6841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6842 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
6843 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
6846 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]";
6847 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
6848 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6851 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]";
6852 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
6853 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
6856 final Phylogeny[] p3 = factory
6857 .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]",
6859 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6862 final Phylogeny[] p4 = factory
6863 .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(]",
6865 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6868 final Phylogeny[] p5 = factory
6869 .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(((]",
6871 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
6874 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)";
6875 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)";
6876 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
6877 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
6880 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)))";
6881 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)))";
6882 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
6883 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
6886 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]) ))[,,, ])))))))";
6887 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
6888 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
6889 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
6892 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
6893 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
6896 final Phylogeny p10 = factory
6897 .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]",
6898 new NHXParser() )[ 0 ];
6899 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
6903 catch ( final Exception e ) {
6904 e.printStackTrace( System.out );
6910 private static boolean testNHXParsingQuotes() {
6912 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6913 final NHXParser p = new NHXParser();
6914 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
6915 if ( phylogenies_0.length != 5 ) {
6918 final Phylogeny phy = phylogenies_0[ 4 ];
6919 if ( phy.getNumberOfExternalNodes() != 7 ) {
6922 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
6925 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
6928 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
6929 .getScientificName().equals( "hsapiens" ) ) {
6932 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
6935 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
6938 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
6941 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
6944 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
6947 final NHXParser p1p = new NHXParser();
6948 p1p.setIgnoreQuotes( true );
6949 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
6950 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
6953 final NHXParser p2p = new NHXParser();
6954 p1p.setIgnoreQuotes( false );
6955 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
6956 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
6959 final NHXParser p3p = new NHXParser();
6960 p3p.setIgnoreQuotes( false );
6961 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
6962 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
6965 final NHXParser p4p = new NHXParser();
6966 p4p.setIgnoreQuotes( false );
6967 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
6968 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
6971 final Phylogeny p10 = factory
6972 .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]",
6973 new NHXParser() )[ 0 ];
6974 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]";
6975 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
6978 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
6979 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
6983 final Phylogeny p12 = factory
6984 .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]",
6985 new NHXParser() )[ 0 ];
6986 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]";
6987 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
6990 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
6991 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
6994 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;";
6995 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
6998 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
6999 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
7003 catch ( final Exception e ) {
7004 e.printStackTrace( System.out );
7010 private static boolean testNHXParsingMB() {
7012 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7013 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7014 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7015 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7016 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7017 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7018 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7019 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7020 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7021 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7022 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7025 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7028 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
7029 0.1100000000000000e+00 ) ) {
7032 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
7035 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
7038 final Phylogeny p2 = factory
7039 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
7040 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7041 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7042 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7043 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7044 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7045 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7046 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7047 + "7.369400000000000e-02}])",
7048 new NHXParser() )[ 0 ];
7049 if ( p2.getNode( "1" ) == null ) {
7052 if ( p2.getNode( "2" ) == null ) {
7056 catch ( final Exception e ) {
7057 e.printStackTrace( System.out );
7064 private static boolean testPhylogenyBranch() {
7066 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
7067 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
7068 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
7069 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
7070 if ( !a1b1.equals( a1b1 ) ) {
7073 if ( !a1b1.equals( b1a1 ) ) {
7076 if ( !b1a1.equals( a1b1 ) ) {
7079 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
7080 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
7081 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
7082 if ( a1_b1.equals( b1_a1 ) ) {
7085 if ( a1_b1.equals( a1_b1_ ) ) {
7088 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
7089 if ( !a1_b1.equals( b1_a1_ ) ) {
7092 if ( a1_b1_.equals( b1_a1_ ) ) {
7095 if ( !a1_b1_.equals( b1_a1 ) ) {
7099 catch ( final Exception e ) {
7100 e.printStackTrace( System.out );
7106 private static boolean testPhyloXMLparsingOfDistributionElement() {
7108 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7109 PhyloXmlParser xml_parser = null;
7111 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
7113 catch ( final Exception e ) {
7114 // Do nothing -- means were not running from jar.
7116 if ( xml_parser == null ) {
7117 xml_parser = new PhyloXmlParser();
7118 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
7119 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
7122 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
7125 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
7127 if ( xml_parser.getErrorCount() > 0 ) {
7128 System.out.println( xml_parser.getErrorMessages().toString() );
7131 if ( phylogenies_0.length != 1 ) {
7134 final Phylogeny t1 = phylogenies_0[ 0 ];
7135 PhylogenyNode n = null;
7136 Distribution d = null;
7137 n = t1.getNode( "root node" );
7138 if ( !n.getNodeData().isHasDistribution() ) {
7141 if ( n.getNodeData().getDistributions().size() != 1 ) {
7144 d = n.getNodeData().getDistribution();
7145 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
7148 if ( d.getPoints().size() != 1 ) {
7151 if ( d.getPolygons() != null ) {
7154 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
7157 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7160 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7163 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
7166 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
7169 n = t1.getNode( "node a" );
7170 if ( !n.getNodeData().isHasDistribution() ) {
7173 if ( n.getNodeData().getDistributions().size() != 2 ) {
7176 d = n.getNodeData().getDistribution( 1 );
7177 if ( !d.getDesc().equals( "San Diego" ) ) {
7180 if ( d.getPoints().size() != 1 ) {
7183 if ( d.getPolygons() != null ) {
7186 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
7189 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7192 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7195 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
7198 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
7201 n = t1.getNode( "node bb" );
7202 if ( !n.getNodeData().isHasDistribution() ) {
7205 if ( n.getNodeData().getDistributions().size() != 1 ) {
7208 d = n.getNodeData().getDistribution( 0 );
7209 if ( d.getPoints().size() != 3 ) {
7212 if ( d.getPolygons().size() != 2 ) {
7215 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
7218 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
7221 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
7224 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
7227 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
7230 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
7233 Polygon p = d.getPolygons().get( 0 );
7234 if ( p.getPoints().size() != 3 ) {
7237 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
7240 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
7243 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7246 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
7249 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
7252 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
7255 p = d.getPolygons().get( 1 );
7256 if ( p.getPoints().size() != 3 ) {
7259 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
7262 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
7265 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7269 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
7270 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
7271 if ( rt.length != 1 ) {
7274 final Phylogeny t1_rt = rt[ 0 ];
7275 n = t1_rt.getNode( "root node" );
7276 if ( !n.getNodeData().isHasDistribution() ) {
7279 if ( n.getNodeData().getDistributions().size() != 1 ) {
7282 d = n.getNodeData().getDistribution();
7283 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
7286 if ( d.getPoints().size() != 1 ) {
7289 if ( d.getPolygons() != null ) {
7292 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
7295 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7298 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7301 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
7304 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
7307 n = t1_rt.getNode( "node a" );
7308 if ( !n.getNodeData().isHasDistribution() ) {
7311 if ( n.getNodeData().getDistributions().size() != 2 ) {
7314 d = n.getNodeData().getDistribution( 1 );
7315 if ( !d.getDesc().equals( "San Diego" ) ) {
7318 if ( d.getPoints().size() != 1 ) {
7321 if ( d.getPolygons() != null ) {
7324 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
7327 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
7330 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
7333 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
7336 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
7339 n = t1_rt.getNode( "node bb" );
7340 if ( !n.getNodeData().isHasDistribution() ) {
7343 if ( n.getNodeData().getDistributions().size() != 1 ) {
7346 d = n.getNodeData().getDistribution( 0 );
7347 if ( d.getPoints().size() != 3 ) {
7350 if ( d.getPolygons().size() != 2 ) {
7353 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
7356 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
7359 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
7362 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
7365 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
7368 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
7371 p = d.getPolygons().get( 0 );
7372 if ( p.getPoints().size() != 3 ) {
7375 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
7378 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
7381 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7384 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
7387 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
7390 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
7393 p = d.getPolygons().get( 1 );
7394 if ( p.getPoints().size() != 3 ) {
7397 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
7400 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
7403 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
7407 catch ( final Exception e ) {
7408 e.printStackTrace( System.out );
7414 private static boolean testPostOrderIterator() {
7416 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7417 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
7418 PhylogenyNodeIterator it0;
7419 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
7422 for( it0.reset(); it0.hasNext(); ) {
7425 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
7426 final PhylogenyNodeIterator it = t1.iteratorPostorder();
7427 if ( !it.next().getName().equals( "A" ) ) {
7430 if ( !it.next().getName().equals( "B" ) ) {
7433 if ( !it.next().getName().equals( "ab" ) ) {
7436 if ( !it.next().getName().equals( "C" ) ) {
7439 if ( !it.next().getName().equals( "D" ) ) {
7442 if ( !it.next().getName().equals( "cd" ) ) {
7445 if ( !it.next().getName().equals( "abcd" ) ) {
7448 if ( !it.next().getName().equals( "E" ) ) {
7451 if ( !it.next().getName().equals( "F" ) ) {
7454 if ( !it.next().getName().equals( "ef" ) ) {
7457 if ( !it.next().getName().equals( "G" ) ) {
7460 if ( !it.next().getName().equals( "H" ) ) {
7463 if ( !it.next().getName().equals( "gh" ) ) {
7466 if ( !it.next().getName().equals( "efgh" ) ) {
7469 if ( !it.next().getName().equals( "r" ) ) {
7472 if ( it.hasNext() ) {
7476 catch ( final Exception e ) {
7477 e.printStackTrace( System.out );
7483 private static boolean testPreOrderIterator() {
7485 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7486 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
7487 PhylogenyNodeIterator it0;
7488 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
7491 for( it0.reset(); it0.hasNext(); ) {
7494 PhylogenyNodeIterator it = t0.iteratorPreorder();
7495 if ( !it.next().getName().equals( "r" ) ) {
7498 if ( !it.next().getName().equals( "ab" ) ) {
7501 if ( !it.next().getName().equals( "A" ) ) {
7504 if ( !it.next().getName().equals( "B" ) ) {
7507 if ( !it.next().getName().equals( "cd" ) ) {
7510 if ( !it.next().getName().equals( "C" ) ) {
7513 if ( !it.next().getName().equals( "D" ) ) {
7516 if ( it.hasNext() ) {
7519 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
7520 it = t1.iteratorPreorder();
7521 if ( !it.next().getName().equals( "r" ) ) {
7524 if ( !it.next().getName().equals( "abcd" ) ) {
7527 if ( !it.next().getName().equals( "ab" ) ) {
7530 if ( !it.next().getName().equals( "A" ) ) {
7533 if ( !it.next().getName().equals( "B" ) ) {
7536 if ( !it.next().getName().equals( "cd" ) ) {
7539 if ( !it.next().getName().equals( "C" ) ) {
7542 if ( !it.next().getName().equals( "D" ) ) {
7545 if ( !it.next().getName().equals( "efgh" ) ) {
7548 if ( !it.next().getName().equals( "ef" ) ) {
7551 if ( !it.next().getName().equals( "E" ) ) {
7554 if ( !it.next().getName().equals( "F" ) ) {
7557 if ( !it.next().getName().equals( "gh" ) ) {
7560 if ( !it.next().getName().equals( "G" ) ) {
7563 if ( !it.next().getName().equals( "H" ) ) {
7566 if ( it.hasNext() ) {
7570 catch ( final Exception e ) {
7571 e.printStackTrace( System.out );
7577 private static boolean testPropertiesMap() {
7579 final PropertiesMap pm = new PropertiesMap();
7580 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
7581 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
7582 final Property p2 = new Property( "something:else",
7584 "improbable:research",
7587 pm.addProperty( p0 );
7588 pm.addProperty( p1 );
7589 pm.addProperty( p2 );
7590 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
7593 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
7596 if ( pm.getProperties().size() != 3 ) {
7599 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
7602 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
7605 if ( pm.getProperties().size() != 3 ) {
7608 pm.removeProperty( "dimensions:diameter" );
7609 if ( pm.getProperties().size() != 2 ) {
7612 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
7615 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
7619 catch ( final Exception e ) {
7620 e.printStackTrace( System.out );
7626 private static boolean testReIdMethods() {
7628 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7629 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
7630 final long count = PhylogenyNode.getNodeCount();
7632 if ( p.getNode( "r" ).getId() != count ) {
7635 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
7638 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
7641 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
7644 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
7647 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
7650 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
7653 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
7656 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
7659 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
7662 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
7665 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
7668 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
7671 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
7674 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
7678 catch ( final Exception e ) {
7679 e.printStackTrace( System.out );
7685 private static boolean testRerooting() {
7687 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7688 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",
7689 new NHXParser() )[ 0 ];
7690 if ( !t1.isRooted() ) {
7693 t1.reRoot( t1.getNode( "D" ) );
7694 t1.reRoot( t1.getNode( "CD" ) );
7695 t1.reRoot( t1.getNode( "A" ) );
7696 t1.reRoot( t1.getNode( "B" ) );
7697 t1.reRoot( t1.getNode( "AB" ) );
7698 t1.reRoot( t1.getNode( "D" ) );
7699 t1.reRoot( t1.getNode( "C" ) );
7700 t1.reRoot( t1.getNode( "CD" ) );
7701 t1.reRoot( t1.getNode( "A" ) );
7702 t1.reRoot( t1.getNode( "B" ) );
7703 t1.reRoot( t1.getNode( "AB" ) );
7704 t1.reRoot( t1.getNode( "D" ) );
7705 t1.reRoot( t1.getNode( "D" ) );
7706 t1.reRoot( t1.getNode( "C" ) );
7707 t1.reRoot( t1.getNode( "A" ) );
7708 t1.reRoot( t1.getNode( "B" ) );
7709 t1.reRoot( t1.getNode( "AB" ) );
7710 t1.reRoot( t1.getNode( "C" ) );
7711 t1.reRoot( t1.getNode( "D" ) );
7712 t1.reRoot( t1.getNode( "CD" ) );
7713 t1.reRoot( t1.getNode( "D" ) );
7714 t1.reRoot( t1.getNode( "A" ) );
7715 t1.reRoot( t1.getNode( "B" ) );
7716 t1.reRoot( t1.getNode( "AB" ) );
7717 t1.reRoot( t1.getNode( "C" ) );
7718 t1.reRoot( t1.getNode( "D" ) );
7719 t1.reRoot( t1.getNode( "CD" ) );
7720 t1.reRoot( t1.getNode( "D" ) );
7721 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
7724 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
7727 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
7730 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
7733 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
7736 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
7739 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",
7740 new NHXParser() )[ 0 ];
7741 t2.reRoot( t2.getNode( "A" ) );
7742 t2.reRoot( t2.getNode( "D" ) );
7743 t2.reRoot( t2.getNode( "ABC" ) );
7744 t2.reRoot( t2.getNode( "A" ) );
7745 t2.reRoot( t2.getNode( "B" ) );
7746 t2.reRoot( t2.getNode( "D" ) );
7747 t2.reRoot( t2.getNode( "C" ) );
7748 t2.reRoot( t2.getNode( "ABC" ) );
7749 t2.reRoot( t2.getNode( "A" ) );
7750 t2.reRoot( t2.getNode( "B" ) );
7751 t2.reRoot( t2.getNode( "AB" ) );
7752 t2.reRoot( t2.getNode( "AB" ) );
7753 t2.reRoot( t2.getNode( "D" ) );
7754 t2.reRoot( t2.getNode( "C" ) );
7755 t2.reRoot( t2.getNode( "B" ) );
7756 t2.reRoot( t2.getNode( "AB" ) );
7757 t2.reRoot( t2.getNode( "D" ) );
7758 t2.reRoot( t2.getNode( "D" ) );
7759 t2.reRoot( t2.getNode( "ABC" ) );
7760 t2.reRoot( t2.getNode( "A" ) );
7761 t2.reRoot( t2.getNode( "B" ) );
7762 t2.reRoot( t2.getNode( "AB" ) );
7763 t2.reRoot( t2.getNode( "D" ) );
7764 t2.reRoot( t2.getNode( "C" ) );
7765 t2.reRoot( t2.getNode( "ABC" ) );
7766 t2.reRoot( t2.getNode( "A" ) );
7767 t2.reRoot( t2.getNode( "B" ) );
7768 t2.reRoot( t2.getNode( "AB" ) );
7769 t2.reRoot( t2.getNode( "D" ) );
7770 t2.reRoot( t2.getNode( "D" ) );
7771 t2.reRoot( t2.getNode( "C" ) );
7772 t2.reRoot( t2.getNode( "A" ) );
7773 t2.reRoot( t2.getNode( "B" ) );
7774 t2.reRoot( t2.getNode( "AB" ) );
7775 t2.reRoot( t2.getNode( "C" ) );
7776 t2.reRoot( t2.getNode( "D" ) );
7777 t2.reRoot( t2.getNode( "ABC" ) );
7778 t2.reRoot( t2.getNode( "D" ) );
7779 t2.reRoot( t2.getNode( "A" ) );
7780 t2.reRoot( t2.getNode( "B" ) );
7781 t2.reRoot( t2.getNode( "AB" ) );
7782 t2.reRoot( t2.getNode( "C" ) );
7783 t2.reRoot( t2.getNode( "D" ) );
7784 t2.reRoot( t2.getNode( "ABC" ) );
7785 t2.reRoot( t2.getNode( "D" ) );
7786 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7789 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7792 t2.reRoot( t2.getNode( "ABC" ) );
7793 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7796 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7799 t2.reRoot( t2.getNode( "AB" ) );
7800 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7803 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7806 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7809 t2.reRoot( t2.getNode( "AB" ) );
7810 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7813 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7816 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7819 t2.reRoot( t2.getNode( "D" ) );
7820 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7823 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7826 t2.reRoot( t2.getNode( "ABC" ) );
7827 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
7830 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
7833 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
7834 new NHXParser() )[ 0 ];
7835 t3.reRoot( t3.getNode( "B" ) );
7836 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7839 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7842 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7845 t3.reRoot( t3.getNode( "B" ) );
7846 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7849 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7852 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7855 t3.reRoot( t3.getRoot() );
7856 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7859 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
7862 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
7866 catch ( final Exception e ) {
7867 e.printStackTrace( System.out );
7873 private static boolean testSDIse() {
7875 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7876 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
7877 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
7878 gene1.setRooted( true );
7879 species1.setRooted( true );
7880 final SDI sdi = new SDI( gene1, species1 );
7881 if ( !gene1.getRoot().isDuplication() ) {
7884 final Phylogeny species2 = factory
7885 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7886 new NHXParser() )[ 0 ];
7887 final Phylogeny gene2 = factory
7888 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7889 new NHXParser() )[ 0 ];
7890 species2.setRooted( true );
7891 gene2.setRooted( true );
7892 final SDI sdi2 = new SDI( gene2, species2 );
7893 if ( sdi2.getDuplicationsSum() != 0 ) {
7896 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
7899 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
7902 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
7905 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
7908 if ( !gene2.getNode( "r" ).isSpeciation() ) {
7911 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
7914 final Phylogeny species3 = factory
7915 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7916 new NHXParser() )[ 0 ];
7917 final Phylogeny gene3 = factory
7918 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7919 new NHXParser() )[ 0 ];
7920 species3.setRooted( true );
7921 gene3.setRooted( true );
7922 final SDI sdi3 = new SDI( gene3, species3 );
7923 if ( sdi3.getDuplicationsSum() != 1 ) {
7926 if ( !gene3.getNode( "aa" ).isDuplication() ) {
7929 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
7932 final Phylogeny species4 = factory
7933 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7934 new NHXParser() )[ 0 ];
7935 final Phylogeny gene4 = factory
7936 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7937 new NHXParser() )[ 0 ];
7938 species4.setRooted( true );
7939 gene4.setRooted( true );
7940 final SDI sdi4 = new SDI( gene4, species4 );
7941 if ( sdi4.getDuplicationsSum() != 1 ) {
7944 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
7947 if ( !gene4.getNode( "abc" ).isDuplication() ) {
7950 if ( gene4.getNode( "abcd" ).isDuplication() ) {
7953 if ( species4.getNumberOfExternalNodes() != 6 ) {
7956 if ( gene4.getNumberOfExternalNodes() != 6 ) {
7959 final Phylogeny species5 = factory
7960 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
7961 new NHXParser() )[ 0 ];
7962 final Phylogeny gene5 = factory
7963 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
7964 new NHXParser() )[ 0 ];
7965 species5.setRooted( true );
7966 gene5.setRooted( true );
7967 final SDI sdi5 = new SDI( gene5, species5 );
7968 if ( sdi5.getDuplicationsSum() != 2 ) {
7971 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
7974 if ( !gene5.getNode( "adc" ).isDuplication() ) {
7977 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
7980 if ( species5.getNumberOfExternalNodes() != 6 ) {
7983 if ( gene5.getNumberOfExternalNodes() != 6 ) {
7986 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
7987 // Conjecture for Comparing Molecular Phylogenies"
7988 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
7989 final Phylogeny species6 = factory
7990 .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,"
7991 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
7992 new NHXParser() )[ 0 ];
7993 final Phylogeny gene6 = factory
7994 .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,"
7995 + "((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,"
7996 + "(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;",
7997 new NHXParser() )[ 0 ];
7998 species6.setRooted( true );
7999 gene6.setRooted( true );
8000 final SDI sdi6 = new SDI( gene6, species6 );
8001 if ( sdi6.getDuplicationsSum() != 3 ) {
8004 if ( !gene6.getNode( "r" ).isDuplication() ) {
8007 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
8010 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
8013 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
8016 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
8019 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
8022 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
8025 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
8028 sdi6.computeMappingCostL();
8029 if ( sdi6.computeMappingCostL() != 17 ) {
8032 if ( species6.getNumberOfExternalNodes() != 9 ) {
8035 if ( gene6.getNumberOfExternalNodes() != 9 ) {
8038 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
8039 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
8040 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
8041 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
8042 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
8043 species7.setRooted( true );
8044 final Phylogeny gene7_1 = Test
8045 .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])" );
8046 gene7_1.setRooted( true );
8047 final SDI sdi7 = new SDI( gene7_1, species7 );
8048 if ( sdi7.getDuplicationsSum() != 0 ) {
8051 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
8054 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
8057 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
8060 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
8063 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
8066 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
8069 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
8072 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
8075 final Phylogeny gene7_2 = Test
8076 .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])" );
8077 gene7_2.setRooted( true );
8078 final SDI sdi7_2 = new SDI( gene7_2, species7 );
8079 if ( sdi7_2.getDuplicationsSum() != 1 ) {
8082 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
8085 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
8088 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
8091 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
8094 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
8097 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
8100 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
8103 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
8106 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
8110 catch ( final Exception e ) {
8116 private static boolean testSDIunrooted() {
8118 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8119 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
8120 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
8121 final Iterator<PhylogenyBranch> iter = l.iterator();
8122 PhylogenyBranch br = iter.next();
8123 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
8126 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
8130 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
8133 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
8137 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
8140 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
8144 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8147 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8151 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8154 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8158 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
8161 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
8165 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8168 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8172 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8175 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8179 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8182 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8186 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
8189 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
8193 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
8196 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
8200 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
8203 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
8207 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
8210 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
8214 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
8217 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
8221 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
8224 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
8227 if ( iter.hasNext() ) {
8230 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
8231 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
8232 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
8234 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
8237 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
8241 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8244 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8248 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8251 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8254 if ( iter1.hasNext() ) {
8257 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
8258 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
8259 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
8261 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
8264 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
8268 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
8271 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
8275 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
8278 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
8281 if ( iter2.hasNext() ) {
8284 final Phylogeny species0 = factory
8285 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
8286 new NHXParser() )[ 0 ];
8287 final Phylogeny gene1 = factory
8288 .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])",
8289 new NHXParser() )[ 0 ];
8290 species0.setRooted( true );
8291 gene1.setRooted( true );
8292 final SDIR sdi_unrooted = new SDIR();
8293 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
8294 if ( sdi_unrooted.getCount() != 1 ) {
8297 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
8300 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
8303 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
8306 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8309 final Phylogeny gene2 = factory
8310 .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])",
8311 new NHXParser() )[ 0 ];
8312 gene2.setRooted( true );
8313 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
8314 if ( sdi_unrooted.getCount() != 1 ) {
8317 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8320 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8323 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
8326 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8329 final Phylogeny species6 = factory
8330 .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,"
8331 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8332 new NHXParser() )[ 0 ];
8333 final Phylogeny gene6 = factory
8334 .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],"
8335 + "(((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],"
8336 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8337 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8338 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8339 new NHXParser() )[ 0 ];
8340 species6.setRooted( true );
8341 gene6.setRooted( true );
8342 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
8343 if ( sdi_unrooted.getCount() != 1 ) {
8346 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8349 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8352 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8355 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8358 if ( !p6[ 0 ].getRoot().isDuplication() ) {
8361 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8364 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8367 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
8370 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8373 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
8376 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
8379 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8383 final Phylogeny species7 = factory
8384 .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,"
8385 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8386 new NHXParser() )[ 0 ];
8387 final Phylogeny gene7 = factory
8388 .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],"
8389 + "(((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],"
8390 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8391 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8392 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8393 new NHXParser() )[ 0 ];
8394 species7.setRooted( true );
8395 gene7.setRooted( true );
8396 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
8397 if ( sdi_unrooted.getCount() != 1 ) {
8400 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8403 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8406 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8409 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
8412 if ( !p7[ 0 ].getRoot().isDuplication() ) {
8415 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8418 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8421 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
8424 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8427 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
8430 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
8433 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8437 final Phylogeny species8 = factory
8438 .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,"
8439 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
8440 new NHXParser() )[ 0 ];
8441 final Phylogeny gene8 = factory
8442 .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],"
8443 + "(((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],"
8444 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
8445 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
8446 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
8447 new NHXParser() )[ 0 ];
8448 species8.setRooted( true );
8449 gene8.setRooted( true );
8450 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
8451 if ( sdi_unrooted.getCount() != 1 ) {
8454 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
8457 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
8460 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
8463 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
8466 if ( !p8[ 0 ].getRoot().isDuplication() ) {
8469 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
8472 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
8475 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
8478 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
8481 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
8484 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
8487 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
8492 catch ( final Exception e ) {
8493 e.printStackTrace( System.out );
8499 private static boolean testSplit() {
8501 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8502 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
8503 //Archaeopteryx.createApplication( p0 );
8504 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
8505 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8506 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8507 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8508 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8509 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8510 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8511 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8512 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8513 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8514 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
8515 // System.out.println( s0.toString() );
8517 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
8518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8520 if ( s0.match( query_nodes ) ) {
8523 query_nodes = new HashSet<PhylogenyNode>();
8524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8525 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8531 if ( !s0.match( query_nodes ) ) {
8535 query_nodes = new HashSet<PhylogenyNode>();
8536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8537 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8539 if ( !s0.match( query_nodes ) ) {
8543 query_nodes = new HashSet<PhylogenyNode>();
8544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8548 if ( !s0.match( query_nodes ) ) {
8552 query_nodes = new HashSet<PhylogenyNode>();
8553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8557 if ( !s0.match( query_nodes ) ) {
8561 query_nodes = new HashSet<PhylogenyNode>();
8562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8565 if ( !s0.match( query_nodes ) ) {
8569 query_nodes = new HashSet<PhylogenyNode>();
8570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8572 if ( !s0.match( query_nodes ) ) {
8576 query_nodes = new HashSet<PhylogenyNode>();
8577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8582 if ( !s0.match( query_nodes ) ) {
8586 query_nodes = new HashSet<PhylogenyNode>();
8587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8590 if ( !s0.match( query_nodes ) ) {
8594 query_nodes = new HashSet<PhylogenyNode>();
8595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8598 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8599 if ( !s0.match( query_nodes ) ) {
8603 query_nodes = new HashSet<PhylogenyNode>();
8604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8606 if ( s0.match( query_nodes ) ) {
8610 query_nodes = new HashSet<PhylogenyNode>();
8611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8615 if ( s0.match( query_nodes ) ) {
8619 query_nodes = new HashSet<PhylogenyNode>();
8620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8625 if ( s0.match( query_nodes ) ) {
8629 query_nodes = new HashSet<PhylogenyNode>();
8630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8633 if ( s0.match( query_nodes ) ) {
8637 query_nodes = new HashSet<PhylogenyNode>();
8638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8640 if ( s0.match( query_nodes ) ) {
8644 query_nodes = new HashSet<PhylogenyNode>();
8645 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8647 if ( s0.match( query_nodes ) ) {
8651 query_nodes = new HashSet<PhylogenyNode>();
8652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8654 if ( s0.match( query_nodes ) ) {
8658 query_nodes = new HashSet<PhylogenyNode>();
8659 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8661 if ( s0.match( query_nodes ) ) {
8665 query_nodes = new HashSet<PhylogenyNode>();
8666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8668 if ( s0.match( query_nodes ) ) {
8672 query_nodes = new HashSet<PhylogenyNode>();
8673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8675 if ( s0.match( query_nodes ) ) {
8679 query_nodes = new HashSet<PhylogenyNode>();
8680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8683 if ( s0.match( query_nodes ) ) {
8687 query_nodes = new HashSet<PhylogenyNode>();
8688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8691 if ( s0.match( query_nodes ) ) {
8695 query_nodes = new HashSet<PhylogenyNode>();
8696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8699 if ( s0.match( query_nodes ) ) {
8703 query_nodes = new HashSet<PhylogenyNode>();
8704 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8708 if ( s0.match( query_nodes ) ) {
8712 // query_nodes = new HashSet<PhylogenyNode>();
8713 // query_nodes.add( new PhylogenyNode( "X" ) );
8714 // query_nodes.add( new PhylogenyNode( "Y" ) );
8715 // query_nodes.add( new PhylogenyNode( "A" ) );
8716 // query_nodes.add( new PhylogenyNode( "B" ) );
8717 // query_nodes.add( new PhylogenyNode( "C" ) );
8718 // query_nodes.add( new PhylogenyNode( "D" ) );
8719 // query_nodes.add( new PhylogenyNode( "E" ) );
8720 // query_nodes.add( new PhylogenyNode( "F" ) );
8721 // query_nodes.add( new PhylogenyNode( "G" ) );
8722 // if ( !s0.match( query_nodes ) ) {
8725 // query_nodes = new HashSet<PhylogenyNode>();
8726 // query_nodes.add( new PhylogenyNode( "X" ) );
8727 // query_nodes.add( new PhylogenyNode( "Y" ) );
8728 // query_nodes.add( new PhylogenyNode( "A" ) );
8729 // query_nodes.add( new PhylogenyNode( "B" ) );
8730 // query_nodes.add( new PhylogenyNode( "C" ) );
8731 // if ( !s0.match( query_nodes ) ) {
8735 // query_nodes = new HashSet<PhylogenyNode>();
8736 // query_nodes.add( new PhylogenyNode( "X" ) );
8737 // query_nodes.add( new PhylogenyNode( "Y" ) );
8738 // query_nodes.add( new PhylogenyNode( "D" ) );
8739 // query_nodes.add( new PhylogenyNode( "E" ) );
8740 // query_nodes.add( new PhylogenyNode( "F" ) );
8741 // query_nodes.add( new PhylogenyNode( "G" ) );
8742 // if ( !s0.match( query_nodes ) ) {
8746 // query_nodes = new HashSet<PhylogenyNode>();
8747 // query_nodes.add( new PhylogenyNode( "X" ) );
8748 // query_nodes.add( new PhylogenyNode( "Y" ) );
8749 // query_nodes.add( new PhylogenyNode( "A" ) );
8750 // query_nodes.add( new PhylogenyNode( "B" ) );
8751 // query_nodes.add( new PhylogenyNode( "C" ) );
8752 // query_nodes.add( new PhylogenyNode( "D" ) );
8753 // if ( !s0.match( query_nodes ) ) {
8757 // query_nodes = new HashSet<PhylogenyNode>();
8758 // query_nodes.add( new PhylogenyNode( "X" ) );
8759 // query_nodes.add( new PhylogenyNode( "Y" ) );
8760 // query_nodes.add( new PhylogenyNode( "E" ) );
8761 // query_nodes.add( new PhylogenyNode( "F" ) );
8762 // query_nodes.add( new PhylogenyNode( "G" ) );
8763 // if ( !s0.match( query_nodes ) ) {
8767 // query_nodes = new HashSet<PhylogenyNode>();
8768 // query_nodes.add( new PhylogenyNode( "X" ) );
8769 // query_nodes.add( new PhylogenyNode( "Y" ) );
8770 // query_nodes.add( new PhylogenyNode( "F" ) );
8771 // query_nodes.add( new PhylogenyNode( "G" ) );
8772 // if ( !s0.match( query_nodes ) ) {
8776 query_nodes = new HashSet<PhylogenyNode>();
8777 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8778 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8779 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8781 if ( s0.match( query_nodes ) ) {
8785 query_nodes = new HashSet<PhylogenyNode>();
8786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8790 if ( s0.match( query_nodes ) ) {
8793 ///////////////////////////
8795 query_nodes = new HashSet<PhylogenyNode>();
8796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8800 if ( s0.match( query_nodes ) ) {
8804 query_nodes = new HashSet<PhylogenyNode>();
8805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8808 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8809 if ( s0.match( query_nodes ) ) {
8813 query_nodes = new HashSet<PhylogenyNode>();
8814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8816 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8817 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8818 if ( s0.match( query_nodes ) ) {
8822 query_nodes = new HashSet<PhylogenyNode>();
8823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8825 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8827 if ( s0.match( query_nodes ) ) {
8831 query_nodes = new HashSet<PhylogenyNode>();
8832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8836 if ( s0.match( query_nodes ) ) {
8840 query_nodes = new HashSet<PhylogenyNode>();
8841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8844 if ( s0.match( query_nodes ) ) {
8848 query_nodes = new HashSet<PhylogenyNode>();
8849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8851 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8852 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8854 if ( s0.match( query_nodes ) ) {
8858 query_nodes = new HashSet<PhylogenyNode>();
8859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8864 if ( s0.match( query_nodes ) ) {
8868 query_nodes = new HashSet<PhylogenyNode>();
8869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8874 if ( s0.match( query_nodes ) ) {
8878 query_nodes = new HashSet<PhylogenyNode>();
8879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
8880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
8881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8885 if ( s0.match( query_nodes ) ) {
8889 catch ( final Exception e ) {
8890 e.printStackTrace();
8896 private static boolean testSplitStrict() {
8898 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8899 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
8900 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
8901 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8902 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8903 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8904 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8905 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8906 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8907 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8908 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
8909 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
8910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8912 if ( s0.match( query_nodes ) ) {
8915 query_nodes = new HashSet<PhylogenyNode>();
8916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8923 if ( !s0.match( query_nodes ) ) {
8927 query_nodes = new HashSet<PhylogenyNode>();
8928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8931 if ( !s0.match( query_nodes ) ) {
8935 query_nodes = new HashSet<PhylogenyNode>();
8936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8937 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8940 if ( !s0.match( query_nodes ) ) {
8944 query_nodes = new HashSet<PhylogenyNode>();
8945 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8949 if ( !s0.match( query_nodes ) ) {
8953 query_nodes = new HashSet<PhylogenyNode>();
8954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8957 if ( !s0.match( query_nodes ) ) {
8961 query_nodes = new HashSet<PhylogenyNode>();
8962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8964 if ( !s0.match( query_nodes ) ) {
8968 query_nodes = new HashSet<PhylogenyNode>();
8969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
8972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
8973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8974 if ( !s0.match( query_nodes ) ) {
8978 query_nodes = new HashSet<PhylogenyNode>();
8979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8982 if ( !s0.match( query_nodes ) ) {
8986 query_nodes = new HashSet<PhylogenyNode>();
8987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
8989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
8990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
8991 if ( !s0.match( query_nodes ) ) {
8995 query_nodes = new HashSet<PhylogenyNode>();
8996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
8997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
8998 if ( s0.match( query_nodes ) ) {
9002 query_nodes = new HashSet<PhylogenyNode>();
9003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9004 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9007 if ( s0.match( query_nodes ) ) {
9011 query_nodes = new HashSet<PhylogenyNode>();
9012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9013 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9017 if ( s0.match( query_nodes ) ) {
9021 query_nodes = new HashSet<PhylogenyNode>();
9022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9024 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9025 if ( s0.match( query_nodes ) ) {
9029 query_nodes = new HashSet<PhylogenyNode>();
9030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9032 if ( s0.match( query_nodes ) ) {
9036 query_nodes = new HashSet<PhylogenyNode>();
9037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9039 if ( s0.match( query_nodes ) ) {
9043 query_nodes = new HashSet<PhylogenyNode>();
9044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9046 if ( s0.match( query_nodes ) ) {
9050 query_nodes = new HashSet<PhylogenyNode>();
9051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9053 if ( s0.match( query_nodes ) ) {
9057 query_nodes = new HashSet<PhylogenyNode>();
9058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9060 if ( s0.match( query_nodes ) ) {
9064 query_nodes = new HashSet<PhylogenyNode>();
9065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9067 if ( s0.match( query_nodes ) ) {
9071 query_nodes = new HashSet<PhylogenyNode>();
9072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9074 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9075 if ( s0.match( query_nodes ) ) {
9079 query_nodes = new HashSet<PhylogenyNode>();
9080 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9081 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9082 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9083 if ( s0.match( query_nodes ) ) {
9087 query_nodes = new HashSet<PhylogenyNode>();
9088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9091 if ( s0.match( query_nodes ) ) {
9095 query_nodes = new HashSet<PhylogenyNode>();
9096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9099 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9100 if ( s0.match( query_nodes ) ) {
9104 catch ( final Exception e ) {
9105 e.printStackTrace();
9111 private static boolean testSubtreeDeletion() {
9113 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9114 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
9115 t1.deleteSubtree( t1.getNode( "A" ), false );
9116 if ( t1.getNumberOfExternalNodes() != 5 ) {
9119 t1.toNewHampshireX();
9120 t1.deleteSubtree( t1.getNode( "E" ), false );
9121 if ( t1.getNumberOfExternalNodes() != 4 ) {
9124 t1.toNewHampshireX();
9125 t1.deleteSubtree( t1.getNode( "F" ), false );
9126 if ( t1.getNumberOfExternalNodes() != 3 ) {
9129 t1.toNewHampshireX();
9130 t1.deleteSubtree( t1.getNode( "D" ), false );
9131 t1.toNewHampshireX();
9132 if ( t1.getNumberOfExternalNodes() != 3 ) {
9135 t1.deleteSubtree( t1.getNode( "def" ), false );
9136 t1.toNewHampshireX();
9137 if ( t1.getNumberOfExternalNodes() != 2 ) {
9140 t1.deleteSubtree( t1.getNode( "B" ), false );
9141 t1.toNewHampshireX();
9142 if ( t1.getNumberOfExternalNodes() != 1 ) {
9145 t1.deleteSubtree( t1.getNode( "C" ), false );
9146 t1.toNewHampshireX();
9147 if ( t1.getNumberOfExternalNodes() != 1 ) {
9150 t1.deleteSubtree( t1.getNode( "abc" ), false );
9151 t1.toNewHampshireX();
9152 if ( t1.getNumberOfExternalNodes() != 1 ) {
9155 t1.deleteSubtree( t1.getNode( "r" ), false );
9156 if ( t1.getNumberOfExternalNodes() != 0 ) {
9159 if ( !t1.isEmpty() ) {
9162 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
9163 t2.deleteSubtree( t2.getNode( "A" ), false );
9164 t2.toNewHampshireX();
9165 if ( t2.getNumberOfExternalNodes() != 5 ) {
9168 t2.deleteSubtree( t2.getNode( "abc" ), false );
9169 t2.toNewHampshireX();
9170 if ( t2.getNumberOfExternalNodes() != 3 ) {
9173 t2.deleteSubtree( t2.getNode( "def" ), false );
9174 t2.toNewHampshireX();
9175 if ( t2.getNumberOfExternalNodes() != 1 ) {
9179 catch ( final Exception e ) {
9180 e.printStackTrace( System.out );
9186 private static boolean testSupportCount() {
9188 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9189 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
9190 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
9191 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
9192 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
9193 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
9194 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
9196 SupportCount.count( t0_1, phylogenies_1, true, false );
9197 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
9198 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
9199 + "(((((A,B),C),D),E),((F,G),X))"
9200 + "(((((A,Y),B),C),D),((F,G),E))"
9201 + "(((((A,B),C),D),E),(F,G))"
9202 + "(((((A,B),C),D),E),(F,G))"
9203 + "(((((A,B),C),D),E),(F,G))"
9204 + "(((((A,B),C),D),E),(F,G),Z)"
9205 + "(((((A,B),C),D),E),(F,G))"
9206 + "((((((A,B),C),D),E),F),G)"
9207 + "(((((X,Y),F,G),E),((A,B),C)),D)",
9209 SupportCount.count( t0_2, phylogenies_2, true, false );
9210 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
9211 while ( it.hasNext() ) {
9212 final PhylogenyNode n = it.next();
9213 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
9217 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
9218 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
9219 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
9220 SupportCount.count( t0_3, phylogenies_3, true, false );
9221 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
9222 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
9225 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
9228 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
9231 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
9234 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
9237 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
9240 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
9243 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
9246 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
9249 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
9252 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9253 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
9254 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
9255 SupportCount.count( t0_4, phylogenies_4, true, false );
9256 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
9257 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
9260 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
9263 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
9266 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
9269 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
9272 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
9275 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
9278 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
9281 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
9284 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
9287 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9288 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9289 double d = SupportCount.compare( b1, a, true, true, true );
9290 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
9293 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9294 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9295 d = SupportCount.compare( b2, a, true, true, true );
9296 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
9299 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
9300 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
9301 d = SupportCount.compare( b3, a, true, true, true );
9302 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
9305 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
9306 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
9307 d = SupportCount.compare( b4, a, true, true, false );
9308 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
9312 catch ( final Exception e ) {
9313 e.printStackTrace( System.out );
9319 private static boolean testSupportTransfer() {
9321 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9322 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)",
9323 new NHXParser() )[ 0 ];
9324 final Phylogeny p2 = factory
9325 .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 ];
9326 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
9329 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
9332 support_transfer.moveBranchLengthsToBootstrap( p1 );
9333 support_transfer.transferSupportValues( p1, p2 );
9334 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
9337 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
9340 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
9343 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
9346 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
9349 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
9352 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
9355 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
9359 catch ( final Exception e ) {
9360 e.printStackTrace( System.out );
9366 private static boolean testUniprotTaxonomySearch() {
9368 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
9370 if ( results.size() != 1 ) {
9373 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9376 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9379 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9382 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9385 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9389 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
9390 if ( results.size() != 1 ) {
9393 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9396 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9399 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9402 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9405 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9409 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
9410 if ( results.size() != 1 ) {
9413 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9416 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9419 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9422 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9425 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9429 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
9430 if ( results.size() != 1 ) {
9433 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
9436 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
9439 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
9442 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
9445 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
9448 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
9451 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
9454 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
9455 .equals( "Nematostella vectensis" ) ) {
9456 System.out.println( results.get( 0 ).getLineage() );
9460 catch ( final IOException e ) {
9461 System.out.println();
9462 System.out.println( "the following might be due to absence internet connection:" );
9463 e.printStackTrace( System.out );
9466 catch ( final Exception e ) {
9472 private static boolean testEmblEntryRetrieval() {
9473 //The format for GenBank Accession numbers are:
9474 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
9475 //Protein: 3 letters + 5 numerals
9476 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
9477 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
9480 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861.2" ).equals( "AY423861.2" ) ) {
9483 if ( !SequenceIdParser.parseGenbankAccessor( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
9486 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
9489 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
9492 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
9495 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
9498 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
9501 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
9504 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
9507 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
9510 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
9513 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
9516 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
9522 private static boolean testUniprotEntryRetrieval() {
9524 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
9525 if ( !entry.getAccession().equals( "P12345" ) ) {
9528 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
9531 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
9534 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
9538 catch ( final IOException e ) {
9539 System.out.println();
9540 System.out.println( "the following might be due to absence internet connection:" );
9541 e.printStackTrace( System.out );
9544 catch ( final Exception e ) {
9550 private static boolean testWabiTxSearch() {
9553 result = TxSearch.searchSimple( "nematostella" );
9554 result = TxSearch.getTxId( "nematostella" );
9555 if ( !result.equals( "45350" ) ) {
9558 result = TxSearch.getTxName( "45350" );
9559 if ( !result.equals( "Nematostella" ) ) {
9562 result = TxSearch.getTxId( "nematostella vectensis" );
9563 if ( !result.equals( "45351" ) ) {
9566 result = TxSearch.getTxName( "45351" );
9567 if ( !result.equals( "Nematostella vectensis" ) ) {
9570 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
9571 if ( !result.equals( "536089" ) ) {
9574 result = TxSearch.getTxName( "536089" );
9575 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
9578 final List<String> queries = new ArrayList<String>();
9579 queries.add( "Campylobacter coli" );
9580 queries.add( "Escherichia coli" );
9581 queries.add( "Arabidopsis" );
9582 queries.add( "Trichoplax" );
9583 queries.add( "Samanea saman" );
9584 queries.add( "Kluyveromyces marxianus" );
9585 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
9586 queries.add( "Bornavirus parrot/PDD/2008" );
9587 final List<RANKS> ranks = new ArrayList<RANKS>();
9588 ranks.add( RANKS.SUPERKINGDOM );
9589 ranks.add( RANKS.KINGDOM );
9590 ranks.add( RANKS.FAMILY );
9591 ranks.add( RANKS.GENUS );
9592 ranks.add( RANKS.TRIBE );
9593 result = TxSearch.searchLineage( queries, ranks );
9594 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
9595 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
9597 catch ( final Exception e ) {
9598 System.out.println();
9599 System.out.println( "the following might be due to absence internet connection:" );
9600 e.printStackTrace( System.out );
9606 private static boolean testAminoAcidSequence() {
9608 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
9609 if ( aa1.getLength() != 13 ) {
9612 if ( aa1.getResidueAt( 0 ) != 'A' ) {
9615 if ( aa1.getResidueAt( 2 ) != 'K' ) {
9618 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
9621 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
9622 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
9625 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
9626 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
9629 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
9630 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
9634 catch ( final Exception e ) {
9635 e.printStackTrace();
9641 private static boolean testSequenceWriter() {
9643 final String n = ForesterUtil.LINE_SEPARATOR;
9644 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9647 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9650 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9653 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9656 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9657 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9660 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9661 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9665 catch ( final Exception e ) {
9666 e.printStackTrace();
9672 private static boolean testCreateBalancedPhylogeny() {
9674 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
9675 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
9678 if ( p0.getNumberOfExternalNodes() != 15625 ) {
9681 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
9682 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
9685 if ( p1.getNumberOfExternalNodes() != 100 ) {
9689 catch ( final Exception e ) {
9690 e.printStackTrace();
9696 private static boolean testFastaParser() {
9698 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
9701 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
9704 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
9705 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
9708 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
9711 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
9714 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
9717 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
9720 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
9724 catch ( final Exception e ) {
9725 e.printStackTrace();
9731 private static boolean testGeneralMsaParser() {
9733 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
9734 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
9735 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
9736 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
9737 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
9738 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
9739 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
9740 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
9741 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9744 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9747 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9750 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9753 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9756 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9759 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9762 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9765 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
9768 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
9771 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
9774 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
9777 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
9778 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
9781 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
9784 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
9787 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
9788 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
9791 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
9794 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
9797 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
9798 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
9801 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
9804 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
9808 catch ( final Exception e ) {
9809 e.printStackTrace();
9815 private static boolean testMafft( final String path ) {
9817 final List<String> opts = new ArrayList<String>();
9818 opts.add( "--maxiterate" );
9820 opts.add( "--localpair" );
9821 opts.add( "--quiet" );
9823 final MsaInferrer mafft = Mafft.createInstance( path );
9824 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
9825 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
9828 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
9832 catch ( final Exception e ) {
9833 e.printStackTrace( System.out );
9839 private static boolean testNextNodeWithCollapsing() {
9841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9843 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
9844 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9845 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
9846 t0.getNode( "cd" ).setCollapse( true );
9847 t0.getNode( "cde" ).setCollapse( true );
9848 n = t0.getFirstExternalNode();
9849 while ( n != null ) {
9851 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9853 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
9856 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
9859 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
9862 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
9865 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
9868 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
9872 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9873 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
9874 t1.getNode( "ab" ).setCollapse( true );
9875 t1.getNode( "cd" ).setCollapse( true );
9876 t1.getNode( "cde" ).setCollapse( true );
9877 n = t1.getNode( "ab" );
9878 ext = new ArrayList<PhylogenyNode>();
9879 while ( n != null ) {
9881 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9883 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9886 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9889 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
9892 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
9895 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
9901 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9902 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
9903 t2.getNode( "ab" ).setCollapse( true );
9904 t2.getNode( "cd" ).setCollapse( true );
9905 t2.getNode( "cde" ).setCollapse( true );
9906 t2.getNode( "c" ).setCollapse( true );
9907 t2.getNode( "d" ).setCollapse( true );
9908 t2.getNode( "e" ).setCollapse( true );
9909 t2.getNode( "gh" ).setCollapse( true );
9910 n = t2.getNode( "ab" );
9911 ext = new ArrayList<PhylogenyNode>();
9912 while ( n != null ) {
9914 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9916 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9919 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9922 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
9925 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
9931 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9932 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
9933 t3.getNode( "ab" ).setCollapse( true );
9934 t3.getNode( "cd" ).setCollapse( true );
9935 t3.getNode( "cde" ).setCollapse( true );
9936 t3.getNode( "c" ).setCollapse( true );
9937 t3.getNode( "d" ).setCollapse( true );
9938 t3.getNode( "e" ).setCollapse( true );
9939 t3.getNode( "gh" ).setCollapse( true );
9940 t3.getNode( "fgh" ).setCollapse( true );
9941 n = t3.getNode( "ab" );
9942 ext = new ArrayList<PhylogenyNode>();
9943 while ( n != null ) {
9945 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9947 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
9950 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
9953 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
9959 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
9960 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
9961 t4.getNode( "ab" ).setCollapse( true );
9962 t4.getNode( "cd" ).setCollapse( true );
9963 t4.getNode( "cde" ).setCollapse( true );
9964 t4.getNode( "c" ).setCollapse( true );
9965 t4.getNode( "d" ).setCollapse( true );
9966 t4.getNode( "e" ).setCollapse( true );
9967 t4.getNode( "gh" ).setCollapse( true );
9968 t4.getNode( "fgh" ).setCollapse( true );
9969 t4.getNode( "abcdefgh" ).setCollapse( true );
9970 n = t4.getNode( "abcdefgh" );
9971 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
9976 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
9977 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
9979 n = t5.getFirstExternalNode();
9980 while ( n != null ) {
9982 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
9984 if ( ext.size() != 8 ) {
9987 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
9990 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
9993 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
9996 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
9999 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10002 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
10005 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
10008 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
10013 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
10014 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
10016 t6.getNode( "ab" ).setCollapse( true );
10017 n = t6.getNode( "ab" );
10018 while ( n != null ) {
10020 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10022 if ( ext.size() != 7 ) {
10025 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10028 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10031 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10034 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10037 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
10040 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
10043 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
10048 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
10049 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
10051 t7.getNode( "cd" ).setCollapse( true );
10052 n = t7.getNode( "a" );
10053 while ( n != null ) {
10055 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10057 if ( ext.size() != 7 ) {
10060 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10063 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10066 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
10069 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10072 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
10075 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
10078 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
10083 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
10084 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
10086 t8.getNode( "cd" ).setCollapse( true );
10087 t8.getNode( "c" ).setCollapse( true );
10088 t8.getNode( "d" ).setCollapse( true );
10089 n = t8.getNode( "a" );
10090 while ( n != null ) {
10092 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10094 if ( ext.size() != 7 ) {
10097 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10100 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10103 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
10104 System.out.println( "2 fail" );
10107 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10110 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
10113 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
10116 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
10121 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10122 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
10124 t9.getNode( "gh" ).setCollapse( true );
10125 n = t9.getNode( "a" );
10126 while ( n != null ) {
10128 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10130 if ( ext.size() != 7 ) {
10133 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10136 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10139 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10142 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10145 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10148 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
10151 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
10156 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10157 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
10159 t10.getNode( "gh" ).setCollapse( true );
10160 t10.getNode( "g" ).setCollapse( true );
10161 t10.getNode( "h" ).setCollapse( true );
10162 n = t10.getNode( "a" );
10163 while ( n != null ) {
10165 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10167 if ( ext.size() != 7 ) {
10170 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10173 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10176 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10179 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10182 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10185 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
10188 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
10193 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10194 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
10196 t11.getNode( "gh" ).setCollapse( true );
10197 t11.getNode( "fgh" ).setCollapse( true );
10198 n = t11.getNode( "a" );
10199 while ( n != null ) {
10201 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10203 if ( ext.size() != 6 ) {
10206 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10209 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10212 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10215 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10218 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10221 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10226 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10227 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
10229 t12.getNode( "gh" ).setCollapse( true );
10230 t12.getNode( "fgh" ).setCollapse( true );
10231 t12.getNode( "g" ).setCollapse( true );
10232 t12.getNode( "h" ).setCollapse( true );
10233 t12.getNode( "f" ).setCollapse( true );
10234 n = t12.getNode( "a" );
10235 while ( n != null ) {
10237 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10239 if ( ext.size() != 6 ) {
10242 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
10245 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
10248 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
10251 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
10254 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
10257 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10262 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
10263 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
10265 t13.getNode( "ab" ).setCollapse( true );
10266 t13.getNode( "b" ).setCollapse( true );
10267 t13.getNode( "fgh" ).setCollapse( true );
10268 t13.getNode( "gh" ).setCollapse( true );
10269 n = t13.getNode( "ab" );
10270 while ( n != null ) {
10272 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10274 if ( ext.size() != 5 ) {
10277 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10280 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10283 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10286 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10289 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
10294 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
10295 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
10297 t14.getNode( "ab" ).setCollapse( true );
10298 t14.getNode( "a" ).setCollapse( true );
10299 t14.getNode( "fgh" ).setCollapse( true );
10300 t14.getNode( "gh" ).setCollapse( true );
10301 n = t14.getNode( "ab" );
10302 while ( n != null ) {
10304 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10306 if ( ext.size() != 5 ) {
10309 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10312 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10315 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10318 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10321 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
10326 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" );
10327 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
10329 t15.getNode( "ab" ).setCollapse( true );
10330 t15.getNode( "a" ).setCollapse( true );
10331 t15.getNode( "fgh" ).setCollapse( true );
10332 t15.getNode( "gh" ).setCollapse( true );
10333 n = t15.getNode( "ab" );
10334 while ( n != null ) {
10336 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10338 if ( ext.size() != 6 ) {
10341 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10344 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
10347 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
10350 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
10353 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
10356 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
10361 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" );
10362 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
10364 t16.getNode( "ab" ).setCollapse( true );
10365 t16.getNode( "a" ).setCollapse( true );
10366 t16.getNode( "fgh" ).setCollapse( true );
10367 t16.getNode( "gh" ).setCollapse( true );
10368 t16.getNode( "cd" ).setCollapse( true );
10369 t16.getNode( "cde" ).setCollapse( true );
10370 t16.getNode( "d" ).setCollapse( true );
10371 t16.getNode( "x" ).setCollapse( true );
10372 n = t16.getNode( "ab" );
10373 while ( n != null ) {
10375 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
10377 if ( ext.size() != 4 ) {
10380 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
10383 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
10386 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
10389 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
10393 catch ( final Exception e ) {
10394 e.printStackTrace( System.out );
10400 private static boolean testMsaQualityMethod() {
10402 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
10403 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
10404 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
10405 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
10406 final List<Sequence> l = new ArrayList<Sequence>();
10411 final Msa msa = BasicMsa.createInstance( l );
10412 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
10415 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
10418 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
10421 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
10425 catch ( final Exception e ) {
10426 e.printStackTrace( System.out );
10432 private static boolean testSequenceIdParsing() {
10434 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
10435 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10436 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10437 if ( id != null ) {
10438 System.out.println( "value =" + id.getValue() );
10439 System.out.println( "provider=" + id.getProvider() );
10444 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
10445 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10446 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10447 if ( id != null ) {
10448 System.out.println( "value =" + id.getValue() );
10449 System.out.println( "provider=" + id.getProvider() );
10454 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
10455 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10456 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
10457 if ( id != null ) {
10458 System.out.println( "value =" + id.getValue() );
10459 System.out.println( "provider=" + id.getProvider() );
10464 id = SequenceIdParser.parse( "gb_AAA96518_1" );
10465 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10466 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
10467 if ( id != null ) {
10468 System.out.println( "value =" + id.getValue() );
10469 System.out.println( "provider=" + id.getProvider() );
10474 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
10475 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10476 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
10477 if ( id != null ) {
10478 System.out.println( "value =" + id.getValue() );
10479 System.out.println( "provider=" + id.getProvider() );
10484 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
10485 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10486 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
10487 if ( id != null ) {
10488 System.out.println( "value =" + id.getValue() );
10489 System.out.println( "provider=" + id.getProvider() );
10494 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
10495 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10496 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
10497 if ( id != null ) {
10498 System.out.println( "value =" + id.getValue() );
10499 System.out.println( "provider=" + id.getProvider() );
10504 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
10505 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10506 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
10507 if ( id != null ) {
10508 System.out.println( "value =" + id.getValue() );
10509 System.out.println( "provider=" + id.getProvider() );
10514 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
10515 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10516 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
10517 if ( id != null ) {
10518 System.out.println( "value =" + id.getValue() );
10519 System.out.println( "provider=" + id.getProvider() );
10524 id = SequenceIdParser.parse( "P4A123" );
10525 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10526 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
10527 if ( id != null ) {
10528 System.out.println( "value =" + id.getValue() );
10529 System.out.println( "provider=" + id.getProvider() );
10534 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
10535 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
10536 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
10537 if ( id != null ) {
10538 System.out.println( "value =" + id.getValue() );
10539 System.out.println( "provider=" + id.getProvider() );
10544 id = SequenceIdParser.parse( "XP_12345" );
10545 if ( id != null ) {
10546 System.out.println( "value =" + id.getValue() );
10547 System.out.println( "provider=" + id.getProvider() );
10550 // lcl_91970_unknown_
10552 catch ( final Exception e ) {
10553 e.printStackTrace( System.out );