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.print( "TreeBase parsing from URL: " );
971 if ( Test.testTreeBaseReading() ) {
972 System.out.println( "OK." );
976 System.out.println( "failed." );
979 System.out.println();
980 final Runtime rt = java.lang.Runtime.getRuntime();
981 final long free_memory = rt.freeMemory() / 1000000;
982 final long total_memory = rt.totalMemory() / 1000000;
983 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
984 + free_memory + "MB, total memory: " + total_memory + "MB)" );
985 System.out.println();
986 System.out.println( "Successful tests: " + succeeded );
987 System.out.println( "Failed tests: " + failed );
988 System.out.println();
990 System.out.println( "OK." );
993 System.out.println( "Not OK." );
997 public static boolean testEngulfingOverlapRemoval() {
999 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1000 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1001 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1002 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1003 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1004 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1005 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1006 final List<Boolean> covered = new ArrayList<Boolean>();
1007 covered.add( true ); // 0
1008 covered.add( false ); // 1
1009 covered.add( true ); // 2
1010 covered.add( false ); // 3
1011 covered.add( true ); // 4
1012 covered.add( true ); // 5
1013 covered.add( false ); // 6
1014 covered.add( true ); // 7
1015 covered.add( true ); // 8
1016 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1019 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1022 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1025 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1028 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1031 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1034 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1037 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1038 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1039 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1040 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1041 abc.addProteinDomain( a );
1042 abc.addProteinDomain( b );
1043 abc.addProteinDomain( c );
1044 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1045 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1046 if ( abc.getNumberOfProteinDomains() != 3 ) {
1049 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1052 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1055 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1058 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1061 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1062 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1063 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1064 final Protein def = new BasicProtein( "def", "nemve", 0 );
1065 def.addProteinDomain( d );
1066 def.addProteinDomain( e );
1067 def.addProteinDomain( f );
1068 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1069 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1070 if ( def.getNumberOfProteinDomains() != 3 ) {
1073 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1076 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1079 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1082 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1085 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1089 catch ( final Exception e ) {
1090 e.printStackTrace( System.out );
1096 public static final boolean testPhyloXMLparsingFromURL() {
1098 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1099 final URL u = new URL( s );
1100 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1101 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1102 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1106 catch ( final Exception e ) {
1107 e.printStackTrace();
1112 public static final boolean testTreeBaseReading() {
1114 final String s = "http://purl.org/phylo/treebase/phylows/tree/TB2:Tr825?format=nexus";
1115 final URL u = new URL( s );
1116 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1117 parser.setReplaceUnderscores( true );
1118 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1119 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1120 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1124 catch ( final Exception e ) {
1125 e.printStackTrace();
1130 public static final boolean testNHXparsingFromURL() {
1132 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1133 final URL u = new URL( s );
1134 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1135 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1136 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1139 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1140 System.out.println( phys[ 0 ].toNewHampshire() );
1143 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1144 System.out.println( phys[ 1 ].toNewHampshire() );
1147 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1148 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1151 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1152 System.out.println( phys2[ 0 ].toNewHampshire() );
1155 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1156 final NHXParser p = new NHXParser();
1157 final URL u2 = new URL( s );
1159 if ( !p.hasNext() ) {
1162 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1165 if ( !p.hasNext() ) {
1169 if ( !p.hasNext() ) {
1172 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1175 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1179 if ( !p.hasNext() ) {
1182 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1185 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1189 catch ( final Exception e ) {
1190 e.printStackTrace();
1195 public static boolean testOverlapRemoval() {
1197 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1198 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1199 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1200 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1201 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1202 final List<Boolean> covered = new ArrayList<Boolean>();
1203 covered.add( true ); // 0
1204 covered.add( false ); // 1
1205 covered.add( true ); // 2
1206 covered.add( false ); // 3
1207 covered.add( true ); // 4
1208 covered.add( true ); // 5
1209 covered.add( false ); // 6
1210 covered.add( true ); // 7
1211 covered.add( true ); // 8
1212 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1215 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1218 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1221 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1224 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1227 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1228 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1229 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1230 ab.addProteinDomain( a );
1231 ab.addProteinDomain( b );
1232 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1233 if ( ab.getNumberOfProteinDomains() != 2 ) {
1236 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1239 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1242 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1243 if ( ab.getNumberOfProteinDomains() != 2 ) {
1246 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1249 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1250 final Domain d = new BasicDomain( "d",
1257 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1258 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1259 cde.addProteinDomain( c );
1260 cde.addProteinDomain( d );
1261 cde.addProteinDomain( e );
1262 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1263 if ( cde.getNumberOfProteinDomains() != 3 ) {
1266 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1269 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1270 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1271 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1272 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1273 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1274 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1275 fghi.addProteinDomain( f );
1276 fghi.addProteinDomain( g );
1277 fghi.addProteinDomain( h );
1278 fghi.addProteinDomain( i );
1279 fghi.addProteinDomain( i );
1280 fghi.addProteinDomain( i );
1281 fghi.addProteinDomain( i2 );
1282 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1283 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1286 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1289 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1292 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1293 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1296 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1299 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1300 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1301 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1302 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1303 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1304 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1305 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1306 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1307 jklm.addProteinDomain( j );
1308 jklm.addProteinDomain( k );
1309 jklm.addProteinDomain( l );
1310 jklm.addProteinDomain( m );
1311 jklm.addProteinDomain( m0 );
1312 jklm.addProteinDomain( m1 );
1313 jklm.addProteinDomain( m2 );
1314 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1315 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1318 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1321 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1324 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1325 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1328 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1331 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1332 final Protein od = new BasicProtein( "od", "varanus", 0 );
1333 od.addProteinDomain( only );
1334 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1335 if ( od.getNumberOfProteinDomains() != 1 ) {
1338 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1342 catch ( final Exception e ) {
1343 e.printStackTrace( System.out );
1349 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1350 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1354 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1355 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1358 private static boolean testAminoAcidSequence() {
1360 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1361 if ( aa1.getLength() != 13 ) {
1364 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1367 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1370 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1373 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1374 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1377 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1378 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1381 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1382 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1386 catch ( final Exception e ) {
1387 e.printStackTrace();
1393 private static boolean testBasicDomain() {
1395 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1396 if ( !pd.getDomainId().equals( "id" ) ) {
1399 if ( pd.getNumber() != 1 ) {
1402 if ( pd.getTotalCount() != 4 ) {
1405 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1408 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1409 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1410 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1411 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1412 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1413 if ( !a1.equals( a1 ) ) {
1416 if ( !a1.equals( a1_copy ) ) {
1419 if ( !a1.equals( a1_equal ) ) {
1422 if ( !a1.equals( a2 ) ) {
1425 if ( a1.equals( a3 ) ) {
1428 if ( a1.compareTo( a1 ) != 0 ) {
1431 if ( a1.compareTo( a1_copy ) != 0 ) {
1434 if ( a1.compareTo( a1_equal ) != 0 ) {
1437 if ( a1.compareTo( a2 ) != 0 ) {
1440 if ( a1.compareTo( a3 ) == 0 ) {
1444 catch ( final Exception e ) {
1445 e.printStackTrace( System.out );
1451 private static boolean testBasicNodeMethods() {
1453 if ( PhylogenyNode.getNodeCount() != 0 ) {
1456 final PhylogenyNode n1 = new PhylogenyNode();
1457 final PhylogenyNode n2 = PhylogenyNode
1458 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1459 final PhylogenyNode n3 = PhylogenyNode
1460 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1461 final PhylogenyNode n4 = PhylogenyNode
1462 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1463 if ( n1.isHasAssignedEvent() ) {
1466 if ( PhylogenyNode.getNodeCount() != 4 ) {
1469 if ( n3.getIndicator() != 0 ) {
1472 if ( n3.getNumberOfExternalNodes() != 1 ) {
1475 if ( !n3.isExternal() ) {
1478 if ( !n3.isRoot() ) {
1481 if ( !n4.getName().equals( "n4" ) ) {
1485 catch ( final Exception e ) {
1486 e.printStackTrace( System.out );
1492 private static boolean testBasicPhyloXMLparsing() {
1494 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1495 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1496 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1498 if ( xml_parser.getErrorCount() > 0 ) {
1499 System.out.println( xml_parser.getErrorMessages().toString() );
1502 if ( phylogenies_0.length != 4 ) {
1505 final Phylogeny t1 = phylogenies_0[ 0 ];
1506 final Phylogeny t2 = phylogenies_0[ 1 ];
1507 final Phylogeny t3 = phylogenies_0[ 2 ];
1508 final Phylogeny t4 = phylogenies_0[ 3 ];
1509 if ( t1.getNumberOfExternalNodes() != 1 ) {
1512 if ( !t1.isRooted() ) {
1515 if ( t1.isRerootable() ) {
1518 if ( !t1.getType().equals( "gene_tree" ) ) {
1521 if ( t2.getNumberOfExternalNodes() != 2 ) {
1524 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1527 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1530 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1533 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1536 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1539 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1542 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1543 .startsWith( "actgtgggggt" ) ) {
1546 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1547 .startsWith( "ctgtgatgcat" ) ) {
1550 if ( t3.getNumberOfExternalNodes() != 4 ) {
1553 if ( !t1.getName().equals( "t1" ) ) {
1556 if ( !t2.getName().equals( "t2" ) ) {
1559 if ( !t3.getName().equals( "t3" ) ) {
1562 if ( !t4.getName().equals( "t4" ) ) {
1565 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1568 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1571 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1574 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1575 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1578 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1581 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1584 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1587 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1588 .equals( "apoptosis" ) ) {
1591 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1592 .equals( "GO:0006915" ) ) {
1595 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1596 .equals( "UniProtKB" ) ) {
1599 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1600 .equals( "experimental" ) ) {
1603 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1604 .equals( "function" ) ) {
1607 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1608 .getValue() != 1 ) {
1611 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1612 .getType().equals( "ml" ) ) {
1615 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1616 .equals( "apoptosis" ) ) {
1619 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1620 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1623 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1624 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1627 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1628 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1631 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1632 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1635 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1636 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1639 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1640 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1643 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1644 .equals( "GO:0005829" ) ) {
1647 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1648 .equals( "intracellular organelle" ) ) {
1651 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1654 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1655 .equals( "UniProt link" ) ) ) {
1658 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1661 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1662 if ( x.size() != 4 ) {
1666 for( final Accession acc : x ) {
1668 if ( !acc.getSource().equals( "KEGG" ) ) {
1671 if ( !acc.getValue().equals( "hsa:596" ) ) {
1678 catch ( final Exception e ) {
1679 e.printStackTrace( System.out );
1685 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1687 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1688 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1689 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1690 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1693 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1695 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1697 if ( xml_parser.getErrorCount() > 0 ) {
1698 System.out.println( xml_parser.getErrorMessages().toString() );
1701 if ( phylogenies_0.length != 4 ) {
1704 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1705 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1706 if ( phylogenies_t1.length != 1 ) {
1709 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1710 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1713 if ( !t1_rt.isRooted() ) {
1716 if ( t1_rt.isRerootable() ) {
1719 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1722 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1723 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1724 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1725 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1728 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1731 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1734 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1737 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1738 .startsWith( "actgtgggggt" ) ) {
1741 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1742 .startsWith( "ctgtgatgcat" ) ) {
1745 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1746 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1747 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1748 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1749 if ( phylogenies_1.length != 1 ) {
1752 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1753 if ( !t3_rt.getName().equals( "t3" ) ) {
1756 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1759 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1762 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1765 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1768 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1769 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1772 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1775 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1778 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1779 .equals( "UniProtKB" ) ) {
1782 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1783 .equals( "apoptosis" ) ) {
1786 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1787 .equals( "GO:0006915" ) ) {
1790 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1791 .equals( "UniProtKB" ) ) {
1794 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1795 .equals( "experimental" ) ) {
1798 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1799 .equals( "function" ) ) {
1802 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1803 .getValue() != 1 ) {
1806 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1807 .getType().equals( "ml" ) ) {
1810 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1811 .equals( "apoptosis" ) ) {
1814 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1815 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1818 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1819 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1822 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1823 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1826 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1827 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1830 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1831 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1834 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1835 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1838 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1839 .equals( "GO:0005829" ) ) {
1842 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1843 .equals( "intracellular organelle" ) ) {
1846 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1849 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1850 .equals( "UniProt link" ) ) ) {
1853 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1856 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1859 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1860 .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." ) ) ) {
1863 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1866 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1869 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1872 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1875 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1876 .equals( "ncbi" ) ) {
1879 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1882 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1883 .getName().equals( "B" ) ) {
1886 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1887 .getFrom() != 21 ) {
1890 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1893 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1894 .getLength() != 24 ) {
1897 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1898 .getConfidence() != 2144 ) {
1901 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1902 .equals( "pfam" ) ) {
1905 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1908 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1911 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1914 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1917 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1918 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1921 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1924 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1927 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1930 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1933 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1936 if ( taxbb.getSynonyms().size() != 2 ) {
1939 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1942 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1945 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1948 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1951 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1954 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1955 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1958 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1961 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1964 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1967 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1970 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1973 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1976 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1980 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1983 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1984 .equalsIgnoreCase( "435" ) ) {
1987 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1990 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1991 .equalsIgnoreCase( "443.7" ) ) {
1994 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1997 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2000 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2001 .equalsIgnoreCase( "433" ) ) {
2004 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2005 .getCrossReferences();
2006 if ( x.size() != 4 ) {
2010 for( final Accession acc : x ) {
2012 if ( !acc.getSource().equals( "KEGG" ) ) {
2015 if ( !acc.getValue().equals( "hsa:596" ) ) {
2022 catch ( final Exception e ) {
2023 e.printStackTrace( System.out );
2029 private static boolean testBasicPhyloXMLparsingValidating() {
2031 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2032 PhyloXmlParser xml_parser = null;
2034 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2036 catch ( final Exception e ) {
2037 // Do nothing -- means were not running from jar.
2039 if ( xml_parser == null ) {
2040 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2041 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2042 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2045 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2048 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2050 if ( xml_parser.getErrorCount() > 0 ) {
2051 System.out.println( xml_parser.getErrorMessages().toString() );
2054 if ( phylogenies_0.length != 4 ) {
2057 final Phylogeny t1 = phylogenies_0[ 0 ];
2058 final Phylogeny t2 = phylogenies_0[ 1 ];
2059 final Phylogeny t3 = phylogenies_0[ 2 ];
2060 final Phylogeny t4 = phylogenies_0[ 3 ];
2061 if ( !t1.getName().equals( "t1" ) ) {
2064 if ( !t2.getName().equals( "t2" ) ) {
2067 if ( !t3.getName().equals( "t3" ) ) {
2070 if ( !t4.getName().equals( "t4" ) ) {
2073 if ( t1.getNumberOfExternalNodes() != 1 ) {
2076 if ( t2.getNumberOfExternalNodes() != 2 ) {
2079 if ( t3.getNumberOfExternalNodes() != 4 ) {
2082 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2083 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2084 if ( xml_parser.getErrorCount() > 0 ) {
2085 System.out.println( "errors:" );
2086 System.out.println( xml_parser.getErrorMessages().toString() );
2089 if ( phylogenies_1.length != 4 ) {
2092 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2094 if ( xml_parser.getErrorCount() > 0 ) {
2095 System.out.println( "errors:" );
2096 System.out.println( xml_parser.getErrorMessages().toString() );
2099 if ( phylogenies_2.length != 1 ) {
2102 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2105 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2107 if ( xml_parser.getErrorCount() > 0 ) {
2108 System.out.println( xml_parser.getErrorMessages().toString() );
2111 if ( phylogenies_3.length != 2 ) {
2114 final Phylogeny a = phylogenies_3[ 0 ];
2115 if ( !a.getName().equals( "tree 4" ) ) {
2118 if ( a.getNumberOfExternalNodes() != 3 ) {
2121 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2124 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2127 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2129 if ( xml_parser.getErrorCount() > 0 ) {
2130 System.out.println( xml_parser.getErrorMessages().toString() );
2133 if ( phylogenies_4.length != 1 ) {
2136 final Phylogeny s = phylogenies_4[ 0 ];
2137 if ( s.getNumberOfExternalNodes() != 6 ) {
2140 s.getNode( "first" );
2142 s.getNode( "\"<a'b&c'd\">\"" );
2143 s.getNode( "'''\"" );
2144 s.getNode( "\"\"\"" );
2145 s.getNode( "dick & doof" );
2147 catch ( final Exception e ) {
2148 e.printStackTrace( System.out );
2154 private static boolean testBasicProtein() {
2156 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2157 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2158 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2159 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2160 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2161 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2162 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2163 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2164 p0.addProteinDomain( y );
2165 p0.addProteinDomain( e );
2166 p0.addProteinDomain( b );
2167 p0.addProteinDomain( c );
2168 p0.addProteinDomain( d );
2169 p0.addProteinDomain( a );
2170 p0.addProteinDomain( x );
2171 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2174 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2178 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2179 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2180 aa0.addProteinDomain( a1 );
2181 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2184 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2188 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2189 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2190 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2191 aa1.addProteinDomain( a11 );
2192 aa1.addProteinDomain( a12 );
2193 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2196 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2199 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2200 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2203 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2206 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2209 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2210 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2213 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2216 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2219 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2222 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2223 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2226 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2229 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2232 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2235 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2236 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2239 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2242 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2245 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2249 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2250 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2251 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2252 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2253 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2254 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2255 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2256 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2257 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2258 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2259 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2260 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2261 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2262 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2263 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2264 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2265 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2266 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2267 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2268 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2269 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2270 p00.addProteinDomain( y0 );
2271 p00.addProteinDomain( e0 );
2272 p00.addProteinDomain( b0 );
2273 p00.addProteinDomain( c0 );
2274 p00.addProteinDomain( d0 );
2275 p00.addProteinDomain( a0 );
2276 p00.addProteinDomain( x0 );
2277 p00.addProteinDomain( y1 );
2278 p00.addProteinDomain( y2 );
2279 p00.addProteinDomain( y3 );
2280 p00.addProteinDomain( e1 );
2281 p00.addProteinDomain( e2 );
2282 p00.addProteinDomain( e3 );
2283 p00.addProteinDomain( e4 );
2284 p00.addProteinDomain( e5 );
2285 p00.addProteinDomain( z0 );
2286 p00.addProteinDomain( z1 );
2287 p00.addProteinDomain( z2 );
2288 p00.addProteinDomain( zz0 );
2289 p00.addProteinDomain( zz1 );
2290 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2293 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2296 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2299 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2302 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" ) ) {
2305 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2306 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2307 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2308 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2309 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2310 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2311 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2312 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2313 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2314 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2315 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2316 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2317 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2318 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2319 p.addProteinDomain( B15 );
2320 p.addProteinDomain( C50 );
2321 p.addProteinDomain( A60 );
2322 p.addProteinDomain( A30 );
2323 p.addProteinDomain( C70 );
2324 p.addProteinDomain( B35 );
2325 p.addProteinDomain( B40 );
2326 p.addProteinDomain( A0 );
2327 p.addProteinDomain( A10 );
2328 p.addProteinDomain( A20 );
2329 p.addProteinDomain( B25 );
2330 p.addProteinDomain( D80 );
2331 List<String> domains_ids = new ArrayList<String>();
2332 domains_ids.add( "A" );
2333 domains_ids.add( "B" );
2334 domains_ids.add( "C" );
2335 if ( !p.contains( domains_ids, false ) ) {
2338 if ( !p.contains( domains_ids, true ) ) {
2341 domains_ids.add( "X" );
2342 if ( p.contains( domains_ids, false ) ) {
2345 if ( p.contains( domains_ids, true ) ) {
2348 domains_ids = new ArrayList<String>();
2349 domains_ids.add( "A" );
2350 domains_ids.add( "C" );
2351 domains_ids.add( "D" );
2352 if ( !p.contains( domains_ids, false ) ) {
2355 if ( !p.contains( domains_ids, true ) ) {
2358 domains_ids = new ArrayList<String>();
2359 domains_ids.add( "A" );
2360 domains_ids.add( "D" );
2361 domains_ids.add( "C" );
2362 if ( !p.contains( domains_ids, false ) ) {
2365 if ( p.contains( domains_ids, true ) ) {
2368 domains_ids = new ArrayList<String>();
2369 domains_ids.add( "A" );
2370 domains_ids.add( "A" );
2371 domains_ids.add( "B" );
2372 if ( !p.contains( domains_ids, false ) ) {
2375 if ( !p.contains( domains_ids, true ) ) {
2378 domains_ids = new ArrayList<String>();
2379 domains_ids.add( "A" );
2380 domains_ids.add( "A" );
2381 domains_ids.add( "A" );
2382 domains_ids.add( "B" );
2383 domains_ids.add( "B" );
2384 if ( !p.contains( domains_ids, false ) ) {
2387 if ( !p.contains( domains_ids, true ) ) {
2390 domains_ids = new ArrayList<String>();
2391 domains_ids.add( "A" );
2392 domains_ids.add( "A" );
2393 domains_ids.add( "B" );
2394 domains_ids.add( "A" );
2395 domains_ids.add( "B" );
2396 domains_ids.add( "B" );
2397 domains_ids.add( "A" );
2398 domains_ids.add( "B" );
2399 domains_ids.add( "C" );
2400 domains_ids.add( "A" );
2401 domains_ids.add( "C" );
2402 domains_ids.add( "D" );
2403 if ( !p.contains( domains_ids, false ) ) {
2406 if ( p.contains( domains_ids, true ) ) {
2410 catch ( final Exception e ) {
2411 e.printStackTrace( System.out );
2417 private static boolean testBasicTable() {
2419 final BasicTable<String> t0 = new BasicTable<String>();
2420 if ( t0.getNumberOfColumns() != 0 ) {
2423 if ( t0.getNumberOfRows() != 0 ) {
2426 t0.setValue( 3, 2, "23" );
2427 t0.setValue( 10, 1, "error" );
2428 t0.setValue( 10, 1, "110" );
2429 t0.setValue( 9, 1, "19" );
2430 t0.setValue( 1, 10, "101" );
2431 t0.setValue( 10, 10, "1010" );
2432 t0.setValue( 100, 10, "10100" );
2433 t0.setValue( 0, 0, "00" );
2434 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2437 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2440 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2443 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2446 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2449 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2452 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2455 if ( t0.getNumberOfColumns() != 101 ) {
2458 if ( t0.getNumberOfRows() != 11 ) {
2461 if ( t0.getValueAsString( 49, 4 ) != null ) {
2464 final String l = ForesterUtil.getLineSeparator();
2465 final StringBuffer source = new StringBuffer();
2466 source.append( "" + l );
2467 source.append( "# 1 1 1 1 1 1 1 1" + l );
2468 source.append( " 00 01 02 03" + l );
2469 source.append( " 10 11 12 13 " + l );
2470 source.append( "20 21 22 23 " + l );
2471 source.append( " 30 31 32 33" + l );
2472 source.append( "40 41 42 43" + l );
2473 source.append( " # 1 1 1 1 1 " + l );
2474 source.append( "50 51 52 53 54" + l );
2475 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2476 if ( t1.getNumberOfColumns() != 5 ) {
2479 if ( t1.getNumberOfRows() != 6 ) {
2482 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2485 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2488 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2491 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2494 final StringBuffer source1 = new StringBuffer();
2495 source1.append( "" + l );
2496 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2497 source1.append( " 00; 01 ;02;03" + l );
2498 source1.append( " 10; 11; 12; 13 " + l );
2499 source1.append( "20; 21; 22; 23 " + l );
2500 source1.append( " 30; 31; 32; 33" + l );
2501 source1.append( "40;41;42;43" + l );
2502 source1.append( " # 1 1 1 1 1 " + l );
2503 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2504 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2505 if ( t2.getNumberOfColumns() != 5 ) {
2508 if ( t2.getNumberOfRows() != 6 ) {
2511 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2514 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2517 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2520 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2523 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2526 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2529 final StringBuffer source2 = new StringBuffer();
2530 source2.append( "" + l );
2531 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2532 source2.append( " 00; 01 ;02;03" + l );
2533 source2.append( " 10; 11; 12; 13 " + l );
2534 source2.append( "20; 21; 22; 23 " + l );
2535 source2.append( " " + l );
2536 source2.append( " 30; 31; 32; 33" + l );
2537 source2.append( "40;41;42;43" + l );
2538 source2.append( " comment: 1 1 1 1 1 " + l );
2539 source2.append( ";;;50 ; 52; 53;;54 " + l );
2540 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2546 if ( tl.size() != 2 ) {
2549 final BasicTable<String> t3 = tl.get( 0 );
2550 final BasicTable<String> t4 = tl.get( 1 );
2551 if ( t3.getNumberOfColumns() != 4 ) {
2554 if ( t3.getNumberOfRows() != 3 ) {
2557 if ( t4.getNumberOfColumns() != 4 ) {
2560 if ( t4.getNumberOfRows() != 3 ) {
2563 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2566 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2570 catch ( final Exception e ) {
2571 e.printStackTrace( System.out );
2577 private static boolean testBasicTolXMLparsing() {
2579 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2580 final TolParser parser = new TolParser();
2581 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2582 if ( parser.getErrorCount() > 0 ) {
2583 System.out.println( parser.getErrorMessages().toString() );
2586 if ( phylogenies_0.length != 1 ) {
2589 final Phylogeny t1 = phylogenies_0[ 0 ];
2590 if ( t1.getNumberOfExternalNodes() != 5 ) {
2593 if ( !t1.isRooted() ) {
2596 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2599 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2602 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2605 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2608 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2609 if ( parser.getErrorCount() > 0 ) {
2610 System.out.println( parser.getErrorMessages().toString() );
2613 if ( phylogenies_1.length != 1 ) {
2616 final Phylogeny t2 = phylogenies_1[ 0 ];
2617 if ( t2.getNumberOfExternalNodes() != 664 ) {
2620 if ( !t2.isRooted() ) {
2623 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2626 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2629 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2632 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2635 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2638 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2639 .equals( "Aquifex" ) ) {
2642 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2643 if ( parser.getErrorCount() > 0 ) {
2644 System.out.println( parser.getErrorMessages().toString() );
2647 if ( phylogenies_2.length != 1 ) {
2650 final Phylogeny t3 = phylogenies_2[ 0 ];
2651 if ( t3.getNumberOfExternalNodes() != 184 ) {
2654 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2657 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2660 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2663 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2664 if ( parser.getErrorCount() > 0 ) {
2665 System.out.println( parser.getErrorMessages().toString() );
2668 if ( phylogenies_3.length != 1 ) {
2671 final Phylogeny t4 = phylogenies_3[ 0 ];
2672 if ( t4.getNumberOfExternalNodes() != 1 ) {
2675 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2678 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2681 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2684 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2685 if ( parser.getErrorCount() > 0 ) {
2686 System.out.println( parser.getErrorMessages().toString() );
2689 if ( phylogenies_4.length != 1 ) {
2692 final Phylogeny t5 = phylogenies_4[ 0 ];
2693 if ( t5.getNumberOfExternalNodes() != 13 ) {
2696 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2699 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2702 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2706 catch ( final Exception e ) {
2707 e.printStackTrace( System.out );
2713 private static boolean testBasicTreeMethods() {
2715 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2716 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2717 if ( t2.getNumberOfExternalNodes() != 4 ) {
2720 if ( t2.getHeight() != 8.5 ) {
2723 if ( !t2.isCompletelyBinary() ) {
2726 if ( t2.isEmpty() ) {
2729 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2730 if ( t3.getNumberOfExternalNodes() != 5 ) {
2733 if ( t3.getHeight() != 11 ) {
2736 if ( t3.isCompletelyBinary() ) {
2739 final PhylogenyNode n = t3.getNode( "ABC" );
2740 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 ];
2741 if ( t4.getNumberOfExternalNodes() != 9 ) {
2744 if ( t4.getHeight() != 11 ) {
2747 if ( t4.isCompletelyBinary() ) {
2750 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)" );
2751 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2752 if ( t5.getNumberOfExternalNodes() != 8 ) {
2755 if ( t5.getHeight() != 15 ) {
2758 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)" );
2759 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2760 if ( t6.getHeight() != 15 ) {
2763 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)" );
2764 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2765 if ( t7.getHeight() != 15 ) {
2768 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)" );
2769 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2770 if ( t8.getNumberOfExternalNodes() != 10 ) {
2773 if ( t8.getHeight() != 15 ) {
2776 final char[] a9 = new char[] { 'a' };
2777 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2778 if ( t9.getHeight() != 0 ) {
2781 final char[] a10 = new char[] { 'a', ':', '6' };
2782 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2783 if ( t10.getHeight() != 6 ) {
2787 catch ( final Exception e ) {
2788 e.printStackTrace( System.out );
2794 private static boolean testConfidenceAssessor() {
2796 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2797 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2798 final Phylogeny[] ev0 = factory
2799 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2801 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2802 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2805 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2808 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2809 final Phylogeny[] ev1 = factory
2810 .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)));",
2812 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2813 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2816 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2819 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2820 final Phylogeny[] ev_b = factory
2821 .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",
2823 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2824 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2827 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2831 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2832 final Phylogeny[] ev1x = factory
2833 .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)));",
2835 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2836 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2839 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2842 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2843 final Phylogeny[] ev_bx = factory
2844 .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",
2846 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2847 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2850 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2854 final Phylogeny[] t2 = factory
2855 .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);",
2857 final Phylogeny[] ev2 = factory
2858 .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);",
2860 for( final Phylogeny target : t2 ) {
2861 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2864 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2865 new NHXParser() )[ 0 ];
2866 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2867 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2868 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2871 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2874 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2878 catch ( final Exception e ) {
2879 e.printStackTrace();
2885 private static boolean testCopyOfNodeData() {
2887 final PhylogenyNode n1 = PhylogenyNode
2888 .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]" );
2889 final PhylogenyNode n2 = n1.copyNodeData();
2890 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2894 catch ( final Exception e ) {
2895 e.printStackTrace();
2901 private static boolean testCreateBalancedPhylogeny() {
2903 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2904 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2907 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2910 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2911 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2914 if ( p1.getNumberOfExternalNodes() != 100 ) {
2918 catch ( final Exception e ) {
2919 e.printStackTrace();
2925 private static boolean testCreateUriForSeqWeb() {
2927 final PhylogenyNode n = new PhylogenyNode();
2928 n.setName( "tr|B3RJ64" );
2929 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2932 n.setName( "B0LM41_HUMAN" );
2933 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2936 n.setName( "NP_001025424" );
2937 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2940 n.setName( "_NM_001030253-" );
2941 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2944 n.setName( "XM_002122186" );
2945 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2948 n.setName( "dgh_AAA34956_gdg" );
2949 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2952 n.setName( "AAA34956" );
2953 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2956 n.setName( "GI:394892" );
2957 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2958 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2961 n.setName( "gi_394892" );
2962 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2963 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2966 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2967 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2968 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2971 n.setName( "P12345" );
2972 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2973 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2976 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2977 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2978 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2982 catch ( final Exception e ) {
2983 e.printStackTrace( System.out );
2989 private static boolean testDataObjects() {
2991 final Confidence s0 = new Confidence();
2992 final Confidence s1 = new Confidence();
2993 if ( !s0.isEqual( s1 ) ) {
2996 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2997 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2998 if ( s2.isEqual( s1 ) ) {
3001 if ( !s2.isEqual( s3 ) ) {
3004 final Confidence s4 = ( Confidence ) s3.copy();
3005 if ( !s4.isEqual( s3 ) ) {
3012 final Taxonomy t1 = new Taxonomy();
3013 final Taxonomy t2 = new Taxonomy();
3014 final Taxonomy t3 = new Taxonomy();
3015 final Taxonomy t4 = new Taxonomy();
3016 final Taxonomy t5 = new Taxonomy();
3017 t1.setIdentifier( new Identifier( "ecoli" ) );
3018 t1.setTaxonomyCode( "ECOLI" );
3019 t1.setScientificName( "E. coli" );
3020 t1.setCommonName( "coli" );
3021 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3022 if ( !t1.isEqual( t0 ) ) {
3025 t2.setIdentifier( new Identifier( "ecoli" ) );
3026 t2.setTaxonomyCode( "OTHER" );
3027 t2.setScientificName( "what" );
3028 t2.setCommonName( "something" );
3029 if ( !t1.isEqual( t2 ) ) {
3032 t2.setIdentifier( new Identifier( "nemve" ) );
3033 if ( t1.isEqual( t2 ) ) {
3036 t1.setIdentifier( null );
3037 t3.setTaxonomyCode( "ECOLI" );
3038 t3.setScientificName( "what" );
3039 t3.setCommonName( "something" );
3040 if ( !t1.isEqual( t3 ) ) {
3043 t1.setIdentifier( null );
3044 t1.setTaxonomyCode( "" );
3045 t4.setScientificName( "E. ColI" );
3046 t4.setCommonName( "something" );
3047 if ( !t1.isEqual( t4 ) ) {
3050 t4.setScientificName( "B. subtilis" );
3051 t4.setCommonName( "something" );
3052 if ( t1.isEqual( t4 ) ) {
3055 t1.setIdentifier( null );
3056 t1.setTaxonomyCode( "" );
3057 t1.setScientificName( "" );
3058 t5.setCommonName( "COLI" );
3059 if ( !t1.isEqual( t5 ) ) {
3062 t5.setCommonName( "vibrio" );
3063 if ( t1.isEqual( t5 ) ) {
3068 final Identifier id0 = new Identifier( "123", "pfam" );
3069 final Identifier id1 = ( Identifier ) id0.copy();
3070 if ( !id1.isEqual( id1 ) ) {
3073 if ( !id1.isEqual( id0 ) ) {
3076 if ( !id0.isEqual( id1 ) ) {
3083 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3084 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3085 if ( !pd1.isEqual( pd1 ) ) {
3088 if ( !pd1.isEqual( pd0 ) ) {
3093 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3094 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3095 if ( !pd3.isEqual( pd3 ) ) {
3098 if ( !pd2.isEqual( pd3 ) ) {
3101 if ( !pd0.isEqual( pd3 ) ) {
3106 // DomainArchitecture
3107 // ------------------
3108 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3109 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3110 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3111 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3112 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3113 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3118 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3119 if ( ds0.getNumberOfDomains() != 4 ) {
3122 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3123 if ( !ds0.isEqual( ds0 ) ) {
3126 if ( !ds0.isEqual( ds1 ) ) {
3129 if ( ds1.getNumberOfDomains() != 4 ) {
3132 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3137 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3138 if ( ds0.isEqual( ds2 ) ) {
3144 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3145 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3146 System.out.println( ds3.toNHX() );
3149 if ( ds3.getNumberOfDomains() != 3 ) {
3154 final Event e1 = new Event( Event.EventType.fusion );
3155 if ( e1.isDuplication() ) {
3158 if ( !e1.isFusion() ) {
3161 if ( !e1.asText().toString().equals( "fusion" ) ) {
3164 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3167 final Event e11 = new Event( Event.EventType.fusion );
3168 if ( !e11.isEqual( e1 ) ) {
3171 if ( !e11.toNHX().toString().equals( "" ) ) {
3174 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3175 if ( e2.isDuplication() ) {
3178 if ( !e2.isSpeciationOrDuplication() ) {
3181 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3184 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3187 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3190 if ( e11.isEqual( e2 ) ) {
3193 final Event e2c = ( Event ) e2.copy();
3194 if ( !e2c.isEqual( e2 ) ) {
3197 Event e3 = new Event( 1, 2, 3 );
3198 if ( e3.isDuplication() ) {
3201 if ( e3.isSpeciation() ) {
3204 if ( e3.isGeneLoss() ) {
3207 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3210 final Event e3c = ( Event ) e3.copy();
3211 final Event e3cc = ( Event ) e3c.copy();
3212 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3216 if ( !e3c.isEqual( e3cc ) ) {
3219 Event e4 = new Event( 1, 2, 3 );
3220 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3223 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3226 final Event e4c = ( Event ) e4.copy();
3228 final Event e4cc = ( Event ) e4c.copy();
3229 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3232 if ( !e4c.isEqual( e4cc ) ) {
3235 final Event e5 = new Event();
3236 if ( !e5.isUnassigned() ) {
3239 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3242 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3245 final Event e6 = new Event( 1, 0, 0 );
3246 if ( !e6.asText().toString().equals( "duplication" ) ) {
3249 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3252 final Event e7 = new Event( 0, 1, 0 );
3253 if ( !e7.asText().toString().equals( "speciation" ) ) {
3256 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3259 final Event e8 = new Event( 0, 0, 1 );
3260 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3263 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3267 catch ( final Exception e ) {
3268 e.printStackTrace( System.out );
3274 private static boolean testDeletionOfExternalNodes() {
3276 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3277 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3278 final PhylogenyWriter w = new PhylogenyWriter();
3279 if ( t0.isEmpty() ) {
3282 if ( t0.getNumberOfExternalNodes() != 1 ) {
3285 t0.deleteSubtree( t0.getNode( "A" ), false );
3286 if ( t0.getNumberOfExternalNodes() != 0 ) {
3289 if ( !t0.isEmpty() ) {
3292 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3293 if ( t1.getNumberOfExternalNodes() != 2 ) {
3296 t1.deleteSubtree( t1.getNode( "A" ), false );
3297 if ( t1.getNumberOfExternalNodes() != 1 ) {
3300 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3303 t1.deleteSubtree( t1.getNode( "B" ), false );
3304 if ( t1.getNumberOfExternalNodes() != 1 ) {
3307 t1.deleteSubtree( t1.getNode( "r" ), false );
3308 if ( !t1.isEmpty() ) {
3311 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3312 if ( t2.getNumberOfExternalNodes() != 3 ) {
3315 t2.deleteSubtree( t2.getNode( "B" ), false );
3316 if ( t2.getNumberOfExternalNodes() != 2 ) {
3319 t2.toNewHampshireX();
3320 PhylogenyNode n = t2.getNode( "A" );
3321 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3324 t2.deleteSubtree( t2.getNode( "A" ), false );
3325 if ( t2.getNumberOfExternalNodes() != 2 ) {
3328 t2.deleteSubtree( t2.getNode( "C" ), true );
3329 if ( t2.getNumberOfExternalNodes() != 1 ) {
3332 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3333 if ( t3.getNumberOfExternalNodes() != 4 ) {
3336 t3.deleteSubtree( t3.getNode( "B" ), true );
3337 if ( t3.getNumberOfExternalNodes() != 3 ) {
3340 n = t3.getNode( "A" );
3341 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3344 n = n.getNextExternalNode();
3345 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3348 t3.deleteSubtree( t3.getNode( "A" ), true );
3349 if ( t3.getNumberOfExternalNodes() != 2 ) {
3352 n = t3.getNode( "C" );
3353 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3356 t3.deleteSubtree( t3.getNode( "C" ), true );
3357 if ( t3.getNumberOfExternalNodes() != 1 ) {
3360 t3.deleteSubtree( t3.getNode( "D" ), true );
3361 if ( t3.getNumberOfExternalNodes() != 0 ) {
3364 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3365 if ( t4.getNumberOfExternalNodes() != 6 ) {
3368 t4.deleteSubtree( t4.getNode( "B2" ), true );
3369 if ( t4.getNumberOfExternalNodes() != 5 ) {
3372 String s = w.toNewHampshire( t4, false, true ).toString();
3373 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3376 t4.deleteSubtree( t4.getNode( "B11" ), true );
3377 if ( t4.getNumberOfExternalNodes() != 4 ) {
3380 t4.deleteSubtree( t4.getNode( "C" ), true );
3381 if ( t4.getNumberOfExternalNodes() != 3 ) {
3384 n = t4.getNode( "A" );
3385 n = n.getNextExternalNode();
3386 if ( !n.getName().equals( "B12" ) ) {
3389 n = n.getNextExternalNode();
3390 if ( !n.getName().equals( "D" ) ) {
3393 s = w.toNewHampshire( t4, false, true ).toString();
3394 if ( !s.equals( "((A,B12),D);" ) ) {
3397 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3398 t5.deleteSubtree( t5.getNode( "A" ), true );
3399 if ( t5.getNumberOfExternalNodes() != 5 ) {
3402 s = w.toNewHampshire( t5, false, true ).toString();
3403 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3406 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3407 t6.deleteSubtree( t6.getNode( "B11" ), true );
3408 if ( t6.getNumberOfExternalNodes() != 5 ) {
3411 s = w.toNewHampshire( t6, false, false ).toString();
3412 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3415 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3416 t7.deleteSubtree( t7.getNode( "B12" ), true );
3417 if ( t7.getNumberOfExternalNodes() != 5 ) {
3420 s = w.toNewHampshire( t7, false, true ).toString();
3421 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3424 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3425 t8.deleteSubtree( t8.getNode( "B2" ), true );
3426 if ( t8.getNumberOfExternalNodes() != 5 ) {
3429 s = w.toNewHampshire( t8, false, false ).toString();
3430 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3433 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3434 t9.deleteSubtree( t9.getNode( "C" ), true );
3435 if ( t9.getNumberOfExternalNodes() != 5 ) {
3438 s = w.toNewHampshire( t9, false, true ).toString();
3439 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3442 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3443 t10.deleteSubtree( t10.getNode( "D" ), true );
3444 if ( t10.getNumberOfExternalNodes() != 5 ) {
3447 s = w.toNewHampshire( t10, false, true ).toString();
3448 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3451 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3452 t11.deleteSubtree( t11.getNode( "A" ), true );
3453 if ( t11.getNumberOfExternalNodes() != 2 ) {
3456 s = w.toNewHampshire( t11, false, true ).toString();
3457 if ( !s.equals( "(B,C);" ) ) {
3460 t11.deleteSubtree( t11.getNode( "C" ), true );
3461 if ( t11.getNumberOfExternalNodes() != 1 ) {
3464 s = w.toNewHampshire( t11, false, false ).toString();
3465 if ( !s.equals( "B;" ) ) {
3468 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3469 t12.deleteSubtree( t12.getNode( "B2" ), true );
3470 if ( t12.getNumberOfExternalNodes() != 8 ) {
3473 s = w.toNewHampshire( t12, false, true ).toString();
3474 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3477 t12.deleteSubtree( t12.getNode( "B3" ), true );
3478 if ( t12.getNumberOfExternalNodes() != 7 ) {
3481 s = w.toNewHampshire( t12, false, true ).toString();
3482 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3485 t12.deleteSubtree( t12.getNode( "C3" ), true );
3486 if ( t12.getNumberOfExternalNodes() != 6 ) {
3489 s = w.toNewHampshire( t12, false, true ).toString();
3490 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3493 t12.deleteSubtree( t12.getNode( "A1" ), true );
3494 if ( t12.getNumberOfExternalNodes() != 5 ) {
3497 s = w.toNewHampshire( t12, false, true ).toString();
3498 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3501 t12.deleteSubtree( t12.getNode( "B1" ), true );
3502 if ( t12.getNumberOfExternalNodes() != 4 ) {
3505 s = w.toNewHampshire( t12, false, true ).toString();
3506 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3509 t12.deleteSubtree( t12.getNode( "A3" ), true );
3510 if ( t12.getNumberOfExternalNodes() != 3 ) {
3513 s = w.toNewHampshire( t12, false, true ).toString();
3514 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3517 t12.deleteSubtree( t12.getNode( "A2" ), true );
3518 if ( t12.getNumberOfExternalNodes() != 2 ) {
3521 s = w.toNewHampshire( t12, false, true ).toString();
3522 if ( !s.equals( "(C1,C2);" ) ) {
3525 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3526 t13.deleteSubtree( t13.getNode( "D" ), true );
3527 if ( t13.getNumberOfExternalNodes() != 4 ) {
3530 s = w.toNewHampshire( t13, false, true ).toString();
3531 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3534 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3535 t14.deleteSubtree( t14.getNode( "E" ), true );
3536 if ( t14.getNumberOfExternalNodes() != 5 ) {
3539 s = w.toNewHampshire( t14, false, true ).toString();
3540 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3543 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3544 t15.deleteSubtree( t15.getNode( "B2" ), true );
3545 if ( t15.getNumberOfExternalNodes() != 11 ) {
3548 t15.deleteSubtree( t15.getNode( "B1" ), true );
3549 if ( t15.getNumberOfExternalNodes() != 10 ) {
3552 t15.deleteSubtree( t15.getNode( "B3" ), true );
3553 if ( t15.getNumberOfExternalNodes() != 9 ) {
3556 t15.deleteSubtree( t15.getNode( "B4" ), true );
3557 if ( t15.getNumberOfExternalNodes() != 8 ) {
3560 t15.deleteSubtree( t15.getNode( "A1" ), true );
3561 if ( t15.getNumberOfExternalNodes() != 7 ) {
3564 t15.deleteSubtree( t15.getNode( "C4" ), true );
3565 if ( t15.getNumberOfExternalNodes() != 6 ) {
3569 catch ( final Exception e ) {
3570 e.printStackTrace( System.out );
3576 private static boolean testDescriptiveStatistics() {
3578 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3579 dss1.addValue( 82 );
3580 dss1.addValue( 78 );
3581 dss1.addValue( 70 );
3582 dss1.addValue( 58 );
3583 dss1.addValue( 42 );
3584 if ( dss1.getN() != 5 ) {
3587 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3590 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3593 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3596 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3599 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3602 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3605 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3608 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3611 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3614 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3617 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3620 dss1.addValue( 123 );
3621 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3624 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3627 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3630 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3631 dss2.addValue( -1.85 );
3632 dss2.addValue( 57.5 );
3633 dss2.addValue( 92.78 );
3634 dss2.addValue( 57.78 );
3635 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3638 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3641 final double[] a = dss2.getDataAsDoubleArray();
3642 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3645 dss2.addValue( -100 );
3646 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3649 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3652 final double[] ds = new double[ 14 ];
3667 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3668 if ( bins.length != 4 ) {
3671 if ( bins[ 0 ] != 2 ) {
3674 if ( bins[ 1 ] != 3 ) {
3677 if ( bins[ 2 ] != 4 ) {
3680 if ( bins[ 3 ] != 5 ) {
3683 final double[] ds1 = new double[ 9 ];
3693 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3694 if ( bins1.length != 4 ) {
3697 if ( bins1[ 0 ] != 2 ) {
3700 if ( bins1[ 1 ] != 3 ) {
3703 if ( bins1[ 2 ] != 0 ) {
3706 if ( bins1[ 3 ] != 4 ) {
3709 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3710 if ( bins1_1.length != 3 ) {
3713 if ( bins1_1[ 0 ] != 3 ) {
3716 if ( bins1_1[ 1 ] != 2 ) {
3719 if ( bins1_1[ 2 ] != 4 ) {
3722 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3723 if ( bins1_2.length != 3 ) {
3726 if ( bins1_2[ 0 ] != 2 ) {
3729 if ( bins1_2[ 1 ] != 2 ) {
3732 if ( bins1_2[ 2 ] != 2 ) {
3735 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3749 dss3.addValue( 10 );
3750 dss3.addValue( 10 );
3751 dss3.addValue( 10 );
3752 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3753 histo.toStringBuffer( 10, '=', 40, 5 );
3754 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3756 catch ( final Exception e ) {
3757 e.printStackTrace( System.out );
3763 private static boolean testDir( final String file ) {
3765 final File f = new File( file );
3766 if ( !f.exists() ) {
3769 if ( !f.isDirectory() ) {
3772 if ( !f.canRead() ) {
3776 catch ( final Exception e ) {
3782 private static boolean testEbiEntryRetrieval() {
3784 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3785 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3786 System.out.println( entry.getAccession() );
3789 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3790 System.out.println( entry.getTaxonomyScientificName() );
3793 if ( !entry.getSequenceName()
3794 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3795 System.out.println( entry.getSequenceName() );
3798 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3799 // System.out.println( entry.getSequenceSymbol() );
3802 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3803 System.out.println( entry.getGeneName() );
3806 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3807 System.out.println( entry.getTaxonomyIdentifier() );
3810 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3811 System.out.println( entry.getAnnotations().first().getRefValue() );
3814 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3815 System.out.println( entry.getAnnotations().first().getRefSource() );
3818 if ( entry.getCrossReferences().size() != 5 ) {
3822 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3823 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3826 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3827 System.out.println( entry1.getTaxonomyScientificName() );
3830 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3831 System.out.println( entry1.getSequenceName() );
3834 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3835 System.out.println( entry1.getTaxonomyIdentifier() );
3838 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3839 System.out.println( entry1.getGeneName() );
3842 if ( entry1.getCrossReferences().size() != 6 ) {
3846 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3847 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3850 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3851 System.out.println( entry2.getTaxonomyScientificName() );
3854 if ( !entry2.getSequenceName()
3855 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3856 System.out.println( entry2.getSequenceName() );
3859 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3860 System.out.println( entry2.getTaxonomyIdentifier() );
3863 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3864 System.out.println( entry2.getGeneName() );
3867 if ( entry2.getCrossReferences().size() != 3 ) {
3871 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3872 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3875 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3876 System.out.println( entry3.getTaxonomyScientificName() );
3879 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3880 System.out.println( entry3.getSequenceName() );
3883 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3884 System.out.println( entry3.getTaxonomyIdentifier() );
3887 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3888 System.out.println( entry3.getSequenceSymbol() );
3891 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3894 if ( entry3.getCrossReferences().size() != 8 ) {
3899 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3900 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
3903 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3904 System.out.println( entry4.getTaxonomyScientificName() );
3907 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
3908 System.out.println( entry4.getSequenceName() );
3911 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
3912 System.out.println( entry4.getTaxonomyIdentifier() );
3915 if ( !entry4.getGeneName().equals( "ras" ) ) {
3916 System.out.println( entry4.getGeneName() );
3919 // if ( !entry4.getChromosome().equals( "ras" ) ) {
3920 // System.out.println( entry4.getChromosome() );
3923 // if ( !entry4.getMap().equals( "ras" ) ) {
3924 // System.out.println( entry4.getMap() );
3930 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
3931 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
3934 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
3935 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
3938 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
3939 System.out.println( entry5.getTaxonomyScientificName() );
3942 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
3943 System.out.println( entry5.getSequenceName() );
3946 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
3947 System.out.println( entry5.getTaxonomyIdentifier() );
3951 catch ( final IOException e ) {
3952 System.out.println();
3953 System.out.println( "the following might be due to absence internet connection:" );
3954 e.printStackTrace( System.out );
3957 catch ( final Exception e ) {
3958 e.printStackTrace();
3964 private static boolean testExternalNodeRelatedMethods() {
3966 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3967 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3968 PhylogenyNode n = t1.getNode( "A" );
3969 n = n.getNextExternalNode();
3970 if ( !n.getName().equals( "B" ) ) {
3973 n = n.getNextExternalNode();
3974 if ( !n.getName().equals( "C" ) ) {
3977 n = n.getNextExternalNode();
3978 if ( !n.getName().equals( "D" ) ) {
3981 n = t1.getNode( "B" );
3982 while ( !n.isLastExternalNode() ) {
3983 n = n.getNextExternalNode();
3985 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3986 n = t2.getNode( "A" );
3987 n = n.getNextExternalNode();
3988 if ( !n.getName().equals( "B" ) ) {
3991 n = n.getNextExternalNode();
3992 if ( !n.getName().equals( "C" ) ) {
3995 n = n.getNextExternalNode();
3996 if ( !n.getName().equals( "D" ) ) {
3999 n = t2.getNode( "B" );
4000 while ( !n.isLastExternalNode() ) {
4001 n = n.getNextExternalNode();
4003 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4004 n = t3.getNode( "A" );
4005 n = n.getNextExternalNode();
4006 if ( !n.getName().equals( "B" ) ) {
4009 n = n.getNextExternalNode();
4010 if ( !n.getName().equals( "C" ) ) {
4013 n = n.getNextExternalNode();
4014 if ( !n.getName().equals( "D" ) ) {
4017 n = n.getNextExternalNode();
4018 if ( !n.getName().equals( "E" ) ) {
4021 n = n.getNextExternalNode();
4022 if ( !n.getName().equals( "F" ) ) {
4025 n = n.getNextExternalNode();
4026 if ( !n.getName().equals( "G" ) ) {
4029 n = n.getNextExternalNode();
4030 if ( !n.getName().equals( "H" ) ) {
4033 n = t3.getNode( "B" );
4034 while ( !n.isLastExternalNode() ) {
4035 n = n.getNextExternalNode();
4037 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4038 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4039 final PhylogenyNode node = iter.next();
4041 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4042 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4043 final PhylogenyNode node = iter.next();
4045 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4046 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4047 if ( !iter.next().getName().equals( "A" ) ) {
4050 if ( !iter.next().getName().equals( "B" ) ) {
4053 if ( !iter.next().getName().equals( "C" ) ) {
4056 if ( !iter.next().getName().equals( "D" ) ) {
4059 if ( !iter.next().getName().equals( "E" ) ) {
4062 if ( !iter.next().getName().equals( "F" ) ) {
4065 if ( iter.hasNext() ) {
4069 catch ( final Exception e ) {
4070 e.printStackTrace( System.out );
4076 private static boolean testExtractSNFromNodeName() {
4078 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4081 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
4082 .equals( "Mus musculus musculus" ) ) {
4085 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
4086 .equals( "Mus musculus musculus" ) ) {
4089 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
4092 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
4093 .equals( "Mus musculus" ) ) {
4096 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4099 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus" )
4100 .equals( "Mus musculus musculus" ) ) {
4103 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4107 catch ( final Exception e ) {
4108 e.printStackTrace( System.out );
4114 private static boolean testExtractTaxonomyCodeFromNodeName() {
4116 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4119 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4120 .equals( "SOYBN" ) ) {
4123 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4124 .equals( "ARATH" ) ) {
4127 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4128 .equals( "ARATH" ) ) {
4131 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4134 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4137 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4140 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4141 .equals( "SOYBN" ) ) {
4144 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4145 .equals( "SOYBN" ) ) {
4148 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4149 .equals( "SOYBN" ) ) {
4152 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4153 .equals( "SOYBN" ) ) {
4156 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4157 .equals( "SOYBN" ) ) {
4160 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4161 .equals( "SOYBN" ) ) {
4164 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4165 .equals( "SOYBN" ) ) {
4168 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4169 .equals( "SOYBN" ) ) {
4172 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4175 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4176 .equals( "SOYBN" ) ) {
4179 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4180 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4183 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4184 .equals( "9YX45" ) ) {
4187 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4188 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4189 .equals( "MOUSE" ) ) {
4192 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4193 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4194 .equals( "MOUSE" ) ) {
4197 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4198 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4199 .equals( "MOUSE" ) ) {
4202 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4203 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4206 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4207 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4210 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4211 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4214 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4215 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4218 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4219 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4222 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4223 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4226 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4227 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4230 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4231 .equals( "RAT" ) ) {
4234 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4235 .equals( "PIG" ) ) {
4239 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4240 .equals( "MOUSE" ) ) {
4243 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4244 .equals( "MOUSE" ) ) {
4247 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4251 catch ( final Exception e ) {
4252 e.printStackTrace( System.out );
4258 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4260 PhylogenyNode n = new PhylogenyNode();
4261 n.setName( "tr|B3RJ64" );
4262 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4265 n.setName( "tr.B3RJ64" );
4266 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4269 n.setName( "tr=B3RJ64" );
4270 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4273 n.setName( "tr-B3RJ64" );
4274 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4277 n.setName( "tr/B3RJ64" );
4278 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4281 n.setName( "tr\\B3RJ64" );
4282 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4285 n.setName( "tr_B3RJ64" );
4286 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4289 n.setName( " tr|B3RJ64 " );
4290 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4293 n.setName( "-tr|B3RJ64-" );
4294 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4297 n.setName( "-tr=B3RJ64-" );
4298 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4301 n.setName( "_tr=B3RJ64_" );
4302 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4305 n.setName( " tr_tr|B3RJ64_sp|123 " );
4306 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4309 n.setName( "B3RJ64" );
4310 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4313 n.setName( "sp|B3RJ64" );
4314 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4317 n.setName( "sp|B3RJ64C" );
4318 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4321 n.setName( "sp B3RJ64" );
4322 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4325 n.setName( "sp|B3RJ6X" );
4326 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4329 n.setName( "sp|B3RJ6" );
4330 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4333 n.setName( "K1PYK7_CRAGI" );
4334 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4337 n.setName( "K1PYK7_PEA" );
4338 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4341 n.setName( "K1PYK7_RAT" );
4342 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4345 n.setName( "K1PYK7_PIG" );
4346 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4349 n.setName( "~K1PYK7_PIG~" );
4350 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4353 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4354 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4357 n.setName( "K1PYKX_CRAGI" );
4358 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4361 n.setName( "XXXXX_CRAGI" );
4362 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4365 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4366 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4369 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4370 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4373 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4374 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4377 n = new PhylogenyNode();
4378 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4379 seq.setSymbol( "K1PYK7_CRAGI" );
4380 n.getNodeData().addSequence( seq );
4381 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4384 seq.setSymbol( "tr|B3RJ64" );
4385 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4388 n = new PhylogenyNode();
4389 seq = new org.forester.phylogeny.data.Sequence();
4390 seq.setName( "K1PYK7_CRAGI" );
4391 n.getNodeData().addSequence( seq );
4392 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4395 seq.setName( "tr|B3RJ64" );
4396 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4399 n = new PhylogenyNode();
4400 seq = new org.forester.phylogeny.data.Sequence();
4401 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4402 n.getNodeData().addSequence( seq );
4403 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4406 n = new PhylogenyNode();
4407 seq = new org.forester.phylogeny.data.Sequence();
4408 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4409 n.getNodeData().addSequence( seq );
4410 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4414 n = new PhylogenyNode();
4415 n.setName( "ACP19736" );
4416 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4419 n = new PhylogenyNode();
4420 n.setName( "|ACP19736|" );
4421 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4425 catch ( final Exception e ) {
4426 e.printStackTrace( System.out );
4432 private static boolean testFastaParser() {
4434 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4437 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4440 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4441 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4444 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4447 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4450 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4453 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4456 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4460 catch ( final Exception e ) {
4461 e.printStackTrace();
4467 private static boolean testGenbankAccessorParsing() {
4468 //The format for GenBank Accession numbers are:
4469 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4470 //Protein: 3 letters + 5 numerals
4471 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4472 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4475 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4478 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4481 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4484 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4487 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4490 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4493 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4496 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4499 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4502 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4505 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4508 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4511 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4517 private static boolean testGeneralMsaParser() {
4519 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4520 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4521 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4522 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4523 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4524 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4525 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4526 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4527 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4530 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4533 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4536 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4539 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4542 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4545 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4548 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4551 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4554 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4557 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4560 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4563 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4564 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4567 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4570 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4573 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4574 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4577 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4580 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4583 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4584 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4587 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4590 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4594 catch ( final Exception e ) {
4595 e.printStackTrace();
4601 private static boolean testGeneralTable() {
4603 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4604 t0.setValue( 3, 2, "23" );
4605 t0.setValue( 10, 1, "error" );
4606 t0.setValue( 10, 1, "110" );
4607 t0.setValue( 9, 1, "19" );
4608 t0.setValue( 1, 10, "101" );
4609 t0.setValue( 10, 10, "1010" );
4610 t0.setValue( 100, 10, "10100" );
4611 t0.setValue( 0, 0, "00" );
4612 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4615 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4618 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4621 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4624 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4627 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4630 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4633 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4636 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4639 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4640 t1.setValue( "3", "2", "23" );
4641 t1.setValue( "10", "1", "error" );
4642 t1.setValue( "10", "1", "110" );
4643 t1.setValue( "9", "1", "19" );
4644 t1.setValue( "1", "10", "101" );
4645 t1.setValue( "10", "10", "1010" );
4646 t1.setValue( "100", "10", "10100" );
4647 t1.setValue( "0", "0", "00" );
4648 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4649 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4652 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4655 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4658 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4661 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4664 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4667 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4670 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4673 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4676 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4680 catch ( final Exception e ) {
4681 e.printStackTrace( System.out );
4687 private static boolean testGetDistance() {
4689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4690 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",
4691 new NHXParser() )[ 0 ];
4692 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4695 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4698 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4701 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4704 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4707 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4710 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4713 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4716 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4719 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4722 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4725 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4728 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4731 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4734 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4737 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4740 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4743 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4746 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4749 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4752 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4755 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4758 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4761 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4764 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4767 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4770 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4773 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4776 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4779 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4782 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4785 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",
4786 new NHXParser() )[ 0 ];
4787 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4790 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4793 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4796 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4799 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4802 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4805 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4808 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4811 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4814 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4817 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4821 catch ( final Exception e ) {
4822 e.printStackTrace( System.out );
4828 private static boolean testGetLCA() {
4830 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4831 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4832 new NHXParser() )[ 0 ];
4833 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4834 if ( !A.getName().equals( "A" ) ) {
4837 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4838 if ( !gh.getName().equals( "gh" ) ) {
4841 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4842 if ( !ab.getName().equals( "ab" ) ) {
4845 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4846 if ( !ab2.getName().equals( "ab" ) ) {
4849 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4850 if ( !gh2.getName().equals( "gh" ) ) {
4853 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4854 if ( !gh3.getName().equals( "gh" ) ) {
4857 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4858 if ( !abc.getName().equals( "abc" ) ) {
4861 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4862 if ( !abc2.getName().equals( "abc" ) ) {
4865 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4866 if ( !abcd.getName().equals( "abcd" ) ) {
4869 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4870 if ( !abcd2.getName().equals( "abcd" ) ) {
4873 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4874 if ( !abcdef.getName().equals( "abcdef" ) ) {
4877 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4878 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4881 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4882 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4885 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4886 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4889 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4890 if ( !abcde.getName().equals( "abcde" ) ) {
4893 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4894 if ( !abcde2.getName().equals( "abcde" ) ) {
4897 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4898 if ( !r.getName().equals( "abcdefgh" ) ) {
4901 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4902 if ( !r2.getName().equals( "abcdefgh" ) ) {
4905 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4906 if ( !r3.getName().equals( "abcdefgh" ) ) {
4909 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4910 if ( !abcde3.getName().equals( "abcde" ) ) {
4913 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4914 if ( !abcde4.getName().equals( "abcde" ) ) {
4917 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4918 if ( !ab3.getName().equals( "ab" ) ) {
4921 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4922 if ( !ab4.getName().equals( "ab" ) ) {
4925 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4926 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4927 if ( !cd.getName().equals( "cd" ) ) {
4930 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4931 if ( !cd2.getName().equals( "cd" ) ) {
4934 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4935 if ( !cde.getName().equals( "cde" ) ) {
4938 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4939 if ( !cde2.getName().equals( "cde" ) ) {
4942 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4943 if ( !cdef.getName().equals( "cdef" ) ) {
4946 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4947 if ( !cdef2.getName().equals( "cdef" ) ) {
4950 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4951 if ( !cdef3.getName().equals( "cdef" ) ) {
4954 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4955 if ( !rt.getName().equals( "r" ) ) {
4958 final Phylogeny p3 = factory
4959 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4960 new NHXParser() )[ 0 ];
4961 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4962 if ( !bc_3.getName().equals( "bc" ) ) {
4965 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4966 if ( !ac_3.getName().equals( "abc" ) ) {
4969 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4970 if ( !ad_3.getName().equals( "abcde" ) ) {
4973 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4974 if ( !af_3.getName().equals( "abcdef" ) ) {
4977 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4978 if ( !ag_3.getName().equals( "" ) ) {
4981 if ( !ag_3.isRoot() ) {
4984 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4985 if ( !al_3.getName().equals( "" ) ) {
4988 if ( !al_3.isRoot() ) {
4991 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4992 if ( !kl_3.getName().equals( "" ) ) {
4995 if ( !kl_3.isRoot() ) {
4998 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4999 if ( !fl_3.getName().equals( "" ) ) {
5002 if ( !fl_3.isRoot() ) {
5005 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5006 if ( !gk_3.getName().equals( "ghijk" ) ) {
5009 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5010 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5011 if ( !r_4.getName().equals( "r" ) ) {
5014 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5015 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5016 if ( !r_5.getName().equals( "root" ) ) {
5019 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5020 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5021 if ( !r_6.getName().equals( "rot" ) ) {
5024 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5025 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5026 if ( !r_7.getName().equals( "rott" ) ) {
5030 catch ( final Exception e ) {
5031 e.printStackTrace( System.out );
5037 private static boolean testGetLCA2() {
5039 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5040 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5041 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5042 PhylogenyMethods.preOrderReId( p_a );
5043 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5044 p_a.getNode( "a" ) );
5045 if ( !p_a_1.getName().equals( "a" ) ) {
5048 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5049 PhylogenyMethods.preOrderReId( p_b );
5050 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5051 p_b.getNode( "a" ) );
5052 if ( !p_b_1.getName().equals( "b" ) ) {
5055 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5056 p_b.getNode( "b" ) );
5057 if ( !p_b_2.getName().equals( "b" ) ) {
5060 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5061 PhylogenyMethods.preOrderReId( p_c );
5062 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5063 p_c.getNode( "a" ) );
5064 if ( !p_c_1.getName().equals( "b" ) ) {
5067 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5068 p_c.getNode( "c" ) );
5069 if ( !p_c_2.getName().equals( "c" ) ) {
5070 System.out.println( p_c_2.getName() );
5074 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5075 p_c.getNode( "b" ) );
5076 if ( !p_c_3.getName().equals( "b" ) ) {
5079 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5080 p_c.getNode( "a" ) );
5081 if ( !p_c_4.getName().equals( "c" ) ) {
5084 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5085 new NHXParser() )[ 0 ];
5086 PhylogenyMethods.preOrderReId( p1 );
5087 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5088 p1.getNode( "A" ) );
5089 if ( !A.getName().equals( "A" ) ) {
5092 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5093 p1.getNode( "gh" ) );
5094 if ( !gh.getName().equals( "gh" ) ) {
5097 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5098 p1.getNode( "B" ) );
5099 if ( !ab.getName().equals( "ab" ) ) {
5102 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5103 p1.getNode( "A" ) );
5104 if ( !ab2.getName().equals( "ab" ) ) {
5107 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5108 p1.getNode( "G" ) );
5109 if ( !gh2.getName().equals( "gh" ) ) {
5112 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5113 p1.getNode( "H" ) );
5114 if ( !gh3.getName().equals( "gh" ) ) {
5117 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5118 p1.getNode( "A" ) );
5119 if ( !abc.getName().equals( "abc" ) ) {
5122 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5123 p1.getNode( "C" ) );
5124 if ( !abc2.getName().equals( "abc" ) ) {
5127 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5128 p1.getNode( "D" ) );
5129 if ( !abcd.getName().equals( "abcd" ) ) {
5132 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5133 p1.getNode( "A" ) );
5134 if ( !abcd2.getName().equals( "abcd" ) ) {
5137 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5138 p1.getNode( "F" ) );
5139 if ( !abcdef.getName().equals( "abcdef" ) ) {
5142 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5143 p1.getNode( "A" ) );
5144 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5147 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5148 p1.getNode( "F" ) );
5149 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5152 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5153 p1.getNode( "ab" ) );
5154 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5157 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5158 p1.getNode( "E" ) );
5159 if ( !abcde.getName().equals( "abcde" ) ) {
5162 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5163 p1.getNode( "A" ) );
5164 if ( !abcde2.getName().equals( "abcde" ) ) {
5167 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5168 p1.getNode( "abcdefgh" ) );
5169 if ( !r.getName().equals( "abcdefgh" ) ) {
5172 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5173 p1.getNode( "H" ) );
5174 if ( !r2.getName().equals( "abcdefgh" ) ) {
5177 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5178 p1.getNode( "A" ) );
5179 if ( !r3.getName().equals( "abcdefgh" ) ) {
5182 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5183 p1.getNode( "abcde" ) );
5184 if ( !abcde3.getName().equals( "abcde" ) ) {
5187 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5188 p1.getNode( "E" ) );
5189 if ( !abcde4.getName().equals( "abcde" ) ) {
5192 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5193 p1.getNode( "B" ) );
5194 if ( !ab3.getName().equals( "ab" ) ) {
5197 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5198 p1.getNode( "ab" ) );
5199 if ( !ab4.getName().equals( "ab" ) ) {
5202 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5203 PhylogenyMethods.preOrderReId( p2 );
5204 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5205 p2.getNode( "d" ) );
5206 if ( !cd.getName().equals( "cd" ) ) {
5209 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5210 p2.getNode( "c" ) );
5211 if ( !cd2.getName().equals( "cd" ) ) {
5214 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5215 p2.getNode( "e" ) );
5216 if ( !cde.getName().equals( "cde" ) ) {
5219 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5220 p2.getNode( "c" ) );
5221 if ( !cde2.getName().equals( "cde" ) ) {
5224 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5225 p2.getNode( "f" ) );
5226 if ( !cdef.getName().equals( "cdef" ) ) {
5229 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5230 p2.getNode( "f" ) );
5231 if ( !cdef2.getName().equals( "cdef" ) ) {
5234 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5235 p2.getNode( "d" ) );
5236 if ( !cdef3.getName().equals( "cdef" ) ) {
5239 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5240 p2.getNode( "a" ) );
5241 if ( !rt.getName().equals( "r" ) ) {
5244 final Phylogeny p3 = factory
5245 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5246 new NHXParser() )[ 0 ];
5247 PhylogenyMethods.preOrderReId( p3 );
5248 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5249 p3.getNode( "c" ) );
5250 if ( !bc_3.getName().equals( "bc" ) ) {
5253 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5254 p3.getNode( "c" ) );
5255 if ( !ac_3.getName().equals( "abc" ) ) {
5258 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5259 p3.getNode( "d" ) );
5260 if ( !ad_3.getName().equals( "abcde" ) ) {
5263 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5264 p3.getNode( "f" ) );
5265 if ( !af_3.getName().equals( "abcdef" ) ) {
5268 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5269 p3.getNode( "g" ) );
5270 if ( !ag_3.getName().equals( "" ) ) {
5273 if ( !ag_3.isRoot() ) {
5276 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5277 p3.getNode( "l" ) );
5278 if ( !al_3.getName().equals( "" ) ) {
5281 if ( !al_3.isRoot() ) {
5284 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5285 p3.getNode( "l" ) );
5286 if ( !kl_3.getName().equals( "" ) ) {
5289 if ( !kl_3.isRoot() ) {
5292 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5293 p3.getNode( "l" ) );
5294 if ( !fl_3.getName().equals( "" ) ) {
5297 if ( !fl_3.isRoot() ) {
5300 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5301 p3.getNode( "k" ) );
5302 if ( !gk_3.getName().equals( "ghijk" ) ) {
5305 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5306 PhylogenyMethods.preOrderReId( p4 );
5307 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5308 p4.getNode( "c" ) );
5309 if ( !r_4.getName().equals( "r" ) ) {
5312 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5313 PhylogenyMethods.preOrderReId( p5 );
5314 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5315 p5.getNode( "c" ) );
5316 if ( !r_5.getName().equals( "root" ) ) {
5319 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5320 PhylogenyMethods.preOrderReId( p6 );
5321 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5322 p6.getNode( "a" ) );
5323 if ( !r_6.getName().equals( "rot" ) ) {
5326 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5327 PhylogenyMethods.preOrderReId( p7 );
5328 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5329 p7.getNode( "e" ) );
5330 if ( !r_7.getName().equals( "rott" ) ) {
5333 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5334 p7.getNode( "a" ) );
5335 if ( !r_71.getName().equals( "rott" ) ) {
5338 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5339 p7.getNode( "rott" ) );
5340 if ( !r_72.getName().equals( "rott" ) ) {
5343 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5344 p7.getNode( "a" ) );
5345 if ( !r_73.getName().equals( "rott" ) ) {
5348 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5349 p7.getNode( "rott" ) );
5350 if ( !r_74.getName().equals( "rott" ) ) {
5353 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5354 p7.getNode( "e" ) );
5355 if ( !r_75.getName().equals( "e" ) ) {
5359 catch ( final Exception e ) {
5360 e.printStackTrace( System.out );
5366 private static boolean testHmmscanOutputParser() {
5367 final String test_dir = Test.PATH_TO_TEST_DATA;
5369 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5370 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5372 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5373 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5374 final List<Protein> proteins = parser2.parse();
5375 if ( parser2.getProteinsEncountered() != 4 ) {
5378 if ( proteins.size() != 4 ) {
5381 if ( parser2.getDomainsEncountered() != 69 ) {
5384 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5387 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5390 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5393 final Protein p1 = proteins.get( 0 );
5394 if ( p1.getNumberOfProteinDomains() != 15 ) {
5397 if ( p1.getLength() != 850 ) {
5400 final Protein p2 = proteins.get( 1 );
5401 if ( p2.getNumberOfProteinDomains() != 51 ) {
5404 if ( p2.getLength() != 1291 ) {
5407 final Protein p3 = proteins.get( 2 );
5408 if ( p3.getNumberOfProteinDomains() != 2 ) {
5411 final Protein p4 = proteins.get( 3 );
5412 if ( p4.getNumberOfProteinDomains() != 1 ) {
5415 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5418 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5421 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5424 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5427 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5430 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5433 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5437 catch ( final Exception e ) {
5438 e.printStackTrace( System.out );
5444 private static boolean testLastExternalNodeMethods() {
5446 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5447 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5448 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5449 final PhylogenyNode n1 = t0.getNode( "A" );
5450 if ( n1.isLastExternalNode() ) {
5453 final PhylogenyNode n2 = t0.getNode( "B" );
5454 if ( n2.isLastExternalNode() ) {
5457 final PhylogenyNode n3 = t0.getNode( "C" );
5458 if ( n3.isLastExternalNode() ) {
5461 final PhylogenyNode n4 = t0.getNode( "D" );
5462 if ( !n4.isLastExternalNode() ) {
5466 catch ( final Exception e ) {
5467 e.printStackTrace( System.out );
5473 private static boolean testLevelOrderIterator() {
5475 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5476 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5477 PhylogenyNodeIterator it0;
5478 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5481 for( it0.reset(); it0.hasNext(); ) {
5484 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5485 if ( !it.next().getName().equals( "r" ) ) {
5488 if ( !it.next().getName().equals( "ab" ) ) {
5491 if ( !it.next().getName().equals( "cd" ) ) {
5494 if ( !it.next().getName().equals( "A" ) ) {
5497 if ( !it.next().getName().equals( "B" ) ) {
5500 if ( !it.next().getName().equals( "C" ) ) {
5503 if ( !it.next().getName().equals( "D" ) ) {
5506 if ( it.hasNext() ) {
5509 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",
5510 new NHXParser() )[ 0 ];
5511 PhylogenyNodeIterator it2;
5512 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5515 for( it2.reset(); it2.hasNext(); ) {
5518 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5519 if ( !it3.next().getName().equals( "r" ) ) {
5522 if ( !it3.next().getName().equals( "abc" ) ) {
5525 if ( !it3.next().getName().equals( "defg" ) ) {
5528 if ( !it3.next().getName().equals( "A" ) ) {
5531 if ( !it3.next().getName().equals( "B" ) ) {
5534 if ( !it3.next().getName().equals( "C" ) ) {
5537 if ( !it3.next().getName().equals( "D" ) ) {
5540 if ( !it3.next().getName().equals( "E" ) ) {
5543 if ( !it3.next().getName().equals( "F" ) ) {
5546 if ( !it3.next().getName().equals( "G" ) ) {
5549 if ( !it3.next().getName().equals( "1" ) ) {
5552 if ( !it3.next().getName().equals( "2" ) ) {
5555 if ( !it3.next().getName().equals( "3" ) ) {
5558 if ( !it3.next().getName().equals( "4" ) ) {
5561 if ( !it3.next().getName().equals( "5" ) ) {
5564 if ( !it3.next().getName().equals( "6" ) ) {
5567 if ( !it3.next().getName().equals( "f1" ) ) {
5570 if ( !it3.next().getName().equals( "f2" ) ) {
5573 if ( !it3.next().getName().equals( "f3" ) ) {
5576 if ( !it3.next().getName().equals( "a" ) ) {
5579 if ( !it3.next().getName().equals( "b" ) ) {
5582 if ( !it3.next().getName().equals( "f21" ) ) {
5585 if ( !it3.next().getName().equals( "X" ) ) {
5588 if ( !it3.next().getName().equals( "Y" ) ) {
5591 if ( !it3.next().getName().equals( "Z" ) ) {
5594 if ( it3.hasNext() ) {
5597 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5598 PhylogenyNodeIterator it4;
5599 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5602 for( it4.reset(); it4.hasNext(); ) {
5605 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5606 if ( !it5.next().getName().equals( "r" ) ) {
5609 if ( !it5.next().getName().equals( "A" ) ) {
5612 if ( !it5.next().getName().equals( "B" ) ) {
5615 if ( !it5.next().getName().equals( "C" ) ) {
5618 if ( !it5.next().getName().equals( "D" ) ) {
5621 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5622 PhylogenyNodeIterator it6;
5623 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5626 for( it6.reset(); it6.hasNext(); ) {
5629 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5630 if ( !it7.next().getName().equals( "A" ) ) {
5633 if ( it.hasNext() ) {
5637 catch ( final Exception e ) {
5638 e.printStackTrace( System.out );
5644 private static boolean testMafft( final String path ) {
5646 final List<String> opts = new ArrayList<String>();
5647 opts.add( "--maxiterate" );
5649 opts.add( "--localpair" );
5650 opts.add( "--quiet" );
5652 final MsaInferrer mafft = Mafft.createInstance( path );
5653 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5654 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5657 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5661 catch ( final Exception e ) {
5662 e.printStackTrace( System.out );
5668 private static boolean testMidpointrooting() {
5670 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5671 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5672 PhylogenyMethods.midpointRoot( t0 );
5673 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5676 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5679 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5683 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",
5684 new NHXParser() )[ 0 ];
5685 if ( !t1.isRooted() ) {
5688 PhylogenyMethods.midpointRoot( t1 );
5689 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5692 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5695 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5698 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5701 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5704 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5707 t1.reRoot( t1.getNode( "A" ) );
5708 PhylogenyMethods.midpointRoot( t1 );
5709 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5712 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5715 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5718 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5721 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5725 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5729 catch ( final Exception e ) {
5730 e.printStackTrace( System.out );
5736 private static boolean testMsaQualityMethod() {
5738 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
5739 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
5740 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
5741 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
5742 final List<Sequence> l = new ArrayList<Sequence>();
5747 final Msa msa = BasicMsa.createInstance( l );
5748 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5751 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5754 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5757 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5760 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
5763 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
5766 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
5770 catch ( final Exception e ) {
5771 e.printStackTrace( System.out );
5777 private static boolean testNextNodeWithCollapsing() {
5779 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5781 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5782 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5783 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5784 t0.getNode( "cd" ).setCollapse( true );
5785 t0.getNode( "cde" ).setCollapse( true );
5786 n = t0.getFirstExternalNode();
5787 while ( n != null ) {
5789 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5791 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5794 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5797 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5800 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5803 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5806 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5810 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5811 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5812 t1.getNode( "ab" ).setCollapse( true );
5813 t1.getNode( "cd" ).setCollapse( true );
5814 t1.getNode( "cde" ).setCollapse( true );
5815 n = t1.getNode( "ab" );
5816 ext = new ArrayList<PhylogenyNode>();
5817 while ( n != null ) {
5819 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5821 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5824 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5827 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5830 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5833 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5839 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5840 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5841 t2.getNode( "ab" ).setCollapse( true );
5842 t2.getNode( "cd" ).setCollapse( true );
5843 t2.getNode( "cde" ).setCollapse( true );
5844 t2.getNode( "c" ).setCollapse( true );
5845 t2.getNode( "d" ).setCollapse( true );
5846 t2.getNode( "e" ).setCollapse( true );
5847 t2.getNode( "gh" ).setCollapse( true );
5848 n = t2.getNode( "ab" );
5849 ext = new ArrayList<PhylogenyNode>();
5850 while ( n != null ) {
5852 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5854 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5857 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5860 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5863 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5869 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5870 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5871 t3.getNode( "ab" ).setCollapse( true );
5872 t3.getNode( "cd" ).setCollapse( true );
5873 t3.getNode( "cde" ).setCollapse( true );
5874 t3.getNode( "c" ).setCollapse( true );
5875 t3.getNode( "d" ).setCollapse( true );
5876 t3.getNode( "e" ).setCollapse( true );
5877 t3.getNode( "gh" ).setCollapse( true );
5878 t3.getNode( "fgh" ).setCollapse( true );
5879 n = t3.getNode( "ab" );
5880 ext = new ArrayList<PhylogenyNode>();
5881 while ( n != null ) {
5883 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5885 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5888 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5891 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5897 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5898 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5899 t4.getNode( "ab" ).setCollapse( true );
5900 t4.getNode( "cd" ).setCollapse( true );
5901 t4.getNode( "cde" ).setCollapse( true );
5902 t4.getNode( "c" ).setCollapse( true );
5903 t4.getNode( "d" ).setCollapse( true );
5904 t4.getNode( "e" ).setCollapse( true );
5905 t4.getNode( "gh" ).setCollapse( true );
5906 t4.getNode( "fgh" ).setCollapse( true );
5907 t4.getNode( "abcdefgh" ).setCollapse( true );
5908 n = t4.getNode( "abcdefgh" );
5909 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5914 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5915 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5917 n = t5.getFirstExternalNode();
5918 while ( n != null ) {
5920 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5922 if ( ext.size() != 8 ) {
5925 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5928 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5931 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5934 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5937 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5940 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5943 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5946 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5951 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5952 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5954 t6.getNode( "ab" ).setCollapse( true );
5955 n = t6.getNode( "ab" );
5956 while ( n != null ) {
5958 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5960 if ( ext.size() != 7 ) {
5963 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5966 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5969 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5972 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5975 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5978 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5981 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5986 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5987 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5989 t7.getNode( "cd" ).setCollapse( true );
5990 n = t7.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" ) ) {
6007 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6010 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6013 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6016 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6021 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6022 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6024 t8.getNode( "cd" ).setCollapse( true );
6025 t8.getNode( "c" ).setCollapse( true );
6026 t8.getNode( "d" ).setCollapse( true );
6027 n = t8.getNode( "a" );
6028 while ( n != null ) {
6030 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6032 if ( ext.size() != 7 ) {
6035 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6038 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6041 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6042 System.out.println( "2 fail" );
6045 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6048 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6051 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6054 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6059 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6060 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6062 t9.getNode( "gh" ).setCollapse( true );
6063 n = t9.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 sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6095 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6097 t10.getNode( "gh" ).setCollapse( true );
6098 t10.getNode( "g" ).setCollapse( true );
6099 t10.getNode( "h" ).setCollapse( true );
6100 n = t10.getNode( "a" );
6101 while ( n != null ) {
6103 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6105 if ( ext.size() != 7 ) {
6108 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6111 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6114 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6117 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6120 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6123 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6126 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6131 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6132 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6134 t11.getNode( "gh" ).setCollapse( true );
6135 t11.getNode( "fgh" ).setCollapse( true );
6136 n = t11.getNode( "a" );
6137 while ( n != null ) {
6139 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6141 if ( ext.size() != 6 ) {
6144 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6147 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6150 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6153 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6156 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6159 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6164 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6165 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6167 t12.getNode( "gh" ).setCollapse( true );
6168 t12.getNode( "fgh" ).setCollapse( true );
6169 t12.getNode( "g" ).setCollapse( true );
6170 t12.getNode( "h" ).setCollapse( true );
6171 t12.getNode( "f" ).setCollapse( true );
6172 n = t12.getNode( "a" );
6173 while ( n != null ) {
6175 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6177 if ( ext.size() != 6 ) {
6180 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6183 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6186 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6189 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6192 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6195 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6200 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6201 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6203 t13.getNode( "ab" ).setCollapse( true );
6204 t13.getNode( "b" ).setCollapse( true );
6205 t13.getNode( "fgh" ).setCollapse( true );
6206 t13.getNode( "gh" ).setCollapse( true );
6207 n = t13.getNode( "ab" );
6208 while ( n != null ) {
6210 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6212 if ( ext.size() != 5 ) {
6215 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6218 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6221 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6224 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6227 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6232 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6233 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6235 t14.getNode( "ab" ).setCollapse( true );
6236 t14.getNode( "a" ).setCollapse( true );
6237 t14.getNode( "fgh" ).setCollapse( true );
6238 t14.getNode( "gh" ).setCollapse( true );
6239 n = t14.getNode( "ab" );
6240 while ( n != null ) {
6242 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6244 if ( ext.size() != 5 ) {
6247 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6250 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6253 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6256 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6259 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6264 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" );
6265 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6267 t15.getNode( "ab" ).setCollapse( true );
6268 t15.getNode( "a" ).setCollapse( true );
6269 t15.getNode( "fgh" ).setCollapse( true );
6270 t15.getNode( "gh" ).setCollapse( true );
6271 n = t15.getNode( "ab" );
6272 while ( n != null ) {
6274 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6276 if ( ext.size() != 6 ) {
6279 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6282 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6285 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6288 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6291 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6294 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6299 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" );
6300 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6302 t16.getNode( "ab" ).setCollapse( true );
6303 t16.getNode( "a" ).setCollapse( true );
6304 t16.getNode( "fgh" ).setCollapse( true );
6305 t16.getNode( "gh" ).setCollapse( true );
6306 t16.getNode( "cd" ).setCollapse( true );
6307 t16.getNode( "cde" ).setCollapse( true );
6308 t16.getNode( "d" ).setCollapse( true );
6309 t16.getNode( "x" ).setCollapse( true );
6310 n = t16.getNode( "ab" );
6311 while ( n != null ) {
6313 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6315 if ( ext.size() != 4 ) {
6318 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6321 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6324 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6327 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6331 catch ( final Exception e ) {
6332 e.printStackTrace( System.out );
6338 private static boolean testNexusCharactersParsing() {
6340 final NexusCharactersParser parser = new NexusCharactersParser();
6341 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6343 String[] labels = parser.getCharStateLabels();
6344 if ( labels.length != 7 ) {
6347 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6350 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6353 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6356 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6359 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6362 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6365 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6368 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6370 labels = parser.getCharStateLabels();
6371 if ( labels.length != 7 ) {
6374 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6377 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6380 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6383 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6386 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6389 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6392 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6396 catch ( final Exception e ) {
6397 e.printStackTrace( System.out );
6403 private static boolean testNexusMatrixParsing() {
6405 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6406 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6408 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6409 if ( m.getNumberOfCharacters() != 9 ) {
6412 if ( m.getNumberOfIdentifiers() != 5 ) {
6415 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6418 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6421 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6424 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6427 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6430 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6433 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6436 // if ( labels.length != 7 ) {
6439 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6442 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6445 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6448 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6451 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6454 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6457 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6460 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6462 // labels = parser.getCharStateLabels();
6463 // if ( labels.length != 7 ) {
6466 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6469 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6472 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6475 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6478 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6481 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6484 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6488 catch ( final Exception e ) {
6489 e.printStackTrace( System.out );
6495 private static boolean testNexusTreeParsing() {
6497 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6498 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6499 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6500 if ( phylogenies.length != 1 ) {
6503 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6506 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6510 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6511 if ( phylogenies.length != 1 ) {
6514 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6517 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6521 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6522 if ( phylogenies.length != 1 ) {
6525 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6528 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6531 if ( phylogenies[ 0 ].isRooted() ) {
6535 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6536 if ( phylogenies.length != 18 ) {
6539 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6542 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6545 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6548 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6551 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6554 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6557 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6560 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6563 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6566 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6569 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6572 if ( phylogenies[ 8 ].isRooted() ) {
6575 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6578 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6581 if ( !phylogenies[ 9 ].isRooted() ) {
6584 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6587 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6590 if ( !phylogenies[ 10 ].isRooted() ) {
6593 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6596 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6599 if ( phylogenies[ 11 ].isRooted() ) {
6602 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6605 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6608 if ( !phylogenies[ 12 ].isRooted() ) {
6611 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6614 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6617 if ( !phylogenies[ 13 ].isRooted() ) {
6620 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6623 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6626 if ( !phylogenies[ 14 ].isRooted() ) {
6629 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6632 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6635 if ( phylogenies[ 15 ].isRooted() ) {
6638 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6641 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6644 if ( !phylogenies[ 16 ].isRooted() ) {
6647 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6650 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6653 if ( phylogenies[ 17 ].isRooted() ) {
6656 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6660 catch ( final Exception e ) {
6661 e.printStackTrace( System.out );
6667 private static boolean testNexusTreeParsingIterating() {
6669 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6670 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6671 if ( !p.hasNext() ) {
6674 Phylogeny phy = p.next();
6675 if ( phy == null ) {
6678 if ( phy.getNumberOfExternalNodes() != 25 ) {
6681 if ( !phy.getName().equals( "" ) ) {
6684 if ( p.hasNext() ) {
6688 if ( phy != null ) {
6693 if ( !p.hasNext() ) {
6697 if ( phy == null ) {
6700 if ( phy.getNumberOfExternalNodes() != 25 ) {
6703 if ( !phy.getName().equals( "" ) ) {
6706 if ( p.hasNext() ) {
6710 if ( phy != null ) {
6714 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6715 if ( !p.hasNext() ) {
6719 if ( phy == null ) {
6722 if ( phy.getNumberOfExternalNodes() != 10 ) {
6725 if ( !phy.getName().equals( "name" ) ) {
6728 if ( p.hasNext() ) {
6732 if ( phy != null ) {
6737 if ( !p.hasNext() ) {
6741 if ( phy == null ) {
6744 if ( phy.getNumberOfExternalNodes() != 10 ) {
6747 if ( !phy.getName().equals( "name" ) ) {
6750 if ( p.hasNext() ) {
6754 if ( phy != null ) {
6758 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6759 if ( !p.hasNext() ) {
6763 if ( phy == null ) {
6766 if ( phy.getNumberOfExternalNodes() != 3 ) {
6769 if ( !phy.getName().equals( "" ) ) {
6772 if ( phy.isRooted() ) {
6775 if ( p.hasNext() ) {
6779 if ( phy != null ) {
6784 if ( !p.hasNext() ) {
6788 if ( phy == null ) {
6791 if ( phy.getNumberOfExternalNodes() != 3 ) {
6794 if ( !phy.getName().equals( "" ) ) {
6797 if ( p.hasNext() ) {
6801 if ( phy != null ) {
6805 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6806 if ( !p.hasNext() ) {
6811 if ( phy == null ) {
6814 if ( phy.getNumberOfExternalNodes() != 10 ) {
6817 if ( !phy.getName().equals( "tree 0" ) ) {
6821 if ( !p.hasNext() ) {
6825 if ( phy == null ) {
6828 if ( phy.getNumberOfExternalNodes() != 10 ) {
6831 if ( !phy.getName().equals( "tree 1" ) ) {
6835 if ( !p.hasNext() ) {
6839 if ( phy == null ) {
6842 if ( phy.getNumberOfExternalNodes() != 3 ) {
6843 System.out.println( phy.toString() );
6846 if ( !phy.getName().equals( "" ) ) {
6849 if ( phy.isRooted() ) {
6853 if ( !p.hasNext() ) {
6857 if ( phy == null ) {
6860 if ( phy.getNumberOfExternalNodes() != 4 ) {
6863 if ( !phy.getName().equals( "" ) ) {
6866 if ( !phy.isRooted() ) {
6870 if ( !p.hasNext() ) {
6874 if ( phy == null ) {
6877 if ( phy.getNumberOfExternalNodes() != 5 ) {
6878 System.out.println( phy.getNumberOfExternalNodes() );
6881 if ( !phy.getName().equals( "" ) ) {
6884 if ( !phy.isRooted() ) {
6888 if ( !p.hasNext() ) {
6892 if ( phy == null ) {
6895 if ( phy.getNumberOfExternalNodes() != 3 ) {
6898 if ( !phy.getName().equals( "" ) ) {
6901 if ( phy.isRooted() ) {
6905 if ( !p.hasNext() ) {
6909 if ( phy == null ) {
6912 if ( phy.getNumberOfExternalNodes() != 2 ) {
6915 if ( !phy.getName().equals( "" ) ) {
6918 if ( !phy.isRooted() ) {
6922 if ( !p.hasNext() ) {
6926 if ( phy.getNumberOfExternalNodes() != 3 ) {
6929 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6932 if ( !phy.isRooted() ) {
6936 if ( !p.hasNext() ) {
6940 if ( phy.getNumberOfExternalNodes() != 3 ) {
6943 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6946 if ( !phy.getName().equals( "tree 8" ) ) {
6950 if ( !p.hasNext() ) {
6954 if ( phy.getNumberOfExternalNodes() != 3 ) {
6957 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6960 if ( !phy.getName().equals( "tree 9" ) ) {
6964 if ( !p.hasNext() ) {
6968 if ( phy.getNumberOfExternalNodes() != 3 ) {
6971 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6974 if ( !phy.getName().equals( "tree 10" ) ) {
6977 if ( !phy.isRooted() ) {
6981 if ( !p.hasNext() ) {
6985 if ( phy.getNumberOfExternalNodes() != 3 ) {
6988 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6991 if ( !phy.getName().equals( "tree 11" ) ) {
6994 if ( phy.isRooted() ) {
6998 if ( !p.hasNext() ) {
7002 if ( phy.getNumberOfExternalNodes() != 3 ) {
7005 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7008 if ( !phy.getName().equals( "tree 12" ) ) {
7011 if ( !phy.isRooted() ) {
7015 if ( !p.hasNext() ) {
7019 if ( phy.getNumberOfExternalNodes() != 3 ) {
7022 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7025 if ( !phy.getName().equals( "tree 13" ) ) {
7028 if ( !phy.isRooted() ) {
7032 if ( !p.hasNext() ) {
7036 if ( phy.getNumberOfExternalNodes() != 10 ) {
7037 System.out.println( phy.getNumberOfExternalNodes() );
7042 .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;" ) ) {
7043 System.out.println( phy.toNewHampshire() );
7046 if ( !phy.getName().equals( "tree 14" ) ) {
7049 if ( !phy.isRooted() ) {
7053 if ( !p.hasNext() ) {
7057 if ( phy.getNumberOfExternalNodes() != 10 ) {
7058 System.out.println( phy.getNumberOfExternalNodes() );
7063 .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;" ) ) {
7064 System.out.println( phy.toNewHampshire() );
7067 if ( !phy.getName().equals( "tree 15" ) ) {
7070 if ( phy.isRooted() ) {
7074 if ( !p.hasNext() ) {
7078 if ( phy.getNumberOfExternalNodes() != 10 ) {
7079 System.out.println( phy.getNumberOfExternalNodes() );
7084 .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;" ) ) {
7085 System.out.println( phy.toNewHampshire() );
7088 if ( !phy.getName().equals( "tree 16" ) ) {
7091 if ( !phy.isRooted() ) {
7095 if ( !p.hasNext() ) {
7099 if ( phy.getNumberOfExternalNodes() != 10 ) {
7100 System.out.println( phy.getNumberOfExternalNodes() );
7105 .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;" ) ) {
7106 System.out.println( phy.toNewHampshire() );
7109 if ( !phy.getName().equals( "tree 17" ) ) {
7112 if ( phy.isRooted() ) {
7116 if ( p.hasNext() ) {
7120 if ( phy != null ) {
7125 if ( !p.hasNext() ) {
7129 if ( phy == null ) {
7132 if ( phy.getNumberOfExternalNodes() != 10 ) {
7135 if ( !phy.getName().equals( "tree 0" ) ) {
7139 if ( !p.hasNext() ) {
7143 if ( phy == null ) {
7146 if ( phy.getNumberOfExternalNodes() != 10 ) {
7149 if ( !phy.getName().equals( "tree 1" ) ) {
7153 if ( !p.hasNext() ) {
7157 if ( phy == null ) {
7160 if ( phy.getNumberOfExternalNodes() != 3 ) {
7163 if ( !phy.getName().equals( "" ) ) {
7166 if ( phy.isRooted() ) {
7170 if ( !p.hasNext() ) {
7174 if ( phy == null ) {
7177 if ( phy.getNumberOfExternalNodes() != 4 ) {
7180 if ( !phy.getName().equals( "" ) ) {
7183 if ( !phy.isRooted() ) {
7187 if ( !p.hasNext() ) {
7191 if ( phy == null ) {
7194 if ( phy.getNumberOfExternalNodes() != 5 ) {
7195 System.out.println( phy.getNumberOfExternalNodes() );
7198 if ( !phy.getName().equals( "" ) ) {
7201 if ( !phy.isRooted() ) {
7205 if ( !p.hasNext() ) {
7209 if ( phy == null ) {
7212 if ( phy.getNumberOfExternalNodes() != 3 ) {
7215 if ( !phy.getName().equals( "" ) ) {
7218 if ( phy.isRooted() ) {
7222 catch ( final Exception e ) {
7223 e.printStackTrace( System.out );
7229 private static boolean testNexusTreeParsingTranslating() {
7231 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7232 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7233 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7234 if ( phylogenies.length != 1 ) {
7237 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7240 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7243 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7246 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7249 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7250 .equals( "Aranaeus" ) ) {
7254 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7255 if ( phylogenies.length != 3 ) {
7258 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7261 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7264 if ( phylogenies[ 0 ].isRooted() ) {
7267 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7270 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7273 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7274 .equals( "Aranaeus" ) ) {
7277 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7280 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7283 if ( phylogenies[ 1 ].isRooted() ) {
7286 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7289 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7292 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7293 .equals( "Aranaeus" ) ) {
7296 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7299 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7302 if ( !phylogenies[ 2 ].isRooted() ) {
7305 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7308 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7311 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7312 .equals( "Aranaeus" ) ) {
7316 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7317 if ( phylogenies.length != 3 ) {
7320 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7323 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7326 if ( phylogenies[ 0 ].isRooted() ) {
7329 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7332 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7335 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7336 .equals( "Aranaeus" ) ) {
7339 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7342 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7345 if ( phylogenies[ 1 ].isRooted() ) {
7348 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7351 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7354 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7355 .equals( "Aranaeus" ) ) {
7358 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7361 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7364 if ( !phylogenies[ 2 ].isRooted() ) {
7367 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7370 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7373 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7374 .equals( "Aranaeus" ) ) {
7378 catch ( final Exception e ) {
7379 e.printStackTrace( System.out );
7385 private static boolean testNHParsing() {
7387 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7388 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7389 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7392 final NHXParser nhxp = new NHXParser();
7393 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7394 nhxp.setReplaceUnderscores( true );
7395 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7396 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7399 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7402 final Phylogeny p1b = factory
7403 .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 ",
7404 new NHXParser() )[ 0 ];
7405 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7408 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7411 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7412 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7413 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7414 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7415 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7416 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7417 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7418 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7419 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7420 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7421 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7422 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7423 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7425 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7428 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7431 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7434 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7437 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7438 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7439 final String p16_S = "((A,B),C)";
7440 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7441 if ( p16.length != 1 ) {
7444 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7447 final String p17_S = "(C,(A,B))";
7448 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7449 if ( p17.length != 1 ) {
7452 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7455 final String p18_S = "((A,B),(C,D))";
7456 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7457 if ( p18.length != 1 ) {
7460 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7463 final String p19_S = "(((A,B),C),D)";
7464 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7465 if ( p19.length != 1 ) {
7468 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7471 final String p20_S = "(A,(B,(C,D)))";
7472 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7473 if ( p20.length != 1 ) {
7476 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7479 final String p21_S = "(A,(B,(C,(D,E))))";
7480 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7481 if ( p21.length != 1 ) {
7484 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7487 final String p22_S = "((((A,B),C),D),E)";
7488 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7489 if ( p22.length != 1 ) {
7492 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7495 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7496 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7497 if ( p23.length != 1 ) {
7498 System.out.println( "xl=" + p23.length );
7502 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7505 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7506 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7507 if ( p24.length != 1 ) {
7510 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7513 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7514 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7515 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7516 if ( p241.length != 2 ) {
7519 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7522 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7525 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7526 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7527 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7528 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7529 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7530 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7531 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7532 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7533 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7534 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7537 final String p26_S = "(A,B)ab";
7538 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7539 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7542 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7543 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7544 if ( p27s.length != 1 ) {
7545 System.out.println( "xxl=" + p27s.length );
7549 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7550 System.out.println( p27s[ 0 ].toNewHampshireX() );
7554 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7556 if ( p27.length != 1 ) {
7557 System.out.println( "yl=" + p27.length );
7561 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7562 System.out.println( p27[ 0 ].toNewHampshireX() );
7566 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7567 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7568 final String p28_S3 = "(A,B)ab";
7569 final String p28_S4 = "((((A,B),C),D),;E;)";
7570 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7572 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7575 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7578 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7581 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7584 if ( p28.length != 4 ) {
7587 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";
7588 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7589 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7592 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";
7593 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7594 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7597 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7598 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7599 if ( ( p32.length != 0 ) ) {
7602 final String p33_S = "A";
7603 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7604 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7607 final String p34_S = "B;";
7608 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7609 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7612 final String p35_S = "B:0.2";
7613 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7614 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7617 final String p36_S = "(A)";
7618 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7619 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7622 final String p37_S = "((A))";
7623 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7624 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7627 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7628 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7629 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7632 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7633 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7634 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7637 final String p40_S = "(A,B,C)";
7638 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7639 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7642 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7643 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7644 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7647 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7648 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7649 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7652 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)";
7653 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7654 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7657 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)))";
7658 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7659 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7662 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7663 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7664 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7667 final String p46_S = "";
7668 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7669 if ( p46.length != 0 ) {
7672 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7673 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7676 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7677 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7680 final Phylogeny p49 = factory
7681 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7682 new NHXParser() )[ 0 ];
7683 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7686 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7687 if ( p50.getNode( "A" ) == null ) {
7690 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7691 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7694 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7697 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7698 .equals( "((A,B)88:2.0,C);" ) ) {
7701 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7702 if ( p51.getNode( "A(A" ) == null ) {
7705 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7706 if ( p52.getNode( "A(A" ) == null ) {
7709 final Phylogeny p53 = factory
7710 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7711 new NHXParser() )[ 0 ];
7712 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7716 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7717 if ( p54.getNode( "A" ) == null ) {
7720 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7721 .equals( "((A,B)[88],C);" ) ) {
7725 catch ( final Exception e ) {
7726 e.printStackTrace( System.out );
7732 private static boolean testNHParsingIter() {
7734 final String p0_str = "(A,B);";
7735 final NHXParser p = new NHXParser();
7736 p.setSource( p0_str );
7737 if ( !p.hasNext() ) {
7740 final Phylogeny p0 = p.next();
7741 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7742 System.out.println( p0.toNewHampshire() );
7745 if ( p.hasNext() ) {
7748 if ( p.next() != null ) {
7752 final String p00_str = "(A,B)root;";
7753 p.setSource( p00_str );
7754 final Phylogeny p00 = p.next();
7755 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7756 System.out.println( p00.toNewHampshire() );
7760 final String p000_str = "A;";
7761 p.setSource( p000_str );
7762 final Phylogeny p000 = p.next();
7763 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7764 System.out.println( p000.toNewHampshire() );
7768 final String p0000_str = "A";
7769 p.setSource( p0000_str );
7770 final Phylogeny p0000 = p.next();
7771 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7772 System.out.println( p0000.toNewHampshire() );
7776 p.setSource( "(A)" );
7777 final Phylogeny p00000 = p.next();
7778 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7779 System.out.println( p00000.toNewHampshire() );
7783 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7784 p.setSource( p1_str );
7785 if ( !p.hasNext() ) {
7788 final Phylogeny p1_0 = p.next();
7789 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7790 System.out.println( p1_0.toNewHampshire() );
7793 if ( !p.hasNext() ) {
7796 final Phylogeny p1_1 = p.next();
7797 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7798 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7801 if ( !p.hasNext() ) {
7804 final Phylogeny p1_2 = p.next();
7805 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7806 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7809 if ( !p.hasNext() ) {
7812 final Phylogeny p1_3 = p.next();
7813 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7814 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7817 if ( p.hasNext() ) {
7820 if ( p.next() != null ) {
7824 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7825 p.setSource( p2_str );
7826 if ( !p.hasNext() ) {
7829 Phylogeny p2_0 = p.next();
7830 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7831 System.out.println( p2_0.toNewHampshire() );
7834 if ( !p.hasNext() ) {
7837 Phylogeny p2_1 = p.next();
7838 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7839 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7842 if ( !p.hasNext() ) {
7845 Phylogeny p2_2 = p.next();
7846 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7847 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7850 if ( !p.hasNext() ) {
7853 Phylogeny p2_3 = p.next();
7854 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7855 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7858 if ( !p.hasNext() ) {
7861 Phylogeny p2_4 = p.next();
7862 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7863 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7866 if ( p.hasNext() ) {
7869 if ( p.next() != null ) {
7874 if ( !p.hasNext() ) {
7878 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7879 System.out.println( p2_0.toNewHampshire() );
7882 if ( !p.hasNext() ) {
7886 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7887 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7890 if ( !p.hasNext() ) {
7894 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7895 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7898 if ( !p.hasNext() ) {
7902 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7903 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7906 if ( !p.hasNext() ) {
7910 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7911 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7914 if ( p.hasNext() ) {
7917 if ( p.next() != null ) {
7921 final String p3_str = "((A,B),C)abc";
7922 p.setSource( p3_str );
7923 if ( !p.hasNext() ) {
7926 final Phylogeny p3_0 = p.next();
7927 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7930 if ( p.hasNext() ) {
7933 if ( p.next() != null ) {
7937 final String p4_str = "((A,B)ab,C)abc";
7938 p.setSource( p4_str );
7939 if ( !p.hasNext() ) {
7942 final Phylogeny p4_0 = p.next();
7943 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7946 if ( p.hasNext() ) {
7949 if ( p.next() != null ) {
7953 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7954 p.setSource( p5_str );
7955 if ( !p.hasNext() ) {
7958 final Phylogeny p5_0 = p.next();
7959 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7962 if ( p.hasNext() ) {
7965 if ( p.next() != null ) {
7969 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7970 p.setSource( p6_str );
7971 if ( !p.hasNext() ) {
7974 Phylogeny p6_0 = p.next();
7975 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7978 if ( p.hasNext() ) {
7981 if ( p.next() != null ) {
7985 if ( !p.hasNext() ) {
7989 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7992 if ( p.hasNext() ) {
7995 if ( p.next() != null ) {
7999 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8000 p.setSource( p7_str );
8001 if ( !p.hasNext() ) {
8004 Phylogeny p7_0 = p.next();
8005 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8008 if ( p.hasNext() ) {
8011 if ( p.next() != null ) {
8015 if ( !p.hasNext() ) {
8019 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8022 if ( p.hasNext() ) {
8025 if ( p.next() != null ) {
8029 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8030 p.setSource( p8_str );
8031 if ( !p.hasNext() ) {
8034 Phylogeny p8_0 = p.next();
8035 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8038 if ( !p.hasNext() ) {
8041 if ( !p.hasNext() ) {
8044 Phylogeny p8_1 = p.next();
8045 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8048 if ( p.hasNext() ) {
8051 if ( p.next() != null ) {
8055 if ( !p.hasNext() ) {
8059 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8062 if ( !p.hasNext() ) {
8066 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8069 if ( p.hasNext() ) {
8072 if ( p.next() != null ) {
8078 if ( p.hasNext() ) {
8082 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8083 if ( !p.hasNext() ) {
8086 Phylogeny p_27 = p.next();
8087 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8088 System.out.println( p_27.toNewHampshireX() );
8092 if ( p.hasNext() ) {
8095 if ( p.next() != null ) {
8099 if ( !p.hasNext() ) {
8103 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8104 System.out.println( p_27.toNewHampshireX() );
8108 if ( p.hasNext() ) {
8111 if ( p.next() != null ) {
8115 final String p30_str = "(A,B);(C,D)";
8116 final NHXParser p30 = new NHXParser();
8117 p30.setSource( p30_str );
8118 if ( !p30.hasNext() ) {
8121 Phylogeny phy30 = p30.next();
8122 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8123 System.out.println( phy30.toNewHampshire() );
8126 if ( !p30.hasNext() ) {
8129 Phylogeny phy301 = p30.next();
8130 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8131 System.out.println( phy301.toNewHampshire() );
8134 if ( p30.hasNext() ) {
8137 if ( p30.hasNext() ) {
8140 if ( p30.next() != null ) {
8143 if ( p30.next() != null ) {
8147 if ( !p30.hasNext() ) {
8151 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8152 System.out.println( phy30.toNewHampshire() );
8155 if ( !p30.hasNext() ) {
8158 phy301 = p30.next();
8159 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8160 System.out.println( phy301.toNewHampshire() );
8163 if ( p30.hasNext() ) {
8166 if ( p30.hasNext() ) {
8169 if ( p30.next() != null ) {
8172 if ( p30.next() != null ) {
8176 catch ( final Exception e ) {
8177 e.printStackTrace( System.out );
8183 private static boolean testNHXconversion() {
8185 final PhylogenyNode n1 = new PhylogenyNode();
8186 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8187 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8188 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8189 final PhylogenyNode n5 = PhylogenyNode
8190 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8191 final PhylogenyNode n6 = PhylogenyNode
8192 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8193 if ( !n1.toNewHampshireX().equals( "" ) ) {
8196 if ( !n2.toNewHampshireX().equals( "" ) ) {
8199 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8202 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8205 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8208 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8209 System.out.println( n6.toNewHampshireX() );
8213 catch ( final Exception e ) {
8214 e.printStackTrace( System.out );
8220 private static boolean testNHXNodeParsing() {
8222 final PhylogenyNode n1 = new PhylogenyNode();
8223 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8224 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8225 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8226 final PhylogenyNode n5 = PhylogenyNode
8227 .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]" );
8228 if ( !n3.getName().equals( "n3" ) ) {
8231 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8234 if ( n3.isDuplication() ) {
8237 if ( n3.isHasAssignedEvent() ) {
8240 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8243 if ( !n4.getName().equals( "n4" ) ) {
8246 if ( n4.getDistanceToParent() != 0.01 ) {
8249 if ( !n5.getName().equals( "n5" ) ) {
8252 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8255 if ( n5.getDistanceToParent() != 0.1 ) {
8258 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8261 if ( !n5.isDuplication() ) {
8264 if ( !n5.isHasAssignedEvent() ) {
8267 final PhylogenyNode n8 = PhylogenyNode
8268 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8269 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8270 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8273 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8276 final PhylogenyNode n9 = PhylogenyNode
8277 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8278 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8279 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8282 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8285 final PhylogenyNode n10 = PhylogenyNode
8286 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8287 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8290 final PhylogenyNode n20 = PhylogenyNode
8291 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8292 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8295 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8298 final PhylogenyNode n20x = PhylogenyNode
8299 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8300 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8303 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8306 final PhylogenyNode n20xx = PhylogenyNode
8307 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8308 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8311 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8314 final PhylogenyNode n20xxx = PhylogenyNode
8315 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8316 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8319 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8322 final PhylogenyNode n20xxxx = PhylogenyNode
8323 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8324 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8327 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8330 final PhylogenyNode n21 = PhylogenyNode
8331 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8332 if ( !n21.getName().equals( "N21_PIG" ) ) {
8335 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8338 final PhylogenyNode n21x = PhylogenyNode
8339 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8340 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8343 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8346 final PhylogenyNode n22 = PhylogenyNode
8347 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8348 if ( !n22.getName().equals( "n22/PIG" ) ) {
8351 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8354 final PhylogenyNode n23 = PhylogenyNode
8355 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8356 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8359 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8362 final PhylogenyNode a = PhylogenyNode
8363 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8364 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8367 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8370 final PhylogenyNode c1 = PhylogenyNode
8371 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8372 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8373 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8376 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8379 final PhylogenyNode c2 = PhylogenyNode
8380 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8381 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8382 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8385 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8388 final PhylogenyNode e3 = PhylogenyNode
8389 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8390 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8393 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8396 final PhylogenyNode n11 = PhylogenyNode
8397 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8398 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8399 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8402 if ( n11.getDistanceToParent() != 0.4 ) {
8405 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8408 final PhylogenyNode n12 = PhylogenyNode
8409 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8410 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8411 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8414 if ( n12.getDistanceToParent() != 0.4 ) {
8417 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8420 final PhylogenyNode o = PhylogenyNode
8421 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8422 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8425 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8428 if ( n1.getName().compareTo( "" ) != 0 ) {
8431 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8434 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8437 if ( n2.getName().compareTo( "" ) != 0 ) {
8440 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8443 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8446 final PhylogenyNode n00 = PhylogenyNode
8447 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8448 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8451 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8454 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8455 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8458 final PhylogenyNode n13 = PhylogenyNode
8459 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8460 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
8463 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8466 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8469 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8472 final PhylogenyNode n14 = PhylogenyNode
8473 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8474 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8477 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8480 final PhylogenyNode n15 = PhylogenyNode
8481 .createInstanceFromNhxString( "something_wicked[123]",
8482 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8483 if ( !n15.getName().equals( "something_wicked" ) ) {
8486 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8489 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8492 final PhylogenyNode n16 = PhylogenyNode
8493 .createInstanceFromNhxString( "something_wicked2[9]",
8494 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8495 if ( !n16.getName().equals( "something_wicked2" ) ) {
8498 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8501 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8504 final PhylogenyNode n17 = PhylogenyNode
8505 .createInstanceFromNhxString( "something_wicked3[a]",
8506 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8507 if ( !n17.getName().equals( "something_wicked3" ) ) {
8510 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8513 final PhylogenyNode n18 = PhylogenyNode
8514 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8515 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8518 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8521 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8524 final PhylogenyNode n19 = PhylogenyNode
8525 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8526 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8529 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8532 final PhylogenyNode n30 = PhylogenyNode
8533 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
8534 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8535 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8538 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8541 final PhylogenyNode n31 = PhylogenyNode
8542 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
8543 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8544 if ( n31.getNodeData().isHasTaxonomy() ) {
8547 final PhylogenyNode n32 = PhylogenyNode
8548 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8549 if ( n32.getNodeData().isHasTaxonomy() ) {
8552 final PhylogenyNode n40 = PhylogenyNode
8553 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8554 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8557 final PhylogenyNode n41 = PhylogenyNode
8558 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8559 if ( n41.getNodeData().isHasTaxonomy() ) {
8562 final PhylogenyNode n42 = PhylogenyNode
8563 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8564 if ( n42.getNodeData().isHasTaxonomy() ) {
8567 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8568 NHXParser.TAXONOMY_EXTRACTION.NO );
8569 if ( n43.getNodeData().isHasTaxonomy() ) {
8572 final PhylogenyNode n44 = PhylogenyNode
8573 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8574 if ( n44.getNodeData().isHasTaxonomy() ) {
8578 catch ( final Exception e ) {
8579 e.printStackTrace( System.out );
8585 private static boolean testNHXParsing() {
8587 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8588 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8589 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8592 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]";
8593 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8594 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8597 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]";
8598 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8599 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8602 final Phylogeny[] p3 = factory
8603 .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]",
8605 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8608 final Phylogeny[] p4 = factory
8609 .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(]",
8611 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8614 final Phylogeny[] p5 = factory
8615 .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(((]",
8617 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8620 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)";
8621 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)";
8622 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8623 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8626 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)))";
8627 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)))";
8628 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8629 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8632 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]) ))[,,, ])))))))";
8633 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8634 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8635 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8638 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8639 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8642 final Phylogeny p10 = factory
8643 .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]",
8644 new NHXParser() )[ 0 ];
8645 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8649 catch ( final Exception e ) {
8650 e.printStackTrace( System.out );
8656 private static boolean testNHXParsingMB() {
8658 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8659 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8660 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8661 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8662 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8663 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8664 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8665 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8666 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8667 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8668 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8671 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8674 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8675 0.1100000000000000e+00 ) ) {
8678 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8681 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8684 final Phylogeny p2 = factory
8685 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8686 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8687 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8688 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8689 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8690 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8691 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8692 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8693 + "7.369400000000000e-02}])",
8694 new NHXParser() )[ 0 ];
8695 if ( p2.getNode( "1" ) == null ) {
8698 if ( p2.getNode( "2" ) == null ) {
8702 catch ( final Exception e ) {
8703 e.printStackTrace( System.out );
8710 private static boolean testNHXParsingQuotes() {
8712 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8713 final NHXParser p = new NHXParser();
8714 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8715 if ( phylogenies_0.length != 5 ) {
8718 final Phylogeny phy = phylogenies_0[ 4 ];
8719 if ( phy.getNumberOfExternalNodes() != 7 ) {
8722 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8725 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8728 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8729 .getScientificName().equals( "hsapiens" ) ) {
8732 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8735 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8738 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8741 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8744 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8747 final NHXParser p1p = new NHXParser();
8748 p1p.setIgnoreQuotes( true );
8749 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8750 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8753 final NHXParser p2p = new NHXParser();
8754 p1p.setIgnoreQuotes( false );
8755 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8756 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8759 final NHXParser p3p = new NHXParser();
8760 p3p.setIgnoreQuotes( false );
8761 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8762 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8765 final NHXParser p4p = new NHXParser();
8766 p4p.setIgnoreQuotes( false );
8767 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8768 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8771 final Phylogeny p10 = factory
8772 .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]",
8773 new NHXParser() )[ 0 ];
8774 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]";
8775 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8778 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8779 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8783 final Phylogeny p12 = factory
8784 .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]",
8785 new NHXParser() )[ 0 ];
8786 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]";
8787 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8790 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8791 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8794 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;";
8795 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8798 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8799 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8803 catch ( final Exception e ) {
8804 e.printStackTrace( System.out );
8810 private static boolean testNodeRemoval() {
8812 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8813 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8814 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8815 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8818 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8819 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8820 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8823 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8824 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8825 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8829 catch ( final Exception e ) {
8830 e.printStackTrace( System.out );
8836 private static boolean testPhylogenyBranch() {
8838 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8839 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8840 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8841 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8842 if ( !a1b1.equals( a1b1 ) ) {
8845 if ( !a1b1.equals( b1a1 ) ) {
8848 if ( !b1a1.equals( a1b1 ) ) {
8851 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8852 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8853 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8854 if ( a1_b1.equals( b1_a1 ) ) {
8857 if ( a1_b1.equals( a1_b1_ ) ) {
8860 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8861 if ( !a1_b1.equals( b1_a1_ ) ) {
8864 if ( a1_b1_.equals( b1_a1_ ) ) {
8867 if ( !a1_b1_.equals( b1_a1 ) ) {
8871 catch ( final Exception e ) {
8872 e.printStackTrace( System.out );
8878 private static boolean testPhyloXMLparsingOfDistributionElement() {
8880 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8881 PhyloXmlParser xml_parser = null;
8883 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8885 catch ( final Exception e ) {
8886 // Do nothing -- means were not running from jar.
8888 if ( xml_parser == null ) {
8889 xml_parser = PhyloXmlParser.createPhyloXmlParser();
8890 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8891 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8894 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8897 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8899 if ( xml_parser.getErrorCount() > 0 ) {
8900 System.out.println( xml_parser.getErrorMessages().toString() );
8903 if ( phylogenies_0.length != 1 ) {
8906 final Phylogeny t1 = phylogenies_0[ 0 ];
8907 PhylogenyNode n = null;
8908 Distribution d = null;
8909 n = t1.getNode( "root node" );
8910 if ( !n.getNodeData().isHasDistribution() ) {
8913 if ( n.getNodeData().getDistributions().size() != 1 ) {
8916 d = n.getNodeData().getDistribution();
8917 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8920 if ( d.getPoints().size() != 1 ) {
8923 if ( d.getPolygons() != null ) {
8926 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8929 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8932 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8935 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8938 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8941 n = t1.getNode( "node a" );
8942 if ( !n.getNodeData().isHasDistribution() ) {
8945 if ( n.getNodeData().getDistributions().size() != 2 ) {
8948 d = n.getNodeData().getDistribution( 1 );
8949 if ( !d.getDesc().equals( "San Diego" ) ) {
8952 if ( d.getPoints().size() != 1 ) {
8955 if ( d.getPolygons() != null ) {
8958 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8961 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8964 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8967 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8970 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8973 n = t1.getNode( "node bb" );
8974 if ( !n.getNodeData().isHasDistribution() ) {
8977 if ( n.getNodeData().getDistributions().size() != 1 ) {
8980 d = n.getNodeData().getDistribution( 0 );
8981 if ( d.getPoints().size() != 3 ) {
8984 if ( d.getPolygons().size() != 2 ) {
8987 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8990 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8993 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8996 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8999 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9002 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9005 Polygon p = d.getPolygons().get( 0 );
9006 if ( p.getPoints().size() != 3 ) {
9009 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9012 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9015 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9018 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9021 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9024 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9027 p = d.getPolygons().get( 1 );
9028 if ( p.getPoints().size() != 3 ) {
9031 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9034 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9037 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9041 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9042 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9043 if ( rt.length != 1 ) {
9046 final Phylogeny t1_rt = rt[ 0 ];
9047 n = t1_rt.getNode( "root node" );
9048 if ( !n.getNodeData().isHasDistribution() ) {
9051 if ( n.getNodeData().getDistributions().size() != 1 ) {
9054 d = n.getNodeData().getDistribution();
9055 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9058 if ( d.getPoints().size() != 1 ) {
9061 if ( d.getPolygons() != null ) {
9064 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9067 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9070 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9073 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9076 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9079 n = t1_rt.getNode( "node a" );
9080 if ( !n.getNodeData().isHasDistribution() ) {
9083 if ( n.getNodeData().getDistributions().size() != 2 ) {
9086 d = n.getNodeData().getDistribution( 1 );
9087 if ( !d.getDesc().equals( "San Diego" ) ) {
9090 if ( d.getPoints().size() != 1 ) {
9093 if ( d.getPolygons() != null ) {
9096 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9099 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9102 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9105 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9108 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9111 n = t1_rt.getNode( "node bb" );
9112 if ( !n.getNodeData().isHasDistribution() ) {
9115 if ( n.getNodeData().getDistributions().size() != 1 ) {
9118 d = n.getNodeData().getDistribution( 0 );
9119 if ( d.getPoints().size() != 3 ) {
9122 if ( d.getPolygons().size() != 2 ) {
9125 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9128 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9131 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9134 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9137 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9140 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9143 p = d.getPolygons().get( 0 );
9144 if ( p.getPoints().size() != 3 ) {
9147 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9150 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9153 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9156 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9159 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9162 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9165 p = d.getPolygons().get( 1 );
9166 if ( p.getPoints().size() != 3 ) {
9169 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9172 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9175 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9179 catch ( final Exception e ) {
9180 e.printStackTrace( System.out );
9186 private static boolean testPostOrderIterator() {
9188 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9189 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9190 PhylogenyNodeIterator it0;
9191 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9194 for( it0.reset(); it0.hasNext(); ) {
9197 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9198 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9199 if ( !it.next().getName().equals( "A" ) ) {
9202 if ( !it.next().getName().equals( "B" ) ) {
9205 if ( !it.next().getName().equals( "ab" ) ) {
9208 if ( !it.next().getName().equals( "C" ) ) {
9211 if ( !it.next().getName().equals( "D" ) ) {
9214 if ( !it.next().getName().equals( "cd" ) ) {
9217 if ( !it.next().getName().equals( "abcd" ) ) {
9220 if ( !it.next().getName().equals( "E" ) ) {
9223 if ( !it.next().getName().equals( "F" ) ) {
9226 if ( !it.next().getName().equals( "ef" ) ) {
9229 if ( !it.next().getName().equals( "G" ) ) {
9232 if ( !it.next().getName().equals( "H" ) ) {
9235 if ( !it.next().getName().equals( "gh" ) ) {
9238 if ( !it.next().getName().equals( "efgh" ) ) {
9241 if ( !it.next().getName().equals( "r" ) ) {
9244 if ( it.hasNext() ) {
9248 catch ( final Exception e ) {
9249 e.printStackTrace( System.out );
9255 private static boolean testPreOrderIterator() {
9257 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9258 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9259 PhylogenyNodeIterator it0;
9260 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9263 for( it0.reset(); it0.hasNext(); ) {
9266 PhylogenyNodeIterator it = t0.iteratorPreorder();
9267 if ( !it.next().getName().equals( "r" ) ) {
9270 if ( !it.next().getName().equals( "ab" ) ) {
9273 if ( !it.next().getName().equals( "A" ) ) {
9276 if ( !it.next().getName().equals( "B" ) ) {
9279 if ( !it.next().getName().equals( "cd" ) ) {
9282 if ( !it.next().getName().equals( "C" ) ) {
9285 if ( !it.next().getName().equals( "D" ) ) {
9288 if ( it.hasNext() ) {
9291 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9292 it = t1.iteratorPreorder();
9293 if ( !it.next().getName().equals( "r" ) ) {
9296 if ( !it.next().getName().equals( "abcd" ) ) {
9299 if ( !it.next().getName().equals( "ab" ) ) {
9302 if ( !it.next().getName().equals( "A" ) ) {
9305 if ( !it.next().getName().equals( "B" ) ) {
9308 if ( !it.next().getName().equals( "cd" ) ) {
9311 if ( !it.next().getName().equals( "C" ) ) {
9314 if ( !it.next().getName().equals( "D" ) ) {
9317 if ( !it.next().getName().equals( "efgh" ) ) {
9320 if ( !it.next().getName().equals( "ef" ) ) {
9323 if ( !it.next().getName().equals( "E" ) ) {
9326 if ( !it.next().getName().equals( "F" ) ) {
9329 if ( !it.next().getName().equals( "gh" ) ) {
9332 if ( !it.next().getName().equals( "G" ) ) {
9335 if ( !it.next().getName().equals( "H" ) ) {
9338 if ( it.hasNext() ) {
9342 catch ( final Exception e ) {
9343 e.printStackTrace( System.out );
9349 private static boolean testPropertiesMap() {
9351 final PropertiesMap pm = new PropertiesMap();
9352 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9353 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9354 final Property p2 = new Property( "something:else",
9356 "improbable:research",
9359 pm.addProperty( p0 );
9360 pm.addProperty( p1 );
9361 pm.addProperty( p2 );
9362 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9365 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9368 if ( pm.getProperties().size() != 3 ) {
9371 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9374 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9377 if ( pm.getProperties().size() != 3 ) {
9380 pm.removeProperty( "dimensions:diameter" );
9381 if ( pm.getProperties().size() != 2 ) {
9384 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9387 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9391 catch ( final Exception e ) {
9392 e.printStackTrace( System.out );
9398 private static boolean testProteinId() {
9400 final ProteinId id1 = new ProteinId( "a" );
9401 final ProteinId id2 = new ProteinId( "a" );
9402 final ProteinId id3 = new ProteinId( "A" );
9403 final ProteinId id4 = new ProteinId( "b" );
9404 if ( !id1.equals( id1 ) ) {
9407 if ( id1.getId().equals( "x" ) ) {
9410 if ( id1.getId().equals( null ) ) {
9413 if ( !id1.equals( id2 ) ) {
9416 if ( id1.equals( id3 ) ) {
9419 if ( id1.hashCode() != id1.hashCode() ) {
9422 if ( id1.hashCode() != id2.hashCode() ) {
9425 if ( id1.hashCode() == id3.hashCode() ) {
9428 if ( id1.compareTo( id1 ) != 0 ) {
9431 if ( id1.compareTo( id2 ) != 0 ) {
9434 if ( id1.compareTo( id3 ) != 0 ) {
9437 if ( id1.compareTo( id4 ) >= 0 ) {
9440 if ( id4.compareTo( id1 ) <= 0 ) {
9443 if ( !id4.getId().equals( "b" ) ) {
9446 final ProteinId id5 = new ProteinId( " C " );
9447 if ( !id5.getId().equals( "C" ) ) {
9450 if ( id5.equals( id1 ) ) {
9454 catch ( final Exception e ) {
9455 e.printStackTrace( System.out );
9461 private static boolean testReIdMethods() {
9463 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9464 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9465 final long count = PhylogenyNode.getNodeCount();
9467 if ( p.getNode( "r" ).getId() != count ) {
9470 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9473 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9476 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9479 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9482 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9485 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9488 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9491 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9494 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9497 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9500 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9503 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9506 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9509 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9513 catch ( final Exception e ) {
9514 e.printStackTrace( System.out );
9520 private static boolean testRerooting() {
9522 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9523 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",
9524 new NHXParser() )[ 0 ];
9525 if ( !t1.isRooted() ) {
9528 t1.reRoot( t1.getNode( "D" ) );
9529 t1.reRoot( t1.getNode( "CD" ) );
9530 t1.reRoot( t1.getNode( "A" ) );
9531 t1.reRoot( t1.getNode( "B" ) );
9532 t1.reRoot( t1.getNode( "AB" ) );
9533 t1.reRoot( t1.getNode( "D" ) );
9534 t1.reRoot( t1.getNode( "C" ) );
9535 t1.reRoot( t1.getNode( "CD" ) );
9536 t1.reRoot( t1.getNode( "A" ) );
9537 t1.reRoot( t1.getNode( "B" ) );
9538 t1.reRoot( t1.getNode( "AB" ) );
9539 t1.reRoot( t1.getNode( "D" ) );
9540 t1.reRoot( t1.getNode( "D" ) );
9541 t1.reRoot( t1.getNode( "C" ) );
9542 t1.reRoot( t1.getNode( "A" ) );
9543 t1.reRoot( t1.getNode( "B" ) );
9544 t1.reRoot( t1.getNode( "AB" ) );
9545 t1.reRoot( t1.getNode( "C" ) );
9546 t1.reRoot( t1.getNode( "D" ) );
9547 t1.reRoot( t1.getNode( "CD" ) );
9548 t1.reRoot( t1.getNode( "D" ) );
9549 t1.reRoot( t1.getNode( "A" ) );
9550 t1.reRoot( t1.getNode( "B" ) );
9551 t1.reRoot( t1.getNode( "AB" ) );
9552 t1.reRoot( t1.getNode( "C" ) );
9553 t1.reRoot( t1.getNode( "D" ) );
9554 t1.reRoot( t1.getNode( "CD" ) );
9555 t1.reRoot( t1.getNode( "D" ) );
9556 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9559 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9562 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9565 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9568 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9571 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9574 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",
9575 new NHXParser() )[ 0 ];
9576 t2.reRoot( t2.getNode( "A" ) );
9577 t2.reRoot( t2.getNode( "D" ) );
9578 t2.reRoot( t2.getNode( "ABC" ) );
9579 t2.reRoot( t2.getNode( "A" ) );
9580 t2.reRoot( t2.getNode( "B" ) );
9581 t2.reRoot( t2.getNode( "D" ) );
9582 t2.reRoot( t2.getNode( "C" ) );
9583 t2.reRoot( t2.getNode( "ABC" ) );
9584 t2.reRoot( t2.getNode( "A" ) );
9585 t2.reRoot( t2.getNode( "B" ) );
9586 t2.reRoot( t2.getNode( "AB" ) );
9587 t2.reRoot( t2.getNode( "AB" ) );
9588 t2.reRoot( t2.getNode( "D" ) );
9589 t2.reRoot( t2.getNode( "C" ) );
9590 t2.reRoot( t2.getNode( "B" ) );
9591 t2.reRoot( t2.getNode( "AB" ) );
9592 t2.reRoot( t2.getNode( "D" ) );
9593 t2.reRoot( t2.getNode( "D" ) );
9594 t2.reRoot( t2.getNode( "ABC" ) );
9595 t2.reRoot( t2.getNode( "A" ) );
9596 t2.reRoot( t2.getNode( "B" ) );
9597 t2.reRoot( t2.getNode( "AB" ) );
9598 t2.reRoot( t2.getNode( "D" ) );
9599 t2.reRoot( t2.getNode( "C" ) );
9600 t2.reRoot( t2.getNode( "ABC" ) );
9601 t2.reRoot( t2.getNode( "A" ) );
9602 t2.reRoot( t2.getNode( "B" ) );
9603 t2.reRoot( t2.getNode( "AB" ) );
9604 t2.reRoot( t2.getNode( "D" ) );
9605 t2.reRoot( t2.getNode( "D" ) );
9606 t2.reRoot( t2.getNode( "C" ) );
9607 t2.reRoot( t2.getNode( "A" ) );
9608 t2.reRoot( t2.getNode( "B" ) );
9609 t2.reRoot( t2.getNode( "AB" ) );
9610 t2.reRoot( t2.getNode( "C" ) );
9611 t2.reRoot( t2.getNode( "D" ) );
9612 t2.reRoot( t2.getNode( "ABC" ) );
9613 t2.reRoot( t2.getNode( "D" ) );
9614 t2.reRoot( t2.getNode( "A" ) );
9615 t2.reRoot( t2.getNode( "B" ) );
9616 t2.reRoot( t2.getNode( "AB" ) );
9617 t2.reRoot( t2.getNode( "C" ) );
9618 t2.reRoot( t2.getNode( "D" ) );
9619 t2.reRoot( t2.getNode( "ABC" ) );
9620 t2.reRoot( t2.getNode( "D" ) );
9621 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9624 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9627 t2.reRoot( t2.getNode( "ABC" ) );
9628 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9631 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9634 t2.reRoot( t2.getNode( "AB" ) );
9635 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9638 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9641 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9644 t2.reRoot( t2.getNode( "AB" ) );
9645 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9648 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9651 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9654 t2.reRoot( t2.getNode( "D" ) );
9655 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9658 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9661 t2.reRoot( t2.getNode( "ABC" ) );
9662 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9665 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9668 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9669 new NHXParser() )[ 0 ];
9670 t3.reRoot( t3.getNode( "B" ) );
9671 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9674 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9677 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9680 t3.reRoot( t3.getNode( "B" ) );
9681 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9684 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9687 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9690 t3.reRoot( t3.getRoot() );
9691 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9694 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9697 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9701 catch ( final Exception e ) {
9702 e.printStackTrace( System.out );
9708 private static boolean testSDIse() {
9710 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9711 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9712 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9713 gene1.setRooted( true );
9714 species1.setRooted( true );
9715 final SDI sdi = new SDI( gene1, species1 );
9716 if ( !gene1.getRoot().isDuplication() ) {
9719 final Phylogeny species2 = factory
9720 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9721 new NHXParser() )[ 0 ];
9722 final Phylogeny gene2 = factory
9723 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9724 new NHXParser() )[ 0 ];
9725 species2.setRooted( true );
9726 gene2.setRooted( true );
9727 final SDI sdi2 = new SDI( gene2, species2 );
9728 if ( sdi2.getDuplicationsSum() != 0 ) {
9731 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9734 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9737 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9740 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9743 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9746 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9749 final Phylogeny species3 = factory
9750 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9751 new NHXParser() )[ 0 ];
9752 final Phylogeny gene3 = factory
9753 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9754 new NHXParser() )[ 0 ];
9755 species3.setRooted( true );
9756 gene3.setRooted( true );
9757 final SDI sdi3 = new SDI( gene3, species3 );
9758 if ( sdi3.getDuplicationsSum() != 1 ) {
9761 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9764 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9767 final Phylogeny species4 = factory
9768 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9769 new NHXParser() )[ 0 ];
9770 final Phylogeny gene4 = factory
9771 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9772 new NHXParser() )[ 0 ];
9773 species4.setRooted( true );
9774 gene4.setRooted( true );
9775 final SDI sdi4 = new SDI( gene4, species4 );
9776 if ( sdi4.getDuplicationsSum() != 1 ) {
9779 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9782 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9785 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9788 if ( species4.getNumberOfExternalNodes() != 6 ) {
9791 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9794 final Phylogeny species5 = factory
9795 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9796 new NHXParser() )[ 0 ];
9797 final Phylogeny gene5 = factory
9798 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9799 new NHXParser() )[ 0 ];
9800 species5.setRooted( true );
9801 gene5.setRooted( true );
9802 final SDI sdi5 = new SDI( gene5, species5 );
9803 if ( sdi5.getDuplicationsSum() != 2 ) {
9806 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9809 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9812 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9815 if ( species5.getNumberOfExternalNodes() != 6 ) {
9818 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9821 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9822 // Conjecture for Comparing Molecular Phylogenies"
9823 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9824 final Phylogeny species6 = factory
9825 .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,"
9826 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9827 new NHXParser() )[ 0 ];
9828 final Phylogeny gene6 = factory
9829 .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,"
9830 + "((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,"
9831 + "(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;",
9832 new NHXParser() )[ 0 ];
9833 species6.setRooted( true );
9834 gene6.setRooted( true );
9835 final SDI sdi6 = new SDI( gene6, species6 );
9836 if ( sdi6.getDuplicationsSum() != 3 ) {
9839 if ( !gene6.getNode( "r" ).isDuplication() ) {
9842 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9845 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9848 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9851 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9854 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9857 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9860 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9863 sdi6.computeMappingCostL();
9864 if ( sdi6.computeMappingCostL() != 17 ) {
9867 if ( species6.getNumberOfExternalNodes() != 9 ) {
9870 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9873 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9874 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9875 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9876 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9877 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9878 species7.setRooted( true );
9879 final Phylogeny gene7_1 = Test
9880 .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])" );
9881 gene7_1.setRooted( true );
9882 final SDI sdi7 = new SDI( gene7_1, species7 );
9883 if ( sdi7.getDuplicationsSum() != 0 ) {
9886 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9889 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9892 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9895 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9898 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9901 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9904 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9907 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9910 final Phylogeny gene7_2 = Test
9911 .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])" );
9912 gene7_2.setRooted( true );
9913 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9914 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9917 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9920 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9923 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9926 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9929 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9932 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9935 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9938 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9941 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9945 catch ( final Exception e ) {
9951 private static boolean testSDIunrooted() {
9953 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9954 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9955 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9956 final Iterator<PhylogenyBranch> iter = l.iterator();
9957 PhylogenyBranch br = iter.next();
9958 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9961 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9965 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9968 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9972 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9975 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9979 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9982 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9986 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9989 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9993 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9996 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10000 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10003 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10007 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10010 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10014 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10017 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10021 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10024 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10028 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10031 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10035 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10038 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10042 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10045 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10049 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10052 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10056 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10059 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10062 if ( iter.hasNext() ) {
10065 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10066 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10067 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10069 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10072 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10076 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10079 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10083 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10086 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10089 if ( iter1.hasNext() ) {
10092 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10093 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10094 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10096 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10099 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10103 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10106 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10110 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10113 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10116 if ( iter2.hasNext() ) {
10119 final Phylogeny species0 = factory
10120 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10121 new NHXParser() )[ 0 ];
10122 final Phylogeny gene1 = factory
10123 .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])",
10124 new NHXParser() )[ 0 ];
10125 species0.setRooted( true );
10126 gene1.setRooted( true );
10127 final SDIR sdi_unrooted = new SDIR();
10128 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10129 if ( sdi_unrooted.getCount() != 1 ) {
10132 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10135 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10138 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10141 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10144 final Phylogeny gene2 = factory
10145 .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])",
10146 new NHXParser() )[ 0 ];
10147 gene2.setRooted( true );
10148 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10149 if ( sdi_unrooted.getCount() != 1 ) {
10152 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10155 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10158 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10161 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10164 final Phylogeny species6 = factory
10165 .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,"
10166 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10167 new NHXParser() )[ 0 ];
10168 final Phylogeny gene6 = factory
10169 .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],"
10170 + "(((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],"
10171 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10172 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10173 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10174 new NHXParser() )[ 0 ];
10175 species6.setRooted( true );
10176 gene6.setRooted( true );
10177 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10178 if ( sdi_unrooted.getCount() != 1 ) {
10181 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10184 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10187 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10190 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10193 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10196 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10199 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10202 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10205 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10208 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10211 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10214 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10218 final Phylogeny species7 = factory
10219 .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,"
10220 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10221 new NHXParser() )[ 0 ];
10222 final Phylogeny gene7 = factory
10223 .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],"
10224 + "(((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],"
10225 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10226 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10227 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10228 new NHXParser() )[ 0 ];
10229 species7.setRooted( true );
10230 gene7.setRooted( true );
10231 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10232 if ( sdi_unrooted.getCount() != 1 ) {
10235 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10238 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10241 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10244 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10247 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10250 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10253 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10256 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10259 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10262 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10265 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10268 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10272 final Phylogeny species8 = factory
10273 .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,"
10274 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10275 new NHXParser() )[ 0 ];
10276 final Phylogeny gene8 = factory
10277 .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],"
10278 + "(((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],"
10279 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10280 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10281 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10282 new NHXParser() )[ 0 ];
10283 species8.setRooted( true );
10284 gene8.setRooted( true );
10285 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10286 if ( sdi_unrooted.getCount() != 1 ) {
10289 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10292 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10295 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10298 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10301 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10304 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10307 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10310 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10313 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10316 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10319 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10322 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10327 catch ( final Exception e ) {
10328 e.printStackTrace( System.out );
10334 private static boolean testSequenceDbWsTools1() {
10336 final PhylogenyNode n = new PhylogenyNode();
10337 n.setName( "NP_001025424" );
10338 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10339 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10340 || !acc.getValue().equals( "NP_001025424" ) ) {
10343 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10344 acc = SequenceDbWsTools.obtainSeqAccession( n );
10345 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10346 || !acc.getValue().equals( "NP_001025424" ) ) {
10349 n.setName( "NP_001025424.1" );
10350 acc = SequenceDbWsTools.obtainSeqAccession( n );
10351 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10352 || !acc.getValue().equals( "NP_001025424" ) ) {
10355 n.setName( "NM_001030253" );
10356 acc = SequenceDbWsTools.obtainSeqAccession( n );
10357 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10358 || !acc.getValue().equals( "NM_001030253" ) ) {
10361 n.setName( "BCL2_HUMAN" );
10362 acc = SequenceDbWsTools.obtainSeqAccession( n );
10363 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10364 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10365 System.out.println( acc.toString() );
10368 n.setName( "P10415" );
10369 acc = SequenceDbWsTools.obtainSeqAccession( n );
10370 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10371 || !acc.getValue().equals( "P10415" ) ) {
10372 System.out.println( acc.toString() );
10375 n.setName( " P10415 " );
10376 acc = SequenceDbWsTools.obtainSeqAccession( n );
10377 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10378 || !acc.getValue().equals( "P10415" ) ) {
10379 System.out.println( acc.toString() );
10382 n.setName( "_P10415|" );
10383 acc = SequenceDbWsTools.obtainSeqAccession( n );
10384 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10385 || !acc.getValue().equals( "P10415" ) ) {
10386 System.out.println( acc.toString() );
10389 n.setName( "AY695820" );
10390 acc = SequenceDbWsTools.obtainSeqAccession( n );
10391 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10392 || !acc.getValue().equals( "AY695820" ) ) {
10393 System.out.println( acc.toString() );
10396 n.setName( "_AY695820_" );
10397 acc = SequenceDbWsTools.obtainSeqAccession( n );
10398 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10399 || !acc.getValue().equals( "AY695820" ) ) {
10400 System.out.println( acc.toString() );
10403 n.setName( "AAA59452" );
10404 acc = SequenceDbWsTools.obtainSeqAccession( n );
10405 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10406 || !acc.getValue().equals( "AAA59452" ) ) {
10407 System.out.println( acc.toString() );
10410 n.setName( "_AAA59452_" );
10411 acc = SequenceDbWsTools.obtainSeqAccession( n );
10412 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10413 || !acc.getValue().equals( "AAA59452" ) ) {
10414 System.out.println( acc.toString() );
10417 n.setName( "AAA59452.1" );
10418 acc = SequenceDbWsTools.obtainSeqAccession( n );
10419 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10420 || !acc.getValue().equals( "AAA59452.1" ) ) {
10421 System.out.println( acc.toString() );
10424 n.setName( "_AAA59452.1_" );
10425 acc = SequenceDbWsTools.obtainSeqAccession( n );
10426 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10427 || !acc.getValue().equals( "AAA59452.1" ) ) {
10428 System.out.println( acc.toString() );
10431 n.setName( "GI:94894583" );
10432 acc = SequenceDbWsTools.obtainSeqAccession( n );
10433 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10434 || !acc.getValue().equals( "94894583" ) ) {
10435 System.out.println( acc.toString() );
10438 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10439 acc = SequenceDbWsTools.obtainSeqAccession( n );
10440 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10441 || !acc.getValue().equals( "71845847" ) ) {
10442 System.out.println( acc.toString() );
10445 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10446 acc = SequenceDbWsTools.obtainSeqAccession( n );
10447 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10448 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10449 System.out.println( acc.toString() );
10453 catch ( final Exception e ) {
10459 private static boolean testSequenceDbWsTools2() {
10461 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10462 SequenceDbWsTools.obtainSeqInformation( n1 );
10463 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10466 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10469 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10472 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10475 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10476 SequenceDbWsTools.obtainSeqInformation( n2 );
10477 if ( !n2.getNodeData().getSequence().getName()
10478 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10481 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10484 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10487 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10490 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10491 SequenceDbWsTools.obtainSeqInformation( n3 );
10492 if ( !n3.getNodeData().getSequence().getName()
10493 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10496 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10499 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10502 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10506 catch ( final IOException e ) {
10507 System.out.println();
10508 System.out.println( "the following might be due to absence internet connection:" );
10509 e.printStackTrace( System.out );
10512 catch ( final Exception e ) {
10513 e.printStackTrace();
10519 private static boolean testSequenceIdParsing() {
10521 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10522 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10523 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10524 if ( id != null ) {
10525 System.out.println( "value =" + id.getValue() );
10526 System.out.println( "provider=" + id.getSource() );
10531 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10532 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10533 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10534 if ( id != null ) {
10535 System.out.println( "value =" + id.getValue() );
10536 System.out.println( "provider=" + id.getSource() );
10541 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10542 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10543 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10544 if ( id != null ) {
10545 System.out.println( "value =" + id.getValue() );
10546 System.out.println( "provider=" + id.getSource() );
10551 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10552 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10553 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10554 if ( id != null ) {
10555 System.out.println( "value =" + id.getValue() );
10556 System.out.println( "provider=" + id.getSource() );
10561 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10562 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10563 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10564 if ( id != null ) {
10565 System.out.println( "value =" + id.getValue() );
10566 System.out.println( "provider=" + id.getSource() );
10571 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10572 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10573 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10574 if ( id != null ) {
10575 System.out.println( "value =" + id.getValue() );
10576 System.out.println( "provider=" + id.getSource() );
10581 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10582 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10583 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10584 if ( id != null ) {
10585 System.out.println( "value =" + id.getValue() );
10586 System.out.println( "provider=" + id.getSource() );
10591 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10592 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10593 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10594 if ( id != null ) {
10595 System.out.println( "value =" + id.getValue() );
10596 System.out.println( "provider=" + id.getSource() );
10601 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10602 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10603 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10604 if ( id != null ) {
10605 System.out.println( "value =" + id.getValue() );
10606 System.out.println( "provider=" + id.getSource() );
10611 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10612 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10613 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10614 if ( id != null ) {
10615 System.out.println( "value =" + id.getValue() );
10616 System.out.println( "provider=" + id.getSource() );
10620 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10621 if ( id != null ) {
10622 System.out.println( "value =" + id.getValue() );
10623 System.out.println( "provider=" + id.getSource() );
10627 catch ( final Exception e ) {
10628 e.printStackTrace( System.out );
10634 private static boolean testSequenceWriter() {
10636 final String n = ForesterUtil.LINE_SEPARATOR;
10637 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10640 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10643 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10646 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10649 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10650 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10653 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10654 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10658 catch ( final Exception e ) {
10659 e.printStackTrace();
10665 private static boolean testSpecies() {
10667 final Species s1 = new BasicSpecies( "a" );
10668 final Species s2 = new BasicSpecies( "a" );
10669 final Species s3 = new BasicSpecies( "A" );
10670 final Species s4 = new BasicSpecies( "b" );
10671 if ( !s1.equals( s1 ) ) {
10674 if ( s1.getSpeciesId().equals( "x" ) ) {
10677 if ( s1.getSpeciesId().equals( null ) ) {
10680 if ( !s1.equals( s2 ) ) {
10683 if ( s1.equals( s3 ) ) {
10686 if ( s1.hashCode() != s1.hashCode() ) {
10689 if ( s1.hashCode() != s2.hashCode() ) {
10692 if ( s1.hashCode() == s3.hashCode() ) {
10695 if ( s1.compareTo( s1 ) != 0 ) {
10698 if ( s1.compareTo( s2 ) != 0 ) {
10701 if ( s1.compareTo( s3 ) != 0 ) {
10704 if ( s1.compareTo( s4 ) >= 0 ) {
10707 if ( s4.compareTo( s1 ) <= 0 ) {
10710 if ( !s4.getSpeciesId().equals( "b" ) ) {
10713 final Species s5 = new BasicSpecies( " C " );
10714 if ( !s5.getSpeciesId().equals( "C" ) ) {
10717 if ( s5.equals( s1 ) ) {
10721 catch ( final Exception e ) {
10722 e.printStackTrace( System.out );
10728 private static boolean testSplit() {
10730 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10731 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10732 //Archaeopteryx.createApplication( p0 );
10733 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10734 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10735 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10736 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10737 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10738 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10739 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10740 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10741 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10742 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10743 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
10744 // System.out.println( s0.toString() );
10746 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10749 if ( s0.match( query_nodes ) ) {
10752 query_nodes = new HashSet<PhylogenyNode>();
10753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10760 if ( !s0.match( query_nodes ) ) {
10764 query_nodes = new HashSet<PhylogenyNode>();
10765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10768 if ( !s0.match( query_nodes ) ) {
10772 query_nodes = new HashSet<PhylogenyNode>();
10773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10777 if ( !s0.match( query_nodes ) ) {
10781 query_nodes = new HashSet<PhylogenyNode>();
10782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10785 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10786 if ( !s0.match( query_nodes ) ) {
10790 query_nodes = new HashSet<PhylogenyNode>();
10791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10794 if ( !s0.match( query_nodes ) ) {
10798 query_nodes = new HashSet<PhylogenyNode>();
10799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10800 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10801 if ( !s0.match( query_nodes ) ) {
10805 query_nodes = new HashSet<PhylogenyNode>();
10806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10808 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10809 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10810 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10811 if ( !s0.match( query_nodes ) ) {
10815 query_nodes = new HashSet<PhylogenyNode>();
10816 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10817 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10818 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10819 if ( !s0.match( query_nodes ) ) {
10823 query_nodes = new HashSet<PhylogenyNode>();
10824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10825 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10828 if ( !s0.match( query_nodes ) ) {
10832 query_nodes = new HashSet<PhylogenyNode>();
10833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10835 if ( s0.match( query_nodes ) ) {
10839 query_nodes = new HashSet<PhylogenyNode>();
10840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10844 if ( s0.match( query_nodes ) ) {
10848 query_nodes = new HashSet<PhylogenyNode>();
10849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10851 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10852 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10854 if ( s0.match( query_nodes ) ) {
10858 query_nodes = new HashSet<PhylogenyNode>();
10859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
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( "D" ) );
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( "B" ) );
10876 if ( s0.match( query_nodes ) ) {
10880 query_nodes = new HashSet<PhylogenyNode>();
10881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10883 if ( s0.match( query_nodes ) ) {
10887 query_nodes = new HashSet<PhylogenyNode>();
10888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10890 if ( s0.match( query_nodes ) ) {
10894 query_nodes = new HashSet<PhylogenyNode>();
10895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10897 if ( s0.match( query_nodes ) ) {
10901 query_nodes = new HashSet<PhylogenyNode>();
10902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10904 if ( s0.match( query_nodes ) ) {
10908 query_nodes = new HashSet<PhylogenyNode>();
10909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10912 if ( s0.match( query_nodes ) ) {
10916 query_nodes = new HashSet<PhylogenyNode>();
10917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10920 if ( s0.match( query_nodes ) ) {
10924 query_nodes = new HashSet<PhylogenyNode>();
10925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10928 if ( s0.match( query_nodes ) ) {
10932 query_nodes = new HashSet<PhylogenyNode>();
10933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10935 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10937 if ( s0.match( query_nodes ) ) {
10941 // query_nodes = new HashSet<PhylogenyNode>();
10942 // query_nodes.add( new PhylogenyNode( "X" ) );
10943 // query_nodes.add( new PhylogenyNode( "Y" ) );
10944 // query_nodes.add( new PhylogenyNode( "A" ) );
10945 // query_nodes.add( new PhylogenyNode( "B" ) );
10946 // query_nodes.add( new PhylogenyNode( "C" ) );
10947 // query_nodes.add( new PhylogenyNode( "D" ) );
10948 // query_nodes.add( new PhylogenyNode( "E" ) );
10949 // query_nodes.add( new PhylogenyNode( "F" ) );
10950 // query_nodes.add( new PhylogenyNode( "G" ) );
10951 // if ( !s0.match( query_nodes ) ) {
10954 // query_nodes = new HashSet<PhylogenyNode>();
10955 // query_nodes.add( new PhylogenyNode( "X" ) );
10956 // query_nodes.add( new PhylogenyNode( "Y" ) );
10957 // query_nodes.add( new PhylogenyNode( "A" ) );
10958 // query_nodes.add( new PhylogenyNode( "B" ) );
10959 // query_nodes.add( new PhylogenyNode( "C" ) );
10960 // if ( !s0.match( query_nodes ) ) {
10964 // query_nodes = new HashSet<PhylogenyNode>();
10965 // query_nodes.add( new PhylogenyNode( "X" ) );
10966 // query_nodes.add( new PhylogenyNode( "Y" ) );
10967 // query_nodes.add( new PhylogenyNode( "D" ) );
10968 // query_nodes.add( new PhylogenyNode( "E" ) );
10969 // query_nodes.add( new PhylogenyNode( "F" ) );
10970 // query_nodes.add( new PhylogenyNode( "G" ) );
10971 // if ( !s0.match( query_nodes ) ) {
10975 // query_nodes = new HashSet<PhylogenyNode>();
10976 // query_nodes.add( new PhylogenyNode( "X" ) );
10977 // query_nodes.add( new PhylogenyNode( "Y" ) );
10978 // query_nodes.add( new PhylogenyNode( "A" ) );
10979 // query_nodes.add( new PhylogenyNode( "B" ) );
10980 // query_nodes.add( new PhylogenyNode( "C" ) );
10981 // query_nodes.add( new PhylogenyNode( "D" ) );
10982 // if ( !s0.match( query_nodes ) ) {
10986 // query_nodes = new HashSet<PhylogenyNode>();
10987 // query_nodes.add( new PhylogenyNode( "X" ) );
10988 // query_nodes.add( new PhylogenyNode( "Y" ) );
10989 // query_nodes.add( new PhylogenyNode( "E" ) );
10990 // query_nodes.add( new PhylogenyNode( "F" ) );
10991 // query_nodes.add( new PhylogenyNode( "G" ) );
10992 // if ( !s0.match( query_nodes ) ) {
10996 // query_nodes = new HashSet<PhylogenyNode>();
10997 // query_nodes.add( new PhylogenyNode( "X" ) );
10998 // query_nodes.add( new PhylogenyNode( "Y" ) );
10999 // query_nodes.add( new PhylogenyNode( "F" ) );
11000 // query_nodes.add( new PhylogenyNode( "G" ) );
11001 // if ( !s0.match( query_nodes ) ) {
11005 query_nodes = new HashSet<PhylogenyNode>();
11006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11010 if ( s0.match( query_nodes ) ) {
11014 query_nodes = new HashSet<PhylogenyNode>();
11015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11019 if ( s0.match( query_nodes ) ) {
11022 ///////////////////////////
11024 query_nodes = new HashSet<PhylogenyNode>();
11025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11027 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11029 if ( s0.match( query_nodes ) ) {
11033 query_nodes = new HashSet<PhylogenyNode>();
11034 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
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( "C" ) );
11047 if ( s0.match( query_nodes ) ) {
11051 query_nodes = new HashSet<PhylogenyNode>();
11052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11056 if ( s0.match( query_nodes ) ) {
11060 query_nodes = new HashSet<PhylogenyNode>();
11061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11065 if ( s0.match( query_nodes ) ) {
11069 query_nodes = new HashSet<PhylogenyNode>();
11070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11071 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11073 if ( s0.match( query_nodes ) ) {
11077 query_nodes = new HashSet<PhylogenyNode>();
11078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11079 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11080 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11081 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11082 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11083 if ( s0.match( query_nodes ) ) {
11087 query_nodes = new HashSet<PhylogenyNode>();
11088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11091 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11092 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11093 if ( s0.match( query_nodes ) ) {
11097 query_nodes = new HashSet<PhylogenyNode>();
11098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11099 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11100 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11101 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11102 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11103 if ( s0.match( query_nodes ) ) {
11107 query_nodes = new HashSet<PhylogenyNode>();
11108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11111 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11112 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11113 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11114 if ( s0.match( query_nodes ) ) {
11118 catch ( final Exception e ) {
11119 e.printStackTrace();
11125 private static boolean testSplitStrict() {
11127 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11128 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11129 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11130 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11131 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11132 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11133 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11134 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11135 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11136 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11137 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11138 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11141 if ( s0.match( query_nodes ) ) {
11144 query_nodes = new HashSet<PhylogenyNode>();
11145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11146 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11147 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11152 if ( !s0.match( query_nodes ) ) {
11156 query_nodes = new HashSet<PhylogenyNode>();
11157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11160 if ( !s0.match( query_nodes ) ) {
11164 query_nodes = new HashSet<PhylogenyNode>();
11165 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11169 if ( !s0.match( query_nodes ) ) {
11173 query_nodes = new HashSet<PhylogenyNode>();
11174 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11175 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11178 if ( !s0.match( query_nodes ) ) {
11182 query_nodes = new HashSet<PhylogenyNode>();
11183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11186 if ( !s0.match( query_nodes ) ) {
11190 query_nodes = new HashSet<PhylogenyNode>();
11191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11193 if ( !s0.match( query_nodes ) ) {
11197 query_nodes = new HashSet<PhylogenyNode>();
11198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11199 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11200 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11201 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11202 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11203 if ( !s0.match( query_nodes ) ) {
11207 query_nodes = new HashSet<PhylogenyNode>();
11208 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11209 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11211 if ( !s0.match( query_nodes ) ) {
11215 query_nodes = new HashSet<PhylogenyNode>();
11216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11217 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11220 if ( !s0.match( query_nodes ) ) {
11224 query_nodes = new HashSet<PhylogenyNode>();
11225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11227 if ( s0.match( query_nodes ) ) {
11231 query_nodes = new HashSet<PhylogenyNode>();
11232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11236 if ( s0.match( query_nodes ) ) {
11240 query_nodes = new HashSet<PhylogenyNode>();
11241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11246 if ( s0.match( query_nodes ) ) {
11250 query_nodes = new HashSet<PhylogenyNode>();
11251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
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( "D" ) );
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( "B" ) );
11268 if ( s0.match( query_nodes ) ) {
11272 query_nodes = new HashSet<PhylogenyNode>();
11273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11275 if ( s0.match( query_nodes ) ) {
11279 query_nodes = new HashSet<PhylogenyNode>();
11280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11282 if ( s0.match( query_nodes ) ) {
11286 query_nodes = new HashSet<PhylogenyNode>();
11287 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11289 if ( s0.match( query_nodes ) ) {
11293 query_nodes = new HashSet<PhylogenyNode>();
11294 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11295 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11296 if ( s0.match( query_nodes ) ) {
11300 query_nodes = new HashSet<PhylogenyNode>();
11301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11303 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11304 if ( s0.match( query_nodes ) ) {
11308 query_nodes = new HashSet<PhylogenyNode>();
11309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11312 if ( s0.match( query_nodes ) ) {
11316 query_nodes = new HashSet<PhylogenyNode>();
11317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11320 if ( s0.match( query_nodes ) ) {
11324 query_nodes = new HashSet<PhylogenyNode>();
11325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11329 if ( s0.match( query_nodes ) ) {
11333 catch ( final Exception e ) {
11334 e.printStackTrace();
11340 private static boolean testSubtreeDeletion() {
11342 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11343 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11344 t1.deleteSubtree( t1.getNode( "A" ), false );
11345 if ( t1.getNumberOfExternalNodes() != 5 ) {
11348 t1.toNewHampshireX();
11349 t1.deleteSubtree( t1.getNode( "E" ), false );
11350 if ( t1.getNumberOfExternalNodes() != 4 ) {
11353 t1.toNewHampshireX();
11354 t1.deleteSubtree( t1.getNode( "F" ), false );
11355 if ( t1.getNumberOfExternalNodes() != 3 ) {
11358 t1.toNewHampshireX();
11359 t1.deleteSubtree( t1.getNode( "D" ), false );
11360 t1.toNewHampshireX();
11361 if ( t1.getNumberOfExternalNodes() != 3 ) {
11364 t1.deleteSubtree( t1.getNode( "def" ), false );
11365 t1.toNewHampshireX();
11366 if ( t1.getNumberOfExternalNodes() != 2 ) {
11369 t1.deleteSubtree( t1.getNode( "B" ), false );
11370 t1.toNewHampshireX();
11371 if ( t1.getNumberOfExternalNodes() != 1 ) {
11374 t1.deleteSubtree( t1.getNode( "C" ), false );
11375 t1.toNewHampshireX();
11376 if ( t1.getNumberOfExternalNodes() != 1 ) {
11379 t1.deleteSubtree( t1.getNode( "abc" ), false );
11380 t1.toNewHampshireX();
11381 if ( t1.getNumberOfExternalNodes() != 1 ) {
11384 t1.deleteSubtree( t1.getNode( "r" ), false );
11385 if ( t1.getNumberOfExternalNodes() != 0 ) {
11388 if ( !t1.isEmpty() ) {
11391 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11392 t2.deleteSubtree( t2.getNode( "A" ), false );
11393 t2.toNewHampshireX();
11394 if ( t2.getNumberOfExternalNodes() != 5 ) {
11397 t2.deleteSubtree( t2.getNode( "abc" ), false );
11398 t2.toNewHampshireX();
11399 if ( t2.getNumberOfExternalNodes() != 3 ) {
11402 t2.deleteSubtree( t2.getNode( "def" ), false );
11403 t2.toNewHampshireX();
11404 if ( t2.getNumberOfExternalNodes() != 1 ) {
11408 catch ( final Exception e ) {
11409 e.printStackTrace( System.out );
11415 private static boolean testSupportCount() {
11417 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11418 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11419 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11420 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11421 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11422 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11423 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11425 SupportCount.count( t0_1, phylogenies_1, true, false );
11426 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11427 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11428 + "(((((A,B),C),D),E),((F,G),X))"
11429 + "(((((A,Y),B),C),D),((F,G),E))"
11430 + "(((((A,B),C),D),E),(F,G))"
11431 + "(((((A,B),C),D),E),(F,G))"
11432 + "(((((A,B),C),D),E),(F,G))"
11433 + "(((((A,B),C),D),E),(F,G),Z)"
11434 + "(((((A,B),C),D),E),(F,G))"
11435 + "((((((A,B),C),D),E),F),G)"
11436 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11438 SupportCount.count( t0_2, phylogenies_2, true, false );
11439 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11440 while ( it.hasNext() ) {
11441 final PhylogenyNode n = it.next();
11442 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11446 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11447 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11448 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11449 SupportCount.count( t0_3, phylogenies_3, true, false );
11450 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11451 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11454 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11457 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11460 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11463 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11466 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11469 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11472 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11475 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11478 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11481 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11482 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11483 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11484 SupportCount.count( t0_4, phylogenies_4, true, false );
11485 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11486 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11489 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11492 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11495 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11498 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11501 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11504 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11507 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11510 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11513 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11516 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11517 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11518 double d = SupportCount.compare( b1, a, true, true, true );
11519 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11522 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11523 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11524 d = SupportCount.compare( b2, a, true, true, true );
11525 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11528 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11529 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11530 d = SupportCount.compare( b3, a, true, true, true );
11531 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11534 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11535 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11536 d = SupportCount.compare( b4, a, true, true, false );
11537 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11541 catch ( final Exception e ) {
11542 e.printStackTrace( System.out );
11548 private static boolean testSupportTransfer() {
11550 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11551 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)",
11552 new NHXParser() )[ 0 ];
11553 final Phylogeny p2 = factory
11554 .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 ];
11555 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11558 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11561 support_transfer.moveBranchLengthsToBootstrap( p1 );
11562 support_transfer.transferSupportValues( p1, p2 );
11563 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11566 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11569 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11572 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11575 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11578 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11581 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11584 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11588 catch ( final Exception e ) {
11589 e.printStackTrace( System.out );
11595 private static boolean testTaxonomyExtraction() {
11597 final PhylogenyNode n0 = PhylogenyNode
11598 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11599 if ( n0.getNodeData().isHasTaxonomy() ) {
11602 final PhylogenyNode n1 = PhylogenyNode
11603 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11604 if ( n1.getNodeData().isHasTaxonomy() ) {
11605 System.out.println( n1.toString() );
11608 final PhylogenyNode n2x = PhylogenyNode
11609 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11610 if ( n2x.getNodeData().isHasTaxonomy() ) {
11613 final PhylogenyNode n3 = PhylogenyNode
11614 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11615 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11616 System.out.println( n3.toString() );
11619 final PhylogenyNode n4 = PhylogenyNode
11620 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11621 if ( n4.getNodeData().isHasTaxonomy() ) {
11622 System.out.println( n4.toString() );
11625 final PhylogenyNode n5 = PhylogenyNode
11626 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11627 if ( n5.getNodeData().isHasTaxonomy() ) {
11628 System.out.println( n5.toString() );
11631 final PhylogenyNode n6 = PhylogenyNode
11632 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11633 if ( n6.getNodeData().isHasTaxonomy() ) {
11634 System.out.println( n6.toString() );
11637 final PhylogenyNode n7 = PhylogenyNode
11638 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11639 if ( n7.getNodeData().isHasTaxonomy() ) {
11640 System.out.println( n7.toString() );
11643 final PhylogenyNode n8 = PhylogenyNode
11644 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11645 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11646 System.out.println( n8.toString() );
11649 final PhylogenyNode n9 = PhylogenyNode
11650 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11651 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11652 System.out.println( n9.toString() );
11655 final PhylogenyNode n10x = PhylogenyNode
11656 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11657 if ( n10x.getNodeData().isHasTaxonomy() ) {
11658 System.out.println( n10x.toString() );
11661 final PhylogenyNode n10xx = PhylogenyNode
11662 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11663 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11664 System.out.println( n10xx.toString() );
11667 final PhylogenyNode n10 = PhylogenyNode
11668 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11669 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11670 System.out.println( n10.toString() );
11673 final PhylogenyNode n11 = PhylogenyNode
11674 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11675 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11676 System.out.println( n11.toString() );
11679 final PhylogenyNode n12 = PhylogenyNode
11680 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11681 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11682 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11683 System.out.println( n12.toString() );
11686 final PhylogenyNode n13 = PhylogenyNode
11687 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11688 if ( n13.getNodeData().isHasTaxonomy() ) {
11689 System.out.println( n13.toString() );
11693 catch ( final Exception e ) {
11694 e.printStackTrace( System.out );
11700 private static boolean testTreeCopy() {
11702 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
11703 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
11704 final Phylogeny t1 = t0.copy();
11705 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
11708 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11711 t0.deleteSubtree( t0.getNode( "c" ), true );
11712 t0.deleteSubtree( t0.getNode( "a" ), true );
11713 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
11714 t0.getNode( "b" ).setName( "Bee" );
11715 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
11718 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11721 t0.deleteSubtree( t0.getNode( "e" ), true );
11722 t0.deleteSubtree( t0.getNode( "Bee" ), true );
11723 t0.deleteSubtree( t0.getNode( "d" ), true );
11724 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
11728 catch ( final Exception e ) {
11729 e.printStackTrace();
11735 private static boolean testTreeMethods() {
11737 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11738 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
11739 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
11740 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
11741 System.out.println( t0.toNewHampshireX() );
11744 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
11745 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
11746 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
11749 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
11752 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
11756 catch ( final Exception e ) {
11757 e.printStackTrace( System.out );
11763 private static boolean testUniprotEntryRetrieval() {
11765 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11766 if ( !entry.getAccession().equals( "P12345" ) ) {
11769 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11772 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11775 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11778 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11781 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11785 catch ( final IOException e ) {
11786 System.out.println();
11787 System.out.println( "the following might be due to absence internet connection:" );
11788 e.printStackTrace( System.out );
11791 catch ( final Exception e ) {
11797 private static boolean testUniprotTaxonomySearch() {
11799 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11801 if ( results.size() != 1 ) {
11804 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11807 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11810 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11813 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11816 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11820 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11821 if ( results.size() != 1 ) {
11824 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11827 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11830 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11833 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11836 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11840 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11841 if ( results.size() != 1 ) {
11844 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11847 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11850 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11853 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11856 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11860 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11861 if ( results.size() != 1 ) {
11864 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11867 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11870 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11873 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11876 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11879 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11882 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11885 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11886 .equals( "Nematostella vectensis" ) ) {
11887 System.out.println( results.get( 0 ).getLineage() );
11892 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11893 if ( results.size() != 1 ) {
11896 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11899 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11902 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11905 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11908 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11911 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11912 .equals( "Xenopus tropicalis" ) ) {
11913 System.out.println( results.get( 0 ).getLineage() );
11918 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11919 if ( results.size() != 1 ) {
11922 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11925 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11928 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11931 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11934 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11937 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11938 .equals( "Xenopus tropicalis" ) ) {
11939 System.out.println( results.get( 0 ).getLineage() );
11944 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11945 if ( results.size() != 1 ) {
11948 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11951 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11954 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11957 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11960 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11963 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11964 .equals( "Xenopus tropicalis" ) ) {
11965 System.out.println( results.get( 0 ).getLineage() );
11969 catch ( final IOException e ) {
11970 System.out.println();
11971 System.out.println( "the following might be due to absence internet connection:" );
11972 e.printStackTrace( System.out );
11975 catch ( final Exception e ) {
11981 private static boolean testWabiTxSearch() {
11983 String result = "";
11984 result = TxSearch.searchSimple( "nematostella" );
11985 result = TxSearch.getTxId( "nematostella" );
11986 if ( !result.equals( "45350" ) ) {
11989 result = TxSearch.getTxName( "45350" );
11990 if ( !result.equals( "Nematostella" ) ) {
11993 result = TxSearch.getTxId( "nematostella vectensis" );
11994 if ( !result.equals( "45351" ) ) {
11997 result = TxSearch.getTxName( "45351" );
11998 if ( !result.equals( "Nematostella vectensis" ) ) {
12001 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12002 if ( !result.equals( "536089" ) ) {
12005 result = TxSearch.getTxName( "536089" );
12006 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12009 final List<String> queries = new ArrayList<String>();
12010 queries.add( "Campylobacter coli" );
12011 queries.add( "Escherichia coli" );
12012 queries.add( "Arabidopsis" );
12013 queries.add( "Trichoplax" );
12014 queries.add( "Samanea saman" );
12015 queries.add( "Kluyveromyces marxianus" );
12016 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12017 queries.add( "Bornavirus parrot/PDD/2008" );
12018 final List<RANKS> ranks = new ArrayList<RANKS>();
12019 ranks.add( RANKS.SUPERKINGDOM );
12020 ranks.add( RANKS.KINGDOM );
12021 ranks.add( RANKS.FAMILY );
12022 ranks.add( RANKS.GENUS );
12023 ranks.add( RANKS.TRIBE );
12024 result = TxSearch.searchLineage( queries, ranks );
12025 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12026 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12028 catch ( final Exception e ) {
12029 System.out.println();
12030 System.out.println( "the following might be due to absence internet connection:" );
12031 e.printStackTrace( System.out );