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" );
6108 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6111 dmsa0.deleteRow( "e" );
6112 dmsa0.deleteRow( "a" );
6113 dmsa0.deleteRow( "f" );
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" );
6136 dmsa0.deleteRow( "d" );
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" );
6157 dmsa1.deleteRow( "f" );
6158 dmsa1.deleteRow( "d" );
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" );
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" );
6218 dmsa2.deleteRow( "b" );
6219 dmsa2.deleteRow( "f" );
6220 dmsa2.deleteRow( "e" );
6221 dmsa2.setIdentifier( 0, "new_c" );
6222 dmsa2.setIdentifier( 1, "new_d" );
6223 dmsa2.setResidueAt( 0, 0, 'x' );
6224 dmsa2.deleteRow( "new_d" );
6225 final Writer w = new StringWriter();
6226 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6227 final String phylip = w.toString();
6228 if ( !phylip.equals( "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6231 final Writer w2 = new StringWriter();
6232 dmsa2.write( w2, MSA_FORMAT.FASTA );
6233 final String fasta = w2.toString();
6234 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6238 catch ( final Exception e ) {
6239 e.printStackTrace( System.out );
6245 private static boolean testNextNodeWithCollapsing() {
6247 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6249 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6250 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6251 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6252 t0.getNode( "cd" ).setCollapse( true );
6253 t0.getNode( "cde" ).setCollapse( true );
6254 n = t0.getFirstExternalNode();
6255 while ( n != null ) {
6257 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6259 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6262 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6265 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6268 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6271 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6274 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6278 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6279 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6280 t1.getNode( "ab" ).setCollapse( true );
6281 t1.getNode( "cd" ).setCollapse( true );
6282 t1.getNode( "cde" ).setCollapse( true );
6283 n = t1.getNode( "ab" );
6284 ext = new ArrayList<PhylogenyNode>();
6285 while ( n != null ) {
6287 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6289 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6292 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6295 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6298 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6301 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6307 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6308 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6309 t2.getNode( "ab" ).setCollapse( true );
6310 t2.getNode( "cd" ).setCollapse( true );
6311 t2.getNode( "cde" ).setCollapse( true );
6312 t2.getNode( "c" ).setCollapse( true );
6313 t2.getNode( "d" ).setCollapse( true );
6314 t2.getNode( "e" ).setCollapse( true );
6315 t2.getNode( "gh" ).setCollapse( true );
6316 n = t2.getNode( "ab" );
6317 ext = new ArrayList<PhylogenyNode>();
6318 while ( n != null ) {
6320 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6322 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6325 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6328 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6331 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6337 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6338 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6339 t3.getNode( "ab" ).setCollapse( true );
6340 t3.getNode( "cd" ).setCollapse( true );
6341 t3.getNode( "cde" ).setCollapse( true );
6342 t3.getNode( "c" ).setCollapse( true );
6343 t3.getNode( "d" ).setCollapse( true );
6344 t3.getNode( "e" ).setCollapse( true );
6345 t3.getNode( "gh" ).setCollapse( true );
6346 t3.getNode( "fgh" ).setCollapse( true );
6347 n = t3.getNode( "ab" );
6348 ext = new ArrayList<PhylogenyNode>();
6349 while ( n != null ) {
6351 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6353 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6356 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6359 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6365 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6366 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6367 t4.getNode( "ab" ).setCollapse( true );
6368 t4.getNode( "cd" ).setCollapse( true );
6369 t4.getNode( "cde" ).setCollapse( true );
6370 t4.getNode( "c" ).setCollapse( true );
6371 t4.getNode( "d" ).setCollapse( true );
6372 t4.getNode( "e" ).setCollapse( true );
6373 t4.getNode( "gh" ).setCollapse( true );
6374 t4.getNode( "fgh" ).setCollapse( true );
6375 t4.getNode( "abcdefgh" ).setCollapse( true );
6376 n = t4.getNode( "abcdefgh" );
6377 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6382 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6383 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6385 n = t5.getFirstExternalNode();
6386 while ( n != null ) {
6388 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6390 if ( ext.size() != 8 ) {
6393 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6396 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6399 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6402 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6405 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6408 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6411 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6414 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6419 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6420 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6422 t6.getNode( "ab" ).setCollapse( true );
6423 n = t6.getNode( "ab" );
6424 while ( n != null ) {
6426 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6428 if ( ext.size() != 7 ) {
6431 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6434 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6437 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6440 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6443 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6446 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6449 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6454 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6455 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6457 t7.getNode( "cd" ).setCollapse( true );
6458 n = t7.getNode( "a" );
6459 while ( n != null ) {
6461 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6463 if ( ext.size() != 7 ) {
6466 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6469 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6472 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6475 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6478 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6481 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6484 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6489 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6490 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6492 t8.getNode( "cd" ).setCollapse( true );
6493 t8.getNode( "c" ).setCollapse( true );
6494 t8.getNode( "d" ).setCollapse( true );
6495 n = t8.getNode( "a" );
6496 while ( n != null ) {
6498 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6500 if ( ext.size() != 7 ) {
6503 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6506 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6509 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6510 System.out.println( "2 fail" );
6513 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6516 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6519 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6522 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6527 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6528 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6530 t9.getNode( "gh" ).setCollapse( true );
6531 n = t9.getNode( "a" );
6532 while ( n != null ) {
6534 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6536 if ( ext.size() != 7 ) {
6539 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6542 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6545 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6548 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6551 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6554 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6557 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6562 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6563 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6565 t10.getNode( "gh" ).setCollapse( true );
6566 t10.getNode( "g" ).setCollapse( true );
6567 t10.getNode( "h" ).setCollapse( true );
6568 n = t10.getNode( "a" );
6569 while ( n != null ) {
6571 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6573 if ( ext.size() != 7 ) {
6576 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6579 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6582 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6585 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6588 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6591 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6594 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6599 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6600 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6602 t11.getNode( "gh" ).setCollapse( true );
6603 t11.getNode( "fgh" ).setCollapse( true );
6604 n = t11.getNode( "a" );
6605 while ( n != null ) {
6607 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6609 if ( ext.size() != 6 ) {
6612 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6615 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6618 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6621 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6624 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6627 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6632 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6633 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6635 t12.getNode( "gh" ).setCollapse( true );
6636 t12.getNode( "fgh" ).setCollapse( true );
6637 t12.getNode( "g" ).setCollapse( true );
6638 t12.getNode( "h" ).setCollapse( true );
6639 t12.getNode( "f" ).setCollapse( true );
6640 n = t12.getNode( "a" );
6641 while ( n != null ) {
6643 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6645 if ( ext.size() != 6 ) {
6648 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6651 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6654 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6657 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6660 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6663 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6668 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6669 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6671 t13.getNode( "ab" ).setCollapse( true );
6672 t13.getNode( "b" ).setCollapse( true );
6673 t13.getNode( "fgh" ).setCollapse( true );
6674 t13.getNode( "gh" ).setCollapse( true );
6675 n = t13.getNode( "ab" );
6676 while ( n != null ) {
6678 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6680 if ( ext.size() != 5 ) {
6683 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6686 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6689 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6692 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6695 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6700 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6701 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6703 t14.getNode( "ab" ).setCollapse( true );
6704 t14.getNode( "a" ).setCollapse( true );
6705 t14.getNode( "fgh" ).setCollapse( true );
6706 t14.getNode( "gh" ).setCollapse( true );
6707 n = t14.getNode( "ab" );
6708 while ( n != null ) {
6710 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6712 if ( ext.size() != 5 ) {
6715 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6718 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6721 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6724 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6727 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6732 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" );
6733 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6735 t15.getNode( "ab" ).setCollapse( true );
6736 t15.getNode( "a" ).setCollapse( true );
6737 t15.getNode( "fgh" ).setCollapse( true );
6738 t15.getNode( "gh" ).setCollapse( true );
6739 n = t15.getNode( "ab" );
6740 while ( n != null ) {
6742 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6744 if ( ext.size() != 6 ) {
6747 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6750 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6753 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6756 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6759 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6762 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6767 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" );
6768 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6770 t16.getNode( "ab" ).setCollapse( true );
6771 t16.getNode( "a" ).setCollapse( true );
6772 t16.getNode( "fgh" ).setCollapse( true );
6773 t16.getNode( "gh" ).setCollapse( true );
6774 t16.getNode( "cd" ).setCollapse( true );
6775 t16.getNode( "cde" ).setCollapse( true );
6776 t16.getNode( "d" ).setCollapse( true );
6777 t16.getNode( "x" ).setCollapse( true );
6778 n = t16.getNode( "ab" );
6779 while ( n != null ) {
6781 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6783 if ( ext.size() != 4 ) {
6786 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6789 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6792 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6795 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6799 catch ( final Exception e ) {
6800 e.printStackTrace( System.out );
6806 private static boolean testNexusCharactersParsing() {
6808 final NexusCharactersParser parser = new NexusCharactersParser();
6809 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6811 String[] labels = parser.getCharStateLabels();
6812 if ( labels.length != 7 ) {
6815 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6818 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6821 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6824 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6827 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6830 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6833 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6836 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6838 labels = parser.getCharStateLabels();
6839 if ( labels.length != 7 ) {
6842 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6845 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6848 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6851 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6854 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6857 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6860 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6864 catch ( final Exception e ) {
6865 e.printStackTrace( System.out );
6871 private static boolean testNexusMatrixParsing() {
6873 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6874 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6876 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6877 if ( m.getNumberOfCharacters() != 9 ) {
6880 if ( m.getNumberOfIdentifiers() != 5 ) {
6883 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6886 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6889 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6892 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6895 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6898 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6901 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6904 // if ( labels.length != 7 ) {
6907 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6910 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6913 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6916 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6919 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6922 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6925 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6928 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6930 // labels = parser.getCharStateLabels();
6931 // if ( labels.length != 7 ) {
6934 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6937 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6940 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6943 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6946 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6949 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6952 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6956 catch ( final Exception e ) {
6957 e.printStackTrace( System.out );
6963 private static boolean testNexusTreeParsing() {
6965 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6966 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6967 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6968 if ( phylogenies.length != 1 ) {
6971 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6974 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6978 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6979 if ( phylogenies.length != 1 ) {
6982 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6985 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6989 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6990 if ( phylogenies.length != 1 ) {
6993 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6996 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6999 if ( phylogenies[ 0 ].isRooted() ) {
7003 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7004 if ( phylogenies.length != 18 ) {
7007 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7010 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7013 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7016 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7019 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7022 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7025 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7028 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7031 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7034 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7037 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7040 if ( phylogenies[ 8 ].isRooted() ) {
7043 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7046 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7049 if ( !phylogenies[ 9 ].isRooted() ) {
7052 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7055 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7058 if ( !phylogenies[ 10 ].isRooted() ) {
7061 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7064 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7067 if ( phylogenies[ 11 ].isRooted() ) {
7070 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7073 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7076 if ( !phylogenies[ 12 ].isRooted() ) {
7079 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7082 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7085 if ( !phylogenies[ 13 ].isRooted() ) {
7088 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7091 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7094 if ( !phylogenies[ 14 ].isRooted() ) {
7097 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7100 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7103 if ( phylogenies[ 15 ].isRooted() ) {
7106 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7109 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7112 if ( !phylogenies[ 16 ].isRooted() ) {
7115 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7118 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7121 if ( phylogenies[ 17 ].isRooted() ) {
7124 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7127 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7129 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7130 if ( phylogenies.length != 9 ) {
7133 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7134 .getDistanceToParent() ) ) {
7137 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7138 .getDistanceToParent() ) ) {
7141 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7144 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7147 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7150 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7153 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7157 catch ( final Exception e ) {
7158 e.printStackTrace( System.out );
7164 private static boolean testNexusTreeParsingIterating() {
7166 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7167 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7168 if ( !p.hasNext() ) {
7171 Phylogeny phy = p.next();
7172 if ( phy == null ) {
7175 if ( phy.getNumberOfExternalNodes() != 25 ) {
7178 if ( !phy.getName().equals( "" ) ) {
7181 if ( p.hasNext() ) {
7185 if ( phy != null ) {
7190 if ( !p.hasNext() ) {
7194 if ( phy == null ) {
7197 if ( phy.getNumberOfExternalNodes() != 25 ) {
7200 if ( !phy.getName().equals( "" ) ) {
7203 if ( p.hasNext() ) {
7207 if ( phy != null ) {
7211 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7212 if ( !p.hasNext() ) {
7216 if ( phy == null ) {
7219 if ( phy.getNumberOfExternalNodes() != 10 ) {
7222 if ( !phy.getName().equals( "name" ) ) {
7225 if ( p.hasNext() ) {
7229 if ( phy != null ) {
7234 if ( !p.hasNext() ) {
7238 if ( phy == null ) {
7241 if ( phy.getNumberOfExternalNodes() != 10 ) {
7244 if ( !phy.getName().equals( "name" ) ) {
7247 if ( p.hasNext() ) {
7251 if ( phy != null ) {
7255 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7256 if ( !p.hasNext() ) {
7260 if ( phy == null ) {
7263 if ( phy.getNumberOfExternalNodes() != 3 ) {
7266 if ( !phy.getName().equals( "" ) ) {
7269 if ( phy.isRooted() ) {
7272 if ( p.hasNext() ) {
7276 if ( phy != null ) {
7281 if ( !p.hasNext() ) {
7285 if ( phy == null ) {
7288 if ( phy.getNumberOfExternalNodes() != 3 ) {
7291 if ( !phy.getName().equals( "" ) ) {
7294 if ( p.hasNext() ) {
7298 if ( phy != null ) {
7302 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7303 if ( !p.hasNext() ) {
7308 if ( phy == null ) {
7311 if ( phy.getNumberOfExternalNodes() != 10 ) {
7314 if ( !phy.getName().equals( "tree 0" ) ) {
7318 if ( !p.hasNext() ) {
7322 if ( phy == null ) {
7325 if ( phy.getNumberOfExternalNodes() != 10 ) {
7328 if ( !phy.getName().equals( "tree 1" ) ) {
7332 if ( !p.hasNext() ) {
7336 if ( phy == null ) {
7339 if ( phy.getNumberOfExternalNodes() != 3 ) {
7340 System.out.println( phy.toString() );
7343 if ( !phy.getName().equals( "" ) ) {
7346 if ( phy.isRooted() ) {
7350 if ( !p.hasNext() ) {
7354 if ( phy == null ) {
7357 if ( phy.getNumberOfExternalNodes() != 4 ) {
7360 if ( !phy.getName().equals( "" ) ) {
7363 if ( !phy.isRooted() ) {
7367 if ( !p.hasNext() ) {
7371 if ( phy == null ) {
7374 if ( phy.getNumberOfExternalNodes() != 5 ) {
7375 System.out.println( phy.getNumberOfExternalNodes() );
7378 if ( !phy.getName().equals( "" ) ) {
7381 if ( !phy.isRooted() ) {
7385 if ( !p.hasNext() ) {
7389 if ( phy == null ) {
7392 if ( phy.getNumberOfExternalNodes() != 3 ) {
7395 if ( !phy.getName().equals( "" ) ) {
7398 if ( phy.isRooted() ) {
7402 if ( !p.hasNext() ) {
7406 if ( phy == null ) {
7409 if ( phy.getNumberOfExternalNodes() != 2 ) {
7412 if ( !phy.getName().equals( "" ) ) {
7415 if ( !phy.isRooted() ) {
7419 if ( !p.hasNext() ) {
7423 if ( phy.getNumberOfExternalNodes() != 3 ) {
7426 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7429 if ( !phy.isRooted() ) {
7433 if ( !p.hasNext() ) {
7437 if ( phy.getNumberOfExternalNodes() != 3 ) {
7440 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7443 if ( !phy.getName().equals( "tree 8" ) ) {
7447 if ( !p.hasNext() ) {
7451 if ( phy.getNumberOfExternalNodes() != 3 ) {
7454 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7457 if ( !phy.getName().equals( "tree 9" ) ) {
7461 if ( !p.hasNext() ) {
7465 if ( phy.getNumberOfExternalNodes() != 3 ) {
7468 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7471 if ( !phy.getName().equals( "tree 10" ) ) {
7474 if ( !phy.isRooted() ) {
7478 if ( !p.hasNext() ) {
7482 if ( phy.getNumberOfExternalNodes() != 3 ) {
7485 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7488 if ( !phy.getName().equals( "tree 11" ) ) {
7491 if ( phy.isRooted() ) {
7495 if ( !p.hasNext() ) {
7499 if ( phy.getNumberOfExternalNodes() != 3 ) {
7502 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7505 if ( !phy.getName().equals( "tree 12" ) ) {
7508 if ( !phy.isRooted() ) {
7512 if ( !p.hasNext() ) {
7516 if ( phy.getNumberOfExternalNodes() != 3 ) {
7519 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7522 if ( !phy.getName().equals( "tree 13" ) ) {
7525 if ( !phy.isRooted() ) {
7529 if ( !p.hasNext() ) {
7533 if ( phy.getNumberOfExternalNodes() != 10 ) {
7534 System.out.println( phy.getNumberOfExternalNodes() );
7539 .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;" ) ) {
7540 System.out.println( phy.toNewHampshire() );
7543 if ( !phy.getName().equals( "tree 14" ) ) {
7546 if ( !phy.isRooted() ) {
7550 if ( !p.hasNext() ) {
7554 if ( phy.getNumberOfExternalNodes() != 10 ) {
7555 System.out.println( phy.getNumberOfExternalNodes() );
7560 .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;" ) ) {
7561 System.out.println( phy.toNewHampshire() );
7564 if ( !phy.getName().equals( "tree 15" ) ) {
7567 if ( phy.isRooted() ) {
7571 if ( !p.hasNext() ) {
7575 if ( phy.getNumberOfExternalNodes() != 10 ) {
7576 System.out.println( phy.getNumberOfExternalNodes() );
7581 .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;" ) ) {
7582 System.out.println( phy.toNewHampshire() );
7585 if ( !phy.getName().equals( "tree 16" ) ) {
7588 if ( !phy.isRooted() ) {
7592 if ( !p.hasNext() ) {
7596 if ( phy.getNumberOfExternalNodes() != 10 ) {
7597 System.out.println( phy.getNumberOfExternalNodes() );
7602 .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;" ) ) {
7603 System.out.println( phy.toNewHampshire() );
7606 if ( !phy.getName().equals( "tree 17" ) ) {
7609 if ( phy.isRooted() ) {
7613 if ( p.hasNext() ) {
7617 if ( phy != null ) {
7622 if ( !p.hasNext() ) {
7626 if ( phy == null ) {
7629 if ( phy.getNumberOfExternalNodes() != 10 ) {
7632 if ( !phy.getName().equals( "tree 0" ) ) {
7636 if ( !p.hasNext() ) {
7640 if ( phy == null ) {
7643 if ( phy.getNumberOfExternalNodes() != 10 ) {
7646 if ( !phy.getName().equals( "tree 1" ) ) {
7650 if ( !p.hasNext() ) {
7654 if ( phy == null ) {
7657 if ( phy.getNumberOfExternalNodes() != 3 ) {
7660 if ( !phy.getName().equals( "" ) ) {
7663 if ( phy.isRooted() ) {
7667 if ( !p.hasNext() ) {
7671 if ( phy == null ) {
7674 if ( phy.getNumberOfExternalNodes() != 4 ) {
7677 if ( !phy.getName().equals( "" ) ) {
7680 if ( !phy.isRooted() ) {
7684 if ( !p.hasNext() ) {
7688 if ( phy == null ) {
7691 if ( phy.getNumberOfExternalNodes() != 5 ) {
7692 System.out.println( phy.getNumberOfExternalNodes() );
7695 if ( !phy.getName().equals( "" ) ) {
7698 if ( !phy.isRooted() ) {
7702 if ( !p.hasNext() ) {
7706 if ( phy == null ) {
7709 if ( phy.getNumberOfExternalNodes() != 3 ) {
7712 if ( !phy.getName().equals( "" ) ) {
7715 if ( phy.isRooted() ) {
7719 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7720 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7722 if ( !p2.hasNext() ) {
7726 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7729 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7733 if ( !p2.hasNext() ) {
7738 if ( !p2.hasNext() ) {
7743 if ( !p2.hasNext() ) {
7748 if ( !p2.hasNext() ) {
7753 if ( !p2.hasNext() ) {
7758 if ( !p2.hasNext() ) {
7763 if ( !p2.hasNext() ) {
7768 if ( !p2.hasNext() ) {
7772 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7775 if ( p2.hasNext() ) {
7779 if ( phy != null ) {
7784 if ( !p2.hasNext() ) {
7788 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7791 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7795 catch ( final Exception e ) {
7796 e.printStackTrace( System.out );
7802 private static boolean testNexusTreeParsingTranslating() {
7804 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7805 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7806 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7807 if ( phylogenies.length != 1 ) {
7810 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7813 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7816 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7819 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7822 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7823 .equals( "Aranaeus" ) ) {
7827 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7828 if ( phylogenies.length != 3 ) {
7831 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7834 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7837 if ( phylogenies[ 0 ].isRooted() ) {
7840 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7843 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7846 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7847 .equals( "Aranaeus" ) ) {
7850 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7853 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7856 if ( phylogenies[ 1 ].isRooted() ) {
7859 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7862 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7865 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7866 .equals( "Aranaeus" ) ) {
7869 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7872 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7875 if ( !phylogenies[ 2 ].isRooted() ) {
7878 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7881 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7884 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7885 .equals( "Aranaeus" ) ) {
7889 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7890 if ( phylogenies.length != 3 ) {
7893 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7896 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7899 if ( phylogenies[ 0 ].isRooted() ) {
7902 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7905 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7908 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7909 .equals( "Aranaeus" ) ) {
7912 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7915 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7918 if ( phylogenies[ 1 ].isRooted() ) {
7921 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7924 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7927 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7928 .equals( "Aranaeus" ) ) {
7931 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7934 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7937 if ( !phylogenies[ 2 ].isRooted() ) {
7940 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7943 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7946 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7947 .equals( "Aranaeus" ) ) {
7950 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7951 if ( phylogenies.length != 3 ) {
7954 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7959 catch ( final Exception e ) {
7960 e.printStackTrace( System.out );
7966 private static boolean testNHParsing() {
7968 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7969 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7970 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7973 final NHXParser nhxp = new NHXParser();
7974 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7975 nhxp.setReplaceUnderscores( true );
7976 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7977 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7980 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7983 final Phylogeny p1b = factory
7984 .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 ",
7985 new NHXParser() )[ 0 ];
7986 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7989 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7992 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7993 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7994 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7995 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7996 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7997 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7998 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7999 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8000 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8001 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8002 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8003 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8004 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8006 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8009 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8012 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8015 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8018 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8019 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8020 final String p16_S = "((A,B),C)";
8021 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8022 if ( p16.length != 1 ) {
8025 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8028 final String p17_S = "(C,(A,B))";
8029 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8030 if ( p17.length != 1 ) {
8033 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8036 final String p18_S = "((A,B),(C,D))";
8037 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8038 if ( p18.length != 1 ) {
8041 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8044 final String p19_S = "(((A,B),C),D)";
8045 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8046 if ( p19.length != 1 ) {
8049 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8052 final String p20_S = "(A,(B,(C,D)))";
8053 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8054 if ( p20.length != 1 ) {
8057 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8060 final String p21_S = "(A,(B,(C,(D,E))))";
8061 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8062 if ( p21.length != 1 ) {
8065 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8068 final String p22_S = "((((A,B),C),D),E)";
8069 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8070 if ( p22.length != 1 ) {
8073 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8076 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8077 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8078 if ( p23.length != 1 ) {
8079 System.out.println( "xl=" + p23.length );
8083 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8086 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8087 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8088 if ( p24.length != 1 ) {
8091 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8094 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8095 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8096 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8097 if ( p241.length != 2 ) {
8100 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8103 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8106 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8107 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8108 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8109 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8110 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8111 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8112 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8113 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8114 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8115 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8118 final String p26_S = "(A,B)ab";
8119 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8120 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8123 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8124 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8125 if ( p27s.length != 1 ) {
8126 System.out.println( "xxl=" + p27s.length );
8130 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8131 System.out.println( p27s[ 0 ].toNewHampshireX() );
8135 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8137 if ( p27.length != 1 ) {
8138 System.out.println( "yl=" + p27.length );
8142 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8143 System.out.println( p27[ 0 ].toNewHampshireX() );
8147 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8148 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8149 final String p28_S3 = "(A,B)ab";
8150 final String p28_S4 = "((((A,B),C),D),;E;)";
8151 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8153 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8156 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8159 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8162 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8165 if ( p28.length != 4 ) {
8168 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";
8169 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8170 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8173 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";
8174 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8175 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8178 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8179 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8180 if ( ( p32.length != 0 ) ) {
8183 final String p33_S = "A";
8184 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8185 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8188 final String p34_S = "B;";
8189 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8190 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8193 final String p35_S = "B:0.2";
8194 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8195 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8198 final String p36_S = "(A)";
8199 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8200 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8203 final String p37_S = "((A))";
8204 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8205 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8208 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8209 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8210 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8213 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8214 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8215 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8218 final String p40_S = "(A,B,C)";
8219 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8220 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8223 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8224 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8225 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8228 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8229 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8230 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8233 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)";
8234 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8235 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8238 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)))";
8239 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8240 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8243 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8244 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8245 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8248 final String p46_S = "";
8249 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8250 if ( p46.length != 0 ) {
8253 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8254 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8257 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8258 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8261 final Phylogeny p49 = factory
8262 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8263 new NHXParser() )[ 0 ];
8264 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8267 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8268 if ( p50.getNode( "A" ) == null ) {
8271 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8272 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8275 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8278 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8279 .equals( "((A,B)88:2.0,C);" ) ) {
8282 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8283 if ( p51.getNode( "A(A" ) == null ) {
8286 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8287 if ( p52.getNode( "A(A" ) == null ) {
8290 final Phylogeny p53 = factory
8291 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8292 new NHXParser() )[ 0 ];
8293 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8296 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8297 if ( p54.getNode( "A" ) == null ) {
8300 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8303 final Phylogeny p55 = factory
8304 .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);" ),
8305 new NHXParser() )[ 0 ];
8308 .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);" ) ) {
8309 System.out.println( p55.toNewHampshire() );
8312 final Phylogeny p56 = factory
8313 .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);" ),
8314 new NHXParser() )[ 0 ];
8317 .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);" ) ) {
8318 System.out.println( p56.toNewHampshire() );
8321 final Phylogeny p57 = factory
8322 .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);" ),
8323 new NHXParser() )[ 0 ];
8326 .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);" ) ) {
8327 System.out.println( p56.toNewHampshire() );
8330 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8331 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8332 if ( !p58.toNewHampshire().equals( s58 ) ) {
8333 System.out.println( p58.toNewHampshire() );
8336 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8337 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8338 if ( !p59.toNewHampshire().equals( s59 ) ) {
8339 System.out.println( p59.toNewHampshire() );
8342 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8343 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8344 if ( !p60.toNewHampshire().equals( s60 ) ) {
8345 System.out.println( p60.toNewHampshire() );
8348 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8349 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8350 if ( !p61.toNewHampshire()
8351 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8352 System.out.println( p61.toNewHampshire() );
8356 catch ( final Exception e ) {
8357 e.printStackTrace( System.out );
8363 private static boolean testNHParsingIter() {
8365 final String p0_str = "(A,B);";
8366 final NHXParser p = new NHXParser();
8367 p.setSource( p0_str );
8368 if ( !p.hasNext() ) {
8371 final Phylogeny p0 = p.next();
8372 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8373 System.out.println( p0.toNewHampshire() );
8376 if ( p.hasNext() ) {
8379 if ( p.next() != null ) {
8383 final String p00_str = "(A,B)root;";
8384 p.setSource( p00_str );
8385 final Phylogeny p00 = p.next();
8386 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8387 System.out.println( p00.toNewHampshire() );
8391 final String p000_str = "A;";
8392 p.setSource( p000_str );
8393 final Phylogeny p000 = p.next();
8394 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8395 System.out.println( p000.toNewHampshire() );
8399 final String p0000_str = "A";
8400 p.setSource( p0000_str );
8401 final Phylogeny p0000 = p.next();
8402 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8403 System.out.println( p0000.toNewHampshire() );
8407 p.setSource( "(A)" );
8408 final Phylogeny p00000 = p.next();
8409 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8410 System.out.println( p00000.toNewHampshire() );
8414 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8415 p.setSource( p1_str );
8416 if ( !p.hasNext() ) {
8419 final Phylogeny p1_0 = p.next();
8420 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8421 System.out.println( p1_0.toNewHampshire() );
8424 if ( !p.hasNext() ) {
8427 final Phylogeny p1_1 = p.next();
8428 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8429 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8432 if ( !p.hasNext() ) {
8435 final Phylogeny p1_2 = p.next();
8436 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8437 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8440 if ( !p.hasNext() ) {
8443 final Phylogeny p1_3 = p.next();
8444 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8445 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8448 if ( p.hasNext() ) {
8451 if ( p.next() != null ) {
8455 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8456 p.setSource( p2_str );
8457 if ( !p.hasNext() ) {
8460 Phylogeny p2_0 = p.next();
8461 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8462 System.out.println( p2_0.toNewHampshire() );
8465 if ( !p.hasNext() ) {
8468 Phylogeny p2_1 = p.next();
8469 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8470 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8473 if ( !p.hasNext() ) {
8476 Phylogeny p2_2 = p.next();
8477 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8478 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8481 if ( !p.hasNext() ) {
8484 Phylogeny p2_3 = p.next();
8485 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8486 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8489 if ( !p.hasNext() ) {
8492 Phylogeny p2_4 = p.next();
8493 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8494 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8497 if ( p.hasNext() ) {
8500 if ( p.next() != null ) {
8505 if ( !p.hasNext() ) {
8509 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8510 System.out.println( p2_0.toNewHampshire() );
8513 if ( !p.hasNext() ) {
8517 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8518 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8521 if ( !p.hasNext() ) {
8525 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8526 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8529 if ( !p.hasNext() ) {
8533 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8534 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8537 if ( !p.hasNext() ) {
8541 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8542 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8545 if ( p.hasNext() ) {
8548 if ( p.next() != null ) {
8552 final String p3_str = "((A,B),C)abc";
8553 p.setSource( p3_str );
8554 if ( !p.hasNext() ) {
8557 final Phylogeny p3_0 = p.next();
8558 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8561 if ( p.hasNext() ) {
8564 if ( p.next() != null ) {
8568 final String p4_str = "((A,B)ab,C)abc";
8569 p.setSource( p4_str );
8570 if ( !p.hasNext() ) {
8573 final Phylogeny p4_0 = p.next();
8574 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8577 if ( p.hasNext() ) {
8580 if ( p.next() != null ) {
8584 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8585 p.setSource( p5_str );
8586 if ( !p.hasNext() ) {
8589 final Phylogeny p5_0 = p.next();
8590 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8593 if ( p.hasNext() ) {
8596 if ( p.next() != null ) {
8600 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8601 p.setSource( p6_str );
8602 if ( !p.hasNext() ) {
8605 Phylogeny p6_0 = p.next();
8606 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8609 if ( p.hasNext() ) {
8612 if ( p.next() != null ) {
8616 if ( !p.hasNext() ) {
8620 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8623 if ( p.hasNext() ) {
8626 if ( p.next() != null ) {
8630 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8631 p.setSource( p7_str );
8632 if ( !p.hasNext() ) {
8635 Phylogeny p7_0 = p.next();
8636 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8639 if ( p.hasNext() ) {
8642 if ( p.next() != null ) {
8646 if ( !p.hasNext() ) {
8650 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8653 if ( p.hasNext() ) {
8656 if ( p.next() != null ) {
8660 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8661 p.setSource( p8_str );
8662 if ( !p.hasNext() ) {
8665 Phylogeny p8_0 = p.next();
8666 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8669 if ( !p.hasNext() ) {
8672 if ( !p.hasNext() ) {
8675 Phylogeny p8_1 = p.next();
8676 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8679 if ( p.hasNext() ) {
8682 if ( p.next() != null ) {
8686 if ( !p.hasNext() ) {
8690 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8693 if ( !p.hasNext() ) {
8697 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8700 if ( p.hasNext() ) {
8703 if ( p.next() != null ) {
8709 if ( p.hasNext() ) {
8713 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8714 if ( !p.hasNext() ) {
8717 Phylogeny p_27 = p.next();
8718 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8719 System.out.println( p_27.toNewHampshireX() );
8723 if ( p.hasNext() ) {
8726 if ( p.next() != null ) {
8730 if ( !p.hasNext() ) {
8734 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8735 System.out.println( p_27.toNewHampshireX() );
8739 if ( p.hasNext() ) {
8742 if ( p.next() != null ) {
8746 final String p30_str = "(A,B);(C,D)";
8747 final NHXParser p30 = new NHXParser();
8748 p30.setSource( p30_str );
8749 if ( !p30.hasNext() ) {
8752 Phylogeny phy30 = p30.next();
8753 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8754 System.out.println( phy30.toNewHampshire() );
8757 if ( !p30.hasNext() ) {
8760 Phylogeny phy301 = p30.next();
8761 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8762 System.out.println( phy301.toNewHampshire() );
8765 if ( p30.hasNext() ) {
8768 if ( p30.hasNext() ) {
8771 if ( p30.next() != null ) {
8774 if ( p30.next() != null ) {
8778 if ( !p30.hasNext() ) {
8782 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8783 System.out.println( phy30.toNewHampshire() );
8786 if ( !p30.hasNext() ) {
8789 phy301 = p30.next();
8790 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8791 System.out.println( phy301.toNewHampshire() );
8794 if ( p30.hasNext() ) {
8797 if ( p30.hasNext() ) {
8800 if ( p30.next() != null ) {
8803 if ( p30.next() != null ) {
8807 catch ( final Exception e ) {
8808 e.printStackTrace( System.out );
8814 private static boolean testNHXconversion() {
8816 final PhylogenyNode n1 = new PhylogenyNode();
8817 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8818 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8819 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8820 final PhylogenyNode n5 = PhylogenyNode
8821 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8822 final PhylogenyNode n6 = PhylogenyNode
8823 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8824 if ( !n1.toNewHampshireX().equals( "" ) ) {
8827 if ( !n2.toNewHampshireX().equals( "" ) ) {
8830 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8833 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8836 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8839 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8840 System.out.println( n6.toNewHampshireX() );
8843 final PhylogenyNode n7 = new PhylogenyNode();
8844 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8845 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8846 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8847 System.out.println( n7
8848 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8852 catch ( final Exception e ) {
8853 e.printStackTrace( System.out );
8859 private static boolean testNHXNodeParsing() {
8861 final PhylogenyNode n1 = new PhylogenyNode();
8862 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8863 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8864 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8865 final PhylogenyNode n5 = PhylogenyNode
8866 .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]" );
8867 if ( !n3.getName().equals( "n3" ) ) {
8870 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8873 if ( n3.isDuplication() ) {
8876 if ( n3.isHasAssignedEvent() ) {
8879 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8882 if ( !n4.getName().equals( "n4" ) ) {
8885 if ( n4.getDistanceToParent() != 0.01 ) {
8888 if ( !n5.getName().equals( "n5" ) ) {
8891 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8894 if ( n5.getDistanceToParent() != 0.1 ) {
8897 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8900 if ( !n5.isDuplication() ) {
8903 if ( !n5.isHasAssignedEvent() ) {
8906 final PhylogenyNode n8 = PhylogenyNode
8907 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8908 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8909 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8912 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8915 final PhylogenyNode n9 = PhylogenyNode
8916 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8917 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8918 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8921 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8924 final PhylogenyNode n10 = PhylogenyNode
8925 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8926 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8929 final PhylogenyNode n20 = PhylogenyNode
8930 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8931 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8934 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8937 final PhylogenyNode n20x = PhylogenyNode
8938 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8939 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8942 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8945 final PhylogenyNode n20xx = PhylogenyNode
8946 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8947 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8950 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8953 final PhylogenyNode n20xxx = PhylogenyNode
8954 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8955 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8958 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8961 final PhylogenyNode n20xxxx = PhylogenyNode
8962 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8963 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8966 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8969 final PhylogenyNode n21 = PhylogenyNode
8970 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8971 if ( !n21.getName().equals( "N21_PIG" ) ) {
8974 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8977 final PhylogenyNode n21x = PhylogenyNode
8978 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8979 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8982 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8985 final PhylogenyNode n22 = PhylogenyNode
8986 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8987 if ( !n22.getName().equals( "n22/PIG" ) ) {
8990 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8993 final PhylogenyNode n23 = PhylogenyNode
8994 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8995 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8998 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9001 final PhylogenyNode a = PhylogenyNode
9002 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9003 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9006 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9009 final PhylogenyNode c1 = PhylogenyNode
9010 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9011 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9012 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9015 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9018 final PhylogenyNode c2 = PhylogenyNode
9019 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9020 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9021 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9024 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9027 final PhylogenyNode e3 = PhylogenyNode
9028 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9029 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9032 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9035 final PhylogenyNode n11 = PhylogenyNode
9036 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9037 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9038 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9041 if ( n11.getDistanceToParent() != 0.4 ) {
9044 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9047 final PhylogenyNode n12 = PhylogenyNode
9048 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9049 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9050 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9053 if ( n12.getDistanceToParent() != 0.4 ) {
9056 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9059 final PhylogenyNode o = PhylogenyNode
9060 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9061 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9064 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9067 if ( n1.getName().compareTo( "" ) != 0 ) {
9070 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9073 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9076 if ( n2.getName().compareTo( "" ) != 0 ) {
9079 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9082 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9085 final PhylogenyNode n00 = PhylogenyNode
9086 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9087 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9090 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9093 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9094 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9097 final PhylogenyNode n13 = PhylogenyNode
9098 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9099 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9102 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9105 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9108 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9111 final PhylogenyNode n14 = PhylogenyNode
9112 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9113 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9116 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9119 final PhylogenyNode n15 = PhylogenyNode
9120 .createInstanceFromNhxString( "something_wicked[123]",
9121 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9122 if ( !n15.getName().equals( "something_wicked" ) ) {
9125 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9128 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9131 final PhylogenyNode n16 = PhylogenyNode
9132 .createInstanceFromNhxString( "something_wicked2[9]",
9133 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9134 if ( !n16.getName().equals( "something_wicked2" ) ) {
9137 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9140 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9143 final PhylogenyNode n17 = PhylogenyNode
9144 .createInstanceFromNhxString( "something_wicked3[a]",
9145 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9146 if ( !n17.getName().equals( "something_wicked3" ) ) {
9149 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9152 final PhylogenyNode n18 = PhylogenyNode
9153 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9154 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9157 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9160 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9163 final PhylogenyNode n19 = PhylogenyNode
9164 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9165 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9168 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9171 final PhylogenyNode n30 = PhylogenyNode
9172 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9173 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9174 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9177 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9180 final PhylogenyNode n31 = PhylogenyNode
9181 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9182 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9183 if ( n31.getNodeData().isHasTaxonomy() ) {
9186 final PhylogenyNode n32 = PhylogenyNode
9187 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9188 if ( n32.getNodeData().isHasTaxonomy() ) {
9191 final PhylogenyNode n40 = PhylogenyNode
9192 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9193 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9196 final PhylogenyNode n41 = PhylogenyNode
9197 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9198 if ( n41.getNodeData().isHasTaxonomy() ) {
9201 final PhylogenyNode n42 = PhylogenyNode
9202 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9203 if ( n42.getNodeData().isHasTaxonomy() ) {
9206 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9207 NHXParser.TAXONOMY_EXTRACTION.NO );
9208 if ( n43.getNodeData().isHasTaxonomy() ) {
9211 final PhylogenyNode n44 = PhylogenyNode
9212 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9213 if ( n44.getNodeData().isHasTaxonomy() ) {
9217 catch ( final Exception e ) {
9218 e.printStackTrace( System.out );
9224 private static boolean testNHXParsing() {
9226 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9227 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9228 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9231 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]";
9232 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9233 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9236 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]";
9237 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9238 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9241 final Phylogeny[] p3 = factory
9242 .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]",
9244 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9247 final Phylogeny[] p4 = factory
9248 .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(]",
9250 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9253 final Phylogeny[] p5 = factory
9254 .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(((]",
9256 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9259 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)";
9260 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)";
9261 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9262 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9265 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)))";
9266 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)))";
9267 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9268 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9271 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]) ))[,,, ])))))))";
9272 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9273 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9274 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9277 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9278 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9281 final Phylogeny p10 = factory
9282 .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]",
9283 new NHXParser() )[ 0 ];
9284 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9287 final Phylogeny p11 = factory
9288 .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]",
9289 new NHXParser() )[ 0 ];
9290 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9294 catch ( final Exception e ) {
9295 e.printStackTrace( System.out );
9301 private static boolean testNHXParsingMB() {
9303 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9304 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9305 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9306 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9307 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9308 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9309 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9310 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9311 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9312 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9313 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9316 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9319 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9320 0.1100000000000000e+00 ) ) {
9323 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9326 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9329 final Phylogeny p2 = factory
9330 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9331 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9332 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9333 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9334 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9335 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9336 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9337 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9338 + "7.369400000000000e-02}])",
9339 new NHXParser() )[ 0 ];
9340 if ( p2.getNode( "1" ) == null ) {
9343 if ( p2.getNode( "2" ) == null ) {
9347 catch ( final Exception e ) {
9348 e.printStackTrace( System.out );
9355 private static boolean testNHXParsingQuotes() {
9357 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9358 final NHXParser p = new NHXParser();
9359 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9360 if ( phylogenies_0.length != 5 ) {
9363 final Phylogeny phy = phylogenies_0[ 4 ];
9364 if ( phy.getNumberOfExternalNodes() != 7 ) {
9367 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9370 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9373 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9374 .getScientificName().equals( "hsapiens" ) ) {
9377 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9380 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9383 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9386 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9389 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9392 final NHXParser p1p = new NHXParser();
9393 p1p.setIgnoreQuotes( true );
9394 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9395 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9398 final NHXParser p2p = new NHXParser();
9399 p1p.setIgnoreQuotes( false );
9400 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9401 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9404 final NHXParser p3p = new NHXParser();
9405 p3p.setIgnoreQuotes( false );
9406 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9407 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9410 final NHXParser p4p = new NHXParser();
9411 p4p.setIgnoreQuotes( false );
9412 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9413 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9416 final Phylogeny p10 = factory
9417 .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]",
9418 new NHXParser() )[ 0 ];
9419 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]";
9420 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9423 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9424 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9427 final Phylogeny p12 = factory
9428 .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]",
9429 new NHXParser() )[ 0 ];
9430 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]";
9431 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9434 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9435 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9438 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;";
9439 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9442 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9443 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9447 catch ( final Exception e ) {
9448 e.printStackTrace( System.out );
9454 private static boolean testNodeRemoval() {
9456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9457 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9458 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9459 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9462 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9463 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9464 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9467 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9468 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9469 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9473 catch ( final Exception e ) {
9474 e.printStackTrace( System.out );
9480 private static boolean testPhylogenyBranch() {
9482 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9483 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9484 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9485 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9486 if ( !a1b1.equals( a1b1 ) ) {
9489 if ( !a1b1.equals( b1a1 ) ) {
9492 if ( !b1a1.equals( a1b1 ) ) {
9495 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9496 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9497 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9498 if ( a1_b1.equals( b1_a1 ) ) {
9501 if ( a1_b1.equals( a1_b1_ ) ) {
9504 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9505 if ( !a1_b1.equals( b1_a1_ ) ) {
9508 if ( a1_b1_.equals( b1_a1_ ) ) {
9511 if ( !a1_b1_.equals( b1_a1 ) ) {
9515 catch ( final Exception e ) {
9516 e.printStackTrace( System.out );
9522 private static boolean testPhyloXMLparsingOfDistributionElement() {
9524 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9525 PhyloXmlParser xml_parser = null;
9527 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9529 catch ( final Exception e ) {
9530 // Do nothing -- means were not running from jar.
9532 if ( xml_parser == null ) {
9533 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9534 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9535 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9538 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9541 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9543 if ( xml_parser.getErrorCount() > 0 ) {
9544 System.out.println( xml_parser.getErrorMessages().toString() );
9547 if ( phylogenies_0.length != 1 ) {
9550 final Phylogeny t1 = phylogenies_0[ 0 ];
9551 PhylogenyNode n = null;
9552 Distribution d = null;
9553 n = t1.getNode( "root node" );
9554 if ( !n.getNodeData().isHasDistribution() ) {
9557 if ( n.getNodeData().getDistributions().size() != 1 ) {
9560 d = n.getNodeData().getDistribution();
9561 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9564 if ( d.getPoints().size() != 1 ) {
9567 if ( d.getPolygons() != null ) {
9570 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9573 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9576 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9579 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9582 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9585 n = t1.getNode( "node a" );
9586 if ( !n.getNodeData().isHasDistribution() ) {
9589 if ( n.getNodeData().getDistributions().size() != 2 ) {
9592 d = n.getNodeData().getDistribution( 1 );
9593 if ( !d.getDesc().equals( "San Diego" ) ) {
9596 if ( d.getPoints().size() != 1 ) {
9599 if ( d.getPolygons() != null ) {
9602 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9605 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9608 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9611 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9614 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9617 n = t1.getNode( "node bb" );
9618 if ( !n.getNodeData().isHasDistribution() ) {
9621 if ( n.getNodeData().getDistributions().size() != 1 ) {
9624 d = n.getNodeData().getDistribution( 0 );
9625 if ( d.getPoints().size() != 3 ) {
9628 if ( d.getPolygons().size() != 2 ) {
9631 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9634 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9637 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9640 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9643 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9646 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9649 Polygon p = d.getPolygons().get( 0 );
9650 if ( p.getPoints().size() != 3 ) {
9653 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9656 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9659 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9662 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9665 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9668 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9671 p = d.getPolygons().get( 1 );
9672 if ( p.getPoints().size() != 3 ) {
9675 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9678 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9681 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9685 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9686 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9687 if ( rt.length != 1 ) {
9690 final Phylogeny t1_rt = rt[ 0 ];
9691 n = t1_rt.getNode( "root node" );
9692 if ( !n.getNodeData().isHasDistribution() ) {
9695 if ( n.getNodeData().getDistributions().size() != 1 ) {
9698 d = n.getNodeData().getDistribution();
9699 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9702 if ( d.getPoints().size() != 1 ) {
9705 if ( d.getPolygons() != null ) {
9708 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9711 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9714 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9717 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9720 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9723 n = t1_rt.getNode( "node a" );
9724 if ( !n.getNodeData().isHasDistribution() ) {
9727 if ( n.getNodeData().getDistributions().size() != 2 ) {
9730 d = n.getNodeData().getDistribution( 1 );
9731 if ( !d.getDesc().equals( "San Diego" ) ) {
9734 if ( d.getPoints().size() != 1 ) {
9737 if ( d.getPolygons() != null ) {
9740 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9743 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9746 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9749 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9752 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9755 n = t1_rt.getNode( "node bb" );
9756 if ( !n.getNodeData().isHasDistribution() ) {
9759 if ( n.getNodeData().getDistributions().size() != 1 ) {
9762 d = n.getNodeData().getDistribution( 0 );
9763 if ( d.getPoints().size() != 3 ) {
9766 if ( d.getPolygons().size() != 2 ) {
9769 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9772 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9775 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9778 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9781 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9784 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9787 p = d.getPolygons().get( 0 );
9788 if ( p.getPoints().size() != 3 ) {
9791 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9794 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9797 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9800 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9803 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9806 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9809 p = d.getPolygons().get( 1 );
9810 if ( p.getPoints().size() != 3 ) {
9813 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9816 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9819 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9823 catch ( final Exception e ) {
9824 e.printStackTrace( System.out );
9830 private static boolean testPostOrderIterator() {
9832 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9833 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9834 PhylogenyNodeIterator it0;
9835 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9838 for( it0.reset(); it0.hasNext(); ) {
9841 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9842 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9843 if ( !it.next().getName().equals( "A" ) ) {
9846 if ( !it.next().getName().equals( "B" ) ) {
9849 if ( !it.next().getName().equals( "ab" ) ) {
9852 if ( !it.next().getName().equals( "C" ) ) {
9855 if ( !it.next().getName().equals( "D" ) ) {
9858 if ( !it.next().getName().equals( "cd" ) ) {
9861 if ( !it.next().getName().equals( "abcd" ) ) {
9864 if ( !it.next().getName().equals( "E" ) ) {
9867 if ( !it.next().getName().equals( "F" ) ) {
9870 if ( !it.next().getName().equals( "ef" ) ) {
9873 if ( !it.next().getName().equals( "G" ) ) {
9876 if ( !it.next().getName().equals( "H" ) ) {
9879 if ( !it.next().getName().equals( "gh" ) ) {
9882 if ( !it.next().getName().equals( "efgh" ) ) {
9885 if ( !it.next().getName().equals( "r" ) ) {
9888 if ( it.hasNext() ) {
9892 catch ( final Exception e ) {
9893 e.printStackTrace( System.out );
9899 private static boolean testPreOrderIterator() {
9901 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9902 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9903 PhylogenyNodeIterator it0;
9904 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9907 for( it0.reset(); it0.hasNext(); ) {
9910 PhylogenyNodeIterator it = t0.iteratorPreorder();
9911 if ( !it.next().getName().equals( "r" ) ) {
9914 if ( !it.next().getName().equals( "ab" ) ) {
9917 if ( !it.next().getName().equals( "A" ) ) {
9920 if ( !it.next().getName().equals( "B" ) ) {
9923 if ( !it.next().getName().equals( "cd" ) ) {
9926 if ( !it.next().getName().equals( "C" ) ) {
9929 if ( !it.next().getName().equals( "D" ) ) {
9932 if ( it.hasNext() ) {
9935 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9936 it = t1.iteratorPreorder();
9937 if ( !it.next().getName().equals( "r" ) ) {
9940 if ( !it.next().getName().equals( "abcd" ) ) {
9943 if ( !it.next().getName().equals( "ab" ) ) {
9946 if ( !it.next().getName().equals( "A" ) ) {
9949 if ( !it.next().getName().equals( "B" ) ) {
9952 if ( !it.next().getName().equals( "cd" ) ) {
9955 if ( !it.next().getName().equals( "C" ) ) {
9958 if ( !it.next().getName().equals( "D" ) ) {
9961 if ( !it.next().getName().equals( "efgh" ) ) {
9964 if ( !it.next().getName().equals( "ef" ) ) {
9967 if ( !it.next().getName().equals( "E" ) ) {
9970 if ( !it.next().getName().equals( "F" ) ) {
9973 if ( !it.next().getName().equals( "gh" ) ) {
9976 if ( !it.next().getName().equals( "G" ) ) {
9979 if ( !it.next().getName().equals( "H" ) ) {
9982 if ( it.hasNext() ) {
9986 catch ( final Exception e ) {
9987 e.printStackTrace( System.out );
9993 private static boolean testPropertiesMap() {
9995 final PropertiesMap pm = new PropertiesMap();
9996 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9997 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9998 final Property p2 = new Property( "something:else",
10000 "improbable:research",
10003 pm.addProperty( p0 );
10004 pm.addProperty( p1 );
10005 pm.addProperty( p2 );
10006 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10009 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10012 if ( pm.getProperties().size() != 3 ) {
10015 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10018 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10021 if ( pm.getProperties().size() != 3 ) {
10024 pm.removeProperty( "dimensions:diameter" );
10025 if ( pm.getProperties().size() != 2 ) {
10028 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10031 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10035 catch ( final Exception e ) {
10036 e.printStackTrace( System.out );
10042 private static boolean testProteinId() {
10044 final ProteinId id1 = new ProteinId( "a" );
10045 final ProteinId id2 = new ProteinId( "a" );
10046 final ProteinId id3 = new ProteinId( "A" );
10047 final ProteinId id4 = new ProteinId( "b" );
10048 if ( !id1.equals( id1 ) ) {
10051 if ( id1.getId().equals( "x" ) ) {
10054 if ( id1.getId().equals( null ) ) {
10057 if ( !id1.equals( id2 ) ) {
10060 if ( id1.equals( id3 ) ) {
10063 if ( id1.hashCode() != id1.hashCode() ) {
10066 if ( id1.hashCode() != id2.hashCode() ) {
10069 if ( id1.hashCode() == id3.hashCode() ) {
10072 if ( id1.compareTo( id1 ) != 0 ) {
10075 if ( id1.compareTo( id2 ) != 0 ) {
10078 if ( id1.compareTo( id3 ) != 0 ) {
10081 if ( id1.compareTo( id4 ) >= 0 ) {
10084 if ( id4.compareTo( id1 ) <= 0 ) {
10087 if ( !id4.getId().equals( "b" ) ) {
10090 final ProteinId id5 = new ProteinId( " C " );
10091 if ( !id5.getId().equals( "C" ) ) {
10094 if ( id5.equals( id1 ) ) {
10098 catch ( final Exception e ) {
10099 e.printStackTrace( System.out );
10105 private static boolean testReIdMethods() {
10107 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10108 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10109 final long count = PhylogenyNode.getNodeCount();
10110 p.levelOrderReID();
10111 if ( p.getNode( "r" ).getId() != count ) {
10114 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10117 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10120 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10123 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10126 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10129 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10132 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10135 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10138 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10141 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10144 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10147 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10150 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10153 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10157 catch ( final Exception e ) {
10158 e.printStackTrace( System.out );
10164 private static boolean testRerooting() {
10166 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10167 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",
10168 new NHXParser() )[ 0 ];
10169 if ( !t1.isRooted() ) {
10172 t1.reRoot( t1.getNode( "D" ) );
10173 t1.reRoot( t1.getNode( "CD" ) );
10174 t1.reRoot( t1.getNode( "A" ) );
10175 t1.reRoot( t1.getNode( "B" ) );
10176 t1.reRoot( t1.getNode( "AB" ) );
10177 t1.reRoot( t1.getNode( "D" ) );
10178 t1.reRoot( t1.getNode( "C" ) );
10179 t1.reRoot( t1.getNode( "CD" ) );
10180 t1.reRoot( t1.getNode( "A" ) );
10181 t1.reRoot( t1.getNode( "B" ) );
10182 t1.reRoot( t1.getNode( "AB" ) );
10183 t1.reRoot( t1.getNode( "D" ) );
10184 t1.reRoot( t1.getNode( "D" ) );
10185 t1.reRoot( t1.getNode( "C" ) );
10186 t1.reRoot( t1.getNode( "A" ) );
10187 t1.reRoot( t1.getNode( "B" ) );
10188 t1.reRoot( t1.getNode( "AB" ) );
10189 t1.reRoot( t1.getNode( "C" ) );
10190 t1.reRoot( t1.getNode( "D" ) );
10191 t1.reRoot( t1.getNode( "CD" ) );
10192 t1.reRoot( t1.getNode( "D" ) );
10193 t1.reRoot( t1.getNode( "A" ) );
10194 t1.reRoot( t1.getNode( "B" ) );
10195 t1.reRoot( t1.getNode( "AB" ) );
10196 t1.reRoot( t1.getNode( "C" ) );
10197 t1.reRoot( t1.getNode( "D" ) );
10198 t1.reRoot( t1.getNode( "CD" ) );
10199 t1.reRoot( t1.getNode( "D" ) );
10200 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10203 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10206 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10209 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10212 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10215 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10218 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",
10219 new NHXParser() )[ 0 ];
10220 t2.reRoot( t2.getNode( "A" ) );
10221 t2.reRoot( t2.getNode( "D" ) );
10222 t2.reRoot( t2.getNode( "ABC" ) );
10223 t2.reRoot( t2.getNode( "A" ) );
10224 t2.reRoot( t2.getNode( "B" ) );
10225 t2.reRoot( t2.getNode( "D" ) );
10226 t2.reRoot( t2.getNode( "C" ) );
10227 t2.reRoot( t2.getNode( "ABC" ) );
10228 t2.reRoot( t2.getNode( "A" ) );
10229 t2.reRoot( t2.getNode( "B" ) );
10230 t2.reRoot( t2.getNode( "AB" ) );
10231 t2.reRoot( t2.getNode( "AB" ) );
10232 t2.reRoot( t2.getNode( "D" ) );
10233 t2.reRoot( t2.getNode( "C" ) );
10234 t2.reRoot( t2.getNode( "B" ) );
10235 t2.reRoot( t2.getNode( "AB" ) );
10236 t2.reRoot( t2.getNode( "D" ) );
10237 t2.reRoot( t2.getNode( "D" ) );
10238 t2.reRoot( t2.getNode( "ABC" ) );
10239 t2.reRoot( t2.getNode( "A" ) );
10240 t2.reRoot( t2.getNode( "B" ) );
10241 t2.reRoot( t2.getNode( "AB" ) );
10242 t2.reRoot( t2.getNode( "D" ) );
10243 t2.reRoot( t2.getNode( "C" ) );
10244 t2.reRoot( t2.getNode( "ABC" ) );
10245 t2.reRoot( t2.getNode( "A" ) );
10246 t2.reRoot( t2.getNode( "B" ) );
10247 t2.reRoot( t2.getNode( "AB" ) );
10248 t2.reRoot( t2.getNode( "D" ) );
10249 t2.reRoot( t2.getNode( "D" ) );
10250 t2.reRoot( t2.getNode( "C" ) );
10251 t2.reRoot( t2.getNode( "A" ) );
10252 t2.reRoot( t2.getNode( "B" ) );
10253 t2.reRoot( t2.getNode( "AB" ) );
10254 t2.reRoot( t2.getNode( "C" ) );
10255 t2.reRoot( t2.getNode( "D" ) );
10256 t2.reRoot( t2.getNode( "ABC" ) );
10257 t2.reRoot( t2.getNode( "D" ) );
10258 t2.reRoot( t2.getNode( "A" ) );
10259 t2.reRoot( t2.getNode( "B" ) );
10260 t2.reRoot( t2.getNode( "AB" ) );
10261 t2.reRoot( t2.getNode( "C" ) );
10262 t2.reRoot( t2.getNode( "D" ) );
10263 t2.reRoot( t2.getNode( "ABC" ) );
10264 t2.reRoot( t2.getNode( "D" ) );
10265 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10268 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10271 t2.reRoot( t2.getNode( "ABC" ) );
10272 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10275 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10278 t2.reRoot( t2.getNode( "AB" ) );
10279 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10282 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10285 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10288 t2.reRoot( t2.getNode( "AB" ) );
10289 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10292 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10295 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10298 t2.reRoot( t2.getNode( "D" ) );
10299 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10302 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10305 t2.reRoot( t2.getNode( "ABC" ) );
10306 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10309 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10312 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10313 new NHXParser() )[ 0 ];
10314 t3.reRoot( t3.getNode( "B" ) );
10315 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10318 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10321 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10324 t3.reRoot( t3.getNode( "B" ) );
10325 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10328 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10331 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10334 t3.reRoot( t3.getRoot() );
10335 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10338 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10341 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10345 catch ( final Exception e ) {
10346 e.printStackTrace( System.out );
10352 private static boolean testSDIse() {
10354 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10355 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10356 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10357 gene1.setRooted( true );
10358 species1.setRooted( true );
10359 final SDI sdi = new SDI( gene1, species1 );
10360 if ( !gene1.getRoot().isDuplication() ) {
10363 final Phylogeny species2 = factory
10364 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10365 new NHXParser() )[ 0 ];
10366 final Phylogeny gene2 = factory
10367 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10368 new NHXParser() )[ 0 ];
10369 species2.setRooted( true );
10370 gene2.setRooted( true );
10371 final SDI sdi2 = new SDI( gene2, species2 );
10372 if ( sdi2.getDuplicationsSum() != 0 ) {
10375 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10378 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10381 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10384 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10387 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10390 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10393 final Phylogeny species3 = factory
10394 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10395 new NHXParser() )[ 0 ];
10396 final Phylogeny gene3 = factory
10397 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10398 new NHXParser() )[ 0 ];
10399 species3.setRooted( true );
10400 gene3.setRooted( true );
10401 final SDI sdi3 = new SDI( gene3, species3 );
10402 if ( sdi3.getDuplicationsSum() != 1 ) {
10405 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10408 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10411 final Phylogeny species4 = factory
10412 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10413 new NHXParser() )[ 0 ];
10414 final Phylogeny gene4 = factory
10415 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10416 new NHXParser() )[ 0 ];
10417 species4.setRooted( true );
10418 gene4.setRooted( true );
10419 final SDI sdi4 = new SDI( gene4, species4 );
10420 if ( sdi4.getDuplicationsSum() != 1 ) {
10423 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10426 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10429 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10432 if ( species4.getNumberOfExternalNodes() != 6 ) {
10435 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10438 final Phylogeny species5 = factory
10439 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10440 new NHXParser() )[ 0 ];
10441 final Phylogeny gene5 = factory
10442 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10443 new NHXParser() )[ 0 ];
10444 species5.setRooted( true );
10445 gene5.setRooted( true );
10446 final SDI sdi5 = new SDI( gene5, species5 );
10447 if ( sdi5.getDuplicationsSum() != 2 ) {
10450 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10453 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10456 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10459 if ( species5.getNumberOfExternalNodes() != 6 ) {
10462 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10465 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10466 // Conjecture for Comparing Molecular Phylogenies"
10467 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10468 final Phylogeny species6 = factory
10469 .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,"
10470 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10471 new NHXParser() )[ 0 ];
10472 final Phylogeny gene6 = factory
10473 .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,"
10474 + "((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,"
10475 + "(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;",
10476 new NHXParser() )[ 0 ];
10477 species6.setRooted( true );
10478 gene6.setRooted( true );
10479 final SDI sdi6 = new SDI( gene6, species6 );
10480 if ( sdi6.getDuplicationsSum() != 3 ) {
10483 if ( !gene6.getNode( "r" ).isDuplication() ) {
10486 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10489 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10492 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10495 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10498 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10501 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10504 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10507 sdi6.computeMappingCostL();
10508 if ( sdi6.computeMappingCostL() != 17 ) {
10511 if ( species6.getNumberOfExternalNodes() != 9 ) {
10514 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10517 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10518 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10519 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10520 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10521 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10522 species7.setRooted( true );
10523 final Phylogeny gene7_1 = Test
10524 .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])" );
10525 gene7_1.setRooted( true );
10526 final SDI sdi7 = new SDI( gene7_1, species7 );
10527 if ( sdi7.getDuplicationsSum() != 0 ) {
10530 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10533 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10536 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10539 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10542 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10545 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10548 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10551 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10554 final Phylogeny gene7_2 = Test
10555 .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])" );
10556 gene7_2.setRooted( true );
10557 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10558 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10561 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10564 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10567 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10570 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10573 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10576 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10579 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10582 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10585 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10589 catch ( final Exception e ) {
10595 private static boolean testSDIunrooted() {
10597 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10598 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10599 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10600 final Iterator<PhylogenyBranch> iter = l.iterator();
10601 PhylogenyBranch br = iter.next();
10602 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10605 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10609 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10612 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10616 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10619 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10623 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10626 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10630 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10633 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10637 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10640 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10644 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10647 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10651 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10654 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10658 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10661 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10665 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10668 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10672 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10675 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10679 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10682 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10686 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10689 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10693 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10696 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10700 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10703 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10706 if ( iter.hasNext() ) {
10709 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10710 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10711 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10713 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10716 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10720 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10723 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10727 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10730 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10733 if ( iter1.hasNext() ) {
10736 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10737 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10738 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10740 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10743 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10747 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10750 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10754 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10757 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10760 if ( iter2.hasNext() ) {
10763 final Phylogeny species0 = factory
10764 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10765 new NHXParser() )[ 0 ];
10766 final Phylogeny gene1 = factory
10767 .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])",
10768 new NHXParser() )[ 0 ];
10769 species0.setRooted( true );
10770 gene1.setRooted( true );
10771 final SDIR sdi_unrooted = new SDIR();
10772 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10773 if ( sdi_unrooted.getCount() != 1 ) {
10776 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10779 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10782 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10785 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10788 final Phylogeny gene2 = factory
10789 .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])",
10790 new NHXParser() )[ 0 ];
10791 gene2.setRooted( true );
10792 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10793 if ( sdi_unrooted.getCount() != 1 ) {
10796 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10799 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10802 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10805 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10808 final Phylogeny species6 = factory
10809 .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,"
10810 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10811 new NHXParser() )[ 0 ];
10812 final Phylogeny gene6 = factory
10813 .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],"
10814 + "(((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],"
10815 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10816 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10817 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10818 new NHXParser() )[ 0 ];
10819 species6.setRooted( true );
10820 gene6.setRooted( true );
10821 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10822 if ( sdi_unrooted.getCount() != 1 ) {
10825 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10828 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10831 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10834 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10837 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10840 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10843 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10846 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10849 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10852 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10855 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10858 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10862 final Phylogeny species7 = factory
10863 .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,"
10864 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10865 new NHXParser() )[ 0 ];
10866 final Phylogeny gene7 = factory
10867 .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],"
10868 + "(((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],"
10869 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10870 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10871 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10872 new NHXParser() )[ 0 ];
10873 species7.setRooted( true );
10874 gene7.setRooted( true );
10875 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10876 if ( sdi_unrooted.getCount() != 1 ) {
10879 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10882 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10885 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10888 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10891 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10894 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10897 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10900 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10903 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10906 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10909 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10912 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10916 final Phylogeny species8 = factory
10917 .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,"
10918 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10919 new NHXParser() )[ 0 ];
10920 final Phylogeny gene8 = factory
10921 .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],"
10922 + "(((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],"
10923 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10924 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10925 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10926 new NHXParser() )[ 0 ];
10927 species8.setRooted( true );
10928 gene8.setRooted( true );
10929 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10930 if ( sdi_unrooted.getCount() != 1 ) {
10933 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10936 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10939 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10942 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10945 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10948 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10951 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10954 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10957 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10960 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10963 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10966 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10971 catch ( final Exception e ) {
10972 e.printStackTrace( System.out );
10978 private static boolean testSequenceDbWsTools1() {
10980 final PhylogenyNode n = new PhylogenyNode();
10981 n.setName( "NP_001025424" );
10982 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10983 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10984 || !acc.getValue().equals( "NP_001025424" ) ) {
10987 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10988 acc = SequenceDbWsTools.obtainSeqAccession( n );
10989 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10990 || !acc.getValue().equals( "NP_001025424" ) ) {
10993 n.setName( "NP_001025424.1" );
10994 acc = SequenceDbWsTools.obtainSeqAccession( n );
10995 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10996 || !acc.getValue().equals( "NP_001025424" ) ) {
10999 n.setName( "NM_001030253" );
11000 acc = SequenceDbWsTools.obtainSeqAccession( n );
11001 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11002 || !acc.getValue().equals( "NM_001030253" ) ) {
11005 n.setName( "BCL2_HUMAN" );
11006 acc = SequenceDbWsTools.obtainSeqAccession( n );
11007 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11008 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11009 System.out.println( acc.toString() );
11012 n.setName( "P10415" );
11013 acc = SequenceDbWsTools.obtainSeqAccession( n );
11014 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11015 || !acc.getValue().equals( "P10415" ) ) {
11016 System.out.println( acc.toString() );
11019 n.setName( " P10415 " );
11020 acc = SequenceDbWsTools.obtainSeqAccession( n );
11021 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11022 || !acc.getValue().equals( "P10415" ) ) {
11023 System.out.println( acc.toString() );
11026 n.setName( "_P10415|" );
11027 acc = SequenceDbWsTools.obtainSeqAccession( n );
11028 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11029 || !acc.getValue().equals( "P10415" ) ) {
11030 System.out.println( acc.toString() );
11033 n.setName( "AY695820" );
11034 acc = SequenceDbWsTools.obtainSeqAccession( n );
11035 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11036 || !acc.getValue().equals( "AY695820" ) ) {
11037 System.out.println( acc.toString() );
11040 n.setName( "_AY695820_" );
11041 acc = SequenceDbWsTools.obtainSeqAccession( n );
11042 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11043 || !acc.getValue().equals( "AY695820" ) ) {
11044 System.out.println( acc.toString() );
11047 n.setName( "AAA59452" );
11048 acc = SequenceDbWsTools.obtainSeqAccession( n );
11049 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11050 || !acc.getValue().equals( "AAA59452" ) ) {
11051 System.out.println( acc.toString() );
11054 n.setName( "_AAA59452_" );
11055 acc = SequenceDbWsTools.obtainSeqAccession( n );
11056 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11057 || !acc.getValue().equals( "AAA59452" ) ) {
11058 System.out.println( acc.toString() );
11061 n.setName( "AAA59452.1" );
11062 acc = SequenceDbWsTools.obtainSeqAccession( n );
11063 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11064 || !acc.getValue().equals( "AAA59452.1" ) ) {
11065 System.out.println( acc.toString() );
11068 n.setName( "_AAA59452.1_" );
11069 acc = SequenceDbWsTools.obtainSeqAccession( n );
11070 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11071 || !acc.getValue().equals( "AAA59452.1" ) ) {
11072 System.out.println( acc.toString() );
11075 n.setName( "GI:94894583" );
11076 acc = SequenceDbWsTools.obtainSeqAccession( n );
11077 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11078 || !acc.getValue().equals( "94894583" ) ) {
11079 System.out.println( acc.toString() );
11082 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11083 acc = SequenceDbWsTools.obtainSeqAccession( n );
11084 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11085 || !acc.getValue().equals( "71845847" ) ) {
11086 System.out.println( acc.toString() );
11089 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11090 acc = SequenceDbWsTools.obtainSeqAccession( n );
11091 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11092 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11093 System.out.println( acc.toString() );
11097 catch ( final Exception e ) {
11103 private static boolean testSequenceDbWsTools2() {
11105 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11106 SequenceDbWsTools.obtainSeqInformation( n1 );
11107 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11110 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11113 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11116 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11119 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11120 SequenceDbWsTools.obtainSeqInformation( n2 );
11121 if ( !n2.getNodeData().getSequence().getName()
11122 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11125 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11128 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11131 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11134 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11135 SequenceDbWsTools.obtainSeqInformation( n3 );
11136 if ( !n3.getNodeData().getSequence().getName()
11137 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11140 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11143 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11146 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11150 catch ( final IOException e ) {
11151 System.out.println();
11152 System.out.println( "the following might be due to absence internet connection:" );
11153 e.printStackTrace( System.out );
11156 catch ( final Exception e ) {
11157 e.printStackTrace();
11163 private static boolean testSequenceIdParsing() {
11165 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11166 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11167 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11168 if ( id != null ) {
11169 System.out.println( "value =" + id.getValue() );
11170 System.out.println( "provider=" + id.getSource() );
11175 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11176 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11177 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11178 if ( id != null ) {
11179 System.out.println( "value =" + id.getValue() );
11180 System.out.println( "provider=" + id.getSource() );
11185 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11186 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11187 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11188 if ( id != null ) {
11189 System.out.println( "value =" + id.getValue() );
11190 System.out.println( "provider=" + id.getSource() );
11195 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11196 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11197 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11198 if ( id != null ) {
11199 System.out.println( "value =" + id.getValue() );
11200 System.out.println( "provider=" + id.getSource() );
11205 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11206 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11207 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11208 if ( id != null ) {
11209 System.out.println( "value =" + id.getValue() );
11210 System.out.println( "provider=" + id.getSource() );
11215 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11216 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11217 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11218 if ( id != null ) {
11219 System.out.println( "value =" + id.getValue() );
11220 System.out.println( "provider=" + id.getSource() );
11225 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11226 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11227 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11228 if ( id != null ) {
11229 System.out.println( "value =" + id.getValue() );
11230 System.out.println( "provider=" + id.getSource() );
11235 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11236 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11237 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11238 if ( id != null ) {
11239 System.out.println( "value =" + id.getValue() );
11240 System.out.println( "provider=" + id.getSource() );
11245 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11246 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11247 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11248 if ( id != null ) {
11249 System.out.println( "value =" + id.getValue() );
11250 System.out.println( "provider=" + id.getSource() );
11255 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11256 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11257 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11258 if ( id != null ) {
11259 System.out.println( "value =" + id.getValue() );
11260 System.out.println( "provider=" + id.getSource() );
11264 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11265 if ( id != null ) {
11266 System.out.println( "value =" + id.getValue() );
11267 System.out.println( "provider=" + id.getSource() );
11271 catch ( final Exception e ) {
11272 e.printStackTrace( System.out );
11278 private static boolean testSequenceWriter() {
11280 final String n = ForesterUtil.LINE_SEPARATOR;
11281 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11284 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11287 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11290 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11293 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11294 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11297 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11298 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11302 catch ( final Exception e ) {
11303 e.printStackTrace();
11309 private static boolean testSpecies() {
11311 final Species s1 = new BasicSpecies( "a" );
11312 final Species s2 = new BasicSpecies( "a" );
11313 final Species s3 = new BasicSpecies( "A" );
11314 final Species s4 = new BasicSpecies( "b" );
11315 if ( !s1.equals( s1 ) ) {
11318 if ( s1.getSpeciesId().equals( "x" ) ) {
11321 if ( s1.getSpeciesId().equals( null ) ) {
11324 if ( !s1.equals( s2 ) ) {
11327 if ( s1.equals( s3 ) ) {
11330 if ( s1.hashCode() != s1.hashCode() ) {
11333 if ( s1.hashCode() != s2.hashCode() ) {
11336 if ( s1.hashCode() == s3.hashCode() ) {
11339 if ( s1.compareTo( s1 ) != 0 ) {
11342 if ( s1.compareTo( s2 ) != 0 ) {
11345 if ( s1.compareTo( s3 ) != 0 ) {
11348 if ( s1.compareTo( s4 ) >= 0 ) {
11351 if ( s4.compareTo( s1 ) <= 0 ) {
11354 if ( !s4.getSpeciesId().equals( "b" ) ) {
11357 final Species s5 = new BasicSpecies( " C " );
11358 if ( !s5.getSpeciesId().equals( "C" ) ) {
11361 if ( s5.equals( s1 ) ) {
11365 catch ( final Exception e ) {
11366 e.printStackTrace( System.out );
11372 private static boolean testSplit() {
11374 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11375 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11376 //Archaeopteryx.createApplication( p0 );
11377 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11378 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11379 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11380 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11381 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11382 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11383 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11384 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11385 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11386 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11387 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11388 // System.out.println( s0.toString() );
11390 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11393 if ( s0.match( query_nodes ) ) {
11396 query_nodes = new HashSet<PhylogenyNode>();
11397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11404 if ( !s0.match( query_nodes ) ) {
11408 query_nodes = new HashSet<PhylogenyNode>();
11409 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11412 if ( !s0.match( query_nodes ) ) {
11416 query_nodes = new HashSet<PhylogenyNode>();
11417 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11418 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11421 if ( !s0.match( query_nodes ) ) {
11425 query_nodes = new HashSet<PhylogenyNode>();
11426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11430 if ( !s0.match( query_nodes ) ) {
11434 query_nodes = new HashSet<PhylogenyNode>();
11435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11438 if ( !s0.match( query_nodes ) ) {
11442 query_nodes = new HashSet<PhylogenyNode>();
11443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11445 if ( !s0.match( query_nodes ) ) {
11449 query_nodes = new HashSet<PhylogenyNode>();
11450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11455 if ( !s0.match( query_nodes ) ) {
11459 query_nodes = new HashSet<PhylogenyNode>();
11460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11463 if ( !s0.match( query_nodes ) ) {
11467 query_nodes = new HashSet<PhylogenyNode>();
11468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11469 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11472 if ( !s0.match( query_nodes ) ) {
11476 query_nodes = new HashSet<PhylogenyNode>();
11477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11479 if ( s0.match( query_nodes ) ) {
11483 query_nodes = new HashSet<PhylogenyNode>();
11484 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11488 if ( s0.match( query_nodes ) ) {
11492 query_nodes = new HashSet<PhylogenyNode>();
11493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11498 if ( s0.match( query_nodes ) ) {
11502 query_nodes = new HashSet<PhylogenyNode>();
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11505 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11506 if ( s0.match( query_nodes ) ) {
11510 query_nodes = new HashSet<PhylogenyNode>();
11511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11513 if ( s0.match( query_nodes ) ) {
11517 query_nodes = new HashSet<PhylogenyNode>();
11518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11520 if ( s0.match( query_nodes ) ) {
11524 query_nodes = new HashSet<PhylogenyNode>();
11525 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11527 if ( s0.match( query_nodes ) ) {
11531 query_nodes = new HashSet<PhylogenyNode>();
11532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11533 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11534 if ( s0.match( query_nodes ) ) {
11538 query_nodes = new HashSet<PhylogenyNode>();
11539 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11540 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11541 if ( s0.match( query_nodes ) ) {
11545 query_nodes = new HashSet<PhylogenyNode>();
11546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11548 if ( s0.match( query_nodes ) ) {
11552 query_nodes = new HashSet<PhylogenyNode>();
11553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11556 if ( s0.match( query_nodes ) ) {
11560 query_nodes = new HashSet<PhylogenyNode>();
11561 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11564 if ( s0.match( query_nodes ) ) {
11568 query_nodes = new HashSet<PhylogenyNode>();
11569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11572 if ( s0.match( query_nodes ) ) {
11576 query_nodes = new HashSet<PhylogenyNode>();
11577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11581 if ( s0.match( query_nodes ) ) {
11585 // query_nodes = new HashSet<PhylogenyNode>();
11586 // query_nodes.add( new PhylogenyNode( "X" ) );
11587 // query_nodes.add( new PhylogenyNode( "Y" ) );
11588 // query_nodes.add( new PhylogenyNode( "A" ) );
11589 // query_nodes.add( new PhylogenyNode( "B" ) );
11590 // query_nodes.add( new PhylogenyNode( "C" ) );
11591 // query_nodes.add( new PhylogenyNode( "D" ) );
11592 // query_nodes.add( new PhylogenyNode( "E" ) );
11593 // query_nodes.add( new PhylogenyNode( "F" ) );
11594 // query_nodes.add( new PhylogenyNode( "G" ) );
11595 // if ( !s0.match( query_nodes ) ) {
11598 // query_nodes = new HashSet<PhylogenyNode>();
11599 // query_nodes.add( new PhylogenyNode( "X" ) );
11600 // query_nodes.add( new PhylogenyNode( "Y" ) );
11601 // query_nodes.add( new PhylogenyNode( "A" ) );
11602 // query_nodes.add( new PhylogenyNode( "B" ) );
11603 // query_nodes.add( new PhylogenyNode( "C" ) );
11604 // if ( !s0.match( query_nodes ) ) {
11608 // query_nodes = new HashSet<PhylogenyNode>();
11609 // query_nodes.add( new PhylogenyNode( "X" ) );
11610 // query_nodes.add( new PhylogenyNode( "Y" ) );
11611 // query_nodes.add( new PhylogenyNode( "D" ) );
11612 // query_nodes.add( new PhylogenyNode( "E" ) );
11613 // query_nodes.add( new PhylogenyNode( "F" ) );
11614 // query_nodes.add( new PhylogenyNode( "G" ) );
11615 // if ( !s0.match( query_nodes ) ) {
11619 // query_nodes = new HashSet<PhylogenyNode>();
11620 // query_nodes.add( new PhylogenyNode( "X" ) );
11621 // query_nodes.add( new PhylogenyNode( "Y" ) );
11622 // query_nodes.add( new PhylogenyNode( "A" ) );
11623 // query_nodes.add( new PhylogenyNode( "B" ) );
11624 // query_nodes.add( new PhylogenyNode( "C" ) );
11625 // query_nodes.add( new PhylogenyNode( "D" ) );
11626 // if ( !s0.match( query_nodes ) ) {
11630 // query_nodes = new HashSet<PhylogenyNode>();
11631 // query_nodes.add( new PhylogenyNode( "X" ) );
11632 // query_nodes.add( new PhylogenyNode( "Y" ) );
11633 // query_nodes.add( new PhylogenyNode( "E" ) );
11634 // query_nodes.add( new PhylogenyNode( "F" ) );
11635 // query_nodes.add( new PhylogenyNode( "G" ) );
11636 // if ( !s0.match( query_nodes ) ) {
11640 // query_nodes = new HashSet<PhylogenyNode>();
11641 // query_nodes.add( new PhylogenyNode( "X" ) );
11642 // query_nodes.add( new PhylogenyNode( "Y" ) );
11643 // query_nodes.add( new PhylogenyNode( "F" ) );
11644 // query_nodes.add( new PhylogenyNode( "G" ) );
11645 // if ( !s0.match( query_nodes ) ) {
11649 query_nodes = new HashSet<PhylogenyNode>();
11650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11654 if ( s0.match( query_nodes ) ) {
11658 query_nodes = new HashSet<PhylogenyNode>();
11659 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11663 if ( s0.match( query_nodes ) ) {
11666 ///////////////////////////
11668 query_nodes = new HashSet<PhylogenyNode>();
11669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11670 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11673 if ( s0.match( query_nodes ) ) {
11677 query_nodes = new HashSet<PhylogenyNode>();
11678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11682 if ( s0.match( query_nodes ) ) {
11686 query_nodes = new HashSet<PhylogenyNode>();
11687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11691 if ( s0.match( query_nodes ) ) {
11695 query_nodes = new HashSet<PhylogenyNode>();
11696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11700 if ( s0.match( query_nodes ) ) {
11704 query_nodes = new HashSet<PhylogenyNode>();
11705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11709 if ( s0.match( query_nodes ) ) {
11713 query_nodes = new HashSet<PhylogenyNode>();
11714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11717 if ( s0.match( query_nodes ) ) {
11721 query_nodes = new HashSet<PhylogenyNode>();
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11727 if ( s0.match( query_nodes ) ) {
11731 query_nodes = new HashSet<PhylogenyNode>();
11732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11733 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11734 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11737 if ( s0.match( query_nodes ) ) {
11741 query_nodes = new HashSet<PhylogenyNode>();
11742 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11747 if ( s0.match( query_nodes ) ) {
11751 query_nodes = new HashSet<PhylogenyNode>();
11752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11758 if ( s0.match( query_nodes ) ) {
11762 catch ( final Exception e ) {
11763 e.printStackTrace();
11769 private static boolean testSplitStrict() {
11771 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11772 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11773 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11774 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11775 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11776 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11777 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11778 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11779 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11780 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11781 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11782 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11785 if ( s0.match( query_nodes ) ) {
11788 query_nodes = new HashSet<PhylogenyNode>();
11789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11796 if ( !s0.match( query_nodes ) ) {
11800 query_nodes = new HashSet<PhylogenyNode>();
11801 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11802 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11804 if ( !s0.match( query_nodes ) ) {
11808 query_nodes = new HashSet<PhylogenyNode>();
11809 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11810 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11811 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11813 if ( !s0.match( query_nodes ) ) {
11817 query_nodes = new HashSet<PhylogenyNode>();
11818 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11819 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11822 if ( !s0.match( query_nodes ) ) {
11826 query_nodes = new HashSet<PhylogenyNode>();
11827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11830 if ( !s0.match( query_nodes ) ) {
11834 query_nodes = new HashSet<PhylogenyNode>();
11835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11836 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11837 if ( !s0.match( query_nodes ) ) {
11841 query_nodes = new HashSet<PhylogenyNode>();
11842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11844 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11845 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11847 if ( !s0.match( query_nodes ) ) {
11851 query_nodes = new HashSet<PhylogenyNode>();
11852 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11855 if ( !s0.match( query_nodes ) ) {
11859 query_nodes = new HashSet<PhylogenyNode>();
11860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11864 if ( !s0.match( query_nodes ) ) {
11868 query_nodes = new HashSet<PhylogenyNode>();
11869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11871 if ( s0.match( query_nodes ) ) {
11875 query_nodes = new HashSet<PhylogenyNode>();
11876 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11880 if ( s0.match( query_nodes ) ) {
11884 query_nodes = new HashSet<PhylogenyNode>();
11885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11890 if ( s0.match( query_nodes ) ) {
11894 query_nodes = new HashSet<PhylogenyNode>();
11895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11898 if ( s0.match( query_nodes ) ) {
11902 query_nodes = new HashSet<PhylogenyNode>();
11903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11904 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11905 if ( s0.match( query_nodes ) ) {
11909 query_nodes = new HashSet<PhylogenyNode>();
11910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11912 if ( s0.match( query_nodes ) ) {
11916 query_nodes = new HashSet<PhylogenyNode>();
11917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11919 if ( s0.match( query_nodes ) ) {
11923 query_nodes = new HashSet<PhylogenyNode>();
11924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11926 if ( s0.match( query_nodes ) ) {
11930 query_nodes = new HashSet<PhylogenyNode>();
11931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11933 if ( s0.match( query_nodes ) ) {
11937 query_nodes = new HashSet<PhylogenyNode>();
11938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11940 if ( s0.match( query_nodes ) ) {
11944 query_nodes = new HashSet<PhylogenyNode>();
11945 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11948 if ( s0.match( query_nodes ) ) {
11952 query_nodes = new HashSet<PhylogenyNode>();
11953 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11956 if ( s0.match( query_nodes ) ) {
11960 query_nodes = new HashSet<PhylogenyNode>();
11961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11964 if ( s0.match( query_nodes ) ) {
11968 query_nodes = new HashSet<PhylogenyNode>();
11969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11973 if ( s0.match( query_nodes ) ) {
11977 catch ( final Exception e ) {
11978 e.printStackTrace();
11984 private static boolean testSubtreeDeletion() {
11986 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11987 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11988 t1.deleteSubtree( t1.getNode( "A" ), false );
11989 if ( t1.getNumberOfExternalNodes() != 5 ) {
11992 t1.toNewHampshireX();
11993 t1.deleteSubtree( t1.getNode( "E" ), false );
11994 if ( t1.getNumberOfExternalNodes() != 4 ) {
11997 t1.toNewHampshireX();
11998 t1.deleteSubtree( t1.getNode( "F" ), false );
11999 if ( t1.getNumberOfExternalNodes() != 3 ) {
12002 t1.toNewHampshireX();
12003 t1.deleteSubtree( t1.getNode( "D" ), false );
12004 t1.toNewHampshireX();
12005 if ( t1.getNumberOfExternalNodes() != 3 ) {
12008 t1.deleteSubtree( t1.getNode( "def" ), false );
12009 t1.toNewHampshireX();
12010 if ( t1.getNumberOfExternalNodes() != 2 ) {
12013 t1.deleteSubtree( t1.getNode( "B" ), false );
12014 t1.toNewHampshireX();
12015 if ( t1.getNumberOfExternalNodes() != 1 ) {
12018 t1.deleteSubtree( t1.getNode( "C" ), false );
12019 t1.toNewHampshireX();
12020 if ( t1.getNumberOfExternalNodes() != 1 ) {
12023 t1.deleteSubtree( t1.getNode( "abc" ), false );
12024 t1.toNewHampshireX();
12025 if ( t1.getNumberOfExternalNodes() != 1 ) {
12028 t1.deleteSubtree( t1.getNode( "r" ), false );
12029 if ( t1.getNumberOfExternalNodes() != 0 ) {
12032 if ( !t1.isEmpty() ) {
12035 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12036 t2.deleteSubtree( t2.getNode( "A" ), false );
12037 t2.toNewHampshireX();
12038 if ( t2.getNumberOfExternalNodes() != 5 ) {
12041 t2.deleteSubtree( t2.getNode( "abc" ), false );
12042 t2.toNewHampshireX();
12043 if ( t2.getNumberOfExternalNodes() != 3 ) {
12046 t2.deleteSubtree( t2.getNode( "def" ), false );
12047 t2.toNewHampshireX();
12048 if ( t2.getNumberOfExternalNodes() != 1 ) {
12052 catch ( final Exception e ) {
12053 e.printStackTrace( System.out );
12059 private static boolean testSupportCount() {
12061 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12062 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12063 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12064 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12065 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12066 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12067 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12069 SupportCount.count( t0_1, phylogenies_1, true, false );
12070 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12071 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12072 + "(((((A,B),C),D),E),((F,G),X))"
12073 + "(((((A,Y),B),C),D),((F,G),E))"
12074 + "(((((A,B),C),D),E),(F,G))"
12075 + "(((((A,B),C),D),E),(F,G))"
12076 + "(((((A,B),C),D),E),(F,G))"
12077 + "(((((A,B),C),D),E),(F,G),Z)"
12078 + "(((((A,B),C),D),E),(F,G))"
12079 + "((((((A,B),C),D),E),F),G)"
12080 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12082 SupportCount.count( t0_2, phylogenies_2, true, false );
12083 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12084 while ( it.hasNext() ) {
12085 final PhylogenyNode n = it.next();
12086 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12090 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12091 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12092 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12093 SupportCount.count( t0_3, phylogenies_3, true, false );
12094 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12095 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12098 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12101 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12104 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12107 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12110 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12113 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12116 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12119 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12122 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12125 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12126 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12127 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12128 SupportCount.count( t0_4, phylogenies_4, true, false );
12129 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12130 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12133 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12136 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12139 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12142 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12145 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12148 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12151 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12154 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12157 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12160 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12161 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12162 double d = SupportCount.compare( b1, a, true, true, true );
12163 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12166 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12167 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12168 d = SupportCount.compare( b2, a, true, true, true );
12169 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12172 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12173 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12174 d = SupportCount.compare( b3, a, true, true, true );
12175 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12178 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12179 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12180 d = SupportCount.compare( b4, a, true, true, false );
12181 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12185 catch ( final Exception e ) {
12186 e.printStackTrace( System.out );
12192 private static boolean testSupportTransfer() {
12194 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12195 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)",
12196 new NHXParser() )[ 0 ];
12197 final Phylogeny p2 = factory
12198 .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 ];
12199 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12202 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12205 support_transfer.moveBranchLengthsToBootstrap( p1 );
12206 support_transfer.transferSupportValues( p1, p2 );
12207 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12210 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12213 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12216 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12219 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12222 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12225 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12228 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12232 catch ( final Exception e ) {
12233 e.printStackTrace( System.out );
12239 private static boolean testTaxonomyExtraction() {
12241 final PhylogenyNode n0 = PhylogenyNode
12242 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12243 if ( n0.getNodeData().isHasTaxonomy() ) {
12246 final PhylogenyNode n1 = PhylogenyNode
12247 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12248 if ( n1.getNodeData().isHasTaxonomy() ) {
12249 System.out.println( n1.toString() );
12252 final PhylogenyNode n2x = PhylogenyNode
12253 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12254 if ( n2x.getNodeData().isHasTaxonomy() ) {
12257 final PhylogenyNode n3 = PhylogenyNode
12258 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12259 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12260 System.out.println( n3.toString() );
12263 final PhylogenyNode n4 = PhylogenyNode
12264 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12265 if ( n4.getNodeData().isHasTaxonomy() ) {
12266 System.out.println( n4.toString() );
12269 final PhylogenyNode n5 = PhylogenyNode
12270 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12271 if ( n5.getNodeData().isHasTaxonomy() ) {
12272 System.out.println( n5.toString() );
12275 final PhylogenyNode n6 = PhylogenyNode
12276 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12277 if ( n6.getNodeData().isHasTaxonomy() ) {
12278 System.out.println( n6.toString() );
12281 final PhylogenyNode n7 = PhylogenyNode
12282 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12283 if ( n7.getNodeData().isHasTaxonomy() ) {
12284 System.out.println( n7.toString() );
12287 final PhylogenyNode n8 = PhylogenyNode
12288 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12289 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12290 System.out.println( n8.toString() );
12293 final PhylogenyNode n9 = PhylogenyNode
12294 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12295 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12296 System.out.println( n9.toString() );
12299 final PhylogenyNode n10x = PhylogenyNode
12300 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12301 if ( n10x.getNodeData().isHasTaxonomy() ) {
12302 System.out.println( n10x.toString() );
12305 final PhylogenyNode n10xx = PhylogenyNode
12306 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12307 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12308 System.out.println( n10xx.toString() );
12311 final PhylogenyNode n10 = PhylogenyNode
12312 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12313 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12314 System.out.println( n10.toString() );
12317 final PhylogenyNode n11 = PhylogenyNode
12318 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12319 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12320 System.out.println( n11.toString() );
12323 final PhylogenyNode n12 = PhylogenyNode
12324 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12325 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12326 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12327 System.out.println( n12.toString() );
12330 final PhylogenyNode n13 = PhylogenyNode
12331 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12332 if ( n13.getNodeData().isHasTaxonomy() ) {
12333 System.out.println( n13.toString() );
12336 final PhylogenyNode n14 = PhylogenyNode
12337 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12338 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12339 System.out.println( n14.toString() );
12342 final PhylogenyNode n15 = PhylogenyNode
12343 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12344 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12345 System.out.println( n15.toString() );
12348 final PhylogenyNode n16 = PhylogenyNode
12349 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12350 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12351 System.out.println( n16.toString() );
12354 final PhylogenyNode n17 = PhylogenyNode
12355 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12356 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12357 System.out.println( n17.toString() );
12361 final PhylogenyNode n18 = PhylogenyNode
12362 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12363 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12364 System.out.println( n18.toString() );
12367 final PhylogenyNode n19 = PhylogenyNode
12368 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12369 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12370 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12371 System.out.println( n19.toString() );
12374 final PhylogenyNode n20 = PhylogenyNode
12375 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12376 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12377 System.out.println( n20.toString() );
12380 final PhylogenyNode n21 = PhylogenyNode
12381 .createInstanceFromNhxString( "Mus musculus musculus K392",
12382 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12383 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12384 System.out.println( n21.toString() );
12387 final PhylogenyNode n22 = PhylogenyNode
12388 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12389 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12390 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12391 System.out.println( n22.toString() );
12394 final PhylogenyNode n23 = PhylogenyNode
12395 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12396 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12397 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12398 System.out.println( n23.toString() );
12401 final PhylogenyNode n24 = PhylogenyNode
12402 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12403 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12404 System.out.println( n24.toString() );
12408 final PhylogenyNode n25 = PhylogenyNode
12409 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12410 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12411 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12412 System.out.println( n25.toString() );
12415 final PhylogenyNode n26 = PhylogenyNode
12416 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12417 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12418 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12419 System.out.println( n26.toString() );
12422 final PhylogenyNode n27 = PhylogenyNode
12423 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12424 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12425 System.out.println( n27.toString() );
12429 catch ( final Exception e ) {
12430 e.printStackTrace( System.out );
12436 private static boolean testTreeCopy() {
12438 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12439 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12440 final Phylogeny t1 = t0.copy();
12441 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12444 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12447 t0.deleteSubtree( t0.getNode( "c" ), true );
12448 t0.deleteSubtree( t0.getNode( "a" ), true );
12449 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12450 t0.getNode( "b" ).setName( "Bee" );
12451 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12454 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12457 t0.deleteSubtree( t0.getNode( "e" ), true );
12458 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12459 t0.deleteSubtree( t0.getNode( "d" ), true );
12460 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12464 catch ( final Exception e ) {
12465 e.printStackTrace();
12471 private static boolean testTreeMethods() {
12473 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12474 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12475 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12476 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12477 System.out.println( t0.toNewHampshireX() );
12480 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12481 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12482 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12485 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12488 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12492 catch ( final Exception e ) {
12493 e.printStackTrace( System.out );
12499 private static boolean testUniprotEntryRetrieval() {
12501 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12502 if ( !entry.getAccession().equals( "P12345" ) ) {
12505 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12508 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12511 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12514 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12517 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12521 catch ( final IOException e ) {
12522 System.out.println();
12523 System.out.println( "the following might be due to absence internet connection:" );
12524 e.printStackTrace( System.out );
12527 catch ( final Exception e ) {
12533 private static boolean testUniprotTaxonomySearch() {
12535 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12537 if ( results.size() != 1 ) {
12540 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12543 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12546 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12549 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12552 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12556 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12557 if ( results.size() != 1 ) {
12560 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12563 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12566 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12569 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12572 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12576 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12577 if ( results.size() != 1 ) {
12580 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12583 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12586 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12589 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12592 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12596 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12597 if ( results.size() != 1 ) {
12600 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12603 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12606 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12609 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12612 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12615 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12618 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12621 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12622 .equals( "Nematostella vectensis" ) ) {
12623 System.out.println( results.get( 0 ).getLineage() );
12628 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12629 if ( results.size() != 1 ) {
12632 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12635 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12638 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12641 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12644 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12647 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12648 .equals( "Xenopus tropicalis" ) ) {
12649 System.out.println( results.get( 0 ).getLineage() );
12654 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12655 if ( results.size() != 1 ) {
12658 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12661 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12664 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12667 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12670 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12673 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12674 .equals( "Xenopus tropicalis" ) ) {
12675 System.out.println( results.get( 0 ).getLineage() );
12680 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12681 if ( results.size() != 1 ) {
12684 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12687 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12690 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12693 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12696 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12699 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12700 .equals( "Xenopus tropicalis" ) ) {
12701 System.out.println( results.get( 0 ).getLineage() );
12705 catch ( final IOException e ) {
12706 System.out.println();
12707 System.out.println( "the following might be due to absence internet connection:" );
12708 e.printStackTrace( System.out );
12711 catch ( final Exception e ) {
12717 private static boolean testWabiTxSearch() {
12719 String result = "";
12720 result = TxSearch.searchSimple( "nematostella" );
12721 result = TxSearch.getTxId( "nematostella" );
12722 if ( !result.equals( "45350" ) ) {
12725 result = TxSearch.getTxName( "45350" );
12726 if ( !result.equals( "Nematostella" ) ) {
12729 result = TxSearch.getTxId( "nematostella vectensis" );
12730 if ( !result.equals( "45351" ) ) {
12733 result = TxSearch.getTxName( "45351" );
12734 if ( !result.equals( "Nematostella vectensis" ) ) {
12737 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12738 if ( !result.equals( "536089" ) ) {
12741 result = TxSearch.getTxName( "536089" );
12742 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12745 final List<String> queries = new ArrayList<String>();
12746 queries.add( "Campylobacter coli" );
12747 queries.add( "Escherichia coli" );
12748 queries.add( "Arabidopsis" );
12749 queries.add( "Trichoplax" );
12750 queries.add( "Samanea saman" );
12751 queries.add( "Kluyveromyces marxianus" );
12752 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12753 queries.add( "Bornavirus parrot/PDD/2008" );
12754 final List<RANKS> ranks = new ArrayList<RANKS>();
12755 ranks.add( RANKS.SUPERKINGDOM );
12756 ranks.add( RANKS.KINGDOM );
12757 ranks.add( RANKS.FAMILY );
12758 ranks.add( RANKS.GENUS );
12759 ranks.add( RANKS.TRIBE );
12760 result = TxSearch.searchLineage( queries, ranks );
12761 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12762 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12764 catch ( final Exception e ) {
12765 System.out.println();
12766 System.out.println( "the following might be due to absence internet connection:" );
12767 e.printStackTrace( System.out );