2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
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 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.TreePanelUtil;
45 import org.forester.archaeopteryx.webservices.WebserviceUtil;
46 import org.forester.development.DevelopmentTools;
47 import org.forester.evoinference.TestPhylogenyReconstruction;
48 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
49 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
50 import org.forester.go.TestGo;
51 import org.forester.io.parsers.FastaParser;
52 import org.forester.io.parsers.GeneralMsaParser;
53 import org.forester.io.parsers.HmmscanPerDomainTableParser;
54 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
55 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
56 import org.forester.io.parsers.nexus.NexusCharactersParser;
57 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
58 import org.forester.io.parsers.nhx.NHXParser;
59 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
60 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
61 import org.forester.io.parsers.tol.TolParser;
62 import org.forester.io.parsers.util.ParserUtils;
63 import org.forester.io.writers.PhylogenyWriter;
64 import org.forester.io.writers.SequenceWriter;
65 import org.forester.msa.BasicMsa;
66 import org.forester.msa.DeleteableMsa;
67 import org.forester.msa.Mafft;
68 import org.forester.msa.Msa;
69 import org.forester.msa.Msa.MSA_FORMAT;
70 import org.forester.msa.MsaInferrer;
71 import org.forester.msa.MsaMethods;
72 import org.forester.pccx.TestPccx;
73 import org.forester.phylogeny.Phylogeny;
74 import org.forester.phylogeny.PhylogenyBranch;
75 import org.forester.phylogeny.PhylogenyMethods;
76 import org.forester.phylogeny.PhylogenyNode;
77 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
78 import org.forester.phylogeny.data.Accession;
79 import org.forester.phylogeny.data.Accession.Source;
80 import org.forester.phylogeny.data.BinaryCharacters;
81 import org.forester.phylogeny.data.BranchWidth;
82 import org.forester.phylogeny.data.Confidence;
83 import org.forester.phylogeny.data.Distribution;
84 import org.forester.phylogeny.data.DomainArchitecture;
85 import org.forester.phylogeny.data.Event;
86 import org.forester.phylogeny.data.Identifier;
87 import org.forester.phylogeny.data.PhylogenyData;
88 import org.forester.phylogeny.data.PhylogenyDataUtil;
89 import org.forester.phylogeny.data.Polygon;
90 import org.forester.phylogeny.data.PropertiesMap;
91 import org.forester.phylogeny.data.Property;
92 import org.forester.phylogeny.data.Property.AppliesTo;
93 import org.forester.phylogeny.data.ProteinDomain;
94 import org.forester.phylogeny.data.Taxonomy;
95 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
96 import org.forester.phylogeny.factories.PhylogenyFactory;
97 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
98 import org.forester.protein.BasicDomain;
99 import org.forester.protein.BasicProtein;
100 import org.forester.protein.Domain;
101 import org.forester.protein.Protein;
102 import org.forester.protein.ProteinId;
103 import org.forester.rio.TestRIO;
104 import org.forester.sdi.SDI;
105 import org.forester.sdi.SDIR;
106 import org.forester.sdi.TestGSDI;
107 import org.forester.sequence.BasicSequence;
108 import org.forester.sequence.Sequence;
109 import org.forester.species.BasicSpecies;
110 import org.forester.species.Species;
111 import org.forester.surfacing.TestSurfacing;
112 import org.forester.tools.ConfidenceAssessor;
113 import org.forester.tools.SupportCount;
114 import org.forester.tools.TreeSplitMatrix;
115 import org.forester.util.AsciiHistogram;
116 import org.forester.util.BasicDescriptiveStatistics;
117 import org.forester.util.BasicTable;
118 import org.forester.util.BasicTableParser;
119 import org.forester.util.DescriptiveStatistics;
120 import org.forester.util.ForesterConstants;
121 import org.forester.util.ForesterUtil;
122 import org.forester.util.GeneralTable;
123 import org.forester.util.SequenceAccessionTools;
124 import org.forester.ws.seqdb.SequenceDatabaseEntry;
125 import org.forester.ws.seqdb.SequenceDbWsTools;
126 import org.forester.ws.seqdb.UniProtTaxonomy;
127 import org.forester.ws.wabi.TxSearch;
128 import org.forester.ws.wabi.TxSearch.RANKS;
129 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
130 import org.forester.ws.wabi.TxSearch.TAX_RANK;
132 @SuppressWarnings( "unused")
133 public final class Test {
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
139 + ForesterUtil.getFileSeparator() + "test_data"
140 + ForesterUtil.getFileSeparator();
141 private final static boolean PERFORM_DB_TESTS = false;
142 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
143 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
144 + ForesterConstants.PHYLO_XML_VERSION + "/"
145 + ForesterConstants.PHYLO_XML_XSD;
146 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
147 + ForesterConstants.PHYLO_XML_VERSION + "/"
148 + ForesterConstants.PHYLO_XML_XSD;
149 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
150 private final static double ZERO_DIFF = 1.0E-9;
152 public static boolean isEqual( final double a, final double b ) {
153 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
156 public static void main( final String[] args ) {
157 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
158 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
160 Locale.setDefault( Locale.US );
161 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
164 System.out.print( "[Test if directory with files for testing exists/is readable: " );
165 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
166 System.out.println( "OK.]" );
169 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
170 System.out.println( "Testing aborted." );
173 System.out.print( "[Test if resources directory exists/is readable: " );
174 if ( testDir( PATH_TO_RESOURCES ) ) {
175 System.out.println( "OK.]" );
178 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
179 System.out.println( "Testing aborted." );
182 final long start_time = new Date().getTime();
183 System.out.print( "Basic node methods: " );
184 if ( Test.testBasicNodeMethods() ) {
185 System.out.println( "OK." );
189 System.out.println( "failed." );
192 System.out.print( "Protein id: " );
193 if ( !testProteinId() ) {
194 System.out.println( "failed." );
200 System.out.println( "OK." );
201 System.out.print( "Species: " );
202 if ( !testSpecies() ) {
203 System.out.println( "failed." );
209 System.out.println( "OK." );
210 System.out.print( "Basic domain: " );
211 if ( !testBasicDomain() ) {
212 System.out.println( "failed." );
218 System.out.println( "OK." );
219 System.out.print( "Basic protein: " );
220 if ( !testBasicProtein() ) {
221 System.out.println( "failed." );
227 System.out.println( "OK." );
228 System.out.print( "Sequence writer: " );
229 if ( testSequenceWriter() ) {
230 System.out.println( "OK." );
234 System.out.println( "failed." );
237 System.out.print( "Sequence id parsing: " );
238 if ( testSequenceIdParsing() ) {
239 System.out.println( "OK." );
243 System.out.println( "failed." );
246 System.out.print( "UniProtKB id extraction: " );
247 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
248 System.out.println( "OK." );
252 System.out.println( "failed." );
255 System.out.print( "Sequence DB tools 1: " );
256 if ( testSequenceDbWsTools1() ) {
257 System.out.println( "OK." );
261 System.out.println( "failed." );
264 System.out.print( "Hmmscan output parser: " );
265 if ( testHmmscanOutputParser() ) {
266 System.out.println( "OK." );
270 System.out.println( "failed." );
273 System.out.print( "Overlap removal: " );
274 if ( !org.forester.test.Test.testOverlapRemoval() ) {
275 System.out.println( "failed." );
281 System.out.println( "OK." );
282 System.out.print( "Engulfing overlap removal: " );
283 if ( !Test.testEngulfingOverlapRemoval() ) {
284 System.out.println( "failed." );
290 System.out.println( "OK." );
291 System.out.print( "Taxonomy code extraction: " );
292 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
293 System.out.println( "OK." );
297 System.out.println( "failed." );
300 System.out.print( "SN extraction: " );
301 if ( Test.testExtractSNFromNodeName() ) {
302 System.out.println( "OK." );
306 System.out.println( "failed." );
309 System.out.print( "Taxonomy extraction (general): " );
310 if ( Test.testTaxonomyExtraction() ) {
311 System.out.println( "OK." );
315 System.out.println( "failed." );
318 System.out.print( "Uri for Aptx web sequence accession: " );
319 if ( Test.testCreateUriForSeqWeb() ) {
320 System.out.println( "OK." );
324 System.out.println( "failed." );
327 System.out.print( "Basic node construction and parsing of NHX (node level): " );
328 if ( Test.testNHXNodeParsing() ) {
329 System.out.println( "OK." );
333 System.out.println( "failed." );
336 System.out.print( "NHX parsing iterating: " );
337 if ( Test.testNHParsingIter() ) {
338 System.out.println( "OK." );
342 System.out.println( "failed." );
345 System.out.print( "NH parsing: " );
346 if ( Test.testNHParsing() ) {
347 System.out.println( "OK." );
351 System.out.println( "failed." );
354 System.out.print( "Conversion to NHX (node level): " );
355 if ( Test.testNHXconversion() ) {
356 System.out.println( "OK." );
360 System.out.println( "failed." );
363 System.out.print( "NHX parsing: " );
364 if ( Test.testNHXParsing() ) {
365 System.out.println( "OK." );
369 System.out.println( "failed." );
372 System.out.print( "NHX parsing with quotes: " );
373 if ( Test.testNHXParsingQuotes() ) {
374 System.out.println( "OK." );
378 System.out.println( "failed." );
381 System.out.print( "NHX parsing (MrBayes): " );
382 if ( Test.testNHXParsingMB() ) {
383 System.out.println( "OK." );
387 System.out.println( "failed." );
390 System.out.print( "Nexus characters parsing: " );
391 if ( Test.testNexusCharactersParsing() ) {
392 System.out.println( "OK." );
396 System.out.println( "failed." );
399 System.out.print( "Nexus tree parsing iterating: " );
400 if ( Test.testNexusTreeParsingIterating() ) {
401 System.out.println( "OK." );
405 System.out.println( "failed." );
408 System.out.print( "Nexus tree parsing: " );
409 if ( Test.testNexusTreeParsing() ) {
410 System.out.println( "OK." );
414 System.out.println( "failed." );
417 System.out.print( "Nexus tree parsing (translating): " );
418 if ( Test.testNexusTreeParsingTranslating() ) {
419 System.out.println( "OK." );
423 System.out.println( "failed." );
426 System.out.print( "Nexus matrix parsing: " );
427 if ( Test.testNexusMatrixParsing() ) {
428 System.out.println( "OK." );
432 System.out.println( "failed." );
435 System.out.print( "Basic phyloXML parsing: " );
436 if ( Test.testBasicPhyloXMLparsing() ) {
437 System.out.println( "OK." );
441 System.out.println( "failed." );
444 System.out.print( "Basic phyloXML parsing (validating against schema): " );
445 if ( testBasicPhyloXMLparsingValidating() ) {
446 System.out.println( "OK." );
450 System.out.println( "failed." );
453 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
454 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
455 System.out.println( "OK." );
459 System.out.println( "failed." );
462 System.out.print( "phyloXML Distribution Element: " );
463 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
464 System.out.println( "OK." );
468 System.out.println( "failed." );
471 System.out.print( "Tol XML parsing: " );
472 if ( Test.testBasicTolXMLparsing() ) {
473 System.out.println( "OK." );
477 System.out.println( "failed." );
480 System.out.print( "Copying of node data: " );
481 if ( Test.testCopyOfNodeData() ) {
482 System.out.println( "OK." );
486 System.out.println( "failed." );
489 System.out.print( "Tree copy: " );
490 if ( Test.testTreeCopy() ) {
491 System.out.println( "OK." );
495 System.out.println( "failed." );
498 System.out.print( "Basic tree methods: " );
499 if ( Test.testBasicTreeMethods() ) {
500 System.out.println( "OK." );
504 System.out.println( "failed." );
507 System.out.print( "Tree methods: " );
508 if ( Test.testTreeMethods() ) {
509 System.out.println( "OK." );
513 System.out.println( "failed." );
516 System.out.print( "Postorder Iterator: " );
517 if ( Test.testPostOrderIterator() ) {
518 System.out.println( "OK." );
522 System.out.println( "failed." );
525 System.out.print( "Preorder Iterator: " );
526 if ( Test.testPreOrderIterator() ) {
527 System.out.println( "OK." );
531 System.out.println( "failed." );
534 System.out.print( "Levelorder Iterator: " );
535 if ( Test.testLevelOrderIterator() ) {
536 System.out.println( "OK." );
540 System.out.println( "failed." );
543 System.out.print( "Re-id methods: " );
544 if ( Test.testReIdMethods() ) {
545 System.out.println( "OK." );
549 System.out.println( "failed." );
552 System.out.print( "Methods on last external nodes: " );
553 if ( Test.testLastExternalNodeMethods() ) {
554 System.out.println( "OK." );
558 System.out.println( "failed." );
561 System.out.print( "Methods on external nodes: " );
562 if ( Test.testExternalNodeRelatedMethods() ) {
563 System.out.println( "OK." );
567 System.out.println( "failed." );
570 System.out.print( "Deletion of external nodes: " );
571 if ( Test.testDeletionOfExternalNodes() ) {
572 System.out.println( "OK." );
576 System.out.println( "failed." );
579 System.out.print( "Subtree deletion: " );
580 if ( Test.testSubtreeDeletion() ) {
581 System.out.println( "OK." );
585 System.out.println( "failed." );
588 System.out.print( "Phylogeny branch: " );
589 if ( Test.testPhylogenyBranch() ) {
590 System.out.println( "OK." );
594 System.out.println( "failed." );
597 System.out.print( "Rerooting: " );
598 if ( Test.testRerooting() ) {
599 System.out.println( "OK." );
603 System.out.println( "failed." );
606 System.out.print( "Mipoint rooting: " );
607 if ( Test.testMidpointrooting() ) {
608 System.out.println( "OK." );
612 System.out.println( "failed." );
615 System.out.print( "Node removal: " );
616 if ( Test.testNodeRemoval() ) {
617 System.out.println( "OK." );
621 System.out.println( "failed." );
624 System.out.print( "Support count: " );
625 if ( Test.testSupportCount() ) {
626 System.out.println( "OK." );
630 System.out.println( "failed." );
633 System.out.print( "Support transfer: " );
634 if ( Test.testSupportTransfer() ) {
635 System.out.println( "OK." );
639 System.out.println( "failed." );
642 System.out.print( "Finding of LCA: " );
643 if ( Test.testGetLCA() ) {
644 System.out.println( "OK." );
648 System.out.println( "failed." );
651 System.out.print( "Finding of LCA 2: " );
652 if ( Test.testGetLCA2() ) {
653 System.out.println( "OK." );
657 System.out.println( "failed." );
660 System.out.print( "Calculation of distance between nodes: " );
661 if ( Test.testGetDistance() ) {
662 System.out.println( "OK." );
666 System.out.println( "failed." );
669 System.out.print( "Descriptive statistics: " );
670 if ( Test.testDescriptiveStatistics() ) {
671 System.out.println( "OK." );
675 System.out.println( "failed." );
678 System.out.print( "Data objects and methods: " );
679 if ( Test.testDataObjects() ) {
680 System.out.println( "OK." );
684 System.out.println( "failed." );
687 System.out.print( "Properties map: " );
688 if ( Test.testPropertiesMap() ) {
689 System.out.println( "OK." );
693 System.out.println( "failed." );
696 System.out.print( "SDIse: " );
697 if ( Test.testSDIse() ) {
698 System.out.println( "OK." );
702 System.out.println( "failed." );
705 System.out.print( "SDIunrooted: " );
706 if ( Test.testSDIunrooted() ) {
707 System.out.println( "OK." );
711 System.out.println( "failed." );
714 System.out.print( "GSDI: " );
715 if ( TestGSDI.test() ) {
716 System.out.println( "OK." );
720 System.out.println( "failed." );
723 System.out.print( "RIO: " );
724 if ( TestRIO.test() ) {
725 System.out.println( "OK." );
729 System.out.println( "failed." );
732 System.out.print( "Phylogeny reconstruction:" );
733 System.out.println();
734 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
735 System.out.println( "OK." );
739 System.out.println( "failed." );
742 System.out.print( "Analysis of domain architectures: " );
743 System.out.println();
744 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "GO: " );
753 System.out.println();
754 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "Modeling tools: " );
763 if ( TestPccx.test() ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "Split Matrix strict: " );
772 if ( Test.testSplitStrict() ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "Split Matrix: " );
781 if ( Test.testSplit() ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "Confidence Assessor: " );
790 if ( Test.testConfidenceAssessor() ) {
791 System.out.println( "OK." );
795 System.out.println( "failed." );
798 System.out.print( "Basic table: " );
799 if ( Test.testBasicTable() ) {
800 System.out.println( "OK." );
804 System.out.println( "failed." );
807 System.out.print( "General table: " );
808 if ( Test.testGeneralTable() ) {
809 System.out.println( "OK." );
813 System.out.println( "failed." );
816 System.out.print( "Amino acid sequence: " );
817 if ( Test.testAminoAcidSequence() ) {
818 System.out.println( "OK." );
822 System.out.println( "failed." );
825 System.out.print( "General MSA parser: " );
826 if ( Test.testGeneralMsaParser() ) {
827 System.out.println( "OK." );
831 System.out.println( "failed." );
834 System.out.print( "Fasta parser for msa: " );
835 if ( Test.testFastaParser() ) {
836 System.out.println( "OK." );
840 System.out.println( "failed." );
843 System.out.print( "Creation of balanced phylogeny: " );
844 if ( Test.testCreateBalancedPhylogeny() ) {
845 System.out.println( "OK." );
849 System.out.println( "failed." );
852 System.out.print( "Genbank accessor parsing: " );
853 if ( Test.testGenbankAccessorParsing() ) {
854 System.out.println( "OK." );
858 System.out.println( "failed." );
862 final String os = ForesterUtil.OS_NAME.toLowerCase();
863 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
864 path = "/usr/local/bin/mafft";
866 else if ( os.indexOf( "win" ) >= 0 ) {
867 path = "C:\\Program Files\\mafft-win\\mafft.bat";
871 if ( !MsaInferrer.isInstalled( path ) ) {
872 path = "/usr/bin/mafft";
874 if ( !MsaInferrer.isInstalled( path ) ) {
875 path = "/usr/local/bin/mafft";
878 if ( MsaInferrer.isInstalled( path ) ) {
879 System.out.print( "MAFFT (external program): " );
880 if ( Test.testMafft( path ) ) {
881 System.out.println( "OK." );
885 System.out.println( "failed [will not count towards failed tests]" );
888 System.out.print( "Next nodes with collapsed: " );
889 if ( Test.testNextNodeWithCollapsing() ) {
890 System.out.println( "OK." );
894 System.out.println( "failed." );
897 System.out.print( "Simple MSA quality: " );
898 if ( Test.testMsaQualityMethod() ) {
899 System.out.println( "OK." );
903 System.out.println( "failed." );
906 System.out.print( "Deleteable MSA: " );
907 if ( Test.testDeleteableMsa() ) {
908 System.out.println( "OK." );
912 System.out.println( "failed." );
915 if ( PERFORM_DB_TESTS ) {
916 System.out.print( "Uniprot Entry Retrieval: " );
917 if ( Test.testUniprotEntryRetrieval() ) {
918 System.out.println( "OK." );
922 System.out.println( "failed." );
925 System.out.print( "Ebi Entry Retrieval: " );
926 if ( Test.testEbiEntryRetrieval() ) {
927 System.out.println( "OK." );
931 System.out.println( "failed." );
934 System.out.print( "Sequence DB tools 2: " );
935 if ( testSequenceDbWsTools2() ) {
936 System.out.println( "OK." );
940 System.out.println( "failed." );
944 System.out.print( "Uniprot Taxonomy Search: " );
945 if ( Test.testUniprotTaxonomySearch() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
954 if ( PERFORM_WEB_TREE_ACCESS ) {
955 System.out.print( "NHX parsing from URL: " );
956 if ( Test.testNHXparsingFromURL() ) {
957 System.out.println( "OK." );
961 System.out.println( "failed." );
964 System.out.print( "phyloXML parsing from URL: " );
965 if ( Test.testPhyloXMLparsingFromURL() ) {
966 System.out.println( "OK." );
970 System.out.println( "failed." );
973 System.out.print( "TreeBase acccess: " );
974 if ( Test.testTreeBaseReading() ) {
975 System.out.println( "OK." );
979 System.out.println( "failed." );
983 System.out.print( "ToL access: " );
984 if ( Test.testToLReading() ) {
985 System.out.println( "OK." );
989 System.out.println( "failed." );
993 System.out.print( "TreeFam access: " );
994 if ( Test.testTreeFamReading() ) {
995 System.out.println( "OK." );
999 System.out.println( "failed." );
1004 System.out.print( "Pfam tree access: " );
1005 if ( Test.testPfamTreeReading() ) {
1006 System.out.println( "OK." );
1010 System.out.println( "failed." );
1014 System.out.println();
1015 final Runtime rt = java.lang.Runtime.getRuntime();
1016 final long free_memory = rt.freeMemory() / 1000000;
1017 final long total_memory = rt.totalMemory() / 1000000;
1018 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1019 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1020 System.out.println();
1021 System.out.println( "Successful tests: " + succeeded );
1022 System.out.println( "Failed tests: " + failed );
1023 System.out.println();
1025 System.out.println( "OK." );
1028 System.out.println( "Not OK." );
1032 public static boolean testEngulfingOverlapRemoval() {
1034 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1035 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1036 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1037 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1038 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1039 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1040 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1041 final List<Boolean> covered = new ArrayList<Boolean>();
1042 covered.add( true ); // 0
1043 covered.add( false ); // 1
1044 covered.add( true ); // 2
1045 covered.add( false ); // 3
1046 covered.add( true ); // 4
1047 covered.add( true ); // 5
1048 covered.add( false ); // 6
1049 covered.add( true ); // 7
1050 covered.add( true ); // 8
1051 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1054 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1057 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1060 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1063 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1066 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1069 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1072 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1073 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1074 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1075 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1076 abc.addProteinDomain( a );
1077 abc.addProteinDomain( b );
1078 abc.addProteinDomain( c );
1079 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1080 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1081 if ( abc.getNumberOfProteinDomains() != 3 ) {
1084 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1087 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1090 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1093 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1096 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1097 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1098 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1099 final Protein def = new BasicProtein( "def", "nemve", 0 );
1100 def.addProteinDomain( d );
1101 def.addProteinDomain( e );
1102 def.addProteinDomain( f );
1103 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1104 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1105 if ( def.getNumberOfProteinDomains() != 3 ) {
1108 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1111 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1114 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1117 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1120 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1124 catch ( final Exception e ) {
1125 e.printStackTrace( System.out );
1131 public static final boolean testNHXparsingFromURL() {
1133 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1134 final URL u = new URL( s );
1135 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1136 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1137 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1140 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1141 System.out.println( phys[ 0 ].toNewHampshire() );
1144 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1145 System.out.println( phys[ 1 ].toNewHampshire() );
1148 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1149 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1152 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1153 System.out.println( phys2[ 0 ].toNewHampshire() );
1156 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1157 final NHXParser p = new NHXParser();
1158 final URL u2 = new URL( s );
1160 if ( !p.hasNext() ) {
1163 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1166 if ( !p.hasNext() ) {
1170 if ( !p.hasNext() ) {
1173 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1176 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1180 if ( !p.hasNext() ) {
1183 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1186 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1190 catch ( final Exception e ) {
1191 e.printStackTrace();
1196 public static boolean testOverlapRemoval() {
1198 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1199 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1200 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1201 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1202 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1203 final List<Boolean> covered = new ArrayList<Boolean>();
1204 covered.add( true ); // 0
1205 covered.add( false ); // 1
1206 covered.add( true ); // 2
1207 covered.add( false ); // 3
1208 covered.add( true ); // 4
1209 covered.add( true ); // 5
1210 covered.add( false ); // 6
1211 covered.add( true ); // 7
1212 covered.add( true ); // 8
1213 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1216 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1219 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1222 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1225 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1228 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1229 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1230 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1231 ab.addProteinDomain( a );
1232 ab.addProteinDomain( b );
1233 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1234 if ( ab.getNumberOfProteinDomains() != 2 ) {
1237 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1240 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1243 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1244 if ( ab.getNumberOfProteinDomains() != 2 ) {
1247 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1250 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1251 final Domain d = new BasicDomain( "d",
1258 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1259 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1260 cde.addProteinDomain( c );
1261 cde.addProteinDomain( d );
1262 cde.addProteinDomain( e );
1263 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1264 if ( cde.getNumberOfProteinDomains() != 3 ) {
1267 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1270 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1271 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1272 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1273 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1274 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1275 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1276 fghi.addProteinDomain( f );
1277 fghi.addProteinDomain( g );
1278 fghi.addProteinDomain( h );
1279 fghi.addProteinDomain( i );
1280 fghi.addProteinDomain( i );
1281 fghi.addProteinDomain( i );
1282 fghi.addProteinDomain( i2 );
1283 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1284 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1287 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1290 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1293 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1294 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1297 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1300 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1301 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1302 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1303 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1304 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1305 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1306 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1307 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1308 jklm.addProteinDomain( j );
1309 jklm.addProteinDomain( k );
1310 jklm.addProteinDomain( l );
1311 jklm.addProteinDomain( m );
1312 jklm.addProteinDomain( m0 );
1313 jklm.addProteinDomain( m1 );
1314 jklm.addProteinDomain( m2 );
1315 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1316 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1319 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1322 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1325 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1326 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1329 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1332 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1333 final Protein od = new BasicProtein( "od", "varanus", 0 );
1334 od.addProteinDomain( only );
1335 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1336 if ( od.getNumberOfProteinDomains() != 1 ) {
1339 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1343 catch ( final Exception e ) {
1344 e.printStackTrace( System.out );
1350 public static final boolean testPfamTreeReading() {
1352 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1353 final NHXParser parser = new NHXParser();
1354 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1355 parser.setReplaceUnderscores( false );
1356 parser.setGuessRootedness( true );
1357 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1358 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1359 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1362 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1366 catch ( final Exception e ) {
1367 e.printStackTrace();
1372 public static final boolean testPhyloXMLparsingFromURL() {
1374 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1375 final URL u = new URL( s );
1376 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1377 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1378 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1382 catch ( final Exception e ) {
1383 e.printStackTrace();
1388 public static final boolean testToLReading() {
1390 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1391 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1392 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1393 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1396 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1399 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1402 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1406 catch ( final Exception e ) {
1407 e.printStackTrace();
1412 public static final boolean testTreeBaseReading() {
1414 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1415 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1416 parser.setReplaceUnderscores( true );
1417 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1418 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1419 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1422 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1423 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1424 parser2.setReplaceUnderscores( true );
1425 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1426 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1427 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1431 catch ( final Exception e ) {
1432 e.printStackTrace();
1437 public static final boolean testTreeFamReading() {
1439 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1440 final NHXParser parser = new NHXParser();
1441 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1442 parser.setReplaceUnderscores( false );
1443 parser.setGuessRootedness( true );
1444 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1445 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1446 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1449 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1453 catch ( final Exception e ) {
1454 e.printStackTrace();
1459 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1460 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1464 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1465 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1468 private static boolean testAminoAcidSequence() {
1470 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1471 if ( aa1.getLength() != 13 ) {
1474 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1477 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1480 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1483 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1484 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1487 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1488 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1491 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1492 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1496 catch ( final Exception e ) {
1497 e.printStackTrace();
1503 private static boolean testBasicDomain() {
1505 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1506 if ( !pd.getDomainId().equals( "id" ) ) {
1509 if ( pd.getNumber() != 1 ) {
1512 if ( pd.getTotalCount() != 4 ) {
1515 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1518 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1519 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1520 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1521 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1522 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1523 if ( !a1.equals( a1 ) ) {
1526 if ( !a1.equals( a1_copy ) ) {
1529 if ( !a1.equals( a1_equal ) ) {
1532 if ( !a1.equals( a2 ) ) {
1535 if ( a1.equals( a3 ) ) {
1538 if ( a1.compareTo( a1 ) != 0 ) {
1541 if ( a1.compareTo( a1_copy ) != 0 ) {
1544 if ( a1.compareTo( a1_equal ) != 0 ) {
1547 if ( a1.compareTo( a2 ) != 0 ) {
1550 if ( a1.compareTo( a3 ) == 0 ) {
1554 catch ( final Exception e ) {
1555 e.printStackTrace( System.out );
1561 private static boolean testBasicNodeMethods() {
1563 if ( PhylogenyNode.getNodeCount() != 0 ) {
1566 final PhylogenyNode n1 = new PhylogenyNode();
1567 final PhylogenyNode n2 = PhylogenyNode
1568 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1569 final PhylogenyNode n3 = PhylogenyNode
1570 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1571 final PhylogenyNode n4 = PhylogenyNode
1572 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1573 if ( n1.isHasAssignedEvent() ) {
1576 if ( PhylogenyNode.getNodeCount() != 4 ) {
1579 if ( n3.getIndicator() != 0 ) {
1582 if ( n3.getNumberOfExternalNodes() != 1 ) {
1585 if ( !n3.isExternal() ) {
1588 if ( !n3.isRoot() ) {
1591 if ( !n4.getName().equals( "n4" ) ) {
1595 catch ( final Exception e ) {
1596 e.printStackTrace( System.out );
1602 private static boolean testBasicPhyloXMLparsing() {
1604 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1605 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1606 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1608 if ( xml_parser.getErrorCount() > 0 ) {
1609 System.out.println( xml_parser.getErrorMessages().toString() );
1612 if ( phylogenies_0.length != 4 ) {
1615 final Phylogeny t1 = phylogenies_0[ 0 ];
1616 final Phylogeny t2 = phylogenies_0[ 1 ];
1617 final Phylogeny t3 = phylogenies_0[ 2 ];
1618 final Phylogeny t4 = phylogenies_0[ 3 ];
1619 if ( t1.getNumberOfExternalNodes() != 1 ) {
1622 if ( !t1.isRooted() ) {
1625 if ( t1.isRerootable() ) {
1628 if ( !t1.getType().equals( "gene_tree" ) ) {
1631 if ( t2.getNumberOfExternalNodes() != 2 ) {
1634 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1637 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1640 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1643 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1646 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1649 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1652 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1653 .startsWith( "actgtgggggt" ) ) {
1656 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1657 .startsWith( "ctgtgatgcat" ) ) {
1660 if ( t3.getNumberOfExternalNodes() != 4 ) {
1663 if ( !t1.getName().equals( "t1" ) ) {
1666 if ( !t2.getName().equals( "t2" ) ) {
1669 if ( !t3.getName().equals( "t3" ) ) {
1672 if ( !t4.getName().equals( "t4" ) ) {
1675 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1678 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1681 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1684 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1685 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1688 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1691 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1694 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1697 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1698 .equals( "apoptosis" ) ) {
1701 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1702 .equals( "GO:0006915" ) ) {
1705 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1706 .equals( "UniProtKB" ) ) {
1709 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1710 .equals( "experimental" ) ) {
1713 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1714 .equals( "function" ) ) {
1717 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1718 .getValue() != 1 ) {
1721 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1722 .getType().equals( "ml" ) ) {
1725 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1726 .equals( "apoptosis" ) ) {
1729 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1730 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1733 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1734 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1737 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1738 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1741 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1742 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1745 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1746 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1749 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1750 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1753 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1754 .equals( "GO:0005829" ) ) {
1757 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1758 .equals( "intracellular organelle" ) ) {
1761 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1764 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1765 .equals( "UniProt link" ) ) ) {
1768 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1771 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1772 if ( x.size() != 4 ) {
1776 for( final Accession acc : x ) {
1778 if ( !acc.getSource().equals( "KEGG" ) ) {
1781 if ( !acc.getValue().equals( "hsa:596" ) ) {
1788 catch ( final Exception e ) {
1789 e.printStackTrace( System.out );
1795 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1797 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1798 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1799 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1800 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1803 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1805 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1807 if ( xml_parser.getErrorCount() > 0 ) {
1808 System.out.println( xml_parser.getErrorMessages().toString() );
1811 if ( phylogenies_0.length != 4 ) {
1814 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1815 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1816 if ( phylogenies_t1.length != 1 ) {
1819 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1820 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1823 if ( !t1_rt.isRooted() ) {
1826 if ( t1_rt.isRerootable() ) {
1829 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1832 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1833 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1834 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1835 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1838 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1841 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1844 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1847 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1848 .startsWith( "actgtgggggt" ) ) {
1851 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1852 .startsWith( "ctgtgatgcat" ) ) {
1855 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1856 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1857 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1858 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1859 if ( phylogenies_1.length != 1 ) {
1862 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1863 if ( !t3_rt.getName().equals( "t3" ) ) {
1866 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1869 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1872 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1875 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1878 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1879 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1882 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1885 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1888 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1889 .equals( "UniProtKB" ) ) {
1892 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1893 .equals( "apoptosis" ) ) {
1896 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1897 .equals( "GO:0006915" ) ) {
1900 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1901 .equals( "UniProtKB" ) ) {
1904 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1905 .equals( "experimental" ) ) {
1908 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1909 .equals( "function" ) ) {
1912 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1913 .getValue() != 1 ) {
1916 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1917 .getType().equals( "ml" ) ) {
1920 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1921 .equals( "apoptosis" ) ) {
1924 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1925 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1928 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1929 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1932 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1933 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1936 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1937 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1940 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1941 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1944 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1945 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1948 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1949 .equals( "GO:0005829" ) ) {
1952 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1953 .equals( "intracellular organelle" ) ) {
1956 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1959 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1960 .equals( "UniProt link" ) ) ) {
1963 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1966 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1969 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1970 .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." ) ) ) {
1973 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1976 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1979 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1982 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1985 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1986 .equals( "ncbi" ) ) {
1989 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1992 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1993 .getName().equals( "B" ) ) {
1996 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1997 .getFrom() != 21 ) {
2000 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2003 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2004 .getLength() != 24 ) {
2007 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2008 .getConfidence() != 2144 ) {
2011 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2012 .equals( "pfam" ) ) {
2015 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2018 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2021 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2024 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2027 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2028 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2031 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2034 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2037 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2040 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2043 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2046 if ( taxbb.getSynonyms().size() != 2 ) {
2049 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2052 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2055 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2058 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2061 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2064 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2065 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2068 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2071 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2074 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2077 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2080 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2083 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2086 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2090 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2093 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2094 .equalsIgnoreCase( "435" ) ) {
2097 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2100 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2101 .equalsIgnoreCase( "443.7" ) ) {
2104 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2107 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2110 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2111 .equalsIgnoreCase( "433" ) ) {
2114 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2115 .getCrossReferences();
2116 if ( x.size() != 4 ) {
2120 for( final Accession acc : x ) {
2122 if ( !acc.getSource().equals( "KEGG" ) ) {
2125 if ( !acc.getValue().equals( "hsa:596" ) ) {
2132 catch ( final Exception e ) {
2133 e.printStackTrace( System.out );
2139 private static boolean testBasicPhyloXMLparsingValidating() {
2141 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2142 PhyloXmlParser xml_parser = null;
2144 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2146 catch ( final Exception e ) {
2147 // Do nothing -- means were not running from jar.
2149 if ( xml_parser == null ) {
2150 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2151 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2152 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2155 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2158 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2160 if ( xml_parser.getErrorCount() > 0 ) {
2161 System.out.println( xml_parser.getErrorMessages().toString() );
2164 if ( phylogenies_0.length != 4 ) {
2167 final Phylogeny t1 = phylogenies_0[ 0 ];
2168 final Phylogeny t2 = phylogenies_0[ 1 ];
2169 final Phylogeny t3 = phylogenies_0[ 2 ];
2170 final Phylogeny t4 = phylogenies_0[ 3 ];
2171 if ( !t1.getName().equals( "t1" ) ) {
2174 if ( !t2.getName().equals( "t2" ) ) {
2177 if ( !t3.getName().equals( "t3" ) ) {
2180 if ( !t4.getName().equals( "t4" ) ) {
2183 if ( t1.getNumberOfExternalNodes() != 1 ) {
2186 if ( t2.getNumberOfExternalNodes() != 2 ) {
2189 if ( t3.getNumberOfExternalNodes() != 4 ) {
2192 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2193 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2194 if ( xml_parser.getErrorCount() > 0 ) {
2195 System.out.println( "errors:" );
2196 System.out.println( xml_parser.getErrorMessages().toString() );
2199 if ( phylogenies_1.length != 4 ) {
2202 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2204 if ( xml_parser.getErrorCount() > 0 ) {
2205 System.out.println( "errors:" );
2206 System.out.println( xml_parser.getErrorMessages().toString() );
2209 if ( phylogenies_2.length != 1 ) {
2212 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2215 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2217 if ( xml_parser.getErrorCount() > 0 ) {
2218 System.out.println( xml_parser.getErrorMessages().toString() );
2221 if ( phylogenies_3.length != 2 ) {
2224 final Phylogeny a = phylogenies_3[ 0 ];
2225 if ( !a.getName().equals( "tree 4" ) ) {
2228 if ( a.getNumberOfExternalNodes() != 3 ) {
2231 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2234 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2237 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2239 if ( xml_parser.getErrorCount() > 0 ) {
2240 System.out.println( xml_parser.getErrorMessages().toString() );
2243 if ( phylogenies_4.length != 1 ) {
2246 final Phylogeny s = phylogenies_4[ 0 ];
2247 if ( s.getNumberOfExternalNodes() != 6 ) {
2250 s.getNode( "first" );
2252 s.getNode( "\"<a'b&c'd\">\"" );
2253 s.getNode( "'''\"" );
2254 s.getNode( "\"\"\"" );
2255 s.getNode( "dick & doof" );
2257 catch ( final Exception e ) {
2258 e.printStackTrace( System.out );
2264 private static boolean testBasicProtein() {
2266 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2267 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2268 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2269 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2270 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2271 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2272 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2273 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2274 p0.addProteinDomain( y );
2275 p0.addProteinDomain( e );
2276 p0.addProteinDomain( b );
2277 p0.addProteinDomain( c );
2278 p0.addProteinDomain( d );
2279 p0.addProteinDomain( a );
2280 p0.addProteinDomain( x );
2281 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2284 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2288 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2289 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2290 aa0.addProteinDomain( a1 );
2291 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2294 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2298 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2299 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2300 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2301 aa1.addProteinDomain( a11 );
2302 aa1.addProteinDomain( a12 );
2303 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2306 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2309 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2310 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2313 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2316 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2319 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2320 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2323 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2326 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2329 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2332 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2333 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2336 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2339 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2342 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2345 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2346 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2349 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2352 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2355 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2359 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2360 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2361 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2368 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2369 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2370 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2371 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2372 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2373 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2374 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2376 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2377 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2378 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2379 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2380 p00.addProteinDomain( y0 );
2381 p00.addProteinDomain( e0 );
2382 p00.addProteinDomain( b0 );
2383 p00.addProteinDomain( c0 );
2384 p00.addProteinDomain( d0 );
2385 p00.addProteinDomain( a0 );
2386 p00.addProteinDomain( x0 );
2387 p00.addProteinDomain( y1 );
2388 p00.addProteinDomain( y2 );
2389 p00.addProteinDomain( y3 );
2390 p00.addProteinDomain( e1 );
2391 p00.addProteinDomain( e2 );
2392 p00.addProteinDomain( e3 );
2393 p00.addProteinDomain( e4 );
2394 p00.addProteinDomain( e5 );
2395 p00.addProteinDomain( z0 );
2396 p00.addProteinDomain( z1 );
2397 p00.addProteinDomain( z2 );
2398 p00.addProteinDomain( zz0 );
2399 p00.addProteinDomain( zz1 );
2400 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2403 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2406 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2409 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2412 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" ) ) {
2415 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2416 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2417 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2418 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2419 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2420 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2421 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2422 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2423 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2424 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2425 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2426 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2427 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2428 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2429 p.addProteinDomain( B15 );
2430 p.addProteinDomain( C50 );
2431 p.addProteinDomain( A60 );
2432 p.addProteinDomain( A30 );
2433 p.addProteinDomain( C70 );
2434 p.addProteinDomain( B35 );
2435 p.addProteinDomain( B40 );
2436 p.addProteinDomain( A0 );
2437 p.addProteinDomain( A10 );
2438 p.addProteinDomain( A20 );
2439 p.addProteinDomain( B25 );
2440 p.addProteinDomain( D80 );
2441 List<String> domains_ids = new ArrayList<String>();
2442 domains_ids.add( "A" );
2443 domains_ids.add( "B" );
2444 domains_ids.add( "C" );
2445 if ( !p.contains( domains_ids, false ) ) {
2448 if ( !p.contains( domains_ids, true ) ) {
2451 domains_ids.add( "X" );
2452 if ( p.contains( domains_ids, false ) ) {
2455 if ( p.contains( domains_ids, true ) ) {
2458 domains_ids = new ArrayList<String>();
2459 domains_ids.add( "A" );
2460 domains_ids.add( "C" );
2461 domains_ids.add( "D" );
2462 if ( !p.contains( domains_ids, false ) ) {
2465 if ( !p.contains( domains_ids, true ) ) {
2468 domains_ids = new ArrayList<String>();
2469 domains_ids.add( "A" );
2470 domains_ids.add( "D" );
2471 domains_ids.add( "C" );
2472 if ( !p.contains( domains_ids, false ) ) {
2475 if ( p.contains( domains_ids, true ) ) {
2478 domains_ids = new ArrayList<String>();
2479 domains_ids.add( "A" );
2480 domains_ids.add( "A" );
2481 domains_ids.add( "B" );
2482 if ( !p.contains( domains_ids, false ) ) {
2485 if ( !p.contains( domains_ids, true ) ) {
2488 domains_ids = new ArrayList<String>();
2489 domains_ids.add( "A" );
2490 domains_ids.add( "A" );
2491 domains_ids.add( "A" );
2492 domains_ids.add( "B" );
2493 domains_ids.add( "B" );
2494 if ( !p.contains( domains_ids, false ) ) {
2497 if ( !p.contains( domains_ids, true ) ) {
2500 domains_ids = new ArrayList<String>();
2501 domains_ids.add( "A" );
2502 domains_ids.add( "A" );
2503 domains_ids.add( "B" );
2504 domains_ids.add( "A" );
2505 domains_ids.add( "B" );
2506 domains_ids.add( "B" );
2507 domains_ids.add( "A" );
2508 domains_ids.add( "B" );
2509 domains_ids.add( "C" );
2510 domains_ids.add( "A" );
2511 domains_ids.add( "C" );
2512 domains_ids.add( "D" );
2513 if ( !p.contains( domains_ids, false ) ) {
2516 if ( p.contains( domains_ids, true ) ) {
2520 catch ( final Exception e ) {
2521 e.printStackTrace( System.out );
2527 private static boolean testBasicTable() {
2529 final BasicTable<String> t0 = new BasicTable<String>();
2530 if ( t0.getNumberOfColumns() != 0 ) {
2533 if ( t0.getNumberOfRows() != 0 ) {
2536 t0.setValue( 3, 2, "23" );
2537 t0.setValue( 10, 1, "error" );
2538 t0.setValue( 10, 1, "110" );
2539 t0.setValue( 9, 1, "19" );
2540 t0.setValue( 1, 10, "101" );
2541 t0.setValue( 10, 10, "1010" );
2542 t0.setValue( 100, 10, "10100" );
2543 t0.setValue( 0, 0, "00" );
2544 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2547 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2550 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2553 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2556 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2559 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2562 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2565 if ( t0.getNumberOfColumns() != 101 ) {
2568 if ( t0.getNumberOfRows() != 11 ) {
2571 if ( t0.getValueAsString( 49, 4 ) != null ) {
2574 final String l = ForesterUtil.getLineSeparator();
2575 final StringBuffer source = new StringBuffer();
2576 source.append( "" + l );
2577 source.append( "# 1 1 1 1 1 1 1 1" + l );
2578 source.append( " 00 01 02 03" + l );
2579 source.append( " 10 11 12 13 " + l );
2580 source.append( "20 21 22 23 " + l );
2581 source.append( " 30 31 32 33" + l );
2582 source.append( "40 41 42 43" + l );
2583 source.append( " # 1 1 1 1 1 " + l );
2584 source.append( "50 51 52 53 54" + l );
2585 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2586 if ( t1.getNumberOfColumns() != 5 ) {
2589 if ( t1.getNumberOfRows() != 6 ) {
2592 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2595 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2598 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2601 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2604 final StringBuffer source1 = new StringBuffer();
2605 source1.append( "" + l );
2606 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2607 source1.append( " 00; 01 ;02;03" + l );
2608 source1.append( " 10; 11; 12; 13 " + l );
2609 source1.append( "20; 21; 22; 23 " + l );
2610 source1.append( " 30; 31; 32; 33" + l );
2611 source1.append( "40;41;42;43" + l );
2612 source1.append( " # 1 1 1 1 1 " + l );
2613 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2614 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2615 if ( t2.getNumberOfColumns() != 5 ) {
2618 if ( t2.getNumberOfRows() != 6 ) {
2621 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2624 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2627 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2630 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2633 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2636 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2639 final StringBuffer source2 = new StringBuffer();
2640 source2.append( "" + l );
2641 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2642 source2.append( " 00; 01 ;02;03" + l );
2643 source2.append( " 10; 11; 12; 13 " + l );
2644 source2.append( "20; 21; 22; 23 " + l );
2645 source2.append( " " + l );
2646 source2.append( " 30; 31; 32; 33" + l );
2647 source2.append( "40;41;42;43" + l );
2648 source2.append( " comment: 1 1 1 1 1 " + l );
2649 source2.append( ";;;50 ; 52; 53;;54 " + l );
2650 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2656 if ( tl.size() != 2 ) {
2659 final BasicTable<String> t3 = tl.get( 0 );
2660 final BasicTable<String> t4 = tl.get( 1 );
2661 if ( t3.getNumberOfColumns() != 4 ) {
2664 if ( t3.getNumberOfRows() != 3 ) {
2667 if ( t4.getNumberOfColumns() != 4 ) {
2670 if ( t4.getNumberOfRows() != 3 ) {
2673 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2676 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2680 catch ( final Exception e ) {
2681 e.printStackTrace( System.out );
2687 private static boolean testBasicTolXMLparsing() {
2689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2690 final TolParser parser = new TolParser();
2691 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2692 if ( parser.getErrorCount() > 0 ) {
2693 System.out.println( parser.getErrorMessages().toString() );
2696 if ( phylogenies_0.length != 1 ) {
2699 final Phylogeny t1 = phylogenies_0[ 0 ];
2700 if ( t1.getNumberOfExternalNodes() != 5 ) {
2703 if ( !t1.isRooted() ) {
2706 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2709 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2712 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2715 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2718 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2719 if ( parser.getErrorCount() > 0 ) {
2720 System.out.println( parser.getErrorMessages().toString() );
2723 if ( phylogenies_1.length != 1 ) {
2726 final Phylogeny t2 = phylogenies_1[ 0 ];
2727 if ( t2.getNumberOfExternalNodes() != 664 ) {
2730 if ( !t2.isRooted() ) {
2733 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2736 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2739 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2742 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2745 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2748 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2749 .equals( "Aquifex" ) ) {
2752 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2753 if ( parser.getErrorCount() > 0 ) {
2754 System.out.println( parser.getErrorMessages().toString() );
2757 if ( phylogenies_2.length != 1 ) {
2760 final Phylogeny t3 = phylogenies_2[ 0 ];
2761 if ( t3.getNumberOfExternalNodes() != 184 ) {
2764 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2767 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2770 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2773 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2774 if ( parser.getErrorCount() > 0 ) {
2775 System.out.println( parser.getErrorMessages().toString() );
2778 if ( phylogenies_3.length != 1 ) {
2781 final Phylogeny t4 = phylogenies_3[ 0 ];
2782 if ( t4.getNumberOfExternalNodes() != 1 ) {
2785 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2788 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2791 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2794 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2795 if ( parser.getErrorCount() > 0 ) {
2796 System.out.println( parser.getErrorMessages().toString() );
2799 if ( phylogenies_4.length != 1 ) {
2802 final Phylogeny t5 = phylogenies_4[ 0 ];
2803 if ( t5.getNumberOfExternalNodes() != 13 ) {
2806 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2809 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2812 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2816 catch ( final Exception e ) {
2817 e.printStackTrace( System.out );
2823 private static boolean testBasicTreeMethods() {
2825 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2826 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2827 if ( t2.getNumberOfExternalNodes() != 4 ) {
2830 if ( t2.getHeight() != 8.5 ) {
2833 if ( !t2.isCompletelyBinary() ) {
2836 if ( t2.isEmpty() ) {
2839 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2840 if ( t3.getNumberOfExternalNodes() != 5 ) {
2843 if ( t3.getHeight() != 11 ) {
2846 if ( t3.isCompletelyBinary() ) {
2849 final PhylogenyNode n = t3.getNode( "ABC" );
2850 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 ];
2851 if ( t4.getNumberOfExternalNodes() != 9 ) {
2854 if ( t4.getHeight() != 11 ) {
2857 if ( t4.isCompletelyBinary() ) {
2860 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)" );
2861 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2862 if ( t5.getNumberOfExternalNodes() != 8 ) {
2865 if ( t5.getHeight() != 15 ) {
2868 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)" );
2869 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2870 if ( t6.getHeight() != 15 ) {
2873 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)" );
2874 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2875 if ( t7.getHeight() != 15 ) {
2878 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)" );
2879 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2880 if ( t8.getNumberOfExternalNodes() != 10 ) {
2883 if ( t8.getHeight() != 15 ) {
2886 final char[] a9 = new char[] { 'a' };
2887 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2888 if ( t9.getHeight() != 0 ) {
2891 final char[] a10 = new char[] { 'a', ':', '6' };
2892 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2893 if ( t10.getHeight() != 6 ) {
2897 catch ( final Exception e ) {
2898 e.printStackTrace( System.out );
2904 private static boolean testConfidenceAssessor() {
2906 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2907 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2908 final Phylogeny[] ev0 = factory
2909 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2911 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2912 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2915 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2918 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2919 final Phylogeny[] ev1 = factory
2920 .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)));",
2922 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2923 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2926 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2929 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2930 final Phylogeny[] ev_b = factory
2931 .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",
2933 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2934 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2937 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2941 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2942 final Phylogeny[] ev1x = factory
2943 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
2945 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2946 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2949 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2952 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2953 final Phylogeny[] ev_bx = factory
2954 .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",
2956 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2957 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2960 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2964 final Phylogeny[] t2 = factory
2965 .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);",
2967 final Phylogeny[] ev2 = factory
2968 .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);",
2970 for( final Phylogeny target : t2 ) {
2971 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2974 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2975 new NHXParser() )[ 0 ];
2976 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2977 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2978 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2981 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2984 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2988 catch ( final Exception e ) {
2989 e.printStackTrace();
2995 private static boolean testCopyOfNodeData() {
2997 final PhylogenyNode n1 = PhylogenyNode
2998 .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]" );
2999 final PhylogenyNode n2 = n1.copyNodeData();
3000 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3004 catch ( final Exception e ) {
3005 e.printStackTrace();
3011 private static boolean testCreateBalancedPhylogeny() {
3013 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3014 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3017 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3020 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3021 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3024 if ( p1.getNumberOfExternalNodes() != 100 ) {
3028 catch ( final Exception e ) {
3029 e.printStackTrace();
3035 private static boolean testCreateUriForSeqWeb() {
3037 final PhylogenyNode n = new PhylogenyNode();
3038 n.setName( "tr|B3RJ64" );
3039 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3042 n.setName( "B0LM41_HUMAN" );
3043 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3046 n.setName( "NP_001025424" );
3047 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3050 n.setName( "_NM_001030253-" );
3051 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3054 n.setName( "XM_002122186" );
3055 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3058 n.setName( "dgh_AAA34956_gdg" );
3059 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3062 n.setName( "AAA34956" );
3063 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3066 n.setName( "GI:394892" );
3067 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3068 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3071 n.setName( "gi_394892" );
3072 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3073 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3076 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3077 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3078 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3081 n.setName( "P12345" );
3082 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3083 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3086 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3087 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3088 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3092 catch ( final Exception e ) {
3093 e.printStackTrace( System.out );
3099 private static boolean testDataObjects() {
3101 final Confidence s0 = new Confidence();
3102 final Confidence s1 = new Confidence();
3103 if ( !s0.isEqual( s1 ) ) {
3106 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3107 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3108 if ( s2.isEqual( s1 ) ) {
3111 if ( !s2.isEqual( s3 ) ) {
3114 final Confidence s4 = ( Confidence ) s3.copy();
3115 if ( !s4.isEqual( s3 ) ) {
3122 final Taxonomy t1 = new Taxonomy();
3123 final Taxonomy t2 = new Taxonomy();
3124 final Taxonomy t3 = new Taxonomy();
3125 final Taxonomy t4 = new Taxonomy();
3126 final Taxonomy t5 = new Taxonomy();
3127 t1.setIdentifier( new Identifier( "ecoli" ) );
3128 t1.setTaxonomyCode( "ECOLI" );
3129 t1.setScientificName( "E. coli" );
3130 t1.setCommonName( "coli" );
3131 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3132 if ( !t1.isEqual( t0 ) ) {
3135 t2.setIdentifier( new Identifier( "ecoli" ) );
3136 t2.setTaxonomyCode( "OTHER" );
3137 t2.setScientificName( "what" );
3138 t2.setCommonName( "something" );
3139 if ( !t1.isEqual( t2 ) ) {
3142 t2.setIdentifier( new Identifier( "nemve" ) );
3143 if ( t1.isEqual( t2 ) ) {
3146 t1.setIdentifier( null );
3147 t3.setTaxonomyCode( "ECOLI" );
3148 t3.setScientificName( "what" );
3149 t3.setCommonName( "something" );
3150 if ( !t1.isEqual( t3 ) ) {
3153 t1.setIdentifier( null );
3154 t1.setTaxonomyCode( "" );
3155 t4.setScientificName( "E. ColI" );
3156 t4.setCommonName( "something" );
3157 if ( !t1.isEqual( t4 ) ) {
3160 t4.setScientificName( "B. subtilis" );
3161 t4.setCommonName( "something" );
3162 if ( t1.isEqual( t4 ) ) {
3165 t1.setIdentifier( null );
3166 t1.setTaxonomyCode( "" );
3167 t1.setScientificName( "" );
3168 t5.setCommonName( "COLI" );
3169 if ( !t1.isEqual( t5 ) ) {
3172 t5.setCommonName( "vibrio" );
3173 if ( t1.isEqual( t5 ) ) {
3178 final Identifier id0 = new Identifier( "123", "pfam" );
3179 final Identifier id1 = ( Identifier ) id0.copy();
3180 if ( !id1.isEqual( id1 ) ) {
3183 if ( !id1.isEqual( id0 ) ) {
3186 if ( !id0.isEqual( id1 ) ) {
3193 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3194 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3195 if ( !pd1.isEqual( pd1 ) ) {
3198 if ( !pd1.isEqual( pd0 ) ) {
3203 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3204 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3205 if ( !pd3.isEqual( pd3 ) ) {
3208 if ( !pd2.isEqual( pd3 ) ) {
3211 if ( !pd0.isEqual( pd3 ) ) {
3216 // DomainArchitecture
3217 // ------------------
3218 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3219 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3220 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3221 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3222 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3223 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3228 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3229 if ( ds0.getNumberOfDomains() != 4 ) {
3232 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3233 if ( !ds0.isEqual( ds0 ) ) {
3236 if ( !ds0.isEqual( ds1 ) ) {
3239 if ( ds1.getNumberOfDomains() != 4 ) {
3242 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3247 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3248 if ( ds0.isEqual( ds2 ) ) {
3254 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3255 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3256 System.out.println( ds3.toNHX() );
3259 if ( ds3.getNumberOfDomains() != 3 ) {
3264 final Event e1 = new Event( Event.EventType.fusion );
3265 if ( e1.isDuplication() ) {
3268 if ( !e1.isFusion() ) {
3271 if ( !e1.asText().toString().equals( "fusion" ) ) {
3274 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3277 final Event e11 = new Event( Event.EventType.fusion );
3278 if ( !e11.isEqual( e1 ) ) {
3281 if ( !e11.toNHX().toString().equals( "" ) ) {
3284 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3285 if ( e2.isDuplication() ) {
3288 if ( !e2.isSpeciationOrDuplication() ) {
3291 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3294 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3297 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3300 if ( e11.isEqual( e2 ) ) {
3303 final Event e2c = ( Event ) e2.copy();
3304 if ( !e2c.isEqual( e2 ) ) {
3307 Event e3 = new Event( 1, 2, 3 );
3308 if ( e3.isDuplication() ) {
3311 if ( e3.isSpeciation() ) {
3314 if ( e3.isGeneLoss() ) {
3317 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3320 final Event e3c = ( Event ) e3.copy();
3321 final Event e3cc = ( Event ) e3c.copy();
3322 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3326 if ( !e3c.isEqual( e3cc ) ) {
3329 Event e4 = new Event( 1, 2, 3 );
3330 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3333 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3336 final Event e4c = ( Event ) e4.copy();
3338 final Event e4cc = ( Event ) e4c.copy();
3339 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3342 if ( !e4c.isEqual( e4cc ) ) {
3345 final Event e5 = new Event();
3346 if ( !e5.isUnassigned() ) {
3349 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3352 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3355 final Event e6 = new Event( 1, 0, 0 );
3356 if ( !e6.asText().toString().equals( "duplication" ) ) {
3359 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3362 final Event e7 = new Event( 0, 1, 0 );
3363 if ( !e7.asText().toString().equals( "speciation" ) ) {
3366 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3369 final Event e8 = new Event( 0, 0, 1 );
3370 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3373 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3377 catch ( final Exception e ) {
3378 e.printStackTrace( System.out );
3384 private static boolean testDeletionOfExternalNodes() {
3386 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3387 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3388 final PhylogenyWriter w = new PhylogenyWriter();
3389 if ( t0.isEmpty() ) {
3392 if ( t0.getNumberOfExternalNodes() != 1 ) {
3395 t0.deleteSubtree( t0.getNode( "A" ), false );
3396 if ( t0.getNumberOfExternalNodes() != 0 ) {
3399 if ( !t0.isEmpty() ) {
3402 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3403 if ( t1.getNumberOfExternalNodes() != 2 ) {
3406 t1.deleteSubtree( t1.getNode( "A" ), false );
3407 if ( t1.getNumberOfExternalNodes() != 1 ) {
3410 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3413 t1.deleteSubtree( t1.getNode( "B" ), false );
3414 if ( t1.getNumberOfExternalNodes() != 1 ) {
3417 t1.deleteSubtree( t1.getNode( "r" ), false );
3418 if ( !t1.isEmpty() ) {
3421 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3422 if ( t2.getNumberOfExternalNodes() != 3 ) {
3425 t2.deleteSubtree( t2.getNode( "B" ), false );
3426 if ( t2.getNumberOfExternalNodes() != 2 ) {
3429 t2.toNewHampshireX();
3430 PhylogenyNode n = t2.getNode( "A" );
3431 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3434 t2.deleteSubtree( t2.getNode( "A" ), false );
3435 if ( t2.getNumberOfExternalNodes() != 2 ) {
3438 t2.deleteSubtree( t2.getNode( "C" ), true );
3439 if ( t2.getNumberOfExternalNodes() != 1 ) {
3442 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3443 if ( t3.getNumberOfExternalNodes() != 4 ) {
3446 t3.deleteSubtree( t3.getNode( "B" ), true );
3447 if ( t3.getNumberOfExternalNodes() != 3 ) {
3450 n = t3.getNode( "A" );
3451 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3454 n = n.getNextExternalNode();
3455 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3458 t3.deleteSubtree( t3.getNode( "A" ), true );
3459 if ( t3.getNumberOfExternalNodes() != 2 ) {
3462 n = t3.getNode( "C" );
3463 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3466 t3.deleteSubtree( t3.getNode( "C" ), true );
3467 if ( t3.getNumberOfExternalNodes() != 1 ) {
3470 t3.deleteSubtree( t3.getNode( "D" ), true );
3471 if ( t3.getNumberOfExternalNodes() != 0 ) {
3474 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3475 if ( t4.getNumberOfExternalNodes() != 6 ) {
3478 t4.deleteSubtree( t4.getNode( "B2" ), true );
3479 if ( t4.getNumberOfExternalNodes() != 5 ) {
3482 String s = w.toNewHampshire( t4, true ).toString();
3483 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3486 t4.deleteSubtree( t4.getNode( "B11" ), true );
3487 if ( t4.getNumberOfExternalNodes() != 4 ) {
3490 t4.deleteSubtree( t4.getNode( "C" ), true );
3491 if ( t4.getNumberOfExternalNodes() != 3 ) {
3494 n = t4.getNode( "A" );
3495 n = n.getNextExternalNode();
3496 if ( !n.getName().equals( "B12" ) ) {
3499 n = n.getNextExternalNode();
3500 if ( !n.getName().equals( "D" ) ) {
3503 s = w.toNewHampshire( t4, true ).toString();
3504 if ( !s.equals( "((A,B12),D);" ) ) {
3507 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3508 t5.deleteSubtree( t5.getNode( "A" ), true );
3509 if ( t5.getNumberOfExternalNodes() != 5 ) {
3512 s = w.toNewHampshire( t5, true ).toString();
3513 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3516 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3517 t6.deleteSubtree( t6.getNode( "B11" ), true );
3518 if ( t6.getNumberOfExternalNodes() != 5 ) {
3521 s = w.toNewHampshire( t6, false ).toString();
3522 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3525 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3526 t7.deleteSubtree( t7.getNode( "B12" ), true );
3527 if ( t7.getNumberOfExternalNodes() != 5 ) {
3530 s = w.toNewHampshire( t7, true ).toString();
3531 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3534 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3535 t8.deleteSubtree( t8.getNode( "B2" ), true );
3536 if ( t8.getNumberOfExternalNodes() != 5 ) {
3539 s = w.toNewHampshire( t8, false ).toString();
3540 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3543 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3544 t9.deleteSubtree( t9.getNode( "C" ), true );
3545 if ( t9.getNumberOfExternalNodes() != 5 ) {
3548 s = w.toNewHampshire( t9, true ).toString();
3549 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3552 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3553 t10.deleteSubtree( t10.getNode( "D" ), true );
3554 if ( t10.getNumberOfExternalNodes() != 5 ) {
3557 s = w.toNewHampshire( t10, true ).toString();
3558 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3561 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3562 t11.deleteSubtree( t11.getNode( "A" ), true );
3563 if ( t11.getNumberOfExternalNodes() != 2 ) {
3566 s = w.toNewHampshire( t11, true ).toString();
3567 if ( !s.equals( "(B,C);" ) ) {
3570 t11.deleteSubtree( t11.getNode( "C" ), true );
3571 if ( t11.getNumberOfExternalNodes() != 1 ) {
3574 s = w.toNewHampshire( t11, false ).toString();
3575 if ( !s.equals( "B;" ) ) {
3578 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3579 t12.deleteSubtree( t12.getNode( "B2" ), true );
3580 if ( t12.getNumberOfExternalNodes() != 8 ) {
3583 s = w.toNewHampshire( t12, true ).toString();
3584 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3587 t12.deleteSubtree( t12.getNode( "B3" ), true );
3588 if ( t12.getNumberOfExternalNodes() != 7 ) {
3591 s = w.toNewHampshire( t12, true ).toString();
3592 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3595 t12.deleteSubtree( t12.getNode( "C3" ), true );
3596 if ( t12.getNumberOfExternalNodes() != 6 ) {
3599 s = w.toNewHampshire( t12, true ).toString();
3600 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3603 t12.deleteSubtree( t12.getNode( "A1" ), true );
3604 if ( t12.getNumberOfExternalNodes() != 5 ) {
3607 s = w.toNewHampshire( t12, true ).toString();
3608 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3611 t12.deleteSubtree( t12.getNode( "B1" ), true );
3612 if ( t12.getNumberOfExternalNodes() != 4 ) {
3615 s = w.toNewHampshire( t12, true ).toString();
3616 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3619 t12.deleteSubtree( t12.getNode( "A3" ), true );
3620 if ( t12.getNumberOfExternalNodes() != 3 ) {
3623 s = w.toNewHampshire( t12, true ).toString();
3624 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3627 t12.deleteSubtree( t12.getNode( "A2" ), true );
3628 if ( t12.getNumberOfExternalNodes() != 2 ) {
3631 s = w.toNewHampshire( t12, true ).toString();
3632 if ( !s.equals( "(C1,C2);" ) ) {
3635 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3636 t13.deleteSubtree( t13.getNode( "D" ), true );
3637 if ( t13.getNumberOfExternalNodes() != 4 ) {
3640 s = w.toNewHampshire( t13, true ).toString();
3641 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3644 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3645 t14.deleteSubtree( t14.getNode( "E" ), true );
3646 if ( t14.getNumberOfExternalNodes() != 5 ) {
3649 s = w.toNewHampshire( t14, true ).toString();
3650 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3653 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3654 t15.deleteSubtree( t15.getNode( "B2" ), true );
3655 if ( t15.getNumberOfExternalNodes() != 11 ) {
3658 t15.deleteSubtree( t15.getNode( "B1" ), true );
3659 if ( t15.getNumberOfExternalNodes() != 10 ) {
3662 t15.deleteSubtree( t15.getNode( "B3" ), true );
3663 if ( t15.getNumberOfExternalNodes() != 9 ) {
3666 t15.deleteSubtree( t15.getNode( "B4" ), true );
3667 if ( t15.getNumberOfExternalNodes() != 8 ) {
3670 t15.deleteSubtree( t15.getNode( "A1" ), true );
3671 if ( t15.getNumberOfExternalNodes() != 7 ) {
3674 t15.deleteSubtree( t15.getNode( "C4" ), true );
3675 if ( t15.getNumberOfExternalNodes() != 6 ) {
3679 catch ( final Exception e ) {
3680 e.printStackTrace( System.out );
3686 private static boolean testDescriptiveStatistics() {
3688 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3689 dss1.addValue( 82 );
3690 dss1.addValue( 78 );
3691 dss1.addValue( 70 );
3692 dss1.addValue( 58 );
3693 dss1.addValue( 42 );
3694 if ( dss1.getN() != 5 ) {
3697 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3700 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3703 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3706 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3709 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3712 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3715 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3718 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3721 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3724 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3727 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3730 dss1.addValue( 123 );
3731 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3734 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3737 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3740 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3741 dss2.addValue( -1.85 );
3742 dss2.addValue( 57.5 );
3743 dss2.addValue( 92.78 );
3744 dss2.addValue( 57.78 );
3745 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3748 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3751 final double[] a = dss2.getDataAsDoubleArray();
3752 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3755 dss2.addValue( -100 );
3756 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3759 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3762 final double[] ds = new double[ 14 ];
3777 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3778 if ( bins.length != 4 ) {
3781 if ( bins[ 0 ] != 2 ) {
3784 if ( bins[ 1 ] != 3 ) {
3787 if ( bins[ 2 ] != 4 ) {
3790 if ( bins[ 3 ] != 5 ) {
3793 final double[] ds1 = new double[ 9 ];
3803 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3804 if ( bins1.length != 4 ) {
3807 if ( bins1[ 0 ] != 2 ) {
3810 if ( bins1[ 1 ] != 3 ) {
3813 if ( bins1[ 2 ] != 0 ) {
3816 if ( bins1[ 3 ] != 4 ) {
3819 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3820 if ( bins1_1.length != 3 ) {
3823 if ( bins1_1[ 0 ] != 3 ) {
3826 if ( bins1_1[ 1 ] != 2 ) {
3829 if ( bins1_1[ 2 ] != 4 ) {
3832 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3833 if ( bins1_2.length != 3 ) {
3836 if ( bins1_2[ 0 ] != 2 ) {
3839 if ( bins1_2[ 1 ] != 2 ) {
3842 if ( bins1_2[ 2 ] != 2 ) {
3845 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3859 dss3.addValue( 10 );
3860 dss3.addValue( 10 );
3861 dss3.addValue( 10 );
3862 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3863 histo.toStringBuffer( 10, '=', 40, 5 );
3864 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3866 catch ( final Exception e ) {
3867 e.printStackTrace( System.out );
3873 private static boolean testDir( final String file ) {
3875 final File f = new File( file );
3876 if ( !f.exists() ) {
3879 if ( !f.isDirectory() ) {
3882 if ( !f.canRead() ) {
3886 catch ( final Exception e ) {
3892 private static boolean testEbiEntryRetrieval() {
3894 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3895 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3896 System.out.println( entry.getAccession() );
3899 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3900 System.out.println( entry.getTaxonomyScientificName() );
3903 if ( !entry.getSequenceName()
3904 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3905 System.out.println( entry.getSequenceName() );
3908 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3909 // System.out.println( entry.getSequenceSymbol() );
3912 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3913 System.out.println( entry.getGeneName() );
3916 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3917 System.out.println( entry.getTaxonomyIdentifier() );
3920 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3921 System.out.println( entry.getAnnotations().first().getRefValue() );
3924 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3925 System.out.println( entry.getAnnotations().first().getRefSource() );
3928 if ( entry.getCrossReferences().size() != 5 ) {
3932 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3933 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3936 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3937 System.out.println( entry1.getTaxonomyScientificName() );
3940 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3941 System.out.println( entry1.getSequenceName() );
3944 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3945 System.out.println( entry1.getTaxonomyIdentifier() );
3948 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3949 System.out.println( entry1.getGeneName() );
3952 if ( entry1.getCrossReferences().size() != 6 ) {
3956 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3957 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3960 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3961 System.out.println( entry2.getTaxonomyScientificName() );
3964 if ( !entry2.getSequenceName()
3965 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3966 System.out.println( entry2.getSequenceName() );
3969 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3970 System.out.println( entry2.getTaxonomyIdentifier() );
3973 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3974 System.out.println( entry2.getGeneName() );
3977 if ( entry2.getCrossReferences().size() != 3 ) {
3981 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3982 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3985 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3986 System.out.println( entry3.getTaxonomyScientificName() );
3989 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3990 System.out.println( entry3.getSequenceName() );
3993 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3994 System.out.println( entry3.getTaxonomyIdentifier() );
3997 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3998 System.out.println( entry3.getSequenceSymbol() );
4001 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4004 if ( entry3.getCrossReferences().size() != 8 ) {
4009 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4010 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4013 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4014 System.out.println( entry4.getTaxonomyScientificName() );
4017 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4018 System.out.println( entry4.getSequenceName() );
4021 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4022 System.out.println( entry4.getTaxonomyIdentifier() );
4025 if ( !entry4.getGeneName().equals( "ras" ) ) {
4026 System.out.println( entry4.getGeneName() );
4029 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4030 // System.out.println( entry4.getChromosome() );
4033 // if ( !entry4.getMap().equals( "ras" ) ) {
4034 // System.out.println( entry4.getMap() );
4040 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4041 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4044 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4045 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4048 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4049 System.out.println( entry5.getTaxonomyScientificName() );
4052 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4053 System.out.println( entry5.getSequenceName() );
4056 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4057 System.out.println( entry5.getTaxonomyIdentifier() );
4061 catch ( final IOException e ) {
4062 System.out.println();
4063 System.out.println( "the following might be due to absence internet connection:" );
4064 e.printStackTrace( System.out );
4067 catch ( final Exception e ) {
4068 e.printStackTrace();
4074 private static boolean testExternalNodeRelatedMethods() {
4076 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4077 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4078 PhylogenyNode n = t1.getNode( "A" );
4079 n = n.getNextExternalNode();
4080 if ( !n.getName().equals( "B" ) ) {
4083 n = n.getNextExternalNode();
4084 if ( !n.getName().equals( "C" ) ) {
4087 n = n.getNextExternalNode();
4088 if ( !n.getName().equals( "D" ) ) {
4091 n = t1.getNode( "B" );
4092 while ( !n.isLastExternalNode() ) {
4093 n = n.getNextExternalNode();
4095 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4096 n = t2.getNode( "A" );
4097 n = n.getNextExternalNode();
4098 if ( !n.getName().equals( "B" ) ) {
4101 n = n.getNextExternalNode();
4102 if ( !n.getName().equals( "C" ) ) {
4105 n = n.getNextExternalNode();
4106 if ( !n.getName().equals( "D" ) ) {
4109 n = t2.getNode( "B" );
4110 while ( !n.isLastExternalNode() ) {
4111 n = n.getNextExternalNode();
4113 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4114 n = t3.getNode( "A" );
4115 n = n.getNextExternalNode();
4116 if ( !n.getName().equals( "B" ) ) {
4119 n = n.getNextExternalNode();
4120 if ( !n.getName().equals( "C" ) ) {
4123 n = n.getNextExternalNode();
4124 if ( !n.getName().equals( "D" ) ) {
4127 n = n.getNextExternalNode();
4128 if ( !n.getName().equals( "E" ) ) {
4131 n = n.getNextExternalNode();
4132 if ( !n.getName().equals( "F" ) ) {
4135 n = n.getNextExternalNode();
4136 if ( !n.getName().equals( "G" ) ) {
4139 n = n.getNextExternalNode();
4140 if ( !n.getName().equals( "H" ) ) {
4143 n = t3.getNode( "B" );
4144 while ( !n.isLastExternalNode() ) {
4145 n = n.getNextExternalNode();
4147 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4148 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4149 final PhylogenyNode node = iter.next();
4151 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4152 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4153 final PhylogenyNode node = iter.next();
4155 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4156 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4157 if ( !iter.next().getName().equals( "A" ) ) {
4160 if ( !iter.next().getName().equals( "B" ) ) {
4163 if ( !iter.next().getName().equals( "C" ) ) {
4166 if ( !iter.next().getName().equals( "D" ) ) {
4169 if ( !iter.next().getName().equals( "E" ) ) {
4172 if ( !iter.next().getName().equals( "F" ) ) {
4175 if ( iter.hasNext() ) {
4179 catch ( final Exception e ) {
4180 e.printStackTrace( System.out );
4186 private static boolean testExtractSNFromNodeName() {
4188 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4191 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4194 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4197 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4198 .equals( "Mus musculus musculus" ) ) {
4201 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4202 .equals( "Mus musculus musculus" ) ) {
4205 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4206 .equals( "Mus musculus musculus" ) ) {
4209 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4210 .equals( "Mus musculus musculus" ) ) {
4213 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4216 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4217 .equals( "Mus musculus musculus" ) ) {
4220 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4221 .equals( "Mus musculus musculus" ) ) {
4224 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4227 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4230 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4233 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4236 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4237 .equals( "Mus musculus musculus" ) ) {
4240 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4243 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4246 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4249 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4252 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4255 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4258 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4261 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4264 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4265 .equals( "Mus musculus" ) ) {
4268 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4269 .equals( "Mus musculus" ) ) {
4272 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4275 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4276 .equals( "Mus musculus musculus" ) ) {
4279 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4280 .equals( "Mus musculus musculus" ) ) {
4283 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4284 .equals( "Mus musculus musculus" ) ) {
4287 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4290 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4291 .equals( "Pilostyles mexicana" ) ) {
4294 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4295 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4298 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4299 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4302 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4303 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4306 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4307 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4310 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4311 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4314 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4315 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4318 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4319 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4322 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4323 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4326 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4327 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4330 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4331 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4334 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4335 .equals( "Escherichia coli (strain K12)" ) ) {
4338 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4339 .equals( "Escherichia coli (strain K12)" ) ) {
4342 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4343 .equals( "Escherichia coli (str. K12)" ) ) {
4346 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4347 .equals( "Escherichia coli (str. K12)" ) ) {
4350 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4351 .equals( "Escherichia coli (str. K12)" ) ) {
4354 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4355 .equals( "Escherichia coli (var. K12)" ) ) {
4358 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4359 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4362 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4363 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4367 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4368 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4371 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4372 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4376 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4377 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4380 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4381 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4384 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4385 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4388 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4391 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4394 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4397 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4398 .equals( "Macrocera sp." ) ) {
4401 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4404 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4405 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4408 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4409 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4412 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4413 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4416 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4417 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4421 catch ( final Exception e ) {
4422 e.printStackTrace( System.out );
4428 private static boolean testExtractTaxonomyCodeFromNodeName() {
4430 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4433 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4434 .equals( "SOYBN" ) ) {
4437 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4438 .equals( "ARATH" ) ) {
4441 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4442 .equals( "ARATH" ) ) {
4445 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4448 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4451 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4454 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4455 .equals( "SOYBN" ) ) {
4458 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4459 .equals( "SOYBN" ) ) {
4462 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4463 .equals( "SOYBN" ) ) {
4466 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4467 .equals( "SOYBN" ) ) {
4470 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4471 .equals( "SOYBN" ) ) {
4474 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4475 .equals( "SOYBN" ) ) {
4478 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4479 .equals( "SOYBN" ) ) {
4482 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4483 .equals( "SOYBN" ) ) {
4486 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4489 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4490 .equals( "SOYBN" ) ) {
4493 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4494 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4497 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4498 .equals( "9YX45" ) ) {
4501 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4502 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4503 .equals( "MOUSE" ) ) {
4506 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4507 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4508 .equals( "MOUSE" ) ) {
4511 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4512 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4513 .equals( "MOUSE" ) ) {
4516 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4517 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4520 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4521 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4524 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4525 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4528 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4529 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4532 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4533 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4536 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4537 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4540 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4541 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4544 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4545 .equals( "RAT" ) ) {
4548 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4549 .equals( "PIG" ) ) {
4553 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4554 .equals( "MOUSE" ) ) {
4557 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4558 .equals( "MOUSE" ) ) {
4561 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4565 catch ( final Exception e ) {
4566 e.printStackTrace( System.out );
4572 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4574 PhylogenyNode n = new PhylogenyNode();
4575 n.setName( "tr|B3RJ64" );
4576 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4579 n.setName( "tr.B3RJ64" );
4580 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4583 n.setName( "tr=B3RJ64" );
4584 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4587 n.setName( "tr-B3RJ64" );
4588 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4591 n.setName( "tr/B3RJ64" );
4592 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4595 n.setName( "tr\\B3RJ64" );
4596 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4599 n.setName( "tr_B3RJ64" );
4600 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4603 n.setName( " tr|B3RJ64 " );
4604 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4607 n.setName( "-tr|B3RJ64-" );
4608 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4611 n.setName( "-tr=B3RJ64-" );
4612 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4615 n.setName( "_tr=B3RJ64_" );
4616 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4619 n.setName( " tr_tr|B3RJ64_sp|123 " );
4620 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4623 n.setName( "B3RJ64" );
4624 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4627 n.setName( "sp|B3RJ64" );
4628 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4631 n.setName( "sp|B3RJ64C" );
4632 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4635 n.setName( "sp B3RJ64" );
4636 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4639 n.setName( "sp|B3RJ6X" );
4640 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4643 n.setName( "sp|B3RJ6" );
4644 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4647 n.setName( "K1PYK7_CRAGI" );
4648 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4651 n.setName( "K1PYK7_PEA" );
4652 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4655 n.setName( "K1PYK7_RAT" );
4656 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4659 n.setName( "K1PYK7_PIG" );
4660 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4663 n.setName( "~K1PYK7_PIG~" );
4664 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4667 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4668 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4671 n.setName( "K1PYKX_CRAGI" );
4672 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4675 n.setName( "XXXXX_CRAGI" );
4676 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4679 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4680 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4683 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4684 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4687 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4688 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4691 n = new PhylogenyNode();
4692 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4693 seq.setSymbol( "K1PYK7_CRAGI" );
4694 n.getNodeData().addSequence( seq );
4695 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4698 seq.setSymbol( "tr|B3RJ64" );
4699 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4702 n = new PhylogenyNode();
4703 seq = new org.forester.phylogeny.data.Sequence();
4704 seq.setName( "K1PYK7_CRAGI" );
4705 n.getNodeData().addSequence( seq );
4706 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4709 seq.setName( "tr|B3RJ64" );
4710 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4713 n = new PhylogenyNode();
4714 seq = new org.forester.phylogeny.data.Sequence();
4715 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4716 n.getNodeData().addSequence( seq );
4717 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4720 n = new PhylogenyNode();
4721 seq = new org.forester.phylogeny.data.Sequence();
4722 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4723 n.getNodeData().addSequence( seq );
4724 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4728 n = new PhylogenyNode();
4729 n.setName( "ACP19736" );
4730 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4733 n = new PhylogenyNode();
4734 n.setName( "|ACP19736|" );
4735 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4739 catch ( final Exception e ) {
4740 e.printStackTrace( System.out );
4746 private static boolean testFastaParser() {
4748 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4751 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4754 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4755 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4758 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4761 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4764 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4767 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4770 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4774 catch ( final Exception e ) {
4775 e.printStackTrace();
4781 private static boolean testGenbankAccessorParsing() {
4782 //The format for GenBank Accession numbers are:
4783 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4784 //Protein: 3 letters + 5 numerals
4785 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4786 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4789 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4792 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4795 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4798 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4801 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4804 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4807 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4810 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4813 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4816 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4819 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4822 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4825 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4831 private static boolean testGeneralMsaParser() {
4833 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4834 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4835 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4836 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4837 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4838 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4839 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4840 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4841 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4844 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4847 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4850 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4853 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4856 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4859 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4862 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4865 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4868 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4871 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4874 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4877 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4878 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4881 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4884 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4887 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4888 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4891 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4894 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4897 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4898 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4901 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4904 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4908 catch ( final Exception e ) {
4909 e.printStackTrace();
4915 private static boolean testGeneralTable() {
4917 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4918 t0.setValue( 3, 2, "23" );
4919 t0.setValue( 10, 1, "error" );
4920 t0.setValue( 10, 1, "110" );
4921 t0.setValue( 9, 1, "19" );
4922 t0.setValue( 1, 10, "101" );
4923 t0.setValue( 10, 10, "1010" );
4924 t0.setValue( 100, 10, "10100" );
4925 t0.setValue( 0, 0, "00" );
4926 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4929 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4932 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4935 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4938 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4941 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4944 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4947 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4950 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4953 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4954 t1.setValue( "3", "2", "23" );
4955 t1.setValue( "10", "1", "error" );
4956 t1.setValue( "10", "1", "110" );
4957 t1.setValue( "9", "1", "19" );
4958 t1.setValue( "1", "10", "101" );
4959 t1.setValue( "10", "10", "1010" );
4960 t1.setValue( "100", "10", "10100" );
4961 t1.setValue( "0", "0", "00" );
4962 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4963 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4966 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4969 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4972 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4975 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4978 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4981 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4984 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4987 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4990 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4994 catch ( final Exception e ) {
4995 e.printStackTrace( System.out );
5001 private static boolean testGetDistance() {
5003 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5004 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",
5005 new NHXParser() )[ 0 ];
5006 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5009 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5012 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5015 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5018 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5021 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5024 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5027 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5030 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5033 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5036 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5039 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5042 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5045 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5048 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5051 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5054 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5057 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5060 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5063 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5066 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5069 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5072 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5075 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5078 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5081 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5084 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5087 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5090 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5093 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5096 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5099 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",
5100 new NHXParser() )[ 0 ];
5101 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5104 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5107 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5110 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5113 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5116 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5119 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5122 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5125 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5128 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5131 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5135 catch ( final Exception e ) {
5136 e.printStackTrace( System.out );
5142 private static boolean testGetLCA() {
5144 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5145 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5146 new NHXParser() )[ 0 ];
5147 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5148 if ( !A.getName().equals( "A" ) ) {
5151 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5152 if ( !gh.getName().equals( "gh" ) ) {
5155 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5156 if ( !ab.getName().equals( "ab" ) ) {
5159 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5160 if ( !ab2.getName().equals( "ab" ) ) {
5163 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5164 if ( !gh2.getName().equals( "gh" ) ) {
5167 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5168 if ( !gh3.getName().equals( "gh" ) ) {
5171 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5172 if ( !abc.getName().equals( "abc" ) ) {
5175 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5176 if ( !abc2.getName().equals( "abc" ) ) {
5179 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5180 if ( !abcd.getName().equals( "abcd" ) ) {
5183 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5184 if ( !abcd2.getName().equals( "abcd" ) ) {
5187 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5188 if ( !abcdef.getName().equals( "abcdef" ) ) {
5191 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5192 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5195 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5196 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5199 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5200 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5203 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5204 if ( !abcde.getName().equals( "abcde" ) ) {
5207 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5208 if ( !abcde2.getName().equals( "abcde" ) ) {
5211 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5212 if ( !r.getName().equals( "abcdefgh" ) ) {
5215 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5216 if ( !r2.getName().equals( "abcdefgh" ) ) {
5219 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5220 if ( !r3.getName().equals( "abcdefgh" ) ) {
5223 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5224 if ( !abcde3.getName().equals( "abcde" ) ) {
5227 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5228 if ( !abcde4.getName().equals( "abcde" ) ) {
5231 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5232 if ( !ab3.getName().equals( "ab" ) ) {
5235 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5236 if ( !ab4.getName().equals( "ab" ) ) {
5239 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5240 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5241 if ( !cd.getName().equals( "cd" ) ) {
5244 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5245 if ( !cd2.getName().equals( "cd" ) ) {
5248 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5249 if ( !cde.getName().equals( "cde" ) ) {
5252 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5253 if ( !cde2.getName().equals( "cde" ) ) {
5256 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5257 if ( !cdef.getName().equals( "cdef" ) ) {
5260 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5261 if ( !cdef2.getName().equals( "cdef" ) ) {
5264 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5265 if ( !cdef3.getName().equals( "cdef" ) ) {
5268 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5269 if ( !rt.getName().equals( "r" ) ) {
5272 final Phylogeny p3 = factory
5273 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5274 new NHXParser() )[ 0 ];
5275 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5276 if ( !bc_3.getName().equals( "bc" ) ) {
5279 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5280 if ( !ac_3.getName().equals( "abc" ) ) {
5283 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5284 if ( !ad_3.getName().equals( "abcde" ) ) {
5287 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5288 if ( !af_3.getName().equals( "abcdef" ) ) {
5291 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5292 if ( !ag_3.getName().equals( "" ) ) {
5295 if ( !ag_3.isRoot() ) {
5298 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5299 if ( !al_3.getName().equals( "" ) ) {
5302 if ( !al_3.isRoot() ) {
5305 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5306 if ( !kl_3.getName().equals( "" ) ) {
5309 if ( !kl_3.isRoot() ) {
5312 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5313 if ( !fl_3.getName().equals( "" ) ) {
5316 if ( !fl_3.isRoot() ) {
5319 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5320 if ( !gk_3.getName().equals( "ghijk" ) ) {
5323 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5324 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5325 if ( !r_4.getName().equals( "r" ) ) {
5328 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5329 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5330 if ( !r_5.getName().equals( "root" ) ) {
5333 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5334 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5335 if ( !r_6.getName().equals( "rot" ) ) {
5338 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5339 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5340 if ( !r_7.getName().equals( "rott" ) ) {
5344 catch ( final Exception e ) {
5345 e.printStackTrace( System.out );
5351 private static boolean testGetLCA2() {
5353 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5354 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5355 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5356 PhylogenyMethods.preOrderReId( p_a );
5357 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5358 p_a.getNode( "a" ) );
5359 if ( !p_a_1.getName().equals( "a" ) ) {
5362 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5363 PhylogenyMethods.preOrderReId( p_b );
5364 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5365 p_b.getNode( "a" ) );
5366 if ( !p_b_1.getName().equals( "b" ) ) {
5369 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5370 p_b.getNode( "b" ) );
5371 if ( !p_b_2.getName().equals( "b" ) ) {
5374 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5375 PhylogenyMethods.preOrderReId( p_c );
5376 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5377 p_c.getNode( "a" ) );
5378 if ( !p_c_1.getName().equals( "b" ) ) {
5381 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5382 p_c.getNode( "c" ) );
5383 if ( !p_c_2.getName().equals( "c" ) ) {
5384 System.out.println( p_c_2.getName() );
5388 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5389 p_c.getNode( "b" ) );
5390 if ( !p_c_3.getName().equals( "b" ) ) {
5393 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5394 p_c.getNode( "a" ) );
5395 if ( !p_c_4.getName().equals( "c" ) ) {
5398 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5399 new NHXParser() )[ 0 ];
5400 PhylogenyMethods.preOrderReId( p1 );
5401 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5402 p1.getNode( "A" ) );
5403 if ( !A.getName().equals( "A" ) ) {
5406 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5407 p1.getNode( "gh" ) );
5408 if ( !gh.getName().equals( "gh" ) ) {
5411 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5412 p1.getNode( "B" ) );
5413 if ( !ab.getName().equals( "ab" ) ) {
5416 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5417 p1.getNode( "A" ) );
5418 if ( !ab2.getName().equals( "ab" ) ) {
5421 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5422 p1.getNode( "G" ) );
5423 if ( !gh2.getName().equals( "gh" ) ) {
5426 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5427 p1.getNode( "H" ) );
5428 if ( !gh3.getName().equals( "gh" ) ) {
5431 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5432 p1.getNode( "A" ) );
5433 if ( !abc.getName().equals( "abc" ) ) {
5436 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5437 p1.getNode( "C" ) );
5438 if ( !abc2.getName().equals( "abc" ) ) {
5441 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5442 p1.getNode( "D" ) );
5443 if ( !abcd.getName().equals( "abcd" ) ) {
5446 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5447 p1.getNode( "A" ) );
5448 if ( !abcd2.getName().equals( "abcd" ) ) {
5451 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5452 p1.getNode( "F" ) );
5453 if ( !abcdef.getName().equals( "abcdef" ) ) {
5456 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5457 p1.getNode( "A" ) );
5458 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5461 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5462 p1.getNode( "F" ) );
5463 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5466 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5467 p1.getNode( "ab" ) );
5468 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5471 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5472 p1.getNode( "E" ) );
5473 if ( !abcde.getName().equals( "abcde" ) ) {
5476 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5477 p1.getNode( "A" ) );
5478 if ( !abcde2.getName().equals( "abcde" ) ) {
5481 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5482 p1.getNode( "abcdefgh" ) );
5483 if ( !r.getName().equals( "abcdefgh" ) ) {
5486 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5487 p1.getNode( "H" ) );
5488 if ( !r2.getName().equals( "abcdefgh" ) ) {
5491 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5492 p1.getNode( "A" ) );
5493 if ( !r3.getName().equals( "abcdefgh" ) ) {
5496 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5497 p1.getNode( "abcde" ) );
5498 if ( !abcde3.getName().equals( "abcde" ) ) {
5501 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5502 p1.getNode( "E" ) );
5503 if ( !abcde4.getName().equals( "abcde" ) ) {
5506 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5507 p1.getNode( "B" ) );
5508 if ( !ab3.getName().equals( "ab" ) ) {
5511 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5512 p1.getNode( "ab" ) );
5513 if ( !ab4.getName().equals( "ab" ) ) {
5516 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5517 PhylogenyMethods.preOrderReId( p2 );
5518 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5519 p2.getNode( "d" ) );
5520 if ( !cd.getName().equals( "cd" ) ) {
5523 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5524 p2.getNode( "c" ) );
5525 if ( !cd2.getName().equals( "cd" ) ) {
5528 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5529 p2.getNode( "e" ) );
5530 if ( !cde.getName().equals( "cde" ) ) {
5533 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5534 p2.getNode( "c" ) );
5535 if ( !cde2.getName().equals( "cde" ) ) {
5538 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5539 p2.getNode( "f" ) );
5540 if ( !cdef.getName().equals( "cdef" ) ) {
5543 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5544 p2.getNode( "f" ) );
5545 if ( !cdef2.getName().equals( "cdef" ) ) {
5548 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5549 p2.getNode( "d" ) );
5550 if ( !cdef3.getName().equals( "cdef" ) ) {
5553 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5554 p2.getNode( "a" ) );
5555 if ( !rt.getName().equals( "r" ) ) {
5558 final Phylogeny p3 = factory
5559 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5560 new NHXParser() )[ 0 ];
5561 PhylogenyMethods.preOrderReId( p3 );
5562 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5563 p3.getNode( "c" ) );
5564 if ( !bc_3.getName().equals( "bc" ) ) {
5567 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5568 p3.getNode( "c" ) );
5569 if ( !ac_3.getName().equals( "abc" ) ) {
5572 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5573 p3.getNode( "d" ) );
5574 if ( !ad_3.getName().equals( "abcde" ) ) {
5577 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5578 p3.getNode( "f" ) );
5579 if ( !af_3.getName().equals( "abcdef" ) ) {
5582 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5583 p3.getNode( "g" ) );
5584 if ( !ag_3.getName().equals( "" ) ) {
5587 if ( !ag_3.isRoot() ) {
5590 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5591 p3.getNode( "l" ) );
5592 if ( !al_3.getName().equals( "" ) ) {
5595 if ( !al_3.isRoot() ) {
5598 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5599 p3.getNode( "l" ) );
5600 if ( !kl_3.getName().equals( "" ) ) {
5603 if ( !kl_3.isRoot() ) {
5606 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5607 p3.getNode( "l" ) );
5608 if ( !fl_3.getName().equals( "" ) ) {
5611 if ( !fl_3.isRoot() ) {
5614 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5615 p3.getNode( "k" ) );
5616 if ( !gk_3.getName().equals( "ghijk" ) ) {
5619 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5620 PhylogenyMethods.preOrderReId( p4 );
5621 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5622 p4.getNode( "c" ) );
5623 if ( !r_4.getName().equals( "r" ) ) {
5626 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5627 PhylogenyMethods.preOrderReId( p5 );
5628 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5629 p5.getNode( "c" ) );
5630 if ( !r_5.getName().equals( "root" ) ) {
5633 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5634 PhylogenyMethods.preOrderReId( p6 );
5635 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5636 p6.getNode( "a" ) );
5637 if ( !r_6.getName().equals( "rot" ) ) {
5640 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5641 PhylogenyMethods.preOrderReId( p7 );
5642 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5643 p7.getNode( "e" ) );
5644 if ( !r_7.getName().equals( "rott" ) ) {
5647 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5648 p7.getNode( "a" ) );
5649 if ( !r_71.getName().equals( "rott" ) ) {
5652 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5653 p7.getNode( "rott" ) );
5654 if ( !r_72.getName().equals( "rott" ) ) {
5657 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5658 p7.getNode( "a" ) );
5659 if ( !r_73.getName().equals( "rott" ) ) {
5662 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5663 p7.getNode( "rott" ) );
5664 if ( !r_74.getName().equals( "rott" ) ) {
5667 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5668 p7.getNode( "e" ) );
5669 if ( !r_75.getName().equals( "e" ) ) {
5673 catch ( final Exception e ) {
5674 e.printStackTrace( System.out );
5680 private static boolean testHmmscanOutputParser() {
5681 final String test_dir = Test.PATH_TO_TEST_DATA;
5683 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5684 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5686 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5687 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5688 final List<Protein> proteins = parser2.parse();
5689 if ( parser2.getProteinsEncountered() != 4 ) {
5692 if ( proteins.size() != 4 ) {
5695 if ( parser2.getDomainsEncountered() != 69 ) {
5698 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5701 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5704 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5707 final Protein p1 = proteins.get( 0 );
5708 if ( p1.getNumberOfProteinDomains() != 15 ) {
5711 if ( p1.getLength() != 850 ) {
5714 final Protein p2 = proteins.get( 1 );
5715 if ( p2.getNumberOfProteinDomains() != 51 ) {
5718 if ( p2.getLength() != 1291 ) {
5721 final Protein p3 = proteins.get( 2 );
5722 if ( p3.getNumberOfProteinDomains() != 2 ) {
5725 final Protein p4 = proteins.get( 3 );
5726 if ( p4.getNumberOfProteinDomains() != 1 ) {
5729 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5732 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5735 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5738 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5741 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5744 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5747 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5751 catch ( final Exception e ) {
5752 e.printStackTrace( System.out );
5758 private static boolean testLastExternalNodeMethods() {
5760 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5761 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5762 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5763 final PhylogenyNode n1 = t0.getNode( "A" );
5764 if ( n1.isLastExternalNode() ) {
5767 final PhylogenyNode n2 = t0.getNode( "B" );
5768 if ( n2.isLastExternalNode() ) {
5771 final PhylogenyNode n3 = t0.getNode( "C" );
5772 if ( n3.isLastExternalNode() ) {
5775 final PhylogenyNode n4 = t0.getNode( "D" );
5776 if ( !n4.isLastExternalNode() ) {
5780 catch ( final Exception e ) {
5781 e.printStackTrace( System.out );
5787 private static boolean testLevelOrderIterator() {
5789 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5790 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5791 PhylogenyNodeIterator it0;
5792 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5795 for( it0.reset(); it0.hasNext(); ) {
5798 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5799 if ( !it.next().getName().equals( "r" ) ) {
5802 if ( !it.next().getName().equals( "ab" ) ) {
5805 if ( !it.next().getName().equals( "cd" ) ) {
5808 if ( !it.next().getName().equals( "A" ) ) {
5811 if ( !it.next().getName().equals( "B" ) ) {
5814 if ( !it.next().getName().equals( "C" ) ) {
5817 if ( !it.next().getName().equals( "D" ) ) {
5820 if ( it.hasNext() ) {
5823 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",
5824 new NHXParser() )[ 0 ];
5825 PhylogenyNodeIterator it2;
5826 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5829 for( it2.reset(); it2.hasNext(); ) {
5832 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5833 if ( !it3.next().getName().equals( "r" ) ) {
5836 if ( !it3.next().getName().equals( "abc" ) ) {
5839 if ( !it3.next().getName().equals( "defg" ) ) {
5842 if ( !it3.next().getName().equals( "A" ) ) {
5845 if ( !it3.next().getName().equals( "B" ) ) {
5848 if ( !it3.next().getName().equals( "C" ) ) {
5851 if ( !it3.next().getName().equals( "D" ) ) {
5854 if ( !it3.next().getName().equals( "E" ) ) {
5857 if ( !it3.next().getName().equals( "F" ) ) {
5860 if ( !it3.next().getName().equals( "G" ) ) {
5863 if ( !it3.next().getName().equals( "1" ) ) {
5866 if ( !it3.next().getName().equals( "2" ) ) {
5869 if ( !it3.next().getName().equals( "3" ) ) {
5872 if ( !it3.next().getName().equals( "4" ) ) {
5875 if ( !it3.next().getName().equals( "5" ) ) {
5878 if ( !it3.next().getName().equals( "6" ) ) {
5881 if ( !it3.next().getName().equals( "f1" ) ) {
5884 if ( !it3.next().getName().equals( "f2" ) ) {
5887 if ( !it3.next().getName().equals( "f3" ) ) {
5890 if ( !it3.next().getName().equals( "a" ) ) {
5893 if ( !it3.next().getName().equals( "b" ) ) {
5896 if ( !it3.next().getName().equals( "f21" ) ) {
5899 if ( !it3.next().getName().equals( "X" ) ) {
5902 if ( !it3.next().getName().equals( "Y" ) ) {
5905 if ( !it3.next().getName().equals( "Z" ) ) {
5908 if ( it3.hasNext() ) {
5911 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5912 PhylogenyNodeIterator it4;
5913 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5916 for( it4.reset(); it4.hasNext(); ) {
5919 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5920 if ( !it5.next().getName().equals( "r" ) ) {
5923 if ( !it5.next().getName().equals( "A" ) ) {
5926 if ( !it5.next().getName().equals( "B" ) ) {
5929 if ( !it5.next().getName().equals( "C" ) ) {
5932 if ( !it5.next().getName().equals( "D" ) ) {
5935 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5936 PhylogenyNodeIterator it6;
5937 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5940 for( it6.reset(); it6.hasNext(); ) {
5943 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5944 if ( !it7.next().getName().equals( "A" ) ) {
5947 if ( it.hasNext() ) {
5951 catch ( final Exception e ) {
5952 e.printStackTrace( System.out );
5958 private static boolean testMafft( final String path ) {
5960 final List<String> opts = new ArrayList<String>();
5961 opts.add( "--maxiterate" );
5963 opts.add( "--localpair" );
5964 opts.add( "--quiet" );
5966 final MsaInferrer mafft = Mafft.createInstance( path );
5967 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5968 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5971 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5975 catch ( final Exception e ) {
5976 e.printStackTrace( System.out );
5982 private static boolean testMidpointrooting() {
5984 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5985 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5986 PhylogenyMethods.midpointRoot( t0 );
5987 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5990 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5993 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5997 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",
5998 new NHXParser() )[ 0 ];
5999 if ( !t1.isRooted() ) {
6002 PhylogenyMethods.midpointRoot( t1 );
6003 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6006 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6009 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6012 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6015 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6018 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6021 t1.reRoot( t1.getNode( "A" ) );
6022 PhylogenyMethods.midpointRoot( t1 );
6023 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6026 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6029 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6032 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6035 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6039 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6043 catch ( final Exception e ) {
6044 e.printStackTrace( System.out );
6050 private static boolean testMsaQualityMethod() {
6052 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6053 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6054 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6055 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6056 final List<Sequence> l = new ArrayList<Sequence>();
6061 final Msa msa = BasicMsa.createInstance( l );
6062 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6065 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6068 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6071 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6074 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6077 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6080 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6084 catch ( final Exception e ) {
6085 e.printStackTrace( System.out );
6091 private static boolean testDeleteableMsa() {
6093 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6094 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6095 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6096 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6097 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6098 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6099 final List<Sequence> l0 = new ArrayList<Sequence>();
6106 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6107 dmsa0.deleteRow( "b", false );
6108 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6111 dmsa0.deleteRow( "e", false );
6112 dmsa0.deleteRow( "a", false );
6113 dmsa0.deleteRow( "f", false );
6114 if ( dmsa0.getLength() != 4 ) {
6117 if ( dmsa0.getNumberOfSequences() != 2 ) {
6120 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6123 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6126 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6129 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6132 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6135 dmsa0.deleteRow( "c", false );
6136 dmsa0.deleteRow( "d", false );
6137 if ( dmsa0.getNumberOfSequences() != 0 ) {
6141 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6142 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6143 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6144 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6145 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6146 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6147 final List<Sequence> l1 = new ArrayList<Sequence>();
6154 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6155 dmsa1.deleteGapOnlyColumns();
6156 dmsa1.deleteRow( "a", false );
6157 dmsa1.deleteRow( "f", false );
6158 dmsa1.deleteRow( "d", false );
6159 dmsa1.deleteGapOnlyColumns();
6160 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6163 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6166 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6169 dmsa1.deleteRow( "c", false );
6170 dmsa1.deleteGapOnlyColumns();
6171 final Writer w0 = new StringWriter();
6172 dmsa1.write( w0, MSA_FORMAT.FASTA );
6173 final Writer w1 = new StringWriter();
6174 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6175 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6178 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6182 final Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6183 final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6184 final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6185 final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6186 final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6187 final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6188 final List<Sequence> l2 = new ArrayList<Sequence>();
6195 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6196 dmsa2.deleteGapColumns( 0.5 );
6197 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6200 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6203 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6206 dmsa2.deleteGapColumns( 0.2 );
6207 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6210 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6213 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6216 dmsa2.deleteGapColumns( 0 );
6217 dmsa2.deleteRow( "a", false );
6218 dmsa2.deleteRow( "b", false );
6219 dmsa2.deleteRow( "f", false );
6220 dmsa2.deleteRow( "e", false );
6221 dmsa2.setIdentifier( 0, "new_c" );
6222 dmsa2.setIdentifier( 1, "new_d" );
6223 dmsa2.setResidueAt( 0, 0, 'x' );
6224 final Sequence s = dmsa2.deleteRow( "new_d", true );
6225 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6228 final Writer w = new StringWriter();
6229 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6230 final String phylip = w.toString();
6231 if ( !phylip.equals( "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6234 final Writer w2 = new StringWriter();
6235 dmsa2.write( w2, MSA_FORMAT.FASTA );
6236 final String fasta = w2.toString();
6237 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6241 catch ( final Exception e ) {
6242 e.printStackTrace( System.out );
6248 private static boolean testNextNodeWithCollapsing() {
6250 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6252 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6253 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6254 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6255 t0.getNode( "cd" ).setCollapse( true );
6256 t0.getNode( "cde" ).setCollapse( true );
6257 n = t0.getFirstExternalNode();
6258 while ( n != null ) {
6260 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6262 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6265 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6268 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6271 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6274 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6277 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6281 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6282 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6283 t1.getNode( "ab" ).setCollapse( true );
6284 t1.getNode( "cd" ).setCollapse( true );
6285 t1.getNode( "cde" ).setCollapse( true );
6286 n = t1.getNode( "ab" );
6287 ext = new ArrayList<PhylogenyNode>();
6288 while ( n != null ) {
6290 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6292 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6295 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6298 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6301 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6304 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6310 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6311 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6312 t2.getNode( "ab" ).setCollapse( true );
6313 t2.getNode( "cd" ).setCollapse( true );
6314 t2.getNode( "cde" ).setCollapse( true );
6315 t2.getNode( "c" ).setCollapse( true );
6316 t2.getNode( "d" ).setCollapse( true );
6317 t2.getNode( "e" ).setCollapse( true );
6318 t2.getNode( "gh" ).setCollapse( true );
6319 n = t2.getNode( "ab" );
6320 ext = new ArrayList<PhylogenyNode>();
6321 while ( n != null ) {
6323 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6325 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6328 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6331 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6334 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6340 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6341 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6342 t3.getNode( "ab" ).setCollapse( true );
6343 t3.getNode( "cd" ).setCollapse( true );
6344 t3.getNode( "cde" ).setCollapse( true );
6345 t3.getNode( "c" ).setCollapse( true );
6346 t3.getNode( "d" ).setCollapse( true );
6347 t3.getNode( "e" ).setCollapse( true );
6348 t3.getNode( "gh" ).setCollapse( true );
6349 t3.getNode( "fgh" ).setCollapse( true );
6350 n = t3.getNode( "ab" );
6351 ext = new ArrayList<PhylogenyNode>();
6352 while ( n != null ) {
6354 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6356 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6359 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6362 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6368 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6369 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6370 t4.getNode( "ab" ).setCollapse( true );
6371 t4.getNode( "cd" ).setCollapse( true );
6372 t4.getNode( "cde" ).setCollapse( true );
6373 t4.getNode( "c" ).setCollapse( true );
6374 t4.getNode( "d" ).setCollapse( true );
6375 t4.getNode( "e" ).setCollapse( true );
6376 t4.getNode( "gh" ).setCollapse( true );
6377 t4.getNode( "fgh" ).setCollapse( true );
6378 t4.getNode( "abcdefgh" ).setCollapse( true );
6379 n = t4.getNode( "abcdefgh" );
6380 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6385 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6386 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6388 n = t5.getFirstExternalNode();
6389 while ( n != null ) {
6391 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6393 if ( ext.size() != 8 ) {
6396 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6399 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6402 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6405 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6408 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6411 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6414 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6417 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6422 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6423 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6425 t6.getNode( "ab" ).setCollapse( true );
6426 n = t6.getNode( "ab" );
6427 while ( n != null ) {
6429 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6431 if ( ext.size() != 7 ) {
6434 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6437 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6440 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6443 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6446 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6449 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6452 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6457 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6458 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6460 t7.getNode( "cd" ).setCollapse( true );
6461 n = t7.getNode( "a" );
6462 while ( n != null ) {
6464 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6466 if ( ext.size() != 7 ) {
6469 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6472 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6475 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6478 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6481 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6484 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6487 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6492 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6493 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6495 t8.getNode( "cd" ).setCollapse( true );
6496 t8.getNode( "c" ).setCollapse( true );
6497 t8.getNode( "d" ).setCollapse( true );
6498 n = t8.getNode( "a" );
6499 while ( n != null ) {
6501 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6503 if ( ext.size() != 7 ) {
6506 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6509 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6512 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6513 System.out.println( "2 fail" );
6516 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6519 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6522 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6525 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6530 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6531 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6533 t9.getNode( "gh" ).setCollapse( true );
6534 n = t9.getNode( "a" );
6535 while ( n != null ) {
6537 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6539 if ( ext.size() != 7 ) {
6542 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6545 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6548 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6551 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6554 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6557 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6560 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6565 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6566 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6568 t10.getNode( "gh" ).setCollapse( true );
6569 t10.getNode( "g" ).setCollapse( true );
6570 t10.getNode( "h" ).setCollapse( true );
6571 n = t10.getNode( "a" );
6572 while ( n != null ) {
6574 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6576 if ( ext.size() != 7 ) {
6579 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6582 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6585 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6588 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6591 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6594 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6597 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6602 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6603 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6605 t11.getNode( "gh" ).setCollapse( true );
6606 t11.getNode( "fgh" ).setCollapse( true );
6607 n = t11.getNode( "a" );
6608 while ( n != null ) {
6610 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6612 if ( ext.size() != 6 ) {
6615 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6618 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6621 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6624 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6627 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6630 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6635 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6636 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6638 t12.getNode( "gh" ).setCollapse( true );
6639 t12.getNode( "fgh" ).setCollapse( true );
6640 t12.getNode( "g" ).setCollapse( true );
6641 t12.getNode( "h" ).setCollapse( true );
6642 t12.getNode( "f" ).setCollapse( true );
6643 n = t12.getNode( "a" );
6644 while ( n != null ) {
6646 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6648 if ( ext.size() != 6 ) {
6651 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6654 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6657 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6660 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6663 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6666 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6671 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6672 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6674 t13.getNode( "ab" ).setCollapse( true );
6675 t13.getNode( "b" ).setCollapse( true );
6676 t13.getNode( "fgh" ).setCollapse( true );
6677 t13.getNode( "gh" ).setCollapse( true );
6678 n = t13.getNode( "ab" );
6679 while ( n != null ) {
6681 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6683 if ( ext.size() != 5 ) {
6686 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6689 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6692 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6695 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6698 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6703 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6704 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6706 t14.getNode( "ab" ).setCollapse( true );
6707 t14.getNode( "a" ).setCollapse( true );
6708 t14.getNode( "fgh" ).setCollapse( true );
6709 t14.getNode( "gh" ).setCollapse( true );
6710 n = t14.getNode( "ab" );
6711 while ( n != null ) {
6713 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6715 if ( ext.size() != 5 ) {
6718 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6721 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6724 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6727 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6730 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6735 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" );
6736 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6738 t15.getNode( "ab" ).setCollapse( true );
6739 t15.getNode( "a" ).setCollapse( true );
6740 t15.getNode( "fgh" ).setCollapse( true );
6741 t15.getNode( "gh" ).setCollapse( true );
6742 n = t15.getNode( "ab" );
6743 while ( n != null ) {
6745 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6747 if ( ext.size() != 6 ) {
6750 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6753 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6756 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6759 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6762 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6765 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6770 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" );
6771 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6773 t16.getNode( "ab" ).setCollapse( true );
6774 t16.getNode( "a" ).setCollapse( true );
6775 t16.getNode( "fgh" ).setCollapse( true );
6776 t16.getNode( "gh" ).setCollapse( true );
6777 t16.getNode( "cd" ).setCollapse( true );
6778 t16.getNode( "cde" ).setCollapse( true );
6779 t16.getNode( "d" ).setCollapse( true );
6780 t16.getNode( "x" ).setCollapse( true );
6781 n = t16.getNode( "ab" );
6782 while ( n != null ) {
6784 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6786 if ( ext.size() != 4 ) {
6789 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6792 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6795 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6798 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6802 catch ( final Exception e ) {
6803 e.printStackTrace( System.out );
6809 private static boolean testNexusCharactersParsing() {
6811 final NexusCharactersParser parser = new NexusCharactersParser();
6812 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6814 String[] labels = parser.getCharStateLabels();
6815 if ( labels.length != 7 ) {
6818 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6821 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6824 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6827 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6830 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6833 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6836 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6839 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6841 labels = parser.getCharStateLabels();
6842 if ( labels.length != 7 ) {
6845 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6848 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6851 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6854 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6857 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6860 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6863 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6867 catch ( final Exception e ) {
6868 e.printStackTrace( System.out );
6874 private static boolean testNexusMatrixParsing() {
6876 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6877 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6879 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6880 if ( m.getNumberOfCharacters() != 9 ) {
6883 if ( m.getNumberOfIdentifiers() != 5 ) {
6886 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6889 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6892 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6895 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6898 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6901 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6904 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6907 // if ( labels.length != 7 ) {
6910 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6913 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6916 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6919 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6922 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6925 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6928 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6931 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6933 // labels = parser.getCharStateLabels();
6934 // if ( labels.length != 7 ) {
6937 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6940 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6943 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6946 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6949 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6952 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6955 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6959 catch ( final Exception e ) {
6960 e.printStackTrace( System.out );
6966 private static boolean testNexusTreeParsing() {
6968 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6969 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6970 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6971 if ( phylogenies.length != 1 ) {
6974 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6977 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6981 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6982 if ( phylogenies.length != 1 ) {
6985 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6988 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6992 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6993 if ( phylogenies.length != 1 ) {
6996 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6999 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7002 if ( phylogenies[ 0 ].isRooted() ) {
7006 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7007 if ( phylogenies.length != 18 ) {
7010 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7013 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7016 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7019 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7022 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7025 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7028 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7031 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7034 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7037 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7040 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7043 if ( phylogenies[ 8 ].isRooted() ) {
7046 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7049 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7052 if ( !phylogenies[ 9 ].isRooted() ) {
7055 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7058 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7061 if ( !phylogenies[ 10 ].isRooted() ) {
7064 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7067 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7070 if ( phylogenies[ 11 ].isRooted() ) {
7073 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7076 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7079 if ( !phylogenies[ 12 ].isRooted() ) {
7082 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7085 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7088 if ( !phylogenies[ 13 ].isRooted() ) {
7091 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7094 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7097 if ( !phylogenies[ 14 ].isRooted() ) {
7100 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7103 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7106 if ( phylogenies[ 15 ].isRooted() ) {
7109 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7112 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7115 if ( !phylogenies[ 16 ].isRooted() ) {
7118 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7121 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7124 if ( phylogenies[ 17 ].isRooted() ) {
7127 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7130 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7132 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7133 if ( phylogenies.length != 9 ) {
7136 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7137 .getDistanceToParent() ) ) {
7140 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7141 .getDistanceToParent() ) ) {
7144 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7147 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7150 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7153 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7156 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7160 catch ( final Exception e ) {
7161 e.printStackTrace( System.out );
7167 private static boolean testNexusTreeParsingIterating() {
7169 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7170 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7171 if ( !p.hasNext() ) {
7174 Phylogeny phy = p.next();
7175 if ( phy == null ) {
7178 if ( phy.getNumberOfExternalNodes() != 25 ) {
7181 if ( !phy.getName().equals( "" ) ) {
7184 if ( p.hasNext() ) {
7188 if ( phy != null ) {
7193 if ( !p.hasNext() ) {
7197 if ( phy == null ) {
7200 if ( phy.getNumberOfExternalNodes() != 25 ) {
7203 if ( !phy.getName().equals( "" ) ) {
7206 if ( p.hasNext() ) {
7210 if ( phy != null ) {
7214 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7215 if ( !p.hasNext() ) {
7219 if ( phy == null ) {
7222 if ( phy.getNumberOfExternalNodes() != 10 ) {
7225 if ( !phy.getName().equals( "name" ) ) {
7228 if ( p.hasNext() ) {
7232 if ( phy != null ) {
7237 if ( !p.hasNext() ) {
7241 if ( phy == null ) {
7244 if ( phy.getNumberOfExternalNodes() != 10 ) {
7247 if ( !phy.getName().equals( "name" ) ) {
7250 if ( p.hasNext() ) {
7254 if ( phy != null ) {
7258 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7259 if ( !p.hasNext() ) {
7263 if ( phy == null ) {
7266 if ( phy.getNumberOfExternalNodes() != 3 ) {
7269 if ( !phy.getName().equals( "" ) ) {
7272 if ( phy.isRooted() ) {
7275 if ( p.hasNext() ) {
7279 if ( phy != null ) {
7284 if ( !p.hasNext() ) {
7288 if ( phy == null ) {
7291 if ( phy.getNumberOfExternalNodes() != 3 ) {
7294 if ( !phy.getName().equals( "" ) ) {
7297 if ( p.hasNext() ) {
7301 if ( phy != null ) {
7305 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7306 if ( !p.hasNext() ) {
7311 if ( phy == null ) {
7314 if ( phy.getNumberOfExternalNodes() != 10 ) {
7317 if ( !phy.getName().equals( "tree 0" ) ) {
7321 if ( !p.hasNext() ) {
7325 if ( phy == null ) {
7328 if ( phy.getNumberOfExternalNodes() != 10 ) {
7331 if ( !phy.getName().equals( "tree 1" ) ) {
7335 if ( !p.hasNext() ) {
7339 if ( phy == null ) {
7342 if ( phy.getNumberOfExternalNodes() != 3 ) {
7343 System.out.println( phy.toString() );
7346 if ( !phy.getName().equals( "" ) ) {
7349 if ( phy.isRooted() ) {
7353 if ( !p.hasNext() ) {
7357 if ( phy == null ) {
7360 if ( phy.getNumberOfExternalNodes() != 4 ) {
7363 if ( !phy.getName().equals( "" ) ) {
7366 if ( !phy.isRooted() ) {
7370 if ( !p.hasNext() ) {
7374 if ( phy == null ) {
7377 if ( phy.getNumberOfExternalNodes() != 5 ) {
7378 System.out.println( phy.getNumberOfExternalNodes() );
7381 if ( !phy.getName().equals( "" ) ) {
7384 if ( !phy.isRooted() ) {
7388 if ( !p.hasNext() ) {
7392 if ( phy == null ) {
7395 if ( phy.getNumberOfExternalNodes() != 3 ) {
7398 if ( !phy.getName().equals( "" ) ) {
7401 if ( phy.isRooted() ) {
7405 if ( !p.hasNext() ) {
7409 if ( phy == null ) {
7412 if ( phy.getNumberOfExternalNodes() != 2 ) {
7415 if ( !phy.getName().equals( "" ) ) {
7418 if ( !phy.isRooted() ) {
7422 if ( !p.hasNext() ) {
7426 if ( phy.getNumberOfExternalNodes() != 3 ) {
7429 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7432 if ( !phy.isRooted() ) {
7436 if ( !p.hasNext() ) {
7440 if ( phy.getNumberOfExternalNodes() != 3 ) {
7443 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7446 if ( !phy.getName().equals( "tree 8" ) ) {
7450 if ( !p.hasNext() ) {
7454 if ( phy.getNumberOfExternalNodes() != 3 ) {
7457 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7460 if ( !phy.getName().equals( "tree 9" ) ) {
7464 if ( !p.hasNext() ) {
7468 if ( phy.getNumberOfExternalNodes() != 3 ) {
7471 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7474 if ( !phy.getName().equals( "tree 10" ) ) {
7477 if ( !phy.isRooted() ) {
7481 if ( !p.hasNext() ) {
7485 if ( phy.getNumberOfExternalNodes() != 3 ) {
7488 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7491 if ( !phy.getName().equals( "tree 11" ) ) {
7494 if ( phy.isRooted() ) {
7498 if ( !p.hasNext() ) {
7502 if ( phy.getNumberOfExternalNodes() != 3 ) {
7505 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7508 if ( !phy.getName().equals( "tree 12" ) ) {
7511 if ( !phy.isRooted() ) {
7515 if ( !p.hasNext() ) {
7519 if ( phy.getNumberOfExternalNodes() != 3 ) {
7522 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7525 if ( !phy.getName().equals( "tree 13" ) ) {
7528 if ( !phy.isRooted() ) {
7532 if ( !p.hasNext() ) {
7536 if ( phy.getNumberOfExternalNodes() != 10 ) {
7537 System.out.println( phy.getNumberOfExternalNodes() );
7542 .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;" ) ) {
7543 System.out.println( phy.toNewHampshire() );
7546 if ( !phy.getName().equals( "tree 14" ) ) {
7549 if ( !phy.isRooted() ) {
7553 if ( !p.hasNext() ) {
7557 if ( phy.getNumberOfExternalNodes() != 10 ) {
7558 System.out.println( phy.getNumberOfExternalNodes() );
7563 .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;" ) ) {
7564 System.out.println( phy.toNewHampshire() );
7567 if ( !phy.getName().equals( "tree 15" ) ) {
7570 if ( phy.isRooted() ) {
7574 if ( !p.hasNext() ) {
7578 if ( phy.getNumberOfExternalNodes() != 10 ) {
7579 System.out.println( phy.getNumberOfExternalNodes() );
7584 .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;" ) ) {
7585 System.out.println( phy.toNewHampshire() );
7588 if ( !phy.getName().equals( "tree 16" ) ) {
7591 if ( !phy.isRooted() ) {
7595 if ( !p.hasNext() ) {
7599 if ( phy.getNumberOfExternalNodes() != 10 ) {
7600 System.out.println( phy.getNumberOfExternalNodes() );
7605 .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;" ) ) {
7606 System.out.println( phy.toNewHampshire() );
7609 if ( !phy.getName().equals( "tree 17" ) ) {
7612 if ( phy.isRooted() ) {
7616 if ( p.hasNext() ) {
7620 if ( phy != null ) {
7625 if ( !p.hasNext() ) {
7629 if ( phy == null ) {
7632 if ( phy.getNumberOfExternalNodes() != 10 ) {
7635 if ( !phy.getName().equals( "tree 0" ) ) {
7639 if ( !p.hasNext() ) {
7643 if ( phy == null ) {
7646 if ( phy.getNumberOfExternalNodes() != 10 ) {
7649 if ( !phy.getName().equals( "tree 1" ) ) {
7653 if ( !p.hasNext() ) {
7657 if ( phy == null ) {
7660 if ( phy.getNumberOfExternalNodes() != 3 ) {
7663 if ( !phy.getName().equals( "" ) ) {
7666 if ( phy.isRooted() ) {
7670 if ( !p.hasNext() ) {
7674 if ( phy == null ) {
7677 if ( phy.getNumberOfExternalNodes() != 4 ) {
7680 if ( !phy.getName().equals( "" ) ) {
7683 if ( !phy.isRooted() ) {
7687 if ( !p.hasNext() ) {
7691 if ( phy == null ) {
7694 if ( phy.getNumberOfExternalNodes() != 5 ) {
7695 System.out.println( phy.getNumberOfExternalNodes() );
7698 if ( !phy.getName().equals( "" ) ) {
7701 if ( !phy.isRooted() ) {
7705 if ( !p.hasNext() ) {
7709 if ( phy == null ) {
7712 if ( phy.getNumberOfExternalNodes() != 3 ) {
7715 if ( !phy.getName().equals( "" ) ) {
7718 if ( phy.isRooted() ) {
7722 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7723 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7725 if ( !p2.hasNext() ) {
7729 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7732 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7736 if ( !p2.hasNext() ) {
7741 if ( !p2.hasNext() ) {
7746 if ( !p2.hasNext() ) {
7751 if ( !p2.hasNext() ) {
7756 if ( !p2.hasNext() ) {
7761 if ( !p2.hasNext() ) {
7766 if ( !p2.hasNext() ) {
7771 if ( !p2.hasNext() ) {
7775 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7778 if ( p2.hasNext() ) {
7782 if ( phy != null ) {
7787 if ( !p2.hasNext() ) {
7791 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7794 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7798 catch ( final Exception e ) {
7799 e.printStackTrace( System.out );
7805 private static boolean testNexusTreeParsingTranslating() {
7807 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7808 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7809 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7810 if ( phylogenies.length != 1 ) {
7813 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7816 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7819 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7822 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7825 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7826 .equals( "Aranaeus" ) ) {
7830 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7831 if ( phylogenies.length != 3 ) {
7834 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7837 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7840 if ( phylogenies[ 0 ].isRooted() ) {
7843 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7846 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7849 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7850 .equals( "Aranaeus" ) ) {
7853 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7856 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7859 if ( phylogenies[ 1 ].isRooted() ) {
7862 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7865 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7868 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7869 .equals( "Aranaeus" ) ) {
7872 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7875 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7878 if ( !phylogenies[ 2 ].isRooted() ) {
7881 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7884 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7887 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7888 .equals( "Aranaeus" ) ) {
7892 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7893 if ( phylogenies.length != 3 ) {
7896 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7899 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7902 if ( phylogenies[ 0 ].isRooted() ) {
7905 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7908 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7911 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7912 .equals( "Aranaeus" ) ) {
7915 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7918 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7921 if ( phylogenies[ 1 ].isRooted() ) {
7924 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7927 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7930 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7931 .equals( "Aranaeus" ) ) {
7934 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7937 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7940 if ( !phylogenies[ 2 ].isRooted() ) {
7943 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7946 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7949 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7950 .equals( "Aranaeus" ) ) {
7953 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7954 if ( phylogenies.length != 3 ) {
7957 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7962 catch ( final Exception e ) {
7963 e.printStackTrace( System.out );
7969 private static boolean testNHParsing() {
7971 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7972 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7973 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7976 final NHXParser nhxp = new NHXParser();
7977 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7978 nhxp.setReplaceUnderscores( true );
7979 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7980 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7983 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7986 final Phylogeny p1b = factory
7987 .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 ",
7988 new NHXParser() )[ 0 ];
7989 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7992 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7995 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7996 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7997 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7998 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7999 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8000 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8001 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8002 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8003 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8004 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8005 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8006 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8007 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8009 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8012 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8015 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8018 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8021 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8022 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8023 final String p16_S = "((A,B),C)";
8024 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8025 if ( p16.length != 1 ) {
8028 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8031 final String p17_S = "(C,(A,B))";
8032 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8033 if ( p17.length != 1 ) {
8036 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8039 final String p18_S = "((A,B),(C,D))";
8040 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8041 if ( p18.length != 1 ) {
8044 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8047 final String p19_S = "(((A,B),C),D)";
8048 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8049 if ( p19.length != 1 ) {
8052 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8055 final String p20_S = "(A,(B,(C,D)))";
8056 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8057 if ( p20.length != 1 ) {
8060 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8063 final String p21_S = "(A,(B,(C,(D,E))))";
8064 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8065 if ( p21.length != 1 ) {
8068 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8071 final String p22_S = "((((A,B),C),D),E)";
8072 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8073 if ( p22.length != 1 ) {
8076 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8079 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8080 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8081 if ( p23.length != 1 ) {
8082 System.out.println( "xl=" + p23.length );
8086 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8089 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8090 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8091 if ( p24.length != 1 ) {
8094 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8097 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8098 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8099 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8100 if ( p241.length != 2 ) {
8103 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8106 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8109 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8110 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8111 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8112 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8113 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8114 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8115 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8116 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8117 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8118 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8121 final String p26_S = "(A,B)ab";
8122 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8123 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8126 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8127 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8128 if ( p27s.length != 1 ) {
8129 System.out.println( "xxl=" + p27s.length );
8133 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8134 System.out.println( p27s[ 0 ].toNewHampshireX() );
8138 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8140 if ( p27.length != 1 ) {
8141 System.out.println( "yl=" + p27.length );
8145 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8146 System.out.println( p27[ 0 ].toNewHampshireX() );
8150 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8151 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8152 final String p28_S3 = "(A,B)ab";
8153 final String p28_S4 = "((((A,B),C),D),;E;)";
8154 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8156 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8159 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8162 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8165 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8168 if ( p28.length != 4 ) {
8171 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";
8172 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8173 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8176 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";
8177 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8178 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8181 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8182 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8183 if ( ( p32.length != 0 ) ) {
8186 final String p33_S = "A";
8187 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8188 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8191 final String p34_S = "B;";
8192 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8193 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8196 final String p35_S = "B:0.2";
8197 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8198 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8201 final String p36_S = "(A)";
8202 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8203 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8206 final String p37_S = "((A))";
8207 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8208 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8211 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8212 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8213 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8216 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8217 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8218 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8221 final String p40_S = "(A,B,C)";
8222 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8223 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8226 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8227 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8228 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8231 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8232 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8233 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8236 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)";
8237 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8238 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8241 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)))";
8242 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8243 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8246 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8247 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8248 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8251 final String p46_S = "";
8252 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8253 if ( p46.length != 0 ) {
8256 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8257 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8260 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8261 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8264 final Phylogeny p49 = factory
8265 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8266 new NHXParser() )[ 0 ];
8267 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8270 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8271 if ( p50.getNode( "A" ) == null ) {
8274 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8275 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8278 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8281 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8282 .equals( "((A,B)88:2.0,C);" ) ) {
8285 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8286 if ( p51.getNode( "A(A" ) == null ) {
8289 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8290 if ( p52.getNode( "A(A" ) == null ) {
8293 final Phylogeny p53 = factory
8294 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8295 new NHXParser() )[ 0 ];
8296 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8299 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8300 if ( p54.getNode( "A" ) == null ) {
8303 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8306 final Phylogeny p55 = factory
8307 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1x\":0.0798012);" ),
8308 new NHXParser() )[ 0 ];
8311 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,lcl|HPV66_L1.1x:0.0798012);" ) ) {
8312 System.out.println( p55.toNewHampshire() );
8315 final Phylogeny p56 = factory
8316 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8317 new NHXParser() )[ 0 ];
8320 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8321 System.out.println( p56.toNewHampshire() );
8324 final Phylogeny p57 = factory
8325 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8326 new NHXParser() )[ 0 ];
8329 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8330 System.out.println( p56.toNewHampshire() );
8333 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8334 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8335 if ( !p58.toNewHampshire().equals( s58 ) ) {
8336 System.out.println( p58.toNewHampshire() );
8339 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8340 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8341 if ( !p59.toNewHampshire().equals( s59 ) ) {
8342 System.out.println( p59.toNewHampshire() );
8345 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8346 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8347 if ( !p60.toNewHampshire().equals( s60 ) ) {
8348 System.out.println( p60.toNewHampshire() );
8351 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8352 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8353 if ( !p61.toNewHampshire()
8354 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8355 System.out.println( p61.toNewHampshire() );
8359 catch ( final Exception e ) {
8360 e.printStackTrace( System.out );
8366 private static boolean testNHParsingIter() {
8368 final String p0_str = "(A,B);";
8369 final NHXParser p = new NHXParser();
8370 p.setSource( p0_str );
8371 if ( !p.hasNext() ) {
8374 final Phylogeny p0 = p.next();
8375 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8376 System.out.println( p0.toNewHampshire() );
8379 if ( p.hasNext() ) {
8382 if ( p.next() != null ) {
8386 final String p00_str = "(A,B)root;";
8387 p.setSource( p00_str );
8388 final Phylogeny p00 = p.next();
8389 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8390 System.out.println( p00.toNewHampshire() );
8394 final String p000_str = "A;";
8395 p.setSource( p000_str );
8396 final Phylogeny p000 = p.next();
8397 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8398 System.out.println( p000.toNewHampshire() );
8402 final String p0000_str = "A";
8403 p.setSource( p0000_str );
8404 final Phylogeny p0000 = p.next();
8405 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8406 System.out.println( p0000.toNewHampshire() );
8410 p.setSource( "(A)" );
8411 final Phylogeny p00000 = p.next();
8412 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8413 System.out.println( p00000.toNewHampshire() );
8417 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8418 p.setSource( p1_str );
8419 if ( !p.hasNext() ) {
8422 final Phylogeny p1_0 = p.next();
8423 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8424 System.out.println( p1_0.toNewHampshire() );
8427 if ( !p.hasNext() ) {
8430 final Phylogeny p1_1 = p.next();
8431 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8432 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8435 if ( !p.hasNext() ) {
8438 final Phylogeny p1_2 = p.next();
8439 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8440 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8443 if ( !p.hasNext() ) {
8446 final Phylogeny p1_3 = p.next();
8447 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8448 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8451 if ( p.hasNext() ) {
8454 if ( p.next() != null ) {
8458 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8459 p.setSource( p2_str );
8460 if ( !p.hasNext() ) {
8463 Phylogeny p2_0 = p.next();
8464 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8465 System.out.println( p2_0.toNewHampshire() );
8468 if ( !p.hasNext() ) {
8471 Phylogeny p2_1 = p.next();
8472 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8473 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8476 if ( !p.hasNext() ) {
8479 Phylogeny p2_2 = p.next();
8480 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8481 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8484 if ( !p.hasNext() ) {
8487 Phylogeny p2_3 = p.next();
8488 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8489 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8492 if ( !p.hasNext() ) {
8495 Phylogeny p2_4 = p.next();
8496 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8497 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8500 if ( p.hasNext() ) {
8503 if ( p.next() != null ) {
8508 if ( !p.hasNext() ) {
8512 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8513 System.out.println( p2_0.toNewHampshire() );
8516 if ( !p.hasNext() ) {
8520 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8521 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8524 if ( !p.hasNext() ) {
8528 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8529 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8532 if ( !p.hasNext() ) {
8536 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8537 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8540 if ( !p.hasNext() ) {
8544 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8545 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8548 if ( p.hasNext() ) {
8551 if ( p.next() != null ) {
8555 final String p3_str = "((A,B),C)abc";
8556 p.setSource( p3_str );
8557 if ( !p.hasNext() ) {
8560 final Phylogeny p3_0 = p.next();
8561 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8564 if ( p.hasNext() ) {
8567 if ( p.next() != null ) {
8571 final String p4_str = "((A,B)ab,C)abc";
8572 p.setSource( p4_str );
8573 if ( !p.hasNext() ) {
8576 final Phylogeny p4_0 = p.next();
8577 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8580 if ( p.hasNext() ) {
8583 if ( p.next() != null ) {
8587 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8588 p.setSource( p5_str );
8589 if ( !p.hasNext() ) {
8592 final Phylogeny p5_0 = p.next();
8593 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8596 if ( p.hasNext() ) {
8599 if ( p.next() != null ) {
8603 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8604 p.setSource( p6_str );
8605 if ( !p.hasNext() ) {
8608 Phylogeny p6_0 = p.next();
8609 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8612 if ( p.hasNext() ) {
8615 if ( p.next() != null ) {
8619 if ( !p.hasNext() ) {
8623 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8626 if ( p.hasNext() ) {
8629 if ( p.next() != null ) {
8633 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8634 p.setSource( p7_str );
8635 if ( !p.hasNext() ) {
8638 Phylogeny p7_0 = p.next();
8639 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8642 if ( p.hasNext() ) {
8645 if ( p.next() != null ) {
8649 if ( !p.hasNext() ) {
8653 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8656 if ( p.hasNext() ) {
8659 if ( p.next() != null ) {
8663 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8664 p.setSource( p8_str );
8665 if ( !p.hasNext() ) {
8668 Phylogeny p8_0 = p.next();
8669 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8672 if ( !p.hasNext() ) {
8675 if ( !p.hasNext() ) {
8678 Phylogeny p8_1 = p.next();
8679 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8682 if ( p.hasNext() ) {
8685 if ( p.next() != null ) {
8689 if ( !p.hasNext() ) {
8693 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8696 if ( !p.hasNext() ) {
8700 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8703 if ( p.hasNext() ) {
8706 if ( p.next() != null ) {
8712 if ( p.hasNext() ) {
8716 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8717 if ( !p.hasNext() ) {
8720 Phylogeny p_27 = p.next();
8721 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8722 System.out.println( p_27.toNewHampshireX() );
8726 if ( p.hasNext() ) {
8729 if ( p.next() != null ) {
8733 if ( !p.hasNext() ) {
8737 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8738 System.out.println( p_27.toNewHampshireX() );
8742 if ( p.hasNext() ) {
8745 if ( p.next() != null ) {
8749 final String p30_str = "(A,B);(C,D)";
8750 final NHXParser p30 = new NHXParser();
8751 p30.setSource( p30_str );
8752 if ( !p30.hasNext() ) {
8755 Phylogeny phy30 = p30.next();
8756 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8757 System.out.println( phy30.toNewHampshire() );
8760 if ( !p30.hasNext() ) {
8763 Phylogeny phy301 = p30.next();
8764 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8765 System.out.println( phy301.toNewHampshire() );
8768 if ( p30.hasNext() ) {
8771 if ( p30.hasNext() ) {
8774 if ( p30.next() != null ) {
8777 if ( p30.next() != null ) {
8781 if ( !p30.hasNext() ) {
8785 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8786 System.out.println( phy30.toNewHampshire() );
8789 if ( !p30.hasNext() ) {
8792 phy301 = p30.next();
8793 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8794 System.out.println( phy301.toNewHampshire() );
8797 if ( p30.hasNext() ) {
8800 if ( p30.hasNext() ) {
8803 if ( p30.next() != null ) {
8806 if ( p30.next() != null ) {
8810 catch ( final Exception e ) {
8811 e.printStackTrace( System.out );
8817 private static boolean testNHXconversion() {
8819 final PhylogenyNode n1 = new PhylogenyNode();
8820 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8821 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8822 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8823 final PhylogenyNode n5 = PhylogenyNode
8824 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8825 final PhylogenyNode n6 = PhylogenyNode
8826 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8827 if ( !n1.toNewHampshireX().equals( "" ) ) {
8830 if ( !n2.toNewHampshireX().equals( "" ) ) {
8833 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8836 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8839 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8842 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8843 System.out.println( n6.toNewHampshireX() );
8846 final PhylogenyNode n7 = new PhylogenyNode();
8847 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8848 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8849 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8850 System.out.println( n7
8851 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8855 catch ( final Exception e ) {
8856 e.printStackTrace( System.out );
8862 private static boolean testNHXNodeParsing() {
8864 final PhylogenyNode n1 = new PhylogenyNode();
8865 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8866 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8867 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8868 final PhylogenyNode n5 = PhylogenyNode
8869 .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]" );
8870 if ( !n3.getName().equals( "n3" ) ) {
8873 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8876 if ( n3.isDuplication() ) {
8879 if ( n3.isHasAssignedEvent() ) {
8882 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8885 if ( !n4.getName().equals( "n4" ) ) {
8888 if ( n4.getDistanceToParent() != 0.01 ) {
8891 if ( !n5.getName().equals( "n5" ) ) {
8894 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8897 if ( n5.getDistanceToParent() != 0.1 ) {
8900 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8903 if ( !n5.isDuplication() ) {
8906 if ( !n5.isHasAssignedEvent() ) {
8909 final PhylogenyNode n8 = PhylogenyNode
8910 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8911 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8912 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8915 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8918 final PhylogenyNode n9 = PhylogenyNode
8919 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8920 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8921 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8924 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8927 final PhylogenyNode n10 = PhylogenyNode
8928 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8929 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8932 final PhylogenyNode n20 = PhylogenyNode
8933 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8934 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8937 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8940 final PhylogenyNode n20x = PhylogenyNode
8941 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8942 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8945 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8948 final PhylogenyNode n20xx = PhylogenyNode
8949 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8950 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8953 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8956 final PhylogenyNode n20xxx = PhylogenyNode
8957 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8958 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8961 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8964 final PhylogenyNode n20xxxx = PhylogenyNode
8965 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8966 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8969 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8972 final PhylogenyNode n21 = PhylogenyNode
8973 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8974 if ( !n21.getName().equals( "N21_PIG" ) ) {
8977 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8980 final PhylogenyNode n21x = PhylogenyNode
8981 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8982 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8985 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8988 final PhylogenyNode n22 = PhylogenyNode
8989 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8990 if ( !n22.getName().equals( "n22/PIG" ) ) {
8993 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8996 final PhylogenyNode n23 = PhylogenyNode
8997 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8998 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9001 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9004 final PhylogenyNode a = PhylogenyNode
9005 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9006 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9009 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9012 final PhylogenyNode c1 = PhylogenyNode
9013 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9014 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9015 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9018 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9021 final PhylogenyNode c2 = PhylogenyNode
9022 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9023 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9024 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9027 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9030 final PhylogenyNode e3 = PhylogenyNode
9031 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9032 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9035 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9038 final PhylogenyNode n11 = PhylogenyNode
9039 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9040 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9041 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9044 if ( n11.getDistanceToParent() != 0.4 ) {
9047 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9050 final PhylogenyNode n12 = PhylogenyNode
9051 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9052 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9053 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9056 if ( n12.getDistanceToParent() != 0.4 ) {
9059 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9062 final PhylogenyNode o = PhylogenyNode
9063 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9064 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9067 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9070 if ( n1.getName().compareTo( "" ) != 0 ) {
9073 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9076 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9079 if ( n2.getName().compareTo( "" ) != 0 ) {
9082 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9085 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9088 final PhylogenyNode n00 = PhylogenyNode
9089 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9090 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9093 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9096 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9097 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9100 final PhylogenyNode n13 = PhylogenyNode
9101 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9102 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9105 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9108 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9111 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9114 final PhylogenyNode n14 = PhylogenyNode
9115 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9116 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9119 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9122 final PhylogenyNode n15 = PhylogenyNode
9123 .createInstanceFromNhxString( "something_wicked[123]",
9124 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9125 if ( !n15.getName().equals( "something_wicked" ) ) {
9128 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9131 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9134 final PhylogenyNode n16 = PhylogenyNode
9135 .createInstanceFromNhxString( "something_wicked2[9]",
9136 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9137 if ( !n16.getName().equals( "something_wicked2" ) ) {
9140 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9143 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9146 final PhylogenyNode n17 = PhylogenyNode
9147 .createInstanceFromNhxString( "something_wicked3[a]",
9148 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9149 if ( !n17.getName().equals( "something_wicked3" ) ) {
9152 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9155 final PhylogenyNode n18 = PhylogenyNode
9156 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9157 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9160 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9163 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9166 final PhylogenyNode n19 = PhylogenyNode
9167 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9168 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9171 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9174 final PhylogenyNode n30 = PhylogenyNode
9175 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9176 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9177 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9180 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9183 final PhylogenyNode n31 = PhylogenyNode
9184 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9185 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9186 if ( n31.getNodeData().isHasTaxonomy() ) {
9189 final PhylogenyNode n32 = PhylogenyNode
9190 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9191 if ( n32.getNodeData().isHasTaxonomy() ) {
9194 final PhylogenyNode n40 = PhylogenyNode
9195 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9196 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9199 final PhylogenyNode n41 = PhylogenyNode
9200 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9201 if ( n41.getNodeData().isHasTaxonomy() ) {
9204 final PhylogenyNode n42 = PhylogenyNode
9205 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9206 if ( n42.getNodeData().isHasTaxonomy() ) {
9209 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9210 NHXParser.TAXONOMY_EXTRACTION.NO );
9211 if ( n43.getNodeData().isHasTaxonomy() ) {
9214 final PhylogenyNode n44 = PhylogenyNode
9215 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9216 if ( n44.getNodeData().isHasTaxonomy() ) {
9220 catch ( final Exception e ) {
9221 e.printStackTrace( System.out );
9227 private static boolean testNHXParsing() {
9229 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9230 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9231 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9234 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]";
9235 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9236 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9239 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]";
9240 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9241 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9244 final Phylogeny[] p3 = factory
9245 .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]",
9247 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9250 final Phylogeny[] p4 = factory
9251 .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(]",
9253 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9256 final Phylogeny[] p5 = factory
9257 .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(((]",
9259 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9262 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)";
9263 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)";
9264 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9265 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9268 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)))";
9269 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)))";
9270 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9271 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9274 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]) ))[,,, ])))))))";
9275 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9276 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9277 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9280 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9281 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9284 final Phylogeny p10 = factory
9285 .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]",
9286 new NHXParser() )[ 0 ];
9287 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9290 final Phylogeny p11 = factory
9291 .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]",
9292 new NHXParser() )[ 0 ];
9293 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9297 catch ( final Exception e ) {
9298 e.printStackTrace( System.out );
9304 private static boolean testNHXParsingMB() {
9306 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9307 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9308 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9309 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9310 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9311 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9312 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9313 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9314 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9315 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9316 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9319 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9322 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9323 0.1100000000000000e+00 ) ) {
9326 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9329 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9332 final Phylogeny p2 = factory
9333 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9334 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9335 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9336 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9337 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9338 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9339 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9340 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9341 + "7.369400000000000e-02}])",
9342 new NHXParser() )[ 0 ];
9343 if ( p2.getNode( "1" ) == null ) {
9346 if ( p2.getNode( "2" ) == null ) {
9350 catch ( final Exception e ) {
9351 e.printStackTrace( System.out );
9358 private static boolean testNHXParsingQuotes() {
9360 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9361 final NHXParser p = new NHXParser();
9362 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9363 if ( phylogenies_0.length != 5 ) {
9366 final Phylogeny phy = phylogenies_0[ 4 ];
9367 if ( phy.getNumberOfExternalNodes() != 7 ) {
9370 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9373 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9376 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9377 .getScientificName().equals( "hsapiens" ) ) {
9380 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9383 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9386 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9389 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9392 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9395 final NHXParser p1p = new NHXParser();
9396 p1p.setIgnoreQuotes( true );
9397 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9398 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9401 final NHXParser p2p = new NHXParser();
9402 p1p.setIgnoreQuotes( false );
9403 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9404 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9407 final NHXParser p3p = new NHXParser();
9408 p3p.setIgnoreQuotes( false );
9409 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9410 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9413 final NHXParser p4p = new NHXParser();
9414 p4p.setIgnoreQuotes( false );
9415 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9416 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9419 final Phylogeny p10 = factory
9420 .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]",
9421 new NHXParser() )[ 0 ];
9422 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]";
9423 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9426 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9427 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9430 final Phylogeny p12 = factory
9431 .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]",
9432 new NHXParser() )[ 0 ];
9433 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]";
9434 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9437 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9438 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9441 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;";
9442 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9445 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9446 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9450 catch ( final Exception e ) {
9451 e.printStackTrace( System.out );
9457 private static boolean testNodeRemoval() {
9459 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9460 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9461 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9462 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9465 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9466 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9467 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9470 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9471 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9472 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9476 catch ( final Exception e ) {
9477 e.printStackTrace( System.out );
9483 private static boolean testPhylogenyBranch() {
9485 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9486 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9487 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9488 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9489 if ( !a1b1.equals( a1b1 ) ) {
9492 if ( !a1b1.equals( b1a1 ) ) {
9495 if ( !b1a1.equals( a1b1 ) ) {
9498 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9499 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9500 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9501 if ( a1_b1.equals( b1_a1 ) ) {
9504 if ( a1_b1.equals( a1_b1_ ) ) {
9507 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9508 if ( !a1_b1.equals( b1_a1_ ) ) {
9511 if ( a1_b1_.equals( b1_a1_ ) ) {
9514 if ( !a1_b1_.equals( b1_a1 ) ) {
9518 catch ( final Exception e ) {
9519 e.printStackTrace( System.out );
9525 private static boolean testPhyloXMLparsingOfDistributionElement() {
9527 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9528 PhyloXmlParser xml_parser = null;
9530 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9532 catch ( final Exception e ) {
9533 // Do nothing -- means were not running from jar.
9535 if ( xml_parser == null ) {
9536 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9537 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9538 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9541 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9544 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9546 if ( xml_parser.getErrorCount() > 0 ) {
9547 System.out.println( xml_parser.getErrorMessages().toString() );
9550 if ( phylogenies_0.length != 1 ) {
9553 final Phylogeny t1 = phylogenies_0[ 0 ];
9554 PhylogenyNode n = null;
9555 Distribution d = null;
9556 n = t1.getNode( "root node" );
9557 if ( !n.getNodeData().isHasDistribution() ) {
9560 if ( n.getNodeData().getDistributions().size() != 1 ) {
9563 d = n.getNodeData().getDistribution();
9564 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9567 if ( d.getPoints().size() != 1 ) {
9570 if ( d.getPolygons() != null ) {
9573 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9576 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9579 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9582 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9585 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9588 n = t1.getNode( "node a" );
9589 if ( !n.getNodeData().isHasDistribution() ) {
9592 if ( n.getNodeData().getDistributions().size() != 2 ) {
9595 d = n.getNodeData().getDistribution( 1 );
9596 if ( !d.getDesc().equals( "San Diego" ) ) {
9599 if ( d.getPoints().size() != 1 ) {
9602 if ( d.getPolygons() != null ) {
9605 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9608 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9611 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9614 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9617 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9620 n = t1.getNode( "node bb" );
9621 if ( !n.getNodeData().isHasDistribution() ) {
9624 if ( n.getNodeData().getDistributions().size() != 1 ) {
9627 d = n.getNodeData().getDistribution( 0 );
9628 if ( d.getPoints().size() != 3 ) {
9631 if ( d.getPolygons().size() != 2 ) {
9634 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9637 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9640 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9643 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9646 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9649 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9652 Polygon p = d.getPolygons().get( 0 );
9653 if ( p.getPoints().size() != 3 ) {
9656 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9659 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9662 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9665 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9668 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9671 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9674 p = d.getPolygons().get( 1 );
9675 if ( p.getPoints().size() != 3 ) {
9678 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9681 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9684 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9688 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9689 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9690 if ( rt.length != 1 ) {
9693 final Phylogeny t1_rt = rt[ 0 ];
9694 n = t1_rt.getNode( "root node" );
9695 if ( !n.getNodeData().isHasDistribution() ) {
9698 if ( n.getNodeData().getDistributions().size() != 1 ) {
9701 d = n.getNodeData().getDistribution();
9702 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9705 if ( d.getPoints().size() != 1 ) {
9708 if ( d.getPolygons() != null ) {
9711 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9714 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9717 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9720 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9723 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9726 n = t1_rt.getNode( "node a" );
9727 if ( !n.getNodeData().isHasDistribution() ) {
9730 if ( n.getNodeData().getDistributions().size() != 2 ) {
9733 d = n.getNodeData().getDistribution( 1 );
9734 if ( !d.getDesc().equals( "San Diego" ) ) {
9737 if ( d.getPoints().size() != 1 ) {
9740 if ( d.getPolygons() != null ) {
9743 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9746 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9749 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9752 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9755 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9758 n = t1_rt.getNode( "node bb" );
9759 if ( !n.getNodeData().isHasDistribution() ) {
9762 if ( n.getNodeData().getDistributions().size() != 1 ) {
9765 d = n.getNodeData().getDistribution( 0 );
9766 if ( d.getPoints().size() != 3 ) {
9769 if ( d.getPolygons().size() != 2 ) {
9772 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9775 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9778 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9781 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9784 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9787 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9790 p = d.getPolygons().get( 0 );
9791 if ( p.getPoints().size() != 3 ) {
9794 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9797 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9800 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9803 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9806 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9809 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9812 p = d.getPolygons().get( 1 );
9813 if ( p.getPoints().size() != 3 ) {
9816 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9819 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9822 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9826 catch ( final Exception e ) {
9827 e.printStackTrace( System.out );
9833 private static boolean testPostOrderIterator() {
9835 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9836 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9837 PhylogenyNodeIterator it0;
9838 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9841 for( it0.reset(); it0.hasNext(); ) {
9844 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9845 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9846 if ( !it.next().getName().equals( "A" ) ) {
9849 if ( !it.next().getName().equals( "B" ) ) {
9852 if ( !it.next().getName().equals( "ab" ) ) {
9855 if ( !it.next().getName().equals( "C" ) ) {
9858 if ( !it.next().getName().equals( "D" ) ) {
9861 if ( !it.next().getName().equals( "cd" ) ) {
9864 if ( !it.next().getName().equals( "abcd" ) ) {
9867 if ( !it.next().getName().equals( "E" ) ) {
9870 if ( !it.next().getName().equals( "F" ) ) {
9873 if ( !it.next().getName().equals( "ef" ) ) {
9876 if ( !it.next().getName().equals( "G" ) ) {
9879 if ( !it.next().getName().equals( "H" ) ) {
9882 if ( !it.next().getName().equals( "gh" ) ) {
9885 if ( !it.next().getName().equals( "efgh" ) ) {
9888 if ( !it.next().getName().equals( "r" ) ) {
9891 if ( it.hasNext() ) {
9895 catch ( final Exception e ) {
9896 e.printStackTrace( System.out );
9902 private static boolean testPreOrderIterator() {
9904 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9905 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9906 PhylogenyNodeIterator it0;
9907 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9910 for( it0.reset(); it0.hasNext(); ) {
9913 PhylogenyNodeIterator it = t0.iteratorPreorder();
9914 if ( !it.next().getName().equals( "r" ) ) {
9917 if ( !it.next().getName().equals( "ab" ) ) {
9920 if ( !it.next().getName().equals( "A" ) ) {
9923 if ( !it.next().getName().equals( "B" ) ) {
9926 if ( !it.next().getName().equals( "cd" ) ) {
9929 if ( !it.next().getName().equals( "C" ) ) {
9932 if ( !it.next().getName().equals( "D" ) ) {
9935 if ( it.hasNext() ) {
9938 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9939 it = t1.iteratorPreorder();
9940 if ( !it.next().getName().equals( "r" ) ) {
9943 if ( !it.next().getName().equals( "abcd" ) ) {
9946 if ( !it.next().getName().equals( "ab" ) ) {
9949 if ( !it.next().getName().equals( "A" ) ) {
9952 if ( !it.next().getName().equals( "B" ) ) {
9955 if ( !it.next().getName().equals( "cd" ) ) {
9958 if ( !it.next().getName().equals( "C" ) ) {
9961 if ( !it.next().getName().equals( "D" ) ) {
9964 if ( !it.next().getName().equals( "efgh" ) ) {
9967 if ( !it.next().getName().equals( "ef" ) ) {
9970 if ( !it.next().getName().equals( "E" ) ) {
9973 if ( !it.next().getName().equals( "F" ) ) {
9976 if ( !it.next().getName().equals( "gh" ) ) {
9979 if ( !it.next().getName().equals( "G" ) ) {
9982 if ( !it.next().getName().equals( "H" ) ) {
9985 if ( it.hasNext() ) {
9989 catch ( final Exception e ) {
9990 e.printStackTrace( System.out );
9996 private static boolean testPropertiesMap() {
9998 final PropertiesMap pm = new PropertiesMap();
9999 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10000 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10001 final Property p2 = new Property( "something:else",
10003 "improbable:research",
10006 pm.addProperty( p0 );
10007 pm.addProperty( p1 );
10008 pm.addProperty( p2 );
10009 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10012 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10015 if ( pm.getProperties().size() != 3 ) {
10018 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10021 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10024 if ( pm.getProperties().size() != 3 ) {
10027 pm.removeProperty( "dimensions:diameter" );
10028 if ( pm.getProperties().size() != 2 ) {
10031 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10034 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10038 catch ( final Exception e ) {
10039 e.printStackTrace( System.out );
10045 private static boolean testProteinId() {
10047 final ProteinId id1 = new ProteinId( "a" );
10048 final ProteinId id2 = new ProteinId( "a" );
10049 final ProteinId id3 = new ProteinId( "A" );
10050 final ProteinId id4 = new ProteinId( "b" );
10051 if ( !id1.equals( id1 ) ) {
10054 if ( id1.getId().equals( "x" ) ) {
10057 if ( id1.getId().equals( null ) ) {
10060 if ( !id1.equals( id2 ) ) {
10063 if ( id1.equals( id3 ) ) {
10066 if ( id1.hashCode() != id1.hashCode() ) {
10069 if ( id1.hashCode() != id2.hashCode() ) {
10072 if ( id1.hashCode() == id3.hashCode() ) {
10075 if ( id1.compareTo( id1 ) != 0 ) {
10078 if ( id1.compareTo( id2 ) != 0 ) {
10081 if ( id1.compareTo( id3 ) != 0 ) {
10084 if ( id1.compareTo( id4 ) >= 0 ) {
10087 if ( id4.compareTo( id1 ) <= 0 ) {
10090 if ( !id4.getId().equals( "b" ) ) {
10093 final ProteinId id5 = new ProteinId( " C " );
10094 if ( !id5.getId().equals( "C" ) ) {
10097 if ( id5.equals( id1 ) ) {
10101 catch ( final Exception e ) {
10102 e.printStackTrace( System.out );
10108 private static boolean testReIdMethods() {
10110 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10111 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10112 final long count = PhylogenyNode.getNodeCount();
10113 p.levelOrderReID();
10114 if ( p.getNode( "r" ).getId() != count ) {
10117 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10120 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10123 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10126 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10129 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10132 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10135 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10138 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10141 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10144 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10147 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10150 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10153 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10156 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10160 catch ( final Exception e ) {
10161 e.printStackTrace( System.out );
10167 private static boolean testRerooting() {
10169 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10170 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",
10171 new NHXParser() )[ 0 ];
10172 if ( !t1.isRooted() ) {
10175 t1.reRoot( t1.getNode( "D" ) );
10176 t1.reRoot( t1.getNode( "CD" ) );
10177 t1.reRoot( t1.getNode( "A" ) );
10178 t1.reRoot( t1.getNode( "B" ) );
10179 t1.reRoot( t1.getNode( "AB" ) );
10180 t1.reRoot( t1.getNode( "D" ) );
10181 t1.reRoot( t1.getNode( "C" ) );
10182 t1.reRoot( t1.getNode( "CD" ) );
10183 t1.reRoot( t1.getNode( "A" ) );
10184 t1.reRoot( t1.getNode( "B" ) );
10185 t1.reRoot( t1.getNode( "AB" ) );
10186 t1.reRoot( t1.getNode( "D" ) );
10187 t1.reRoot( t1.getNode( "D" ) );
10188 t1.reRoot( t1.getNode( "C" ) );
10189 t1.reRoot( t1.getNode( "A" ) );
10190 t1.reRoot( t1.getNode( "B" ) );
10191 t1.reRoot( t1.getNode( "AB" ) );
10192 t1.reRoot( t1.getNode( "C" ) );
10193 t1.reRoot( t1.getNode( "D" ) );
10194 t1.reRoot( t1.getNode( "CD" ) );
10195 t1.reRoot( t1.getNode( "D" ) );
10196 t1.reRoot( t1.getNode( "A" ) );
10197 t1.reRoot( t1.getNode( "B" ) );
10198 t1.reRoot( t1.getNode( "AB" ) );
10199 t1.reRoot( t1.getNode( "C" ) );
10200 t1.reRoot( t1.getNode( "D" ) );
10201 t1.reRoot( t1.getNode( "CD" ) );
10202 t1.reRoot( t1.getNode( "D" ) );
10203 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10206 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10209 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10212 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10215 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10218 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10221 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",
10222 new NHXParser() )[ 0 ];
10223 t2.reRoot( t2.getNode( "A" ) );
10224 t2.reRoot( t2.getNode( "D" ) );
10225 t2.reRoot( t2.getNode( "ABC" ) );
10226 t2.reRoot( t2.getNode( "A" ) );
10227 t2.reRoot( t2.getNode( "B" ) );
10228 t2.reRoot( t2.getNode( "D" ) );
10229 t2.reRoot( t2.getNode( "C" ) );
10230 t2.reRoot( t2.getNode( "ABC" ) );
10231 t2.reRoot( t2.getNode( "A" ) );
10232 t2.reRoot( t2.getNode( "B" ) );
10233 t2.reRoot( t2.getNode( "AB" ) );
10234 t2.reRoot( t2.getNode( "AB" ) );
10235 t2.reRoot( t2.getNode( "D" ) );
10236 t2.reRoot( t2.getNode( "C" ) );
10237 t2.reRoot( t2.getNode( "B" ) );
10238 t2.reRoot( t2.getNode( "AB" ) );
10239 t2.reRoot( t2.getNode( "D" ) );
10240 t2.reRoot( t2.getNode( "D" ) );
10241 t2.reRoot( t2.getNode( "ABC" ) );
10242 t2.reRoot( t2.getNode( "A" ) );
10243 t2.reRoot( t2.getNode( "B" ) );
10244 t2.reRoot( t2.getNode( "AB" ) );
10245 t2.reRoot( t2.getNode( "D" ) );
10246 t2.reRoot( t2.getNode( "C" ) );
10247 t2.reRoot( t2.getNode( "ABC" ) );
10248 t2.reRoot( t2.getNode( "A" ) );
10249 t2.reRoot( t2.getNode( "B" ) );
10250 t2.reRoot( t2.getNode( "AB" ) );
10251 t2.reRoot( t2.getNode( "D" ) );
10252 t2.reRoot( t2.getNode( "D" ) );
10253 t2.reRoot( t2.getNode( "C" ) );
10254 t2.reRoot( t2.getNode( "A" ) );
10255 t2.reRoot( t2.getNode( "B" ) );
10256 t2.reRoot( t2.getNode( "AB" ) );
10257 t2.reRoot( t2.getNode( "C" ) );
10258 t2.reRoot( t2.getNode( "D" ) );
10259 t2.reRoot( t2.getNode( "ABC" ) );
10260 t2.reRoot( t2.getNode( "D" ) );
10261 t2.reRoot( t2.getNode( "A" ) );
10262 t2.reRoot( t2.getNode( "B" ) );
10263 t2.reRoot( t2.getNode( "AB" ) );
10264 t2.reRoot( t2.getNode( "C" ) );
10265 t2.reRoot( t2.getNode( "D" ) );
10266 t2.reRoot( t2.getNode( "ABC" ) );
10267 t2.reRoot( t2.getNode( "D" ) );
10268 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10271 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10274 t2.reRoot( t2.getNode( "ABC" ) );
10275 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10278 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10281 t2.reRoot( t2.getNode( "AB" ) );
10282 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10285 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10288 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10291 t2.reRoot( t2.getNode( "AB" ) );
10292 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10295 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10298 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10301 t2.reRoot( t2.getNode( "D" ) );
10302 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10305 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10308 t2.reRoot( t2.getNode( "ABC" ) );
10309 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10312 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10315 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10316 new NHXParser() )[ 0 ];
10317 t3.reRoot( t3.getNode( "B" ) );
10318 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10321 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10324 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10327 t3.reRoot( t3.getNode( "B" ) );
10328 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10331 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10334 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10337 t3.reRoot( t3.getRoot() );
10338 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10341 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10344 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10348 catch ( final Exception e ) {
10349 e.printStackTrace( System.out );
10355 private static boolean testSDIse() {
10357 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10358 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10359 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10360 gene1.setRooted( true );
10361 species1.setRooted( true );
10362 final SDI sdi = new SDI( gene1, species1 );
10363 if ( !gene1.getRoot().isDuplication() ) {
10366 final Phylogeny species2 = factory
10367 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10368 new NHXParser() )[ 0 ];
10369 final Phylogeny gene2 = factory
10370 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10371 new NHXParser() )[ 0 ];
10372 species2.setRooted( true );
10373 gene2.setRooted( true );
10374 final SDI sdi2 = new SDI( gene2, species2 );
10375 if ( sdi2.getDuplicationsSum() != 0 ) {
10378 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10381 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10384 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10387 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10390 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10393 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10396 final Phylogeny species3 = factory
10397 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10398 new NHXParser() )[ 0 ];
10399 final Phylogeny gene3 = factory
10400 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10401 new NHXParser() )[ 0 ];
10402 species3.setRooted( true );
10403 gene3.setRooted( true );
10404 final SDI sdi3 = new SDI( gene3, species3 );
10405 if ( sdi3.getDuplicationsSum() != 1 ) {
10408 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10411 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10414 final Phylogeny species4 = factory
10415 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10416 new NHXParser() )[ 0 ];
10417 final Phylogeny gene4 = factory
10418 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10419 new NHXParser() )[ 0 ];
10420 species4.setRooted( true );
10421 gene4.setRooted( true );
10422 final SDI sdi4 = new SDI( gene4, species4 );
10423 if ( sdi4.getDuplicationsSum() != 1 ) {
10426 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10429 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10432 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10435 if ( species4.getNumberOfExternalNodes() != 6 ) {
10438 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10441 final Phylogeny species5 = factory
10442 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10443 new NHXParser() )[ 0 ];
10444 final Phylogeny gene5 = factory
10445 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10446 new NHXParser() )[ 0 ];
10447 species5.setRooted( true );
10448 gene5.setRooted( true );
10449 final SDI sdi5 = new SDI( gene5, species5 );
10450 if ( sdi5.getDuplicationsSum() != 2 ) {
10453 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10456 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10459 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10462 if ( species5.getNumberOfExternalNodes() != 6 ) {
10465 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10468 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10469 // Conjecture for Comparing Molecular Phylogenies"
10470 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10471 final Phylogeny species6 = factory
10472 .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,"
10473 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10474 new NHXParser() )[ 0 ];
10475 final Phylogeny gene6 = factory
10476 .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,"
10477 + "((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,"
10478 + "(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;",
10479 new NHXParser() )[ 0 ];
10480 species6.setRooted( true );
10481 gene6.setRooted( true );
10482 final SDI sdi6 = new SDI( gene6, species6 );
10483 if ( sdi6.getDuplicationsSum() != 3 ) {
10486 if ( !gene6.getNode( "r" ).isDuplication() ) {
10489 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10492 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10495 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10498 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10501 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10504 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10507 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10510 sdi6.computeMappingCostL();
10511 if ( sdi6.computeMappingCostL() != 17 ) {
10514 if ( species6.getNumberOfExternalNodes() != 9 ) {
10517 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10520 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10521 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10522 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10523 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10524 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10525 species7.setRooted( true );
10526 final Phylogeny gene7_1 = Test
10527 .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])" );
10528 gene7_1.setRooted( true );
10529 final SDI sdi7 = new SDI( gene7_1, species7 );
10530 if ( sdi7.getDuplicationsSum() != 0 ) {
10533 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10536 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10539 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10542 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10545 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10548 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10551 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10554 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10557 final Phylogeny gene7_2 = Test
10558 .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])" );
10559 gene7_2.setRooted( true );
10560 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10561 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10564 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10567 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10570 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10573 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10576 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10579 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10582 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10585 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10588 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10592 catch ( final Exception e ) {
10598 private static boolean testSDIunrooted() {
10600 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10601 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10602 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10603 final Iterator<PhylogenyBranch> iter = l.iterator();
10604 PhylogenyBranch br = iter.next();
10605 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10608 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10612 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10615 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10619 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10622 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10626 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10629 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10633 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10636 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10640 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10643 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10647 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10650 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10654 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10657 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10661 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10664 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10668 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10671 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10675 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10678 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10682 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10685 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10689 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10692 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10696 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10699 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10703 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10706 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10709 if ( iter.hasNext() ) {
10712 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10713 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10714 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10716 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10719 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10723 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10726 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10730 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10733 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10736 if ( iter1.hasNext() ) {
10739 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10740 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10741 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10743 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10746 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10750 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10753 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10757 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10760 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10763 if ( iter2.hasNext() ) {
10766 final Phylogeny species0 = factory
10767 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10768 new NHXParser() )[ 0 ];
10769 final Phylogeny gene1 = factory
10770 .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])",
10771 new NHXParser() )[ 0 ];
10772 species0.setRooted( true );
10773 gene1.setRooted( true );
10774 final SDIR sdi_unrooted = new SDIR();
10775 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10776 if ( sdi_unrooted.getCount() != 1 ) {
10779 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10782 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10785 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10788 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10791 final Phylogeny gene2 = factory
10792 .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])",
10793 new NHXParser() )[ 0 ];
10794 gene2.setRooted( true );
10795 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10796 if ( sdi_unrooted.getCount() != 1 ) {
10799 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10802 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10805 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10808 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10811 final Phylogeny species6 = factory
10812 .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,"
10813 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10814 new NHXParser() )[ 0 ];
10815 final Phylogeny gene6 = factory
10816 .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],"
10817 + "(((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],"
10818 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10819 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10820 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10821 new NHXParser() )[ 0 ];
10822 species6.setRooted( true );
10823 gene6.setRooted( true );
10824 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10825 if ( sdi_unrooted.getCount() != 1 ) {
10828 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10831 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10834 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10837 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10840 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10843 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10846 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10849 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10852 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10855 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10858 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10861 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10865 final Phylogeny species7 = factory
10866 .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,"
10867 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10868 new NHXParser() )[ 0 ];
10869 final Phylogeny gene7 = factory
10870 .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],"
10871 + "(((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],"
10872 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10873 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10874 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10875 new NHXParser() )[ 0 ];
10876 species7.setRooted( true );
10877 gene7.setRooted( true );
10878 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10879 if ( sdi_unrooted.getCount() != 1 ) {
10882 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10885 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10888 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10891 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10894 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10897 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10900 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10903 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10906 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10909 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10912 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10915 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10919 final Phylogeny species8 = factory
10920 .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,"
10921 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10922 new NHXParser() )[ 0 ];
10923 final Phylogeny gene8 = factory
10924 .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],"
10925 + "(((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],"
10926 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10927 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10928 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10929 new NHXParser() )[ 0 ];
10930 species8.setRooted( true );
10931 gene8.setRooted( true );
10932 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10933 if ( sdi_unrooted.getCount() != 1 ) {
10936 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10939 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10942 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10945 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10948 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10951 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10954 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10957 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10960 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10963 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10966 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10969 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10974 catch ( final Exception e ) {
10975 e.printStackTrace( System.out );
10981 private static boolean testSequenceDbWsTools1() {
10983 final PhylogenyNode n = new PhylogenyNode();
10984 n.setName( "NP_001025424" );
10985 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10986 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10987 || !acc.getValue().equals( "NP_001025424" ) ) {
10990 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10991 acc = SequenceDbWsTools.obtainSeqAccession( n );
10992 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10993 || !acc.getValue().equals( "NP_001025424" ) ) {
10996 n.setName( "NP_001025424.1" );
10997 acc = SequenceDbWsTools.obtainSeqAccession( n );
10998 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10999 || !acc.getValue().equals( "NP_001025424" ) ) {
11002 n.setName( "NM_001030253" );
11003 acc = SequenceDbWsTools.obtainSeqAccession( n );
11004 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11005 || !acc.getValue().equals( "NM_001030253" ) ) {
11008 n.setName( "BCL2_HUMAN" );
11009 acc = SequenceDbWsTools.obtainSeqAccession( n );
11010 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11011 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11012 System.out.println( acc.toString() );
11015 n.setName( "P10415" );
11016 acc = SequenceDbWsTools.obtainSeqAccession( n );
11017 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11018 || !acc.getValue().equals( "P10415" ) ) {
11019 System.out.println( acc.toString() );
11022 n.setName( " P10415 " );
11023 acc = SequenceDbWsTools.obtainSeqAccession( n );
11024 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11025 || !acc.getValue().equals( "P10415" ) ) {
11026 System.out.println( acc.toString() );
11029 n.setName( "_P10415|" );
11030 acc = SequenceDbWsTools.obtainSeqAccession( n );
11031 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11032 || !acc.getValue().equals( "P10415" ) ) {
11033 System.out.println( acc.toString() );
11036 n.setName( "AY695820" );
11037 acc = SequenceDbWsTools.obtainSeqAccession( n );
11038 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11039 || !acc.getValue().equals( "AY695820" ) ) {
11040 System.out.println( acc.toString() );
11043 n.setName( "_AY695820_" );
11044 acc = SequenceDbWsTools.obtainSeqAccession( n );
11045 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11046 || !acc.getValue().equals( "AY695820" ) ) {
11047 System.out.println( acc.toString() );
11050 n.setName( "AAA59452" );
11051 acc = SequenceDbWsTools.obtainSeqAccession( n );
11052 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11053 || !acc.getValue().equals( "AAA59452" ) ) {
11054 System.out.println( acc.toString() );
11057 n.setName( "_AAA59452_" );
11058 acc = SequenceDbWsTools.obtainSeqAccession( n );
11059 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11060 || !acc.getValue().equals( "AAA59452" ) ) {
11061 System.out.println( acc.toString() );
11064 n.setName( "AAA59452.1" );
11065 acc = SequenceDbWsTools.obtainSeqAccession( n );
11066 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11067 || !acc.getValue().equals( "AAA59452.1" ) ) {
11068 System.out.println( acc.toString() );
11071 n.setName( "_AAA59452.1_" );
11072 acc = SequenceDbWsTools.obtainSeqAccession( n );
11073 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11074 || !acc.getValue().equals( "AAA59452.1" ) ) {
11075 System.out.println( acc.toString() );
11078 n.setName( "GI:94894583" );
11079 acc = SequenceDbWsTools.obtainSeqAccession( n );
11080 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11081 || !acc.getValue().equals( "94894583" ) ) {
11082 System.out.println( acc.toString() );
11085 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11086 acc = SequenceDbWsTools.obtainSeqAccession( n );
11087 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11088 || !acc.getValue().equals( "71845847" ) ) {
11089 System.out.println( acc.toString() );
11092 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11093 acc = SequenceDbWsTools.obtainSeqAccession( n );
11094 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11095 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11096 System.out.println( acc.toString() );
11100 catch ( final Exception e ) {
11106 private static boolean testSequenceDbWsTools2() {
11108 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11109 SequenceDbWsTools.obtainSeqInformation( n1 );
11110 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11113 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11116 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11119 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11122 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11123 SequenceDbWsTools.obtainSeqInformation( n2 );
11124 if ( !n2.getNodeData().getSequence().getName()
11125 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11128 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11131 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11134 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11137 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11138 SequenceDbWsTools.obtainSeqInformation( n3 );
11139 if ( !n3.getNodeData().getSequence().getName()
11140 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11143 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11146 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11149 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11153 catch ( final IOException e ) {
11154 System.out.println();
11155 System.out.println( "the following might be due to absence internet connection:" );
11156 e.printStackTrace( System.out );
11159 catch ( final Exception e ) {
11160 e.printStackTrace();
11166 private static boolean testSequenceIdParsing() {
11168 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11169 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11170 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11171 if ( id != null ) {
11172 System.out.println( "value =" + id.getValue() );
11173 System.out.println( "provider=" + id.getSource() );
11178 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11179 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11180 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11181 if ( id != null ) {
11182 System.out.println( "value =" + id.getValue() );
11183 System.out.println( "provider=" + id.getSource() );
11188 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11189 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11190 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11191 if ( id != null ) {
11192 System.out.println( "value =" + id.getValue() );
11193 System.out.println( "provider=" + id.getSource() );
11198 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11199 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11200 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11201 if ( id != null ) {
11202 System.out.println( "value =" + id.getValue() );
11203 System.out.println( "provider=" + id.getSource() );
11208 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11209 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11210 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11211 if ( id != null ) {
11212 System.out.println( "value =" + id.getValue() );
11213 System.out.println( "provider=" + id.getSource() );
11218 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11219 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11220 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11221 if ( id != null ) {
11222 System.out.println( "value =" + id.getValue() );
11223 System.out.println( "provider=" + id.getSource() );
11228 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11229 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11230 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11231 if ( id != null ) {
11232 System.out.println( "value =" + id.getValue() );
11233 System.out.println( "provider=" + id.getSource() );
11238 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11239 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11240 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11241 if ( id != null ) {
11242 System.out.println( "value =" + id.getValue() );
11243 System.out.println( "provider=" + id.getSource() );
11248 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11249 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11250 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11251 if ( id != null ) {
11252 System.out.println( "value =" + id.getValue() );
11253 System.out.println( "provider=" + id.getSource() );
11258 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11259 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11260 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11261 if ( id != null ) {
11262 System.out.println( "value =" + id.getValue() );
11263 System.out.println( "provider=" + id.getSource() );
11267 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11268 if ( id != null ) {
11269 System.out.println( "value =" + id.getValue() );
11270 System.out.println( "provider=" + id.getSource() );
11274 catch ( final Exception e ) {
11275 e.printStackTrace( System.out );
11281 private static boolean testSequenceWriter() {
11283 final String n = ForesterUtil.LINE_SEPARATOR;
11284 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11287 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11290 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11293 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11296 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11297 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11300 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11301 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11305 catch ( final Exception e ) {
11306 e.printStackTrace();
11312 private static boolean testSpecies() {
11314 final Species s1 = new BasicSpecies( "a" );
11315 final Species s2 = new BasicSpecies( "a" );
11316 final Species s3 = new BasicSpecies( "A" );
11317 final Species s4 = new BasicSpecies( "b" );
11318 if ( !s1.equals( s1 ) ) {
11321 if ( s1.getSpeciesId().equals( "x" ) ) {
11324 if ( s1.getSpeciesId().equals( null ) ) {
11327 if ( !s1.equals( s2 ) ) {
11330 if ( s1.equals( s3 ) ) {
11333 if ( s1.hashCode() != s1.hashCode() ) {
11336 if ( s1.hashCode() != s2.hashCode() ) {
11339 if ( s1.hashCode() == s3.hashCode() ) {
11342 if ( s1.compareTo( s1 ) != 0 ) {
11345 if ( s1.compareTo( s2 ) != 0 ) {
11348 if ( s1.compareTo( s3 ) != 0 ) {
11351 if ( s1.compareTo( s4 ) >= 0 ) {
11354 if ( s4.compareTo( s1 ) <= 0 ) {
11357 if ( !s4.getSpeciesId().equals( "b" ) ) {
11360 final Species s5 = new BasicSpecies( " C " );
11361 if ( !s5.getSpeciesId().equals( "C" ) ) {
11364 if ( s5.equals( s1 ) ) {
11368 catch ( final Exception e ) {
11369 e.printStackTrace( System.out );
11375 private static boolean testSplit() {
11377 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11378 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11379 //Archaeopteryx.createApplication( p0 );
11380 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11381 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11382 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11383 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11384 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11385 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11386 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11387 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11388 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11389 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11390 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11391 // System.out.println( s0.toString() );
11393 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11396 if ( s0.match( query_nodes ) ) {
11399 query_nodes = new HashSet<PhylogenyNode>();
11400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11405 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11406 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11407 if ( !s0.match( query_nodes ) ) {
11411 query_nodes = new HashSet<PhylogenyNode>();
11412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11415 if ( !s0.match( query_nodes ) ) {
11419 query_nodes = new HashSet<PhylogenyNode>();
11420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11423 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11424 if ( !s0.match( query_nodes ) ) {
11428 query_nodes = new HashSet<PhylogenyNode>();
11429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11430 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11431 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11432 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11433 if ( !s0.match( query_nodes ) ) {
11437 query_nodes = new HashSet<PhylogenyNode>();
11438 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11439 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11440 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11441 if ( !s0.match( query_nodes ) ) {
11445 query_nodes = new HashSet<PhylogenyNode>();
11446 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11447 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11448 if ( !s0.match( query_nodes ) ) {
11452 query_nodes = new HashSet<PhylogenyNode>();
11453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11455 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11456 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11458 if ( !s0.match( query_nodes ) ) {
11462 query_nodes = new HashSet<PhylogenyNode>();
11463 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11466 if ( !s0.match( query_nodes ) ) {
11470 query_nodes = new HashSet<PhylogenyNode>();
11471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11475 if ( !s0.match( query_nodes ) ) {
11479 query_nodes = new HashSet<PhylogenyNode>();
11480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11482 if ( s0.match( query_nodes ) ) {
11486 query_nodes = new HashSet<PhylogenyNode>();
11487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11491 if ( s0.match( query_nodes ) ) {
11495 query_nodes = new HashSet<PhylogenyNode>();
11496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11499 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11501 if ( s0.match( query_nodes ) ) {
11505 query_nodes = new HashSet<PhylogenyNode>();
11506 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11507 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11509 if ( s0.match( query_nodes ) ) {
11513 query_nodes = new HashSet<PhylogenyNode>();
11514 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11515 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11516 if ( s0.match( query_nodes ) ) {
11520 query_nodes = new HashSet<PhylogenyNode>();
11521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11522 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11523 if ( s0.match( query_nodes ) ) {
11527 query_nodes = new HashSet<PhylogenyNode>();
11528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11530 if ( s0.match( query_nodes ) ) {
11534 query_nodes = new HashSet<PhylogenyNode>();
11535 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11537 if ( s0.match( query_nodes ) ) {
11541 query_nodes = new HashSet<PhylogenyNode>();
11542 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11543 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11544 if ( s0.match( query_nodes ) ) {
11548 query_nodes = new HashSet<PhylogenyNode>();
11549 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11550 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11551 if ( s0.match( query_nodes ) ) {
11555 query_nodes = new HashSet<PhylogenyNode>();
11556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11558 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11559 if ( s0.match( query_nodes ) ) {
11563 query_nodes = new HashSet<PhylogenyNode>();
11564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11567 if ( s0.match( query_nodes ) ) {
11571 query_nodes = new HashSet<PhylogenyNode>();
11572 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11575 if ( s0.match( query_nodes ) ) {
11579 query_nodes = new HashSet<PhylogenyNode>();
11580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11582 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11583 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11584 if ( s0.match( query_nodes ) ) {
11588 // query_nodes = new HashSet<PhylogenyNode>();
11589 // query_nodes.add( new PhylogenyNode( "X" ) );
11590 // query_nodes.add( new PhylogenyNode( "Y" ) );
11591 // query_nodes.add( new PhylogenyNode( "A" ) );
11592 // query_nodes.add( new PhylogenyNode( "B" ) );
11593 // query_nodes.add( new PhylogenyNode( "C" ) );
11594 // query_nodes.add( new PhylogenyNode( "D" ) );
11595 // query_nodes.add( new PhylogenyNode( "E" ) );
11596 // query_nodes.add( new PhylogenyNode( "F" ) );
11597 // query_nodes.add( new PhylogenyNode( "G" ) );
11598 // if ( !s0.match( query_nodes ) ) {
11601 // query_nodes = new HashSet<PhylogenyNode>();
11602 // query_nodes.add( new PhylogenyNode( "X" ) );
11603 // query_nodes.add( new PhylogenyNode( "Y" ) );
11604 // query_nodes.add( new PhylogenyNode( "A" ) );
11605 // query_nodes.add( new PhylogenyNode( "B" ) );
11606 // query_nodes.add( new PhylogenyNode( "C" ) );
11607 // if ( !s0.match( query_nodes ) ) {
11611 // query_nodes = new HashSet<PhylogenyNode>();
11612 // query_nodes.add( new PhylogenyNode( "X" ) );
11613 // query_nodes.add( new PhylogenyNode( "Y" ) );
11614 // query_nodes.add( new PhylogenyNode( "D" ) );
11615 // query_nodes.add( new PhylogenyNode( "E" ) );
11616 // query_nodes.add( new PhylogenyNode( "F" ) );
11617 // query_nodes.add( new PhylogenyNode( "G" ) );
11618 // if ( !s0.match( query_nodes ) ) {
11622 // query_nodes = new HashSet<PhylogenyNode>();
11623 // query_nodes.add( new PhylogenyNode( "X" ) );
11624 // query_nodes.add( new PhylogenyNode( "Y" ) );
11625 // query_nodes.add( new PhylogenyNode( "A" ) );
11626 // query_nodes.add( new PhylogenyNode( "B" ) );
11627 // query_nodes.add( new PhylogenyNode( "C" ) );
11628 // query_nodes.add( new PhylogenyNode( "D" ) );
11629 // if ( !s0.match( query_nodes ) ) {
11633 // query_nodes = new HashSet<PhylogenyNode>();
11634 // query_nodes.add( new PhylogenyNode( "X" ) );
11635 // query_nodes.add( new PhylogenyNode( "Y" ) );
11636 // query_nodes.add( new PhylogenyNode( "E" ) );
11637 // query_nodes.add( new PhylogenyNode( "F" ) );
11638 // query_nodes.add( new PhylogenyNode( "G" ) );
11639 // if ( !s0.match( query_nodes ) ) {
11643 // query_nodes = new HashSet<PhylogenyNode>();
11644 // query_nodes.add( new PhylogenyNode( "X" ) );
11645 // query_nodes.add( new PhylogenyNode( "Y" ) );
11646 // query_nodes.add( new PhylogenyNode( "F" ) );
11647 // query_nodes.add( new PhylogenyNode( "G" ) );
11648 // if ( !s0.match( query_nodes ) ) {
11652 query_nodes = new HashSet<PhylogenyNode>();
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11657 if ( s0.match( query_nodes ) ) {
11661 query_nodes = new HashSet<PhylogenyNode>();
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11666 if ( s0.match( query_nodes ) ) {
11669 ///////////////////////////
11671 query_nodes = new HashSet<PhylogenyNode>();
11672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11676 if ( s0.match( query_nodes ) ) {
11680 query_nodes = new HashSet<PhylogenyNode>();
11681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11685 if ( s0.match( query_nodes ) ) {
11689 query_nodes = new HashSet<PhylogenyNode>();
11690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11694 if ( s0.match( query_nodes ) ) {
11698 query_nodes = new HashSet<PhylogenyNode>();
11699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11703 if ( s0.match( query_nodes ) ) {
11707 query_nodes = new HashSet<PhylogenyNode>();
11708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11712 if ( s0.match( query_nodes ) ) {
11716 query_nodes = new HashSet<PhylogenyNode>();
11717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11720 if ( s0.match( query_nodes ) ) {
11724 query_nodes = new HashSet<PhylogenyNode>();
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11730 if ( s0.match( query_nodes ) ) {
11734 query_nodes = new HashSet<PhylogenyNode>();
11735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11740 if ( s0.match( query_nodes ) ) {
11744 query_nodes = new HashSet<PhylogenyNode>();
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11749 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11750 if ( s0.match( query_nodes ) ) {
11754 query_nodes = new HashSet<PhylogenyNode>();
11755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11761 if ( s0.match( query_nodes ) ) {
11765 catch ( final Exception e ) {
11766 e.printStackTrace();
11772 private static boolean testSplitStrict() {
11774 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11775 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11776 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11777 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11778 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11779 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11780 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11781 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11782 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11783 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11784 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11785 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11788 if ( s0.match( query_nodes ) ) {
11791 query_nodes = new HashSet<PhylogenyNode>();
11792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11799 if ( !s0.match( query_nodes ) ) {
11803 query_nodes = new HashSet<PhylogenyNode>();
11804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11807 if ( !s0.match( query_nodes ) ) {
11811 query_nodes = new HashSet<PhylogenyNode>();
11812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11816 if ( !s0.match( query_nodes ) ) {
11820 query_nodes = new HashSet<PhylogenyNode>();
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11825 if ( !s0.match( query_nodes ) ) {
11829 query_nodes = new HashSet<PhylogenyNode>();
11830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11833 if ( !s0.match( query_nodes ) ) {
11837 query_nodes = new HashSet<PhylogenyNode>();
11838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11840 if ( !s0.match( query_nodes ) ) {
11844 query_nodes = new HashSet<PhylogenyNode>();
11845 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11850 if ( !s0.match( query_nodes ) ) {
11854 query_nodes = new HashSet<PhylogenyNode>();
11855 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11858 if ( !s0.match( query_nodes ) ) {
11862 query_nodes = new HashSet<PhylogenyNode>();
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11867 if ( !s0.match( query_nodes ) ) {
11871 query_nodes = new HashSet<PhylogenyNode>();
11872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11874 if ( s0.match( query_nodes ) ) {
11878 query_nodes = new HashSet<PhylogenyNode>();
11879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11883 if ( s0.match( query_nodes ) ) {
11887 query_nodes = new HashSet<PhylogenyNode>();
11888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11893 if ( s0.match( query_nodes ) ) {
11897 query_nodes = new HashSet<PhylogenyNode>();
11898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11901 if ( s0.match( query_nodes ) ) {
11905 query_nodes = new HashSet<PhylogenyNode>();
11906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11908 if ( s0.match( query_nodes ) ) {
11912 query_nodes = new HashSet<PhylogenyNode>();
11913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11915 if ( s0.match( query_nodes ) ) {
11919 query_nodes = new HashSet<PhylogenyNode>();
11920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11922 if ( s0.match( query_nodes ) ) {
11926 query_nodes = new HashSet<PhylogenyNode>();
11927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11929 if ( s0.match( query_nodes ) ) {
11933 query_nodes = new HashSet<PhylogenyNode>();
11934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11935 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11936 if ( s0.match( query_nodes ) ) {
11940 query_nodes = new HashSet<PhylogenyNode>();
11941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11943 if ( s0.match( query_nodes ) ) {
11947 query_nodes = new HashSet<PhylogenyNode>();
11948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11951 if ( s0.match( query_nodes ) ) {
11955 query_nodes = new HashSet<PhylogenyNode>();
11956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11959 if ( s0.match( query_nodes ) ) {
11963 query_nodes = new HashSet<PhylogenyNode>();
11964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11967 if ( s0.match( query_nodes ) ) {
11971 query_nodes = new HashSet<PhylogenyNode>();
11972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11976 if ( s0.match( query_nodes ) ) {
11980 catch ( final Exception e ) {
11981 e.printStackTrace();
11987 private static boolean testSubtreeDeletion() {
11989 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11990 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11991 t1.deleteSubtree( t1.getNode( "A" ), false );
11992 if ( t1.getNumberOfExternalNodes() != 5 ) {
11995 t1.toNewHampshireX();
11996 t1.deleteSubtree( t1.getNode( "E" ), false );
11997 if ( t1.getNumberOfExternalNodes() != 4 ) {
12000 t1.toNewHampshireX();
12001 t1.deleteSubtree( t1.getNode( "F" ), false );
12002 if ( t1.getNumberOfExternalNodes() != 3 ) {
12005 t1.toNewHampshireX();
12006 t1.deleteSubtree( t1.getNode( "D" ), false );
12007 t1.toNewHampshireX();
12008 if ( t1.getNumberOfExternalNodes() != 3 ) {
12011 t1.deleteSubtree( t1.getNode( "def" ), false );
12012 t1.toNewHampshireX();
12013 if ( t1.getNumberOfExternalNodes() != 2 ) {
12016 t1.deleteSubtree( t1.getNode( "B" ), false );
12017 t1.toNewHampshireX();
12018 if ( t1.getNumberOfExternalNodes() != 1 ) {
12021 t1.deleteSubtree( t1.getNode( "C" ), false );
12022 t1.toNewHampshireX();
12023 if ( t1.getNumberOfExternalNodes() != 1 ) {
12026 t1.deleteSubtree( t1.getNode( "abc" ), false );
12027 t1.toNewHampshireX();
12028 if ( t1.getNumberOfExternalNodes() != 1 ) {
12031 t1.deleteSubtree( t1.getNode( "r" ), false );
12032 if ( t1.getNumberOfExternalNodes() != 0 ) {
12035 if ( !t1.isEmpty() ) {
12038 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12039 t2.deleteSubtree( t2.getNode( "A" ), false );
12040 t2.toNewHampshireX();
12041 if ( t2.getNumberOfExternalNodes() != 5 ) {
12044 t2.deleteSubtree( t2.getNode( "abc" ), false );
12045 t2.toNewHampshireX();
12046 if ( t2.getNumberOfExternalNodes() != 3 ) {
12049 t2.deleteSubtree( t2.getNode( "def" ), false );
12050 t2.toNewHampshireX();
12051 if ( t2.getNumberOfExternalNodes() != 1 ) {
12055 catch ( final Exception e ) {
12056 e.printStackTrace( System.out );
12062 private static boolean testSupportCount() {
12064 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12065 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12066 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12067 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12068 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12069 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12070 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12072 SupportCount.count( t0_1, phylogenies_1, true, false );
12073 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12074 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12075 + "(((((A,B),C),D),E),((F,G),X))"
12076 + "(((((A,Y),B),C),D),((F,G),E))"
12077 + "(((((A,B),C),D),E),(F,G))"
12078 + "(((((A,B),C),D),E),(F,G))"
12079 + "(((((A,B),C),D),E),(F,G))"
12080 + "(((((A,B),C),D),E),(F,G),Z)"
12081 + "(((((A,B),C),D),E),(F,G))"
12082 + "((((((A,B),C),D),E),F),G)"
12083 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12085 SupportCount.count( t0_2, phylogenies_2, true, false );
12086 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12087 while ( it.hasNext() ) {
12088 final PhylogenyNode n = it.next();
12089 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12093 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12094 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12095 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12096 SupportCount.count( t0_3, phylogenies_3, true, false );
12097 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12098 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12101 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12104 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12107 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12110 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12113 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12116 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12119 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12122 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12125 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12128 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12129 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12130 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12131 SupportCount.count( t0_4, phylogenies_4, true, false );
12132 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12133 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12136 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12139 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12142 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12145 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12148 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12151 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12154 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12157 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12160 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12163 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12164 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12165 double d = SupportCount.compare( b1, a, true, true, true );
12166 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12169 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12170 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12171 d = SupportCount.compare( b2, a, true, true, true );
12172 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12175 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12176 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12177 d = SupportCount.compare( b3, a, true, true, true );
12178 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12181 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12182 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12183 d = SupportCount.compare( b4, a, true, true, false );
12184 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12188 catch ( final Exception e ) {
12189 e.printStackTrace( System.out );
12195 private static boolean testSupportTransfer() {
12197 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12198 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)",
12199 new NHXParser() )[ 0 ];
12200 final Phylogeny p2 = factory
12201 .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 ];
12202 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12205 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12208 support_transfer.moveBranchLengthsToBootstrap( p1 );
12209 support_transfer.transferSupportValues( p1, p2 );
12210 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12213 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12216 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12219 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12222 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12225 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12228 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12231 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12235 catch ( final Exception e ) {
12236 e.printStackTrace( System.out );
12242 private static boolean testTaxonomyExtraction() {
12244 final PhylogenyNode n0 = PhylogenyNode
12245 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12246 if ( n0.getNodeData().isHasTaxonomy() ) {
12249 final PhylogenyNode n1 = PhylogenyNode
12250 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12251 if ( n1.getNodeData().isHasTaxonomy() ) {
12252 System.out.println( n1.toString() );
12255 final PhylogenyNode n2x = PhylogenyNode
12256 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12257 if ( n2x.getNodeData().isHasTaxonomy() ) {
12260 final PhylogenyNode n3 = PhylogenyNode
12261 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12262 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12263 System.out.println( n3.toString() );
12266 final PhylogenyNode n4 = PhylogenyNode
12267 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12268 if ( n4.getNodeData().isHasTaxonomy() ) {
12269 System.out.println( n4.toString() );
12272 final PhylogenyNode n5 = PhylogenyNode
12273 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12274 if ( n5.getNodeData().isHasTaxonomy() ) {
12275 System.out.println( n5.toString() );
12278 final PhylogenyNode n6 = PhylogenyNode
12279 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12280 if ( n6.getNodeData().isHasTaxonomy() ) {
12281 System.out.println( n6.toString() );
12284 final PhylogenyNode n7 = PhylogenyNode
12285 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12286 if ( n7.getNodeData().isHasTaxonomy() ) {
12287 System.out.println( n7.toString() );
12290 final PhylogenyNode n8 = PhylogenyNode
12291 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12292 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12293 System.out.println( n8.toString() );
12296 final PhylogenyNode n9 = PhylogenyNode
12297 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12298 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12299 System.out.println( n9.toString() );
12302 final PhylogenyNode n10x = PhylogenyNode
12303 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12304 if ( n10x.getNodeData().isHasTaxonomy() ) {
12305 System.out.println( n10x.toString() );
12308 final PhylogenyNode n10xx = PhylogenyNode
12309 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12310 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12311 System.out.println( n10xx.toString() );
12314 final PhylogenyNode n10 = PhylogenyNode
12315 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12316 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12317 System.out.println( n10.toString() );
12320 final PhylogenyNode n11 = PhylogenyNode
12321 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12322 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12323 System.out.println( n11.toString() );
12326 final PhylogenyNode n12 = PhylogenyNode
12327 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12328 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12329 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12330 System.out.println( n12.toString() );
12333 final PhylogenyNode n13 = PhylogenyNode
12334 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12335 if ( n13.getNodeData().isHasTaxonomy() ) {
12336 System.out.println( n13.toString() );
12339 final PhylogenyNode n14 = PhylogenyNode
12340 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12341 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12342 System.out.println( n14.toString() );
12345 final PhylogenyNode n15 = PhylogenyNode
12346 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12347 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12348 System.out.println( n15.toString() );
12351 final PhylogenyNode n16 = PhylogenyNode
12352 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12353 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12354 System.out.println( n16.toString() );
12357 final PhylogenyNode n17 = PhylogenyNode
12358 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12359 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12360 System.out.println( n17.toString() );
12364 final PhylogenyNode n18 = PhylogenyNode
12365 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12366 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12367 System.out.println( n18.toString() );
12370 final PhylogenyNode n19 = PhylogenyNode
12371 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12372 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12373 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12374 System.out.println( n19.toString() );
12377 final PhylogenyNode n20 = PhylogenyNode
12378 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12379 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12380 System.out.println( n20.toString() );
12383 final PhylogenyNode n21 = PhylogenyNode
12384 .createInstanceFromNhxString( "Mus musculus musculus K392",
12385 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12386 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12387 System.out.println( n21.toString() );
12390 final PhylogenyNode n22 = PhylogenyNode
12391 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12392 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12393 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12394 System.out.println( n22.toString() );
12397 final PhylogenyNode n23 = PhylogenyNode
12398 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12399 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12400 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12401 System.out.println( n23.toString() );
12404 final PhylogenyNode n24 = PhylogenyNode
12405 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12406 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12407 System.out.println( n24.toString() );
12411 final PhylogenyNode n25 = PhylogenyNode
12412 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12413 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12414 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12415 System.out.println( n25.toString() );
12418 final PhylogenyNode n26 = PhylogenyNode
12419 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12420 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12421 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12422 System.out.println( n26.toString() );
12425 final PhylogenyNode n27 = PhylogenyNode
12426 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12427 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12428 System.out.println( n27.toString() );
12432 catch ( final Exception e ) {
12433 e.printStackTrace( System.out );
12439 private static boolean testTreeCopy() {
12441 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12442 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12443 final Phylogeny t1 = t0.copy();
12444 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12447 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12450 t0.deleteSubtree( t0.getNode( "c" ), true );
12451 t0.deleteSubtree( t0.getNode( "a" ), true );
12452 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12453 t0.getNode( "b" ).setName( "Bee" );
12454 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12457 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12460 t0.deleteSubtree( t0.getNode( "e" ), true );
12461 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12462 t0.deleteSubtree( t0.getNode( "d" ), true );
12463 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12467 catch ( final Exception e ) {
12468 e.printStackTrace();
12474 private static boolean testTreeMethods() {
12476 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12477 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12478 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12479 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12480 System.out.println( t0.toNewHampshireX() );
12483 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12484 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12485 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12488 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12491 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12495 catch ( final Exception e ) {
12496 e.printStackTrace( System.out );
12502 private static boolean testUniprotEntryRetrieval() {
12504 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12505 if ( !entry.getAccession().equals( "P12345" ) ) {
12508 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12511 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12514 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12517 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12520 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12524 catch ( final IOException e ) {
12525 System.out.println();
12526 System.out.println( "the following might be due to absence internet connection:" );
12527 e.printStackTrace( System.out );
12530 catch ( final Exception e ) {
12536 private static boolean testUniprotTaxonomySearch() {
12538 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12540 if ( results.size() != 1 ) {
12543 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12546 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12549 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12552 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12555 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12559 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12560 if ( results.size() != 1 ) {
12563 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12566 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12569 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12572 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12575 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12579 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12580 if ( results.size() != 1 ) {
12583 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12586 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12589 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12592 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12595 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12599 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12600 if ( results.size() != 1 ) {
12603 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12606 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12609 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12612 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12615 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12618 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12621 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12624 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12625 .equals( "Nematostella vectensis" ) ) {
12626 System.out.println( results.get( 0 ).getLineage() );
12631 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12632 if ( results.size() != 1 ) {
12635 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12638 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12641 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12644 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12647 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12650 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12651 .equals( "Xenopus tropicalis" ) ) {
12652 System.out.println( results.get( 0 ).getLineage() );
12657 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12658 if ( results.size() != 1 ) {
12661 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12664 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12667 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12670 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12673 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12676 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12677 .equals( "Xenopus tropicalis" ) ) {
12678 System.out.println( results.get( 0 ).getLineage() );
12683 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12684 if ( results.size() != 1 ) {
12687 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12690 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12693 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12696 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12699 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12702 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12703 .equals( "Xenopus tropicalis" ) ) {
12704 System.out.println( results.get( 0 ).getLineage() );
12708 catch ( final IOException e ) {
12709 System.out.println();
12710 System.out.println( "the following might be due to absence internet connection:" );
12711 e.printStackTrace( System.out );
12714 catch ( final Exception e ) {
12720 private static boolean testWabiTxSearch() {
12722 String result = "";
12723 result = TxSearch.searchSimple( "nematostella" );
12724 result = TxSearch.getTxId( "nematostella" );
12725 if ( !result.equals( "45350" ) ) {
12728 result = TxSearch.getTxName( "45350" );
12729 if ( !result.equals( "Nematostella" ) ) {
12732 result = TxSearch.getTxId( "nematostella vectensis" );
12733 if ( !result.equals( "45351" ) ) {
12736 result = TxSearch.getTxName( "45351" );
12737 if ( !result.equals( "Nematostella vectensis" ) ) {
12740 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12741 if ( !result.equals( "536089" ) ) {
12744 result = TxSearch.getTxName( "536089" );
12745 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12748 final List<String> queries = new ArrayList<String>();
12749 queries.add( "Campylobacter coli" );
12750 queries.add( "Escherichia coli" );
12751 queries.add( "Arabidopsis" );
12752 queries.add( "Trichoplax" );
12753 queries.add( "Samanea saman" );
12754 queries.add( "Kluyveromyces marxianus" );
12755 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12756 queries.add( "Bornavirus parrot/PDD/2008" );
12757 final List<RANKS> ranks = new ArrayList<RANKS>();
12758 ranks.add( RANKS.SUPERKINGDOM );
12759 ranks.add( RANKS.KINGDOM );
12760 ranks.add( RANKS.FAMILY );
12761 ranks.add( RANKS.GENUS );
12762 ranks.add( RANKS.TRIBE );
12763 result = TxSearch.searchLineage( queries, ranks );
12764 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12765 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12767 catch ( final Exception e ) {
12768 System.out.println();
12769 System.out.println( "the following might be due to absence internet connection:" );
12770 e.printStackTrace( System.out );