2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
33 import java.util.ArrayList;
34 import java.util.Date;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Locale;
40 import java.util.SortedSet;
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.development.DevelopmentTools;
45 import org.forester.evoinference.TestPhylogenyReconstruction;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
48 import org.forester.go.TestGo;
49 import org.forester.io.parsers.FastaParser;
50 import org.forester.io.parsers.GeneralMsaParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
53 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
54 import org.forester.io.parsers.nexus.NexusCharactersParser;
55 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
56 import org.forester.io.parsers.nhx.NHXParser;
57 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
58 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
59 import org.forester.io.parsers.tol.TolParser;
60 import org.forester.io.parsers.util.ParserUtils;
61 import org.forester.io.writers.PhylogenyWriter;
62 import org.forester.io.writers.SequenceWriter;
63 import org.forester.msa.BasicMsa;
64 import org.forester.msa.Mafft;
65 import org.forester.msa.Msa;
66 import org.forester.msa.MsaInferrer;
67 import org.forester.msa.MsaMethods;
68 import org.forester.pccx.TestPccx;
69 import org.forester.phylogeny.Phylogeny;
70 import org.forester.phylogeny.PhylogenyBranch;
71 import org.forester.phylogeny.PhylogenyMethods;
72 import org.forester.phylogeny.PhylogenyNode;
73 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
74 import org.forester.phylogeny.data.Accession;
75 import org.forester.phylogeny.data.Accession.Source;
76 import org.forester.phylogeny.data.BinaryCharacters;
77 import org.forester.phylogeny.data.BranchWidth;
78 import org.forester.phylogeny.data.Confidence;
79 import org.forester.phylogeny.data.Distribution;
80 import org.forester.phylogeny.data.DomainArchitecture;
81 import org.forester.phylogeny.data.Event;
82 import org.forester.phylogeny.data.Identifier;
83 import org.forester.phylogeny.data.PhylogenyData;
84 import org.forester.phylogeny.data.PhylogenyDataUtil;
85 import org.forester.phylogeny.data.Polygon;
86 import org.forester.phylogeny.data.PropertiesMap;
87 import org.forester.phylogeny.data.Property;
88 import org.forester.phylogeny.data.Property.AppliesTo;
89 import org.forester.phylogeny.data.ProteinDomain;
90 import org.forester.phylogeny.data.Taxonomy;
91 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
92 import org.forester.phylogeny.factories.PhylogenyFactory;
93 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
94 import org.forester.protein.BasicDomain;
95 import org.forester.protein.BasicProtein;
96 import org.forester.protein.Domain;
97 import org.forester.protein.Protein;
98 import org.forester.protein.ProteinId;
99 import org.forester.rio.TestRIO;
100 import org.forester.sdi.SDI;
101 import org.forester.sdi.SDIR;
102 import org.forester.sdi.TestGSDI;
103 import org.forester.sequence.BasicSequence;
104 import org.forester.sequence.Sequence;
105 import org.forester.species.BasicSpecies;
106 import org.forester.species.Species;
107 import org.forester.surfacing.TestSurfacing;
108 import org.forester.tools.ConfidenceAssessor;
109 import org.forester.tools.SupportCount;
110 import org.forester.tools.TreeSplitMatrix;
111 import org.forester.util.AsciiHistogram;
112 import org.forester.util.BasicDescriptiveStatistics;
113 import org.forester.util.BasicTable;
114 import org.forester.util.BasicTableParser;
115 import org.forester.util.DescriptiveStatistics;
116 import org.forester.util.ForesterConstants;
117 import org.forester.util.ForesterUtil;
118 import org.forester.util.GeneralTable;
119 import org.forester.util.SequenceAccessionTools;
120 import org.forester.ws.seqdb.SequenceDatabaseEntry;
121 import org.forester.ws.seqdb.SequenceDbWsTools;
122 import org.forester.ws.seqdb.UniProtTaxonomy;
123 import org.forester.ws.wabi.TxSearch;
124 import org.forester.ws.wabi.TxSearch.RANKS;
125 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
126 import org.forester.ws.wabi.TxSearch.TAX_RANK;
128 @SuppressWarnings( "unused")
129 public final class Test {
131 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
132 + ForesterUtil.getFileSeparator() + "resources"
133 + ForesterUtil.getFileSeparator();
134 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
135 + ForesterUtil.getFileSeparator() + "test_data"
136 + ForesterUtil.getFileSeparator();
137 private final static boolean PERFORM_DB_TESTS = false;
138 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
139 + ForesterConstants.PHYLO_XML_VERSION + "/"
140 + ForesterConstants.PHYLO_XML_XSD;
141 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
142 + ForesterConstants.PHYLO_XML_VERSION + "/"
143 + ForesterConstants.PHYLO_XML_XSD;
144 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
145 private final static double ZERO_DIFF = 1.0E-9;
147 public static boolean isEqual( final double a, final double b ) {
148 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
151 public static void main( final String[] args ) {
152 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
153 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
155 Locale.setDefault( Locale.US );
156 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
159 System.out.print( "[Test if directory with files for testing exists/is readable: " );
160 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
161 System.out.println( "OK.]" );
164 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
165 System.out.println( "Testing aborted." );
168 System.out.print( "[Test if resources directory exists/is readable: " );
169 if ( testDir( PATH_TO_RESOURCES ) ) {
170 System.out.println( "OK.]" );
173 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
174 System.out.println( "Testing aborted." );
177 final long start_time = new Date().getTime();
178 System.out.print( "Basic node methods: " );
179 if ( Test.testBasicNodeMethods() ) {
180 System.out.println( "OK." );
184 System.out.println( "failed." );
187 System.out.print( "Protein id: " );
188 if ( !testProteinId() ) {
189 System.out.println( "failed." );
195 System.out.println( "OK." );
196 System.out.print( "Species: " );
197 if ( !testSpecies() ) {
198 System.out.println( "failed." );
204 System.out.println( "OK." );
205 System.out.print( "Basic domain: " );
206 if ( !testBasicDomain() ) {
207 System.out.println( "failed." );
213 System.out.println( "OK." );
214 System.out.print( "Basic protein: " );
215 if ( !testBasicProtein() ) {
216 System.out.println( "failed." );
222 System.out.println( "OK." );
223 System.out.print( "Sequence writer: " );
224 if ( testSequenceWriter() ) {
225 System.out.println( "OK." );
229 System.out.println( "failed." );
232 System.out.print( "Sequence id parsing: " );
233 if ( testSequenceIdParsing() ) {
234 System.out.println( "OK." );
238 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( "Sequence DB tools 1: " );
251 if ( testSequenceDbWsTools1() ) {
252 System.out.println( "OK." );
256 System.out.println( "failed." );
259 if ( PERFORM_DB_TESTS ) {
260 System.out.print( "Ebi Entry Retrieval: " );
261 if ( Test.testEbiEntryRetrieval() ) {
262 System.out.println( "OK." );
266 System.out.println( "failed." );
271 if ( PERFORM_DB_TESTS ) {
272 System.out.print( "Sequence DB tools 2: " );
273 if ( testSequenceDbWsTools2() ) {
274 System.out.println( "OK." );
278 System.out.println( "failed." );
284 System.out.print( "Hmmscan output parser: " );
285 if ( testHmmscanOutputParser() ) {
286 System.out.println( "OK." );
290 System.out.println( "failed." );
294 System.out.print( "Overlap removal: " );
295 if ( !org.forester.test.Test.testOverlapRemoval() ) {
296 System.out.println( "failed." );
302 System.out.println( "OK." );
303 System.out.print( "Engulfing overlap removal: " );
304 if ( !Test.testEngulfingOverlapRemoval() ) {
305 System.out.println( "failed." );
311 System.out.println( "OK." );
313 System.out.print( "Taxonomy code extraction: " );
314 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
315 System.out.println( "OK." );
319 System.out.println( "failed." );
322 System.out.print( "SN extraction: " );
323 if ( Test.testExtractSNFromNodeName() ) {
324 System.out.println( "OK." );
328 System.out.println( "failed." );
331 System.out.print( "Taxonomy extraction (general): " );
332 if ( Test.testTaxonomyExtraction() ) {
333 System.out.println( "OK." );
337 System.out.println( "failed." );
340 System.out.print( "Uri for Aptx web sequence accession: " );
341 if ( Test.testCreateUriForSeqWeb() ) {
342 System.out.println( "OK." );
346 System.out.println( "failed." );
349 System.out.print( "Basic node construction and parsing of NHX (node level): " );
350 if ( Test.testNHXNodeParsing() ) {
351 System.out.println( "OK." );
355 System.out.println( "failed." );
358 System.out.print( "NHX parsing iterating: " );
359 if ( Test.testNHParsingIter() ) {
360 System.out.println( "OK." );
364 System.out.println( "failed." );
367 System.out.print( "NH parsing: " );
368 if ( Test.testNHParsing() ) {
369 System.out.println( "OK." );
373 System.out.println( "failed." );
376 System.out.print( "Conversion to NHX (node level): " );
377 if ( Test.testNHXconversion() ) {
378 System.out.println( "OK." );
382 System.out.println( "failed." );
385 System.out.print( "NHX parsing: " );
386 if ( Test.testNHXParsing() ) {
387 System.out.println( "OK." );
391 System.out.println( "failed." );
394 System.out.print( "NHX parsing with quotes: " );
395 if ( Test.testNHXParsingQuotes() ) {
396 System.out.println( "OK." );
400 System.out.println( "failed." );
403 System.out.print( "NHX parsing (MrBayes): " );
404 if ( Test.testNHXParsingMB() ) {
405 System.out.println( "OK." );
409 System.out.println( "failed." );
412 System.out.print( "Nexus characters parsing: " );
413 if ( Test.testNexusCharactersParsing() ) {
414 System.out.println( "OK." );
418 System.out.println( "failed." );
421 System.out.print( "Nexus tree parsing iterating: " );
422 if ( Test.testNexusTreeParsingIterating() ) {
423 System.out.println( "OK." );
427 System.out.println( "failed." );
430 System.out.print( "Nexus tree parsing: " );
431 if ( Test.testNexusTreeParsing() ) {
432 System.out.println( "OK." );
436 System.out.println( "failed." );
439 System.out.print( "Nexus tree parsing (translating): " );
440 if ( Test.testNexusTreeParsingTranslating() ) {
441 System.out.println( "OK." );
445 System.out.println( "failed." );
448 System.out.print( "Nexus matrix parsing: " );
449 if ( Test.testNexusMatrixParsing() ) {
450 System.out.println( "OK." );
454 System.out.println( "failed." );
457 System.out.print( "Basic phyloXML parsing: " );
458 if ( Test.testBasicPhyloXMLparsing() ) {
459 System.out.println( "OK." );
463 System.out.println( "failed." );
466 System.out.print( "Basic phyloXML parsing (validating against schema): " );
467 if ( testBasicPhyloXMLparsingValidating() ) {
468 System.out.println( "OK." );
472 System.out.println( "failed." );
475 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
476 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
477 System.out.println( "OK." );
481 System.out.println( "failed." );
484 System.out.print( "phyloXML Distribution Element: " );
485 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
486 System.out.println( "OK." );
490 System.out.println( "failed." );
493 System.out.print( "Tol XML parsing: " );
494 if ( Test.testBasicTolXMLparsing() ) {
495 System.out.println( "OK." );
499 System.out.println( "failed." );
502 System.out.print( "Copying of node data: " );
503 if ( Test.testCopyOfNodeData() ) {
504 System.out.println( "OK." );
508 System.out.println( "failed." );
511 System.out.print( "Tree copy: " );
512 if ( Test.testTreeCopy() ) {
513 System.out.println( "OK." );
517 System.out.println( "failed." );
520 System.out.print( "Basic tree methods: " );
521 if ( Test.testBasicTreeMethods() ) {
522 System.out.println( "OK." );
526 System.out.println( "failed." );
529 System.out.print( "Tree methods: " );
530 if ( Test.testTreeMethods() ) {
531 System.out.println( "OK." );
535 System.out.println( "failed." );
538 System.out.print( "Postorder Iterator: " );
539 if ( Test.testPostOrderIterator() ) {
540 System.out.println( "OK." );
544 System.out.println( "failed." );
547 System.out.print( "Preorder Iterator: " );
548 if ( Test.testPreOrderIterator() ) {
549 System.out.println( "OK." );
553 System.out.println( "failed." );
556 System.out.print( "Levelorder Iterator: " );
557 if ( Test.testLevelOrderIterator() ) {
558 System.out.println( "OK." );
562 System.out.println( "failed." );
565 System.out.print( "Re-id methods: " );
566 if ( Test.testReIdMethods() ) {
567 System.out.println( "OK." );
571 System.out.println( "failed." );
574 System.out.print( "Methods on last external nodes: " );
575 if ( Test.testLastExternalNodeMethods() ) {
576 System.out.println( "OK." );
580 System.out.println( "failed." );
583 System.out.print( "Methods on external nodes: " );
584 if ( Test.testExternalNodeRelatedMethods() ) {
585 System.out.println( "OK." );
589 System.out.println( "failed." );
592 System.out.print( "Deletion of external nodes: " );
593 if ( Test.testDeletionOfExternalNodes() ) {
594 System.out.println( "OK." );
598 System.out.println( "failed." );
601 System.out.print( "Subtree deletion: " );
602 if ( Test.testSubtreeDeletion() ) {
603 System.out.println( "OK." );
607 System.out.println( "failed." );
610 System.out.print( "Phylogeny branch: " );
611 if ( Test.testPhylogenyBranch() ) {
612 System.out.println( "OK." );
616 System.out.println( "failed." );
619 System.out.print( "Rerooting: " );
620 if ( Test.testRerooting() ) {
621 System.out.println( "OK." );
625 System.out.println( "failed." );
628 System.out.print( "Mipoint rooting: " );
629 if ( Test.testMidpointrooting() ) {
630 System.out.println( "OK." );
634 System.out.println( "failed." );
637 System.out.print( "Node removal: " );
638 if ( Test.testNodeRemoval() ) {
639 System.out.println( "OK." );
643 System.out.println( "failed." );
646 System.out.print( "Support count: " );
647 if ( Test.testSupportCount() ) {
648 System.out.println( "OK." );
652 System.out.println( "failed." );
655 System.out.print( "Support transfer: " );
656 if ( Test.testSupportTransfer() ) {
657 System.out.println( "OK." );
661 System.out.println( "failed." );
664 System.out.print( "Finding of LCA: " );
665 if ( Test.testGetLCA() ) {
666 System.out.println( "OK." );
670 System.out.println( "failed." );
673 System.out.print( "Finding of LCA 2: " );
674 if ( Test.testGetLCA2() ) {
675 System.out.println( "OK." );
679 System.out.println( "failed." );
682 System.out.print( "Calculation of distance between nodes: " );
683 if ( Test.testGetDistance() ) {
684 System.out.println( "OK." );
688 System.out.println( "failed." );
691 System.out.print( "Descriptive statistics: " );
692 if ( Test.testDescriptiveStatistics() ) {
693 System.out.println( "OK." );
697 System.out.println( "failed." );
700 System.out.print( "Data objects and methods: " );
701 if ( Test.testDataObjects() ) {
702 System.out.println( "OK." );
706 System.out.println( "failed." );
709 System.out.print( "Properties map: " );
710 if ( Test.testPropertiesMap() ) {
711 System.out.println( "OK." );
715 System.out.println( "failed." );
718 System.out.print( "SDIse: " );
719 if ( Test.testSDIse() ) {
720 System.out.println( "OK." );
724 System.out.println( "failed." );
727 System.out.print( "SDIunrooted: " );
728 if ( Test.testSDIunrooted() ) {
729 System.out.println( "OK." );
733 System.out.println( "failed." );
736 System.out.print( "GSDI: " );
737 if ( TestGSDI.test() ) {
738 System.out.println( "OK." );
742 System.out.println( "failed." );
745 System.out.print( "RIO: " );
746 if ( TestRIO.test() ) {
747 System.out.println( "OK." );
751 System.out.println( "failed." );
754 System.out.print( "Phylogeny reconstruction:" );
755 System.out.println();
756 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
757 System.out.println( "OK." );
761 System.out.println( "failed." );
764 System.out.print( "Analysis of domain architectures: " );
765 System.out.println();
766 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
767 System.out.println( "OK." );
771 System.out.println( "failed." );
774 System.out.print( "GO: " );
775 System.out.println();
776 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
777 System.out.println( "OK." );
781 System.out.println( "failed." );
784 System.out.print( "Modeling tools: " );
785 if ( TestPccx.test() ) {
786 System.out.println( "OK." );
790 System.out.println( "failed." );
793 System.out.print( "Split Matrix strict: " );
794 if ( Test.testSplitStrict() ) {
795 System.out.println( "OK." );
799 System.out.println( "failed." );
802 System.out.print( "Split Matrix: " );
803 if ( Test.testSplit() ) {
804 System.out.println( "OK." );
808 System.out.println( "failed." );
811 System.out.print( "Confidence Assessor: " );
812 if ( Test.testConfidenceAssessor() ) {
813 System.out.println( "OK." );
817 System.out.println( "failed." );
820 System.out.print( "Basic table: " );
821 if ( Test.testBasicTable() ) {
822 System.out.println( "OK." );
826 System.out.println( "failed." );
829 System.out.print( "General table: " );
830 if ( Test.testGeneralTable() ) {
831 System.out.println( "OK." );
835 System.out.println( "failed." );
838 System.out.print( "Amino acid sequence: " );
839 if ( Test.testAminoAcidSequence() ) {
840 System.out.println( "OK." );
844 System.out.println( "failed." );
847 System.out.print( "General MSA parser: " );
848 if ( Test.testGeneralMsaParser() ) {
849 System.out.println( "OK." );
853 System.out.println( "failed." );
856 System.out.print( "Fasta parser for msa: " );
857 if ( Test.testFastaParser() ) {
858 System.out.println( "OK." );
862 System.out.println( "failed." );
865 System.out.print( "Creation of balanced phylogeny: " );
866 if ( Test.testCreateBalancedPhylogeny() ) {
867 System.out.println( "OK." );
871 System.out.println( "failed." );
874 System.out.print( "Genbank accessor parsing: " );
875 if ( Test.testGenbankAccessorParsing() ) {
876 System.out.println( "OK." );
880 System.out.println( "failed." );
883 if ( PERFORM_DB_TESTS ) {
884 System.out.print( "Uniprot Entry Retrieval: " );
885 if ( Test.testUniprotEntryRetrieval() ) {
886 System.out.println( "OK." );
890 System.out.println( "failed." );
894 if ( PERFORM_DB_TESTS ) {
895 System.out.print( "Uniprot Taxonomy Search: " );
896 if ( Test.testUniprotTaxonomySearch() ) {
897 System.out.println( "OK." );
901 System.out.println( "failed." );
907 final String os = ForesterUtil.OS_NAME.toLowerCase();
908 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
909 path = "/usr/local/bin/mafft";
911 else if ( os.indexOf( "win" ) >= 0 ) {
912 path = "C:\\Program Files\\mafft-win\\mafft.bat";
915 path = "/home/czmasek/bin/mafft";
917 if ( !MsaInferrer.isInstalled( path ) ) {
920 if ( !MsaInferrer.isInstalled( path ) ) {
921 path = "/usr/local/bin/mafft";
923 if ( MsaInferrer.isInstalled( path ) ) {
924 System.out.print( "MAFFT (external program): " );
925 if ( Test.testMafft( path ) ) {
926 System.out.println( "OK." );
930 System.out.println( "failed [will not count towards failed tests]" );
934 System.out.print( "Next nodes with collapsed: " );
935 if ( Test.testNextNodeWithCollapsing() ) {
936 System.out.println( "OK." );
940 System.out.println( "failed." );
943 System.out.print( "Simple MSA quality: " );
944 if ( Test.testMsaQualityMethod() ) {
945 System.out.println( "OK." );
949 System.out.println( "failed." );
952 System.out.print( "NHX parsing from URL: " );
953 if ( Test.testNHXparsingFromURL() ) {
954 System.out.println( "OK." );
958 System.out.println( "failed." );
961 System.out.println();
962 final Runtime rt = java.lang.Runtime.getRuntime();
963 final long free_memory = rt.freeMemory() / 1000000;
964 final long total_memory = rt.totalMemory() / 1000000;
965 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
966 + free_memory + "MB, total memory: " + total_memory + "MB)" );
967 System.out.println();
968 System.out.println( "Successful tests: " + succeeded );
969 System.out.println( "Failed tests: " + failed );
970 System.out.println();
972 System.out.println( "OK." );
975 System.out.println( "Not OK." );
979 public static boolean testEngulfingOverlapRemoval() {
981 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
982 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
983 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
984 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
985 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
986 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
987 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
988 final List<Boolean> covered = new ArrayList<Boolean>();
989 covered.add( true ); // 0
990 covered.add( false ); // 1
991 covered.add( true ); // 2
992 covered.add( false ); // 3
993 covered.add( true ); // 4
994 covered.add( true ); // 5
995 covered.add( false ); // 6
996 covered.add( true ); // 7
997 covered.add( true ); // 8
998 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1001 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1004 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1007 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1010 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1013 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1016 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1019 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1020 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1021 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1022 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1023 abc.addProteinDomain( a );
1024 abc.addProteinDomain( b );
1025 abc.addProteinDomain( c );
1026 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1027 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1028 if ( abc.getNumberOfProteinDomains() != 3 ) {
1031 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1034 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1037 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1040 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1043 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1044 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1045 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1046 final Protein def = new BasicProtein( "def", "nemve", 0 );
1047 def.addProteinDomain( d );
1048 def.addProteinDomain( e );
1049 def.addProteinDomain( f );
1050 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1051 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1052 if ( def.getNumberOfProteinDomains() != 3 ) {
1055 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1058 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1061 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1064 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1067 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1071 catch ( final Exception e ) {
1072 e.printStackTrace( System.out );
1078 public static final boolean testNHXparsingFromURL() {
1080 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1081 final URL u = new URL( s );
1082 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1083 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1084 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1087 if ( !phys[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
1088 System.out.println( phys[ 0 ].toNewHampshire() );
1091 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1092 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1095 if ( !phys2[ 0 ].toNewHampshire().equals( "((a,b),c);" ) ) {
1096 System.out.println( phys2[ 0 ].toNewHampshire() );
1099 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1100 final NHXParser p = new NHXParser();
1101 final URL u2 = new URL( s );
1103 if ( !p.hasNext() ) {
1106 if ( !p.next().toNewHampshire().equals( "((a,b),c);" ) ) {
1109 if ( p.hasNext() ) {
1112 if ( p.next() != null ) {
1115 if ( p.hasNext() ) {
1118 if ( p.next() != null ) {
1122 if ( !p.hasNext() ) {
1125 if ( !p.next().toNewHampshire().equals( "((a,b),c);" ) ) {
1128 if ( p.hasNext() ) {
1131 if ( p.next() != null ) {
1134 if ( p.hasNext() ) {
1137 if ( p.next() != null ) {
1141 if ( !p.hasNext() ) {
1145 catch ( final Exception e ) {
1146 e.printStackTrace();
1151 public static boolean testOverlapRemoval() {
1153 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1154 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1155 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1156 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1157 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1158 final List<Boolean> covered = new ArrayList<Boolean>();
1159 covered.add( true ); // 0
1160 covered.add( false ); // 1
1161 covered.add( true ); // 2
1162 covered.add( false ); // 3
1163 covered.add( true ); // 4
1164 covered.add( true ); // 5
1165 covered.add( false ); // 6
1166 covered.add( true ); // 7
1167 covered.add( true ); // 8
1168 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1171 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1174 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1177 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1180 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1183 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1184 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1185 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1186 ab.addProteinDomain( a );
1187 ab.addProteinDomain( b );
1188 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1189 if ( ab.getNumberOfProteinDomains() != 2 ) {
1192 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1195 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1198 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1199 if ( ab.getNumberOfProteinDomains() != 2 ) {
1202 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1205 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1206 final Domain d = new BasicDomain( "d",
1213 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1214 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1215 cde.addProteinDomain( c );
1216 cde.addProteinDomain( d );
1217 cde.addProteinDomain( e );
1218 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1219 if ( cde.getNumberOfProteinDomains() != 3 ) {
1222 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1225 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1226 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1227 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1228 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1229 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1230 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1231 fghi.addProteinDomain( f );
1232 fghi.addProteinDomain( g );
1233 fghi.addProteinDomain( h );
1234 fghi.addProteinDomain( i );
1235 fghi.addProteinDomain( i );
1236 fghi.addProteinDomain( i );
1237 fghi.addProteinDomain( i2 );
1238 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1239 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1242 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1245 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1248 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1249 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1252 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1255 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1256 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1257 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1258 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1259 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1260 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1261 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1262 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1263 jklm.addProteinDomain( j );
1264 jklm.addProteinDomain( k );
1265 jklm.addProteinDomain( l );
1266 jklm.addProteinDomain( m );
1267 jklm.addProteinDomain( m0 );
1268 jklm.addProteinDomain( m1 );
1269 jklm.addProteinDomain( m2 );
1270 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1271 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1274 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1277 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1280 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1281 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1284 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1287 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1288 final Protein od = new BasicProtein( "od", "varanus", 0 );
1289 od.addProteinDomain( only );
1290 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1291 if ( od.getNumberOfProteinDomains() != 1 ) {
1294 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1298 catch ( final Exception e ) {
1299 e.printStackTrace( System.out );
1305 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1306 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1310 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1311 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1314 private static boolean testAminoAcidSequence() {
1316 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1317 if ( aa1.getLength() != 13 ) {
1320 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1323 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1326 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1329 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1330 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1333 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1334 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1337 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1338 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1342 catch ( final Exception e ) {
1343 e.printStackTrace();
1349 private static boolean testBasicDomain() {
1351 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1352 if ( !pd.getDomainId().equals( "id" ) ) {
1355 if ( pd.getNumber() != 1 ) {
1358 if ( pd.getTotalCount() != 4 ) {
1361 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1364 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1365 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1366 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1367 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1368 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1369 if ( !a1.equals( a1 ) ) {
1372 if ( !a1.equals( a1_copy ) ) {
1375 if ( !a1.equals( a1_equal ) ) {
1378 if ( !a1.equals( a2 ) ) {
1381 if ( a1.equals( a3 ) ) {
1384 if ( a1.compareTo( a1 ) != 0 ) {
1387 if ( a1.compareTo( a1_copy ) != 0 ) {
1390 if ( a1.compareTo( a1_equal ) != 0 ) {
1393 if ( a1.compareTo( a2 ) != 0 ) {
1396 if ( a1.compareTo( a3 ) == 0 ) {
1400 catch ( final Exception e ) {
1401 e.printStackTrace( System.out );
1407 private static boolean testBasicNodeMethods() {
1409 if ( PhylogenyNode.getNodeCount() != 0 ) {
1412 final PhylogenyNode n1 = new PhylogenyNode();
1413 final PhylogenyNode n2 = PhylogenyNode
1414 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1415 final PhylogenyNode n3 = PhylogenyNode
1416 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1417 final PhylogenyNode n4 = PhylogenyNode
1418 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1419 if ( n1.isHasAssignedEvent() ) {
1422 if ( PhylogenyNode.getNodeCount() != 4 ) {
1425 if ( n3.getIndicator() != 0 ) {
1428 if ( n3.getNumberOfExternalNodes() != 1 ) {
1431 if ( !n3.isExternal() ) {
1434 if ( !n3.isRoot() ) {
1437 if ( !n4.getName().equals( "n4" ) ) {
1441 catch ( final Exception e ) {
1442 e.printStackTrace( System.out );
1448 private static boolean testBasicPhyloXMLparsing() {
1450 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1451 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1452 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1454 if ( xml_parser.getErrorCount() > 0 ) {
1455 System.out.println( xml_parser.getErrorMessages().toString() );
1458 if ( phylogenies_0.length != 4 ) {
1461 final Phylogeny t1 = phylogenies_0[ 0 ];
1462 final Phylogeny t2 = phylogenies_0[ 1 ];
1463 final Phylogeny t3 = phylogenies_0[ 2 ];
1464 final Phylogeny t4 = phylogenies_0[ 3 ];
1465 if ( t1.getNumberOfExternalNodes() != 1 ) {
1468 if ( !t1.isRooted() ) {
1471 if ( t1.isRerootable() ) {
1474 if ( !t1.getType().equals( "gene_tree" ) ) {
1477 if ( t2.getNumberOfExternalNodes() != 2 ) {
1480 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1483 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1486 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1489 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1492 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1495 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1498 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1499 .startsWith( "actgtgggggt" ) ) {
1502 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1503 .startsWith( "ctgtgatgcat" ) ) {
1506 if ( t3.getNumberOfExternalNodes() != 4 ) {
1509 if ( !t1.getName().equals( "t1" ) ) {
1512 if ( !t2.getName().equals( "t2" ) ) {
1515 if ( !t3.getName().equals( "t3" ) ) {
1518 if ( !t4.getName().equals( "t4" ) ) {
1521 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1524 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1527 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1530 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1531 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1534 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1537 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1540 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1543 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1544 .equals( "apoptosis" ) ) {
1547 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1548 .equals( "GO:0006915" ) ) {
1551 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1552 .equals( "UniProtKB" ) ) {
1555 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1556 .equals( "experimental" ) ) {
1559 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1560 .equals( "function" ) ) {
1563 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1564 .getValue() != 1 ) {
1567 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1568 .getType().equals( "ml" ) ) {
1571 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1572 .equals( "apoptosis" ) ) {
1575 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1576 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1579 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1580 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1583 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1584 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1587 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1588 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1591 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1592 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1595 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1596 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1599 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1600 .equals( "GO:0005829" ) ) {
1603 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1604 .equals( "intracellular organelle" ) ) {
1607 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1610 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1611 .equals( "UniProt link" ) ) ) {
1614 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1617 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1618 if ( x.size() != 4 ) {
1622 for( final Accession acc : x ) {
1624 if ( !acc.getSource().equals( "KEGG" ) ) {
1627 if ( !acc.getValue().equals( "hsa:596" ) ) {
1634 catch ( final Exception e ) {
1635 e.printStackTrace( System.out );
1641 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1643 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1644 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1645 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1646 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1649 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1651 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1653 if ( xml_parser.getErrorCount() > 0 ) {
1654 System.out.println( xml_parser.getErrorMessages().toString() );
1657 if ( phylogenies_0.length != 4 ) {
1660 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1661 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1662 if ( phylogenies_t1.length != 1 ) {
1665 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1666 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1669 if ( !t1_rt.isRooted() ) {
1672 if ( t1_rt.isRerootable() ) {
1675 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1678 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1679 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1680 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1681 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1684 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1687 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1690 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1693 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1694 .startsWith( "actgtgggggt" ) ) {
1697 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1698 .startsWith( "ctgtgatgcat" ) ) {
1701 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1702 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1703 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1704 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1705 if ( phylogenies_1.length != 1 ) {
1708 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1709 if ( !t3_rt.getName().equals( "t3" ) ) {
1712 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1715 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1718 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1721 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1724 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1725 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1728 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1731 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1734 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1735 .equals( "UniProtKB" ) ) {
1738 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1739 .equals( "apoptosis" ) ) {
1742 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1743 .equals( "GO:0006915" ) ) {
1746 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1747 .equals( "UniProtKB" ) ) {
1750 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1751 .equals( "experimental" ) ) {
1754 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1755 .equals( "function" ) ) {
1758 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1759 .getValue() != 1 ) {
1762 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1763 .getType().equals( "ml" ) ) {
1766 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1767 .equals( "apoptosis" ) ) {
1770 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1771 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1774 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1775 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1778 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1779 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1782 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1783 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1786 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1787 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1790 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1791 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1794 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1795 .equals( "GO:0005829" ) ) {
1798 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1799 .equals( "intracellular organelle" ) ) {
1802 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1805 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1806 .equals( "UniProt link" ) ) ) {
1809 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1812 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1815 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1816 .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." ) ) ) {
1819 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1822 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1825 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1828 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1831 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1832 .equals( "ncbi" ) ) {
1835 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1838 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1839 .getName().equals( "B" ) ) {
1842 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1843 .getFrom() != 21 ) {
1846 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1849 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1850 .getLength() != 24 ) {
1853 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1854 .getConfidence() != 2144 ) {
1857 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1858 .equals( "pfam" ) ) {
1861 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1864 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1867 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1870 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1873 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1874 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1877 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1880 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1883 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1886 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1889 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1892 if ( taxbb.getSynonyms().size() != 2 ) {
1895 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1898 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1901 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1904 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1907 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1910 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1911 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1914 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1917 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1920 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1923 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1926 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1929 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1932 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1936 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1939 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1940 .equalsIgnoreCase( "435" ) ) {
1943 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1946 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1947 .equalsIgnoreCase( "443.7" ) ) {
1950 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1953 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1956 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1957 .equalsIgnoreCase( "433" ) ) {
1960 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1961 .getCrossReferences();
1962 if ( x.size() != 4 ) {
1966 for( final Accession acc : x ) {
1968 if ( !acc.getSource().equals( "KEGG" ) ) {
1971 if ( !acc.getValue().equals( "hsa:596" ) ) {
1978 catch ( final Exception e ) {
1979 e.printStackTrace( System.out );
1985 private static boolean testBasicPhyloXMLparsingValidating() {
1987 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1988 PhyloXmlParser xml_parser = null;
1990 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1992 catch ( final Exception e ) {
1993 // Do nothing -- means were not running from jar.
1995 if ( xml_parser == null ) {
1996 xml_parser = PhyloXmlParser.createPhyloXmlParser();
1997 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1998 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2001 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2004 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2006 if ( xml_parser.getErrorCount() > 0 ) {
2007 System.out.println( xml_parser.getErrorMessages().toString() );
2010 if ( phylogenies_0.length != 4 ) {
2013 final Phylogeny t1 = phylogenies_0[ 0 ];
2014 final Phylogeny t2 = phylogenies_0[ 1 ];
2015 final Phylogeny t3 = phylogenies_0[ 2 ];
2016 final Phylogeny t4 = phylogenies_0[ 3 ];
2017 if ( !t1.getName().equals( "t1" ) ) {
2020 if ( !t2.getName().equals( "t2" ) ) {
2023 if ( !t3.getName().equals( "t3" ) ) {
2026 if ( !t4.getName().equals( "t4" ) ) {
2029 if ( t1.getNumberOfExternalNodes() != 1 ) {
2032 if ( t2.getNumberOfExternalNodes() != 2 ) {
2035 if ( t3.getNumberOfExternalNodes() != 4 ) {
2038 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2039 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2040 if ( xml_parser.getErrorCount() > 0 ) {
2041 System.out.println( "errors:" );
2042 System.out.println( xml_parser.getErrorMessages().toString() );
2045 if ( phylogenies_1.length != 4 ) {
2048 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2050 if ( xml_parser.getErrorCount() > 0 ) {
2051 System.out.println( "errors:" );
2052 System.out.println( xml_parser.getErrorMessages().toString() );
2055 if ( phylogenies_2.length != 1 ) {
2058 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2061 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2063 if ( xml_parser.getErrorCount() > 0 ) {
2064 System.out.println( xml_parser.getErrorMessages().toString() );
2067 if ( phylogenies_3.length != 2 ) {
2070 final Phylogeny a = phylogenies_3[ 0 ];
2071 if ( !a.getName().equals( "tree 4" ) ) {
2074 if ( a.getNumberOfExternalNodes() != 3 ) {
2077 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2080 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2083 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2085 if ( xml_parser.getErrorCount() > 0 ) {
2086 System.out.println( xml_parser.getErrorMessages().toString() );
2089 if ( phylogenies_4.length != 1 ) {
2092 final Phylogeny s = phylogenies_4[ 0 ];
2093 if ( s.getNumberOfExternalNodes() != 6 ) {
2096 s.getNode( "first" );
2098 s.getNode( "\"<a'b&c'd\">\"" );
2099 s.getNode( "'''\"" );
2100 s.getNode( "\"\"\"" );
2101 s.getNode( "dick & doof" );
2103 catch ( final Exception e ) {
2104 e.printStackTrace( System.out );
2110 private static boolean testBasicProtein() {
2112 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2113 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2114 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2115 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2116 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2117 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2118 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2119 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2120 p0.addProteinDomain( y );
2121 p0.addProteinDomain( e );
2122 p0.addProteinDomain( b );
2123 p0.addProteinDomain( c );
2124 p0.addProteinDomain( d );
2125 p0.addProteinDomain( a );
2126 p0.addProteinDomain( x );
2127 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2130 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2134 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2135 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2136 aa0.addProteinDomain( a1 );
2137 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2140 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2144 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2145 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2146 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2147 aa1.addProteinDomain( a11 );
2148 aa1.addProteinDomain( a12 );
2149 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2152 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2155 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2156 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2159 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2162 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2165 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2166 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2169 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2172 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2175 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2178 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2179 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2182 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2185 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2188 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2191 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2192 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2195 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2198 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2201 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2205 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2206 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2207 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2208 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2209 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2210 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2211 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2212 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2213 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2214 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2215 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2216 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2217 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2218 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2219 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2220 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2221 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2222 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2223 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2224 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2225 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2226 p00.addProteinDomain( y0 );
2227 p00.addProteinDomain( e0 );
2228 p00.addProteinDomain( b0 );
2229 p00.addProteinDomain( c0 );
2230 p00.addProteinDomain( d0 );
2231 p00.addProteinDomain( a0 );
2232 p00.addProteinDomain( x0 );
2233 p00.addProteinDomain( y1 );
2234 p00.addProteinDomain( y2 );
2235 p00.addProteinDomain( y3 );
2236 p00.addProteinDomain( e1 );
2237 p00.addProteinDomain( e2 );
2238 p00.addProteinDomain( e3 );
2239 p00.addProteinDomain( e4 );
2240 p00.addProteinDomain( e5 );
2241 p00.addProteinDomain( z0 );
2242 p00.addProteinDomain( z1 );
2243 p00.addProteinDomain( z2 );
2244 p00.addProteinDomain( zz0 );
2245 p00.addProteinDomain( zz1 );
2246 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2249 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2252 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2255 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2258 if ( !p00.toDomainArchitectureString( "~", 7, "" ).equals( "a~b~c~d~e~e~e~e~e~e~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2261 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2262 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2263 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2264 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2265 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2266 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2267 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2268 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2269 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2270 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2271 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2272 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2273 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2274 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2275 p.addProteinDomain( B15 );
2276 p.addProteinDomain( C50 );
2277 p.addProteinDomain( A60 );
2278 p.addProteinDomain( A30 );
2279 p.addProteinDomain( C70 );
2280 p.addProteinDomain( B35 );
2281 p.addProteinDomain( B40 );
2282 p.addProteinDomain( A0 );
2283 p.addProteinDomain( A10 );
2284 p.addProteinDomain( A20 );
2285 p.addProteinDomain( B25 );
2286 p.addProteinDomain( D80 );
2287 List<String> domains_ids = new ArrayList<String>();
2288 domains_ids.add( "A" );
2289 domains_ids.add( "B" );
2290 domains_ids.add( "C" );
2291 if ( !p.contains( domains_ids, false ) ) {
2294 if ( !p.contains( domains_ids, true ) ) {
2297 domains_ids.add( "X" );
2298 if ( p.contains( domains_ids, false ) ) {
2301 if ( p.contains( domains_ids, true ) ) {
2304 domains_ids = new ArrayList<String>();
2305 domains_ids.add( "A" );
2306 domains_ids.add( "C" );
2307 domains_ids.add( "D" );
2308 if ( !p.contains( domains_ids, false ) ) {
2311 if ( !p.contains( domains_ids, true ) ) {
2314 domains_ids = new ArrayList<String>();
2315 domains_ids.add( "A" );
2316 domains_ids.add( "D" );
2317 domains_ids.add( "C" );
2318 if ( !p.contains( domains_ids, false ) ) {
2321 if ( p.contains( domains_ids, true ) ) {
2324 domains_ids = new ArrayList<String>();
2325 domains_ids.add( "A" );
2326 domains_ids.add( "A" );
2327 domains_ids.add( "B" );
2328 if ( !p.contains( domains_ids, false ) ) {
2331 if ( !p.contains( domains_ids, true ) ) {
2334 domains_ids = new ArrayList<String>();
2335 domains_ids.add( "A" );
2336 domains_ids.add( "A" );
2337 domains_ids.add( "A" );
2338 domains_ids.add( "B" );
2339 domains_ids.add( "B" );
2340 if ( !p.contains( domains_ids, false ) ) {
2343 if ( !p.contains( domains_ids, true ) ) {
2346 domains_ids = new ArrayList<String>();
2347 domains_ids.add( "A" );
2348 domains_ids.add( "A" );
2349 domains_ids.add( "B" );
2350 domains_ids.add( "A" );
2351 domains_ids.add( "B" );
2352 domains_ids.add( "B" );
2353 domains_ids.add( "A" );
2354 domains_ids.add( "B" );
2355 domains_ids.add( "C" );
2356 domains_ids.add( "A" );
2357 domains_ids.add( "C" );
2358 domains_ids.add( "D" );
2359 if ( !p.contains( domains_ids, false ) ) {
2362 if ( p.contains( domains_ids, true ) ) {
2366 catch ( final Exception e ) {
2367 e.printStackTrace( System.out );
2373 private static boolean testBasicTable() {
2375 final BasicTable<String> t0 = new BasicTable<String>();
2376 if ( t0.getNumberOfColumns() != 0 ) {
2379 if ( t0.getNumberOfRows() != 0 ) {
2382 t0.setValue( 3, 2, "23" );
2383 t0.setValue( 10, 1, "error" );
2384 t0.setValue( 10, 1, "110" );
2385 t0.setValue( 9, 1, "19" );
2386 t0.setValue( 1, 10, "101" );
2387 t0.setValue( 10, 10, "1010" );
2388 t0.setValue( 100, 10, "10100" );
2389 t0.setValue( 0, 0, "00" );
2390 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2393 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2396 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2399 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2402 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2405 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2408 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2411 if ( t0.getNumberOfColumns() != 101 ) {
2414 if ( t0.getNumberOfRows() != 11 ) {
2417 if ( t0.getValueAsString( 49, 4 ) != null ) {
2420 final String l = ForesterUtil.getLineSeparator();
2421 final StringBuffer source = new StringBuffer();
2422 source.append( "" + l );
2423 source.append( "# 1 1 1 1 1 1 1 1" + l );
2424 source.append( " 00 01 02 03" + l );
2425 source.append( " 10 11 12 13 " + l );
2426 source.append( "20 21 22 23 " + l );
2427 source.append( " 30 31 32 33" + l );
2428 source.append( "40 41 42 43" + l );
2429 source.append( " # 1 1 1 1 1 " + l );
2430 source.append( "50 51 52 53 54" + l );
2431 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2432 if ( t1.getNumberOfColumns() != 5 ) {
2435 if ( t1.getNumberOfRows() != 6 ) {
2438 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2441 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2444 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2447 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2450 final StringBuffer source1 = new StringBuffer();
2451 source1.append( "" + l );
2452 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2453 source1.append( " 00; 01 ;02;03" + l );
2454 source1.append( " 10; 11; 12; 13 " + l );
2455 source1.append( "20; 21; 22; 23 " + l );
2456 source1.append( " 30; 31; 32; 33" + l );
2457 source1.append( "40;41;42;43" + l );
2458 source1.append( " # 1 1 1 1 1 " + l );
2459 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2460 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2461 if ( t2.getNumberOfColumns() != 5 ) {
2464 if ( t2.getNumberOfRows() != 6 ) {
2467 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2470 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2473 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2476 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2479 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2482 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2485 final StringBuffer source2 = new StringBuffer();
2486 source2.append( "" + l );
2487 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2488 source2.append( " 00; 01 ;02;03" + l );
2489 source2.append( " 10; 11; 12; 13 " + l );
2490 source2.append( "20; 21; 22; 23 " + l );
2491 source2.append( " " + l );
2492 source2.append( " 30; 31; 32; 33" + l );
2493 source2.append( "40;41;42;43" + l );
2494 source2.append( " comment: 1 1 1 1 1 " + l );
2495 source2.append( ";;;50 ; 52; 53;;54 " + l );
2496 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2502 if ( tl.size() != 2 ) {
2505 final BasicTable<String> t3 = tl.get( 0 );
2506 final BasicTable<String> t4 = tl.get( 1 );
2507 if ( t3.getNumberOfColumns() != 4 ) {
2510 if ( t3.getNumberOfRows() != 3 ) {
2513 if ( t4.getNumberOfColumns() != 4 ) {
2516 if ( t4.getNumberOfRows() != 3 ) {
2519 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2522 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2526 catch ( final Exception e ) {
2527 e.printStackTrace( System.out );
2533 private static boolean testBasicTolXMLparsing() {
2535 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2536 final TolParser parser = new TolParser();
2537 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2538 if ( parser.getErrorCount() > 0 ) {
2539 System.out.println( parser.getErrorMessages().toString() );
2542 if ( phylogenies_0.length != 1 ) {
2545 final Phylogeny t1 = phylogenies_0[ 0 ];
2546 if ( t1.getNumberOfExternalNodes() != 5 ) {
2549 if ( !t1.isRooted() ) {
2552 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2555 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2558 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2561 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2564 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2565 if ( parser.getErrorCount() > 0 ) {
2566 System.out.println( parser.getErrorMessages().toString() );
2569 if ( phylogenies_1.length != 1 ) {
2572 final Phylogeny t2 = phylogenies_1[ 0 ];
2573 if ( t2.getNumberOfExternalNodes() != 664 ) {
2576 if ( !t2.isRooted() ) {
2579 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2582 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2585 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2588 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2591 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2594 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2595 .equals( "Aquifex" ) ) {
2598 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2599 if ( parser.getErrorCount() > 0 ) {
2600 System.out.println( parser.getErrorMessages().toString() );
2603 if ( phylogenies_2.length != 1 ) {
2606 final Phylogeny t3 = phylogenies_2[ 0 ];
2607 if ( t3.getNumberOfExternalNodes() != 184 ) {
2610 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2613 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2616 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2619 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2620 if ( parser.getErrorCount() > 0 ) {
2621 System.out.println( parser.getErrorMessages().toString() );
2624 if ( phylogenies_3.length != 1 ) {
2627 final Phylogeny t4 = phylogenies_3[ 0 ];
2628 if ( t4.getNumberOfExternalNodes() != 1 ) {
2631 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2634 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2637 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2640 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2641 if ( parser.getErrorCount() > 0 ) {
2642 System.out.println( parser.getErrorMessages().toString() );
2645 if ( phylogenies_4.length != 1 ) {
2648 final Phylogeny t5 = phylogenies_4[ 0 ];
2649 if ( t5.getNumberOfExternalNodes() != 13 ) {
2652 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2655 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2658 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2662 catch ( final Exception e ) {
2663 e.printStackTrace( System.out );
2669 private static boolean testBasicTreeMethods() {
2671 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2672 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2673 if ( t2.getNumberOfExternalNodes() != 4 ) {
2676 if ( t2.getHeight() != 8.5 ) {
2679 if ( !t2.isCompletelyBinary() ) {
2682 if ( t2.isEmpty() ) {
2685 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2686 if ( t3.getNumberOfExternalNodes() != 5 ) {
2689 if ( t3.getHeight() != 11 ) {
2692 if ( t3.isCompletelyBinary() ) {
2695 final PhylogenyNode n = t3.getNode( "ABC" );
2696 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 ];
2697 if ( t4.getNumberOfExternalNodes() != 9 ) {
2700 if ( t4.getHeight() != 11 ) {
2703 if ( t4.isCompletelyBinary() ) {
2706 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)" );
2707 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2708 if ( t5.getNumberOfExternalNodes() != 8 ) {
2711 if ( t5.getHeight() != 15 ) {
2714 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)" );
2715 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2716 if ( t6.getHeight() != 15 ) {
2719 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)" );
2720 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2721 if ( t7.getHeight() != 15 ) {
2724 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)" );
2725 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2726 if ( t8.getNumberOfExternalNodes() != 10 ) {
2729 if ( t8.getHeight() != 15 ) {
2732 final char[] a9 = new char[] { 'a' };
2733 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2734 if ( t9.getHeight() != 0 ) {
2737 final char[] a10 = new char[] { 'a', ':', '6' };
2738 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2739 if ( t10.getHeight() != 6 ) {
2743 catch ( final Exception e ) {
2744 e.printStackTrace( System.out );
2750 private static boolean testConfidenceAssessor() {
2752 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2753 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2754 final Phylogeny[] ev0 = factory
2755 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2757 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2758 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2761 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2764 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2765 final Phylogeny[] ev1 = factory
2766 .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)));",
2768 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2769 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2772 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2775 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2776 final Phylogeny[] ev_b = factory
2777 .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",
2779 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2780 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2783 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2787 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2788 final Phylogeny[] ev1x = factory
2789 .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)));",
2791 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2792 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2795 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2798 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2799 final Phylogeny[] ev_bx = factory
2800 .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",
2802 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2803 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2806 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2810 final Phylogeny[] t2 = factory
2811 .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);",
2813 final Phylogeny[] ev2 = factory
2814 .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);",
2816 for( final Phylogeny target : t2 ) {
2817 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2820 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2821 new NHXParser() )[ 0 ];
2822 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2823 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2824 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2827 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2830 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2834 catch ( final Exception e ) {
2835 e.printStackTrace();
2841 private static boolean testCopyOfNodeData() {
2843 final PhylogenyNode n1 = PhylogenyNode
2844 .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]" );
2845 final PhylogenyNode n2 = n1.copyNodeData();
2846 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2850 catch ( final Exception e ) {
2851 e.printStackTrace();
2857 private static boolean testCreateBalancedPhylogeny() {
2859 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2860 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2863 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2866 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2867 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2870 if ( p1.getNumberOfExternalNodes() != 100 ) {
2874 catch ( final Exception e ) {
2875 e.printStackTrace();
2881 private static boolean testCreateUriForSeqWeb() {
2883 final PhylogenyNode n = new PhylogenyNode();
2884 n.setName( "tr|B3RJ64" );
2885 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2888 n.setName( "B0LM41_HUMAN" );
2889 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2892 n.setName( "NP_001025424" );
2893 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2896 n.setName( "_NM_001030253-" );
2897 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2900 n.setName( "XM_002122186" );
2901 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2904 n.setName( "dgh_AAA34956_gdg" );
2905 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2908 n.setName( "AAA34956" );
2909 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2912 n.setName( "GI:394892" );
2913 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2914 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2917 n.setName( "gi_394892" );
2918 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2919 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2922 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2923 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2924 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2927 n.setName( "P12345" );
2928 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2929 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2932 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2933 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2934 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2938 catch ( final Exception e ) {
2939 e.printStackTrace( System.out );
2945 private static boolean testDataObjects() {
2947 final Confidence s0 = new Confidence();
2948 final Confidence s1 = new Confidence();
2949 if ( !s0.isEqual( s1 ) ) {
2952 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2953 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2954 if ( s2.isEqual( s1 ) ) {
2957 if ( !s2.isEqual( s3 ) ) {
2960 final Confidence s4 = ( Confidence ) s3.copy();
2961 if ( !s4.isEqual( s3 ) ) {
2968 final Taxonomy t1 = new Taxonomy();
2969 final Taxonomy t2 = new Taxonomy();
2970 final Taxonomy t3 = new Taxonomy();
2971 final Taxonomy t4 = new Taxonomy();
2972 final Taxonomy t5 = new Taxonomy();
2973 t1.setIdentifier( new Identifier( "ecoli" ) );
2974 t1.setTaxonomyCode( "ECOLI" );
2975 t1.setScientificName( "E. coli" );
2976 t1.setCommonName( "coli" );
2977 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2978 if ( !t1.isEqual( t0 ) ) {
2981 t2.setIdentifier( new Identifier( "ecoli" ) );
2982 t2.setTaxonomyCode( "OTHER" );
2983 t2.setScientificName( "what" );
2984 t2.setCommonName( "something" );
2985 if ( !t1.isEqual( t2 ) ) {
2988 t2.setIdentifier( new Identifier( "nemve" ) );
2989 if ( t1.isEqual( t2 ) ) {
2992 t1.setIdentifier( null );
2993 t3.setTaxonomyCode( "ECOLI" );
2994 t3.setScientificName( "what" );
2995 t3.setCommonName( "something" );
2996 if ( !t1.isEqual( t3 ) ) {
2999 t1.setIdentifier( null );
3000 t1.setTaxonomyCode( "" );
3001 t4.setScientificName( "E. ColI" );
3002 t4.setCommonName( "something" );
3003 if ( !t1.isEqual( t4 ) ) {
3006 t4.setScientificName( "B. subtilis" );
3007 t4.setCommonName( "something" );
3008 if ( t1.isEqual( t4 ) ) {
3011 t1.setIdentifier( null );
3012 t1.setTaxonomyCode( "" );
3013 t1.setScientificName( "" );
3014 t5.setCommonName( "COLI" );
3015 if ( !t1.isEqual( t5 ) ) {
3018 t5.setCommonName( "vibrio" );
3019 if ( t1.isEqual( t5 ) ) {
3024 final Identifier id0 = new Identifier( "123", "pfam" );
3025 final Identifier id1 = ( Identifier ) id0.copy();
3026 if ( !id1.isEqual( id1 ) ) {
3029 if ( !id1.isEqual( id0 ) ) {
3032 if ( !id0.isEqual( id1 ) ) {
3039 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3040 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3041 if ( !pd1.isEqual( pd1 ) ) {
3044 if ( !pd1.isEqual( pd0 ) ) {
3049 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3050 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3051 if ( !pd3.isEqual( pd3 ) ) {
3054 if ( !pd2.isEqual( pd3 ) ) {
3057 if ( !pd0.isEqual( pd3 ) ) {
3062 // DomainArchitecture
3063 // ------------------
3064 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3065 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3066 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3067 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3068 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3069 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3074 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3075 if ( ds0.getNumberOfDomains() != 4 ) {
3078 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3079 if ( !ds0.isEqual( ds0 ) ) {
3082 if ( !ds0.isEqual( ds1 ) ) {
3085 if ( ds1.getNumberOfDomains() != 4 ) {
3088 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3093 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3094 if ( ds0.isEqual( ds2 ) ) {
3100 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3101 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3102 System.out.println( ds3.toNHX() );
3105 if ( ds3.getNumberOfDomains() != 3 ) {
3110 final Event e1 = new Event( Event.EventType.fusion );
3111 if ( e1.isDuplication() ) {
3114 if ( !e1.isFusion() ) {
3117 if ( !e1.asText().toString().equals( "fusion" ) ) {
3120 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3123 final Event e11 = new Event( Event.EventType.fusion );
3124 if ( !e11.isEqual( e1 ) ) {
3127 if ( !e11.toNHX().toString().equals( "" ) ) {
3130 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3131 if ( e2.isDuplication() ) {
3134 if ( !e2.isSpeciationOrDuplication() ) {
3137 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3140 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3143 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3146 if ( e11.isEqual( e2 ) ) {
3149 final Event e2c = ( Event ) e2.copy();
3150 if ( !e2c.isEqual( e2 ) ) {
3153 Event e3 = new Event( 1, 2, 3 );
3154 if ( e3.isDuplication() ) {
3157 if ( e3.isSpeciation() ) {
3160 if ( e3.isGeneLoss() ) {
3163 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3166 final Event e3c = ( Event ) e3.copy();
3167 final Event e3cc = ( Event ) e3c.copy();
3168 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3172 if ( !e3c.isEqual( e3cc ) ) {
3175 Event e4 = new Event( 1, 2, 3 );
3176 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3179 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3182 final Event e4c = ( Event ) e4.copy();
3184 final Event e4cc = ( Event ) e4c.copy();
3185 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3188 if ( !e4c.isEqual( e4cc ) ) {
3191 final Event e5 = new Event();
3192 if ( !e5.isUnassigned() ) {
3195 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3198 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3201 final Event e6 = new Event( 1, 0, 0 );
3202 if ( !e6.asText().toString().equals( "duplication" ) ) {
3205 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3208 final Event e7 = new Event( 0, 1, 0 );
3209 if ( !e7.asText().toString().equals( "speciation" ) ) {
3212 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3215 final Event e8 = new Event( 0, 0, 1 );
3216 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3219 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3223 catch ( final Exception e ) {
3224 e.printStackTrace( System.out );
3230 private static boolean testDeletionOfExternalNodes() {
3232 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3233 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3234 final PhylogenyWriter w = new PhylogenyWriter();
3235 if ( t0.isEmpty() ) {
3238 if ( t0.getNumberOfExternalNodes() != 1 ) {
3241 t0.deleteSubtree( t0.getNode( "A" ), false );
3242 if ( t0.getNumberOfExternalNodes() != 0 ) {
3245 if ( !t0.isEmpty() ) {
3248 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3249 if ( t1.getNumberOfExternalNodes() != 2 ) {
3252 t1.deleteSubtree( t1.getNode( "A" ), false );
3253 if ( t1.getNumberOfExternalNodes() != 1 ) {
3256 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3259 t1.deleteSubtree( t1.getNode( "B" ), false );
3260 if ( t1.getNumberOfExternalNodes() != 1 ) {
3263 t1.deleteSubtree( t1.getNode( "r" ), false );
3264 if ( !t1.isEmpty() ) {
3267 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3268 if ( t2.getNumberOfExternalNodes() != 3 ) {
3271 t2.deleteSubtree( t2.getNode( "B" ), false );
3272 if ( t2.getNumberOfExternalNodes() != 2 ) {
3275 t2.toNewHampshireX();
3276 PhylogenyNode n = t2.getNode( "A" );
3277 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3280 t2.deleteSubtree( t2.getNode( "A" ), false );
3281 if ( t2.getNumberOfExternalNodes() != 2 ) {
3284 t2.deleteSubtree( t2.getNode( "C" ), true );
3285 if ( t2.getNumberOfExternalNodes() != 1 ) {
3288 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3289 if ( t3.getNumberOfExternalNodes() != 4 ) {
3292 t3.deleteSubtree( t3.getNode( "B" ), true );
3293 if ( t3.getNumberOfExternalNodes() != 3 ) {
3296 n = t3.getNode( "A" );
3297 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3300 n = n.getNextExternalNode();
3301 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3304 t3.deleteSubtree( t3.getNode( "A" ), true );
3305 if ( t3.getNumberOfExternalNodes() != 2 ) {
3308 n = t3.getNode( "C" );
3309 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3312 t3.deleteSubtree( t3.getNode( "C" ), true );
3313 if ( t3.getNumberOfExternalNodes() != 1 ) {
3316 t3.deleteSubtree( t3.getNode( "D" ), true );
3317 if ( t3.getNumberOfExternalNodes() != 0 ) {
3320 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3321 if ( t4.getNumberOfExternalNodes() != 6 ) {
3324 t4.deleteSubtree( t4.getNode( "B2" ), true );
3325 if ( t4.getNumberOfExternalNodes() != 5 ) {
3328 String s = w.toNewHampshire( t4, false, true ).toString();
3329 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3332 t4.deleteSubtree( t4.getNode( "B11" ), true );
3333 if ( t4.getNumberOfExternalNodes() != 4 ) {
3336 t4.deleteSubtree( t4.getNode( "C" ), true );
3337 if ( t4.getNumberOfExternalNodes() != 3 ) {
3340 n = t4.getNode( "A" );
3341 n = n.getNextExternalNode();
3342 if ( !n.getName().equals( "B12" ) ) {
3345 n = n.getNextExternalNode();
3346 if ( !n.getName().equals( "D" ) ) {
3349 s = w.toNewHampshire( t4, false, true ).toString();
3350 if ( !s.equals( "((A,B12),D);" ) ) {
3353 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3354 t5.deleteSubtree( t5.getNode( "A" ), true );
3355 if ( t5.getNumberOfExternalNodes() != 5 ) {
3358 s = w.toNewHampshire( t5, false, true ).toString();
3359 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3362 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3363 t6.deleteSubtree( t6.getNode( "B11" ), true );
3364 if ( t6.getNumberOfExternalNodes() != 5 ) {
3367 s = w.toNewHampshire( t6, false, false ).toString();
3368 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3371 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3372 t7.deleteSubtree( t7.getNode( "B12" ), true );
3373 if ( t7.getNumberOfExternalNodes() != 5 ) {
3376 s = w.toNewHampshire( t7, false, true ).toString();
3377 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3380 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3381 t8.deleteSubtree( t8.getNode( "B2" ), true );
3382 if ( t8.getNumberOfExternalNodes() != 5 ) {
3385 s = w.toNewHampshire( t8, false, false ).toString();
3386 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3389 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3390 t9.deleteSubtree( t9.getNode( "C" ), true );
3391 if ( t9.getNumberOfExternalNodes() != 5 ) {
3394 s = w.toNewHampshire( t9, false, true ).toString();
3395 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3398 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3399 t10.deleteSubtree( t10.getNode( "D" ), true );
3400 if ( t10.getNumberOfExternalNodes() != 5 ) {
3403 s = w.toNewHampshire( t10, false, true ).toString();
3404 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3407 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3408 t11.deleteSubtree( t11.getNode( "A" ), true );
3409 if ( t11.getNumberOfExternalNodes() != 2 ) {
3412 s = w.toNewHampshire( t11, false, true ).toString();
3413 if ( !s.equals( "(B,C);" ) ) {
3416 t11.deleteSubtree( t11.getNode( "C" ), true );
3417 if ( t11.getNumberOfExternalNodes() != 1 ) {
3420 s = w.toNewHampshire( t11, false, false ).toString();
3421 if ( !s.equals( "B;" ) ) {
3424 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3425 t12.deleteSubtree( t12.getNode( "B2" ), true );
3426 if ( t12.getNumberOfExternalNodes() != 8 ) {
3429 s = w.toNewHampshire( t12, false, true ).toString();
3430 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3433 t12.deleteSubtree( t12.getNode( "B3" ), true );
3434 if ( t12.getNumberOfExternalNodes() != 7 ) {
3437 s = w.toNewHampshire( t12, false, true ).toString();
3438 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3441 t12.deleteSubtree( t12.getNode( "C3" ), true );
3442 if ( t12.getNumberOfExternalNodes() != 6 ) {
3445 s = w.toNewHampshire( t12, false, true ).toString();
3446 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3449 t12.deleteSubtree( t12.getNode( "A1" ), true );
3450 if ( t12.getNumberOfExternalNodes() != 5 ) {
3453 s = w.toNewHampshire( t12, false, true ).toString();
3454 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3457 t12.deleteSubtree( t12.getNode( "B1" ), true );
3458 if ( t12.getNumberOfExternalNodes() != 4 ) {
3461 s = w.toNewHampshire( t12, false, true ).toString();
3462 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3465 t12.deleteSubtree( t12.getNode( "A3" ), true );
3466 if ( t12.getNumberOfExternalNodes() != 3 ) {
3469 s = w.toNewHampshire( t12, false, true ).toString();
3470 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3473 t12.deleteSubtree( t12.getNode( "A2" ), true );
3474 if ( t12.getNumberOfExternalNodes() != 2 ) {
3477 s = w.toNewHampshire( t12, false, true ).toString();
3478 if ( !s.equals( "(C1,C2);" ) ) {
3481 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3482 t13.deleteSubtree( t13.getNode( "D" ), true );
3483 if ( t13.getNumberOfExternalNodes() != 4 ) {
3486 s = w.toNewHampshire( t13, false, true ).toString();
3487 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3490 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3491 t14.deleteSubtree( t14.getNode( "E" ), true );
3492 if ( t14.getNumberOfExternalNodes() != 5 ) {
3495 s = w.toNewHampshire( t14, false, true ).toString();
3496 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3499 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3500 t15.deleteSubtree( t15.getNode( "B2" ), true );
3501 if ( t15.getNumberOfExternalNodes() != 11 ) {
3504 t15.deleteSubtree( t15.getNode( "B1" ), true );
3505 if ( t15.getNumberOfExternalNodes() != 10 ) {
3508 t15.deleteSubtree( t15.getNode( "B3" ), true );
3509 if ( t15.getNumberOfExternalNodes() != 9 ) {
3512 t15.deleteSubtree( t15.getNode( "B4" ), true );
3513 if ( t15.getNumberOfExternalNodes() != 8 ) {
3516 t15.deleteSubtree( t15.getNode( "A1" ), true );
3517 if ( t15.getNumberOfExternalNodes() != 7 ) {
3520 t15.deleteSubtree( t15.getNode( "C4" ), true );
3521 if ( t15.getNumberOfExternalNodes() != 6 ) {
3525 catch ( final Exception e ) {
3526 e.printStackTrace( System.out );
3532 private static boolean testDescriptiveStatistics() {
3534 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3535 dss1.addValue( 82 );
3536 dss1.addValue( 78 );
3537 dss1.addValue( 70 );
3538 dss1.addValue( 58 );
3539 dss1.addValue( 42 );
3540 if ( dss1.getN() != 5 ) {
3543 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3546 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3549 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3552 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3555 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3558 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3561 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3564 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3567 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3570 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3573 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3576 dss1.addValue( 123 );
3577 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3580 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3583 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3586 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3587 dss2.addValue( -1.85 );
3588 dss2.addValue( 57.5 );
3589 dss2.addValue( 92.78 );
3590 dss2.addValue( 57.78 );
3591 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3594 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3597 final double[] a = dss2.getDataAsDoubleArray();
3598 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3601 dss2.addValue( -100 );
3602 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3605 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3608 final double[] ds = new double[ 14 ];
3623 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3624 if ( bins.length != 4 ) {
3627 if ( bins[ 0 ] != 2 ) {
3630 if ( bins[ 1 ] != 3 ) {
3633 if ( bins[ 2 ] != 4 ) {
3636 if ( bins[ 3 ] != 5 ) {
3639 final double[] ds1 = new double[ 9 ];
3649 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3650 if ( bins1.length != 4 ) {
3653 if ( bins1[ 0 ] != 2 ) {
3656 if ( bins1[ 1 ] != 3 ) {
3659 if ( bins1[ 2 ] != 0 ) {
3662 if ( bins1[ 3 ] != 4 ) {
3665 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3666 if ( bins1_1.length != 3 ) {
3669 if ( bins1_1[ 0 ] != 3 ) {
3672 if ( bins1_1[ 1 ] != 2 ) {
3675 if ( bins1_1[ 2 ] != 4 ) {
3678 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3679 if ( bins1_2.length != 3 ) {
3682 if ( bins1_2[ 0 ] != 2 ) {
3685 if ( bins1_2[ 1 ] != 2 ) {
3688 if ( bins1_2[ 2 ] != 2 ) {
3691 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3705 dss3.addValue( 10 );
3706 dss3.addValue( 10 );
3707 dss3.addValue( 10 );
3708 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3709 histo.toStringBuffer( 10, '=', 40, 5 );
3710 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3712 catch ( final Exception e ) {
3713 e.printStackTrace( System.out );
3719 private static boolean testDir( final String file ) {
3721 final File f = new File( file );
3722 if ( !f.exists() ) {
3725 if ( !f.isDirectory() ) {
3728 if ( !f.canRead() ) {
3732 catch ( final Exception e ) {
3738 private static boolean testEbiEntryRetrieval() {
3740 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3741 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3742 System.out.println( entry.getAccession() );
3745 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3746 System.out.println( entry.getTaxonomyScientificName() );
3749 if ( !entry.getSequenceName()
3750 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3751 System.out.println( entry.getSequenceName() );
3754 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3755 // System.out.println( entry.getSequenceSymbol() );
3758 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3759 System.out.println( entry.getGeneName() );
3762 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3763 System.out.println( entry.getTaxonomyIdentifier() );
3766 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3767 System.out.println( entry.getAnnotations().first().getRefValue() );
3770 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3771 System.out.println( entry.getAnnotations().first().getRefSource() );
3774 if ( entry.getCrossReferences().size() != 5 ) {
3778 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3779 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3782 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3783 System.out.println( entry1.getTaxonomyScientificName() );
3786 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3787 System.out.println( entry1.getSequenceName() );
3790 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3791 System.out.println( entry1.getTaxonomyIdentifier() );
3794 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3795 System.out.println( entry1.getGeneName() );
3798 if ( entry1.getCrossReferences().size() != 6 ) {
3802 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3803 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3806 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3807 System.out.println( entry2.getTaxonomyScientificName() );
3810 if ( !entry2.getSequenceName()
3811 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3812 System.out.println( entry2.getSequenceName() );
3815 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3816 System.out.println( entry2.getTaxonomyIdentifier() );
3819 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3820 System.out.println( entry2.getGeneName() );
3823 if ( entry2.getCrossReferences().size() != 3 ) {
3827 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3828 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3831 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3832 System.out.println( entry3.getTaxonomyScientificName() );
3835 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3836 System.out.println( entry3.getSequenceName() );
3839 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3840 System.out.println( entry3.getTaxonomyIdentifier() );
3843 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3844 System.out.println( entry3.getSequenceSymbol() );
3847 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3850 if ( entry3.getCrossReferences().size() != 8 ) {
3855 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3856 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
3859 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3860 System.out.println( entry4.getTaxonomyScientificName() );
3863 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
3864 System.out.println( entry4.getSequenceName() );
3867 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
3868 System.out.println( entry4.getTaxonomyIdentifier() );
3871 if ( !entry4.getGeneName().equals( "ras" ) ) {
3872 System.out.println( entry4.getGeneName() );
3875 // if ( !entry4.getChromosome().equals( "ras" ) ) {
3876 // System.out.println( entry4.getChromosome() );
3879 // if ( !entry4.getMap().equals( "ras" ) ) {
3880 // System.out.println( entry4.getMap() );
3886 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
3887 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
3890 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
3891 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
3894 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
3895 System.out.println( entry5.getTaxonomyScientificName() );
3898 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
3899 System.out.println( entry5.getSequenceName() );
3902 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
3903 System.out.println( entry5.getTaxonomyIdentifier() );
3907 catch ( final IOException e ) {
3908 System.out.println();
3909 System.out.println( "the following might be due to absence internet connection:" );
3910 e.printStackTrace( System.out );
3913 catch ( final Exception e ) {
3914 e.printStackTrace();
3920 private static boolean testExternalNodeRelatedMethods() {
3922 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3923 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3924 PhylogenyNode n = t1.getNode( "A" );
3925 n = n.getNextExternalNode();
3926 if ( !n.getName().equals( "B" ) ) {
3929 n = n.getNextExternalNode();
3930 if ( !n.getName().equals( "C" ) ) {
3933 n = n.getNextExternalNode();
3934 if ( !n.getName().equals( "D" ) ) {
3937 n = t1.getNode( "B" );
3938 while ( !n.isLastExternalNode() ) {
3939 n = n.getNextExternalNode();
3941 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3942 n = t2.getNode( "A" );
3943 n = n.getNextExternalNode();
3944 if ( !n.getName().equals( "B" ) ) {
3947 n = n.getNextExternalNode();
3948 if ( !n.getName().equals( "C" ) ) {
3951 n = n.getNextExternalNode();
3952 if ( !n.getName().equals( "D" ) ) {
3955 n = t2.getNode( "B" );
3956 while ( !n.isLastExternalNode() ) {
3957 n = n.getNextExternalNode();
3959 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3960 n = t3.getNode( "A" );
3961 n = n.getNextExternalNode();
3962 if ( !n.getName().equals( "B" ) ) {
3965 n = n.getNextExternalNode();
3966 if ( !n.getName().equals( "C" ) ) {
3969 n = n.getNextExternalNode();
3970 if ( !n.getName().equals( "D" ) ) {
3973 n = n.getNextExternalNode();
3974 if ( !n.getName().equals( "E" ) ) {
3977 n = n.getNextExternalNode();
3978 if ( !n.getName().equals( "F" ) ) {
3981 n = n.getNextExternalNode();
3982 if ( !n.getName().equals( "G" ) ) {
3985 n = n.getNextExternalNode();
3986 if ( !n.getName().equals( "H" ) ) {
3989 n = t3.getNode( "B" );
3990 while ( !n.isLastExternalNode() ) {
3991 n = n.getNextExternalNode();
3993 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3994 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3995 final PhylogenyNode node = iter.next();
3997 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3998 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3999 final PhylogenyNode node = iter.next();
4001 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4002 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4003 if ( !iter.next().getName().equals( "A" ) ) {
4006 if ( !iter.next().getName().equals( "B" ) ) {
4009 if ( !iter.next().getName().equals( "C" ) ) {
4012 if ( !iter.next().getName().equals( "D" ) ) {
4015 if ( !iter.next().getName().equals( "E" ) ) {
4018 if ( !iter.next().getName().equals( "F" ) ) {
4021 if ( iter.hasNext() ) {
4025 catch ( final Exception e ) {
4026 e.printStackTrace( System.out );
4032 private static boolean testExtractSNFromNodeName() {
4034 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4037 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
4038 .equals( "Mus musculus musculus" ) ) {
4041 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
4042 .equals( "Mus musculus musculus" ) ) {
4045 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
4048 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
4049 .equals( "Mus musculus" ) ) {
4053 catch ( final Exception e ) {
4054 e.printStackTrace( System.out );
4060 private static boolean testExtractTaxonomyCodeFromNodeName() {
4062 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4065 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4066 .equals( "SOYBN" ) ) {
4069 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4070 .equals( "ARATH" ) ) {
4073 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4074 .equals( "ARATH" ) ) {
4077 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4080 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4083 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4086 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4087 .equals( "SOYBN" ) ) {
4090 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4091 .equals( "SOYBN" ) ) {
4094 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4095 .equals( "SOYBN" ) ) {
4098 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4099 .equals( "SOYBN" ) ) {
4102 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4103 .equals( "SOYBN" ) ) {
4106 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4107 .equals( "SOYBN" ) ) {
4110 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4111 .equals( "SOYBN" ) ) {
4114 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4115 .equals( "SOYBN" ) ) {
4118 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4121 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4122 .equals( "SOYBN" ) ) {
4125 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4126 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4129 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4130 .equals( "9YX45" ) ) {
4133 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4134 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4135 .equals( "MOUSE" ) ) {
4138 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4139 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4140 .equals( "MOUSE" ) ) {
4143 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4144 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4145 .equals( "MOUSE" ) ) {
4148 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4149 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4152 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4153 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4156 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4157 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4160 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4161 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4164 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4165 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4168 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4169 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4172 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4173 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4176 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4177 .equals( "RAT" ) ) {
4180 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4181 .equals( "PIG" ) ) {
4185 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4186 .equals( "MOUSE" ) ) {
4189 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4190 .equals( "MOUSE" ) ) {
4193 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4197 catch ( final Exception e ) {
4198 e.printStackTrace( System.out );
4204 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4206 PhylogenyNode n = new PhylogenyNode();
4207 n.setName( "tr|B3RJ64" );
4208 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4211 n.setName( "tr.B3RJ64" );
4212 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4215 n.setName( "tr=B3RJ64" );
4216 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4219 n.setName( "tr-B3RJ64" );
4220 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4223 n.setName( "tr/B3RJ64" );
4224 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4227 n.setName( "tr\\B3RJ64" );
4228 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4231 n.setName( "tr_B3RJ64" );
4232 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4235 n.setName( " tr|B3RJ64 " );
4236 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4239 n.setName( "-tr|B3RJ64-" );
4240 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4243 n.setName( "-tr=B3RJ64-" );
4244 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4247 n.setName( "_tr=B3RJ64_" );
4248 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4251 n.setName( " tr_tr|B3RJ64_sp|123 " );
4252 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4255 n.setName( "B3RJ64" );
4256 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4259 n.setName( "sp|B3RJ64" );
4260 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4263 n.setName( "sp|B3RJ64C" );
4264 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4267 n.setName( "sp B3RJ64" );
4268 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4271 n.setName( "sp|B3RJ6X" );
4272 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4275 n.setName( "sp|B3RJ6" );
4276 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4279 n.setName( "K1PYK7_CRAGI" );
4280 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4283 n.setName( "K1PYK7_PEA" );
4284 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4287 n.setName( "K1PYK7_RAT" );
4288 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4291 n.setName( "K1PYK7_PIG" );
4292 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4295 n.setName( "~K1PYK7_PIG~" );
4296 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4299 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4300 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4303 n.setName( "K1PYKX_CRAGI" );
4304 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4307 n.setName( "XXXXX_CRAGI" );
4308 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4311 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4312 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4315 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4316 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4319 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4320 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4323 n = new PhylogenyNode();
4324 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4325 seq.setSymbol( "K1PYK7_CRAGI" );
4326 n.getNodeData().addSequence( seq );
4327 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4330 seq.setSymbol( "tr|B3RJ64" );
4331 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4334 n = new PhylogenyNode();
4335 seq = new org.forester.phylogeny.data.Sequence();
4336 seq.setName( "K1PYK7_CRAGI" );
4337 n.getNodeData().addSequence( seq );
4338 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4341 seq.setName( "tr|B3RJ64" );
4342 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4345 n = new PhylogenyNode();
4346 seq = new org.forester.phylogeny.data.Sequence();
4347 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4348 n.getNodeData().addSequence( seq );
4349 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4352 n = new PhylogenyNode();
4353 seq = new org.forester.phylogeny.data.Sequence();
4354 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4355 n.getNodeData().addSequence( seq );
4356 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4360 n = new PhylogenyNode();
4361 n.setName( "ACP19736" );
4362 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4365 n = new PhylogenyNode();
4366 n.setName( "|ACP19736|" );
4367 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4371 catch ( final Exception e ) {
4372 e.printStackTrace( System.out );
4378 private static boolean testFastaParser() {
4380 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4383 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4386 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4387 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4390 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4393 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4396 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4399 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4402 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4406 catch ( final Exception e ) {
4407 e.printStackTrace();
4413 private static boolean testGenbankAccessorParsing() {
4414 //The format for GenBank Accession numbers are:
4415 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4416 //Protein: 3 letters + 5 numerals
4417 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4418 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4421 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4424 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4427 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4430 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4433 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4436 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4439 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4442 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4445 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4448 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4451 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4454 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4457 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4463 private static boolean testGeneralMsaParser() {
4465 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4466 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4467 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4468 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4469 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4470 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4471 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4472 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4473 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4476 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4479 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4482 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4485 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4488 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4491 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4494 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4497 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4500 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4503 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4506 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4509 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4510 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4513 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4516 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4519 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4520 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4523 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4526 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4529 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4530 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4533 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4536 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4540 catch ( final Exception e ) {
4541 e.printStackTrace();
4547 private static boolean testGeneralTable() {
4549 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4550 t0.setValue( 3, 2, "23" );
4551 t0.setValue( 10, 1, "error" );
4552 t0.setValue( 10, 1, "110" );
4553 t0.setValue( 9, 1, "19" );
4554 t0.setValue( 1, 10, "101" );
4555 t0.setValue( 10, 10, "1010" );
4556 t0.setValue( 100, 10, "10100" );
4557 t0.setValue( 0, 0, "00" );
4558 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4561 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4564 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4567 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4570 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4573 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4576 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4579 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4582 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4585 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4586 t1.setValue( "3", "2", "23" );
4587 t1.setValue( "10", "1", "error" );
4588 t1.setValue( "10", "1", "110" );
4589 t1.setValue( "9", "1", "19" );
4590 t1.setValue( "1", "10", "101" );
4591 t1.setValue( "10", "10", "1010" );
4592 t1.setValue( "100", "10", "10100" );
4593 t1.setValue( "0", "0", "00" );
4594 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4595 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4598 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4601 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4604 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4607 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4610 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4613 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4616 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4619 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4622 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4626 catch ( final Exception e ) {
4627 e.printStackTrace( System.out );
4633 private static boolean testGetDistance() {
4635 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4636 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",
4637 new NHXParser() )[ 0 ];
4638 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4641 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4644 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4647 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4650 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4653 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4656 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4659 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4662 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4665 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4668 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4671 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4674 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4677 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4680 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4683 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4686 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4689 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4692 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4695 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4698 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4701 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4704 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4707 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4710 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4713 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4716 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4719 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4722 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4725 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4728 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4731 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",
4732 new NHXParser() )[ 0 ];
4733 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4736 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4739 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4742 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4745 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4748 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4751 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4754 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4757 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4760 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4763 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4767 catch ( final Exception e ) {
4768 e.printStackTrace( System.out );
4774 private static boolean testGetLCA() {
4776 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4777 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4778 new NHXParser() )[ 0 ];
4779 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4780 if ( !A.getName().equals( "A" ) ) {
4783 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4784 if ( !gh.getName().equals( "gh" ) ) {
4787 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4788 if ( !ab.getName().equals( "ab" ) ) {
4791 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4792 if ( !ab2.getName().equals( "ab" ) ) {
4795 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4796 if ( !gh2.getName().equals( "gh" ) ) {
4799 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4800 if ( !gh3.getName().equals( "gh" ) ) {
4803 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4804 if ( !abc.getName().equals( "abc" ) ) {
4807 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4808 if ( !abc2.getName().equals( "abc" ) ) {
4811 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4812 if ( !abcd.getName().equals( "abcd" ) ) {
4815 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4816 if ( !abcd2.getName().equals( "abcd" ) ) {
4819 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4820 if ( !abcdef.getName().equals( "abcdef" ) ) {
4823 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4824 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4827 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4828 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4831 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4832 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4835 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4836 if ( !abcde.getName().equals( "abcde" ) ) {
4839 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4840 if ( !abcde2.getName().equals( "abcde" ) ) {
4843 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4844 if ( !r.getName().equals( "abcdefgh" ) ) {
4847 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4848 if ( !r2.getName().equals( "abcdefgh" ) ) {
4851 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4852 if ( !r3.getName().equals( "abcdefgh" ) ) {
4855 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4856 if ( !abcde3.getName().equals( "abcde" ) ) {
4859 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4860 if ( !abcde4.getName().equals( "abcde" ) ) {
4863 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4864 if ( !ab3.getName().equals( "ab" ) ) {
4867 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4868 if ( !ab4.getName().equals( "ab" ) ) {
4871 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4872 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4873 if ( !cd.getName().equals( "cd" ) ) {
4876 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4877 if ( !cd2.getName().equals( "cd" ) ) {
4880 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4881 if ( !cde.getName().equals( "cde" ) ) {
4884 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4885 if ( !cde2.getName().equals( "cde" ) ) {
4888 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4889 if ( !cdef.getName().equals( "cdef" ) ) {
4892 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4893 if ( !cdef2.getName().equals( "cdef" ) ) {
4896 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4897 if ( !cdef3.getName().equals( "cdef" ) ) {
4900 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4901 if ( !rt.getName().equals( "r" ) ) {
4904 final Phylogeny p3 = factory
4905 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4906 new NHXParser() )[ 0 ];
4907 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4908 if ( !bc_3.getName().equals( "bc" ) ) {
4911 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4912 if ( !ac_3.getName().equals( "abc" ) ) {
4915 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4916 if ( !ad_3.getName().equals( "abcde" ) ) {
4919 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4920 if ( !af_3.getName().equals( "abcdef" ) ) {
4923 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4924 if ( !ag_3.getName().equals( "" ) ) {
4927 if ( !ag_3.isRoot() ) {
4930 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4931 if ( !al_3.getName().equals( "" ) ) {
4934 if ( !al_3.isRoot() ) {
4937 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4938 if ( !kl_3.getName().equals( "" ) ) {
4941 if ( !kl_3.isRoot() ) {
4944 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4945 if ( !fl_3.getName().equals( "" ) ) {
4948 if ( !fl_3.isRoot() ) {
4951 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4952 if ( !gk_3.getName().equals( "ghijk" ) ) {
4955 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4956 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4957 if ( !r_4.getName().equals( "r" ) ) {
4960 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4961 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4962 if ( !r_5.getName().equals( "root" ) ) {
4965 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4966 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4967 if ( !r_6.getName().equals( "rot" ) ) {
4970 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4971 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4972 if ( !r_7.getName().equals( "rott" ) ) {
4976 catch ( final Exception e ) {
4977 e.printStackTrace( System.out );
4983 private static boolean testGetLCA2() {
4985 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4986 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4987 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
4988 PhylogenyMethods.preOrderReId( p_a );
4989 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4990 p_a.getNode( "a" ) );
4991 if ( !p_a_1.getName().equals( "a" ) ) {
4994 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
4995 PhylogenyMethods.preOrderReId( p_b );
4996 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4997 p_b.getNode( "a" ) );
4998 if ( !p_b_1.getName().equals( "b" ) ) {
5001 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5002 p_b.getNode( "b" ) );
5003 if ( !p_b_2.getName().equals( "b" ) ) {
5006 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5007 PhylogenyMethods.preOrderReId( p_c );
5008 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5009 p_c.getNode( "a" ) );
5010 if ( !p_c_1.getName().equals( "b" ) ) {
5013 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5014 p_c.getNode( "c" ) );
5015 if ( !p_c_2.getName().equals( "c" ) ) {
5016 System.out.println( p_c_2.getName() );
5020 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5021 p_c.getNode( "b" ) );
5022 if ( !p_c_3.getName().equals( "b" ) ) {
5025 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5026 p_c.getNode( "a" ) );
5027 if ( !p_c_4.getName().equals( "c" ) ) {
5030 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5031 new NHXParser() )[ 0 ];
5032 PhylogenyMethods.preOrderReId( p1 );
5033 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5034 p1.getNode( "A" ) );
5035 if ( !A.getName().equals( "A" ) ) {
5038 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5039 p1.getNode( "gh" ) );
5040 if ( !gh.getName().equals( "gh" ) ) {
5043 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5044 p1.getNode( "B" ) );
5045 if ( !ab.getName().equals( "ab" ) ) {
5048 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5049 p1.getNode( "A" ) );
5050 if ( !ab2.getName().equals( "ab" ) ) {
5053 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5054 p1.getNode( "G" ) );
5055 if ( !gh2.getName().equals( "gh" ) ) {
5058 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5059 p1.getNode( "H" ) );
5060 if ( !gh3.getName().equals( "gh" ) ) {
5063 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5064 p1.getNode( "A" ) );
5065 if ( !abc.getName().equals( "abc" ) ) {
5068 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5069 p1.getNode( "C" ) );
5070 if ( !abc2.getName().equals( "abc" ) ) {
5073 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5074 p1.getNode( "D" ) );
5075 if ( !abcd.getName().equals( "abcd" ) ) {
5078 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5079 p1.getNode( "A" ) );
5080 if ( !abcd2.getName().equals( "abcd" ) ) {
5083 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5084 p1.getNode( "F" ) );
5085 if ( !abcdef.getName().equals( "abcdef" ) ) {
5088 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5089 p1.getNode( "A" ) );
5090 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5093 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5094 p1.getNode( "F" ) );
5095 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5098 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5099 p1.getNode( "ab" ) );
5100 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5103 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5104 p1.getNode( "E" ) );
5105 if ( !abcde.getName().equals( "abcde" ) ) {
5108 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5109 p1.getNode( "A" ) );
5110 if ( !abcde2.getName().equals( "abcde" ) ) {
5113 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5114 p1.getNode( "abcdefgh" ) );
5115 if ( !r.getName().equals( "abcdefgh" ) ) {
5118 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5119 p1.getNode( "H" ) );
5120 if ( !r2.getName().equals( "abcdefgh" ) ) {
5123 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5124 p1.getNode( "A" ) );
5125 if ( !r3.getName().equals( "abcdefgh" ) ) {
5128 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5129 p1.getNode( "abcde" ) );
5130 if ( !abcde3.getName().equals( "abcde" ) ) {
5133 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5134 p1.getNode( "E" ) );
5135 if ( !abcde4.getName().equals( "abcde" ) ) {
5138 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5139 p1.getNode( "B" ) );
5140 if ( !ab3.getName().equals( "ab" ) ) {
5143 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5144 p1.getNode( "ab" ) );
5145 if ( !ab4.getName().equals( "ab" ) ) {
5148 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5149 PhylogenyMethods.preOrderReId( p2 );
5150 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5151 p2.getNode( "d" ) );
5152 if ( !cd.getName().equals( "cd" ) ) {
5155 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5156 p2.getNode( "c" ) );
5157 if ( !cd2.getName().equals( "cd" ) ) {
5160 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5161 p2.getNode( "e" ) );
5162 if ( !cde.getName().equals( "cde" ) ) {
5165 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5166 p2.getNode( "c" ) );
5167 if ( !cde2.getName().equals( "cde" ) ) {
5170 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5171 p2.getNode( "f" ) );
5172 if ( !cdef.getName().equals( "cdef" ) ) {
5175 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5176 p2.getNode( "f" ) );
5177 if ( !cdef2.getName().equals( "cdef" ) ) {
5180 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5181 p2.getNode( "d" ) );
5182 if ( !cdef3.getName().equals( "cdef" ) ) {
5185 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5186 p2.getNode( "a" ) );
5187 if ( !rt.getName().equals( "r" ) ) {
5190 final Phylogeny p3 = factory
5191 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5192 new NHXParser() )[ 0 ];
5193 PhylogenyMethods.preOrderReId( p3 );
5194 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5195 p3.getNode( "c" ) );
5196 if ( !bc_3.getName().equals( "bc" ) ) {
5199 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5200 p3.getNode( "c" ) );
5201 if ( !ac_3.getName().equals( "abc" ) ) {
5204 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5205 p3.getNode( "d" ) );
5206 if ( !ad_3.getName().equals( "abcde" ) ) {
5209 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5210 p3.getNode( "f" ) );
5211 if ( !af_3.getName().equals( "abcdef" ) ) {
5214 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5215 p3.getNode( "g" ) );
5216 if ( !ag_3.getName().equals( "" ) ) {
5219 if ( !ag_3.isRoot() ) {
5222 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5223 p3.getNode( "l" ) );
5224 if ( !al_3.getName().equals( "" ) ) {
5227 if ( !al_3.isRoot() ) {
5230 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5231 p3.getNode( "l" ) );
5232 if ( !kl_3.getName().equals( "" ) ) {
5235 if ( !kl_3.isRoot() ) {
5238 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5239 p3.getNode( "l" ) );
5240 if ( !fl_3.getName().equals( "" ) ) {
5243 if ( !fl_3.isRoot() ) {
5246 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5247 p3.getNode( "k" ) );
5248 if ( !gk_3.getName().equals( "ghijk" ) ) {
5251 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5252 PhylogenyMethods.preOrderReId( p4 );
5253 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5254 p4.getNode( "c" ) );
5255 if ( !r_4.getName().equals( "r" ) ) {
5258 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5259 PhylogenyMethods.preOrderReId( p5 );
5260 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5261 p5.getNode( "c" ) );
5262 if ( !r_5.getName().equals( "root" ) ) {
5265 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5266 PhylogenyMethods.preOrderReId( p6 );
5267 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5268 p6.getNode( "a" ) );
5269 if ( !r_6.getName().equals( "rot" ) ) {
5272 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5273 PhylogenyMethods.preOrderReId( p7 );
5274 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5275 p7.getNode( "e" ) );
5276 if ( !r_7.getName().equals( "rott" ) ) {
5279 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5280 p7.getNode( "a" ) );
5281 if ( !r_71.getName().equals( "rott" ) ) {
5284 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5285 p7.getNode( "rott" ) );
5286 if ( !r_72.getName().equals( "rott" ) ) {
5289 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5290 p7.getNode( "a" ) );
5291 if ( !r_73.getName().equals( "rott" ) ) {
5294 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5295 p7.getNode( "rott" ) );
5296 if ( !r_74.getName().equals( "rott" ) ) {
5299 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5300 p7.getNode( "e" ) );
5301 if ( !r_75.getName().equals( "e" ) ) {
5305 catch ( final Exception e ) {
5306 e.printStackTrace( System.out );
5312 private static boolean testHmmscanOutputParser() {
5313 final String test_dir = Test.PATH_TO_TEST_DATA;
5315 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5316 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5318 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5319 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5320 final List<Protein> proteins = parser2.parse();
5321 if ( parser2.getProteinsEncountered() != 4 ) {
5324 if ( proteins.size() != 4 ) {
5327 if ( parser2.getDomainsEncountered() != 69 ) {
5330 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5333 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5336 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5339 final Protein p1 = proteins.get( 0 );
5340 if ( p1.getNumberOfProteinDomains() != 15 ) {
5343 if ( p1.getLength() != 850 ) {
5346 final Protein p2 = proteins.get( 1 );
5347 if ( p2.getNumberOfProteinDomains() != 51 ) {
5350 if ( p2.getLength() != 1291 ) {
5353 final Protein p3 = proteins.get( 2 );
5354 if ( p3.getNumberOfProteinDomains() != 2 ) {
5357 final Protein p4 = proteins.get( 3 );
5358 if ( p4.getNumberOfProteinDomains() != 1 ) {
5361 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5364 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5367 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5370 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5373 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5376 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5379 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5383 catch ( final Exception e ) {
5384 e.printStackTrace( System.out );
5390 private static boolean testLastExternalNodeMethods() {
5392 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5393 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5394 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5395 final PhylogenyNode n1 = t0.getNode( "A" );
5396 if ( n1.isLastExternalNode() ) {
5399 final PhylogenyNode n2 = t0.getNode( "B" );
5400 if ( n2.isLastExternalNode() ) {
5403 final PhylogenyNode n3 = t0.getNode( "C" );
5404 if ( n3.isLastExternalNode() ) {
5407 final PhylogenyNode n4 = t0.getNode( "D" );
5408 if ( !n4.isLastExternalNode() ) {
5412 catch ( final Exception e ) {
5413 e.printStackTrace( System.out );
5419 private static boolean testLevelOrderIterator() {
5421 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5422 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5423 PhylogenyNodeIterator it0;
5424 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5427 for( it0.reset(); it0.hasNext(); ) {
5430 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5431 if ( !it.next().getName().equals( "r" ) ) {
5434 if ( !it.next().getName().equals( "ab" ) ) {
5437 if ( !it.next().getName().equals( "cd" ) ) {
5440 if ( !it.next().getName().equals( "A" ) ) {
5443 if ( !it.next().getName().equals( "B" ) ) {
5446 if ( !it.next().getName().equals( "C" ) ) {
5449 if ( !it.next().getName().equals( "D" ) ) {
5452 if ( it.hasNext() ) {
5455 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",
5456 new NHXParser() )[ 0 ];
5457 PhylogenyNodeIterator it2;
5458 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5461 for( it2.reset(); it2.hasNext(); ) {
5464 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5465 if ( !it3.next().getName().equals( "r" ) ) {
5468 if ( !it3.next().getName().equals( "abc" ) ) {
5471 if ( !it3.next().getName().equals( "defg" ) ) {
5474 if ( !it3.next().getName().equals( "A" ) ) {
5477 if ( !it3.next().getName().equals( "B" ) ) {
5480 if ( !it3.next().getName().equals( "C" ) ) {
5483 if ( !it3.next().getName().equals( "D" ) ) {
5486 if ( !it3.next().getName().equals( "E" ) ) {
5489 if ( !it3.next().getName().equals( "F" ) ) {
5492 if ( !it3.next().getName().equals( "G" ) ) {
5495 if ( !it3.next().getName().equals( "1" ) ) {
5498 if ( !it3.next().getName().equals( "2" ) ) {
5501 if ( !it3.next().getName().equals( "3" ) ) {
5504 if ( !it3.next().getName().equals( "4" ) ) {
5507 if ( !it3.next().getName().equals( "5" ) ) {
5510 if ( !it3.next().getName().equals( "6" ) ) {
5513 if ( !it3.next().getName().equals( "f1" ) ) {
5516 if ( !it3.next().getName().equals( "f2" ) ) {
5519 if ( !it3.next().getName().equals( "f3" ) ) {
5522 if ( !it3.next().getName().equals( "a" ) ) {
5525 if ( !it3.next().getName().equals( "b" ) ) {
5528 if ( !it3.next().getName().equals( "f21" ) ) {
5531 if ( !it3.next().getName().equals( "X" ) ) {
5534 if ( !it3.next().getName().equals( "Y" ) ) {
5537 if ( !it3.next().getName().equals( "Z" ) ) {
5540 if ( it3.hasNext() ) {
5543 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5544 PhylogenyNodeIterator it4;
5545 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5548 for( it4.reset(); it4.hasNext(); ) {
5551 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5552 if ( !it5.next().getName().equals( "r" ) ) {
5555 if ( !it5.next().getName().equals( "A" ) ) {
5558 if ( !it5.next().getName().equals( "B" ) ) {
5561 if ( !it5.next().getName().equals( "C" ) ) {
5564 if ( !it5.next().getName().equals( "D" ) ) {
5567 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5568 PhylogenyNodeIterator it6;
5569 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5572 for( it6.reset(); it6.hasNext(); ) {
5575 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5576 if ( !it7.next().getName().equals( "A" ) ) {
5579 if ( it.hasNext() ) {
5583 catch ( final Exception e ) {
5584 e.printStackTrace( System.out );
5590 private static boolean testMafft( final String path ) {
5592 final List<String> opts = new ArrayList<String>();
5593 opts.add( "--maxiterate" );
5595 opts.add( "--localpair" );
5596 opts.add( "--quiet" );
5598 final MsaInferrer mafft = Mafft.createInstance( path );
5599 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5600 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5603 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5607 catch ( final Exception e ) {
5608 e.printStackTrace( System.out );
5614 private static boolean testMidpointrooting() {
5616 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5617 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5618 PhylogenyMethods.midpointRoot( t0 );
5619 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5622 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5625 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5629 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",
5630 new NHXParser() )[ 0 ];
5631 if ( !t1.isRooted() ) {
5634 PhylogenyMethods.midpointRoot( t1 );
5635 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5638 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5641 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5644 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5647 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5650 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5653 t1.reRoot( t1.getNode( "A" ) );
5654 PhylogenyMethods.midpointRoot( t1 );
5655 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5658 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5661 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5664 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5667 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5671 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5675 catch ( final Exception e ) {
5676 e.printStackTrace( System.out );
5682 private static boolean testMsaQualityMethod() {
5684 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5685 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5686 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5687 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5688 final List<Sequence> l = new ArrayList<Sequence>();
5693 final Msa msa = BasicMsa.createInstance( l );
5694 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5697 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5700 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5703 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5707 catch ( final Exception e ) {
5708 e.printStackTrace( System.out );
5714 private static boolean testNextNodeWithCollapsing() {
5716 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5718 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5719 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5720 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5721 t0.getNode( "cd" ).setCollapse( true );
5722 t0.getNode( "cde" ).setCollapse( true );
5723 n = t0.getFirstExternalNode();
5724 while ( n != null ) {
5726 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5728 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5731 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5734 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5737 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5740 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5743 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5747 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5748 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5749 t1.getNode( "ab" ).setCollapse( true );
5750 t1.getNode( "cd" ).setCollapse( true );
5751 t1.getNode( "cde" ).setCollapse( true );
5752 n = t1.getNode( "ab" );
5753 ext = new ArrayList<PhylogenyNode>();
5754 while ( n != null ) {
5756 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5758 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5761 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5764 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5767 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5770 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5776 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5777 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5778 t2.getNode( "ab" ).setCollapse( true );
5779 t2.getNode( "cd" ).setCollapse( true );
5780 t2.getNode( "cde" ).setCollapse( true );
5781 t2.getNode( "c" ).setCollapse( true );
5782 t2.getNode( "d" ).setCollapse( true );
5783 t2.getNode( "e" ).setCollapse( true );
5784 t2.getNode( "gh" ).setCollapse( true );
5785 n = t2.getNode( "ab" );
5786 ext = new ArrayList<PhylogenyNode>();
5787 while ( n != null ) {
5789 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5791 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5794 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5797 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5800 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5806 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5807 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5808 t3.getNode( "ab" ).setCollapse( true );
5809 t3.getNode( "cd" ).setCollapse( true );
5810 t3.getNode( "cde" ).setCollapse( true );
5811 t3.getNode( "c" ).setCollapse( true );
5812 t3.getNode( "d" ).setCollapse( true );
5813 t3.getNode( "e" ).setCollapse( true );
5814 t3.getNode( "gh" ).setCollapse( true );
5815 t3.getNode( "fgh" ).setCollapse( true );
5816 n = t3.getNode( "ab" );
5817 ext = new ArrayList<PhylogenyNode>();
5818 while ( n != null ) {
5820 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5822 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5825 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5828 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5834 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5835 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5836 t4.getNode( "ab" ).setCollapse( true );
5837 t4.getNode( "cd" ).setCollapse( true );
5838 t4.getNode( "cde" ).setCollapse( true );
5839 t4.getNode( "c" ).setCollapse( true );
5840 t4.getNode( "d" ).setCollapse( true );
5841 t4.getNode( "e" ).setCollapse( true );
5842 t4.getNode( "gh" ).setCollapse( true );
5843 t4.getNode( "fgh" ).setCollapse( true );
5844 t4.getNode( "abcdefgh" ).setCollapse( true );
5845 n = t4.getNode( "abcdefgh" );
5846 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5851 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5852 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5854 n = t5.getFirstExternalNode();
5855 while ( n != null ) {
5857 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5859 if ( ext.size() != 8 ) {
5862 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5865 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5868 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5871 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5874 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5877 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5880 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5883 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5888 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5889 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5891 t6.getNode( "ab" ).setCollapse( true );
5892 n = t6.getNode( "ab" );
5893 while ( n != null ) {
5895 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5897 if ( ext.size() != 7 ) {
5900 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5903 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5906 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5909 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5912 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5915 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5918 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5923 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5924 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5926 t7.getNode( "cd" ).setCollapse( true );
5927 n = t7.getNode( "a" );
5928 while ( n != null ) {
5930 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5932 if ( ext.size() != 7 ) {
5935 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5938 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5941 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5944 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5947 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5950 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5953 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5958 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5959 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5961 t8.getNode( "cd" ).setCollapse( true );
5962 t8.getNode( "c" ).setCollapse( true );
5963 t8.getNode( "d" ).setCollapse( true );
5964 n = t8.getNode( "a" );
5965 while ( n != null ) {
5967 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5969 if ( ext.size() != 7 ) {
5972 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5975 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5978 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5979 System.out.println( "2 fail" );
5982 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5985 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5988 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5991 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5996 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5997 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5999 t9.getNode( "gh" ).setCollapse( true );
6000 n = t9.getNode( "a" );
6001 while ( n != null ) {
6003 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6005 if ( ext.size() != 7 ) {
6008 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6011 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6014 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6017 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6020 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6023 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6026 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6031 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6032 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6034 t10.getNode( "gh" ).setCollapse( true );
6035 t10.getNode( "g" ).setCollapse( true );
6036 t10.getNode( "h" ).setCollapse( true );
6037 n = t10.getNode( "a" );
6038 while ( n != null ) {
6040 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6042 if ( ext.size() != 7 ) {
6045 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6048 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6051 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6054 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6057 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6060 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6063 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6068 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6069 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6071 t11.getNode( "gh" ).setCollapse( true );
6072 t11.getNode( "fgh" ).setCollapse( true );
6073 n = t11.getNode( "a" );
6074 while ( n != null ) {
6076 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6078 if ( ext.size() != 6 ) {
6081 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6084 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6087 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6090 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6093 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6096 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6101 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6102 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6104 t12.getNode( "gh" ).setCollapse( true );
6105 t12.getNode( "fgh" ).setCollapse( true );
6106 t12.getNode( "g" ).setCollapse( true );
6107 t12.getNode( "h" ).setCollapse( true );
6108 t12.getNode( "f" ).setCollapse( true );
6109 n = t12.getNode( "a" );
6110 while ( n != null ) {
6112 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6114 if ( ext.size() != 6 ) {
6117 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6120 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6123 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6126 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6129 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6132 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6137 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6138 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6140 t13.getNode( "ab" ).setCollapse( true );
6141 t13.getNode( "b" ).setCollapse( true );
6142 t13.getNode( "fgh" ).setCollapse( true );
6143 t13.getNode( "gh" ).setCollapse( true );
6144 n = t13.getNode( "ab" );
6145 while ( n != null ) {
6147 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6149 if ( ext.size() != 5 ) {
6152 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6155 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6158 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6161 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6164 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6169 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6170 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6172 t14.getNode( "ab" ).setCollapse( true );
6173 t14.getNode( "a" ).setCollapse( true );
6174 t14.getNode( "fgh" ).setCollapse( true );
6175 t14.getNode( "gh" ).setCollapse( true );
6176 n = t14.getNode( "ab" );
6177 while ( n != null ) {
6179 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6181 if ( ext.size() != 5 ) {
6184 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6187 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6190 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6193 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6196 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6201 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" );
6202 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6204 t15.getNode( "ab" ).setCollapse( true );
6205 t15.getNode( "a" ).setCollapse( true );
6206 t15.getNode( "fgh" ).setCollapse( true );
6207 t15.getNode( "gh" ).setCollapse( true );
6208 n = t15.getNode( "ab" );
6209 while ( n != null ) {
6211 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6213 if ( ext.size() != 6 ) {
6216 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6219 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6222 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6225 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6228 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6231 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6236 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" );
6237 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6239 t16.getNode( "ab" ).setCollapse( true );
6240 t16.getNode( "a" ).setCollapse( true );
6241 t16.getNode( "fgh" ).setCollapse( true );
6242 t16.getNode( "gh" ).setCollapse( true );
6243 t16.getNode( "cd" ).setCollapse( true );
6244 t16.getNode( "cde" ).setCollapse( true );
6245 t16.getNode( "d" ).setCollapse( true );
6246 t16.getNode( "x" ).setCollapse( true );
6247 n = t16.getNode( "ab" );
6248 while ( n != null ) {
6250 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6252 if ( ext.size() != 4 ) {
6255 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6258 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6261 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6264 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6268 catch ( final Exception e ) {
6269 e.printStackTrace( System.out );
6275 private static boolean testNexusCharactersParsing() {
6277 final NexusCharactersParser parser = new NexusCharactersParser();
6278 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6280 String[] labels = parser.getCharStateLabels();
6281 if ( labels.length != 7 ) {
6284 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6287 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6290 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6293 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6296 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6299 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6302 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6305 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6307 labels = parser.getCharStateLabels();
6308 if ( labels.length != 7 ) {
6311 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6314 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6317 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6320 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6323 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6326 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6329 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6333 catch ( final Exception e ) {
6334 e.printStackTrace( System.out );
6340 private static boolean testNexusMatrixParsing() {
6342 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6343 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6345 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6346 if ( m.getNumberOfCharacters() != 9 ) {
6349 if ( m.getNumberOfIdentifiers() != 5 ) {
6352 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6355 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6358 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6361 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6364 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6367 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6370 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6373 // if ( labels.length != 7 ) {
6376 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6379 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6382 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6385 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6388 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6391 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6394 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6397 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6399 // labels = parser.getCharStateLabels();
6400 // if ( labels.length != 7 ) {
6403 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6406 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6409 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6412 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6415 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6418 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6421 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6425 catch ( final Exception e ) {
6426 e.printStackTrace( System.out );
6432 private static boolean testNexusTreeParsing() {
6434 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6435 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6436 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6437 if ( phylogenies.length != 1 ) {
6440 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6443 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6447 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6448 if ( phylogenies.length != 1 ) {
6451 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6454 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6458 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6459 if ( phylogenies.length != 1 ) {
6462 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6465 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6468 if ( phylogenies[ 0 ].isRooted() ) {
6472 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6473 if ( phylogenies.length != 18 ) {
6476 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6479 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6482 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6485 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6488 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6491 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6494 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6497 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6500 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6503 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6506 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6509 if ( phylogenies[ 8 ].isRooted() ) {
6512 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6515 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6518 if ( !phylogenies[ 9 ].isRooted() ) {
6521 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6524 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6527 if ( !phylogenies[ 10 ].isRooted() ) {
6530 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6533 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6536 if ( phylogenies[ 11 ].isRooted() ) {
6539 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6542 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6545 if ( !phylogenies[ 12 ].isRooted() ) {
6548 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6551 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6554 if ( !phylogenies[ 13 ].isRooted() ) {
6557 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6560 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6563 if ( !phylogenies[ 14 ].isRooted() ) {
6566 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6569 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6572 if ( phylogenies[ 15 ].isRooted() ) {
6575 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6578 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6581 if ( !phylogenies[ 16 ].isRooted() ) {
6584 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6587 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6590 if ( phylogenies[ 17 ].isRooted() ) {
6593 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6597 catch ( final Exception e ) {
6598 e.printStackTrace( System.out );
6604 private static boolean testNexusTreeParsingIterating() {
6606 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6607 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6608 if ( !p.hasNext() ) {
6611 Phylogeny phy = p.next();
6612 if ( phy == null ) {
6615 if ( phy.getNumberOfExternalNodes() != 25 ) {
6618 if ( !phy.getName().equals( "" ) ) {
6621 if ( p.hasNext() ) {
6625 if ( phy != null ) {
6630 if ( !p.hasNext() ) {
6634 if ( phy == null ) {
6637 if ( phy.getNumberOfExternalNodes() != 25 ) {
6640 if ( !phy.getName().equals( "" ) ) {
6643 if ( p.hasNext() ) {
6647 if ( phy != null ) {
6651 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6652 if ( !p.hasNext() ) {
6656 if ( phy == null ) {
6659 if ( phy.getNumberOfExternalNodes() != 10 ) {
6662 if ( !phy.getName().equals( "name" ) ) {
6665 if ( p.hasNext() ) {
6669 if ( phy != null ) {
6674 if ( !p.hasNext() ) {
6678 if ( phy == null ) {
6681 if ( phy.getNumberOfExternalNodes() != 10 ) {
6684 if ( !phy.getName().equals( "name" ) ) {
6687 if ( p.hasNext() ) {
6691 if ( phy != null ) {
6695 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6696 if ( !p.hasNext() ) {
6700 if ( phy == null ) {
6703 if ( phy.getNumberOfExternalNodes() != 3 ) {
6706 if ( !phy.getName().equals( "" ) ) {
6709 if ( phy.isRooted() ) {
6712 if ( p.hasNext() ) {
6716 if ( phy != null ) {
6721 if ( !p.hasNext() ) {
6725 if ( phy == null ) {
6728 if ( phy.getNumberOfExternalNodes() != 3 ) {
6731 if ( !phy.getName().equals( "" ) ) {
6734 if ( p.hasNext() ) {
6738 if ( phy != null ) {
6742 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6743 // if ( phylogenies.length != 18 ) {
6747 if ( !p.hasNext() ) {
6751 if ( phy == null ) {
6754 if ( phy.getNumberOfExternalNodes() != 10 ) {
6757 if ( !phy.getName().equals( "tree 0" ) ) {
6761 if ( !p.hasNext() ) {
6765 if ( phy == null ) {
6768 if ( phy.getNumberOfExternalNodes() != 10 ) {
6771 if ( !phy.getName().equals( "tree 1" ) ) {
6775 if ( !p.hasNext() ) {
6779 if ( phy == null ) {
6782 if ( phy.getNumberOfExternalNodes() != 3 ) {
6785 if ( !phy.getName().equals( "" ) ) {
6788 if ( phy.isRooted() ) {
6792 if ( !p.hasNext() ) {
6796 if ( phy == null ) {
6799 if ( phy.getNumberOfExternalNodes() != 4 ) {
6802 if ( !phy.getName().equals( "" ) ) {
6805 if ( !phy.isRooted() ) {
6809 if ( !p.hasNext() ) {
6813 if ( phy == null ) {
6816 if ( phy.getNumberOfExternalNodes() != 5 ) {
6817 System.out.println( phy.getNumberOfExternalNodes() );
6820 if ( !phy.getName().equals( "" ) ) {
6823 if ( !phy.isRooted() ) {
6827 if ( !p.hasNext() ) {
6831 if ( phy == null ) {
6834 if ( phy.getNumberOfExternalNodes() != 3 ) {
6837 if ( !phy.getName().equals( "" ) ) {
6840 if ( phy.isRooted() ) {
6844 if ( !p.hasNext() ) {
6848 if ( phy == null ) {
6851 if ( phy.getNumberOfExternalNodes() != 2 ) {
6854 if ( !phy.getName().equals( "" ) ) {
6857 if ( !phy.isRooted() ) {
6861 if ( !p.hasNext() ) {
6865 if ( phy.getNumberOfExternalNodes() != 3 ) {
6868 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6871 if ( !phy.isRooted() ) {
6875 if ( !p.hasNext() ) {
6879 if ( phy.getNumberOfExternalNodes() != 3 ) {
6882 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6885 if ( !phy.getName().equals( "tree 8" ) ) {
6889 if ( !p.hasNext() ) {
6893 if ( phy.getNumberOfExternalNodes() != 3 ) {
6896 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6899 if ( !phy.getName().equals( "tree 9" ) ) {
6903 if ( !p.hasNext() ) {
6907 if ( phy.getNumberOfExternalNodes() != 3 ) {
6910 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6913 if ( !phy.getName().equals( "tree 10" ) ) {
6916 if ( !phy.isRooted() ) {
6920 if ( !p.hasNext() ) {
6924 if ( phy.getNumberOfExternalNodes() != 3 ) {
6927 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6930 if ( !phy.getName().equals( "tree 11" ) ) {
6933 if ( phy.isRooted() ) {
6937 if ( !p.hasNext() ) {
6941 if ( phy.getNumberOfExternalNodes() != 3 ) {
6944 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6947 if ( !phy.getName().equals( "tree 12" ) ) {
6950 if ( !phy.isRooted() ) {
6954 if ( !p.hasNext() ) {
6958 if ( phy.getNumberOfExternalNodes() != 3 ) {
6961 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6964 if ( !phy.getName().equals( "tree 13" ) ) {
6967 if ( !phy.isRooted() ) {
6971 if ( !p.hasNext() ) {
6975 if ( phy.getNumberOfExternalNodes() != 10 ) {
6976 System.out.println( phy.getNumberOfExternalNodes() );
6981 .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;" ) ) {
6982 System.out.println( phy.toNewHampshire() );
6985 if ( !phy.getName().equals( "tree 14" ) ) {
6988 if ( !phy.isRooted() ) {
6992 if ( !p.hasNext() ) {
6996 if ( phy.getNumberOfExternalNodes() != 10 ) {
6997 System.out.println( phy.getNumberOfExternalNodes() );
7002 .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;" ) ) {
7003 System.out.println( phy.toNewHampshire() );
7006 if ( !phy.getName().equals( "tree 15" ) ) {
7009 if ( phy.isRooted() ) {
7013 if ( !p.hasNext() ) {
7017 if ( phy.getNumberOfExternalNodes() != 10 ) {
7018 System.out.println( phy.getNumberOfExternalNodes() );
7023 .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;" ) ) {
7024 System.out.println( phy.toNewHampshire() );
7027 if ( !phy.getName().equals( "tree 16" ) ) {
7030 if ( !phy.isRooted() ) {
7034 if ( !p.hasNext() ) {
7038 if ( phy.getNumberOfExternalNodes() != 10 ) {
7039 System.out.println( phy.getNumberOfExternalNodes() );
7044 .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;" ) ) {
7045 System.out.println( phy.toNewHampshire() );
7048 if ( !phy.getName().equals( "tree 17" ) ) {
7051 if ( phy.isRooted() ) {
7055 if ( p.hasNext() ) {
7059 if ( phy != null ) {
7064 if ( !p.hasNext() ) {
7068 if ( phy == null ) {
7071 if ( phy.getNumberOfExternalNodes() != 10 ) {
7074 if ( !phy.getName().equals( "tree 0" ) ) {
7078 if ( !p.hasNext() ) {
7082 if ( phy == null ) {
7085 if ( phy.getNumberOfExternalNodes() != 10 ) {
7088 if ( !phy.getName().equals( "tree 1" ) ) {
7092 if ( !p.hasNext() ) {
7096 if ( phy == null ) {
7099 if ( phy.getNumberOfExternalNodes() != 3 ) {
7102 if ( !phy.getName().equals( "" ) ) {
7105 if ( phy.isRooted() ) {
7109 if ( !p.hasNext() ) {
7113 if ( phy == null ) {
7116 if ( phy.getNumberOfExternalNodes() != 4 ) {
7119 if ( !phy.getName().equals( "" ) ) {
7122 if ( !phy.isRooted() ) {
7126 if ( !p.hasNext() ) {
7130 if ( phy == null ) {
7133 if ( phy.getNumberOfExternalNodes() != 5 ) {
7134 System.out.println( phy.getNumberOfExternalNodes() );
7137 if ( !phy.getName().equals( "" ) ) {
7140 if ( !phy.isRooted() ) {
7144 if ( !p.hasNext() ) {
7148 if ( phy == null ) {
7151 if ( phy.getNumberOfExternalNodes() != 3 ) {
7154 if ( !phy.getName().equals( "" ) ) {
7157 if ( phy.isRooted() ) {
7161 catch ( final Exception e ) {
7162 e.printStackTrace( System.out );
7168 private static boolean testNexusTreeParsingTranslating() {
7170 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7171 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7172 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7173 if ( phylogenies.length != 1 ) {
7176 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7179 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7182 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7185 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7188 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7189 .equals( "Aranaeus" ) ) {
7193 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7194 if ( phylogenies.length != 3 ) {
7197 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7200 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7203 if ( phylogenies[ 0 ].isRooted() ) {
7206 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7209 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7212 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7213 .equals( "Aranaeus" ) ) {
7216 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7219 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7222 if ( phylogenies[ 1 ].isRooted() ) {
7225 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7228 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7231 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7232 .equals( "Aranaeus" ) ) {
7235 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7238 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7241 if ( !phylogenies[ 2 ].isRooted() ) {
7244 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7247 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7250 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7251 .equals( "Aranaeus" ) ) {
7255 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7256 if ( phylogenies.length != 3 ) {
7259 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7262 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7265 if ( phylogenies[ 0 ].isRooted() ) {
7268 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7271 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7274 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7275 .equals( "Aranaeus" ) ) {
7278 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7281 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7284 if ( phylogenies[ 1 ].isRooted() ) {
7287 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7290 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7293 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7294 .equals( "Aranaeus" ) ) {
7297 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7300 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7303 if ( !phylogenies[ 2 ].isRooted() ) {
7306 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7309 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7312 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7313 .equals( "Aranaeus" ) ) {
7317 catch ( final Exception e ) {
7318 e.printStackTrace( System.out );
7324 private static boolean testNHParsing() {
7326 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7327 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7328 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7331 final NHXParser nhxp = new NHXParser();
7332 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7333 nhxp.setReplaceUnderscores( true );
7334 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7335 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7338 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7341 final Phylogeny p1b = factory
7342 .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 ",
7343 new NHXParser() )[ 0 ];
7344 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7347 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7350 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7351 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7352 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7353 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7354 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7355 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7356 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7357 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7358 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7359 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7360 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7361 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7362 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7364 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7367 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7370 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7373 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7376 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7377 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7378 final String p16_S = "((A,B),C)";
7379 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7380 if ( p16.length != 1 ) {
7383 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7386 final String p17_S = "(C,(A,B))";
7387 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7388 if ( p17.length != 1 ) {
7391 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7394 final String p18_S = "((A,B),(C,D))";
7395 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7396 if ( p18.length != 1 ) {
7399 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7402 final String p19_S = "(((A,B),C),D)";
7403 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7404 if ( p19.length != 1 ) {
7407 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7410 final String p20_S = "(A,(B,(C,D)))";
7411 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7412 if ( p20.length != 1 ) {
7415 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7418 final String p21_S = "(A,(B,(C,(D,E))))";
7419 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7420 if ( p21.length != 1 ) {
7423 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7426 final String p22_S = "((((A,B),C),D),E)";
7427 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7428 if ( p22.length != 1 ) {
7431 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7434 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7435 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7436 if ( p23.length != 1 ) {
7437 System.out.println( "xl=" + p23.length );
7441 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7444 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7445 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7446 if ( p24.length != 1 ) {
7449 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7452 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7453 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7454 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7455 if ( p241.length != 2 ) {
7458 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7461 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7464 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7465 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7466 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7467 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7468 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7469 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7470 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7471 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7472 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7473 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7476 final String p26_S = "(A,B)ab";
7477 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7478 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7481 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7482 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7483 if ( p27s.length != 1 ) {
7484 System.out.println( "xxl=" + p27s.length );
7488 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7489 System.out.println( p27s[ 0 ].toNewHampshireX() );
7493 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7495 if ( p27.length != 1 ) {
7496 System.out.println( "yl=" + p27.length );
7500 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7501 System.out.println( p27[ 0 ].toNewHampshireX() );
7505 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7506 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7507 final String p28_S3 = "(A,B)ab";
7508 final String p28_S4 = "((((A,B),C),D),;E;)";
7509 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7511 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7514 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7517 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7520 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7523 if ( p28.length != 4 ) {
7526 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";
7527 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7528 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7531 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";
7532 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7533 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7536 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7537 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7538 if ( ( p32.length != 0 ) ) {
7541 final String p33_S = "A";
7542 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7543 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7546 final String p34_S = "B;";
7547 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7548 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7551 final String p35_S = "B:0.2";
7552 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7553 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7556 final String p36_S = "(A)";
7557 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7558 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7561 final String p37_S = "((A))";
7562 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7563 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7566 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7567 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7568 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7571 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7572 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7573 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7576 final String p40_S = "(A,B,C)";
7577 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7578 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7581 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7582 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7583 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7586 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7587 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7588 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7591 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)";
7592 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7593 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7596 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)))";
7597 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7598 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7601 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7602 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7603 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7606 final String p46_S = "";
7607 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7608 if ( p46.length != 0 ) {
7611 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7612 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7615 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7616 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7619 final Phylogeny p49 = factory
7620 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7621 new NHXParser() )[ 0 ];
7622 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7625 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7626 if ( p50.getNode( "A" ) == null ) {
7629 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7630 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7633 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7636 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7637 .equals( "((A,B)88:2.0,C);" ) ) {
7640 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7641 if ( p51.getNode( "A(A" ) == null ) {
7644 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7645 if ( p52.getNode( "A(A" ) == null ) {
7648 final Phylogeny p53 = factory
7649 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7650 new NHXParser() )[ 0 ];
7651 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7655 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7656 if ( p54.getNode( "A" ) == null ) {
7659 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7660 .equals( "((A,B)[88],C);" ) ) {
7664 catch ( final Exception e ) {
7665 e.printStackTrace( System.out );
7671 private static boolean testNHParsingIter() {
7673 final String p0_str = "(A,B);";
7674 final NHXParser p = new NHXParser();
7675 p.setSource( p0_str );
7676 if ( !p.hasNext() ) {
7679 final Phylogeny p0 = p.next();
7680 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7681 System.out.println( p0.toNewHampshire() );
7684 if ( p.hasNext() ) {
7687 if ( p.next() != null ) {
7691 final String p00_str = "(A,B)root;";
7692 p.setSource( p00_str );
7693 final Phylogeny p00 = p.next();
7694 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7695 System.out.println( p00.toNewHampshire() );
7699 final String p000_str = "A;";
7700 p.setSource( p000_str );
7701 final Phylogeny p000 = p.next();
7702 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7703 System.out.println( p000.toNewHampshire() );
7707 final String p0000_str = "A";
7708 p.setSource( p0000_str );
7709 final Phylogeny p0000 = p.next();
7710 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7711 System.out.println( p0000.toNewHampshire() );
7715 p.setSource( "(A)" );
7716 final Phylogeny p00000 = p.next();
7717 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7718 System.out.println( p00000.toNewHampshire() );
7722 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7723 p.setSource( p1_str );
7724 if ( !p.hasNext() ) {
7727 final Phylogeny p1_0 = p.next();
7728 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7729 System.out.println( p1_0.toNewHampshire() );
7732 if ( !p.hasNext() ) {
7735 final Phylogeny p1_1 = p.next();
7736 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7737 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7740 if ( !p.hasNext() ) {
7743 final Phylogeny p1_2 = p.next();
7744 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7745 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7748 if ( !p.hasNext() ) {
7751 final Phylogeny p1_3 = p.next();
7752 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7753 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7756 if ( p.hasNext() ) {
7759 if ( p.next() != null ) {
7763 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7764 p.setSource( p2_str );
7765 if ( !p.hasNext() ) {
7768 Phylogeny p2_0 = p.next();
7769 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7770 System.out.println( p2_0.toNewHampshire() );
7773 if ( !p.hasNext() ) {
7776 Phylogeny p2_1 = p.next();
7777 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7778 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7781 if ( !p.hasNext() ) {
7784 Phylogeny p2_2 = p.next();
7785 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7786 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7789 if ( !p.hasNext() ) {
7792 Phylogeny p2_3 = p.next();
7793 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7794 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7797 if ( !p.hasNext() ) {
7800 Phylogeny p2_4 = p.next();
7801 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7802 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7805 if ( p.hasNext() ) {
7808 if ( p.next() != null ) {
7813 if ( !p.hasNext() ) {
7817 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7818 System.out.println( p2_0.toNewHampshire() );
7821 if ( !p.hasNext() ) {
7825 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7826 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7829 if ( !p.hasNext() ) {
7833 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7834 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7837 if ( !p.hasNext() ) {
7841 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7842 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7845 if ( !p.hasNext() ) {
7849 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7850 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7853 if ( p.hasNext() ) {
7856 if ( p.next() != null ) {
7860 final String p3_str = "((A,B),C)abc";
7861 p.setSource( p3_str );
7862 if ( !p.hasNext() ) {
7865 final Phylogeny p3_0 = p.next();
7866 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7869 if ( p.hasNext() ) {
7872 if ( p.next() != null ) {
7876 final String p4_str = "((A,B)ab,C)abc";
7877 p.setSource( p4_str );
7878 if ( !p.hasNext() ) {
7881 final Phylogeny p4_0 = p.next();
7882 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7885 if ( p.hasNext() ) {
7888 if ( p.next() != null ) {
7892 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7893 p.setSource( p5_str );
7894 if ( !p.hasNext() ) {
7897 final Phylogeny p5_0 = p.next();
7898 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7901 if ( p.hasNext() ) {
7904 if ( p.next() != null ) {
7908 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7909 p.setSource( p6_str );
7910 if ( !p.hasNext() ) {
7913 Phylogeny p6_0 = p.next();
7914 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7917 if ( p.hasNext() ) {
7920 if ( p.next() != null ) {
7924 if ( !p.hasNext() ) {
7928 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7931 if ( p.hasNext() ) {
7934 if ( p.next() != null ) {
7938 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7939 p.setSource( p7_str );
7940 if ( !p.hasNext() ) {
7943 Phylogeny p7_0 = p.next();
7944 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7947 if ( p.hasNext() ) {
7950 if ( p.next() != null ) {
7954 if ( !p.hasNext() ) {
7958 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7961 if ( p.hasNext() ) {
7964 if ( p.next() != null ) {
7968 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7969 p.setSource( p8_str );
7970 if ( !p.hasNext() ) {
7973 Phylogeny p8_0 = p.next();
7974 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7977 if ( !p.hasNext() ) {
7980 if ( !p.hasNext() ) {
7983 Phylogeny p8_1 = p.next();
7984 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7987 if ( p.hasNext() ) {
7990 if ( p.next() != null ) {
7994 if ( !p.hasNext() ) {
7998 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8001 if ( !p.hasNext() ) {
8005 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8008 if ( p.hasNext() ) {
8011 if ( p.next() != null ) {
8017 if ( p.hasNext() ) {
8021 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8022 if ( !p.hasNext() ) {
8025 Phylogeny p_27 = p.next();
8026 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8027 System.out.println( p_27.toNewHampshireX() );
8031 if ( p.hasNext() ) {
8034 if ( p.next() != null ) {
8038 if ( !p.hasNext() ) {
8042 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8043 System.out.println( p_27.toNewHampshireX() );
8047 if ( p.hasNext() ) {
8050 if ( p.next() != null ) {
8054 final String p30_str = "(A,B);(C,D)";
8055 final NHXParser p30 = new NHXParser();
8056 p30.setSource( p30_str );
8057 if ( !p30.hasNext() ) {
8060 Phylogeny phy30 = p30.next();
8061 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8062 System.out.println( phy30.toNewHampshire() );
8065 if ( !p30.hasNext() ) {
8068 Phylogeny phy301 = p30.next();
8069 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8070 System.out.println( phy301.toNewHampshire() );
8073 if ( p30.hasNext() ) {
8076 if ( p30.hasNext() ) {
8079 if ( p30.next() != null ) {
8082 if ( p30.next() != null ) {
8086 if ( !p30.hasNext() ) {
8090 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8091 System.out.println( phy30.toNewHampshire() );
8094 if ( !p30.hasNext() ) {
8097 phy301 = p30.next();
8098 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8099 System.out.println( phy301.toNewHampshire() );
8102 if ( p30.hasNext() ) {
8105 if ( p30.hasNext() ) {
8108 if ( p30.next() != null ) {
8111 if ( p30.next() != null ) {
8115 catch ( final Exception e ) {
8116 e.printStackTrace( System.out );
8122 private static boolean testNHXconversion() {
8124 final PhylogenyNode n1 = new PhylogenyNode();
8125 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8126 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8127 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8128 final PhylogenyNode n5 = PhylogenyNode
8129 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8130 final PhylogenyNode n6 = PhylogenyNode
8131 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8132 if ( !n1.toNewHampshireX().equals( "" ) ) {
8135 if ( !n2.toNewHampshireX().equals( "" ) ) {
8138 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8141 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8144 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8147 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8148 System.out.println( n6.toNewHampshireX() );
8152 catch ( final Exception e ) {
8153 e.printStackTrace( System.out );
8159 private static boolean testNHXNodeParsing() {
8161 final PhylogenyNode n1 = new PhylogenyNode();
8162 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8163 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8164 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8165 final PhylogenyNode n5 = PhylogenyNode
8166 .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]" );
8167 if ( !n3.getName().equals( "n3" ) ) {
8170 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8173 if ( n3.isDuplication() ) {
8176 if ( n3.isHasAssignedEvent() ) {
8179 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8182 if ( !n4.getName().equals( "n4" ) ) {
8185 if ( n4.getDistanceToParent() != 0.01 ) {
8188 if ( !n5.getName().equals( "n5" ) ) {
8191 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8194 if ( n5.getDistanceToParent() != 0.1 ) {
8197 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8200 if ( !n5.isDuplication() ) {
8203 if ( !n5.isHasAssignedEvent() ) {
8206 final PhylogenyNode n8 = PhylogenyNode
8207 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8208 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8209 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8212 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8215 final PhylogenyNode n9 = PhylogenyNode
8216 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8217 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8218 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8221 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8224 final PhylogenyNode n10 = PhylogenyNode
8225 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8226 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8229 final PhylogenyNode n20 = PhylogenyNode
8230 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8231 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8234 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8237 final PhylogenyNode n20x = PhylogenyNode
8238 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8239 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8242 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8245 final PhylogenyNode n20xx = PhylogenyNode
8246 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8247 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8250 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8253 final PhylogenyNode n20xxx = PhylogenyNode
8254 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8255 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8258 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8261 final PhylogenyNode n20xxxx = PhylogenyNode
8262 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8263 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8266 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8269 final PhylogenyNode n21 = PhylogenyNode
8270 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8271 if ( !n21.getName().equals( "N21_PIG" ) ) {
8274 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8277 final PhylogenyNode n21x = PhylogenyNode
8278 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8279 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8282 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8285 final PhylogenyNode n22 = PhylogenyNode
8286 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8287 if ( !n22.getName().equals( "n22/PIG" ) ) {
8290 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8293 final PhylogenyNode n23 = PhylogenyNode
8294 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8295 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8298 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8301 final PhylogenyNode a = PhylogenyNode
8302 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8303 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8306 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8309 final PhylogenyNode c1 = PhylogenyNode
8310 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8311 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8312 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8315 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8318 final PhylogenyNode c2 = PhylogenyNode
8319 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8320 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8321 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8324 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8327 final PhylogenyNode e3 = PhylogenyNode
8328 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8329 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8332 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8335 final PhylogenyNode n11 = PhylogenyNode
8336 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8337 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8338 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8341 if ( n11.getDistanceToParent() != 0.4 ) {
8344 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8347 final PhylogenyNode n12 = PhylogenyNode
8348 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8349 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8350 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8353 if ( n12.getDistanceToParent() != 0.4 ) {
8356 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8359 final PhylogenyNode o = PhylogenyNode
8360 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8361 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8364 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8367 if ( n1.getName().compareTo( "" ) != 0 ) {
8370 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8373 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8376 if ( n2.getName().compareTo( "" ) != 0 ) {
8379 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8382 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8385 final PhylogenyNode n00 = PhylogenyNode
8386 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8387 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8390 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8393 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8394 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8397 final PhylogenyNode n13 = PhylogenyNode
8398 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8399 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
8402 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8405 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8408 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8411 final PhylogenyNode n14 = PhylogenyNode
8412 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8413 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8416 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8419 final PhylogenyNode n15 = PhylogenyNode
8420 .createInstanceFromNhxString( "something_wicked[123]",
8421 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8422 if ( !n15.getName().equals( "something_wicked" ) ) {
8425 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8428 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8431 final PhylogenyNode n16 = PhylogenyNode
8432 .createInstanceFromNhxString( "something_wicked2[9]",
8433 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8434 if ( !n16.getName().equals( "something_wicked2" ) ) {
8437 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8440 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8443 final PhylogenyNode n17 = PhylogenyNode
8444 .createInstanceFromNhxString( "something_wicked3[a]",
8445 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8446 if ( !n17.getName().equals( "something_wicked3" ) ) {
8449 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8452 final PhylogenyNode n18 = PhylogenyNode
8453 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8454 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8457 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8460 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8463 final PhylogenyNode n19 = PhylogenyNode
8464 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8465 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8468 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8471 final PhylogenyNode n30 = PhylogenyNode
8472 .createInstanceFromNhxString( "blah_1234567-roejojoej",
8473 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8474 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8477 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8480 final PhylogenyNode n31 = PhylogenyNode
8481 .createInstanceFromNhxString( "blah_12345678-roejojoej",
8482 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8483 if ( n31.getNodeData().isHasTaxonomy() ) {
8486 final PhylogenyNode n32 = PhylogenyNode
8487 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8488 if ( n32.getNodeData().isHasTaxonomy() ) {
8491 final PhylogenyNode n40 = PhylogenyNode
8492 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8493 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8496 final PhylogenyNode n41 = PhylogenyNode
8497 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8498 if ( n41.getNodeData().isHasTaxonomy() ) {
8501 final PhylogenyNode n42 = PhylogenyNode
8502 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8503 if ( n42.getNodeData().isHasTaxonomy() ) {
8506 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8507 NHXParser.TAXONOMY_EXTRACTION.NO );
8508 if ( n43.getNodeData().isHasTaxonomy() ) {
8511 final PhylogenyNode n44 = PhylogenyNode
8512 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8513 if ( n44.getNodeData().isHasTaxonomy() ) {
8517 catch ( final Exception e ) {
8518 e.printStackTrace( System.out );
8524 private static boolean testNHXParsing() {
8526 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8527 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8528 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8531 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]";
8532 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8533 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8536 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]";
8537 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8538 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8541 final Phylogeny[] p3 = factory
8542 .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]",
8544 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8547 final Phylogeny[] p4 = factory
8548 .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(]",
8550 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8553 final Phylogeny[] p5 = factory
8554 .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(((]",
8556 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8559 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)";
8560 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)";
8561 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8562 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8565 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)))";
8566 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)))";
8567 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8568 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8571 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]) ))[,,, ])))))))";
8572 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8573 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8574 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8577 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8578 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8581 final Phylogeny p10 = factory
8582 .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]",
8583 new NHXParser() )[ 0 ];
8584 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8588 catch ( final Exception e ) {
8589 e.printStackTrace( System.out );
8595 private static boolean testNHXParsingMB() {
8597 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8598 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8599 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8600 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8601 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8602 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8603 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8604 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8605 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8606 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8607 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8610 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8613 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8614 0.1100000000000000e+00 ) ) {
8617 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8620 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8623 final Phylogeny p2 = factory
8624 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8625 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8626 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8627 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8628 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8629 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8630 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8631 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8632 + "7.369400000000000e-02}])",
8633 new NHXParser() )[ 0 ];
8634 if ( p2.getNode( "1" ) == null ) {
8637 if ( p2.getNode( "2" ) == null ) {
8641 catch ( final Exception e ) {
8642 e.printStackTrace( System.out );
8649 private static boolean testNHXParsingQuotes() {
8651 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8652 final NHXParser p = new NHXParser();
8653 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8654 if ( phylogenies_0.length != 5 ) {
8657 final Phylogeny phy = phylogenies_0[ 4 ];
8658 if ( phy.getNumberOfExternalNodes() != 7 ) {
8661 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8664 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8667 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8668 .getScientificName().equals( "hsapiens" ) ) {
8671 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8674 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8677 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8680 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8683 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8686 final NHXParser p1p = new NHXParser();
8687 p1p.setIgnoreQuotes( true );
8688 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8689 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8692 final NHXParser p2p = new NHXParser();
8693 p1p.setIgnoreQuotes( false );
8694 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8695 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8698 final NHXParser p3p = new NHXParser();
8699 p3p.setIgnoreQuotes( false );
8700 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8701 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8704 final NHXParser p4p = new NHXParser();
8705 p4p.setIgnoreQuotes( false );
8706 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8707 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8710 final Phylogeny p10 = factory
8711 .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]",
8712 new NHXParser() )[ 0 ];
8713 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]";
8714 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8717 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8718 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8722 final Phylogeny p12 = factory
8723 .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]",
8724 new NHXParser() )[ 0 ];
8725 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]";
8726 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8729 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8730 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8733 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;";
8734 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8737 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8738 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8742 catch ( final Exception e ) {
8743 e.printStackTrace( System.out );
8749 private static boolean testNodeRemoval() {
8751 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8752 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8753 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8754 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8757 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8758 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8759 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8762 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8763 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8764 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8768 catch ( final Exception e ) {
8769 e.printStackTrace( System.out );
8775 private static boolean testPhylogenyBranch() {
8777 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8778 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8779 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8780 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8781 if ( !a1b1.equals( a1b1 ) ) {
8784 if ( !a1b1.equals( b1a1 ) ) {
8787 if ( !b1a1.equals( a1b1 ) ) {
8790 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8791 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8792 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8793 if ( a1_b1.equals( b1_a1 ) ) {
8796 if ( a1_b1.equals( a1_b1_ ) ) {
8799 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8800 if ( !a1_b1.equals( b1_a1_ ) ) {
8803 if ( a1_b1_.equals( b1_a1_ ) ) {
8806 if ( !a1_b1_.equals( b1_a1 ) ) {
8810 catch ( final Exception e ) {
8811 e.printStackTrace( System.out );
8817 private static boolean testPhyloXMLparsingOfDistributionElement() {
8819 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8820 PhyloXmlParser xml_parser = null;
8822 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8824 catch ( final Exception e ) {
8825 // Do nothing -- means were not running from jar.
8827 if ( xml_parser == null ) {
8828 xml_parser = PhyloXmlParser.createPhyloXmlParser();
8829 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8830 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8833 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8836 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8838 if ( xml_parser.getErrorCount() > 0 ) {
8839 System.out.println( xml_parser.getErrorMessages().toString() );
8842 if ( phylogenies_0.length != 1 ) {
8845 final Phylogeny t1 = phylogenies_0[ 0 ];
8846 PhylogenyNode n = null;
8847 Distribution d = null;
8848 n = t1.getNode( "root node" );
8849 if ( !n.getNodeData().isHasDistribution() ) {
8852 if ( n.getNodeData().getDistributions().size() != 1 ) {
8855 d = n.getNodeData().getDistribution();
8856 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8859 if ( d.getPoints().size() != 1 ) {
8862 if ( d.getPolygons() != null ) {
8865 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8868 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8871 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8874 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8877 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8880 n = t1.getNode( "node a" );
8881 if ( !n.getNodeData().isHasDistribution() ) {
8884 if ( n.getNodeData().getDistributions().size() != 2 ) {
8887 d = n.getNodeData().getDistribution( 1 );
8888 if ( !d.getDesc().equals( "San Diego" ) ) {
8891 if ( d.getPoints().size() != 1 ) {
8894 if ( d.getPolygons() != null ) {
8897 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8900 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8903 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8906 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8909 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8912 n = t1.getNode( "node bb" );
8913 if ( !n.getNodeData().isHasDistribution() ) {
8916 if ( n.getNodeData().getDistributions().size() != 1 ) {
8919 d = n.getNodeData().getDistribution( 0 );
8920 if ( d.getPoints().size() != 3 ) {
8923 if ( d.getPolygons().size() != 2 ) {
8926 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8929 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8932 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8935 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8938 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8941 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8944 Polygon p = d.getPolygons().get( 0 );
8945 if ( p.getPoints().size() != 3 ) {
8948 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8951 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8954 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8957 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8960 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8963 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8966 p = d.getPolygons().get( 1 );
8967 if ( p.getPoints().size() != 3 ) {
8970 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8973 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8976 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8980 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8981 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8982 if ( rt.length != 1 ) {
8985 final Phylogeny t1_rt = rt[ 0 ];
8986 n = t1_rt.getNode( "root node" );
8987 if ( !n.getNodeData().isHasDistribution() ) {
8990 if ( n.getNodeData().getDistributions().size() != 1 ) {
8993 d = n.getNodeData().getDistribution();
8994 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8997 if ( d.getPoints().size() != 1 ) {
9000 if ( d.getPolygons() != null ) {
9003 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9006 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9009 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9012 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9015 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9018 n = t1_rt.getNode( "node a" );
9019 if ( !n.getNodeData().isHasDistribution() ) {
9022 if ( n.getNodeData().getDistributions().size() != 2 ) {
9025 d = n.getNodeData().getDistribution( 1 );
9026 if ( !d.getDesc().equals( "San Diego" ) ) {
9029 if ( d.getPoints().size() != 1 ) {
9032 if ( d.getPolygons() != null ) {
9035 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9038 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9041 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9044 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9047 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9050 n = t1_rt.getNode( "node bb" );
9051 if ( !n.getNodeData().isHasDistribution() ) {
9054 if ( n.getNodeData().getDistributions().size() != 1 ) {
9057 d = n.getNodeData().getDistribution( 0 );
9058 if ( d.getPoints().size() != 3 ) {
9061 if ( d.getPolygons().size() != 2 ) {
9064 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9067 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9070 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9073 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9076 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9079 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9082 p = d.getPolygons().get( 0 );
9083 if ( p.getPoints().size() != 3 ) {
9086 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9089 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9092 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9095 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9098 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9101 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9104 p = d.getPolygons().get( 1 );
9105 if ( p.getPoints().size() != 3 ) {
9108 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9111 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9114 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9118 catch ( final Exception e ) {
9119 e.printStackTrace( System.out );
9125 private static boolean testPostOrderIterator() {
9127 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9128 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9129 PhylogenyNodeIterator it0;
9130 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9133 for( it0.reset(); it0.hasNext(); ) {
9136 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9137 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9138 if ( !it.next().getName().equals( "A" ) ) {
9141 if ( !it.next().getName().equals( "B" ) ) {
9144 if ( !it.next().getName().equals( "ab" ) ) {
9147 if ( !it.next().getName().equals( "C" ) ) {
9150 if ( !it.next().getName().equals( "D" ) ) {
9153 if ( !it.next().getName().equals( "cd" ) ) {
9156 if ( !it.next().getName().equals( "abcd" ) ) {
9159 if ( !it.next().getName().equals( "E" ) ) {
9162 if ( !it.next().getName().equals( "F" ) ) {
9165 if ( !it.next().getName().equals( "ef" ) ) {
9168 if ( !it.next().getName().equals( "G" ) ) {
9171 if ( !it.next().getName().equals( "H" ) ) {
9174 if ( !it.next().getName().equals( "gh" ) ) {
9177 if ( !it.next().getName().equals( "efgh" ) ) {
9180 if ( !it.next().getName().equals( "r" ) ) {
9183 if ( it.hasNext() ) {
9187 catch ( final Exception e ) {
9188 e.printStackTrace( System.out );
9194 private static boolean testPreOrderIterator() {
9196 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9197 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9198 PhylogenyNodeIterator it0;
9199 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9202 for( it0.reset(); it0.hasNext(); ) {
9205 PhylogenyNodeIterator it = t0.iteratorPreorder();
9206 if ( !it.next().getName().equals( "r" ) ) {
9209 if ( !it.next().getName().equals( "ab" ) ) {
9212 if ( !it.next().getName().equals( "A" ) ) {
9215 if ( !it.next().getName().equals( "B" ) ) {
9218 if ( !it.next().getName().equals( "cd" ) ) {
9221 if ( !it.next().getName().equals( "C" ) ) {
9224 if ( !it.next().getName().equals( "D" ) ) {
9227 if ( it.hasNext() ) {
9230 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9231 it = t1.iteratorPreorder();
9232 if ( !it.next().getName().equals( "r" ) ) {
9235 if ( !it.next().getName().equals( "abcd" ) ) {
9238 if ( !it.next().getName().equals( "ab" ) ) {
9241 if ( !it.next().getName().equals( "A" ) ) {
9244 if ( !it.next().getName().equals( "B" ) ) {
9247 if ( !it.next().getName().equals( "cd" ) ) {
9250 if ( !it.next().getName().equals( "C" ) ) {
9253 if ( !it.next().getName().equals( "D" ) ) {
9256 if ( !it.next().getName().equals( "efgh" ) ) {
9259 if ( !it.next().getName().equals( "ef" ) ) {
9262 if ( !it.next().getName().equals( "E" ) ) {
9265 if ( !it.next().getName().equals( "F" ) ) {
9268 if ( !it.next().getName().equals( "gh" ) ) {
9271 if ( !it.next().getName().equals( "G" ) ) {
9274 if ( !it.next().getName().equals( "H" ) ) {
9277 if ( it.hasNext() ) {
9281 catch ( final Exception e ) {
9282 e.printStackTrace( System.out );
9288 private static boolean testPropertiesMap() {
9290 final PropertiesMap pm = new PropertiesMap();
9291 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9292 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9293 final Property p2 = new Property( "something:else",
9295 "improbable:research",
9298 pm.addProperty( p0 );
9299 pm.addProperty( p1 );
9300 pm.addProperty( p2 );
9301 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9304 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9307 if ( pm.getProperties().size() != 3 ) {
9310 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9313 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9316 if ( pm.getProperties().size() != 3 ) {
9319 pm.removeProperty( "dimensions:diameter" );
9320 if ( pm.getProperties().size() != 2 ) {
9323 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9326 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9330 catch ( final Exception e ) {
9331 e.printStackTrace( System.out );
9337 private static boolean testProteinId() {
9339 final ProteinId id1 = new ProteinId( "a" );
9340 final ProteinId id2 = new ProteinId( "a" );
9341 final ProteinId id3 = new ProteinId( "A" );
9342 final ProteinId id4 = new ProteinId( "b" );
9343 if ( !id1.equals( id1 ) ) {
9346 if ( id1.getId().equals( "x" ) ) {
9349 if ( id1.getId().equals( null ) ) {
9352 if ( !id1.equals( id2 ) ) {
9355 if ( id1.equals( id3 ) ) {
9358 if ( id1.hashCode() != id1.hashCode() ) {
9361 if ( id1.hashCode() != id2.hashCode() ) {
9364 if ( id1.hashCode() == id3.hashCode() ) {
9367 if ( id1.compareTo( id1 ) != 0 ) {
9370 if ( id1.compareTo( id2 ) != 0 ) {
9373 if ( id1.compareTo( id3 ) != 0 ) {
9376 if ( id1.compareTo( id4 ) >= 0 ) {
9379 if ( id4.compareTo( id1 ) <= 0 ) {
9382 if ( !id4.getId().equals( "b" ) ) {
9385 final ProteinId id5 = new ProteinId( " C " );
9386 if ( !id5.getId().equals( "C" ) ) {
9389 if ( id5.equals( id1 ) ) {
9393 catch ( final Exception e ) {
9394 e.printStackTrace( System.out );
9400 private static boolean testReIdMethods() {
9402 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9403 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9404 final long count = PhylogenyNode.getNodeCount();
9406 if ( p.getNode( "r" ).getId() != count ) {
9409 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9412 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9415 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9418 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9421 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9424 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9427 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9430 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9433 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9436 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9439 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9442 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9445 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9448 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9452 catch ( final Exception e ) {
9453 e.printStackTrace( System.out );
9459 private static boolean testRerooting() {
9461 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9462 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",
9463 new NHXParser() )[ 0 ];
9464 if ( !t1.isRooted() ) {
9467 t1.reRoot( t1.getNode( "D" ) );
9468 t1.reRoot( t1.getNode( "CD" ) );
9469 t1.reRoot( t1.getNode( "A" ) );
9470 t1.reRoot( t1.getNode( "B" ) );
9471 t1.reRoot( t1.getNode( "AB" ) );
9472 t1.reRoot( t1.getNode( "D" ) );
9473 t1.reRoot( t1.getNode( "C" ) );
9474 t1.reRoot( t1.getNode( "CD" ) );
9475 t1.reRoot( t1.getNode( "A" ) );
9476 t1.reRoot( t1.getNode( "B" ) );
9477 t1.reRoot( t1.getNode( "AB" ) );
9478 t1.reRoot( t1.getNode( "D" ) );
9479 t1.reRoot( t1.getNode( "D" ) );
9480 t1.reRoot( t1.getNode( "C" ) );
9481 t1.reRoot( t1.getNode( "A" ) );
9482 t1.reRoot( t1.getNode( "B" ) );
9483 t1.reRoot( t1.getNode( "AB" ) );
9484 t1.reRoot( t1.getNode( "C" ) );
9485 t1.reRoot( t1.getNode( "D" ) );
9486 t1.reRoot( t1.getNode( "CD" ) );
9487 t1.reRoot( t1.getNode( "D" ) );
9488 t1.reRoot( t1.getNode( "A" ) );
9489 t1.reRoot( t1.getNode( "B" ) );
9490 t1.reRoot( t1.getNode( "AB" ) );
9491 t1.reRoot( t1.getNode( "C" ) );
9492 t1.reRoot( t1.getNode( "D" ) );
9493 t1.reRoot( t1.getNode( "CD" ) );
9494 t1.reRoot( t1.getNode( "D" ) );
9495 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9498 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9501 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9504 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9507 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9510 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9513 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",
9514 new NHXParser() )[ 0 ];
9515 t2.reRoot( t2.getNode( "A" ) );
9516 t2.reRoot( t2.getNode( "D" ) );
9517 t2.reRoot( t2.getNode( "ABC" ) );
9518 t2.reRoot( t2.getNode( "A" ) );
9519 t2.reRoot( t2.getNode( "B" ) );
9520 t2.reRoot( t2.getNode( "D" ) );
9521 t2.reRoot( t2.getNode( "C" ) );
9522 t2.reRoot( t2.getNode( "ABC" ) );
9523 t2.reRoot( t2.getNode( "A" ) );
9524 t2.reRoot( t2.getNode( "B" ) );
9525 t2.reRoot( t2.getNode( "AB" ) );
9526 t2.reRoot( t2.getNode( "AB" ) );
9527 t2.reRoot( t2.getNode( "D" ) );
9528 t2.reRoot( t2.getNode( "C" ) );
9529 t2.reRoot( t2.getNode( "B" ) );
9530 t2.reRoot( t2.getNode( "AB" ) );
9531 t2.reRoot( t2.getNode( "D" ) );
9532 t2.reRoot( t2.getNode( "D" ) );
9533 t2.reRoot( t2.getNode( "ABC" ) );
9534 t2.reRoot( t2.getNode( "A" ) );
9535 t2.reRoot( t2.getNode( "B" ) );
9536 t2.reRoot( t2.getNode( "AB" ) );
9537 t2.reRoot( t2.getNode( "D" ) );
9538 t2.reRoot( t2.getNode( "C" ) );
9539 t2.reRoot( t2.getNode( "ABC" ) );
9540 t2.reRoot( t2.getNode( "A" ) );
9541 t2.reRoot( t2.getNode( "B" ) );
9542 t2.reRoot( t2.getNode( "AB" ) );
9543 t2.reRoot( t2.getNode( "D" ) );
9544 t2.reRoot( t2.getNode( "D" ) );
9545 t2.reRoot( t2.getNode( "C" ) );
9546 t2.reRoot( t2.getNode( "A" ) );
9547 t2.reRoot( t2.getNode( "B" ) );
9548 t2.reRoot( t2.getNode( "AB" ) );
9549 t2.reRoot( t2.getNode( "C" ) );
9550 t2.reRoot( t2.getNode( "D" ) );
9551 t2.reRoot( t2.getNode( "ABC" ) );
9552 t2.reRoot( t2.getNode( "D" ) );
9553 t2.reRoot( t2.getNode( "A" ) );
9554 t2.reRoot( t2.getNode( "B" ) );
9555 t2.reRoot( t2.getNode( "AB" ) );
9556 t2.reRoot( t2.getNode( "C" ) );
9557 t2.reRoot( t2.getNode( "D" ) );
9558 t2.reRoot( t2.getNode( "ABC" ) );
9559 t2.reRoot( t2.getNode( "D" ) );
9560 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9563 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9566 t2.reRoot( t2.getNode( "ABC" ) );
9567 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9570 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9573 t2.reRoot( t2.getNode( "AB" ) );
9574 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9577 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9580 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9583 t2.reRoot( t2.getNode( "AB" ) );
9584 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9587 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9590 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9593 t2.reRoot( t2.getNode( "D" ) );
9594 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9597 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9600 t2.reRoot( t2.getNode( "ABC" ) );
9601 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9604 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9607 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9608 new NHXParser() )[ 0 ];
9609 t3.reRoot( t3.getNode( "B" ) );
9610 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9613 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9616 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9619 t3.reRoot( t3.getNode( "B" ) );
9620 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9623 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9626 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9629 t3.reRoot( t3.getRoot() );
9630 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9633 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9636 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9640 catch ( final Exception e ) {
9641 e.printStackTrace( System.out );
9647 private static boolean testSDIse() {
9649 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9650 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9651 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9652 gene1.setRooted( true );
9653 species1.setRooted( true );
9654 final SDI sdi = new SDI( gene1, species1 );
9655 if ( !gene1.getRoot().isDuplication() ) {
9658 final Phylogeny species2 = factory
9659 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9660 new NHXParser() )[ 0 ];
9661 final Phylogeny gene2 = factory
9662 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9663 new NHXParser() )[ 0 ];
9664 species2.setRooted( true );
9665 gene2.setRooted( true );
9666 final SDI sdi2 = new SDI( gene2, species2 );
9667 if ( sdi2.getDuplicationsSum() != 0 ) {
9670 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9673 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9676 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9679 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9682 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9685 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9688 final Phylogeny species3 = factory
9689 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9690 new NHXParser() )[ 0 ];
9691 final Phylogeny gene3 = factory
9692 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9693 new NHXParser() )[ 0 ];
9694 species3.setRooted( true );
9695 gene3.setRooted( true );
9696 final SDI sdi3 = new SDI( gene3, species3 );
9697 if ( sdi3.getDuplicationsSum() != 1 ) {
9700 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9703 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9706 final Phylogeny species4 = factory
9707 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9708 new NHXParser() )[ 0 ];
9709 final Phylogeny gene4 = factory
9710 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9711 new NHXParser() )[ 0 ];
9712 species4.setRooted( true );
9713 gene4.setRooted( true );
9714 final SDI sdi4 = new SDI( gene4, species4 );
9715 if ( sdi4.getDuplicationsSum() != 1 ) {
9718 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9721 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9724 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9727 if ( species4.getNumberOfExternalNodes() != 6 ) {
9730 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9733 final Phylogeny species5 = factory
9734 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9735 new NHXParser() )[ 0 ];
9736 final Phylogeny gene5 = factory
9737 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9738 new NHXParser() )[ 0 ];
9739 species5.setRooted( true );
9740 gene5.setRooted( true );
9741 final SDI sdi5 = new SDI( gene5, species5 );
9742 if ( sdi5.getDuplicationsSum() != 2 ) {
9745 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9748 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9751 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9754 if ( species5.getNumberOfExternalNodes() != 6 ) {
9757 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9760 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9761 // Conjecture for Comparing Molecular Phylogenies"
9762 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9763 final Phylogeny species6 = factory
9764 .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,"
9765 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9766 new NHXParser() )[ 0 ];
9767 final Phylogeny gene6 = factory
9768 .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,"
9769 + "((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,"
9770 + "(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;",
9771 new NHXParser() )[ 0 ];
9772 species6.setRooted( true );
9773 gene6.setRooted( true );
9774 final SDI sdi6 = new SDI( gene6, species6 );
9775 if ( sdi6.getDuplicationsSum() != 3 ) {
9778 if ( !gene6.getNode( "r" ).isDuplication() ) {
9781 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9784 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9787 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9790 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9793 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9796 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9799 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9802 sdi6.computeMappingCostL();
9803 if ( sdi6.computeMappingCostL() != 17 ) {
9806 if ( species6.getNumberOfExternalNodes() != 9 ) {
9809 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9812 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9813 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9814 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9815 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9816 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9817 species7.setRooted( true );
9818 final Phylogeny gene7_1 = Test
9819 .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])" );
9820 gene7_1.setRooted( true );
9821 final SDI sdi7 = new SDI( gene7_1, species7 );
9822 if ( sdi7.getDuplicationsSum() != 0 ) {
9825 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9828 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9831 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9834 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9837 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9840 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9843 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9846 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9849 final Phylogeny gene7_2 = Test
9850 .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])" );
9851 gene7_2.setRooted( true );
9852 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9853 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9856 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9859 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9862 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9865 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9868 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9871 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9874 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9877 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9880 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9884 catch ( final Exception e ) {
9890 private static boolean testSDIunrooted() {
9892 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9893 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9894 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9895 final Iterator<PhylogenyBranch> iter = l.iterator();
9896 PhylogenyBranch br = iter.next();
9897 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9900 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9904 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9907 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9911 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9914 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9918 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9921 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9925 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9928 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9932 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9935 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9939 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9942 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9946 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9949 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9953 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9956 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9960 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9963 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9967 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9970 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9974 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9977 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9981 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9984 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9988 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9991 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9995 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9998 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10001 if ( iter.hasNext() ) {
10004 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10005 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10006 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10008 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10011 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10015 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10018 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10022 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10025 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10028 if ( iter1.hasNext() ) {
10031 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10032 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10033 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10035 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10038 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10042 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10045 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10049 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10052 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10055 if ( iter2.hasNext() ) {
10058 final Phylogeny species0 = factory
10059 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10060 new NHXParser() )[ 0 ];
10061 final Phylogeny gene1 = factory
10062 .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])",
10063 new NHXParser() )[ 0 ];
10064 species0.setRooted( true );
10065 gene1.setRooted( true );
10066 final SDIR sdi_unrooted = new SDIR();
10067 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10068 if ( sdi_unrooted.getCount() != 1 ) {
10071 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10074 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10077 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10080 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10083 final Phylogeny gene2 = factory
10084 .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])",
10085 new NHXParser() )[ 0 ];
10086 gene2.setRooted( true );
10087 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10088 if ( sdi_unrooted.getCount() != 1 ) {
10091 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10094 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10097 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10100 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10103 final Phylogeny species6 = factory
10104 .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,"
10105 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10106 new NHXParser() )[ 0 ];
10107 final Phylogeny gene6 = factory
10108 .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],"
10109 + "(((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],"
10110 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10111 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10112 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10113 new NHXParser() )[ 0 ];
10114 species6.setRooted( true );
10115 gene6.setRooted( true );
10116 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10117 if ( sdi_unrooted.getCount() != 1 ) {
10120 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10123 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10126 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10129 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10132 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10135 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10138 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10141 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10144 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10147 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10150 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10153 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10157 final Phylogeny species7 = factory
10158 .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,"
10159 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10160 new NHXParser() )[ 0 ];
10161 final Phylogeny gene7 = factory
10162 .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],"
10163 + "(((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],"
10164 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10165 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10166 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10167 new NHXParser() )[ 0 ];
10168 species7.setRooted( true );
10169 gene7.setRooted( true );
10170 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10171 if ( sdi_unrooted.getCount() != 1 ) {
10174 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10177 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10180 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10183 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10186 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10189 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10192 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10195 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10198 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10201 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10204 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10207 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10211 final Phylogeny species8 = factory
10212 .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,"
10213 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10214 new NHXParser() )[ 0 ];
10215 final Phylogeny gene8 = factory
10216 .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],"
10217 + "(((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],"
10218 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10219 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10220 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10221 new NHXParser() )[ 0 ];
10222 species8.setRooted( true );
10223 gene8.setRooted( true );
10224 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10225 if ( sdi_unrooted.getCount() != 1 ) {
10228 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10231 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10234 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10237 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10240 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10243 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10246 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10249 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10252 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10255 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10258 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10261 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10266 catch ( final Exception e ) {
10267 e.printStackTrace( System.out );
10273 private static boolean testSequenceDbWsTools1() {
10275 final PhylogenyNode n = new PhylogenyNode();
10276 n.setName( "NP_001025424" );
10277 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10278 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10279 || !acc.getValue().equals( "NP_001025424" ) ) {
10282 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10283 acc = SequenceDbWsTools.obtainSeqAccession( n );
10284 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10285 || !acc.getValue().equals( "NP_001025424" ) ) {
10288 n.setName( "NP_001025424.1" );
10289 acc = SequenceDbWsTools.obtainSeqAccession( n );
10290 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10291 || !acc.getValue().equals( "NP_001025424" ) ) {
10294 n.setName( "NM_001030253" );
10295 acc = SequenceDbWsTools.obtainSeqAccession( n );
10296 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10297 || !acc.getValue().equals( "NM_001030253" ) ) {
10300 n.setName( "BCL2_HUMAN" );
10301 acc = SequenceDbWsTools.obtainSeqAccession( n );
10302 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10303 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10304 System.out.println( acc.toString() );
10307 n.setName( "P10415" );
10308 acc = SequenceDbWsTools.obtainSeqAccession( n );
10309 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10310 || !acc.getValue().equals( "P10415" ) ) {
10311 System.out.println( acc.toString() );
10314 n.setName( " P10415 " );
10315 acc = SequenceDbWsTools.obtainSeqAccession( n );
10316 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10317 || !acc.getValue().equals( "P10415" ) ) {
10318 System.out.println( acc.toString() );
10321 n.setName( "_P10415|" );
10322 acc = SequenceDbWsTools.obtainSeqAccession( n );
10323 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10324 || !acc.getValue().equals( "P10415" ) ) {
10325 System.out.println( acc.toString() );
10328 n.setName( "AY695820" );
10329 acc = SequenceDbWsTools.obtainSeqAccession( n );
10330 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10331 || !acc.getValue().equals( "AY695820" ) ) {
10332 System.out.println( acc.toString() );
10335 n.setName( "_AY695820_" );
10336 acc = SequenceDbWsTools.obtainSeqAccession( n );
10337 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10338 || !acc.getValue().equals( "AY695820" ) ) {
10339 System.out.println( acc.toString() );
10342 n.setName( "AAA59452" );
10343 acc = SequenceDbWsTools.obtainSeqAccession( n );
10344 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10345 || !acc.getValue().equals( "AAA59452" ) ) {
10346 System.out.println( acc.toString() );
10349 n.setName( "_AAA59452_" );
10350 acc = SequenceDbWsTools.obtainSeqAccession( n );
10351 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10352 || !acc.getValue().equals( "AAA59452" ) ) {
10353 System.out.println( acc.toString() );
10356 n.setName( "AAA59452.1" );
10357 acc = SequenceDbWsTools.obtainSeqAccession( n );
10358 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10359 || !acc.getValue().equals( "AAA59452.1" ) ) {
10360 System.out.println( acc.toString() );
10363 n.setName( "_AAA59452.1_" );
10364 acc = SequenceDbWsTools.obtainSeqAccession( n );
10365 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10366 || !acc.getValue().equals( "AAA59452.1" ) ) {
10367 System.out.println( acc.toString() );
10370 n.setName( "GI:94894583" );
10371 acc = SequenceDbWsTools.obtainSeqAccession( n );
10372 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10373 || !acc.getValue().equals( "94894583" ) ) {
10374 System.out.println( acc.toString() );
10377 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10378 acc = SequenceDbWsTools.obtainSeqAccession( n );
10379 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10380 || !acc.getValue().equals( "71845847" ) ) {
10381 System.out.println( acc.toString() );
10384 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10385 acc = SequenceDbWsTools.obtainSeqAccession( n );
10386 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10387 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10388 System.out.println( acc.toString() );
10392 catch ( final Exception e ) {
10398 private static boolean testSequenceDbWsTools2() {
10400 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10401 SequenceDbWsTools.obtainSeqInformation( n1 );
10402 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10405 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10408 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10411 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10414 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10415 SequenceDbWsTools.obtainSeqInformation( n2 );
10416 if ( !n2.getNodeData().getSequence().getName()
10417 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10420 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10423 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10426 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10429 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10430 SequenceDbWsTools.obtainSeqInformation( n3 );
10431 if ( !n3.getNodeData().getSequence().getName()
10432 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10435 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10438 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10441 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10445 catch ( final IOException e ) {
10446 System.out.println();
10447 System.out.println( "the following might be due to absence internet connection:" );
10448 e.printStackTrace( System.out );
10451 catch ( final Exception e ) {
10452 e.printStackTrace();
10458 private static boolean testSequenceIdParsing() {
10460 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10461 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10462 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10463 if ( id != null ) {
10464 System.out.println( "value =" + id.getValue() );
10465 System.out.println( "provider=" + id.getSource() );
10470 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10471 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10472 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10473 if ( id != null ) {
10474 System.out.println( "value =" + id.getValue() );
10475 System.out.println( "provider=" + id.getSource() );
10480 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10481 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10482 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10483 if ( id != null ) {
10484 System.out.println( "value =" + id.getValue() );
10485 System.out.println( "provider=" + id.getSource() );
10490 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10491 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10492 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10493 if ( id != null ) {
10494 System.out.println( "value =" + id.getValue() );
10495 System.out.println( "provider=" + id.getSource() );
10500 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10501 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10502 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10503 if ( id != null ) {
10504 System.out.println( "value =" + id.getValue() );
10505 System.out.println( "provider=" + id.getSource() );
10510 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10511 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10512 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10513 if ( id != null ) {
10514 System.out.println( "value =" + id.getValue() );
10515 System.out.println( "provider=" + id.getSource() );
10520 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10521 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10522 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10523 if ( id != null ) {
10524 System.out.println( "value =" + id.getValue() );
10525 System.out.println( "provider=" + id.getSource() );
10530 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10531 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10532 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10533 if ( id != null ) {
10534 System.out.println( "value =" + id.getValue() );
10535 System.out.println( "provider=" + id.getSource() );
10540 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10541 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10542 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10543 if ( id != null ) {
10544 System.out.println( "value =" + id.getValue() );
10545 System.out.println( "provider=" + id.getSource() );
10550 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10551 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10552 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10553 if ( id != null ) {
10554 System.out.println( "value =" + id.getValue() );
10555 System.out.println( "provider=" + id.getSource() );
10559 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10560 if ( id != null ) {
10561 System.out.println( "value =" + id.getValue() );
10562 System.out.println( "provider=" + id.getSource() );
10566 catch ( final Exception e ) {
10567 e.printStackTrace( System.out );
10573 private static boolean testSequenceWriter() {
10575 final String n = ForesterUtil.LINE_SEPARATOR;
10576 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10579 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10582 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10585 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10588 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10589 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10592 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10593 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10597 catch ( final Exception e ) {
10598 e.printStackTrace();
10604 private static boolean testSpecies() {
10606 final Species s1 = new BasicSpecies( "a" );
10607 final Species s2 = new BasicSpecies( "a" );
10608 final Species s3 = new BasicSpecies( "A" );
10609 final Species s4 = new BasicSpecies( "b" );
10610 if ( !s1.equals( s1 ) ) {
10613 if ( s1.getSpeciesId().equals( "x" ) ) {
10616 if ( s1.getSpeciesId().equals( null ) ) {
10619 if ( !s1.equals( s2 ) ) {
10622 if ( s1.equals( s3 ) ) {
10625 if ( s1.hashCode() != s1.hashCode() ) {
10628 if ( s1.hashCode() != s2.hashCode() ) {
10631 if ( s1.hashCode() == s3.hashCode() ) {
10634 if ( s1.compareTo( s1 ) != 0 ) {
10637 if ( s1.compareTo( s2 ) != 0 ) {
10640 if ( s1.compareTo( s3 ) != 0 ) {
10643 if ( s1.compareTo( s4 ) >= 0 ) {
10646 if ( s4.compareTo( s1 ) <= 0 ) {
10649 if ( !s4.getSpeciesId().equals( "b" ) ) {
10652 final Species s5 = new BasicSpecies( " C " );
10653 if ( !s5.getSpeciesId().equals( "C" ) ) {
10656 if ( s5.equals( s1 ) ) {
10660 catch ( final Exception e ) {
10661 e.printStackTrace( System.out );
10667 private static boolean testSplit() {
10669 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10670 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10671 //Archaeopteryx.createApplication( p0 );
10672 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10673 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10674 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10675 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10676 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10677 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10678 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10679 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10680 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10681 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10682 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
10683 // System.out.println( s0.toString() );
10685 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10688 if ( s0.match( query_nodes ) ) {
10691 query_nodes = new HashSet<PhylogenyNode>();
10692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10699 if ( !s0.match( query_nodes ) ) {
10703 query_nodes = new HashSet<PhylogenyNode>();
10704 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10707 if ( !s0.match( query_nodes ) ) {
10711 query_nodes = new HashSet<PhylogenyNode>();
10712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10716 if ( !s0.match( query_nodes ) ) {
10720 query_nodes = new HashSet<PhylogenyNode>();
10721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10725 if ( !s0.match( query_nodes ) ) {
10729 query_nodes = new HashSet<PhylogenyNode>();
10730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10733 if ( !s0.match( query_nodes ) ) {
10737 query_nodes = new HashSet<PhylogenyNode>();
10738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10740 if ( !s0.match( query_nodes ) ) {
10744 query_nodes = new HashSet<PhylogenyNode>();
10745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10749 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10750 if ( !s0.match( query_nodes ) ) {
10754 query_nodes = new HashSet<PhylogenyNode>();
10755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10758 if ( !s0.match( query_nodes ) ) {
10762 query_nodes = new HashSet<PhylogenyNode>();
10763 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10767 if ( !s0.match( query_nodes ) ) {
10771 query_nodes = new HashSet<PhylogenyNode>();
10772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10774 if ( s0.match( query_nodes ) ) {
10778 query_nodes = new HashSet<PhylogenyNode>();
10779 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10783 if ( s0.match( query_nodes ) ) {
10787 query_nodes = new HashSet<PhylogenyNode>();
10788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10793 if ( s0.match( query_nodes ) ) {
10797 query_nodes = new HashSet<PhylogenyNode>();
10798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10800 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10801 if ( s0.match( query_nodes ) ) {
10805 query_nodes = new HashSet<PhylogenyNode>();
10806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10808 if ( s0.match( query_nodes ) ) {
10812 query_nodes = new HashSet<PhylogenyNode>();
10813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10815 if ( s0.match( query_nodes ) ) {
10819 query_nodes = new HashSet<PhylogenyNode>();
10820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10822 if ( s0.match( query_nodes ) ) {
10826 query_nodes = new HashSet<PhylogenyNode>();
10827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10829 if ( s0.match( query_nodes ) ) {
10833 query_nodes = new HashSet<PhylogenyNode>();
10834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10836 if ( s0.match( query_nodes ) ) {
10840 query_nodes = new HashSet<PhylogenyNode>();
10841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10843 if ( s0.match( query_nodes ) ) {
10847 query_nodes = new HashSet<PhylogenyNode>();
10848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10851 if ( s0.match( query_nodes ) ) {
10855 query_nodes = new HashSet<PhylogenyNode>();
10856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10858 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10859 if ( s0.match( query_nodes ) ) {
10863 query_nodes = new HashSet<PhylogenyNode>();
10864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10867 if ( s0.match( query_nodes ) ) {
10871 query_nodes = new HashSet<PhylogenyNode>();
10872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10875 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10876 if ( s0.match( query_nodes ) ) {
10880 // query_nodes = new HashSet<PhylogenyNode>();
10881 // query_nodes.add( new PhylogenyNode( "X" ) );
10882 // query_nodes.add( new PhylogenyNode( "Y" ) );
10883 // query_nodes.add( new PhylogenyNode( "A" ) );
10884 // query_nodes.add( new PhylogenyNode( "B" ) );
10885 // query_nodes.add( new PhylogenyNode( "C" ) );
10886 // query_nodes.add( new PhylogenyNode( "D" ) );
10887 // query_nodes.add( new PhylogenyNode( "E" ) );
10888 // query_nodes.add( new PhylogenyNode( "F" ) );
10889 // query_nodes.add( new PhylogenyNode( "G" ) );
10890 // if ( !s0.match( query_nodes ) ) {
10893 // query_nodes = new HashSet<PhylogenyNode>();
10894 // query_nodes.add( new PhylogenyNode( "X" ) );
10895 // query_nodes.add( new PhylogenyNode( "Y" ) );
10896 // query_nodes.add( new PhylogenyNode( "A" ) );
10897 // query_nodes.add( new PhylogenyNode( "B" ) );
10898 // query_nodes.add( new PhylogenyNode( "C" ) );
10899 // if ( !s0.match( query_nodes ) ) {
10903 // query_nodes = new HashSet<PhylogenyNode>();
10904 // query_nodes.add( new PhylogenyNode( "X" ) );
10905 // query_nodes.add( new PhylogenyNode( "Y" ) );
10906 // query_nodes.add( new PhylogenyNode( "D" ) );
10907 // query_nodes.add( new PhylogenyNode( "E" ) );
10908 // query_nodes.add( new PhylogenyNode( "F" ) );
10909 // query_nodes.add( new PhylogenyNode( "G" ) );
10910 // if ( !s0.match( query_nodes ) ) {
10914 // query_nodes = new HashSet<PhylogenyNode>();
10915 // query_nodes.add( new PhylogenyNode( "X" ) );
10916 // query_nodes.add( new PhylogenyNode( "Y" ) );
10917 // query_nodes.add( new PhylogenyNode( "A" ) );
10918 // query_nodes.add( new PhylogenyNode( "B" ) );
10919 // query_nodes.add( new PhylogenyNode( "C" ) );
10920 // query_nodes.add( new PhylogenyNode( "D" ) );
10921 // if ( !s0.match( query_nodes ) ) {
10925 // query_nodes = new HashSet<PhylogenyNode>();
10926 // query_nodes.add( new PhylogenyNode( "X" ) );
10927 // query_nodes.add( new PhylogenyNode( "Y" ) );
10928 // query_nodes.add( new PhylogenyNode( "E" ) );
10929 // query_nodes.add( new PhylogenyNode( "F" ) );
10930 // query_nodes.add( new PhylogenyNode( "G" ) );
10931 // if ( !s0.match( query_nodes ) ) {
10935 // query_nodes = new HashSet<PhylogenyNode>();
10936 // query_nodes.add( new PhylogenyNode( "X" ) );
10937 // query_nodes.add( new PhylogenyNode( "Y" ) );
10938 // query_nodes.add( new PhylogenyNode( "F" ) );
10939 // query_nodes.add( new PhylogenyNode( "G" ) );
10940 // if ( !s0.match( query_nodes ) ) {
10944 query_nodes = new HashSet<PhylogenyNode>();
10945 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10949 if ( s0.match( query_nodes ) ) {
10953 query_nodes = new HashSet<PhylogenyNode>();
10954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10958 if ( s0.match( query_nodes ) ) {
10961 ///////////////////////////
10963 query_nodes = new HashSet<PhylogenyNode>();
10964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10968 if ( s0.match( query_nodes ) ) {
10972 query_nodes = new HashSet<PhylogenyNode>();
10973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10977 if ( s0.match( query_nodes ) ) {
10981 query_nodes = new HashSet<PhylogenyNode>();
10982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10986 if ( s0.match( query_nodes ) ) {
10990 query_nodes = new HashSet<PhylogenyNode>();
10991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10995 if ( s0.match( query_nodes ) ) {
10999 query_nodes = new HashSet<PhylogenyNode>();
11000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11004 if ( s0.match( query_nodes ) ) {
11008 query_nodes = new HashSet<PhylogenyNode>();
11009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11012 if ( s0.match( query_nodes ) ) {
11016 query_nodes = new HashSet<PhylogenyNode>();
11017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11022 if ( s0.match( query_nodes ) ) {
11026 query_nodes = new HashSet<PhylogenyNode>();
11027 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11032 if ( s0.match( query_nodes ) ) {
11036 query_nodes = new HashSet<PhylogenyNode>();
11037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11042 if ( s0.match( query_nodes ) ) {
11046 query_nodes = new HashSet<PhylogenyNode>();
11047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11048 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11053 if ( s0.match( query_nodes ) ) {
11057 catch ( final Exception e ) {
11058 e.printStackTrace();
11064 private static boolean testSplitStrict() {
11066 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11067 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11068 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11069 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11070 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11071 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11072 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11073 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11074 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11075 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11076 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11077 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11079 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11080 if ( s0.match( query_nodes ) ) {
11083 query_nodes = new HashSet<PhylogenyNode>();
11084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11085 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11091 if ( !s0.match( query_nodes ) ) {
11095 query_nodes = new HashSet<PhylogenyNode>();
11096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11099 if ( !s0.match( query_nodes ) ) {
11103 query_nodes = new HashSet<PhylogenyNode>();
11104 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11106 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11107 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11108 if ( !s0.match( query_nodes ) ) {
11112 query_nodes = new HashSet<PhylogenyNode>();
11113 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11114 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11115 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11117 if ( !s0.match( query_nodes ) ) {
11121 query_nodes = new HashSet<PhylogenyNode>();
11122 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11123 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11124 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11125 if ( !s0.match( query_nodes ) ) {
11129 query_nodes = new HashSet<PhylogenyNode>();
11130 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11132 if ( !s0.match( query_nodes ) ) {
11136 query_nodes = new HashSet<PhylogenyNode>();
11137 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11138 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11142 if ( !s0.match( query_nodes ) ) {
11146 query_nodes = new HashSet<PhylogenyNode>();
11147 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11150 if ( !s0.match( query_nodes ) ) {
11154 query_nodes = new HashSet<PhylogenyNode>();
11155 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11156 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11159 if ( !s0.match( query_nodes ) ) {
11163 query_nodes = new HashSet<PhylogenyNode>();
11164 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11165 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11166 if ( s0.match( query_nodes ) ) {
11170 query_nodes = new HashSet<PhylogenyNode>();
11171 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11172 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11173 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11174 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11175 if ( s0.match( query_nodes ) ) {
11179 query_nodes = new HashSet<PhylogenyNode>();
11180 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11181 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11182 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11185 if ( s0.match( query_nodes ) ) {
11189 query_nodes = new HashSet<PhylogenyNode>();
11190 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11193 if ( s0.match( query_nodes ) ) {
11197 query_nodes = new HashSet<PhylogenyNode>();
11198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11199 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11200 if ( s0.match( query_nodes ) ) {
11204 query_nodes = new HashSet<PhylogenyNode>();
11205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11207 if ( s0.match( query_nodes ) ) {
11211 query_nodes = new HashSet<PhylogenyNode>();
11212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11214 if ( s0.match( query_nodes ) ) {
11218 query_nodes = new HashSet<PhylogenyNode>();
11219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11221 if ( s0.match( query_nodes ) ) {
11225 query_nodes = new HashSet<PhylogenyNode>();
11226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11227 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11228 if ( s0.match( query_nodes ) ) {
11232 query_nodes = new HashSet<PhylogenyNode>();
11233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11235 if ( s0.match( query_nodes ) ) {
11239 query_nodes = new HashSet<PhylogenyNode>();
11240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11243 if ( s0.match( query_nodes ) ) {
11247 query_nodes = new HashSet<PhylogenyNode>();
11248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11251 if ( s0.match( query_nodes ) ) {
11255 query_nodes = new HashSet<PhylogenyNode>();
11256 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11257 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11258 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11259 if ( s0.match( query_nodes ) ) {
11263 query_nodes = new HashSet<PhylogenyNode>();
11264 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11265 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11267 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11268 if ( s0.match( query_nodes ) ) {
11272 catch ( final Exception e ) {
11273 e.printStackTrace();
11279 private static boolean testSubtreeDeletion() {
11281 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11282 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11283 t1.deleteSubtree( t1.getNode( "A" ), false );
11284 if ( t1.getNumberOfExternalNodes() != 5 ) {
11287 t1.toNewHampshireX();
11288 t1.deleteSubtree( t1.getNode( "E" ), false );
11289 if ( t1.getNumberOfExternalNodes() != 4 ) {
11292 t1.toNewHampshireX();
11293 t1.deleteSubtree( t1.getNode( "F" ), false );
11294 if ( t1.getNumberOfExternalNodes() != 3 ) {
11297 t1.toNewHampshireX();
11298 t1.deleteSubtree( t1.getNode( "D" ), false );
11299 t1.toNewHampshireX();
11300 if ( t1.getNumberOfExternalNodes() != 3 ) {
11303 t1.deleteSubtree( t1.getNode( "def" ), false );
11304 t1.toNewHampshireX();
11305 if ( t1.getNumberOfExternalNodes() != 2 ) {
11308 t1.deleteSubtree( t1.getNode( "B" ), false );
11309 t1.toNewHampshireX();
11310 if ( t1.getNumberOfExternalNodes() != 1 ) {
11313 t1.deleteSubtree( t1.getNode( "C" ), false );
11314 t1.toNewHampshireX();
11315 if ( t1.getNumberOfExternalNodes() != 1 ) {
11318 t1.deleteSubtree( t1.getNode( "abc" ), false );
11319 t1.toNewHampshireX();
11320 if ( t1.getNumberOfExternalNodes() != 1 ) {
11323 t1.deleteSubtree( t1.getNode( "r" ), false );
11324 if ( t1.getNumberOfExternalNodes() != 0 ) {
11327 if ( !t1.isEmpty() ) {
11330 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11331 t2.deleteSubtree( t2.getNode( "A" ), false );
11332 t2.toNewHampshireX();
11333 if ( t2.getNumberOfExternalNodes() != 5 ) {
11336 t2.deleteSubtree( t2.getNode( "abc" ), false );
11337 t2.toNewHampshireX();
11338 if ( t2.getNumberOfExternalNodes() != 3 ) {
11341 t2.deleteSubtree( t2.getNode( "def" ), false );
11342 t2.toNewHampshireX();
11343 if ( t2.getNumberOfExternalNodes() != 1 ) {
11347 catch ( final Exception e ) {
11348 e.printStackTrace( System.out );
11354 private static boolean testSupportCount() {
11356 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11357 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11358 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11359 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11360 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11361 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11362 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11364 SupportCount.count( t0_1, phylogenies_1, true, false );
11365 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11366 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11367 + "(((((A,B),C),D),E),((F,G),X))"
11368 + "(((((A,Y),B),C),D),((F,G),E))"
11369 + "(((((A,B),C),D),E),(F,G))"
11370 + "(((((A,B),C),D),E),(F,G))"
11371 + "(((((A,B),C),D),E),(F,G))"
11372 + "(((((A,B),C),D),E),(F,G),Z)"
11373 + "(((((A,B),C),D),E),(F,G))"
11374 + "((((((A,B),C),D),E),F),G)"
11375 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11377 SupportCount.count( t0_2, phylogenies_2, true, false );
11378 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11379 while ( it.hasNext() ) {
11380 final PhylogenyNode n = it.next();
11381 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11385 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11386 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11387 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11388 SupportCount.count( t0_3, phylogenies_3, true, false );
11389 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11390 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11393 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11396 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11399 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11402 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11405 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11408 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11411 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11414 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11417 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11420 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11421 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11422 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11423 SupportCount.count( t0_4, phylogenies_4, true, false );
11424 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11425 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11428 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11431 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11434 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11437 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11440 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11443 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11446 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11449 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11452 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11455 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11456 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11457 double d = SupportCount.compare( b1, a, true, true, true );
11458 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11461 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11462 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11463 d = SupportCount.compare( b2, a, true, true, true );
11464 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11467 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11468 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11469 d = SupportCount.compare( b3, a, true, true, true );
11470 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11473 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11474 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11475 d = SupportCount.compare( b4, a, true, true, false );
11476 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11480 catch ( final Exception e ) {
11481 e.printStackTrace( System.out );
11487 private static boolean testSupportTransfer() {
11489 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11490 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)",
11491 new NHXParser() )[ 0 ];
11492 final Phylogeny p2 = factory
11493 .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 ];
11494 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11497 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11500 support_transfer.moveBranchLengthsToBootstrap( p1 );
11501 support_transfer.transferSupportValues( p1, p2 );
11502 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11505 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11508 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11511 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11514 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11517 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11520 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11523 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11527 catch ( final Exception e ) {
11528 e.printStackTrace( System.out );
11534 private static boolean testTaxonomyExtraction() {
11536 final PhylogenyNode n0 = PhylogenyNode
11537 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11538 if ( n0.getNodeData().isHasTaxonomy() ) {
11541 final PhylogenyNode n1 = PhylogenyNode
11542 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11543 if ( n1.getNodeData().isHasTaxonomy() ) {
11544 System.out.println( n1.toString() );
11547 final PhylogenyNode n2x = PhylogenyNode
11548 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11549 if ( n2x.getNodeData().isHasTaxonomy() ) {
11552 final PhylogenyNode n3 = PhylogenyNode
11553 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11554 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11555 System.out.println( n3.toString() );
11558 final PhylogenyNode n4 = PhylogenyNode
11559 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11560 if ( n4.getNodeData().isHasTaxonomy() ) {
11561 System.out.println( n4.toString() );
11564 final PhylogenyNode n5 = PhylogenyNode
11565 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11566 if ( n5.getNodeData().isHasTaxonomy() ) {
11567 System.out.println( n5.toString() );
11570 final PhylogenyNode n6 = PhylogenyNode
11571 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11572 if ( n6.getNodeData().isHasTaxonomy() ) {
11573 System.out.println( n6.toString() );
11576 final PhylogenyNode n7 = PhylogenyNode
11577 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11578 if ( n7.getNodeData().isHasTaxonomy() ) {
11579 System.out.println( n7.toString() );
11582 final PhylogenyNode n8 = PhylogenyNode
11583 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11584 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11585 System.out.println( n8.toString() );
11588 final PhylogenyNode n9 = PhylogenyNode
11589 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11590 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11591 System.out.println( n9.toString() );
11594 final PhylogenyNode n10x = PhylogenyNode
11595 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11596 if ( n10x.getNodeData().isHasTaxonomy() ) {
11597 System.out.println( n10x.toString() );
11600 final PhylogenyNode n10xx = PhylogenyNode
11601 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11602 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11603 System.out.println( n10xx.toString() );
11606 final PhylogenyNode n10 = PhylogenyNode
11607 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11608 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11609 System.out.println( n10.toString() );
11612 final PhylogenyNode n11 = PhylogenyNode
11613 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11614 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11615 System.out.println( n11.toString() );
11618 final PhylogenyNode n12 = PhylogenyNode
11619 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11620 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11621 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11622 System.out.println( n12.toString() );
11625 final PhylogenyNode n13 = PhylogenyNode
11626 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11627 if ( n13.getNodeData().isHasTaxonomy() ) {
11628 System.out.println( n13.toString() );
11632 catch ( final Exception e ) {
11633 e.printStackTrace( System.out );
11639 private static boolean testTreeCopy() {
11641 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
11642 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
11643 final Phylogeny t1 = t0.copy();
11644 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
11647 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11650 t0.deleteSubtree( t0.getNode( "c" ), true );
11651 t0.deleteSubtree( t0.getNode( "a" ), true );
11652 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
11653 t0.getNode( "b" ).setName( "Bee" );
11654 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
11657 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11660 t0.deleteSubtree( t0.getNode( "e" ), true );
11661 t0.deleteSubtree( t0.getNode( "Bee" ), true );
11662 t0.deleteSubtree( t0.getNode( "d" ), true );
11663 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11667 catch ( final Exception e ) {
11668 e.printStackTrace();
11674 private static boolean testTreeMethods() {
11676 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11677 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
11678 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
11679 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
11680 System.out.println( t0.toNewHampshireX() );
11683 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
11684 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
11685 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
11688 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
11691 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
11695 catch ( final Exception e ) {
11696 e.printStackTrace( System.out );
11702 private static boolean testUniprotEntryRetrieval() {
11704 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11705 if ( !entry.getAccession().equals( "P12345" ) ) {
11708 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11711 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11714 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11717 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11720 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11724 catch ( final IOException e ) {
11725 System.out.println();
11726 System.out.println( "the following might be due to absence internet connection:" );
11727 e.printStackTrace( System.out );
11730 catch ( final Exception e ) {
11736 private static boolean testUniprotTaxonomySearch() {
11738 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11740 if ( results.size() != 1 ) {
11743 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11746 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11749 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11752 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11755 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11759 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11760 if ( results.size() != 1 ) {
11763 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11766 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11769 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11772 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11775 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11779 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11780 if ( results.size() != 1 ) {
11783 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11786 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11789 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11792 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11795 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11799 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11800 if ( results.size() != 1 ) {
11803 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11806 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11809 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11812 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11815 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11818 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11821 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11824 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11825 .equals( "Nematostella vectensis" ) ) {
11826 System.out.println( results.get( 0 ).getLineage() );
11831 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11832 if ( results.size() != 1 ) {
11835 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11838 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11841 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11844 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11847 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11850 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11851 .equals( "Xenopus tropicalis" ) ) {
11852 System.out.println( results.get( 0 ).getLineage() );
11857 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11858 if ( results.size() != 1 ) {
11861 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11864 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11867 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11870 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11873 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11876 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11877 .equals( "Xenopus tropicalis" ) ) {
11878 System.out.println( results.get( 0 ).getLineage() );
11883 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11884 if ( results.size() != 1 ) {
11887 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11890 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11893 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11896 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11899 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11902 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11903 .equals( "Xenopus tropicalis" ) ) {
11904 System.out.println( results.get( 0 ).getLineage() );
11908 catch ( final IOException e ) {
11909 System.out.println();
11910 System.out.println( "the following might be due to absence internet connection:" );
11911 e.printStackTrace( System.out );
11914 catch ( final Exception e ) {
11920 private static boolean testWabiTxSearch() {
11922 String result = "";
11923 result = TxSearch.searchSimple( "nematostella" );
11924 result = TxSearch.getTxId( "nematostella" );
11925 if ( !result.equals( "45350" ) ) {
11928 result = TxSearch.getTxName( "45350" );
11929 if ( !result.equals( "Nematostella" ) ) {
11932 result = TxSearch.getTxId( "nematostella vectensis" );
11933 if ( !result.equals( "45351" ) ) {
11936 result = TxSearch.getTxName( "45351" );
11937 if ( !result.equals( "Nematostella vectensis" ) ) {
11940 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11941 if ( !result.equals( "536089" ) ) {
11944 result = TxSearch.getTxName( "536089" );
11945 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11948 final List<String> queries = new ArrayList<String>();
11949 queries.add( "Campylobacter coli" );
11950 queries.add( "Escherichia coli" );
11951 queries.add( "Arabidopsis" );
11952 queries.add( "Trichoplax" );
11953 queries.add( "Samanea saman" );
11954 queries.add( "Kluyveromyces marxianus" );
11955 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11956 queries.add( "Bornavirus parrot/PDD/2008" );
11957 final List<RANKS> ranks = new ArrayList<RANKS>();
11958 ranks.add( RANKS.SUPERKINGDOM );
11959 ranks.add( RANKS.KINGDOM );
11960 ranks.add( RANKS.FAMILY );
11961 ranks.add( RANKS.GENUS );
11962 ranks.add( RANKS.TRIBE );
11963 result = TxSearch.searchLineage( queries, ranks );
11964 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11965 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11967 catch ( final Exception e ) {
11968 System.out.println();
11969 System.out.println( "the following might be due to absence internet connection:" );
11970 e.printStackTrace( System.out );