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";
916 if ( !MsaInferrer.isInstalled( path ) ) {
917 path = "/usr/bin/mafft";
919 if ( !MsaInferrer.isInstalled( path ) ) {
920 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.print( "phyloXML parsing from URL: " );
962 if ( Test.testPhyloXMLparsingFromURL() ) {
963 System.out.println( "OK." );
967 System.out.println( "failed." );
970 System.out.println();
971 final Runtime rt = java.lang.Runtime.getRuntime();
972 final long free_memory = rt.freeMemory() / 1000000;
973 final long total_memory = rt.totalMemory() / 1000000;
974 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
975 + free_memory + "MB, total memory: " + total_memory + "MB)" );
976 System.out.println();
977 System.out.println( "Successful tests: " + succeeded );
978 System.out.println( "Failed tests: " + failed );
979 System.out.println();
981 System.out.println( "OK." );
984 System.out.println( "Not OK." );
988 public static boolean testEngulfingOverlapRemoval() {
990 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
991 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
992 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
993 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
994 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
995 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
996 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
997 final List<Boolean> covered = new ArrayList<Boolean>();
998 covered.add( true ); // 0
999 covered.add( false ); // 1
1000 covered.add( true ); // 2
1001 covered.add( false ); // 3
1002 covered.add( true ); // 4
1003 covered.add( true ); // 5
1004 covered.add( false ); // 6
1005 covered.add( true ); // 7
1006 covered.add( true ); // 8
1007 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1010 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1013 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1016 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1019 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1022 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1025 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1028 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1029 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1030 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1031 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1032 abc.addProteinDomain( a );
1033 abc.addProteinDomain( b );
1034 abc.addProteinDomain( c );
1035 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1036 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1037 if ( abc.getNumberOfProteinDomains() != 3 ) {
1040 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1043 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1046 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1049 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1052 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1053 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1054 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1055 final Protein def = new BasicProtein( "def", "nemve", 0 );
1056 def.addProteinDomain( d );
1057 def.addProteinDomain( e );
1058 def.addProteinDomain( f );
1059 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1060 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1061 if ( def.getNumberOfProteinDomains() != 3 ) {
1064 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1067 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1070 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1073 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1076 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1080 catch ( final Exception e ) {
1081 e.printStackTrace( System.out );
1087 public static final boolean testPhyloXMLparsingFromURL() {
1089 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1090 final URL u = new URL( s );
1091 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1092 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1093 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1097 catch ( final Exception e ) {
1098 e.printStackTrace();
1103 public static final boolean testNHXparsingFromURL() {
1105 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1106 final URL u = new URL( s );
1107 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1108 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1109 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1112 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1113 System.out.println( phys[ 0 ].toNewHampshire() );
1116 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1117 System.out.println( phys[ 1 ].toNewHampshire() );
1120 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1121 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1124 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1125 System.out.println( phys2[ 0 ].toNewHampshire() );
1128 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1129 final NHXParser p = new NHXParser();
1130 final URL u2 = new URL( s );
1132 if ( !p.hasNext() ) {
1135 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1138 if ( !p.hasNext() ) {
1142 if ( !p.hasNext() ) {
1145 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1148 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1152 if ( !p.hasNext() ) {
1155 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1158 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1162 catch ( final Exception e ) {
1163 e.printStackTrace();
1168 public static boolean testOverlapRemoval() {
1170 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1171 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1172 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1173 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1174 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1175 final List<Boolean> covered = new ArrayList<Boolean>();
1176 covered.add( true ); // 0
1177 covered.add( false ); // 1
1178 covered.add( true ); // 2
1179 covered.add( false ); // 3
1180 covered.add( true ); // 4
1181 covered.add( true ); // 5
1182 covered.add( false ); // 6
1183 covered.add( true ); // 7
1184 covered.add( true ); // 8
1185 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1188 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1191 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1194 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1197 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1200 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1201 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1202 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1203 ab.addProteinDomain( a );
1204 ab.addProteinDomain( b );
1205 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1206 if ( ab.getNumberOfProteinDomains() != 2 ) {
1209 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1212 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1215 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1216 if ( ab.getNumberOfProteinDomains() != 2 ) {
1219 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1222 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1223 final Domain d = new BasicDomain( "d",
1230 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1231 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1232 cde.addProteinDomain( c );
1233 cde.addProteinDomain( d );
1234 cde.addProteinDomain( e );
1235 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1236 if ( cde.getNumberOfProteinDomains() != 3 ) {
1239 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1242 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1243 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1244 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1245 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1246 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1247 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1248 fghi.addProteinDomain( f );
1249 fghi.addProteinDomain( g );
1250 fghi.addProteinDomain( h );
1251 fghi.addProteinDomain( i );
1252 fghi.addProteinDomain( i );
1253 fghi.addProteinDomain( i );
1254 fghi.addProteinDomain( i2 );
1255 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1256 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1259 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1262 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1265 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1266 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1269 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1272 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1273 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1274 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1275 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1276 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1277 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1278 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1279 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1280 jklm.addProteinDomain( j );
1281 jklm.addProteinDomain( k );
1282 jklm.addProteinDomain( l );
1283 jklm.addProteinDomain( m );
1284 jklm.addProteinDomain( m0 );
1285 jklm.addProteinDomain( m1 );
1286 jklm.addProteinDomain( m2 );
1287 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1288 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1291 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1294 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1297 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1298 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1301 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1304 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1305 final Protein od = new BasicProtein( "od", "varanus", 0 );
1306 od.addProteinDomain( only );
1307 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1308 if ( od.getNumberOfProteinDomains() != 1 ) {
1311 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1315 catch ( final Exception e ) {
1316 e.printStackTrace( System.out );
1322 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1323 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1327 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1328 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1331 private static boolean testAminoAcidSequence() {
1333 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1334 if ( aa1.getLength() != 13 ) {
1337 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1340 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1343 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1346 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1347 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1350 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1351 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1354 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1355 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1359 catch ( final Exception e ) {
1360 e.printStackTrace();
1366 private static boolean testBasicDomain() {
1368 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1369 if ( !pd.getDomainId().equals( "id" ) ) {
1372 if ( pd.getNumber() != 1 ) {
1375 if ( pd.getTotalCount() != 4 ) {
1378 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1381 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1382 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1383 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1384 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1385 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1386 if ( !a1.equals( a1 ) ) {
1389 if ( !a1.equals( a1_copy ) ) {
1392 if ( !a1.equals( a1_equal ) ) {
1395 if ( !a1.equals( a2 ) ) {
1398 if ( a1.equals( a3 ) ) {
1401 if ( a1.compareTo( a1 ) != 0 ) {
1404 if ( a1.compareTo( a1_copy ) != 0 ) {
1407 if ( a1.compareTo( a1_equal ) != 0 ) {
1410 if ( a1.compareTo( a2 ) != 0 ) {
1413 if ( a1.compareTo( a3 ) == 0 ) {
1417 catch ( final Exception e ) {
1418 e.printStackTrace( System.out );
1424 private static boolean testBasicNodeMethods() {
1426 if ( PhylogenyNode.getNodeCount() != 0 ) {
1429 final PhylogenyNode n1 = new PhylogenyNode();
1430 final PhylogenyNode n2 = PhylogenyNode
1431 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1432 final PhylogenyNode n3 = PhylogenyNode
1433 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1434 final PhylogenyNode n4 = PhylogenyNode
1435 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1436 if ( n1.isHasAssignedEvent() ) {
1439 if ( PhylogenyNode.getNodeCount() != 4 ) {
1442 if ( n3.getIndicator() != 0 ) {
1445 if ( n3.getNumberOfExternalNodes() != 1 ) {
1448 if ( !n3.isExternal() ) {
1451 if ( !n3.isRoot() ) {
1454 if ( !n4.getName().equals( "n4" ) ) {
1458 catch ( final Exception e ) {
1459 e.printStackTrace( System.out );
1465 private static boolean testBasicPhyloXMLparsing() {
1467 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1468 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1469 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1471 if ( xml_parser.getErrorCount() > 0 ) {
1472 System.out.println( xml_parser.getErrorMessages().toString() );
1475 if ( phylogenies_0.length != 4 ) {
1478 final Phylogeny t1 = phylogenies_0[ 0 ];
1479 final Phylogeny t2 = phylogenies_0[ 1 ];
1480 final Phylogeny t3 = phylogenies_0[ 2 ];
1481 final Phylogeny t4 = phylogenies_0[ 3 ];
1482 if ( t1.getNumberOfExternalNodes() != 1 ) {
1485 if ( !t1.isRooted() ) {
1488 if ( t1.isRerootable() ) {
1491 if ( !t1.getType().equals( "gene_tree" ) ) {
1494 if ( t2.getNumberOfExternalNodes() != 2 ) {
1497 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1500 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1503 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1506 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1509 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1512 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1515 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1516 .startsWith( "actgtgggggt" ) ) {
1519 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1520 .startsWith( "ctgtgatgcat" ) ) {
1523 if ( t3.getNumberOfExternalNodes() != 4 ) {
1526 if ( !t1.getName().equals( "t1" ) ) {
1529 if ( !t2.getName().equals( "t2" ) ) {
1532 if ( !t3.getName().equals( "t3" ) ) {
1535 if ( !t4.getName().equals( "t4" ) ) {
1538 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1541 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1544 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1547 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1548 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1551 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1554 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1557 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1560 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1561 .equals( "apoptosis" ) ) {
1564 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1565 .equals( "GO:0006915" ) ) {
1568 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1569 .equals( "UniProtKB" ) ) {
1572 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1573 .equals( "experimental" ) ) {
1576 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1577 .equals( "function" ) ) {
1580 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1581 .getValue() != 1 ) {
1584 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1585 .getType().equals( "ml" ) ) {
1588 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1589 .equals( "apoptosis" ) ) {
1592 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1593 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1596 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1597 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1600 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1601 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1604 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1605 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1608 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1609 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1612 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1613 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1616 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1617 .equals( "GO:0005829" ) ) {
1620 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1621 .equals( "intracellular organelle" ) ) {
1624 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1627 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1628 .equals( "UniProt link" ) ) ) {
1631 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1634 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1635 if ( x.size() != 4 ) {
1639 for( final Accession acc : x ) {
1641 if ( !acc.getSource().equals( "KEGG" ) ) {
1644 if ( !acc.getValue().equals( "hsa:596" ) ) {
1651 catch ( final Exception e ) {
1652 e.printStackTrace( System.out );
1658 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1660 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1661 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1662 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1663 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1666 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1668 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1670 if ( xml_parser.getErrorCount() > 0 ) {
1671 System.out.println( xml_parser.getErrorMessages().toString() );
1674 if ( phylogenies_0.length != 4 ) {
1677 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1678 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1679 if ( phylogenies_t1.length != 1 ) {
1682 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1683 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1686 if ( !t1_rt.isRooted() ) {
1689 if ( t1_rt.isRerootable() ) {
1692 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1695 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1696 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1697 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1698 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1701 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1704 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1707 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1710 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1711 .startsWith( "actgtgggggt" ) ) {
1714 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1715 .startsWith( "ctgtgatgcat" ) ) {
1718 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1719 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1720 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1721 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1722 if ( phylogenies_1.length != 1 ) {
1725 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1726 if ( !t3_rt.getName().equals( "t3" ) ) {
1729 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1732 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1735 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1738 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1741 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1742 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1745 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1748 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1751 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1752 .equals( "UniProtKB" ) ) {
1755 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1756 .equals( "apoptosis" ) ) {
1759 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1760 .equals( "GO:0006915" ) ) {
1763 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1764 .equals( "UniProtKB" ) ) {
1767 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1768 .equals( "experimental" ) ) {
1771 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1772 .equals( "function" ) ) {
1775 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1776 .getValue() != 1 ) {
1779 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1780 .getType().equals( "ml" ) ) {
1783 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1784 .equals( "apoptosis" ) ) {
1787 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1788 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1791 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1792 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1795 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1796 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1799 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1800 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1803 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1804 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1807 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1808 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1811 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1812 .equals( "GO:0005829" ) ) {
1815 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1816 .equals( "intracellular organelle" ) ) {
1819 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1822 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1823 .equals( "UniProt link" ) ) ) {
1826 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1829 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1832 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1833 .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." ) ) ) {
1836 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1839 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1842 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1845 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1848 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1849 .equals( "ncbi" ) ) {
1852 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1855 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1856 .getName().equals( "B" ) ) {
1859 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1860 .getFrom() != 21 ) {
1863 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1866 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1867 .getLength() != 24 ) {
1870 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1871 .getConfidence() != 2144 ) {
1874 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1875 .equals( "pfam" ) ) {
1878 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1881 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1884 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1887 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1890 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1891 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1894 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1897 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1900 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1903 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1906 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1909 if ( taxbb.getSynonyms().size() != 2 ) {
1912 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1915 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1918 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1921 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1924 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1927 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1928 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1931 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1934 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1937 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1940 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1943 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1946 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1949 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1953 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1956 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1957 .equalsIgnoreCase( "435" ) ) {
1960 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1963 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1964 .equalsIgnoreCase( "443.7" ) ) {
1967 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1970 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1973 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1974 .equalsIgnoreCase( "433" ) ) {
1977 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1978 .getCrossReferences();
1979 if ( x.size() != 4 ) {
1983 for( final Accession acc : x ) {
1985 if ( !acc.getSource().equals( "KEGG" ) ) {
1988 if ( !acc.getValue().equals( "hsa:596" ) ) {
1995 catch ( final Exception e ) {
1996 e.printStackTrace( System.out );
2002 private static boolean testBasicPhyloXMLparsingValidating() {
2004 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2005 PhyloXmlParser xml_parser = null;
2007 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2009 catch ( final Exception e ) {
2010 // Do nothing -- means were not running from jar.
2012 if ( xml_parser == null ) {
2013 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2014 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2015 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2018 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2021 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2023 if ( xml_parser.getErrorCount() > 0 ) {
2024 System.out.println( xml_parser.getErrorMessages().toString() );
2027 if ( phylogenies_0.length != 4 ) {
2030 final Phylogeny t1 = phylogenies_0[ 0 ];
2031 final Phylogeny t2 = phylogenies_0[ 1 ];
2032 final Phylogeny t3 = phylogenies_0[ 2 ];
2033 final Phylogeny t4 = phylogenies_0[ 3 ];
2034 if ( !t1.getName().equals( "t1" ) ) {
2037 if ( !t2.getName().equals( "t2" ) ) {
2040 if ( !t3.getName().equals( "t3" ) ) {
2043 if ( !t4.getName().equals( "t4" ) ) {
2046 if ( t1.getNumberOfExternalNodes() != 1 ) {
2049 if ( t2.getNumberOfExternalNodes() != 2 ) {
2052 if ( t3.getNumberOfExternalNodes() != 4 ) {
2055 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2056 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2057 if ( xml_parser.getErrorCount() > 0 ) {
2058 System.out.println( "errors:" );
2059 System.out.println( xml_parser.getErrorMessages().toString() );
2062 if ( phylogenies_1.length != 4 ) {
2065 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2067 if ( xml_parser.getErrorCount() > 0 ) {
2068 System.out.println( "errors:" );
2069 System.out.println( xml_parser.getErrorMessages().toString() );
2072 if ( phylogenies_2.length != 1 ) {
2075 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2078 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2080 if ( xml_parser.getErrorCount() > 0 ) {
2081 System.out.println( xml_parser.getErrorMessages().toString() );
2084 if ( phylogenies_3.length != 2 ) {
2087 final Phylogeny a = phylogenies_3[ 0 ];
2088 if ( !a.getName().equals( "tree 4" ) ) {
2091 if ( a.getNumberOfExternalNodes() != 3 ) {
2094 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2097 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2100 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2102 if ( xml_parser.getErrorCount() > 0 ) {
2103 System.out.println( xml_parser.getErrorMessages().toString() );
2106 if ( phylogenies_4.length != 1 ) {
2109 final Phylogeny s = phylogenies_4[ 0 ];
2110 if ( s.getNumberOfExternalNodes() != 6 ) {
2113 s.getNode( "first" );
2115 s.getNode( "\"<a'b&c'd\">\"" );
2116 s.getNode( "'''\"" );
2117 s.getNode( "\"\"\"" );
2118 s.getNode( "dick & doof" );
2120 catch ( final Exception e ) {
2121 e.printStackTrace( System.out );
2127 private static boolean testBasicProtein() {
2129 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2130 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2131 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2132 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2133 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2134 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2135 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2136 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2137 p0.addProteinDomain( y );
2138 p0.addProteinDomain( e );
2139 p0.addProteinDomain( b );
2140 p0.addProteinDomain( c );
2141 p0.addProteinDomain( d );
2142 p0.addProteinDomain( a );
2143 p0.addProteinDomain( x );
2144 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2147 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2151 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2152 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2153 aa0.addProteinDomain( a1 );
2154 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2157 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2161 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2162 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2163 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2164 aa1.addProteinDomain( a11 );
2165 aa1.addProteinDomain( a12 );
2166 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2169 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2172 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2173 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2176 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2179 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2182 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2183 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2186 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2189 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2192 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2195 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2196 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2199 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2202 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2205 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2208 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2209 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2212 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2215 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2218 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2222 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2223 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2224 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2225 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2226 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2227 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2228 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2229 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2230 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2231 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2232 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2233 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2234 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2235 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2236 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2237 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2238 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2239 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2240 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2241 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2242 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2243 p00.addProteinDomain( y0 );
2244 p00.addProteinDomain( e0 );
2245 p00.addProteinDomain( b0 );
2246 p00.addProteinDomain( c0 );
2247 p00.addProteinDomain( d0 );
2248 p00.addProteinDomain( a0 );
2249 p00.addProteinDomain( x0 );
2250 p00.addProteinDomain( y1 );
2251 p00.addProteinDomain( y2 );
2252 p00.addProteinDomain( y3 );
2253 p00.addProteinDomain( e1 );
2254 p00.addProteinDomain( e2 );
2255 p00.addProteinDomain( e3 );
2256 p00.addProteinDomain( e4 );
2257 p00.addProteinDomain( e5 );
2258 p00.addProteinDomain( z0 );
2259 p00.addProteinDomain( z1 );
2260 p00.addProteinDomain( z2 );
2261 p00.addProteinDomain( zz0 );
2262 p00.addProteinDomain( zz1 );
2263 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2266 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2269 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2272 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2275 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" ) ) {
2278 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2279 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2280 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2281 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2282 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2283 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2284 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2285 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2286 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2287 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2288 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2289 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2290 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2291 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2292 p.addProteinDomain( B15 );
2293 p.addProteinDomain( C50 );
2294 p.addProteinDomain( A60 );
2295 p.addProteinDomain( A30 );
2296 p.addProteinDomain( C70 );
2297 p.addProteinDomain( B35 );
2298 p.addProteinDomain( B40 );
2299 p.addProteinDomain( A0 );
2300 p.addProteinDomain( A10 );
2301 p.addProteinDomain( A20 );
2302 p.addProteinDomain( B25 );
2303 p.addProteinDomain( D80 );
2304 List<String> domains_ids = new ArrayList<String>();
2305 domains_ids.add( "A" );
2306 domains_ids.add( "B" );
2307 domains_ids.add( "C" );
2308 if ( !p.contains( domains_ids, false ) ) {
2311 if ( !p.contains( domains_ids, true ) ) {
2314 domains_ids.add( "X" );
2315 if ( p.contains( domains_ids, false ) ) {
2318 if ( p.contains( domains_ids, true ) ) {
2321 domains_ids = new ArrayList<String>();
2322 domains_ids.add( "A" );
2323 domains_ids.add( "C" );
2324 domains_ids.add( "D" );
2325 if ( !p.contains( domains_ids, false ) ) {
2328 if ( !p.contains( domains_ids, true ) ) {
2331 domains_ids = new ArrayList<String>();
2332 domains_ids.add( "A" );
2333 domains_ids.add( "D" );
2334 domains_ids.add( "C" );
2335 if ( !p.contains( domains_ids, false ) ) {
2338 if ( p.contains( domains_ids, true ) ) {
2341 domains_ids = new ArrayList<String>();
2342 domains_ids.add( "A" );
2343 domains_ids.add( "A" );
2344 domains_ids.add( "B" );
2345 if ( !p.contains( domains_ids, false ) ) {
2348 if ( !p.contains( domains_ids, true ) ) {
2351 domains_ids = new ArrayList<String>();
2352 domains_ids.add( "A" );
2353 domains_ids.add( "A" );
2354 domains_ids.add( "A" );
2355 domains_ids.add( "B" );
2356 domains_ids.add( "B" );
2357 if ( !p.contains( domains_ids, false ) ) {
2360 if ( !p.contains( domains_ids, true ) ) {
2363 domains_ids = new ArrayList<String>();
2364 domains_ids.add( "A" );
2365 domains_ids.add( "A" );
2366 domains_ids.add( "B" );
2367 domains_ids.add( "A" );
2368 domains_ids.add( "B" );
2369 domains_ids.add( "B" );
2370 domains_ids.add( "A" );
2371 domains_ids.add( "B" );
2372 domains_ids.add( "C" );
2373 domains_ids.add( "A" );
2374 domains_ids.add( "C" );
2375 domains_ids.add( "D" );
2376 if ( !p.contains( domains_ids, false ) ) {
2379 if ( p.contains( domains_ids, true ) ) {
2383 catch ( final Exception e ) {
2384 e.printStackTrace( System.out );
2390 private static boolean testBasicTable() {
2392 final BasicTable<String> t0 = new BasicTable<String>();
2393 if ( t0.getNumberOfColumns() != 0 ) {
2396 if ( t0.getNumberOfRows() != 0 ) {
2399 t0.setValue( 3, 2, "23" );
2400 t0.setValue( 10, 1, "error" );
2401 t0.setValue( 10, 1, "110" );
2402 t0.setValue( 9, 1, "19" );
2403 t0.setValue( 1, 10, "101" );
2404 t0.setValue( 10, 10, "1010" );
2405 t0.setValue( 100, 10, "10100" );
2406 t0.setValue( 0, 0, "00" );
2407 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2410 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2413 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2416 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2419 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2422 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2425 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2428 if ( t0.getNumberOfColumns() != 101 ) {
2431 if ( t0.getNumberOfRows() != 11 ) {
2434 if ( t0.getValueAsString( 49, 4 ) != null ) {
2437 final String l = ForesterUtil.getLineSeparator();
2438 final StringBuffer source = new StringBuffer();
2439 source.append( "" + l );
2440 source.append( "# 1 1 1 1 1 1 1 1" + l );
2441 source.append( " 00 01 02 03" + l );
2442 source.append( " 10 11 12 13 " + l );
2443 source.append( "20 21 22 23 " + l );
2444 source.append( " 30 31 32 33" + l );
2445 source.append( "40 41 42 43" + l );
2446 source.append( " # 1 1 1 1 1 " + l );
2447 source.append( "50 51 52 53 54" + l );
2448 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2449 if ( t1.getNumberOfColumns() != 5 ) {
2452 if ( t1.getNumberOfRows() != 6 ) {
2455 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2458 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2461 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2464 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2467 final StringBuffer source1 = new StringBuffer();
2468 source1.append( "" + l );
2469 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2470 source1.append( " 00; 01 ;02;03" + l );
2471 source1.append( " 10; 11; 12; 13 " + l );
2472 source1.append( "20; 21; 22; 23 " + l );
2473 source1.append( " 30; 31; 32; 33" + l );
2474 source1.append( "40;41;42;43" + l );
2475 source1.append( " # 1 1 1 1 1 " + l );
2476 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2477 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2478 if ( t2.getNumberOfColumns() != 5 ) {
2481 if ( t2.getNumberOfRows() != 6 ) {
2484 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2487 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2490 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2493 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2496 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2499 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2502 final StringBuffer source2 = new StringBuffer();
2503 source2.append( "" + l );
2504 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2505 source2.append( " 00; 01 ;02;03" + l );
2506 source2.append( " 10; 11; 12; 13 " + l );
2507 source2.append( "20; 21; 22; 23 " + l );
2508 source2.append( " " + l );
2509 source2.append( " 30; 31; 32; 33" + l );
2510 source2.append( "40;41;42;43" + l );
2511 source2.append( " comment: 1 1 1 1 1 " + l );
2512 source2.append( ";;;50 ; 52; 53;;54 " + l );
2513 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2519 if ( tl.size() != 2 ) {
2522 final BasicTable<String> t3 = tl.get( 0 );
2523 final BasicTable<String> t4 = tl.get( 1 );
2524 if ( t3.getNumberOfColumns() != 4 ) {
2527 if ( t3.getNumberOfRows() != 3 ) {
2530 if ( t4.getNumberOfColumns() != 4 ) {
2533 if ( t4.getNumberOfRows() != 3 ) {
2536 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2539 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2543 catch ( final Exception e ) {
2544 e.printStackTrace( System.out );
2550 private static boolean testBasicTolXMLparsing() {
2552 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2553 final TolParser parser = new TolParser();
2554 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2555 if ( parser.getErrorCount() > 0 ) {
2556 System.out.println( parser.getErrorMessages().toString() );
2559 if ( phylogenies_0.length != 1 ) {
2562 final Phylogeny t1 = phylogenies_0[ 0 ];
2563 if ( t1.getNumberOfExternalNodes() != 5 ) {
2566 if ( !t1.isRooted() ) {
2569 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2572 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2575 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2578 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2581 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2582 if ( parser.getErrorCount() > 0 ) {
2583 System.out.println( parser.getErrorMessages().toString() );
2586 if ( phylogenies_1.length != 1 ) {
2589 final Phylogeny t2 = phylogenies_1[ 0 ];
2590 if ( t2.getNumberOfExternalNodes() != 664 ) {
2593 if ( !t2.isRooted() ) {
2596 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2599 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2602 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2605 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2608 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2611 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2612 .equals( "Aquifex" ) ) {
2615 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2616 if ( parser.getErrorCount() > 0 ) {
2617 System.out.println( parser.getErrorMessages().toString() );
2620 if ( phylogenies_2.length != 1 ) {
2623 final Phylogeny t3 = phylogenies_2[ 0 ];
2624 if ( t3.getNumberOfExternalNodes() != 184 ) {
2627 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2630 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2633 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2636 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2637 if ( parser.getErrorCount() > 0 ) {
2638 System.out.println( parser.getErrorMessages().toString() );
2641 if ( phylogenies_3.length != 1 ) {
2644 final Phylogeny t4 = phylogenies_3[ 0 ];
2645 if ( t4.getNumberOfExternalNodes() != 1 ) {
2648 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2651 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2654 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2657 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2658 if ( parser.getErrorCount() > 0 ) {
2659 System.out.println( parser.getErrorMessages().toString() );
2662 if ( phylogenies_4.length != 1 ) {
2665 final Phylogeny t5 = phylogenies_4[ 0 ];
2666 if ( t5.getNumberOfExternalNodes() != 13 ) {
2669 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2672 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2675 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2679 catch ( final Exception e ) {
2680 e.printStackTrace( System.out );
2686 private static boolean testBasicTreeMethods() {
2688 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2689 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2690 if ( t2.getNumberOfExternalNodes() != 4 ) {
2693 if ( t2.getHeight() != 8.5 ) {
2696 if ( !t2.isCompletelyBinary() ) {
2699 if ( t2.isEmpty() ) {
2702 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2703 if ( t3.getNumberOfExternalNodes() != 5 ) {
2706 if ( t3.getHeight() != 11 ) {
2709 if ( t3.isCompletelyBinary() ) {
2712 final PhylogenyNode n = t3.getNode( "ABC" );
2713 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 ];
2714 if ( t4.getNumberOfExternalNodes() != 9 ) {
2717 if ( t4.getHeight() != 11 ) {
2720 if ( t4.isCompletelyBinary() ) {
2723 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)" );
2724 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2725 if ( t5.getNumberOfExternalNodes() != 8 ) {
2728 if ( t5.getHeight() != 15 ) {
2731 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)" );
2732 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2733 if ( t6.getHeight() != 15 ) {
2736 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)" );
2737 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2738 if ( t7.getHeight() != 15 ) {
2741 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)" );
2742 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2743 if ( t8.getNumberOfExternalNodes() != 10 ) {
2746 if ( t8.getHeight() != 15 ) {
2749 final char[] a9 = new char[] { 'a' };
2750 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2751 if ( t9.getHeight() != 0 ) {
2754 final char[] a10 = new char[] { 'a', ':', '6' };
2755 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2756 if ( t10.getHeight() != 6 ) {
2760 catch ( final Exception e ) {
2761 e.printStackTrace( System.out );
2767 private static boolean testConfidenceAssessor() {
2769 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2770 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2771 final Phylogeny[] ev0 = factory
2772 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2774 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2775 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2778 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2781 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2782 final Phylogeny[] ev1 = factory
2783 .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)));",
2785 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2786 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2789 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2792 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2793 final Phylogeny[] ev_b = factory
2794 .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",
2796 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2797 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2800 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2804 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2805 final Phylogeny[] ev1x = factory
2806 .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)));",
2808 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2809 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2812 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2815 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2816 final Phylogeny[] ev_bx = factory
2817 .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",
2819 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2820 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2823 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2827 final Phylogeny[] t2 = factory
2828 .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);",
2830 final Phylogeny[] ev2 = factory
2831 .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);",
2833 for( final Phylogeny target : t2 ) {
2834 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2837 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2838 new NHXParser() )[ 0 ];
2839 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2840 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2841 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2844 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2847 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2851 catch ( final Exception e ) {
2852 e.printStackTrace();
2858 private static boolean testCopyOfNodeData() {
2860 final PhylogenyNode n1 = PhylogenyNode
2861 .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]" );
2862 final PhylogenyNode n2 = n1.copyNodeData();
2863 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2867 catch ( final Exception e ) {
2868 e.printStackTrace();
2874 private static boolean testCreateBalancedPhylogeny() {
2876 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2877 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2880 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2883 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2884 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2887 if ( p1.getNumberOfExternalNodes() != 100 ) {
2891 catch ( final Exception e ) {
2892 e.printStackTrace();
2898 private static boolean testCreateUriForSeqWeb() {
2900 final PhylogenyNode n = new PhylogenyNode();
2901 n.setName( "tr|B3RJ64" );
2902 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2905 n.setName( "B0LM41_HUMAN" );
2906 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2909 n.setName( "NP_001025424" );
2910 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2913 n.setName( "_NM_001030253-" );
2914 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2917 n.setName( "XM_002122186" );
2918 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2921 n.setName( "dgh_AAA34956_gdg" );
2922 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2925 n.setName( "AAA34956" );
2926 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2929 n.setName( "GI:394892" );
2930 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2931 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2934 n.setName( "gi_394892" );
2935 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2936 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2939 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2940 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2941 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2944 n.setName( "P12345" );
2945 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2946 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2949 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2950 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2951 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2955 catch ( final Exception e ) {
2956 e.printStackTrace( System.out );
2962 private static boolean testDataObjects() {
2964 final Confidence s0 = new Confidence();
2965 final Confidence s1 = new Confidence();
2966 if ( !s0.isEqual( s1 ) ) {
2969 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2970 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2971 if ( s2.isEqual( s1 ) ) {
2974 if ( !s2.isEqual( s3 ) ) {
2977 final Confidence s4 = ( Confidence ) s3.copy();
2978 if ( !s4.isEqual( s3 ) ) {
2985 final Taxonomy t1 = new Taxonomy();
2986 final Taxonomy t2 = new Taxonomy();
2987 final Taxonomy t3 = new Taxonomy();
2988 final Taxonomy t4 = new Taxonomy();
2989 final Taxonomy t5 = new Taxonomy();
2990 t1.setIdentifier( new Identifier( "ecoli" ) );
2991 t1.setTaxonomyCode( "ECOLI" );
2992 t1.setScientificName( "E. coli" );
2993 t1.setCommonName( "coli" );
2994 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2995 if ( !t1.isEqual( t0 ) ) {
2998 t2.setIdentifier( new Identifier( "ecoli" ) );
2999 t2.setTaxonomyCode( "OTHER" );
3000 t2.setScientificName( "what" );
3001 t2.setCommonName( "something" );
3002 if ( !t1.isEqual( t2 ) ) {
3005 t2.setIdentifier( new Identifier( "nemve" ) );
3006 if ( t1.isEqual( t2 ) ) {
3009 t1.setIdentifier( null );
3010 t3.setTaxonomyCode( "ECOLI" );
3011 t3.setScientificName( "what" );
3012 t3.setCommonName( "something" );
3013 if ( !t1.isEqual( t3 ) ) {
3016 t1.setIdentifier( null );
3017 t1.setTaxonomyCode( "" );
3018 t4.setScientificName( "E. ColI" );
3019 t4.setCommonName( "something" );
3020 if ( !t1.isEqual( t4 ) ) {
3023 t4.setScientificName( "B. subtilis" );
3024 t4.setCommonName( "something" );
3025 if ( t1.isEqual( t4 ) ) {
3028 t1.setIdentifier( null );
3029 t1.setTaxonomyCode( "" );
3030 t1.setScientificName( "" );
3031 t5.setCommonName( "COLI" );
3032 if ( !t1.isEqual( t5 ) ) {
3035 t5.setCommonName( "vibrio" );
3036 if ( t1.isEqual( t5 ) ) {
3041 final Identifier id0 = new Identifier( "123", "pfam" );
3042 final Identifier id1 = ( Identifier ) id0.copy();
3043 if ( !id1.isEqual( id1 ) ) {
3046 if ( !id1.isEqual( id0 ) ) {
3049 if ( !id0.isEqual( id1 ) ) {
3056 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3057 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3058 if ( !pd1.isEqual( pd1 ) ) {
3061 if ( !pd1.isEqual( pd0 ) ) {
3066 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3067 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3068 if ( !pd3.isEqual( pd3 ) ) {
3071 if ( !pd2.isEqual( pd3 ) ) {
3074 if ( !pd0.isEqual( pd3 ) ) {
3079 // DomainArchitecture
3080 // ------------------
3081 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3082 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3083 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3084 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3085 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3086 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3091 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3092 if ( ds0.getNumberOfDomains() != 4 ) {
3095 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3096 if ( !ds0.isEqual( ds0 ) ) {
3099 if ( !ds0.isEqual( ds1 ) ) {
3102 if ( ds1.getNumberOfDomains() != 4 ) {
3105 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3110 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3111 if ( ds0.isEqual( ds2 ) ) {
3117 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3118 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3119 System.out.println( ds3.toNHX() );
3122 if ( ds3.getNumberOfDomains() != 3 ) {
3127 final Event e1 = new Event( Event.EventType.fusion );
3128 if ( e1.isDuplication() ) {
3131 if ( !e1.isFusion() ) {
3134 if ( !e1.asText().toString().equals( "fusion" ) ) {
3137 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3140 final Event e11 = new Event( Event.EventType.fusion );
3141 if ( !e11.isEqual( e1 ) ) {
3144 if ( !e11.toNHX().toString().equals( "" ) ) {
3147 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3148 if ( e2.isDuplication() ) {
3151 if ( !e2.isSpeciationOrDuplication() ) {
3154 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3157 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3160 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3163 if ( e11.isEqual( e2 ) ) {
3166 final Event e2c = ( Event ) e2.copy();
3167 if ( !e2c.isEqual( e2 ) ) {
3170 Event e3 = new Event( 1, 2, 3 );
3171 if ( e3.isDuplication() ) {
3174 if ( e3.isSpeciation() ) {
3177 if ( e3.isGeneLoss() ) {
3180 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3183 final Event e3c = ( Event ) e3.copy();
3184 final Event e3cc = ( Event ) e3c.copy();
3185 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3189 if ( !e3c.isEqual( e3cc ) ) {
3192 Event e4 = new Event( 1, 2, 3 );
3193 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3196 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3199 final Event e4c = ( Event ) e4.copy();
3201 final Event e4cc = ( Event ) e4c.copy();
3202 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3205 if ( !e4c.isEqual( e4cc ) ) {
3208 final Event e5 = new Event();
3209 if ( !e5.isUnassigned() ) {
3212 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3215 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3218 final Event e6 = new Event( 1, 0, 0 );
3219 if ( !e6.asText().toString().equals( "duplication" ) ) {
3222 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3225 final Event e7 = new Event( 0, 1, 0 );
3226 if ( !e7.asText().toString().equals( "speciation" ) ) {
3229 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3232 final Event e8 = new Event( 0, 0, 1 );
3233 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3236 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3240 catch ( final Exception e ) {
3241 e.printStackTrace( System.out );
3247 private static boolean testDeletionOfExternalNodes() {
3249 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3250 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3251 final PhylogenyWriter w = new PhylogenyWriter();
3252 if ( t0.isEmpty() ) {
3255 if ( t0.getNumberOfExternalNodes() != 1 ) {
3258 t0.deleteSubtree( t0.getNode( "A" ), false );
3259 if ( t0.getNumberOfExternalNodes() != 0 ) {
3262 if ( !t0.isEmpty() ) {
3265 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3266 if ( t1.getNumberOfExternalNodes() != 2 ) {
3269 t1.deleteSubtree( t1.getNode( "A" ), false );
3270 if ( t1.getNumberOfExternalNodes() != 1 ) {
3273 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3276 t1.deleteSubtree( t1.getNode( "B" ), false );
3277 if ( t1.getNumberOfExternalNodes() != 1 ) {
3280 t1.deleteSubtree( t1.getNode( "r" ), false );
3281 if ( !t1.isEmpty() ) {
3284 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3285 if ( t2.getNumberOfExternalNodes() != 3 ) {
3288 t2.deleteSubtree( t2.getNode( "B" ), false );
3289 if ( t2.getNumberOfExternalNodes() != 2 ) {
3292 t2.toNewHampshireX();
3293 PhylogenyNode n = t2.getNode( "A" );
3294 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3297 t2.deleteSubtree( t2.getNode( "A" ), false );
3298 if ( t2.getNumberOfExternalNodes() != 2 ) {
3301 t2.deleteSubtree( t2.getNode( "C" ), true );
3302 if ( t2.getNumberOfExternalNodes() != 1 ) {
3305 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3306 if ( t3.getNumberOfExternalNodes() != 4 ) {
3309 t3.deleteSubtree( t3.getNode( "B" ), true );
3310 if ( t3.getNumberOfExternalNodes() != 3 ) {
3313 n = t3.getNode( "A" );
3314 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3317 n = n.getNextExternalNode();
3318 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3321 t3.deleteSubtree( t3.getNode( "A" ), true );
3322 if ( t3.getNumberOfExternalNodes() != 2 ) {
3325 n = t3.getNode( "C" );
3326 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3329 t3.deleteSubtree( t3.getNode( "C" ), true );
3330 if ( t3.getNumberOfExternalNodes() != 1 ) {
3333 t3.deleteSubtree( t3.getNode( "D" ), true );
3334 if ( t3.getNumberOfExternalNodes() != 0 ) {
3337 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3338 if ( t4.getNumberOfExternalNodes() != 6 ) {
3341 t4.deleteSubtree( t4.getNode( "B2" ), true );
3342 if ( t4.getNumberOfExternalNodes() != 5 ) {
3345 String s = w.toNewHampshire( t4, false, true ).toString();
3346 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3349 t4.deleteSubtree( t4.getNode( "B11" ), true );
3350 if ( t4.getNumberOfExternalNodes() != 4 ) {
3353 t4.deleteSubtree( t4.getNode( "C" ), true );
3354 if ( t4.getNumberOfExternalNodes() != 3 ) {
3357 n = t4.getNode( "A" );
3358 n = n.getNextExternalNode();
3359 if ( !n.getName().equals( "B12" ) ) {
3362 n = n.getNextExternalNode();
3363 if ( !n.getName().equals( "D" ) ) {
3366 s = w.toNewHampshire( t4, false, true ).toString();
3367 if ( !s.equals( "((A,B12),D);" ) ) {
3370 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3371 t5.deleteSubtree( t5.getNode( "A" ), true );
3372 if ( t5.getNumberOfExternalNodes() != 5 ) {
3375 s = w.toNewHampshire( t5, false, true ).toString();
3376 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3379 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3380 t6.deleteSubtree( t6.getNode( "B11" ), true );
3381 if ( t6.getNumberOfExternalNodes() != 5 ) {
3384 s = w.toNewHampshire( t6, false, false ).toString();
3385 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3388 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3389 t7.deleteSubtree( t7.getNode( "B12" ), true );
3390 if ( t7.getNumberOfExternalNodes() != 5 ) {
3393 s = w.toNewHampshire( t7, false, true ).toString();
3394 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3397 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3398 t8.deleteSubtree( t8.getNode( "B2" ), true );
3399 if ( t8.getNumberOfExternalNodes() != 5 ) {
3402 s = w.toNewHampshire( t8, false, false ).toString();
3403 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3406 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3407 t9.deleteSubtree( t9.getNode( "C" ), true );
3408 if ( t9.getNumberOfExternalNodes() != 5 ) {
3411 s = w.toNewHampshire( t9, false, true ).toString();
3412 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3415 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3416 t10.deleteSubtree( t10.getNode( "D" ), true );
3417 if ( t10.getNumberOfExternalNodes() != 5 ) {
3420 s = w.toNewHampshire( t10, false, true ).toString();
3421 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3424 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3425 t11.deleteSubtree( t11.getNode( "A" ), true );
3426 if ( t11.getNumberOfExternalNodes() != 2 ) {
3429 s = w.toNewHampshire( t11, false, true ).toString();
3430 if ( !s.equals( "(B,C);" ) ) {
3433 t11.deleteSubtree( t11.getNode( "C" ), true );
3434 if ( t11.getNumberOfExternalNodes() != 1 ) {
3437 s = w.toNewHampshire( t11, false, false ).toString();
3438 if ( !s.equals( "B;" ) ) {
3441 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3442 t12.deleteSubtree( t12.getNode( "B2" ), true );
3443 if ( t12.getNumberOfExternalNodes() != 8 ) {
3446 s = w.toNewHampshire( t12, false, true ).toString();
3447 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3450 t12.deleteSubtree( t12.getNode( "B3" ), true );
3451 if ( t12.getNumberOfExternalNodes() != 7 ) {
3454 s = w.toNewHampshire( t12, false, true ).toString();
3455 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3458 t12.deleteSubtree( t12.getNode( "C3" ), true );
3459 if ( t12.getNumberOfExternalNodes() != 6 ) {
3462 s = w.toNewHampshire( t12, false, true ).toString();
3463 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3466 t12.deleteSubtree( t12.getNode( "A1" ), true );
3467 if ( t12.getNumberOfExternalNodes() != 5 ) {
3470 s = w.toNewHampshire( t12, false, true ).toString();
3471 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3474 t12.deleteSubtree( t12.getNode( "B1" ), true );
3475 if ( t12.getNumberOfExternalNodes() != 4 ) {
3478 s = w.toNewHampshire( t12, false, true ).toString();
3479 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3482 t12.deleteSubtree( t12.getNode( "A3" ), true );
3483 if ( t12.getNumberOfExternalNodes() != 3 ) {
3486 s = w.toNewHampshire( t12, false, true ).toString();
3487 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3490 t12.deleteSubtree( t12.getNode( "A2" ), true );
3491 if ( t12.getNumberOfExternalNodes() != 2 ) {
3494 s = w.toNewHampshire( t12, false, true ).toString();
3495 if ( !s.equals( "(C1,C2);" ) ) {
3498 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3499 t13.deleteSubtree( t13.getNode( "D" ), true );
3500 if ( t13.getNumberOfExternalNodes() != 4 ) {
3503 s = w.toNewHampshire( t13, false, true ).toString();
3504 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3507 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3508 t14.deleteSubtree( t14.getNode( "E" ), true );
3509 if ( t14.getNumberOfExternalNodes() != 5 ) {
3512 s = w.toNewHampshire( t14, false, true ).toString();
3513 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3516 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3517 t15.deleteSubtree( t15.getNode( "B2" ), true );
3518 if ( t15.getNumberOfExternalNodes() != 11 ) {
3521 t15.deleteSubtree( t15.getNode( "B1" ), true );
3522 if ( t15.getNumberOfExternalNodes() != 10 ) {
3525 t15.deleteSubtree( t15.getNode( "B3" ), true );
3526 if ( t15.getNumberOfExternalNodes() != 9 ) {
3529 t15.deleteSubtree( t15.getNode( "B4" ), true );
3530 if ( t15.getNumberOfExternalNodes() != 8 ) {
3533 t15.deleteSubtree( t15.getNode( "A1" ), true );
3534 if ( t15.getNumberOfExternalNodes() != 7 ) {
3537 t15.deleteSubtree( t15.getNode( "C4" ), true );
3538 if ( t15.getNumberOfExternalNodes() != 6 ) {
3542 catch ( final Exception e ) {
3543 e.printStackTrace( System.out );
3549 private static boolean testDescriptiveStatistics() {
3551 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3552 dss1.addValue( 82 );
3553 dss1.addValue( 78 );
3554 dss1.addValue( 70 );
3555 dss1.addValue( 58 );
3556 dss1.addValue( 42 );
3557 if ( dss1.getN() != 5 ) {
3560 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3563 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3566 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3569 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3572 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3575 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3578 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3581 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3584 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3587 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3590 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3593 dss1.addValue( 123 );
3594 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3597 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3600 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3603 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3604 dss2.addValue( -1.85 );
3605 dss2.addValue( 57.5 );
3606 dss2.addValue( 92.78 );
3607 dss2.addValue( 57.78 );
3608 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3611 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3614 final double[] a = dss2.getDataAsDoubleArray();
3615 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3618 dss2.addValue( -100 );
3619 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3622 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3625 final double[] ds = new double[ 14 ];
3640 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3641 if ( bins.length != 4 ) {
3644 if ( bins[ 0 ] != 2 ) {
3647 if ( bins[ 1 ] != 3 ) {
3650 if ( bins[ 2 ] != 4 ) {
3653 if ( bins[ 3 ] != 5 ) {
3656 final double[] ds1 = new double[ 9 ];
3666 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3667 if ( bins1.length != 4 ) {
3670 if ( bins1[ 0 ] != 2 ) {
3673 if ( bins1[ 1 ] != 3 ) {
3676 if ( bins1[ 2 ] != 0 ) {
3679 if ( bins1[ 3 ] != 4 ) {
3682 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3683 if ( bins1_1.length != 3 ) {
3686 if ( bins1_1[ 0 ] != 3 ) {
3689 if ( bins1_1[ 1 ] != 2 ) {
3692 if ( bins1_1[ 2 ] != 4 ) {
3695 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3696 if ( bins1_2.length != 3 ) {
3699 if ( bins1_2[ 0 ] != 2 ) {
3702 if ( bins1_2[ 1 ] != 2 ) {
3705 if ( bins1_2[ 2 ] != 2 ) {
3708 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3722 dss3.addValue( 10 );
3723 dss3.addValue( 10 );
3724 dss3.addValue( 10 );
3725 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3726 histo.toStringBuffer( 10, '=', 40, 5 );
3727 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3729 catch ( final Exception e ) {
3730 e.printStackTrace( System.out );
3736 private static boolean testDir( final String file ) {
3738 final File f = new File( file );
3739 if ( !f.exists() ) {
3742 if ( !f.isDirectory() ) {
3745 if ( !f.canRead() ) {
3749 catch ( final Exception e ) {
3755 private static boolean testEbiEntryRetrieval() {
3757 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3758 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3759 System.out.println( entry.getAccession() );
3762 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3763 System.out.println( entry.getTaxonomyScientificName() );
3766 if ( !entry.getSequenceName()
3767 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3768 System.out.println( entry.getSequenceName() );
3771 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3772 // System.out.println( entry.getSequenceSymbol() );
3775 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3776 System.out.println( entry.getGeneName() );
3779 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3780 System.out.println( entry.getTaxonomyIdentifier() );
3783 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3784 System.out.println( entry.getAnnotations().first().getRefValue() );
3787 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3788 System.out.println( entry.getAnnotations().first().getRefSource() );
3791 if ( entry.getCrossReferences().size() != 5 ) {
3795 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3796 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3799 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3800 System.out.println( entry1.getTaxonomyScientificName() );
3803 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3804 System.out.println( entry1.getSequenceName() );
3807 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3808 System.out.println( entry1.getTaxonomyIdentifier() );
3811 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3812 System.out.println( entry1.getGeneName() );
3815 if ( entry1.getCrossReferences().size() != 6 ) {
3819 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3820 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3823 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3824 System.out.println( entry2.getTaxonomyScientificName() );
3827 if ( !entry2.getSequenceName()
3828 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3829 System.out.println( entry2.getSequenceName() );
3832 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3833 System.out.println( entry2.getTaxonomyIdentifier() );
3836 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3837 System.out.println( entry2.getGeneName() );
3840 if ( entry2.getCrossReferences().size() != 3 ) {
3844 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3845 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3848 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3849 System.out.println( entry3.getTaxonomyScientificName() );
3852 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3853 System.out.println( entry3.getSequenceName() );
3856 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3857 System.out.println( entry3.getTaxonomyIdentifier() );
3860 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3861 System.out.println( entry3.getSequenceSymbol() );
3864 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3867 if ( entry3.getCrossReferences().size() != 8 ) {
3872 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3873 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
3876 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3877 System.out.println( entry4.getTaxonomyScientificName() );
3880 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
3881 System.out.println( entry4.getSequenceName() );
3884 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
3885 System.out.println( entry4.getTaxonomyIdentifier() );
3888 if ( !entry4.getGeneName().equals( "ras" ) ) {
3889 System.out.println( entry4.getGeneName() );
3892 // if ( !entry4.getChromosome().equals( "ras" ) ) {
3893 // System.out.println( entry4.getChromosome() );
3896 // if ( !entry4.getMap().equals( "ras" ) ) {
3897 // System.out.println( entry4.getMap() );
3903 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
3904 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
3907 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
3908 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
3911 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
3912 System.out.println( entry5.getTaxonomyScientificName() );
3915 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
3916 System.out.println( entry5.getSequenceName() );
3919 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
3920 System.out.println( entry5.getTaxonomyIdentifier() );
3924 catch ( final IOException e ) {
3925 System.out.println();
3926 System.out.println( "the following might be due to absence internet connection:" );
3927 e.printStackTrace( System.out );
3930 catch ( final Exception e ) {
3931 e.printStackTrace();
3937 private static boolean testExternalNodeRelatedMethods() {
3939 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3940 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3941 PhylogenyNode n = t1.getNode( "A" );
3942 n = n.getNextExternalNode();
3943 if ( !n.getName().equals( "B" ) ) {
3946 n = n.getNextExternalNode();
3947 if ( !n.getName().equals( "C" ) ) {
3950 n = n.getNextExternalNode();
3951 if ( !n.getName().equals( "D" ) ) {
3954 n = t1.getNode( "B" );
3955 while ( !n.isLastExternalNode() ) {
3956 n = n.getNextExternalNode();
3958 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3959 n = t2.getNode( "A" );
3960 n = n.getNextExternalNode();
3961 if ( !n.getName().equals( "B" ) ) {
3964 n = n.getNextExternalNode();
3965 if ( !n.getName().equals( "C" ) ) {
3968 n = n.getNextExternalNode();
3969 if ( !n.getName().equals( "D" ) ) {
3972 n = t2.getNode( "B" );
3973 while ( !n.isLastExternalNode() ) {
3974 n = n.getNextExternalNode();
3976 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3977 n = t3.getNode( "A" );
3978 n = n.getNextExternalNode();
3979 if ( !n.getName().equals( "B" ) ) {
3982 n = n.getNextExternalNode();
3983 if ( !n.getName().equals( "C" ) ) {
3986 n = n.getNextExternalNode();
3987 if ( !n.getName().equals( "D" ) ) {
3990 n = n.getNextExternalNode();
3991 if ( !n.getName().equals( "E" ) ) {
3994 n = n.getNextExternalNode();
3995 if ( !n.getName().equals( "F" ) ) {
3998 n = n.getNextExternalNode();
3999 if ( !n.getName().equals( "G" ) ) {
4002 n = n.getNextExternalNode();
4003 if ( !n.getName().equals( "H" ) ) {
4006 n = t3.getNode( "B" );
4007 while ( !n.isLastExternalNode() ) {
4008 n = n.getNextExternalNode();
4010 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4011 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4012 final PhylogenyNode node = iter.next();
4014 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4015 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4016 final PhylogenyNode node = iter.next();
4018 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4019 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4020 if ( !iter.next().getName().equals( "A" ) ) {
4023 if ( !iter.next().getName().equals( "B" ) ) {
4026 if ( !iter.next().getName().equals( "C" ) ) {
4029 if ( !iter.next().getName().equals( "D" ) ) {
4032 if ( !iter.next().getName().equals( "E" ) ) {
4035 if ( !iter.next().getName().equals( "F" ) ) {
4038 if ( iter.hasNext() ) {
4042 catch ( final Exception e ) {
4043 e.printStackTrace( System.out );
4049 private static boolean testExtractSNFromNodeName() {
4051 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4054 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
4055 .equals( "Mus musculus musculus" ) ) {
4058 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
4059 .equals( "Mus musculus musculus" ) ) {
4062 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
4065 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
4066 .equals( "Mus musculus" ) ) {
4070 catch ( final Exception e ) {
4071 e.printStackTrace( System.out );
4077 private static boolean testExtractTaxonomyCodeFromNodeName() {
4079 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4082 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4083 .equals( "SOYBN" ) ) {
4086 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4087 .equals( "ARATH" ) ) {
4090 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4091 .equals( "ARATH" ) ) {
4094 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4097 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4100 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4103 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4104 .equals( "SOYBN" ) ) {
4107 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4108 .equals( "SOYBN" ) ) {
4111 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4112 .equals( "SOYBN" ) ) {
4115 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4116 .equals( "SOYBN" ) ) {
4119 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4120 .equals( "SOYBN" ) ) {
4123 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4124 .equals( "SOYBN" ) ) {
4127 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4128 .equals( "SOYBN" ) ) {
4131 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4132 .equals( "SOYBN" ) ) {
4135 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4138 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4139 .equals( "SOYBN" ) ) {
4142 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4143 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4146 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4147 .equals( "9YX45" ) ) {
4150 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4151 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4152 .equals( "MOUSE" ) ) {
4155 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4156 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4157 .equals( "MOUSE" ) ) {
4160 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4161 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4162 .equals( "MOUSE" ) ) {
4165 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4166 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4169 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4170 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4173 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4174 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4177 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4178 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4181 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4182 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4185 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4186 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4189 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4190 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4193 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4194 .equals( "RAT" ) ) {
4197 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4198 .equals( "PIG" ) ) {
4202 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4203 .equals( "MOUSE" ) ) {
4206 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4207 .equals( "MOUSE" ) ) {
4210 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4214 catch ( final Exception e ) {
4215 e.printStackTrace( System.out );
4221 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4223 PhylogenyNode n = new PhylogenyNode();
4224 n.setName( "tr|B3RJ64" );
4225 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4228 n.setName( "tr.B3RJ64" );
4229 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4232 n.setName( "tr=B3RJ64" );
4233 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4236 n.setName( "tr-B3RJ64" );
4237 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4240 n.setName( "tr/B3RJ64" );
4241 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4244 n.setName( "tr\\B3RJ64" );
4245 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4248 n.setName( "tr_B3RJ64" );
4249 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4252 n.setName( " tr|B3RJ64 " );
4253 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4256 n.setName( "-tr|B3RJ64-" );
4257 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4260 n.setName( "-tr=B3RJ64-" );
4261 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4264 n.setName( "_tr=B3RJ64_" );
4265 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4268 n.setName( " tr_tr|B3RJ64_sp|123 " );
4269 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4272 n.setName( "B3RJ64" );
4273 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4276 n.setName( "sp|B3RJ64" );
4277 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4280 n.setName( "sp|B3RJ64C" );
4281 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4284 n.setName( "sp B3RJ64" );
4285 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4288 n.setName( "sp|B3RJ6X" );
4289 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4292 n.setName( "sp|B3RJ6" );
4293 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4296 n.setName( "K1PYK7_CRAGI" );
4297 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4300 n.setName( "K1PYK7_PEA" );
4301 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4304 n.setName( "K1PYK7_RAT" );
4305 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4308 n.setName( "K1PYK7_PIG" );
4309 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4312 n.setName( "~K1PYK7_PIG~" );
4313 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4316 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4317 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4320 n.setName( "K1PYKX_CRAGI" );
4321 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4324 n.setName( "XXXXX_CRAGI" );
4325 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4328 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4329 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4332 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4333 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4336 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4337 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4340 n = new PhylogenyNode();
4341 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4342 seq.setSymbol( "K1PYK7_CRAGI" );
4343 n.getNodeData().addSequence( seq );
4344 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4347 seq.setSymbol( "tr|B3RJ64" );
4348 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4351 n = new PhylogenyNode();
4352 seq = new org.forester.phylogeny.data.Sequence();
4353 seq.setName( "K1PYK7_CRAGI" );
4354 n.getNodeData().addSequence( seq );
4355 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4358 seq.setName( "tr|B3RJ64" );
4359 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4362 n = new PhylogenyNode();
4363 seq = new org.forester.phylogeny.data.Sequence();
4364 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4365 n.getNodeData().addSequence( seq );
4366 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4369 n = new PhylogenyNode();
4370 seq = new org.forester.phylogeny.data.Sequence();
4371 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4372 n.getNodeData().addSequence( seq );
4373 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4377 n = new PhylogenyNode();
4378 n.setName( "ACP19736" );
4379 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4382 n = new PhylogenyNode();
4383 n.setName( "|ACP19736|" );
4384 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4388 catch ( final Exception e ) {
4389 e.printStackTrace( System.out );
4395 private static boolean testFastaParser() {
4397 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4400 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4403 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4404 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4407 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4410 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4413 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4416 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4419 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4423 catch ( final Exception e ) {
4424 e.printStackTrace();
4430 private static boolean testGenbankAccessorParsing() {
4431 //The format for GenBank Accession numbers are:
4432 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4433 //Protein: 3 letters + 5 numerals
4434 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4435 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4438 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4441 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4444 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4447 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4450 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4453 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4456 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4459 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4462 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4465 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4468 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4471 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4474 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4480 private static boolean testGeneralMsaParser() {
4482 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4483 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4484 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4485 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4486 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4487 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4488 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4489 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4490 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4493 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4496 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4499 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4502 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4505 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4508 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4511 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4514 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4517 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4520 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4523 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4526 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4527 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4530 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4533 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4536 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4537 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4540 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4543 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4546 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4547 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4550 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4553 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4557 catch ( final Exception e ) {
4558 e.printStackTrace();
4564 private static boolean testGeneralTable() {
4566 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4567 t0.setValue( 3, 2, "23" );
4568 t0.setValue( 10, 1, "error" );
4569 t0.setValue( 10, 1, "110" );
4570 t0.setValue( 9, 1, "19" );
4571 t0.setValue( 1, 10, "101" );
4572 t0.setValue( 10, 10, "1010" );
4573 t0.setValue( 100, 10, "10100" );
4574 t0.setValue( 0, 0, "00" );
4575 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4578 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4581 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4584 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4587 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4590 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4593 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4596 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4599 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4602 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4603 t1.setValue( "3", "2", "23" );
4604 t1.setValue( "10", "1", "error" );
4605 t1.setValue( "10", "1", "110" );
4606 t1.setValue( "9", "1", "19" );
4607 t1.setValue( "1", "10", "101" );
4608 t1.setValue( "10", "10", "1010" );
4609 t1.setValue( "100", "10", "10100" );
4610 t1.setValue( "0", "0", "00" );
4611 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4612 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4615 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4618 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4621 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4624 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4627 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4630 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4633 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4636 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4639 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4643 catch ( final Exception e ) {
4644 e.printStackTrace( System.out );
4650 private static boolean testGetDistance() {
4652 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4653 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",
4654 new NHXParser() )[ 0 ];
4655 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4658 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4661 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4664 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4667 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4670 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4673 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4676 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4679 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4682 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4685 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4688 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4691 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4694 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4697 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4700 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4703 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4706 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4709 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4712 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4715 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4718 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4721 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4724 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4727 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4730 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4733 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4736 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4739 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4742 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4745 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4748 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",
4749 new NHXParser() )[ 0 ];
4750 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4753 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4756 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4759 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4762 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4765 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4768 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4771 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4774 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4777 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4780 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4784 catch ( final Exception e ) {
4785 e.printStackTrace( System.out );
4791 private static boolean testGetLCA() {
4793 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4794 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4795 new NHXParser() )[ 0 ];
4796 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4797 if ( !A.getName().equals( "A" ) ) {
4800 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4801 if ( !gh.getName().equals( "gh" ) ) {
4804 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4805 if ( !ab.getName().equals( "ab" ) ) {
4808 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4809 if ( !ab2.getName().equals( "ab" ) ) {
4812 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4813 if ( !gh2.getName().equals( "gh" ) ) {
4816 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4817 if ( !gh3.getName().equals( "gh" ) ) {
4820 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4821 if ( !abc.getName().equals( "abc" ) ) {
4824 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4825 if ( !abc2.getName().equals( "abc" ) ) {
4828 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4829 if ( !abcd.getName().equals( "abcd" ) ) {
4832 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4833 if ( !abcd2.getName().equals( "abcd" ) ) {
4836 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4837 if ( !abcdef.getName().equals( "abcdef" ) ) {
4840 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4841 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4844 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4845 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4848 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4849 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4852 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4853 if ( !abcde.getName().equals( "abcde" ) ) {
4856 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4857 if ( !abcde2.getName().equals( "abcde" ) ) {
4860 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4861 if ( !r.getName().equals( "abcdefgh" ) ) {
4864 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4865 if ( !r2.getName().equals( "abcdefgh" ) ) {
4868 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4869 if ( !r3.getName().equals( "abcdefgh" ) ) {
4872 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4873 if ( !abcde3.getName().equals( "abcde" ) ) {
4876 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4877 if ( !abcde4.getName().equals( "abcde" ) ) {
4880 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4881 if ( !ab3.getName().equals( "ab" ) ) {
4884 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4885 if ( !ab4.getName().equals( "ab" ) ) {
4888 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4889 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4890 if ( !cd.getName().equals( "cd" ) ) {
4893 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4894 if ( !cd2.getName().equals( "cd" ) ) {
4897 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4898 if ( !cde.getName().equals( "cde" ) ) {
4901 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4902 if ( !cde2.getName().equals( "cde" ) ) {
4905 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4906 if ( !cdef.getName().equals( "cdef" ) ) {
4909 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4910 if ( !cdef2.getName().equals( "cdef" ) ) {
4913 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4914 if ( !cdef3.getName().equals( "cdef" ) ) {
4917 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4918 if ( !rt.getName().equals( "r" ) ) {
4921 final Phylogeny p3 = factory
4922 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4923 new NHXParser() )[ 0 ];
4924 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4925 if ( !bc_3.getName().equals( "bc" ) ) {
4928 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4929 if ( !ac_3.getName().equals( "abc" ) ) {
4932 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4933 if ( !ad_3.getName().equals( "abcde" ) ) {
4936 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4937 if ( !af_3.getName().equals( "abcdef" ) ) {
4940 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4941 if ( !ag_3.getName().equals( "" ) ) {
4944 if ( !ag_3.isRoot() ) {
4947 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4948 if ( !al_3.getName().equals( "" ) ) {
4951 if ( !al_3.isRoot() ) {
4954 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4955 if ( !kl_3.getName().equals( "" ) ) {
4958 if ( !kl_3.isRoot() ) {
4961 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4962 if ( !fl_3.getName().equals( "" ) ) {
4965 if ( !fl_3.isRoot() ) {
4968 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4969 if ( !gk_3.getName().equals( "ghijk" ) ) {
4972 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4973 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4974 if ( !r_4.getName().equals( "r" ) ) {
4977 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4978 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4979 if ( !r_5.getName().equals( "root" ) ) {
4982 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4983 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4984 if ( !r_6.getName().equals( "rot" ) ) {
4987 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4988 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4989 if ( !r_7.getName().equals( "rott" ) ) {
4993 catch ( final Exception e ) {
4994 e.printStackTrace( System.out );
5000 private static boolean testGetLCA2() {
5002 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5003 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5004 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5005 PhylogenyMethods.preOrderReId( p_a );
5006 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5007 p_a.getNode( "a" ) );
5008 if ( !p_a_1.getName().equals( "a" ) ) {
5011 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5012 PhylogenyMethods.preOrderReId( p_b );
5013 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5014 p_b.getNode( "a" ) );
5015 if ( !p_b_1.getName().equals( "b" ) ) {
5018 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5019 p_b.getNode( "b" ) );
5020 if ( !p_b_2.getName().equals( "b" ) ) {
5023 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5024 PhylogenyMethods.preOrderReId( p_c );
5025 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5026 p_c.getNode( "a" ) );
5027 if ( !p_c_1.getName().equals( "b" ) ) {
5030 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5031 p_c.getNode( "c" ) );
5032 if ( !p_c_2.getName().equals( "c" ) ) {
5033 System.out.println( p_c_2.getName() );
5037 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5038 p_c.getNode( "b" ) );
5039 if ( !p_c_3.getName().equals( "b" ) ) {
5042 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5043 p_c.getNode( "a" ) );
5044 if ( !p_c_4.getName().equals( "c" ) ) {
5047 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5048 new NHXParser() )[ 0 ];
5049 PhylogenyMethods.preOrderReId( p1 );
5050 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5051 p1.getNode( "A" ) );
5052 if ( !A.getName().equals( "A" ) ) {
5055 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5056 p1.getNode( "gh" ) );
5057 if ( !gh.getName().equals( "gh" ) ) {
5060 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5061 p1.getNode( "B" ) );
5062 if ( !ab.getName().equals( "ab" ) ) {
5065 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5066 p1.getNode( "A" ) );
5067 if ( !ab2.getName().equals( "ab" ) ) {
5070 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5071 p1.getNode( "G" ) );
5072 if ( !gh2.getName().equals( "gh" ) ) {
5075 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5076 p1.getNode( "H" ) );
5077 if ( !gh3.getName().equals( "gh" ) ) {
5080 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5081 p1.getNode( "A" ) );
5082 if ( !abc.getName().equals( "abc" ) ) {
5085 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5086 p1.getNode( "C" ) );
5087 if ( !abc2.getName().equals( "abc" ) ) {
5090 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5091 p1.getNode( "D" ) );
5092 if ( !abcd.getName().equals( "abcd" ) ) {
5095 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5096 p1.getNode( "A" ) );
5097 if ( !abcd2.getName().equals( "abcd" ) ) {
5100 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5101 p1.getNode( "F" ) );
5102 if ( !abcdef.getName().equals( "abcdef" ) ) {
5105 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5106 p1.getNode( "A" ) );
5107 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5110 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5111 p1.getNode( "F" ) );
5112 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5115 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5116 p1.getNode( "ab" ) );
5117 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5120 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5121 p1.getNode( "E" ) );
5122 if ( !abcde.getName().equals( "abcde" ) ) {
5125 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5126 p1.getNode( "A" ) );
5127 if ( !abcde2.getName().equals( "abcde" ) ) {
5130 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5131 p1.getNode( "abcdefgh" ) );
5132 if ( !r.getName().equals( "abcdefgh" ) ) {
5135 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5136 p1.getNode( "H" ) );
5137 if ( !r2.getName().equals( "abcdefgh" ) ) {
5140 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5141 p1.getNode( "A" ) );
5142 if ( !r3.getName().equals( "abcdefgh" ) ) {
5145 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5146 p1.getNode( "abcde" ) );
5147 if ( !abcde3.getName().equals( "abcde" ) ) {
5150 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5151 p1.getNode( "E" ) );
5152 if ( !abcde4.getName().equals( "abcde" ) ) {
5155 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5156 p1.getNode( "B" ) );
5157 if ( !ab3.getName().equals( "ab" ) ) {
5160 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5161 p1.getNode( "ab" ) );
5162 if ( !ab4.getName().equals( "ab" ) ) {
5165 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5166 PhylogenyMethods.preOrderReId( p2 );
5167 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5168 p2.getNode( "d" ) );
5169 if ( !cd.getName().equals( "cd" ) ) {
5172 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5173 p2.getNode( "c" ) );
5174 if ( !cd2.getName().equals( "cd" ) ) {
5177 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5178 p2.getNode( "e" ) );
5179 if ( !cde.getName().equals( "cde" ) ) {
5182 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5183 p2.getNode( "c" ) );
5184 if ( !cde2.getName().equals( "cde" ) ) {
5187 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5188 p2.getNode( "f" ) );
5189 if ( !cdef.getName().equals( "cdef" ) ) {
5192 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5193 p2.getNode( "f" ) );
5194 if ( !cdef2.getName().equals( "cdef" ) ) {
5197 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5198 p2.getNode( "d" ) );
5199 if ( !cdef3.getName().equals( "cdef" ) ) {
5202 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5203 p2.getNode( "a" ) );
5204 if ( !rt.getName().equals( "r" ) ) {
5207 final Phylogeny p3 = factory
5208 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5209 new NHXParser() )[ 0 ];
5210 PhylogenyMethods.preOrderReId( p3 );
5211 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5212 p3.getNode( "c" ) );
5213 if ( !bc_3.getName().equals( "bc" ) ) {
5216 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5217 p3.getNode( "c" ) );
5218 if ( !ac_3.getName().equals( "abc" ) ) {
5221 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5222 p3.getNode( "d" ) );
5223 if ( !ad_3.getName().equals( "abcde" ) ) {
5226 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5227 p3.getNode( "f" ) );
5228 if ( !af_3.getName().equals( "abcdef" ) ) {
5231 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5232 p3.getNode( "g" ) );
5233 if ( !ag_3.getName().equals( "" ) ) {
5236 if ( !ag_3.isRoot() ) {
5239 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5240 p3.getNode( "l" ) );
5241 if ( !al_3.getName().equals( "" ) ) {
5244 if ( !al_3.isRoot() ) {
5247 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5248 p3.getNode( "l" ) );
5249 if ( !kl_3.getName().equals( "" ) ) {
5252 if ( !kl_3.isRoot() ) {
5255 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5256 p3.getNode( "l" ) );
5257 if ( !fl_3.getName().equals( "" ) ) {
5260 if ( !fl_3.isRoot() ) {
5263 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5264 p3.getNode( "k" ) );
5265 if ( !gk_3.getName().equals( "ghijk" ) ) {
5268 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5269 PhylogenyMethods.preOrderReId( p4 );
5270 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5271 p4.getNode( "c" ) );
5272 if ( !r_4.getName().equals( "r" ) ) {
5275 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5276 PhylogenyMethods.preOrderReId( p5 );
5277 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5278 p5.getNode( "c" ) );
5279 if ( !r_5.getName().equals( "root" ) ) {
5282 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5283 PhylogenyMethods.preOrderReId( p6 );
5284 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5285 p6.getNode( "a" ) );
5286 if ( !r_6.getName().equals( "rot" ) ) {
5289 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5290 PhylogenyMethods.preOrderReId( p7 );
5291 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5292 p7.getNode( "e" ) );
5293 if ( !r_7.getName().equals( "rott" ) ) {
5296 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5297 p7.getNode( "a" ) );
5298 if ( !r_71.getName().equals( "rott" ) ) {
5301 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5302 p7.getNode( "rott" ) );
5303 if ( !r_72.getName().equals( "rott" ) ) {
5306 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5307 p7.getNode( "a" ) );
5308 if ( !r_73.getName().equals( "rott" ) ) {
5311 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5312 p7.getNode( "rott" ) );
5313 if ( !r_74.getName().equals( "rott" ) ) {
5316 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5317 p7.getNode( "e" ) );
5318 if ( !r_75.getName().equals( "e" ) ) {
5322 catch ( final Exception e ) {
5323 e.printStackTrace( System.out );
5329 private static boolean testHmmscanOutputParser() {
5330 final String test_dir = Test.PATH_TO_TEST_DATA;
5332 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5333 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5335 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5336 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5337 final List<Protein> proteins = parser2.parse();
5338 if ( parser2.getProteinsEncountered() != 4 ) {
5341 if ( proteins.size() != 4 ) {
5344 if ( parser2.getDomainsEncountered() != 69 ) {
5347 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5350 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5353 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5356 final Protein p1 = proteins.get( 0 );
5357 if ( p1.getNumberOfProteinDomains() != 15 ) {
5360 if ( p1.getLength() != 850 ) {
5363 final Protein p2 = proteins.get( 1 );
5364 if ( p2.getNumberOfProteinDomains() != 51 ) {
5367 if ( p2.getLength() != 1291 ) {
5370 final Protein p3 = proteins.get( 2 );
5371 if ( p3.getNumberOfProteinDomains() != 2 ) {
5374 final Protein p4 = proteins.get( 3 );
5375 if ( p4.getNumberOfProteinDomains() != 1 ) {
5378 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5381 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5384 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5387 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5390 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5393 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5396 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5400 catch ( final Exception e ) {
5401 e.printStackTrace( System.out );
5407 private static boolean testLastExternalNodeMethods() {
5409 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5410 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5411 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5412 final PhylogenyNode n1 = t0.getNode( "A" );
5413 if ( n1.isLastExternalNode() ) {
5416 final PhylogenyNode n2 = t0.getNode( "B" );
5417 if ( n2.isLastExternalNode() ) {
5420 final PhylogenyNode n3 = t0.getNode( "C" );
5421 if ( n3.isLastExternalNode() ) {
5424 final PhylogenyNode n4 = t0.getNode( "D" );
5425 if ( !n4.isLastExternalNode() ) {
5429 catch ( final Exception e ) {
5430 e.printStackTrace( System.out );
5436 private static boolean testLevelOrderIterator() {
5438 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5439 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5440 PhylogenyNodeIterator it0;
5441 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5444 for( it0.reset(); it0.hasNext(); ) {
5447 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5448 if ( !it.next().getName().equals( "r" ) ) {
5451 if ( !it.next().getName().equals( "ab" ) ) {
5454 if ( !it.next().getName().equals( "cd" ) ) {
5457 if ( !it.next().getName().equals( "A" ) ) {
5460 if ( !it.next().getName().equals( "B" ) ) {
5463 if ( !it.next().getName().equals( "C" ) ) {
5466 if ( !it.next().getName().equals( "D" ) ) {
5469 if ( it.hasNext() ) {
5472 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",
5473 new NHXParser() )[ 0 ];
5474 PhylogenyNodeIterator it2;
5475 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5478 for( it2.reset(); it2.hasNext(); ) {
5481 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5482 if ( !it3.next().getName().equals( "r" ) ) {
5485 if ( !it3.next().getName().equals( "abc" ) ) {
5488 if ( !it3.next().getName().equals( "defg" ) ) {
5491 if ( !it3.next().getName().equals( "A" ) ) {
5494 if ( !it3.next().getName().equals( "B" ) ) {
5497 if ( !it3.next().getName().equals( "C" ) ) {
5500 if ( !it3.next().getName().equals( "D" ) ) {
5503 if ( !it3.next().getName().equals( "E" ) ) {
5506 if ( !it3.next().getName().equals( "F" ) ) {
5509 if ( !it3.next().getName().equals( "G" ) ) {
5512 if ( !it3.next().getName().equals( "1" ) ) {
5515 if ( !it3.next().getName().equals( "2" ) ) {
5518 if ( !it3.next().getName().equals( "3" ) ) {
5521 if ( !it3.next().getName().equals( "4" ) ) {
5524 if ( !it3.next().getName().equals( "5" ) ) {
5527 if ( !it3.next().getName().equals( "6" ) ) {
5530 if ( !it3.next().getName().equals( "f1" ) ) {
5533 if ( !it3.next().getName().equals( "f2" ) ) {
5536 if ( !it3.next().getName().equals( "f3" ) ) {
5539 if ( !it3.next().getName().equals( "a" ) ) {
5542 if ( !it3.next().getName().equals( "b" ) ) {
5545 if ( !it3.next().getName().equals( "f21" ) ) {
5548 if ( !it3.next().getName().equals( "X" ) ) {
5551 if ( !it3.next().getName().equals( "Y" ) ) {
5554 if ( !it3.next().getName().equals( "Z" ) ) {
5557 if ( it3.hasNext() ) {
5560 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5561 PhylogenyNodeIterator it4;
5562 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5565 for( it4.reset(); it4.hasNext(); ) {
5568 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5569 if ( !it5.next().getName().equals( "r" ) ) {
5572 if ( !it5.next().getName().equals( "A" ) ) {
5575 if ( !it5.next().getName().equals( "B" ) ) {
5578 if ( !it5.next().getName().equals( "C" ) ) {
5581 if ( !it5.next().getName().equals( "D" ) ) {
5584 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5585 PhylogenyNodeIterator it6;
5586 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5589 for( it6.reset(); it6.hasNext(); ) {
5592 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5593 if ( !it7.next().getName().equals( "A" ) ) {
5596 if ( it.hasNext() ) {
5600 catch ( final Exception e ) {
5601 e.printStackTrace( System.out );
5607 private static boolean testMafft( final String path ) {
5609 final List<String> opts = new ArrayList<String>();
5610 opts.add( "--maxiterate" );
5612 opts.add( "--localpair" );
5613 opts.add( "--quiet" );
5615 final MsaInferrer mafft = Mafft.createInstance( path );
5616 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5617 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5620 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5624 catch ( final Exception e ) {
5625 e.printStackTrace( System.out );
5631 private static boolean testMidpointrooting() {
5633 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5634 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5635 PhylogenyMethods.midpointRoot( t0 );
5636 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5639 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5642 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5646 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",
5647 new NHXParser() )[ 0 ];
5648 if ( !t1.isRooted() ) {
5651 PhylogenyMethods.midpointRoot( t1 );
5652 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5655 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5658 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5661 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5664 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5667 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5670 t1.reRoot( t1.getNode( "A" ) );
5671 PhylogenyMethods.midpointRoot( t1 );
5672 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5675 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5678 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5681 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5684 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5688 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5692 catch ( final Exception e ) {
5693 e.printStackTrace( System.out );
5699 private static boolean testMsaQualityMethod() {
5701 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
5702 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
5703 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
5704 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
5705 final List<Sequence> l = new ArrayList<Sequence>();
5710 final Msa msa = BasicMsa.createInstance( l );
5711 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5714 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5717 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5720 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5723 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
5726 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
5729 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
5733 catch ( final Exception e ) {
5734 e.printStackTrace( System.out );
5740 private static boolean testNextNodeWithCollapsing() {
5742 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5744 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5745 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5746 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5747 t0.getNode( "cd" ).setCollapse( true );
5748 t0.getNode( "cde" ).setCollapse( true );
5749 n = t0.getFirstExternalNode();
5750 while ( n != null ) {
5752 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5754 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5757 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5760 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5763 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5766 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5769 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5773 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5774 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5775 t1.getNode( "ab" ).setCollapse( true );
5776 t1.getNode( "cd" ).setCollapse( true );
5777 t1.getNode( "cde" ).setCollapse( true );
5778 n = t1.getNode( "ab" );
5779 ext = new ArrayList<PhylogenyNode>();
5780 while ( n != null ) {
5782 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5784 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5787 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5790 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5793 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5796 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5802 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5803 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5804 t2.getNode( "ab" ).setCollapse( true );
5805 t2.getNode( "cd" ).setCollapse( true );
5806 t2.getNode( "cde" ).setCollapse( true );
5807 t2.getNode( "c" ).setCollapse( true );
5808 t2.getNode( "d" ).setCollapse( true );
5809 t2.getNode( "e" ).setCollapse( true );
5810 t2.getNode( "gh" ).setCollapse( true );
5811 n = t2.getNode( "ab" );
5812 ext = new ArrayList<PhylogenyNode>();
5813 while ( n != null ) {
5815 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5817 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5820 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5823 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5826 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5832 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5833 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5834 t3.getNode( "ab" ).setCollapse( true );
5835 t3.getNode( "cd" ).setCollapse( true );
5836 t3.getNode( "cde" ).setCollapse( true );
5837 t3.getNode( "c" ).setCollapse( true );
5838 t3.getNode( "d" ).setCollapse( true );
5839 t3.getNode( "e" ).setCollapse( true );
5840 t3.getNode( "gh" ).setCollapse( true );
5841 t3.getNode( "fgh" ).setCollapse( true );
5842 n = t3.getNode( "ab" );
5843 ext = new ArrayList<PhylogenyNode>();
5844 while ( n != null ) {
5846 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5848 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5851 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5854 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5860 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5861 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5862 t4.getNode( "ab" ).setCollapse( true );
5863 t4.getNode( "cd" ).setCollapse( true );
5864 t4.getNode( "cde" ).setCollapse( true );
5865 t4.getNode( "c" ).setCollapse( true );
5866 t4.getNode( "d" ).setCollapse( true );
5867 t4.getNode( "e" ).setCollapse( true );
5868 t4.getNode( "gh" ).setCollapse( true );
5869 t4.getNode( "fgh" ).setCollapse( true );
5870 t4.getNode( "abcdefgh" ).setCollapse( true );
5871 n = t4.getNode( "abcdefgh" );
5872 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5877 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5878 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5880 n = t5.getFirstExternalNode();
5881 while ( n != null ) {
5883 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5885 if ( ext.size() != 8 ) {
5888 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5891 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5894 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5897 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5900 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5903 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5906 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5909 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5914 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5915 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5917 t6.getNode( "ab" ).setCollapse( true );
5918 n = t6.getNode( "ab" );
5919 while ( n != null ) {
5921 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5923 if ( ext.size() != 7 ) {
5926 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5929 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5932 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5935 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5938 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5941 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5944 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5949 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5950 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5952 t7.getNode( "cd" ).setCollapse( true );
5953 n = t7.getNode( "a" );
5954 while ( n != null ) {
5956 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5958 if ( ext.size() != 7 ) {
5961 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5964 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5967 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5970 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5973 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5976 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5979 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5984 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5985 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5987 t8.getNode( "cd" ).setCollapse( true );
5988 t8.getNode( "c" ).setCollapse( true );
5989 t8.getNode( "d" ).setCollapse( true );
5990 n = t8.getNode( "a" );
5991 while ( n != null ) {
5993 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5995 if ( ext.size() != 7 ) {
5998 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6001 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6004 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6005 System.out.println( "2 fail" );
6008 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6011 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6014 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6017 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6022 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6023 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6025 t9.getNode( "gh" ).setCollapse( true );
6026 n = t9.getNode( "a" );
6027 while ( n != null ) {
6029 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6031 if ( ext.size() != 7 ) {
6034 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6037 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6040 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6043 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6046 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6049 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6052 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6057 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6058 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6060 t10.getNode( "gh" ).setCollapse( true );
6061 t10.getNode( "g" ).setCollapse( true );
6062 t10.getNode( "h" ).setCollapse( true );
6063 n = t10.getNode( "a" );
6064 while ( n != null ) {
6066 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6068 if ( ext.size() != 7 ) {
6071 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6074 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6077 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6080 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6083 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6086 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6089 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6094 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6095 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6097 t11.getNode( "gh" ).setCollapse( true );
6098 t11.getNode( "fgh" ).setCollapse( true );
6099 n = t11.getNode( "a" );
6100 while ( n != null ) {
6102 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6104 if ( ext.size() != 6 ) {
6107 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6110 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6113 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6116 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6119 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6122 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6127 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6128 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6130 t12.getNode( "gh" ).setCollapse( true );
6131 t12.getNode( "fgh" ).setCollapse( true );
6132 t12.getNode( "g" ).setCollapse( true );
6133 t12.getNode( "h" ).setCollapse( true );
6134 t12.getNode( "f" ).setCollapse( true );
6135 n = t12.getNode( "a" );
6136 while ( n != null ) {
6138 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6140 if ( ext.size() != 6 ) {
6143 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6146 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6149 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6152 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6155 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6158 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6163 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6164 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6166 t13.getNode( "ab" ).setCollapse( true );
6167 t13.getNode( "b" ).setCollapse( true );
6168 t13.getNode( "fgh" ).setCollapse( true );
6169 t13.getNode( "gh" ).setCollapse( true );
6170 n = t13.getNode( "ab" );
6171 while ( n != null ) {
6173 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6175 if ( ext.size() != 5 ) {
6178 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6181 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6184 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6187 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6190 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6195 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6196 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6198 t14.getNode( "ab" ).setCollapse( true );
6199 t14.getNode( "a" ).setCollapse( true );
6200 t14.getNode( "fgh" ).setCollapse( true );
6201 t14.getNode( "gh" ).setCollapse( true );
6202 n = t14.getNode( "ab" );
6203 while ( n != null ) {
6205 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6207 if ( ext.size() != 5 ) {
6210 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6213 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6216 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6219 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6222 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6227 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" );
6228 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6230 t15.getNode( "ab" ).setCollapse( true );
6231 t15.getNode( "a" ).setCollapse( true );
6232 t15.getNode( "fgh" ).setCollapse( true );
6233 t15.getNode( "gh" ).setCollapse( true );
6234 n = t15.getNode( "ab" );
6235 while ( n != null ) {
6237 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6239 if ( ext.size() != 6 ) {
6242 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6245 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6248 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6251 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6254 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6257 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6262 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" );
6263 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6265 t16.getNode( "ab" ).setCollapse( true );
6266 t16.getNode( "a" ).setCollapse( true );
6267 t16.getNode( "fgh" ).setCollapse( true );
6268 t16.getNode( "gh" ).setCollapse( true );
6269 t16.getNode( "cd" ).setCollapse( true );
6270 t16.getNode( "cde" ).setCollapse( true );
6271 t16.getNode( "d" ).setCollapse( true );
6272 t16.getNode( "x" ).setCollapse( true );
6273 n = t16.getNode( "ab" );
6274 while ( n != null ) {
6276 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6278 if ( ext.size() != 4 ) {
6281 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6284 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6287 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6290 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6294 catch ( final Exception e ) {
6295 e.printStackTrace( System.out );
6301 private static boolean testNexusCharactersParsing() {
6303 final NexusCharactersParser parser = new NexusCharactersParser();
6304 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6306 String[] labels = parser.getCharStateLabels();
6307 if ( labels.length != 7 ) {
6310 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6313 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6316 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6319 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6322 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6325 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6328 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6331 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6333 labels = parser.getCharStateLabels();
6334 if ( labels.length != 7 ) {
6337 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6340 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6343 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6346 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6349 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6352 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6355 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6359 catch ( final Exception e ) {
6360 e.printStackTrace( System.out );
6366 private static boolean testNexusMatrixParsing() {
6368 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6369 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6371 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6372 if ( m.getNumberOfCharacters() != 9 ) {
6375 if ( m.getNumberOfIdentifiers() != 5 ) {
6378 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6381 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6384 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6387 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6390 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6393 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6396 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6399 // if ( labels.length != 7 ) {
6402 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6405 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6408 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6411 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6414 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6417 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6420 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6423 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6425 // labels = parser.getCharStateLabels();
6426 // if ( labels.length != 7 ) {
6429 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6432 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6435 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6438 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6441 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6444 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6447 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6451 catch ( final Exception e ) {
6452 e.printStackTrace( System.out );
6458 private static boolean testNexusTreeParsing() {
6460 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6461 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6462 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6463 if ( phylogenies.length != 1 ) {
6466 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6469 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6473 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6474 if ( phylogenies.length != 1 ) {
6477 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6480 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6484 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6485 if ( phylogenies.length != 1 ) {
6488 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6491 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6494 if ( phylogenies[ 0 ].isRooted() ) {
6498 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6499 if ( phylogenies.length != 18 ) {
6502 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6505 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6508 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6511 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6514 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6517 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6520 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6523 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6526 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6529 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6532 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6535 if ( phylogenies[ 8 ].isRooted() ) {
6538 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6541 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6544 if ( !phylogenies[ 9 ].isRooted() ) {
6547 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6550 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6553 if ( !phylogenies[ 10 ].isRooted() ) {
6556 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6559 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6562 if ( phylogenies[ 11 ].isRooted() ) {
6565 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6568 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6571 if ( !phylogenies[ 12 ].isRooted() ) {
6574 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6577 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6580 if ( !phylogenies[ 13 ].isRooted() ) {
6583 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6586 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6589 if ( !phylogenies[ 14 ].isRooted() ) {
6592 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6595 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6598 if ( phylogenies[ 15 ].isRooted() ) {
6601 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6604 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6607 if ( !phylogenies[ 16 ].isRooted() ) {
6610 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6613 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6616 if ( phylogenies[ 17 ].isRooted() ) {
6619 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6623 catch ( final Exception e ) {
6624 e.printStackTrace( System.out );
6630 private static boolean testNexusTreeParsingIterating() {
6632 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6633 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6634 if ( !p.hasNext() ) {
6637 Phylogeny phy = p.next();
6638 if ( phy == null ) {
6641 if ( phy.getNumberOfExternalNodes() != 25 ) {
6644 if ( !phy.getName().equals( "" ) ) {
6647 if ( p.hasNext() ) {
6651 if ( phy != null ) {
6656 if ( !p.hasNext() ) {
6660 if ( phy == null ) {
6663 if ( phy.getNumberOfExternalNodes() != 25 ) {
6666 if ( !phy.getName().equals( "" ) ) {
6669 if ( p.hasNext() ) {
6673 if ( phy != null ) {
6677 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6678 if ( !p.hasNext() ) {
6682 if ( phy == null ) {
6685 if ( phy.getNumberOfExternalNodes() != 10 ) {
6688 if ( !phy.getName().equals( "name" ) ) {
6691 if ( p.hasNext() ) {
6695 if ( phy != null ) {
6700 if ( !p.hasNext() ) {
6704 if ( phy == null ) {
6707 if ( phy.getNumberOfExternalNodes() != 10 ) {
6710 if ( !phy.getName().equals( "name" ) ) {
6713 if ( p.hasNext() ) {
6717 if ( phy != null ) {
6721 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6722 if ( !p.hasNext() ) {
6726 if ( phy == null ) {
6729 if ( phy.getNumberOfExternalNodes() != 3 ) {
6732 if ( !phy.getName().equals( "" ) ) {
6735 if ( phy.isRooted() ) {
6738 if ( p.hasNext() ) {
6742 if ( phy != null ) {
6747 if ( !p.hasNext() ) {
6751 if ( phy == null ) {
6754 if ( phy.getNumberOfExternalNodes() != 3 ) {
6757 if ( !phy.getName().equals( "" ) ) {
6760 if ( p.hasNext() ) {
6764 if ( phy != null ) {
6768 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6769 // if ( phylogenies.length != 18 ) {
6773 if ( !p.hasNext() ) {
6777 if ( phy == null ) {
6780 if ( phy.getNumberOfExternalNodes() != 10 ) {
6783 if ( !phy.getName().equals( "tree 0" ) ) {
6787 if ( !p.hasNext() ) {
6791 if ( phy == null ) {
6794 if ( phy.getNumberOfExternalNodes() != 10 ) {
6797 if ( !phy.getName().equals( "tree 1" ) ) {
6801 if ( !p.hasNext() ) {
6805 if ( phy == null ) {
6808 if ( phy.getNumberOfExternalNodes() != 3 ) {
6811 if ( !phy.getName().equals( "" ) ) {
6814 if ( phy.isRooted() ) {
6818 if ( !p.hasNext() ) {
6822 if ( phy == null ) {
6825 if ( phy.getNumberOfExternalNodes() != 4 ) {
6828 if ( !phy.getName().equals( "" ) ) {
6831 if ( !phy.isRooted() ) {
6835 if ( !p.hasNext() ) {
6839 if ( phy == null ) {
6842 if ( phy.getNumberOfExternalNodes() != 5 ) {
6843 System.out.println( phy.getNumberOfExternalNodes() );
6846 if ( !phy.getName().equals( "" ) ) {
6849 if ( !phy.isRooted() ) {
6853 if ( !p.hasNext() ) {
6857 if ( phy == null ) {
6860 if ( phy.getNumberOfExternalNodes() != 3 ) {
6863 if ( !phy.getName().equals( "" ) ) {
6866 if ( phy.isRooted() ) {
6870 if ( !p.hasNext() ) {
6874 if ( phy == null ) {
6877 if ( phy.getNumberOfExternalNodes() != 2 ) {
6880 if ( !phy.getName().equals( "" ) ) {
6883 if ( !phy.isRooted() ) {
6887 if ( !p.hasNext() ) {
6891 if ( phy.getNumberOfExternalNodes() != 3 ) {
6894 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6897 if ( !phy.isRooted() ) {
6901 if ( !p.hasNext() ) {
6905 if ( phy.getNumberOfExternalNodes() != 3 ) {
6908 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6911 if ( !phy.getName().equals( "tree 8" ) ) {
6915 if ( !p.hasNext() ) {
6919 if ( phy.getNumberOfExternalNodes() != 3 ) {
6922 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6925 if ( !phy.getName().equals( "tree 9" ) ) {
6929 if ( !p.hasNext() ) {
6933 if ( phy.getNumberOfExternalNodes() != 3 ) {
6936 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6939 if ( !phy.getName().equals( "tree 10" ) ) {
6942 if ( !phy.isRooted() ) {
6946 if ( !p.hasNext() ) {
6950 if ( phy.getNumberOfExternalNodes() != 3 ) {
6953 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6956 if ( !phy.getName().equals( "tree 11" ) ) {
6959 if ( phy.isRooted() ) {
6963 if ( !p.hasNext() ) {
6967 if ( phy.getNumberOfExternalNodes() != 3 ) {
6970 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6973 if ( !phy.getName().equals( "tree 12" ) ) {
6976 if ( !phy.isRooted() ) {
6980 if ( !p.hasNext() ) {
6984 if ( phy.getNumberOfExternalNodes() != 3 ) {
6987 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6990 if ( !phy.getName().equals( "tree 13" ) ) {
6993 if ( !phy.isRooted() ) {
6997 if ( !p.hasNext() ) {
7001 if ( phy.getNumberOfExternalNodes() != 10 ) {
7002 System.out.println( phy.getNumberOfExternalNodes() );
7007 .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;" ) ) {
7008 System.out.println( phy.toNewHampshire() );
7011 if ( !phy.getName().equals( "tree 14" ) ) {
7014 if ( !phy.isRooted() ) {
7018 if ( !p.hasNext() ) {
7022 if ( phy.getNumberOfExternalNodes() != 10 ) {
7023 System.out.println( phy.getNumberOfExternalNodes() );
7028 .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;" ) ) {
7029 System.out.println( phy.toNewHampshire() );
7032 if ( !phy.getName().equals( "tree 15" ) ) {
7035 if ( phy.isRooted() ) {
7039 if ( !p.hasNext() ) {
7043 if ( phy.getNumberOfExternalNodes() != 10 ) {
7044 System.out.println( phy.getNumberOfExternalNodes() );
7049 .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;" ) ) {
7050 System.out.println( phy.toNewHampshire() );
7053 if ( !phy.getName().equals( "tree 16" ) ) {
7056 if ( !phy.isRooted() ) {
7060 if ( !p.hasNext() ) {
7064 if ( phy.getNumberOfExternalNodes() != 10 ) {
7065 System.out.println( phy.getNumberOfExternalNodes() );
7070 .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;" ) ) {
7071 System.out.println( phy.toNewHampshire() );
7074 if ( !phy.getName().equals( "tree 17" ) ) {
7077 if ( phy.isRooted() ) {
7081 if ( p.hasNext() ) {
7085 if ( phy != null ) {
7090 if ( !p.hasNext() ) {
7094 if ( phy == null ) {
7097 if ( phy.getNumberOfExternalNodes() != 10 ) {
7100 if ( !phy.getName().equals( "tree 0" ) ) {
7104 if ( !p.hasNext() ) {
7108 if ( phy == null ) {
7111 if ( phy.getNumberOfExternalNodes() != 10 ) {
7114 if ( !phy.getName().equals( "tree 1" ) ) {
7118 if ( !p.hasNext() ) {
7122 if ( phy == null ) {
7125 if ( phy.getNumberOfExternalNodes() != 3 ) {
7128 if ( !phy.getName().equals( "" ) ) {
7131 if ( phy.isRooted() ) {
7135 if ( !p.hasNext() ) {
7139 if ( phy == null ) {
7142 if ( phy.getNumberOfExternalNodes() != 4 ) {
7145 if ( !phy.getName().equals( "" ) ) {
7148 if ( !phy.isRooted() ) {
7152 if ( !p.hasNext() ) {
7156 if ( phy == null ) {
7159 if ( phy.getNumberOfExternalNodes() != 5 ) {
7160 System.out.println( phy.getNumberOfExternalNodes() );
7163 if ( !phy.getName().equals( "" ) ) {
7166 if ( !phy.isRooted() ) {
7170 if ( !p.hasNext() ) {
7174 if ( phy == null ) {
7177 if ( phy.getNumberOfExternalNodes() != 3 ) {
7180 if ( !phy.getName().equals( "" ) ) {
7183 if ( phy.isRooted() ) {
7187 catch ( final Exception e ) {
7188 e.printStackTrace( System.out );
7194 private static boolean testNexusTreeParsingTranslating() {
7196 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7197 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7198 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7199 if ( phylogenies.length != 1 ) {
7202 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7205 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7208 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7211 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7214 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7215 .equals( "Aranaeus" ) ) {
7219 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7220 if ( phylogenies.length != 3 ) {
7223 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7226 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7229 if ( phylogenies[ 0 ].isRooted() ) {
7232 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7235 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7238 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7239 .equals( "Aranaeus" ) ) {
7242 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7245 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7248 if ( phylogenies[ 1 ].isRooted() ) {
7251 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7254 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7257 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7258 .equals( "Aranaeus" ) ) {
7261 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7264 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7267 if ( !phylogenies[ 2 ].isRooted() ) {
7270 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7273 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7276 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7277 .equals( "Aranaeus" ) ) {
7281 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7282 if ( phylogenies.length != 3 ) {
7285 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7288 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7291 if ( phylogenies[ 0 ].isRooted() ) {
7294 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7297 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7300 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7301 .equals( "Aranaeus" ) ) {
7304 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7307 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7310 if ( phylogenies[ 1 ].isRooted() ) {
7313 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7316 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7319 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7320 .equals( "Aranaeus" ) ) {
7323 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7326 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7329 if ( !phylogenies[ 2 ].isRooted() ) {
7332 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7335 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7338 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7339 .equals( "Aranaeus" ) ) {
7343 catch ( final Exception e ) {
7344 e.printStackTrace( System.out );
7350 private static boolean testNHParsing() {
7352 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7353 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7354 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7357 final NHXParser nhxp = new NHXParser();
7358 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7359 nhxp.setReplaceUnderscores( true );
7360 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7361 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7364 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7367 final Phylogeny p1b = factory
7368 .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 ",
7369 new NHXParser() )[ 0 ];
7370 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7373 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7376 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7377 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7378 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7379 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7380 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7381 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7382 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7383 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7384 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7385 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7386 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7387 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7388 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7390 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7393 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7396 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7399 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7402 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7403 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7404 final String p16_S = "((A,B),C)";
7405 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7406 if ( p16.length != 1 ) {
7409 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7412 final String p17_S = "(C,(A,B))";
7413 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7414 if ( p17.length != 1 ) {
7417 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7420 final String p18_S = "((A,B),(C,D))";
7421 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7422 if ( p18.length != 1 ) {
7425 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7428 final String p19_S = "(((A,B),C),D)";
7429 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7430 if ( p19.length != 1 ) {
7433 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7436 final String p20_S = "(A,(B,(C,D)))";
7437 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7438 if ( p20.length != 1 ) {
7441 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7444 final String p21_S = "(A,(B,(C,(D,E))))";
7445 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7446 if ( p21.length != 1 ) {
7449 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7452 final String p22_S = "((((A,B),C),D),E)";
7453 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7454 if ( p22.length != 1 ) {
7457 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7460 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7461 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7462 if ( p23.length != 1 ) {
7463 System.out.println( "xl=" + p23.length );
7467 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7470 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7471 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7472 if ( p24.length != 1 ) {
7475 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7478 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7479 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7480 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7481 if ( p241.length != 2 ) {
7484 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7487 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7490 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7491 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7492 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7493 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7494 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7495 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7496 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7497 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7498 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7499 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7502 final String p26_S = "(A,B)ab";
7503 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7504 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7507 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7508 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7509 if ( p27s.length != 1 ) {
7510 System.out.println( "xxl=" + p27s.length );
7514 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7515 System.out.println( p27s[ 0 ].toNewHampshireX() );
7519 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7521 if ( p27.length != 1 ) {
7522 System.out.println( "yl=" + p27.length );
7526 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7527 System.out.println( p27[ 0 ].toNewHampshireX() );
7531 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7532 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7533 final String p28_S3 = "(A,B)ab";
7534 final String p28_S4 = "((((A,B),C),D),;E;)";
7535 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7537 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7540 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7543 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7546 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7549 if ( p28.length != 4 ) {
7552 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";
7553 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7554 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7557 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";
7558 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7559 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7562 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7563 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7564 if ( ( p32.length != 0 ) ) {
7567 final String p33_S = "A";
7568 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7569 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7572 final String p34_S = "B;";
7573 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7574 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7577 final String p35_S = "B:0.2";
7578 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7579 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7582 final String p36_S = "(A)";
7583 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7584 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7587 final String p37_S = "((A))";
7588 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7589 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7592 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7593 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7594 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7597 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7598 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7599 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7602 final String p40_S = "(A,B,C)";
7603 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7604 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7607 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7608 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7609 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7612 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7613 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7614 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7617 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)";
7618 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7619 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7622 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)))";
7623 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7624 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7627 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7628 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7629 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7632 final String p46_S = "";
7633 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7634 if ( p46.length != 0 ) {
7637 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7638 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7641 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7642 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7645 final Phylogeny p49 = factory
7646 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7647 new NHXParser() )[ 0 ];
7648 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7651 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7652 if ( p50.getNode( "A" ) == null ) {
7655 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7656 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7659 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7662 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7663 .equals( "((A,B)88:2.0,C);" ) ) {
7666 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7667 if ( p51.getNode( "A(A" ) == null ) {
7670 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7671 if ( p52.getNode( "A(A" ) == null ) {
7674 final Phylogeny p53 = factory
7675 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7676 new NHXParser() )[ 0 ];
7677 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7681 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7682 if ( p54.getNode( "A" ) == null ) {
7685 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7686 .equals( "((A,B)[88],C);" ) ) {
7690 catch ( final Exception e ) {
7691 e.printStackTrace( System.out );
7697 private static boolean testNHParsingIter() {
7699 final String p0_str = "(A,B);";
7700 final NHXParser p = new NHXParser();
7701 p.setSource( p0_str );
7702 if ( !p.hasNext() ) {
7705 final Phylogeny p0 = p.next();
7706 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7707 System.out.println( p0.toNewHampshire() );
7710 if ( p.hasNext() ) {
7713 if ( p.next() != null ) {
7717 final String p00_str = "(A,B)root;";
7718 p.setSource( p00_str );
7719 final Phylogeny p00 = p.next();
7720 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7721 System.out.println( p00.toNewHampshire() );
7725 final String p000_str = "A;";
7726 p.setSource( p000_str );
7727 final Phylogeny p000 = p.next();
7728 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7729 System.out.println( p000.toNewHampshire() );
7733 final String p0000_str = "A";
7734 p.setSource( p0000_str );
7735 final Phylogeny p0000 = p.next();
7736 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7737 System.out.println( p0000.toNewHampshire() );
7741 p.setSource( "(A)" );
7742 final Phylogeny p00000 = p.next();
7743 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7744 System.out.println( p00000.toNewHampshire() );
7748 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7749 p.setSource( p1_str );
7750 if ( !p.hasNext() ) {
7753 final Phylogeny p1_0 = p.next();
7754 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7755 System.out.println( p1_0.toNewHampshire() );
7758 if ( !p.hasNext() ) {
7761 final Phylogeny p1_1 = p.next();
7762 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7763 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7766 if ( !p.hasNext() ) {
7769 final Phylogeny p1_2 = p.next();
7770 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7771 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7774 if ( !p.hasNext() ) {
7777 final Phylogeny p1_3 = p.next();
7778 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7779 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7782 if ( p.hasNext() ) {
7785 if ( p.next() != null ) {
7789 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7790 p.setSource( p2_str );
7791 if ( !p.hasNext() ) {
7794 Phylogeny p2_0 = p.next();
7795 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7796 System.out.println( p2_0.toNewHampshire() );
7799 if ( !p.hasNext() ) {
7802 Phylogeny p2_1 = p.next();
7803 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7804 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7807 if ( !p.hasNext() ) {
7810 Phylogeny p2_2 = p.next();
7811 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7812 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7815 if ( !p.hasNext() ) {
7818 Phylogeny p2_3 = p.next();
7819 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7820 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7823 if ( !p.hasNext() ) {
7826 Phylogeny p2_4 = p.next();
7827 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7828 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7831 if ( p.hasNext() ) {
7834 if ( p.next() != null ) {
7839 if ( !p.hasNext() ) {
7843 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7844 System.out.println( p2_0.toNewHampshire() );
7847 if ( !p.hasNext() ) {
7851 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7852 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7855 if ( !p.hasNext() ) {
7859 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7860 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7863 if ( !p.hasNext() ) {
7867 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7868 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7871 if ( !p.hasNext() ) {
7875 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7876 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7879 if ( p.hasNext() ) {
7882 if ( p.next() != null ) {
7886 final String p3_str = "((A,B),C)abc";
7887 p.setSource( p3_str );
7888 if ( !p.hasNext() ) {
7891 final Phylogeny p3_0 = p.next();
7892 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7895 if ( p.hasNext() ) {
7898 if ( p.next() != null ) {
7902 final String p4_str = "((A,B)ab,C)abc";
7903 p.setSource( p4_str );
7904 if ( !p.hasNext() ) {
7907 final Phylogeny p4_0 = p.next();
7908 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7911 if ( p.hasNext() ) {
7914 if ( p.next() != null ) {
7918 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7919 p.setSource( p5_str );
7920 if ( !p.hasNext() ) {
7923 final Phylogeny p5_0 = p.next();
7924 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7927 if ( p.hasNext() ) {
7930 if ( p.next() != null ) {
7934 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7935 p.setSource( p6_str );
7936 if ( !p.hasNext() ) {
7939 Phylogeny p6_0 = p.next();
7940 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7943 if ( p.hasNext() ) {
7946 if ( p.next() != null ) {
7950 if ( !p.hasNext() ) {
7954 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7957 if ( p.hasNext() ) {
7960 if ( p.next() != null ) {
7964 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7965 p.setSource( p7_str );
7966 if ( !p.hasNext() ) {
7969 Phylogeny p7_0 = p.next();
7970 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7973 if ( p.hasNext() ) {
7976 if ( p.next() != null ) {
7980 if ( !p.hasNext() ) {
7984 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7987 if ( p.hasNext() ) {
7990 if ( p.next() != null ) {
7994 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7995 p.setSource( p8_str );
7996 if ( !p.hasNext() ) {
7999 Phylogeny p8_0 = p.next();
8000 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8003 if ( !p.hasNext() ) {
8006 if ( !p.hasNext() ) {
8009 Phylogeny p8_1 = p.next();
8010 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8013 if ( p.hasNext() ) {
8016 if ( p.next() != null ) {
8020 if ( !p.hasNext() ) {
8024 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8027 if ( !p.hasNext() ) {
8031 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8034 if ( p.hasNext() ) {
8037 if ( p.next() != null ) {
8043 if ( p.hasNext() ) {
8047 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8048 if ( !p.hasNext() ) {
8051 Phylogeny p_27 = p.next();
8052 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8053 System.out.println( p_27.toNewHampshireX() );
8057 if ( p.hasNext() ) {
8060 if ( p.next() != null ) {
8064 if ( !p.hasNext() ) {
8068 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8069 System.out.println( p_27.toNewHampshireX() );
8073 if ( p.hasNext() ) {
8076 if ( p.next() != null ) {
8080 final String p30_str = "(A,B);(C,D)";
8081 final NHXParser p30 = new NHXParser();
8082 p30.setSource( p30_str );
8083 if ( !p30.hasNext() ) {
8086 Phylogeny phy30 = p30.next();
8087 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8088 System.out.println( phy30.toNewHampshire() );
8091 if ( !p30.hasNext() ) {
8094 Phylogeny phy301 = p30.next();
8095 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8096 System.out.println( phy301.toNewHampshire() );
8099 if ( p30.hasNext() ) {
8102 if ( p30.hasNext() ) {
8105 if ( p30.next() != null ) {
8108 if ( p30.next() != null ) {
8112 if ( !p30.hasNext() ) {
8116 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8117 System.out.println( phy30.toNewHampshire() );
8120 if ( !p30.hasNext() ) {
8123 phy301 = p30.next();
8124 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8125 System.out.println( phy301.toNewHampshire() );
8128 if ( p30.hasNext() ) {
8131 if ( p30.hasNext() ) {
8134 if ( p30.next() != null ) {
8137 if ( p30.next() != null ) {
8141 catch ( final Exception e ) {
8142 e.printStackTrace( System.out );
8148 private static boolean testNHXconversion() {
8150 final PhylogenyNode n1 = new PhylogenyNode();
8151 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8152 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8153 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8154 final PhylogenyNode n5 = PhylogenyNode
8155 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8156 final PhylogenyNode n6 = PhylogenyNode
8157 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8158 if ( !n1.toNewHampshireX().equals( "" ) ) {
8161 if ( !n2.toNewHampshireX().equals( "" ) ) {
8164 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8167 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8170 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8173 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8174 System.out.println( n6.toNewHampshireX() );
8178 catch ( final Exception e ) {
8179 e.printStackTrace( System.out );
8185 private static boolean testNHXNodeParsing() {
8187 final PhylogenyNode n1 = new PhylogenyNode();
8188 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8189 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8190 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8191 final PhylogenyNode n5 = PhylogenyNode
8192 .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]" );
8193 if ( !n3.getName().equals( "n3" ) ) {
8196 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8199 if ( n3.isDuplication() ) {
8202 if ( n3.isHasAssignedEvent() ) {
8205 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8208 if ( !n4.getName().equals( "n4" ) ) {
8211 if ( n4.getDistanceToParent() != 0.01 ) {
8214 if ( !n5.getName().equals( "n5" ) ) {
8217 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8220 if ( n5.getDistanceToParent() != 0.1 ) {
8223 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8226 if ( !n5.isDuplication() ) {
8229 if ( !n5.isHasAssignedEvent() ) {
8232 final PhylogenyNode n8 = PhylogenyNode
8233 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8234 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8235 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8238 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8241 final PhylogenyNode n9 = PhylogenyNode
8242 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8243 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8244 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8247 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8250 final PhylogenyNode n10 = PhylogenyNode
8251 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8252 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8255 final PhylogenyNode n20 = PhylogenyNode
8256 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8257 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8260 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8263 final PhylogenyNode n20x = PhylogenyNode
8264 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8265 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8268 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8271 final PhylogenyNode n20xx = PhylogenyNode
8272 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8273 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8276 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8279 final PhylogenyNode n20xxx = PhylogenyNode
8280 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8281 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8284 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8287 final PhylogenyNode n20xxxx = PhylogenyNode
8288 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8289 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8292 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8295 final PhylogenyNode n21 = PhylogenyNode
8296 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8297 if ( !n21.getName().equals( "N21_PIG" ) ) {
8300 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8303 final PhylogenyNode n21x = PhylogenyNode
8304 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8305 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8308 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8311 final PhylogenyNode n22 = PhylogenyNode
8312 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8313 if ( !n22.getName().equals( "n22/PIG" ) ) {
8316 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8319 final PhylogenyNode n23 = PhylogenyNode
8320 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8321 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8324 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8327 final PhylogenyNode a = PhylogenyNode
8328 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8329 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8332 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8335 final PhylogenyNode c1 = PhylogenyNode
8336 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8337 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8338 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8341 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8344 final PhylogenyNode c2 = PhylogenyNode
8345 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8346 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8347 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8350 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8353 final PhylogenyNode e3 = PhylogenyNode
8354 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8355 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8358 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8361 final PhylogenyNode n11 = PhylogenyNode
8362 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8363 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8364 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8367 if ( n11.getDistanceToParent() != 0.4 ) {
8370 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8373 final PhylogenyNode n12 = PhylogenyNode
8374 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8375 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8376 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8379 if ( n12.getDistanceToParent() != 0.4 ) {
8382 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8385 final PhylogenyNode o = PhylogenyNode
8386 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8387 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8390 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8393 if ( n1.getName().compareTo( "" ) != 0 ) {
8396 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8399 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8402 if ( n2.getName().compareTo( "" ) != 0 ) {
8405 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8408 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8411 final PhylogenyNode n00 = PhylogenyNode
8412 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8413 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8416 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8419 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8420 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8423 final PhylogenyNode n13 = PhylogenyNode
8424 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8425 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
8428 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8431 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8434 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8437 final PhylogenyNode n14 = PhylogenyNode
8438 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8439 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8442 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8445 final PhylogenyNode n15 = PhylogenyNode
8446 .createInstanceFromNhxString( "something_wicked[123]",
8447 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8448 if ( !n15.getName().equals( "something_wicked" ) ) {
8451 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8454 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8457 final PhylogenyNode n16 = PhylogenyNode
8458 .createInstanceFromNhxString( "something_wicked2[9]",
8459 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8460 if ( !n16.getName().equals( "something_wicked2" ) ) {
8463 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8466 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8469 final PhylogenyNode n17 = PhylogenyNode
8470 .createInstanceFromNhxString( "something_wicked3[a]",
8471 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8472 if ( !n17.getName().equals( "something_wicked3" ) ) {
8475 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8478 final PhylogenyNode n18 = PhylogenyNode
8479 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8480 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8483 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8486 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8489 final PhylogenyNode n19 = PhylogenyNode
8490 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8491 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8494 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8497 final PhylogenyNode n30 = PhylogenyNode
8498 .createInstanceFromNhxString( "blah_1234567-roejojoej",
8499 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8500 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8503 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8506 final PhylogenyNode n31 = PhylogenyNode
8507 .createInstanceFromNhxString( "blah_12345678-roejojoej",
8508 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8509 if ( n31.getNodeData().isHasTaxonomy() ) {
8512 final PhylogenyNode n32 = PhylogenyNode
8513 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8514 if ( n32.getNodeData().isHasTaxonomy() ) {
8517 final PhylogenyNode n40 = PhylogenyNode
8518 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8519 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8522 final PhylogenyNode n41 = PhylogenyNode
8523 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8524 if ( n41.getNodeData().isHasTaxonomy() ) {
8527 final PhylogenyNode n42 = PhylogenyNode
8528 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8529 if ( n42.getNodeData().isHasTaxonomy() ) {
8532 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8533 NHXParser.TAXONOMY_EXTRACTION.NO );
8534 if ( n43.getNodeData().isHasTaxonomy() ) {
8537 final PhylogenyNode n44 = PhylogenyNode
8538 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8539 if ( n44.getNodeData().isHasTaxonomy() ) {
8543 catch ( final Exception e ) {
8544 e.printStackTrace( System.out );
8550 private static boolean testNHXParsing() {
8552 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8553 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8554 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8557 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]";
8558 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8559 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8562 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]";
8563 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8564 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8567 final Phylogeny[] p3 = factory
8568 .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]",
8570 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8573 final Phylogeny[] p4 = factory
8574 .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(]",
8576 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8579 final Phylogeny[] p5 = factory
8580 .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(((]",
8582 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8585 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)";
8586 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)";
8587 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8588 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8591 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)))";
8592 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)))";
8593 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8594 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8597 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]) ))[,,, ])))))))";
8598 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8599 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8600 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8603 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8604 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8607 final Phylogeny p10 = factory
8608 .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]",
8609 new NHXParser() )[ 0 ];
8610 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8614 catch ( final Exception e ) {
8615 e.printStackTrace( System.out );
8621 private static boolean testNHXParsingMB() {
8623 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8624 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+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}])", new NHXParser() )[ 0 ];
8633 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8636 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8639 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8640 0.1100000000000000e+00 ) ) {
8643 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8646 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8649 final Phylogeny p2 = factory
8650 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8651 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8652 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8653 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8654 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8655 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8656 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8657 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8658 + "7.369400000000000e-02}])",
8659 new NHXParser() )[ 0 ];
8660 if ( p2.getNode( "1" ) == null ) {
8663 if ( p2.getNode( "2" ) == null ) {
8667 catch ( final Exception e ) {
8668 e.printStackTrace( System.out );
8675 private static boolean testNHXParsingQuotes() {
8677 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8678 final NHXParser p = new NHXParser();
8679 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8680 if ( phylogenies_0.length != 5 ) {
8683 final Phylogeny phy = phylogenies_0[ 4 ];
8684 if ( phy.getNumberOfExternalNodes() != 7 ) {
8687 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8690 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8693 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8694 .getScientificName().equals( "hsapiens" ) ) {
8697 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8700 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8703 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8706 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8709 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8712 final NHXParser p1p = new NHXParser();
8713 p1p.setIgnoreQuotes( true );
8714 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8715 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8718 final NHXParser p2p = new NHXParser();
8719 p1p.setIgnoreQuotes( false );
8720 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8721 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8724 final NHXParser p3p = new NHXParser();
8725 p3p.setIgnoreQuotes( false );
8726 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8727 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8730 final NHXParser p4p = new NHXParser();
8731 p4p.setIgnoreQuotes( false );
8732 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8733 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8736 final Phylogeny p10 = factory
8737 .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]",
8738 new NHXParser() )[ 0 ];
8739 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]";
8740 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8743 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8744 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8748 final Phylogeny p12 = factory
8749 .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]",
8750 new NHXParser() )[ 0 ];
8751 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]";
8752 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8755 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8756 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8759 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;";
8760 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8763 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8764 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8768 catch ( final Exception e ) {
8769 e.printStackTrace( System.out );
8775 private static boolean testNodeRemoval() {
8777 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8778 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8779 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8780 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8783 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8784 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8785 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8788 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8789 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8790 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8794 catch ( final Exception e ) {
8795 e.printStackTrace( System.out );
8801 private static boolean testPhylogenyBranch() {
8803 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8804 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8805 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8806 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8807 if ( !a1b1.equals( a1b1 ) ) {
8810 if ( !a1b1.equals( b1a1 ) ) {
8813 if ( !b1a1.equals( a1b1 ) ) {
8816 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8817 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8818 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8819 if ( a1_b1.equals( b1_a1 ) ) {
8822 if ( a1_b1.equals( a1_b1_ ) ) {
8825 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8826 if ( !a1_b1.equals( b1_a1_ ) ) {
8829 if ( a1_b1_.equals( b1_a1_ ) ) {
8832 if ( !a1_b1_.equals( b1_a1 ) ) {
8836 catch ( final Exception e ) {
8837 e.printStackTrace( System.out );
8843 private static boolean testPhyloXMLparsingOfDistributionElement() {
8845 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8846 PhyloXmlParser xml_parser = null;
8848 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8850 catch ( final Exception e ) {
8851 // Do nothing -- means were not running from jar.
8853 if ( xml_parser == null ) {
8854 xml_parser = PhyloXmlParser.createPhyloXmlParser();
8855 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8856 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8859 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8862 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8864 if ( xml_parser.getErrorCount() > 0 ) {
8865 System.out.println( xml_parser.getErrorMessages().toString() );
8868 if ( phylogenies_0.length != 1 ) {
8871 final Phylogeny t1 = phylogenies_0[ 0 ];
8872 PhylogenyNode n = null;
8873 Distribution d = null;
8874 n = t1.getNode( "root node" );
8875 if ( !n.getNodeData().isHasDistribution() ) {
8878 if ( n.getNodeData().getDistributions().size() != 1 ) {
8881 d = n.getNodeData().getDistribution();
8882 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8885 if ( d.getPoints().size() != 1 ) {
8888 if ( d.getPolygons() != null ) {
8891 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8894 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8897 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8900 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8903 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8906 n = t1.getNode( "node a" );
8907 if ( !n.getNodeData().isHasDistribution() ) {
8910 if ( n.getNodeData().getDistributions().size() != 2 ) {
8913 d = n.getNodeData().getDistribution( 1 );
8914 if ( !d.getDesc().equals( "San Diego" ) ) {
8917 if ( d.getPoints().size() != 1 ) {
8920 if ( d.getPolygons() != null ) {
8923 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8926 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8929 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8932 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8935 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8938 n = t1.getNode( "node bb" );
8939 if ( !n.getNodeData().isHasDistribution() ) {
8942 if ( n.getNodeData().getDistributions().size() != 1 ) {
8945 d = n.getNodeData().getDistribution( 0 );
8946 if ( d.getPoints().size() != 3 ) {
8949 if ( d.getPolygons().size() != 2 ) {
8952 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8955 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8958 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8961 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8964 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8967 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8970 Polygon p = d.getPolygons().get( 0 );
8971 if ( p.getPoints().size() != 3 ) {
8974 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8977 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8980 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8983 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8986 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8989 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8992 p = d.getPolygons().get( 1 );
8993 if ( p.getPoints().size() != 3 ) {
8996 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8999 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9002 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9006 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9007 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9008 if ( rt.length != 1 ) {
9011 final Phylogeny t1_rt = rt[ 0 ];
9012 n = t1_rt.getNode( "root node" );
9013 if ( !n.getNodeData().isHasDistribution() ) {
9016 if ( n.getNodeData().getDistributions().size() != 1 ) {
9019 d = n.getNodeData().getDistribution();
9020 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9023 if ( d.getPoints().size() != 1 ) {
9026 if ( d.getPolygons() != null ) {
9029 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9032 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9035 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9038 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9041 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9044 n = t1_rt.getNode( "node a" );
9045 if ( !n.getNodeData().isHasDistribution() ) {
9048 if ( n.getNodeData().getDistributions().size() != 2 ) {
9051 d = n.getNodeData().getDistribution( 1 );
9052 if ( !d.getDesc().equals( "San Diego" ) ) {
9055 if ( d.getPoints().size() != 1 ) {
9058 if ( d.getPolygons() != null ) {
9061 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9064 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9067 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9070 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9073 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9076 n = t1_rt.getNode( "node bb" );
9077 if ( !n.getNodeData().isHasDistribution() ) {
9080 if ( n.getNodeData().getDistributions().size() != 1 ) {
9083 d = n.getNodeData().getDistribution( 0 );
9084 if ( d.getPoints().size() != 3 ) {
9087 if ( d.getPolygons().size() != 2 ) {
9090 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9093 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9096 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9099 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9102 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9105 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9108 p = d.getPolygons().get( 0 );
9109 if ( p.getPoints().size() != 3 ) {
9112 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9115 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9118 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9121 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9124 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9127 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9130 p = d.getPolygons().get( 1 );
9131 if ( p.getPoints().size() != 3 ) {
9134 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9137 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9140 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9144 catch ( final Exception e ) {
9145 e.printStackTrace( System.out );
9151 private static boolean testPostOrderIterator() {
9153 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9154 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9155 PhylogenyNodeIterator it0;
9156 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9159 for( it0.reset(); it0.hasNext(); ) {
9162 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9163 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9164 if ( !it.next().getName().equals( "A" ) ) {
9167 if ( !it.next().getName().equals( "B" ) ) {
9170 if ( !it.next().getName().equals( "ab" ) ) {
9173 if ( !it.next().getName().equals( "C" ) ) {
9176 if ( !it.next().getName().equals( "D" ) ) {
9179 if ( !it.next().getName().equals( "cd" ) ) {
9182 if ( !it.next().getName().equals( "abcd" ) ) {
9185 if ( !it.next().getName().equals( "E" ) ) {
9188 if ( !it.next().getName().equals( "F" ) ) {
9191 if ( !it.next().getName().equals( "ef" ) ) {
9194 if ( !it.next().getName().equals( "G" ) ) {
9197 if ( !it.next().getName().equals( "H" ) ) {
9200 if ( !it.next().getName().equals( "gh" ) ) {
9203 if ( !it.next().getName().equals( "efgh" ) ) {
9206 if ( !it.next().getName().equals( "r" ) ) {
9209 if ( it.hasNext() ) {
9213 catch ( final Exception e ) {
9214 e.printStackTrace( System.out );
9220 private static boolean testPreOrderIterator() {
9222 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9223 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9224 PhylogenyNodeIterator it0;
9225 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9228 for( it0.reset(); it0.hasNext(); ) {
9231 PhylogenyNodeIterator it = t0.iteratorPreorder();
9232 if ( !it.next().getName().equals( "r" ) ) {
9235 if ( !it.next().getName().equals( "ab" ) ) {
9238 if ( !it.next().getName().equals( "A" ) ) {
9241 if ( !it.next().getName().equals( "B" ) ) {
9244 if ( !it.next().getName().equals( "cd" ) ) {
9247 if ( !it.next().getName().equals( "C" ) ) {
9250 if ( !it.next().getName().equals( "D" ) ) {
9253 if ( it.hasNext() ) {
9256 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9257 it = t1.iteratorPreorder();
9258 if ( !it.next().getName().equals( "r" ) ) {
9261 if ( !it.next().getName().equals( "abcd" ) ) {
9264 if ( !it.next().getName().equals( "ab" ) ) {
9267 if ( !it.next().getName().equals( "A" ) ) {
9270 if ( !it.next().getName().equals( "B" ) ) {
9273 if ( !it.next().getName().equals( "cd" ) ) {
9276 if ( !it.next().getName().equals( "C" ) ) {
9279 if ( !it.next().getName().equals( "D" ) ) {
9282 if ( !it.next().getName().equals( "efgh" ) ) {
9285 if ( !it.next().getName().equals( "ef" ) ) {
9288 if ( !it.next().getName().equals( "E" ) ) {
9291 if ( !it.next().getName().equals( "F" ) ) {
9294 if ( !it.next().getName().equals( "gh" ) ) {
9297 if ( !it.next().getName().equals( "G" ) ) {
9300 if ( !it.next().getName().equals( "H" ) ) {
9303 if ( it.hasNext() ) {
9307 catch ( final Exception e ) {
9308 e.printStackTrace( System.out );
9314 private static boolean testPropertiesMap() {
9316 final PropertiesMap pm = new PropertiesMap();
9317 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9318 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9319 final Property p2 = new Property( "something:else",
9321 "improbable:research",
9324 pm.addProperty( p0 );
9325 pm.addProperty( p1 );
9326 pm.addProperty( p2 );
9327 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9330 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9333 if ( pm.getProperties().size() != 3 ) {
9336 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9339 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9342 if ( pm.getProperties().size() != 3 ) {
9345 pm.removeProperty( "dimensions:diameter" );
9346 if ( pm.getProperties().size() != 2 ) {
9349 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9352 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9356 catch ( final Exception e ) {
9357 e.printStackTrace( System.out );
9363 private static boolean testProteinId() {
9365 final ProteinId id1 = new ProteinId( "a" );
9366 final ProteinId id2 = new ProteinId( "a" );
9367 final ProteinId id3 = new ProteinId( "A" );
9368 final ProteinId id4 = new ProteinId( "b" );
9369 if ( !id1.equals( id1 ) ) {
9372 if ( id1.getId().equals( "x" ) ) {
9375 if ( id1.getId().equals( null ) ) {
9378 if ( !id1.equals( id2 ) ) {
9381 if ( id1.equals( id3 ) ) {
9384 if ( id1.hashCode() != id1.hashCode() ) {
9387 if ( id1.hashCode() != id2.hashCode() ) {
9390 if ( id1.hashCode() == id3.hashCode() ) {
9393 if ( id1.compareTo( id1 ) != 0 ) {
9396 if ( id1.compareTo( id2 ) != 0 ) {
9399 if ( id1.compareTo( id3 ) != 0 ) {
9402 if ( id1.compareTo( id4 ) >= 0 ) {
9405 if ( id4.compareTo( id1 ) <= 0 ) {
9408 if ( !id4.getId().equals( "b" ) ) {
9411 final ProteinId id5 = new ProteinId( " C " );
9412 if ( !id5.getId().equals( "C" ) ) {
9415 if ( id5.equals( id1 ) ) {
9419 catch ( final Exception e ) {
9420 e.printStackTrace( System.out );
9426 private static boolean testReIdMethods() {
9428 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9429 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9430 final long count = PhylogenyNode.getNodeCount();
9432 if ( p.getNode( "r" ).getId() != count ) {
9435 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9438 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9441 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9444 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9447 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9450 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9453 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9456 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9459 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9462 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9465 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9468 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9471 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9474 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9478 catch ( final Exception e ) {
9479 e.printStackTrace( System.out );
9485 private static boolean testRerooting() {
9487 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9488 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",
9489 new NHXParser() )[ 0 ];
9490 if ( !t1.isRooted() ) {
9493 t1.reRoot( t1.getNode( "D" ) );
9494 t1.reRoot( t1.getNode( "CD" ) );
9495 t1.reRoot( t1.getNode( "A" ) );
9496 t1.reRoot( t1.getNode( "B" ) );
9497 t1.reRoot( t1.getNode( "AB" ) );
9498 t1.reRoot( t1.getNode( "D" ) );
9499 t1.reRoot( t1.getNode( "C" ) );
9500 t1.reRoot( t1.getNode( "CD" ) );
9501 t1.reRoot( t1.getNode( "A" ) );
9502 t1.reRoot( t1.getNode( "B" ) );
9503 t1.reRoot( t1.getNode( "AB" ) );
9504 t1.reRoot( t1.getNode( "D" ) );
9505 t1.reRoot( t1.getNode( "D" ) );
9506 t1.reRoot( t1.getNode( "C" ) );
9507 t1.reRoot( t1.getNode( "A" ) );
9508 t1.reRoot( t1.getNode( "B" ) );
9509 t1.reRoot( t1.getNode( "AB" ) );
9510 t1.reRoot( t1.getNode( "C" ) );
9511 t1.reRoot( t1.getNode( "D" ) );
9512 t1.reRoot( t1.getNode( "CD" ) );
9513 t1.reRoot( t1.getNode( "D" ) );
9514 t1.reRoot( t1.getNode( "A" ) );
9515 t1.reRoot( t1.getNode( "B" ) );
9516 t1.reRoot( t1.getNode( "AB" ) );
9517 t1.reRoot( t1.getNode( "C" ) );
9518 t1.reRoot( t1.getNode( "D" ) );
9519 t1.reRoot( t1.getNode( "CD" ) );
9520 t1.reRoot( t1.getNode( "D" ) );
9521 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9524 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9527 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9530 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9533 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9536 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9539 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",
9540 new NHXParser() )[ 0 ];
9541 t2.reRoot( t2.getNode( "A" ) );
9542 t2.reRoot( t2.getNode( "D" ) );
9543 t2.reRoot( t2.getNode( "ABC" ) );
9544 t2.reRoot( t2.getNode( "A" ) );
9545 t2.reRoot( t2.getNode( "B" ) );
9546 t2.reRoot( t2.getNode( "D" ) );
9547 t2.reRoot( t2.getNode( "C" ) );
9548 t2.reRoot( t2.getNode( "ABC" ) );
9549 t2.reRoot( t2.getNode( "A" ) );
9550 t2.reRoot( t2.getNode( "B" ) );
9551 t2.reRoot( t2.getNode( "AB" ) );
9552 t2.reRoot( t2.getNode( "AB" ) );
9553 t2.reRoot( t2.getNode( "D" ) );
9554 t2.reRoot( t2.getNode( "C" ) );
9555 t2.reRoot( t2.getNode( "B" ) );
9556 t2.reRoot( t2.getNode( "AB" ) );
9557 t2.reRoot( t2.getNode( "D" ) );
9558 t2.reRoot( t2.getNode( "D" ) );
9559 t2.reRoot( t2.getNode( "ABC" ) );
9560 t2.reRoot( t2.getNode( "A" ) );
9561 t2.reRoot( t2.getNode( "B" ) );
9562 t2.reRoot( t2.getNode( "AB" ) );
9563 t2.reRoot( t2.getNode( "D" ) );
9564 t2.reRoot( t2.getNode( "C" ) );
9565 t2.reRoot( t2.getNode( "ABC" ) );
9566 t2.reRoot( t2.getNode( "A" ) );
9567 t2.reRoot( t2.getNode( "B" ) );
9568 t2.reRoot( t2.getNode( "AB" ) );
9569 t2.reRoot( t2.getNode( "D" ) );
9570 t2.reRoot( t2.getNode( "D" ) );
9571 t2.reRoot( t2.getNode( "C" ) );
9572 t2.reRoot( t2.getNode( "A" ) );
9573 t2.reRoot( t2.getNode( "B" ) );
9574 t2.reRoot( t2.getNode( "AB" ) );
9575 t2.reRoot( t2.getNode( "C" ) );
9576 t2.reRoot( t2.getNode( "D" ) );
9577 t2.reRoot( t2.getNode( "ABC" ) );
9578 t2.reRoot( t2.getNode( "D" ) );
9579 t2.reRoot( t2.getNode( "A" ) );
9580 t2.reRoot( t2.getNode( "B" ) );
9581 t2.reRoot( t2.getNode( "AB" ) );
9582 t2.reRoot( t2.getNode( "C" ) );
9583 t2.reRoot( t2.getNode( "D" ) );
9584 t2.reRoot( t2.getNode( "ABC" ) );
9585 t2.reRoot( t2.getNode( "D" ) );
9586 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9589 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9592 t2.reRoot( t2.getNode( "ABC" ) );
9593 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9596 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9599 t2.reRoot( t2.getNode( "AB" ) );
9600 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9603 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9606 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9609 t2.reRoot( t2.getNode( "AB" ) );
9610 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9613 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9616 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9619 t2.reRoot( t2.getNode( "D" ) );
9620 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9623 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9626 t2.reRoot( t2.getNode( "ABC" ) );
9627 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9630 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9633 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9634 new NHXParser() )[ 0 ];
9635 t3.reRoot( t3.getNode( "B" ) );
9636 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9639 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9642 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9645 t3.reRoot( t3.getNode( "B" ) );
9646 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9649 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9652 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9655 t3.reRoot( t3.getRoot() );
9656 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9659 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9662 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9666 catch ( final Exception e ) {
9667 e.printStackTrace( System.out );
9673 private static boolean testSDIse() {
9675 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9676 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9677 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9678 gene1.setRooted( true );
9679 species1.setRooted( true );
9680 final SDI sdi = new SDI( gene1, species1 );
9681 if ( !gene1.getRoot().isDuplication() ) {
9684 final Phylogeny species2 = factory
9685 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9686 new NHXParser() )[ 0 ];
9687 final Phylogeny gene2 = factory
9688 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9689 new NHXParser() )[ 0 ];
9690 species2.setRooted( true );
9691 gene2.setRooted( true );
9692 final SDI sdi2 = new SDI( gene2, species2 );
9693 if ( sdi2.getDuplicationsSum() != 0 ) {
9696 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9699 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9702 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9705 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9708 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9711 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9714 final Phylogeny species3 = factory
9715 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9716 new NHXParser() )[ 0 ];
9717 final Phylogeny gene3 = factory
9718 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9719 new NHXParser() )[ 0 ];
9720 species3.setRooted( true );
9721 gene3.setRooted( true );
9722 final SDI sdi3 = new SDI( gene3, species3 );
9723 if ( sdi3.getDuplicationsSum() != 1 ) {
9726 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9729 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9732 final Phylogeny species4 = factory
9733 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9734 new NHXParser() )[ 0 ];
9735 final Phylogeny gene4 = factory
9736 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9737 new NHXParser() )[ 0 ];
9738 species4.setRooted( true );
9739 gene4.setRooted( true );
9740 final SDI sdi4 = new SDI( gene4, species4 );
9741 if ( sdi4.getDuplicationsSum() != 1 ) {
9744 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9747 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9750 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9753 if ( species4.getNumberOfExternalNodes() != 6 ) {
9756 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9759 final Phylogeny species5 = factory
9760 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9761 new NHXParser() )[ 0 ];
9762 final Phylogeny gene5 = factory
9763 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9764 new NHXParser() )[ 0 ];
9765 species5.setRooted( true );
9766 gene5.setRooted( true );
9767 final SDI sdi5 = new SDI( gene5, species5 );
9768 if ( sdi5.getDuplicationsSum() != 2 ) {
9771 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9774 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9777 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9780 if ( species5.getNumberOfExternalNodes() != 6 ) {
9783 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9786 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9787 // Conjecture for Comparing Molecular Phylogenies"
9788 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9789 final Phylogeny species6 = factory
9790 .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,"
9791 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9792 new NHXParser() )[ 0 ];
9793 final Phylogeny gene6 = factory
9794 .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,"
9795 + "((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,"
9796 + "(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;",
9797 new NHXParser() )[ 0 ];
9798 species6.setRooted( true );
9799 gene6.setRooted( true );
9800 final SDI sdi6 = new SDI( gene6, species6 );
9801 if ( sdi6.getDuplicationsSum() != 3 ) {
9804 if ( !gene6.getNode( "r" ).isDuplication() ) {
9807 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9810 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9813 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9816 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9819 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9822 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9825 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9828 sdi6.computeMappingCostL();
9829 if ( sdi6.computeMappingCostL() != 17 ) {
9832 if ( species6.getNumberOfExternalNodes() != 9 ) {
9835 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9838 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9839 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9840 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9841 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9842 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9843 species7.setRooted( true );
9844 final Phylogeny gene7_1 = Test
9845 .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])" );
9846 gene7_1.setRooted( true );
9847 final SDI sdi7 = new SDI( gene7_1, species7 );
9848 if ( sdi7.getDuplicationsSum() != 0 ) {
9851 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9854 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9857 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9860 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9863 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9866 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9869 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9872 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9875 final Phylogeny gene7_2 = Test
9876 .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])" );
9877 gene7_2.setRooted( true );
9878 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9879 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9882 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9885 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9888 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9891 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9894 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9897 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9900 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9903 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9906 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9910 catch ( final Exception e ) {
9916 private static boolean testSDIunrooted() {
9918 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9919 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9920 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9921 final Iterator<PhylogenyBranch> iter = l.iterator();
9922 PhylogenyBranch br = iter.next();
9923 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9926 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9930 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9933 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9937 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9940 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9944 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9947 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9951 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9954 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9958 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9961 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9965 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9968 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9972 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9975 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9979 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9982 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9986 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9989 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9993 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9996 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10000 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10003 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10007 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10010 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10014 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10017 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10021 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10024 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10027 if ( iter.hasNext() ) {
10030 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10031 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10032 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10034 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10037 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10041 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10044 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10048 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10051 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10054 if ( iter1.hasNext() ) {
10057 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10058 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10059 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10061 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10064 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10068 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10071 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10075 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10078 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10081 if ( iter2.hasNext() ) {
10084 final Phylogeny species0 = factory
10085 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10086 new NHXParser() )[ 0 ];
10087 final Phylogeny gene1 = factory
10088 .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])",
10089 new NHXParser() )[ 0 ];
10090 species0.setRooted( true );
10091 gene1.setRooted( true );
10092 final SDIR sdi_unrooted = new SDIR();
10093 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10094 if ( sdi_unrooted.getCount() != 1 ) {
10097 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10100 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10103 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10106 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10109 final Phylogeny gene2 = factory
10110 .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])",
10111 new NHXParser() )[ 0 ];
10112 gene2.setRooted( true );
10113 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10114 if ( sdi_unrooted.getCount() != 1 ) {
10117 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10120 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10123 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10126 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10129 final Phylogeny species6 = factory
10130 .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,"
10131 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10132 new NHXParser() )[ 0 ];
10133 final Phylogeny gene6 = factory
10134 .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],"
10135 + "(((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],"
10136 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10137 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10138 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10139 new NHXParser() )[ 0 ];
10140 species6.setRooted( true );
10141 gene6.setRooted( true );
10142 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10143 if ( sdi_unrooted.getCount() != 1 ) {
10146 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10149 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10152 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10155 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10158 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10161 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10164 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10167 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10170 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10173 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10176 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10179 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10183 final Phylogeny species7 = factory
10184 .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,"
10185 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10186 new NHXParser() )[ 0 ];
10187 final Phylogeny gene7 = factory
10188 .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],"
10189 + "(((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],"
10190 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10191 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10192 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10193 new NHXParser() )[ 0 ];
10194 species7.setRooted( true );
10195 gene7.setRooted( true );
10196 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10197 if ( sdi_unrooted.getCount() != 1 ) {
10200 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10203 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10206 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10209 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10212 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10215 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10218 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10221 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10224 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10227 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10230 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10233 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10237 final Phylogeny species8 = factory
10238 .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,"
10239 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10240 new NHXParser() )[ 0 ];
10241 final Phylogeny gene8 = factory
10242 .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],"
10243 + "(((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],"
10244 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10245 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10246 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10247 new NHXParser() )[ 0 ];
10248 species8.setRooted( true );
10249 gene8.setRooted( true );
10250 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10251 if ( sdi_unrooted.getCount() != 1 ) {
10254 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10257 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10260 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10263 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10266 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10269 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10272 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10275 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10278 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10281 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10284 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10287 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10292 catch ( final Exception e ) {
10293 e.printStackTrace( System.out );
10299 private static boolean testSequenceDbWsTools1() {
10301 final PhylogenyNode n = new PhylogenyNode();
10302 n.setName( "NP_001025424" );
10303 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10304 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10305 || !acc.getValue().equals( "NP_001025424" ) ) {
10308 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10309 acc = SequenceDbWsTools.obtainSeqAccession( n );
10310 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10311 || !acc.getValue().equals( "NP_001025424" ) ) {
10314 n.setName( "NP_001025424.1" );
10315 acc = SequenceDbWsTools.obtainSeqAccession( n );
10316 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10317 || !acc.getValue().equals( "NP_001025424" ) ) {
10320 n.setName( "NM_001030253" );
10321 acc = SequenceDbWsTools.obtainSeqAccession( n );
10322 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10323 || !acc.getValue().equals( "NM_001030253" ) ) {
10326 n.setName( "BCL2_HUMAN" );
10327 acc = SequenceDbWsTools.obtainSeqAccession( n );
10328 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10329 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10330 System.out.println( acc.toString() );
10333 n.setName( "P10415" );
10334 acc = SequenceDbWsTools.obtainSeqAccession( n );
10335 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10336 || !acc.getValue().equals( "P10415" ) ) {
10337 System.out.println( acc.toString() );
10340 n.setName( " P10415 " );
10341 acc = SequenceDbWsTools.obtainSeqAccession( n );
10342 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10343 || !acc.getValue().equals( "P10415" ) ) {
10344 System.out.println( acc.toString() );
10347 n.setName( "_P10415|" );
10348 acc = SequenceDbWsTools.obtainSeqAccession( n );
10349 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10350 || !acc.getValue().equals( "P10415" ) ) {
10351 System.out.println( acc.toString() );
10354 n.setName( "AY695820" );
10355 acc = SequenceDbWsTools.obtainSeqAccession( n );
10356 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10357 || !acc.getValue().equals( "AY695820" ) ) {
10358 System.out.println( acc.toString() );
10361 n.setName( "_AY695820_" );
10362 acc = SequenceDbWsTools.obtainSeqAccession( n );
10363 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10364 || !acc.getValue().equals( "AY695820" ) ) {
10365 System.out.println( acc.toString() );
10368 n.setName( "AAA59452" );
10369 acc = SequenceDbWsTools.obtainSeqAccession( n );
10370 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10371 || !acc.getValue().equals( "AAA59452" ) ) {
10372 System.out.println( acc.toString() );
10375 n.setName( "_AAA59452_" );
10376 acc = SequenceDbWsTools.obtainSeqAccession( n );
10377 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10378 || !acc.getValue().equals( "AAA59452" ) ) {
10379 System.out.println( acc.toString() );
10382 n.setName( "AAA59452.1" );
10383 acc = SequenceDbWsTools.obtainSeqAccession( n );
10384 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10385 || !acc.getValue().equals( "AAA59452.1" ) ) {
10386 System.out.println( acc.toString() );
10389 n.setName( "_AAA59452.1_" );
10390 acc = SequenceDbWsTools.obtainSeqAccession( n );
10391 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10392 || !acc.getValue().equals( "AAA59452.1" ) ) {
10393 System.out.println( acc.toString() );
10396 n.setName( "GI:94894583" );
10397 acc = SequenceDbWsTools.obtainSeqAccession( n );
10398 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10399 || !acc.getValue().equals( "94894583" ) ) {
10400 System.out.println( acc.toString() );
10403 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10404 acc = SequenceDbWsTools.obtainSeqAccession( n );
10405 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10406 || !acc.getValue().equals( "71845847" ) ) {
10407 System.out.println( acc.toString() );
10410 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10411 acc = SequenceDbWsTools.obtainSeqAccession( n );
10412 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10413 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10414 System.out.println( acc.toString() );
10418 catch ( final Exception e ) {
10424 private static boolean testSequenceDbWsTools2() {
10426 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10427 SequenceDbWsTools.obtainSeqInformation( n1 );
10428 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10431 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10434 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10437 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10440 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10441 SequenceDbWsTools.obtainSeqInformation( n2 );
10442 if ( !n2.getNodeData().getSequence().getName()
10443 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10446 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10449 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10452 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10455 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10456 SequenceDbWsTools.obtainSeqInformation( n3 );
10457 if ( !n3.getNodeData().getSequence().getName()
10458 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10461 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10464 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10467 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10471 catch ( final IOException e ) {
10472 System.out.println();
10473 System.out.println( "the following might be due to absence internet connection:" );
10474 e.printStackTrace( System.out );
10477 catch ( final Exception e ) {
10478 e.printStackTrace();
10484 private static boolean testSequenceIdParsing() {
10486 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10487 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10488 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10489 if ( id != null ) {
10490 System.out.println( "value =" + id.getValue() );
10491 System.out.println( "provider=" + id.getSource() );
10496 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10497 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10498 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10499 if ( id != null ) {
10500 System.out.println( "value =" + id.getValue() );
10501 System.out.println( "provider=" + id.getSource() );
10506 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10507 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10508 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10509 if ( id != null ) {
10510 System.out.println( "value =" + id.getValue() );
10511 System.out.println( "provider=" + id.getSource() );
10516 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10517 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10518 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10519 if ( id != null ) {
10520 System.out.println( "value =" + id.getValue() );
10521 System.out.println( "provider=" + id.getSource() );
10526 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10527 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10528 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10529 if ( id != null ) {
10530 System.out.println( "value =" + id.getValue() );
10531 System.out.println( "provider=" + id.getSource() );
10536 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10537 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10538 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10539 if ( id != null ) {
10540 System.out.println( "value =" + id.getValue() );
10541 System.out.println( "provider=" + id.getSource() );
10546 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10547 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10548 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10549 if ( id != null ) {
10550 System.out.println( "value =" + id.getValue() );
10551 System.out.println( "provider=" + id.getSource() );
10556 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10557 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10558 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10559 if ( id != null ) {
10560 System.out.println( "value =" + id.getValue() );
10561 System.out.println( "provider=" + id.getSource() );
10566 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10567 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10568 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10569 if ( id != null ) {
10570 System.out.println( "value =" + id.getValue() );
10571 System.out.println( "provider=" + id.getSource() );
10576 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10577 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10578 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10579 if ( id != null ) {
10580 System.out.println( "value =" + id.getValue() );
10581 System.out.println( "provider=" + id.getSource() );
10585 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10586 if ( id != null ) {
10587 System.out.println( "value =" + id.getValue() );
10588 System.out.println( "provider=" + id.getSource() );
10592 catch ( final Exception e ) {
10593 e.printStackTrace( System.out );
10599 private static boolean testSequenceWriter() {
10601 final String n = ForesterUtil.LINE_SEPARATOR;
10602 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10605 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10608 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10611 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10614 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10615 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10618 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10619 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10623 catch ( final Exception e ) {
10624 e.printStackTrace();
10630 private static boolean testSpecies() {
10632 final Species s1 = new BasicSpecies( "a" );
10633 final Species s2 = new BasicSpecies( "a" );
10634 final Species s3 = new BasicSpecies( "A" );
10635 final Species s4 = new BasicSpecies( "b" );
10636 if ( !s1.equals( s1 ) ) {
10639 if ( s1.getSpeciesId().equals( "x" ) ) {
10642 if ( s1.getSpeciesId().equals( null ) ) {
10645 if ( !s1.equals( s2 ) ) {
10648 if ( s1.equals( s3 ) ) {
10651 if ( s1.hashCode() != s1.hashCode() ) {
10654 if ( s1.hashCode() != s2.hashCode() ) {
10657 if ( s1.hashCode() == s3.hashCode() ) {
10660 if ( s1.compareTo( s1 ) != 0 ) {
10663 if ( s1.compareTo( s2 ) != 0 ) {
10666 if ( s1.compareTo( s3 ) != 0 ) {
10669 if ( s1.compareTo( s4 ) >= 0 ) {
10672 if ( s4.compareTo( s1 ) <= 0 ) {
10675 if ( !s4.getSpeciesId().equals( "b" ) ) {
10678 final Species s5 = new BasicSpecies( " C " );
10679 if ( !s5.getSpeciesId().equals( "C" ) ) {
10682 if ( s5.equals( s1 ) ) {
10686 catch ( final Exception e ) {
10687 e.printStackTrace( System.out );
10693 private static boolean testSplit() {
10695 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10696 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10697 //Archaeopteryx.createApplication( p0 );
10698 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10699 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10700 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10701 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10702 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10703 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10704 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10705 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10706 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10707 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10708 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
10709 // System.out.println( s0.toString() );
10711 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10714 if ( s0.match( query_nodes ) ) {
10717 query_nodes = new HashSet<PhylogenyNode>();
10718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10725 if ( !s0.match( query_nodes ) ) {
10729 query_nodes = new HashSet<PhylogenyNode>();
10730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10733 if ( !s0.match( query_nodes ) ) {
10737 query_nodes = new HashSet<PhylogenyNode>();
10738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10740 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10741 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10742 if ( !s0.match( query_nodes ) ) {
10746 query_nodes = new HashSet<PhylogenyNode>();
10747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10749 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10751 if ( !s0.match( query_nodes ) ) {
10755 query_nodes = new HashSet<PhylogenyNode>();
10756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10759 if ( !s0.match( query_nodes ) ) {
10763 query_nodes = new HashSet<PhylogenyNode>();
10764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10766 if ( !s0.match( query_nodes ) ) {
10770 query_nodes = new HashSet<PhylogenyNode>();
10771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10776 if ( !s0.match( query_nodes ) ) {
10780 query_nodes = new HashSet<PhylogenyNode>();
10781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10784 if ( !s0.match( query_nodes ) ) {
10788 query_nodes = new HashSet<PhylogenyNode>();
10789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10793 if ( !s0.match( query_nodes ) ) {
10797 query_nodes = new HashSet<PhylogenyNode>();
10798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10800 if ( s0.match( query_nodes ) ) {
10804 query_nodes = new HashSet<PhylogenyNode>();
10805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10808 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10809 if ( s0.match( query_nodes ) ) {
10813 query_nodes = new HashSet<PhylogenyNode>();
10814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10816 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10817 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10818 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10819 if ( s0.match( query_nodes ) ) {
10823 query_nodes = new HashSet<PhylogenyNode>();
10824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10825 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10827 if ( s0.match( query_nodes ) ) {
10831 query_nodes = new HashSet<PhylogenyNode>();
10832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10834 if ( s0.match( query_nodes ) ) {
10838 query_nodes = new HashSet<PhylogenyNode>();
10839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10841 if ( s0.match( query_nodes ) ) {
10845 query_nodes = new HashSet<PhylogenyNode>();
10846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10848 if ( s0.match( query_nodes ) ) {
10852 query_nodes = new HashSet<PhylogenyNode>();
10853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10855 if ( s0.match( query_nodes ) ) {
10859 query_nodes = new HashSet<PhylogenyNode>();
10860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10862 if ( s0.match( query_nodes ) ) {
10866 query_nodes = new HashSet<PhylogenyNode>();
10867 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10869 if ( s0.match( query_nodes ) ) {
10873 query_nodes = new HashSet<PhylogenyNode>();
10874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10875 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10876 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10877 if ( s0.match( query_nodes ) ) {
10881 query_nodes = new HashSet<PhylogenyNode>();
10882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10885 if ( s0.match( query_nodes ) ) {
10889 query_nodes = new HashSet<PhylogenyNode>();
10890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10893 if ( s0.match( query_nodes ) ) {
10897 query_nodes = new HashSet<PhylogenyNode>();
10898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10902 if ( s0.match( query_nodes ) ) {
10906 // query_nodes = new HashSet<PhylogenyNode>();
10907 // query_nodes.add( new PhylogenyNode( "X" ) );
10908 // query_nodes.add( new PhylogenyNode( "Y" ) );
10909 // query_nodes.add( new PhylogenyNode( "A" ) );
10910 // query_nodes.add( new PhylogenyNode( "B" ) );
10911 // query_nodes.add( new PhylogenyNode( "C" ) );
10912 // query_nodes.add( new PhylogenyNode( "D" ) );
10913 // query_nodes.add( new PhylogenyNode( "E" ) );
10914 // query_nodes.add( new PhylogenyNode( "F" ) );
10915 // query_nodes.add( new PhylogenyNode( "G" ) );
10916 // if ( !s0.match( query_nodes ) ) {
10919 // query_nodes = new HashSet<PhylogenyNode>();
10920 // query_nodes.add( new PhylogenyNode( "X" ) );
10921 // query_nodes.add( new PhylogenyNode( "Y" ) );
10922 // query_nodes.add( new PhylogenyNode( "A" ) );
10923 // query_nodes.add( new PhylogenyNode( "B" ) );
10924 // query_nodes.add( new PhylogenyNode( "C" ) );
10925 // if ( !s0.match( query_nodes ) ) {
10929 // query_nodes = new HashSet<PhylogenyNode>();
10930 // query_nodes.add( new PhylogenyNode( "X" ) );
10931 // query_nodes.add( new PhylogenyNode( "Y" ) );
10932 // query_nodes.add( new PhylogenyNode( "D" ) );
10933 // query_nodes.add( new PhylogenyNode( "E" ) );
10934 // query_nodes.add( new PhylogenyNode( "F" ) );
10935 // query_nodes.add( new PhylogenyNode( "G" ) );
10936 // if ( !s0.match( query_nodes ) ) {
10940 // query_nodes = new HashSet<PhylogenyNode>();
10941 // query_nodes.add( new PhylogenyNode( "X" ) );
10942 // query_nodes.add( new PhylogenyNode( "Y" ) );
10943 // query_nodes.add( new PhylogenyNode( "A" ) );
10944 // query_nodes.add( new PhylogenyNode( "B" ) );
10945 // query_nodes.add( new PhylogenyNode( "C" ) );
10946 // query_nodes.add( new PhylogenyNode( "D" ) );
10947 // if ( !s0.match( query_nodes ) ) {
10951 // query_nodes = new HashSet<PhylogenyNode>();
10952 // query_nodes.add( new PhylogenyNode( "X" ) );
10953 // query_nodes.add( new PhylogenyNode( "Y" ) );
10954 // query_nodes.add( new PhylogenyNode( "E" ) );
10955 // query_nodes.add( new PhylogenyNode( "F" ) );
10956 // query_nodes.add( new PhylogenyNode( "G" ) );
10957 // if ( !s0.match( query_nodes ) ) {
10961 // query_nodes = new HashSet<PhylogenyNode>();
10962 // query_nodes.add( new PhylogenyNode( "X" ) );
10963 // query_nodes.add( new PhylogenyNode( "Y" ) );
10964 // query_nodes.add( new PhylogenyNode( "F" ) );
10965 // query_nodes.add( new PhylogenyNode( "G" ) );
10966 // if ( !s0.match( query_nodes ) ) {
10970 query_nodes = new HashSet<PhylogenyNode>();
10971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10975 if ( s0.match( query_nodes ) ) {
10979 query_nodes = new HashSet<PhylogenyNode>();
10980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10984 if ( s0.match( query_nodes ) ) {
10987 ///////////////////////////
10989 query_nodes = new HashSet<PhylogenyNode>();
10990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10994 if ( s0.match( query_nodes ) ) {
10998 query_nodes = new HashSet<PhylogenyNode>();
10999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11003 if ( s0.match( query_nodes ) ) {
11007 query_nodes = new HashSet<PhylogenyNode>();
11008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
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( "E" ) );
11021 if ( s0.match( query_nodes ) ) {
11025 query_nodes = new HashSet<PhylogenyNode>();
11026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11027 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11030 if ( s0.match( query_nodes ) ) {
11034 query_nodes = new HashSet<PhylogenyNode>();
11035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11038 if ( s0.match( query_nodes ) ) {
11042 query_nodes = new HashSet<PhylogenyNode>();
11043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11046 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11048 if ( s0.match( query_nodes ) ) {
11052 query_nodes = new HashSet<PhylogenyNode>();
11053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11056 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11058 if ( s0.match( query_nodes ) ) {
11062 query_nodes = new HashSet<PhylogenyNode>();
11063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11066 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11068 if ( s0.match( query_nodes ) ) {
11072 query_nodes = new HashSet<PhylogenyNode>();
11073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11074 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11075 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11077 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11079 if ( s0.match( query_nodes ) ) {
11083 catch ( final Exception e ) {
11084 e.printStackTrace();
11090 private static boolean testSplitStrict() {
11092 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11093 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11094 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11095 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11096 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11097 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11098 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11099 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11100 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11101 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11102 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11103 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11104 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11106 if ( s0.match( query_nodes ) ) {
11109 query_nodes = new HashSet<PhylogenyNode>();
11110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11111 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11112 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11113 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11114 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11115 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11117 if ( !s0.match( query_nodes ) ) {
11121 query_nodes = new HashSet<PhylogenyNode>();
11122 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11123 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11124 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11125 if ( !s0.match( query_nodes ) ) {
11129 query_nodes = new HashSet<PhylogenyNode>();
11130 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11132 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11134 if ( !s0.match( query_nodes ) ) {
11138 query_nodes = new HashSet<PhylogenyNode>();
11139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11143 if ( !s0.match( query_nodes ) ) {
11147 query_nodes = new HashSet<PhylogenyNode>();
11148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11151 if ( !s0.match( query_nodes ) ) {
11155 query_nodes = new HashSet<PhylogenyNode>();
11156 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11158 if ( !s0.match( query_nodes ) ) {
11162 query_nodes = new HashSet<PhylogenyNode>();
11163 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11164 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11165 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11168 if ( !s0.match( query_nodes ) ) {
11172 query_nodes = new HashSet<PhylogenyNode>();
11173 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11174 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11175 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11176 if ( !s0.match( query_nodes ) ) {
11180 query_nodes = new HashSet<PhylogenyNode>();
11181 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11182 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11185 if ( !s0.match( query_nodes ) ) {
11189 query_nodes = new HashSet<PhylogenyNode>();
11190 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11192 if ( s0.match( query_nodes ) ) {
11196 query_nodes = new HashSet<PhylogenyNode>();
11197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11199 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11200 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11201 if ( s0.match( query_nodes ) ) {
11205 query_nodes = new HashSet<PhylogenyNode>();
11206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11207 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11208 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11209 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11211 if ( s0.match( query_nodes ) ) {
11215 query_nodes = new HashSet<PhylogenyNode>();
11216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11217 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11219 if ( s0.match( query_nodes ) ) {
11223 query_nodes = new HashSet<PhylogenyNode>();
11224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11226 if ( s0.match( query_nodes ) ) {
11230 query_nodes = new HashSet<PhylogenyNode>();
11231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11233 if ( s0.match( query_nodes ) ) {
11237 query_nodes = new HashSet<PhylogenyNode>();
11238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11240 if ( s0.match( query_nodes ) ) {
11244 query_nodes = new HashSet<PhylogenyNode>();
11245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11247 if ( s0.match( query_nodes ) ) {
11251 query_nodes = new HashSet<PhylogenyNode>();
11252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11254 if ( s0.match( query_nodes ) ) {
11258 query_nodes = new HashSet<PhylogenyNode>();
11259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11261 if ( s0.match( query_nodes ) ) {
11265 query_nodes = new HashSet<PhylogenyNode>();
11266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11267 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11268 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11269 if ( s0.match( query_nodes ) ) {
11273 query_nodes = new HashSet<PhylogenyNode>();
11274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11276 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11277 if ( s0.match( query_nodes ) ) {
11281 query_nodes = new HashSet<PhylogenyNode>();
11282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11285 if ( s0.match( query_nodes ) ) {
11289 query_nodes = new HashSet<PhylogenyNode>();
11290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11294 if ( s0.match( query_nodes ) ) {
11298 catch ( final Exception e ) {
11299 e.printStackTrace();
11305 private static boolean testSubtreeDeletion() {
11307 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11308 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11309 t1.deleteSubtree( t1.getNode( "A" ), false );
11310 if ( t1.getNumberOfExternalNodes() != 5 ) {
11313 t1.toNewHampshireX();
11314 t1.deleteSubtree( t1.getNode( "E" ), false );
11315 if ( t1.getNumberOfExternalNodes() != 4 ) {
11318 t1.toNewHampshireX();
11319 t1.deleteSubtree( t1.getNode( "F" ), false );
11320 if ( t1.getNumberOfExternalNodes() != 3 ) {
11323 t1.toNewHampshireX();
11324 t1.deleteSubtree( t1.getNode( "D" ), false );
11325 t1.toNewHampshireX();
11326 if ( t1.getNumberOfExternalNodes() != 3 ) {
11329 t1.deleteSubtree( t1.getNode( "def" ), false );
11330 t1.toNewHampshireX();
11331 if ( t1.getNumberOfExternalNodes() != 2 ) {
11334 t1.deleteSubtree( t1.getNode( "B" ), false );
11335 t1.toNewHampshireX();
11336 if ( t1.getNumberOfExternalNodes() != 1 ) {
11339 t1.deleteSubtree( t1.getNode( "C" ), false );
11340 t1.toNewHampshireX();
11341 if ( t1.getNumberOfExternalNodes() != 1 ) {
11344 t1.deleteSubtree( t1.getNode( "abc" ), false );
11345 t1.toNewHampshireX();
11346 if ( t1.getNumberOfExternalNodes() != 1 ) {
11349 t1.deleteSubtree( t1.getNode( "r" ), false );
11350 if ( t1.getNumberOfExternalNodes() != 0 ) {
11353 if ( !t1.isEmpty() ) {
11356 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11357 t2.deleteSubtree( t2.getNode( "A" ), false );
11358 t2.toNewHampshireX();
11359 if ( t2.getNumberOfExternalNodes() != 5 ) {
11362 t2.deleteSubtree( t2.getNode( "abc" ), false );
11363 t2.toNewHampshireX();
11364 if ( t2.getNumberOfExternalNodes() != 3 ) {
11367 t2.deleteSubtree( t2.getNode( "def" ), false );
11368 t2.toNewHampshireX();
11369 if ( t2.getNumberOfExternalNodes() != 1 ) {
11373 catch ( final Exception e ) {
11374 e.printStackTrace( System.out );
11380 private static boolean testSupportCount() {
11382 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11383 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11384 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11385 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11386 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11387 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11388 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11390 SupportCount.count( t0_1, phylogenies_1, true, false );
11391 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11392 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11393 + "(((((A,B),C),D),E),((F,G),X))"
11394 + "(((((A,Y),B),C),D),((F,G),E))"
11395 + "(((((A,B),C),D),E),(F,G))"
11396 + "(((((A,B),C),D),E),(F,G))"
11397 + "(((((A,B),C),D),E),(F,G))"
11398 + "(((((A,B),C),D),E),(F,G),Z)"
11399 + "(((((A,B),C),D),E),(F,G))"
11400 + "((((((A,B),C),D),E),F),G)"
11401 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11403 SupportCount.count( t0_2, phylogenies_2, true, false );
11404 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11405 while ( it.hasNext() ) {
11406 final PhylogenyNode n = it.next();
11407 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11411 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11412 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11413 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11414 SupportCount.count( t0_3, phylogenies_3, true, false );
11415 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11416 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11419 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11422 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11425 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11428 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11431 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11434 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11437 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11440 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11443 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11446 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11447 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11448 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11449 SupportCount.count( t0_4, phylogenies_4, true, false );
11450 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11451 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11454 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11457 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11460 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11463 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11466 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11469 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11472 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11475 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11478 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11481 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11482 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11483 double d = SupportCount.compare( b1, a, true, true, true );
11484 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11487 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11488 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11489 d = SupportCount.compare( b2, a, true, true, true );
11490 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11493 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11494 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11495 d = SupportCount.compare( b3, a, true, true, true );
11496 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11499 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11500 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11501 d = SupportCount.compare( b4, a, true, true, false );
11502 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11506 catch ( final Exception e ) {
11507 e.printStackTrace( System.out );
11513 private static boolean testSupportTransfer() {
11515 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11516 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)",
11517 new NHXParser() )[ 0 ];
11518 final Phylogeny p2 = factory
11519 .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 ];
11520 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11523 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11526 support_transfer.moveBranchLengthsToBootstrap( p1 );
11527 support_transfer.transferSupportValues( p1, p2 );
11528 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11531 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11534 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11537 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11540 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11543 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11546 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11549 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11553 catch ( final Exception e ) {
11554 e.printStackTrace( System.out );
11560 private static boolean testTaxonomyExtraction() {
11562 final PhylogenyNode n0 = PhylogenyNode
11563 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11564 if ( n0.getNodeData().isHasTaxonomy() ) {
11567 final PhylogenyNode n1 = PhylogenyNode
11568 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11569 if ( n1.getNodeData().isHasTaxonomy() ) {
11570 System.out.println( n1.toString() );
11573 final PhylogenyNode n2x = PhylogenyNode
11574 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11575 if ( n2x.getNodeData().isHasTaxonomy() ) {
11578 final PhylogenyNode n3 = PhylogenyNode
11579 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11580 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11581 System.out.println( n3.toString() );
11584 final PhylogenyNode n4 = PhylogenyNode
11585 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11586 if ( n4.getNodeData().isHasTaxonomy() ) {
11587 System.out.println( n4.toString() );
11590 final PhylogenyNode n5 = PhylogenyNode
11591 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11592 if ( n5.getNodeData().isHasTaxonomy() ) {
11593 System.out.println( n5.toString() );
11596 final PhylogenyNode n6 = PhylogenyNode
11597 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11598 if ( n6.getNodeData().isHasTaxonomy() ) {
11599 System.out.println( n6.toString() );
11602 final PhylogenyNode n7 = PhylogenyNode
11603 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11604 if ( n7.getNodeData().isHasTaxonomy() ) {
11605 System.out.println( n7.toString() );
11608 final PhylogenyNode n8 = PhylogenyNode
11609 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11610 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11611 System.out.println( n8.toString() );
11614 final PhylogenyNode n9 = PhylogenyNode
11615 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11616 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11617 System.out.println( n9.toString() );
11620 final PhylogenyNode n10x = PhylogenyNode
11621 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11622 if ( n10x.getNodeData().isHasTaxonomy() ) {
11623 System.out.println( n10x.toString() );
11626 final PhylogenyNode n10xx = PhylogenyNode
11627 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11628 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11629 System.out.println( n10xx.toString() );
11632 final PhylogenyNode n10 = PhylogenyNode
11633 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11634 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11635 System.out.println( n10.toString() );
11638 final PhylogenyNode n11 = PhylogenyNode
11639 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11640 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11641 System.out.println( n11.toString() );
11644 final PhylogenyNode n12 = PhylogenyNode
11645 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11646 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11647 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11648 System.out.println( n12.toString() );
11651 final PhylogenyNode n13 = PhylogenyNode
11652 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11653 if ( n13.getNodeData().isHasTaxonomy() ) {
11654 System.out.println( n13.toString() );
11658 catch ( final Exception e ) {
11659 e.printStackTrace( System.out );
11665 private static boolean testTreeCopy() {
11667 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
11668 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
11669 final Phylogeny t1 = t0.copy();
11670 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
11673 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11676 t0.deleteSubtree( t0.getNode( "c" ), true );
11677 t0.deleteSubtree( t0.getNode( "a" ), true );
11678 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
11679 t0.getNode( "b" ).setName( "Bee" );
11680 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
11683 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11686 t0.deleteSubtree( t0.getNode( "e" ), true );
11687 t0.deleteSubtree( t0.getNode( "Bee" ), true );
11688 t0.deleteSubtree( t0.getNode( "d" ), true );
11689 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11693 catch ( final Exception e ) {
11694 e.printStackTrace();
11700 private static boolean testTreeMethods() {
11702 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11703 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
11704 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
11705 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
11706 System.out.println( t0.toNewHampshireX() );
11709 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
11710 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
11711 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
11714 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
11717 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
11721 catch ( final Exception e ) {
11722 e.printStackTrace( System.out );
11728 private static boolean testUniprotEntryRetrieval() {
11730 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11731 if ( !entry.getAccession().equals( "P12345" ) ) {
11734 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11737 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11740 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11743 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11746 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11750 catch ( final IOException e ) {
11751 System.out.println();
11752 System.out.println( "the following might be due to absence internet connection:" );
11753 e.printStackTrace( System.out );
11756 catch ( final Exception e ) {
11762 private static boolean testUniprotTaxonomySearch() {
11764 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11766 if ( results.size() != 1 ) {
11769 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11772 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11775 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11778 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11781 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11785 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11786 if ( results.size() != 1 ) {
11789 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11792 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11795 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11798 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11801 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11805 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11806 if ( results.size() != 1 ) {
11809 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11812 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11815 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11818 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11821 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11825 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11826 if ( results.size() != 1 ) {
11829 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11832 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11835 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11838 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11841 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11844 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11847 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11850 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11851 .equals( "Nematostella vectensis" ) ) {
11852 System.out.println( results.get( 0 ).getLineage() );
11857 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 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.getTaxonomiesFromId( "8364", 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() );
11909 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11910 if ( results.size() != 1 ) {
11913 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11916 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11919 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11922 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11925 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11928 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11929 .equals( "Xenopus tropicalis" ) ) {
11930 System.out.println( results.get( 0 ).getLineage() );
11934 catch ( final IOException e ) {
11935 System.out.println();
11936 System.out.println( "the following might be due to absence internet connection:" );
11937 e.printStackTrace( System.out );
11940 catch ( final Exception e ) {
11946 private static boolean testWabiTxSearch() {
11948 String result = "";
11949 result = TxSearch.searchSimple( "nematostella" );
11950 result = TxSearch.getTxId( "nematostella" );
11951 if ( !result.equals( "45350" ) ) {
11954 result = TxSearch.getTxName( "45350" );
11955 if ( !result.equals( "Nematostella" ) ) {
11958 result = TxSearch.getTxId( "nematostella vectensis" );
11959 if ( !result.equals( "45351" ) ) {
11962 result = TxSearch.getTxName( "45351" );
11963 if ( !result.equals( "Nematostella vectensis" ) ) {
11966 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11967 if ( !result.equals( "536089" ) ) {
11970 result = TxSearch.getTxName( "536089" );
11971 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11974 final List<String> queries = new ArrayList<String>();
11975 queries.add( "Campylobacter coli" );
11976 queries.add( "Escherichia coli" );
11977 queries.add( "Arabidopsis" );
11978 queries.add( "Trichoplax" );
11979 queries.add( "Samanea saman" );
11980 queries.add( "Kluyveromyces marxianus" );
11981 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11982 queries.add( "Bornavirus parrot/PDD/2008" );
11983 final List<RANKS> ranks = new ArrayList<RANKS>();
11984 ranks.add( RANKS.SUPERKINGDOM );
11985 ranks.add( RANKS.KINGDOM );
11986 ranks.add( RANKS.FAMILY );
11987 ranks.add( RANKS.GENUS );
11988 ranks.add( RANKS.TRIBE );
11989 result = TxSearch.searchLineage( queries, ranks );
11990 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11991 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11993 catch ( final Exception e ) {
11994 System.out.println();
11995 System.out.println( "the following might be due to absence internet connection:" );
11996 e.printStackTrace( System.out );