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." );
916 if ( PERFORM_DB_TESTS ) {
917 System.out.print( "Uniprot Entry Retrieval: " );
918 if ( Test.testUniprotEntryRetrieval() ) {
919 System.out.println( "OK." );
923 System.out.println( "failed." );
926 System.out.print( "Ebi Entry Retrieval: " );
927 if ( Test.testEbiEntryRetrieval() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Sequence DB tools 2: " );
936 if ( testSequenceDbWsTools2() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
945 System.out.print( "Uniprot Taxonomy Search: " );
946 if ( Test.testUniprotTaxonomySearch() ) {
947 System.out.println( "OK." );
951 System.out.println( "failed." );
955 if ( PERFORM_WEB_TREE_ACCESS ) {
956 System.out.print( "NHX parsing from URL: " );
957 if ( Test.testNHXparsingFromURL() ) {
958 System.out.println( "OK." );
962 System.out.println( "failed." );
965 System.out.print( "phyloXML parsing from URL: " );
966 if ( Test.testPhyloXMLparsingFromURL() ) {
967 System.out.println( "OK." );
971 System.out.println( "failed." );
974 System.out.print( "TreeBase acccess: " );
975 if ( Test.testTreeBaseReading() ) {
976 System.out.println( "OK." );
980 System.out.println( "failed." );
984 System.out.print( "ToL access: " );
985 if ( Test.testToLReading() ) {
986 System.out.println( "OK." );
990 System.out.println( "failed." );
994 System.out.print( "TreeFam access: " );
995 if ( Test.testTreeFamReading() ) {
996 System.out.println( "OK." );
1000 System.out.println( "failed." );
1005 System.out.print( "Pfam tree access: " );
1006 if ( Test.testPfamTreeReading() ) {
1007 System.out.println( "OK." );
1011 System.out.println( "failed." );
1015 System.out.println();
1016 final Runtime rt = java.lang.Runtime.getRuntime();
1017 final long free_memory = rt.freeMemory() / 1000000;
1018 final long total_memory = rt.totalMemory() / 1000000;
1019 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1020 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1021 System.out.println();
1022 System.out.println( "Successful tests: " + succeeded );
1023 System.out.println( "Failed tests: " + failed );
1024 System.out.println();
1026 System.out.println( "OK." );
1029 System.out.println( "Not OK." );
1033 public static boolean testEngulfingOverlapRemoval() {
1035 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1036 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1037 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1038 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1039 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1040 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1041 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1042 final List<Boolean> covered = new ArrayList<Boolean>();
1043 covered.add( true ); // 0
1044 covered.add( false ); // 1
1045 covered.add( true ); // 2
1046 covered.add( false ); // 3
1047 covered.add( true ); // 4
1048 covered.add( true ); // 5
1049 covered.add( false ); // 6
1050 covered.add( true ); // 7
1051 covered.add( true ); // 8
1052 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1055 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1058 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1061 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1064 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1067 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1070 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1073 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1074 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1075 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1076 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1077 abc.addProteinDomain( a );
1078 abc.addProteinDomain( b );
1079 abc.addProteinDomain( c );
1080 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1081 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1082 if ( abc.getNumberOfProteinDomains() != 3 ) {
1085 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1088 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1091 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1094 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1097 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1098 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1099 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1100 final Protein def = new BasicProtein( "def", "nemve", 0 );
1101 def.addProteinDomain( d );
1102 def.addProteinDomain( e );
1103 def.addProteinDomain( f );
1104 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1105 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1106 if ( def.getNumberOfProteinDomains() != 3 ) {
1109 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1112 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1115 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1118 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1121 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1125 catch ( final Exception e ) {
1126 e.printStackTrace( System.out );
1132 public static final boolean testNHXparsingFromURL() {
1134 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1135 final URL u = new URL( s );
1136 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1137 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1138 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1141 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1142 System.out.println( phys[ 0 ].toNewHampshire() );
1145 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1146 System.out.println( phys[ 1 ].toNewHampshire() );
1149 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1150 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1153 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1154 System.out.println( phys2[ 0 ].toNewHampshire() );
1157 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1158 final NHXParser p = new NHXParser();
1159 final URL u2 = new URL( s );
1161 if ( !p.hasNext() ) {
1164 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1167 if ( !p.hasNext() ) {
1171 if ( !p.hasNext() ) {
1174 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1177 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1181 if ( !p.hasNext() ) {
1184 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1187 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1191 catch ( final Exception e ) {
1192 e.printStackTrace();
1197 public static boolean testOverlapRemoval() {
1199 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1200 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1201 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1202 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1203 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1204 final List<Boolean> covered = new ArrayList<Boolean>();
1205 covered.add( true ); // 0
1206 covered.add( false ); // 1
1207 covered.add( true ); // 2
1208 covered.add( false ); // 3
1209 covered.add( true ); // 4
1210 covered.add( true ); // 5
1211 covered.add( false ); // 6
1212 covered.add( true ); // 7
1213 covered.add( true ); // 8
1214 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1217 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1220 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1223 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1226 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1229 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1230 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1231 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1232 ab.addProteinDomain( a );
1233 ab.addProteinDomain( b );
1234 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1235 if ( ab.getNumberOfProteinDomains() != 2 ) {
1238 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1241 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1244 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1245 if ( ab.getNumberOfProteinDomains() != 2 ) {
1248 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1251 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1252 final Domain d = new BasicDomain( "d",
1259 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1260 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1261 cde.addProteinDomain( c );
1262 cde.addProteinDomain( d );
1263 cde.addProteinDomain( e );
1264 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1265 if ( cde.getNumberOfProteinDomains() != 3 ) {
1268 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1271 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1272 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1273 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1274 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1275 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1276 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1277 fghi.addProteinDomain( f );
1278 fghi.addProteinDomain( g );
1279 fghi.addProteinDomain( h );
1280 fghi.addProteinDomain( i );
1281 fghi.addProteinDomain( i );
1282 fghi.addProteinDomain( i );
1283 fghi.addProteinDomain( i2 );
1284 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1285 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1288 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1291 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1294 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1295 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1298 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1301 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1302 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1303 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1304 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1305 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1306 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1307 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1308 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1309 jklm.addProteinDomain( j );
1310 jklm.addProteinDomain( k );
1311 jklm.addProteinDomain( l );
1312 jklm.addProteinDomain( m );
1313 jklm.addProteinDomain( m0 );
1314 jklm.addProteinDomain( m1 );
1315 jklm.addProteinDomain( m2 );
1316 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1317 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1320 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1323 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1326 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1327 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1330 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1333 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1334 final Protein od = new BasicProtein( "od", "varanus", 0 );
1335 od.addProteinDomain( only );
1336 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1337 if ( od.getNumberOfProteinDomains() != 1 ) {
1340 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1344 catch ( final Exception e ) {
1345 e.printStackTrace( System.out );
1351 public static final boolean testPfamTreeReading() {
1353 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1354 final NHXParser parser = new NHXParser();
1355 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1356 parser.setReplaceUnderscores( false );
1357 parser.setGuessRootedness( true );
1358 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1359 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1360 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1363 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1367 catch ( final Exception e ) {
1368 e.printStackTrace();
1373 public static final boolean testPhyloXMLparsingFromURL() {
1375 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1376 final URL u = new URL( s );
1377 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1378 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1379 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1383 catch ( final Exception e ) {
1384 e.printStackTrace();
1389 public static final boolean testToLReading() {
1391 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1392 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1393 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1394 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1397 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1400 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1403 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1407 catch ( final Exception e ) {
1408 e.printStackTrace();
1413 public static final boolean testTreeBaseReading() {
1415 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1416 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1417 parser.setReplaceUnderscores( true );
1418 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1419 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1420 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1423 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1424 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1425 parser2.setReplaceUnderscores( true );
1426 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1427 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1428 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1432 catch ( final Exception e ) {
1433 e.printStackTrace();
1438 public static final boolean testTreeFamReading() {
1440 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1441 final NHXParser parser = new NHXParser();
1442 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1443 parser.setReplaceUnderscores( false );
1444 parser.setGuessRootedness( true );
1445 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1446 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1447 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1450 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1454 catch ( final Exception e ) {
1455 e.printStackTrace();
1460 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1461 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1465 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1466 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1469 private static boolean testAminoAcidSequence() {
1471 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1472 if ( aa1.getLength() != 13 ) {
1475 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1478 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1481 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1484 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1485 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1488 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1489 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1492 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1493 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1497 catch ( final Exception e ) {
1498 e.printStackTrace();
1504 private static boolean testBasicDomain() {
1506 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1507 if ( !pd.getDomainId().equals( "id" ) ) {
1510 if ( pd.getNumber() != 1 ) {
1513 if ( pd.getTotalCount() != 4 ) {
1516 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1519 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1520 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1521 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1522 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1523 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1524 if ( !a1.equals( a1 ) ) {
1527 if ( !a1.equals( a1_copy ) ) {
1530 if ( !a1.equals( a1_equal ) ) {
1533 if ( !a1.equals( a2 ) ) {
1536 if ( a1.equals( a3 ) ) {
1539 if ( a1.compareTo( a1 ) != 0 ) {
1542 if ( a1.compareTo( a1_copy ) != 0 ) {
1545 if ( a1.compareTo( a1_equal ) != 0 ) {
1548 if ( a1.compareTo( a2 ) != 0 ) {
1551 if ( a1.compareTo( a3 ) == 0 ) {
1555 catch ( final Exception e ) {
1556 e.printStackTrace( System.out );
1562 private static boolean testBasicNodeMethods() {
1564 if ( PhylogenyNode.getNodeCount() != 0 ) {
1567 final PhylogenyNode n1 = new PhylogenyNode();
1568 final PhylogenyNode n2 = PhylogenyNode
1569 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1570 final PhylogenyNode n3 = PhylogenyNode
1571 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1572 final PhylogenyNode n4 = PhylogenyNode
1573 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1574 if ( n1.isHasAssignedEvent() ) {
1577 if ( PhylogenyNode.getNodeCount() != 4 ) {
1580 if ( n3.getIndicator() != 0 ) {
1583 if ( n3.getNumberOfExternalNodes() != 1 ) {
1586 if ( !n3.isExternal() ) {
1589 if ( !n3.isRoot() ) {
1592 if ( !n4.getName().equals( "n4" ) ) {
1596 catch ( final Exception e ) {
1597 e.printStackTrace( System.out );
1603 private static boolean testBasicPhyloXMLparsing() {
1605 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1606 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1607 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1609 if ( xml_parser.getErrorCount() > 0 ) {
1610 System.out.println( xml_parser.getErrorMessages().toString() );
1613 if ( phylogenies_0.length != 4 ) {
1616 final Phylogeny t1 = phylogenies_0[ 0 ];
1617 final Phylogeny t2 = phylogenies_0[ 1 ];
1618 final Phylogeny t3 = phylogenies_0[ 2 ];
1619 final Phylogeny t4 = phylogenies_0[ 3 ];
1620 if ( t1.getNumberOfExternalNodes() != 1 ) {
1623 if ( !t1.isRooted() ) {
1626 if ( t1.isRerootable() ) {
1629 if ( !t1.getType().equals( "gene_tree" ) ) {
1632 if ( t2.getNumberOfExternalNodes() != 2 ) {
1635 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1638 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1641 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1644 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1647 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1650 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1653 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1654 .startsWith( "actgtgggggt" ) ) {
1657 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1658 .startsWith( "ctgtgatgcat" ) ) {
1661 if ( t3.getNumberOfExternalNodes() != 4 ) {
1664 if ( !t1.getName().equals( "t1" ) ) {
1667 if ( !t2.getName().equals( "t2" ) ) {
1670 if ( !t3.getName().equals( "t3" ) ) {
1673 if ( !t4.getName().equals( "t4" ) ) {
1676 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1679 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1682 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1685 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1686 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1689 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1692 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1695 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1698 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1699 .equals( "apoptosis" ) ) {
1702 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1703 .equals( "GO:0006915" ) ) {
1706 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1707 .equals( "UniProtKB" ) ) {
1710 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1711 .equals( "experimental" ) ) {
1714 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1715 .equals( "function" ) ) {
1718 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1719 .getValue() != 1 ) {
1722 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1723 .getType().equals( "ml" ) ) {
1726 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1727 .equals( "apoptosis" ) ) {
1730 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1731 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1734 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1735 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1738 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1739 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1742 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1743 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1746 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1747 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1750 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1751 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1754 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1755 .equals( "GO:0005829" ) ) {
1758 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1759 .equals( "intracellular organelle" ) ) {
1762 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1765 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1766 .equals( "UniProt link" ) ) ) {
1769 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1772 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1773 if ( x.size() != 4 ) {
1777 for( final Accession acc : x ) {
1779 if ( !acc.getSource().equals( "KEGG" ) ) {
1782 if ( !acc.getValue().equals( "hsa:596" ) ) {
1789 catch ( final Exception e ) {
1790 e.printStackTrace( System.out );
1796 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1798 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1799 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1800 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1801 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1804 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1806 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1808 if ( xml_parser.getErrorCount() > 0 ) {
1809 System.out.println( xml_parser.getErrorMessages().toString() );
1812 if ( phylogenies_0.length != 4 ) {
1815 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1816 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1817 if ( phylogenies_t1.length != 1 ) {
1820 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1821 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1824 if ( !t1_rt.isRooted() ) {
1827 if ( t1_rt.isRerootable() ) {
1830 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1833 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1834 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1835 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1836 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1839 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1842 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1845 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1848 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1849 .startsWith( "actgtgggggt" ) ) {
1852 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1853 .startsWith( "ctgtgatgcat" ) ) {
1856 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1857 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1858 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1859 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1860 if ( phylogenies_1.length != 1 ) {
1863 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1864 if ( !t3_rt.getName().equals( "t3" ) ) {
1867 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1870 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1873 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1876 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1879 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1880 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1883 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1886 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1889 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1890 .equals( "UniProtKB" ) ) {
1893 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1894 .equals( "apoptosis" ) ) {
1897 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1898 .equals( "GO:0006915" ) ) {
1901 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1902 .equals( "UniProtKB" ) ) {
1905 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1906 .equals( "experimental" ) ) {
1909 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1910 .equals( "function" ) ) {
1913 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1914 .getValue() != 1 ) {
1917 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1918 .getType().equals( "ml" ) ) {
1921 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1922 .equals( "apoptosis" ) ) {
1925 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1926 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1929 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1930 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1933 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1934 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1937 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1938 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1941 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1942 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1945 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1946 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1949 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1950 .equals( "GO:0005829" ) ) {
1953 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1954 .equals( "intracellular organelle" ) ) {
1957 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1960 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1961 .equals( "UniProt link" ) ) ) {
1964 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1967 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1970 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1971 .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." ) ) ) {
1974 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1977 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1980 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1983 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1986 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1987 .equals( "ncbi" ) ) {
1990 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1993 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1994 .getName().equals( "B" ) ) {
1997 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1998 .getFrom() != 21 ) {
2001 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2004 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2005 .getLength() != 24 ) {
2008 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2009 .getConfidence() != 2144 ) {
2012 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2013 .equals( "pfam" ) ) {
2016 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2019 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2022 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2025 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2028 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2029 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2032 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2035 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2038 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2041 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2044 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2047 if ( taxbb.getSynonyms().size() != 2 ) {
2050 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2053 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2056 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2059 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2062 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2065 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2066 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2069 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2072 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2075 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2078 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2081 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2084 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2087 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2091 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2094 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2095 .equalsIgnoreCase( "435" ) ) {
2098 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2101 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2102 .equalsIgnoreCase( "443.7" ) ) {
2105 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2108 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2111 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2112 .equalsIgnoreCase( "433" ) ) {
2115 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2116 .getCrossReferences();
2117 if ( x.size() != 4 ) {
2121 for( final Accession acc : x ) {
2123 if ( !acc.getSource().equals( "KEGG" ) ) {
2126 if ( !acc.getValue().equals( "hsa:596" ) ) {
2133 catch ( final Exception e ) {
2134 e.printStackTrace( System.out );
2140 private static boolean testBasicPhyloXMLparsingValidating() {
2142 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2143 PhyloXmlParser xml_parser = null;
2145 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2147 catch ( final Exception e ) {
2148 // Do nothing -- means were not running from jar.
2150 if ( xml_parser == null ) {
2151 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2152 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2153 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2156 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2159 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2161 if ( xml_parser.getErrorCount() > 0 ) {
2162 System.out.println( xml_parser.getErrorMessages().toString() );
2165 if ( phylogenies_0.length != 4 ) {
2168 final Phylogeny t1 = phylogenies_0[ 0 ];
2169 final Phylogeny t2 = phylogenies_0[ 1 ];
2170 final Phylogeny t3 = phylogenies_0[ 2 ];
2171 final Phylogeny t4 = phylogenies_0[ 3 ];
2172 if ( !t1.getName().equals( "t1" ) ) {
2175 if ( !t2.getName().equals( "t2" ) ) {
2178 if ( !t3.getName().equals( "t3" ) ) {
2181 if ( !t4.getName().equals( "t4" ) ) {
2184 if ( t1.getNumberOfExternalNodes() != 1 ) {
2187 if ( t2.getNumberOfExternalNodes() != 2 ) {
2190 if ( t3.getNumberOfExternalNodes() != 4 ) {
2193 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2194 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2195 if ( xml_parser.getErrorCount() > 0 ) {
2196 System.out.println( "errors:" );
2197 System.out.println( xml_parser.getErrorMessages().toString() );
2200 if ( phylogenies_1.length != 4 ) {
2203 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2205 if ( xml_parser.getErrorCount() > 0 ) {
2206 System.out.println( "errors:" );
2207 System.out.println( xml_parser.getErrorMessages().toString() );
2210 if ( phylogenies_2.length != 1 ) {
2213 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2216 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2218 if ( xml_parser.getErrorCount() > 0 ) {
2219 System.out.println( xml_parser.getErrorMessages().toString() );
2222 if ( phylogenies_3.length != 2 ) {
2225 final Phylogeny a = phylogenies_3[ 0 ];
2226 if ( !a.getName().equals( "tree 4" ) ) {
2229 if ( a.getNumberOfExternalNodes() != 3 ) {
2232 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2235 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2238 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2240 if ( xml_parser.getErrorCount() > 0 ) {
2241 System.out.println( xml_parser.getErrorMessages().toString() );
2244 if ( phylogenies_4.length != 1 ) {
2247 final Phylogeny s = phylogenies_4[ 0 ];
2248 if ( s.getNumberOfExternalNodes() != 6 ) {
2251 s.getNode( "first" );
2253 s.getNode( "\"<a'b&c'd\">\"" );
2254 s.getNode( "'''\"" );
2255 s.getNode( "\"\"\"" );
2256 s.getNode( "dick & doof" );
2258 catch ( final Exception e ) {
2259 e.printStackTrace( System.out );
2265 private static boolean testBasicProtein() {
2267 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2268 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2269 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2270 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2271 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2272 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2273 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2274 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2275 p0.addProteinDomain( y );
2276 p0.addProteinDomain( e );
2277 p0.addProteinDomain( b );
2278 p0.addProteinDomain( c );
2279 p0.addProteinDomain( d );
2280 p0.addProteinDomain( a );
2281 p0.addProteinDomain( x );
2282 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2285 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2289 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2290 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2291 aa0.addProteinDomain( a1 );
2292 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2295 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2299 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2300 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2301 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2302 aa1.addProteinDomain( a11 );
2303 aa1.addProteinDomain( a12 );
2304 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2307 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2310 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2311 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2314 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2317 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2320 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2321 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2324 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2327 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2330 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2333 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2334 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2337 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2340 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2343 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2346 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2347 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2350 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2353 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2356 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2360 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2361 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2368 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2369 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2370 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2371 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2372 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2373 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2374 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2376 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2377 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2378 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2379 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2380 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2381 p00.addProteinDomain( y0 );
2382 p00.addProteinDomain( e0 );
2383 p00.addProteinDomain( b0 );
2384 p00.addProteinDomain( c0 );
2385 p00.addProteinDomain( d0 );
2386 p00.addProteinDomain( a0 );
2387 p00.addProteinDomain( x0 );
2388 p00.addProteinDomain( y1 );
2389 p00.addProteinDomain( y2 );
2390 p00.addProteinDomain( y3 );
2391 p00.addProteinDomain( e1 );
2392 p00.addProteinDomain( e2 );
2393 p00.addProteinDomain( e3 );
2394 p00.addProteinDomain( e4 );
2395 p00.addProteinDomain( e5 );
2396 p00.addProteinDomain( z0 );
2397 p00.addProteinDomain( z1 );
2398 p00.addProteinDomain( z2 );
2399 p00.addProteinDomain( zz0 );
2400 p00.addProteinDomain( zz1 );
2401 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2404 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2407 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2410 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2413 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" ) ) {
2416 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2417 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2418 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2419 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2420 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2421 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2422 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2423 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2424 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2425 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2426 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2427 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2428 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2429 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2430 p.addProteinDomain( B15 );
2431 p.addProteinDomain( C50 );
2432 p.addProteinDomain( A60 );
2433 p.addProteinDomain( A30 );
2434 p.addProteinDomain( C70 );
2435 p.addProteinDomain( B35 );
2436 p.addProteinDomain( B40 );
2437 p.addProteinDomain( A0 );
2438 p.addProteinDomain( A10 );
2439 p.addProteinDomain( A20 );
2440 p.addProteinDomain( B25 );
2441 p.addProteinDomain( D80 );
2442 List<String> domains_ids = new ArrayList<String>();
2443 domains_ids.add( "A" );
2444 domains_ids.add( "B" );
2445 domains_ids.add( "C" );
2446 if ( !p.contains( domains_ids, false ) ) {
2449 if ( !p.contains( domains_ids, true ) ) {
2452 domains_ids.add( "X" );
2453 if ( p.contains( domains_ids, false ) ) {
2456 if ( p.contains( domains_ids, true ) ) {
2459 domains_ids = new ArrayList<String>();
2460 domains_ids.add( "A" );
2461 domains_ids.add( "C" );
2462 domains_ids.add( "D" );
2463 if ( !p.contains( domains_ids, false ) ) {
2466 if ( !p.contains( domains_ids, true ) ) {
2469 domains_ids = new ArrayList<String>();
2470 domains_ids.add( "A" );
2471 domains_ids.add( "D" );
2472 domains_ids.add( "C" );
2473 if ( !p.contains( domains_ids, false ) ) {
2476 if ( p.contains( domains_ids, true ) ) {
2479 domains_ids = new ArrayList<String>();
2480 domains_ids.add( "A" );
2481 domains_ids.add( "A" );
2482 domains_ids.add( "B" );
2483 if ( !p.contains( domains_ids, false ) ) {
2486 if ( !p.contains( domains_ids, true ) ) {
2489 domains_ids = new ArrayList<String>();
2490 domains_ids.add( "A" );
2491 domains_ids.add( "A" );
2492 domains_ids.add( "A" );
2493 domains_ids.add( "B" );
2494 domains_ids.add( "B" );
2495 if ( !p.contains( domains_ids, false ) ) {
2498 if ( !p.contains( domains_ids, true ) ) {
2501 domains_ids = new ArrayList<String>();
2502 domains_ids.add( "A" );
2503 domains_ids.add( "A" );
2504 domains_ids.add( "B" );
2505 domains_ids.add( "A" );
2506 domains_ids.add( "B" );
2507 domains_ids.add( "B" );
2508 domains_ids.add( "A" );
2509 domains_ids.add( "B" );
2510 domains_ids.add( "C" );
2511 domains_ids.add( "A" );
2512 domains_ids.add( "C" );
2513 domains_ids.add( "D" );
2514 if ( !p.contains( domains_ids, false ) ) {
2517 if ( p.contains( domains_ids, true ) ) {
2521 catch ( final Exception e ) {
2522 e.printStackTrace( System.out );
2528 private static boolean testBasicTable() {
2530 final BasicTable<String> t0 = new BasicTable<String>();
2531 if ( t0.getNumberOfColumns() != 0 ) {
2534 if ( t0.getNumberOfRows() != 0 ) {
2537 t0.setValue( 3, 2, "23" );
2538 t0.setValue( 10, 1, "error" );
2539 t0.setValue( 10, 1, "110" );
2540 t0.setValue( 9, 1, "19" );
2541 t0.setValue( 1, 10, "101" );
2542 t0.setValue( 10, 10, "1010" );
2543 t0.setValue( 100, 10, "10100" );
2544 t0.setValue( 0, 0, "00" );
2545 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2548 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2551 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2554 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2557 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2560 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2563 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2566 if ( t0.getNumberOfColumns() != 101 ) {
2569 if ( t0.getNumberOfRows() != 11 ) {
2572 if ( t0.getValueAsString( 49, 4 ) != null ) {
2575 final String l = ForesterUtil.getLineSeparator();
2576 final StringBuffer source = new StringBuffer();
2577 source.append( "" + l );
2578 source.append( "# 1 1 1 1 1 1 1 1" + l );
2579 source.append( " 00 01 02 03" + l );
2580 source.append( " 10 11 12 13 " + l );
2581 source.append( "20 21 22 23 " + l );
2582 source.append( " 30 31 32 33" + l );
2583 source.append( "40 41 42 43" + l );
2584 source.append( " # 1 1 1 1 1 " + l );
2585 source.append( "50 51 52 53 54" + l );
2586 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2587 if ( t1.getNumberOfColumns() != 5 ) {
2590 if ( t1.getNumberOfRows() != 6 ) {
2593 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2596 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2599 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2602 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2605 final StringBuffer source1 = new StringBuffer();
2606 source1.append( "" + l );
2607 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2608 source1.append( " 00; 01 ;02;03" + l );
2609 source1.append( " 10; 11; 12; 13 " + l );
2610 source1.append( "20; 21; 22; 23 " + l );
2611 source1.append( " 30; 31; 32; 33" + l );
2612 source1.append( "40;41;42;43" + l );
2613 source1.append( " # 1 1 1 1 1 " + l );
2614 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2615 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2616 if ( t2.getNumberOfColumns() != 5 ) {
2619 if ( t2.getNumberOfRows() != 6 ) {
2622 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2625 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2628 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2631 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2634 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2637 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2640 final StringBuffer source2 = new StringBuffer();
2641 source2.append( "" + l );
2642 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2643 source2.append( " 00; 01 ;02;03" + l );
2644 source2.append( " 10; 11; 12; 13 " + l );
2645 source2.append( "20; 21; 22; 23 " + l );
2646 source2.append( " " + l );
2647 source2.append( " 30; 31; 32; 33" + l );
2648 source2.append( "40;41;42;43" + l );
2649 source2.append( " comment: 1 1 1 1 1 " + l );
2650 source2.append( ";;;50 ; 52; 53;;54 " + l );
2651 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2657 if ( tl.size() != 2 ) {
2660 final BasicTable<String> t3 = tl.get( 0 );
2661 final BasicTable<String> t4 = tl.get( 1 );
2662 if ( t3.getNumberOfColumns() != 4 ) {
2665 if ( t3.getNumberOfRows() != 3 ) {
2668 if ( t4.getNumberOfColumns() != 4 ) {
2671 if ( t4.getNumberOfRows() != 3 ) {
2674 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2677 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2681 catch ( final Exception e ) {
2682 e.printStackTrace( System.out );
2688 private static boolean testBasicTolXMLparsing() {
2690 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2691 final TolParser parser = new TolParser();
2692 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2693 if ( parser.getErrorCount() > 0 ) {
2694 System.out.println( parser.getErrorMessages().toString() );
2697 if ( phylogenies_0.length != 1 ) {
2700 final Phylogeny t1 = phylogenies_0[ 0 ];
2701 if ( t1.getNumberOfExternalNodes() != 5 ) {
2704 if ( !t1.isRooted() ) {
2707 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2710 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2713 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2716 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2719 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2720 if ( parser.getErrorCount() > 0 ) {
2721 System.out.println( parser.getErrorMessages().toString() );
2724 if ( phylogenies_1.length != 1 ) {
2727 final Phylogeny t2 = phylogenies_1[ 0 ];
2728 if ( t2.getNumberOfExternalNodes() != 664 ) {
2731 if ( !t2.isRooted() ) {
2734 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2737 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2740 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2743 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2746 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2749 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2750 .equals( "Aquifex" ) ) {
2753 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2754 if ( parser.getErrorCount() > 0 ) {
2755 System.out.println( parser.getErrorMessages().toString() );
2758 if ( phylogenies_2.length != 1 ) {
2761 final Phylogeny t3 = phylogenies_2[ 0 ];
2762 if ( t3.getNumberOfExternalNodes() != 184 ) {
2765 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2768 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2771 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2774 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2775 if ( parser.getErrorCount() > 0 ) {
2776 System.out.println( parser.getErrorMessages().toString() );
2779 if ( phylogenies_3.length != 1 ) {
2782 final Phylogeny t4 = phylogenies_3[ 0 ];
2783 if ( t4.getNumberOfExternalNodes() != 1 ) {
2786 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2789 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2792 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2795 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2796 if ( parser.getErrorCount() > 0 ) {
2797 System.out.println( parser.getErrorMessages().toString() );
2800 if ( phylogenies_4.length != 1 ) {
2803 final Phylogeny t5 = phylogenies_4[ 0 ];
2804 if ( t5.getNumberOfExternalNodes() != 13 ) {
2807 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2810 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2813 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2817 catch ( final Exception e ) {
2818 e.printStackTrace( System.out );
2824 private static boolean testBasicTreeMethods() {
2826 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2827 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2828 if ( t2.getNumberOfExternalNodes() != 4 ) {
2831 if ( t2.getHeight() != 8.5 ) {
2834 if ( !t2.isCompletelyBinary() ) {
2837 if ( t2.isEmpty() ) {
2840 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2841 if ( t3.getNumberOfExternalNodes() != 5 ) {
2844 if ( t3.getHeight() != 11 ) {
2847 if ( t3.isCompletelyBinary() ) {
2850 final PhylogenyNode n = t3.getNode( "ABC" );
2851 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 ];
2852 if ( t4.getNumberOfExternalNodes() != 9 ) {
2855 if ( t4.getHeight() != 11 ) {
2858 if ( t4.isCompletelyBinary() ) {
2861 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)" );
2862 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2863 if ( t5.getNumberOfExternalNodes() != 8 ) {
2866 if ( t5.getHeight() != 15 ) {
2869 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)" );
2870 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2871 if ( t6.getHeight() != 15 ) {
2874 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)" );
2875 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2876 if ( t7.getHeight() != 15 ) {
2879 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)" );
2880 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2881 if ( t8.getNumberOfExternalNodes() != 10 ) {
2884 if ( t8.getHeight() != 15 ) {
2887 final char[] a9 = new char[] { 'a' };
2888 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2889 if ( t9.getHeight() != 0 ) {
2892 final char[] a10 = new char[] { 'a', ':', '6' };
2893 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2894 if ( t10.getHeight() != 6 ) {
2898 catch ( final Exception e ) {
2899 e.printStackTrace( System.out );
2905 private static boolean testConfidenceAssessor() {
2907 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2908 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2909 final Phylogeny[] ev0 = factory
2910 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2912 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2913 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2916 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2919 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2920 final Phylogeny[] ev1 = factory
2921 .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)));",
2923 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2924 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2927 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2930 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2931 final Phylogeny[] ev_b = factory
2932 .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",
2934 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2935 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2938 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2942 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2943 final Phylogeny[] ev1x = factory
2944 .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)));",
2946 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2947 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2950 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2953 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2954 final Phylogeny[] ev_bx = factory
2955 .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",
2957 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2958 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2961 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2965 final Phylogeny[] t2 = factory
2966 .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);",
2968 final Phylogeny[] ev2 = factory
2969 .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);",
2971 for( final Phylogeny target : t2 ) {
2972 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2975 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2976 new NHXParser() )[ 0 ];
2977 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2978 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2979 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2982 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2985 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2989 catch ( final Exception e ) {
2990 e.printStackTrace();
2996 private static boolean testCopyOfNodeData() {
2998 final PhylogenyNode n1 = PhylogenyNode
2999 .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]" );
3000 final PhylogenyNode n2 = n1.copyNodeData();
3001 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3005 catch ( final Exception e ) {
3006 e.printStackTrace();
3012 private static boolean testCreateBalancedPhylogeny() {
3014 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3015 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3018 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3021 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3022 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3025 if ( p1.getNumberOfExternalNodes() != 100 ) {
3029 catch ( final Exception e ) {
3030 e.printStackTrace();
3036 private static boolean testCreateUriForSeqWeb() {
3038 final PhylogenyNode n = new PhylogenyNode();
3039 n.setName( "tr|B3RJ64" );
3040 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3043 n.setName( "B0LM41_HUMAN" );
3044 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3047 n.setName( "NP_001025424" );
3048 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3051 n.setName( "_NM_001030253-" );
3052 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3055 n.setName( "XM_002122186" );
3056 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3059 n.setName( "dgh_AAA34956_gdg" );
3060 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3063 n.setName( "AAA34956" );
3064 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3067 n.setName( "GI:394892" );
3068 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3069 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3072 n.setName( "gi_394892" );
3073 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3074 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3077 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3078 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3079 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3082 n.setName( "P12345" );
3083 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3084 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3087 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3088 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3089 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3093 catch ( final Exception e ) {
3094 e.printStackTrace( System.out );
3100 private static boolean testDataObjects() {
3102 final Confidence s0 = new Confidence();
3103 final Confidence s1 = new Confidence();
3104 if ( !s0.isEqual( s1 ) ) {
3107 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3108 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3109 if ( s2.isEqual( s1 ) ) {
3112 if ( !s2.isEqual( s3 ) ) {
3115 final Confidence s4 = ( Confidence ) s3.copy();
3116 if ( !s4.isEqual( s3 ) ) {
3123 final Taxonomy t1 = new Taxonomy();
3124 final Taxonomy t2 = new Taxonomy();
3125 final Taxonomy t3 = new Taxonomy();
3126 final Taxonomy t4 = new Taxonomy();
3127 final Taxonomy t5 = new Taxonomy();
3128 t1.setIdentifier( new Identifier( "ecoli" ) );
3129 t1.setTaxonomyCode( "ECOLI" );
3130 t1.setScientificName( "E. coli" );
3131 t1.setCommonName( "coli" );
3132 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3133 if ( !t1.isEqual( t0 ) ) {
3136 t2.setIdentifier( new Identifier( "ecoli" ) );
3137 t2.setTaxonomyCode( "OTHER" );
3138 t2.setScientificName( "what" );
3139 t2.setCommonName( "something" );
3140 if ( !t1.isEqual( t2 ) ) {
3143 t2.setIdentifier( new Identifier( "nemve" ) );
3144 if ( t1.isEqual( t2 ) ) {
3147 t1.setIdentifier( null );
3148 t3.setTaxonomyCode( "ECOLI" );
3149 t3.setScientificName( "what" );
3150 t3.setCommonName( "something" );
3151 if ( !t1.isEqual( t3 ) ) {
3154 t1.setIdentifier( null );
3155 t1.setTaxonomyCode( "" );
3156 t4.setScientificName( "E. ColI" );
3157 t4.setCommonName( "something" );
3158 if ( !t1.isEqual( t4 ) ) {
3161 t4.setScientificName( "B. subtilis" );
3162 t4.setCommonName( "something" );
3163 if ( t1.isEqual( t4 ) ) {
3166 t1.setIdentifier( null );
3167 t1.setTaxonomyCode( "" );
3168 t1.setScientificName( "" );
3169 t5.setCommonName( "COLI" );
3170 if ( !t1.isEqual( t5 ) ) {
3173 t5.setCommonName( "vibrio" );
3174 if ( t1.isEqual( t5 ) ) {
3179 final Identifier id0 = new Identifier( "123", "pfam" );
3180 final Identifier id1 = ( Identifier ) id0.copy();
3181 if ( !id1.isEqual( id1 ) ) {
3184 if ( !id1.isEqual( id0 ) ) {
3187 if ( !id0.isEqual( id1 ) ) {
3194 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3195 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3196 if ( !pd1.isEqual( pd1 ) ) {
3199 if ( !pd1.isEqual( pd0 ) ) {
3204 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3205 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3206 if ( !pd3.isEqual( pd3 ) ) {
3209 if ( !pd2.isEqual( pd3 ) ) {
3212 if ( !pd0.isEqual( pd3 ) ) {
3217 // DomainArchitecture
3218 // ------------------
3219 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3220 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3221 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3222 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3223 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3224 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3229 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3230 if ( ds0.getNumberOfDomains() != 4 ) {
3233 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3234 if ( !ds0.isEqual( ds0 ) ) {
3237 if ( !ds0.isEqual( ds1 ) ) {
3240 if ( ds1.getNumberOfDomains() != 4 ) {
3243 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3248 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3249 if ( ds0.isEqual( ds2 ) ) {
3255 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3256 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3257 System.out.println( ds3.toNHX() );
3260 if ( ds3.getNumberOfDomains() != 3 ) {
3265 final Event e1 = new Event( Event.EventType.fusion );
3266 if ( e1.isDuplication() ) {
3269 if ( !e1.isFusion() ) {
3272 if ( !e1.asText().toString().equals( "fusion" ) ) {
3275 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3278 final Event e11 = new Event( Event.EventType.fusion );
3279 if ( !e11.isEqual( e1 ) ) {
3282 if ( !e11.toNHX().toString().equals( "" ) ) {
3285 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3286 if ( e2.isDuplication() ) {
3289 if ( !e2.isSpeciationOrDuplication() ) {
3292 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3295 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3298 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3301 if ( e11.isEqual( e2 ) ) {
3304 final Event e2c = ( Event ) e2.copy();
3305 if ( !e2c.isEqual( e2 ) ) {
3308 Event e3 = new Event( 1, 2, 3 );
3309 if ( e3.isDuplication() ) {
3312 if ( e3.isSpeciation() ) {
3315 if ( e3.isGeneLoss() ) {
3318 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3321 final Event e3c = ( Event ) e3.copy();
3322 final Event e3cc = ( Event ) e3c.copy();
3323 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3327 if ( !e3c.isEqual( e3cc ) ) {
3330 Event e4 = new Event( 1, 2, 3 );
3331 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3334 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3337 final Event e4c = ( Event ) e4.copy();
3339 final Event e4cc = ( Event ) e4c.copy();
3340 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3343 if ( !e4c.isEqual( e4cc ) ) {
3346 final Event e5 = new Event();
3347 if ( !e5.isUnassigned() ) {
3350 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3353 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3356 final Event e6 = new Event( 1, 0, 0 );
3357 if ( !e6.asText().toString().equals( "duplication" ) ) {
3360 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3363 final Event e7 = new Event( 0, 1, 0 );
3364 if ( !e7.asText().toString().equals( "speciation" ) ) {
3367 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3370 final Event e8 = new Event( 0, 0, 1 );
3371 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3374 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3378 catch ( final Exception e ) {
3379 e.printStackTrace( System.out );
3385 private static boolean testDeletionOfExternalNodes() {
3387 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3388 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3389 final PhylogenyWriter w = new PhylogenyWriter();
3390 if ( t0.isEmpty() ) {
3393 if ( t0.getNumberOfExternalNodes() != 1 ) {
3396 t0.deleteSubtree( t0.getNode( "A" ), false );
3397 if ( t0.getNumberOfExternalNodes() != 0 ) {
3400 if ( !t0.isEmpty() ) {
3403 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3404 if ( t1.getNumberOfExternalNodes() != 2 ) {
3407 t1.deleteSubtree( t1.getNode( "A" ), false );
3408 if ( t1.getNumberOfExternalNodes() != 1 ) {
3411 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3414 t1.deleteSubtree( t1.getNode( "B" ), false );
3415 if ( t1.getNumberOfExternalNodes() != 1 ) {
3418 t1.deleteSubtree( t1.getNode( "r" ), false );
3419 if ( !t1.isEmpty() ) {
3422 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3423 if ( t2.getNumberOfExternalNodes() != 3 ) {
3426 t2.deleteSubtree( t2.getNode( "B" ), false );
3427 if ( t2.getNumberOfExternalNodes() != 2 ) {
3430 t2.toNewHampshireX();
3431 PhylogenyNode n = t2.getNode( "A" );
3432 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3435 t2.deleteSubtree( t2.getNode( "A" ), false );
3436 if ( t2.getNumberOfExternalNodes() != 2 ) {
3439 t2.deleteSubtree( t2.getNode( "C" ), true );
3440 if ( t2.getNumberOfExternalNodes() != 1 ) {
3443 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3444 if ( t3.getNumberOfExternalNodes() != 4 ) {
3447 t3.deleteSubtree( t3.getNode( "B" ), true );
3448 if ( t3.getNumberOfExternalNodes() != 3 ) {
3451 n = t3.getNode( "A" );
3452 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3455 n = n.getNextExternalNode();
3456 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3459 t3.deleteSubtree( t3.getNode( "A" ), true );
3460 if ( t3.getNumberOfExternalNodes() != 2 ) {
3463 n = t3.getNode( "C" );
3464 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3467 t3.deleteSubtree( t3.getNode( "C" ), true );
3468 if ( t3.getNumberOfExternalNodes() != 1 ) {
3471 t3.deleteSubtree( t3.getNode( "D" ), true );
3472 if ( t3.getNumberOfExternalNodes() != 0 ) {
3475 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3476 if ( t4.getNumberOfExternalNodes() != 6 ) {
3479 t4.deleteSubtree( t4.getNode( "B2" ), true );
3480 if ( t4.getNumberOfExternalNodes() != 5 ) {
3483 String s = w.toNewHampshire( t4, true ).toString();
3484 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3487 t4.deleteSubtree( t4.getNode( "B11" ), true );
3488 if ( t4.getNumberOfExternalNodes() != 4 ) {
3491 t4.deleteSubtree( t4.getNode( "C" ), true );
3492 if ( t4.getNumberOfExternalNodes() != 3 ) {
3495 n = t4.getNode( "A" );
3496 n = n.getNextExternalNode();
3497 if ( !n.getName().equals( "B12" ) ) {
3500 n = n.getNextExternalNode();
3501 if ( !n.getName().equals( "D" ) ) {
3504 s = w.toNewHampshire( t4, true ).toString();
3505 if ( !s.equals( "((A,B12),D);" ) ) {
3508 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3509 t5.deleteSubtree( t5.getNode( "A" ), true );
3510 if ( t5.getNumberOfExternalNodes() != 5 ) {
3513 s = w.toNewHampshire( t5, true ).toString();
3514 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3517 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3518 t6.deleteSubtree( t6.getNode( "B11" ), true );
3519 if ( t6.getNumberOfExternalNodes() != 5 ) {
3522 s = w.toNewHampshire( t6, false ).toString();
3523 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3526 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3527 t7.deleteSubtree( t7.getNode( "B12" ), true );
3528 if ( t7.getNumberOfExternalNodes() != 5 ) {
3531 s = w.toNewHampshire( t7, true ).toString();
3532 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3535 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3536 t8.deleteSubtree( t8.getNode( "B2" ), true );
3537 if ( t8.getNumberOfExternalNodes() != 5 ) {
3540 s = w.toNewHampshire( t8, false ).toString();
3541 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3544 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3545 t9.deleteSubtree( t9.getNode( "C" ), true );
3546 if ( t9.getNumberOfExternalNodes() != 5 ) {
3549 s = w.toNewHampshire( t9, true ).toString();
3550 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3553 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3554 t10.deleteSubtree( t10.getNode( "D" ), true );
3555 if ( t10.getNumberOfExternalNodes() != 5 ) {
3558 s = w.toNewHampshire( t10, true ).toString();
3559 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3562 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3563 t11.deleteSubtree( t11.getNode( "A" ), true );
3564 if ( t11.getNumberOfExternalNodes() != 2 ) {
3567 s = w.toNewHampshire( t11, true ).toString();
3568 if ( !s.equals( "(B,C);" ) ) {
3571 t11.deleteSubtree( t11.getNode( "C" ), true );
3572 if ( t11.getNumberOfExternalNodes() != 1 ) {
3575 s = w.toNewHampshire( t11, false ).toString();
3576 if ( !s.equals( "B;" ) ) {
3579 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3580 t12.deleteSubtree( t12.getNode( "B2" ), true );
3581 if ( t12.getNumberOfExternalNodes() != 8 ) {
3584 s = w.toNewHampshire( t12, true ).toString();
3585 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3588 t12.deleteSubtree( t12.getNode( "B3" ), true );
3589 if ( t12.getNumberOfExternalNodes() != 7 ) {
3592 s = w.toNewHampshire( t12, true ).toString();
3593 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3596 t12.deleteSubtree( t12.getNode( "C3" ), true );
3597 if ( t12.getNumberOfExternalNodes() != 6 ) {
3600 s = w.toNewHampshire( t12, true ).toString();
3601 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3604 t12.deleteSubtree( t12.getNode( "A1" ), true );
3605 if ( t12.getNumberOfExternalNodes() != 5 ) {
3608 s = w.toNewHampshire( t12, true ).toString();
3609 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3612 t12.deleteSubtree( t12.getNode( "B1" ), true );
3613 if ( t12.getNumberOfExternalNodes() != 4 ) {
3616 s = w.toNewHampshire( t12, true ).toString();
3617 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3620 t12.deleteSubtree( t12.getNode( "A3" ), true );
3621 if ( t12.getNumberOfExternalNodes() != 3 ) {
3624 s = w.toNewHampshire( t12, true ).toString();
3625 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3628 t12.deleteSubtree( t12.getNode( "A2" ), true );
3629 if ( t12.getNumberOfExternalNodes() != 2 ) {
3632 s = w.toNewHampshire( t12, true ).toString();
3633 if ( !s.equals( "(C1,C2);" ) ) {
3636 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3637 t13.deleteSubtree( t13.getNode( "D" ), true );
3638 if ( t13.getNumberOfExternalNodes() != 4 ) {
3641 s = w.toNewHampshire( t13, true ).toString();
3642 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3645 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3646 t14.deleteSubtree( t14.getNode( "E" ), true );
3647 if ( t14.getNumberOfExternalNodes() != 5 ) {
3650 s = w.toNewHampshire( t14, true ).toString();
3651 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3654 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3655 t15.deleteSubtree( t15.getNode( "B2" ), true );
3656 if ( t15.getNumberOfExternalNodes() != 11 ) {
3659 t15.deleteSubtree( t15.getNode( "B1" ), true );
3660 if ( t15.getNumberOfExternalNodes() != 10 ) {
3663 t15.deleteSubtree( t15.getNode( "B3" ), true );
3664 if ( t15.getNumberOfExternalNodes() != 9 ) {
3667 t15.deleteSubtree( t15.getNode( "B4" ), true );
3668 if ( t15.getNumberOfExternalNodes() != 8 ) {
3671 t15.deleteSubtree( t15.getNode( "A1" ), true );
3672 if ( t15.getNumberOfExternalNodes() != 7 ) {
3675 t15.deleteSubtree( t15.getNode( "C4" ), true );
3676 if ( t15.getNumberOfExternalNodes() != 6 ) {
3680 catch ( final Exception e ) {
3681 e.printStackTrace( System.out );
3687 private static boolean testDescriptiveStatistics() {
3689 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3690 dss1.addValue( 82 );
3691 dss1.addValue( 78 );
3692 dss1.addValue( 70 );
3693 dss1.addValue( 58 );
3694 dss1.addValue( 42 );
3695 if ( dss1.getN() != 5 ) {
3698 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3701 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3704 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3707 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3710 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3713 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3716 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3719 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3722 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3725 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3728 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3731 dss1.addValue( 123 );
3732 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3735 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3738 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3741 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3742 dss2.addValue( -1.85 );
3743 dss2.addValue( 57.5 );
3744 dss2.addValue( 92.78 );
3745 dss2.addValue( 57.78 );
3746 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3749 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3752 final double[] a = dss2.getDataAsDoubleArray();
3753 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3756 dss2.addValue( -100 );
3757 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3760 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3763 final double[] ds = new double[ 14 ];
3778 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3779 if ( bins.length != 4 ) {
3782 if ( bins[ 0 ] != 2 ) {
3785 if ( bins[ 1 ] != 3 ) {
3788 if ( bins[ 2 ] != 4 ) {
3791 if ( bins[ 3 ] != 5 ) {
3794 final double[] ds1 = new double[ 9 ];
3804 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3805 if ( bins1.length != 4 ) {
3808 if ( bins1[ 0 ] != 2 ) {
3811 if ( bins1[ 1 ] != 3 ) {
3814 if ( bins1[ 2 ] != 0 ) {
3817 if ( bins1[ 3 ] != 4 ) {
3820 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3821 if ( bins1_1.length != 3 ) {
3824 if ( bins1_1[ 0 ] != 3 ) {
3827 if ( bins1_1[ 1 ] != 2 ) {
3830 if ( bins1_1[ 2 ] != 4 ) {
3833 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3834 if ( bins1_2.length != 3 ) {
3837 if ( bins1_2[ 0 ] != 2 ) {
3840 if ( bins1_2[ 1 ] != 2 ) {
3843 if ( bins1_2[ 2 ] != 2 ) {
3846 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3860 dss3.addValue( 10 );
3861 dss3.addValue( 10 );
3862 dss3.addValue( 10 );
3863 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3864 histo.toStringBuffer( 10, '=', 40, 5 );
3865 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3867 catch ( final Exception e ) {
3868 e.printStackTrace( System.out );
3874 private static boolean testDir( final String file ) {
3876 final File f = new File( file );
3877 if ( !f.exists() ) {
3880 if ( !f.isDirectory() ) {
3883 if ( !f.canRead() ) {
3887 catch ( final Exception e ) {
3893 private static boolean testEbiEntryRetrieval() {
3895 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3896 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3897 System.out.println( entry.getAccession() );
3900 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3901 System.out.println( entry.getTaxonomyScientificName() );
3904 if ( !entry.getSequenceName()
3905 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3906 System.out.println( entry.getSequenceName() );
3909 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3910 // System.out.println( entry.getSequenceSymbol() );
3913 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3914 System.out.println( entry.getGeneName() );
3917 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3918 System.out.println( entry.getTaxonomyIdentifier() );
3921 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3922 System.out.println( entry.getAnnotations().first().getRefValue() );
3925 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3926 System.out.println( entry.getAnnotations().first().getRefSource() );
3929 if ( entry.getCrossReferences().size() != 5 ) {
3933 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3934 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3937 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3938 System.out.println( entry1.getTaxonomyScientificName() );
3941 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3942 System.out.println( entry1.getSequenceName() );
3945 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3946 System.out.println( entry1.getTaxonomyIdentifier() );
3949 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3950 System.out.println( entry1.getGeneName() );
3953 if ( entry1.getCrossReferences().size() != 6 ) {
3957 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3958 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3961 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3962 System.out.println( entry2.getTaxonomyScientificName() );
3965 if ( !entry2.getSequenceName()
3966 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3967 System.out.println( entry2.getSequenceName() );
3970 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3971 System.out.println( entry2.getTaxonomyIdentifier() );
3974 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3975 System.out.println( entry2.getGeneName() );
3978 if ( entry2.getCrossReferences().size() != 3 ) {
3982 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3983 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3986 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3987 System.out.println( entry3.getTaxonomyScientificName() );
3990 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3991 System.out.println( entry3.getSequenceName() );
3994 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3995 System.out.println( entry3.getTaxonomyIdentifier() );
3998 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3999 System.out.println( entry3.getSequenceSymbol() );
4002 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4005 if ( entry3.getCrossReferences().size() != 8 ) {
4010 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4011 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4014 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4015 System.out.println( entry4.getTaxonomyScientificName() );
4018 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4019 System.out.println( entry4.getSequenceName() );
4022 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4023 System.out.println( entry4.getTaxonomyIdentifier() );
4026 if ( !entry4.getGeneName().equals( "ras" ) ) {
4027 System.out.println( entry4.getGeneName() );
4030 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4031 // System.out.println( entry4.getChromosome() );
4034 // if ( !entry4.getMap().equals( "ras" ) ) {
4035 // System.out.println( entry4.getMap() );
4041 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4042 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4045 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4046 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4049 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4050 System.out.println( entry5.getTaxonomyScientificName() );
4053 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4054 System.out.println( entry5.getSequenceName() );
4057 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4058 System.out.println( entry5.getTaxonomyIdentifier() );
4062 catch ( final IOException e ) {
4063 System.out.println();
4064 System.out.println( "the following might be due to absence internet connection:" );
4065 e.printStackTrace( System.out );
4068 catch ( final Exception e ) {
4069 e.printStackTrace();
4075 private static boolean testExternalNodeRelatedMethods() {
4077 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4078 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4079 PhylogenyNode n = t1.getNode( "A" );
4080 n = n.getNextExternalNode();
4081 if ( !n.getName().equals( "B" ) ) {
4084 n = n.getNextExternalNode();
4085 if ( !n.getName().equals( "C" ) ) {
4088 n = n.getNextExternalNode();
4089 if ( !n.getName().equals( "D" ) ) {
4092 n = t1.getNode( "B" );
4093 while ( !n.isLastExternalNode() ) {
4094 n = n.getNextExternalNode();
4096 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4097 n = t2.getNode( "A" );
4098 n = n.getNextExternalNode();
4099 if ( !n.getName().equals( "B" ) ) {
4102 n = n.getNextExternalNode();
4103 if ( !n.getName().equals( "C" ) ) {
4106 n = n.getNextExternalNode();
4107 if ( !n.getName().equals( "D" ) ) {
4110 n = t2.getNode( "B" );
4111 while ( !n.isLastExternalNode() ) {
4112 n = n.getNextExternalNode();
4114 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4115 n = t3.getNode( "A" );
4116 n = n.getNextExternalNode();
4117 if ( !n.getName().equals( "B" ) ) {
4120 n = n.getNextExternalNode();
4121 if ( !n.getName().equals( "C" ) ) {
4124 n = n.getNextExternalNode();
4125 if ( !n.getName().equals( "D" ) ) {
4128 n = n.getNextExternalNode();
4129 if ( !n.getName().equals( "E" ) ) {
4132 n = n.getNextExternalNode();
4133 if ( !n.getName().equals( "F" ) ) {
4136 n = n.getNextExternalNode();
4137 if ( !n.getName().equals( "G" ) ) {
4140 n = n.getNextExternalNode();
4141 if ( !n.getName().equals( "H" ) ) {
4144 n = t3.getNode( "B" );
4145 while ( !n.isLastExternalNode() ) {
4146 n = n.getNextExternalNode();
4148 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4149 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4150 final PhylogenyNode node = iter.next();
4152 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4153 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4154 final PhylogenyNode node = iter.next();
4156 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4157 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4158 if ( !iter.next().getName().equals( "A" ) ) {
4161 if ( !iter.next().getName().equals( "B" ) ) {
4164 if ( !iter.next().getName().equals( "C" ) ) {
4167 if ( !iter.next().getName().equals( "D" ) ) {
4170 if ( !iter.next().getName().equals( "E" ) ) {
4173 if ( !iter.next().getName().equals( "F" ) ) {
4176 if ( iter.hasNext() ) {
4180 catch ( final Exception e ) {
4181 e.printStackTrace( System.out );
4187 private static boolean testExtractSNFromNodeName() {
4189 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4192 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4195 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4198 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4199 .equals( "Mus musculus musculus" ) ) {
4202 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4203 .equals( "Mus musculus musculus" ) ) {
4206 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4207 .equals( "Mus musculus musculus" ) ) {
4210 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4211 .equals( "Mus musculus musculus" ) ) {
4214 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4217 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4218 .equals( "Mus musculus musculus" ) ) {
4221 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4222 .equals( "Mus musculus musculus" ) ) {
4225 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4228 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4231 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4234 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4237 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4238 .equals( "Mus musculus musculus" ) ) {
4241 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4244 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4247 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4250 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4253 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4256 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4259 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4262 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4265 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4266 .equals( "Mus musculus" ) ) {
4269 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4270 .equals( "Mus musculus" ) ) {
4273 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4276 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4277 .equals( "Mus musculus musculus" ) ) {
4280 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4281 .equals( "Mus musculus musculus" ) ) {
4284 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4285 .equals( "Mus musculus musculus" ) ) {
4288 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4291 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4292 .equals( "Pilostyles mexicana" ) ) {
4295 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4296 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4299 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4300 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4303 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4304 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4307 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4308 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4311 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4312 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4315 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4316 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4319 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4320 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4323 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4324 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4327 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4328 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4331 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4332 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4335 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4336 .equals( "Escherichia coli (strain K12)" ) ) {
4339 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4340 .equals( "Escherichia coli (strain K12)" ) ) {
4343 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4344 .equals( "Escherichia coli (str. K12)" ) ) {
4347 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4348 .equals( "Escherichia coli (str. K12)" ) ) {
4351 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4352 .equals( "Escherichia coli (str. K12)" ) ) {
4355 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4356 .equals( "Escherichia coli (var. K12)" ) ) {
4359 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4360 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4363 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4364 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4368 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4369 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4372 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4373 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4377 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4378 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4381 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4382 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4385 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4386 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4389 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4392 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4395 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4398 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4399 .equals( "Macrocera sp." ) ) {
4402 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4405 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4406 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4409 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4410 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4413 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4414 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4417 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4418 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4422 catch ( final Exception e ) {
4423 e.printStackTrace( System.out );
4429 private static boolean testExtractTaxonomyCodeFromNodeName() {
4431 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4434 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4435 .equals( "SOYBN" ) ) {
4438 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4439 .equals( "ARATH" ) ) {
4442 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4443 .equals( "ARATH" ) ) {
4446 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4449 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4452 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4455 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4456 .equals( "SOYBN" ) ) {
4459 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4460 .equals( "SOYBN" ) ) {
4463 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4464 .equals( "SOYBN" ) ) {
4467 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4468 .equals( "SOYBN" ) ) {
4471 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4472 .equals( "SOYBN" ) ) {
4475 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4476 .equals( "SOYBN" ) ) {
4479 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4480 .equals( "SOYBN" ) ) {
4483 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4484 .equals( "SOYBN" ) ) {
4487 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4490 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4491 .equals( "SOYBN" ) ) {
4494 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4495 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4498 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4499 .equals( "9YX45" ) ) {
4502 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4503 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4504 .equals( "MOUSE" ) ) {
4507 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4508 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4509 .equals( "MOUSE" ) ) {
4512 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4513 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4514 .equals( "MOUSE" ) ) {
4517 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4518 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4521 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4522 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4525 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4526 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4529 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4530 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4533 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4534 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4537 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4538 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4541 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4542 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4545 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4546 .equals( "RAT" ) ) {
4549 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4550 .equals( "PIG" ) ) {
4554 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4555 .equals( "MOUSE" ) ) {
4558 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4559 .equals( "MOUSE" ) ) {
4562 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4566 catch ( final Exception e ) {
4567 e.printStackTrace( System.out );
4573 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4575 PhylogenyNode n = new PhylogenyNode();
4576 n.setName( "tr|B3RJ64" );
4577 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4580 n.setName( "tr.B3RJ64" );
4581 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4584 n.setName( "tr=B3RJ64" );
4585 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4588 n.setName( "tr-B3RJ64" );
4589 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4592 n.setName( "tr/B3RJ64" );
4593 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4596 n.setName( "tr\\B3RJ64" );
4597 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4600 n.setName( "tr_B3RJ64" );
4601 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4604 n.setName( " tr|B3RJ64 " );
4605 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4608 n.setName( "-tr|B3RJ64-" );
4609 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4612 n.setName( "-tr=B3RJ64-" );
4613 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4616 n.setName( "_tr=B3RJ64_" );
4617 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4620 n.setName( " tr_tr|B3RJ64_sp|123 " );
4621 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4624 n.setName( "B3RJ64" );
4625 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4628 n.setName( "sp|B3RJ64" );
4629 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4632 n.setName( "sp|B3RJ64C" );
4633 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4636 n.setName( "sp B3RJ64" );
4637 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4640 n.setName( "sp|B3RJ6X" );
4641 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4644 n.setName( "sp|B3RJ6" );
4645 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4648 n.setName( "K1PYK7_CRAGI" );
4649 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4652 n.setName( "K1PYK7_PEA" );
4653 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4656 n.setName( "K1PYK7_RAT" );
4657 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4660 n.setName( "K1PYK7_PIG" );
4661 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4664 n.setName( "~K1PYK7_PIG~" );
4665 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4668 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4669 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4672 n.setName( "K1PYKX_CRAGI" );
4673 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4676 n.setName( "XXXXX_CRAGI" );
4677 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4680 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4681 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4684 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4685 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4688 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4689 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4692 n = new PhylogenyNode();
4693 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4694 seq.setSymbol( "K1PYK7_CRAGI" );
4695 n.getNodeData().addSequence( seq );
4696 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4699 seq.setSymbol( "tr|B3RJ64" );
4700 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4703 n = new PhylogenyNode();
4704 seq = new org.forester.phylogeny.data.Sequence();
4705 seq.setName( "K1PYK7_CRAGI" );
4706 n.getNodeData().addSequence( seq );
4707 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4710 seq.setName( "tr|B3RJ64" );
4711 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4714 n = new PhylogenyNode();
4715 seq = new org.forester.phylogeny.data.Sequence();
4716 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4717 n.getNodeData().addSequence( seq );
4718 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4721 n = new PhylogenyNode();
4722 seq = new org.forester.phylogeny.data.Sequence();
4723 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4724 n.getNodeData().addSequence( seq );
4725 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4729 n = new PhylogenyNode();
4730 n.setName( "ACP19736" );
4731 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4734 n = new PhylogenyNode();
4735 n.setName( "|ACP19736|" );
4736 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4740 catch ( final Exception e ) {
4741 e.printStackTrace( System.out );
4747 private static boolean testFastaParser() {
4749 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4752 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4755 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4756 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4759 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4762 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4765 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4768 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4771 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4775 catch ( final Exception e ) {
4776 e.printStackTrace();
4782 private static boolean testGenbankAccessorParsing() {
4783 //The format for GenBank Accession numbers are:
4784 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4785 //Protein: 3 letters + 5 numerals
4786 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4787 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4790 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4793 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4796 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4799 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4802 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4805 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4808 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4811 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4814 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4817 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4820 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4823 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4826 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4832 private static boolean testGeneralMsaParser() {
4834 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4835 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4836 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4837 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4838 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4839 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4840 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4841 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4842 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4845 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4848 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4851 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4854 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4857 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4860 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4863 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4866 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4869 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4872 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4875 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4878 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4879 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4882 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4885 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4888 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4889 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4892 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4895 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4898 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4899 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4902 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4905 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4909 catch ( final Exception e ) {
4910 e.printStackTrace();
4916 private static boolean testGeneralTable() {
4918 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4919 t0.setValue( 3, 2, "23" );
4920 t0.setValue( 10, 1, "error" );
4921 t0.setValue( 10, 1, "110" );
4922 t0.setValue( 9, 1, "19" );
4923 t0.setValue( 1, 10, "101" );
4924 t0.setValue( 10, 10, "1010" );
4925 t0.setValue( 100, 10, "10100" );
4926 t0.setValue( 0, 0, "00" );
4927 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4930 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4933 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4936 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4939 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4942 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4945 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4948 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4951 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4954 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4955 t1.setValue( "3", "2", "23" );
4956 t1.setValue( "10", "1", "error" );
4957 t1.setValue( "10", "1", "110" );
4958 t1.setValue( "9", "1", "19" );
4959 t1.setValue( "1", "10", "101" );
4960 t1.setValue( "10", "10", "1010" );
4961 t1.setValue( "100", "10", "10100" );
4962 t1.setValue( "0", "0", "00" );
4963 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4964 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4967 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4970 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4973 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4976 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4979 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4982 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4985 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4988 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4991 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4995 catch ( final Exception e ) {
4996 e.printStackTrace( System.out );
5002 private static boolean testGetDistance() {
5004 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5005 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",
5006 new NHXParser() )[ 0 ];
5007 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5010 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5013 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5016 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5019 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5022 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5025 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5028 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5031 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5034 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5037 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5040 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5043 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5046 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5049 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5052 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5055 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5058 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5061 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5064 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5067 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5070 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5073 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5076 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5079 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5082 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5085 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5088 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5100 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",
5101 new NHXParser() )[ 0 ];
5102 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5105 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5108 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5111 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5114 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5117 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5120 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5123 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5126 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5129 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5132 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5136 catch ( final Exception e ) {
5137 e.printStackTrace( System.out );
5143 private static boolean testGetLCA() {
5145 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5146 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5147 new NHXParser() )[ 0 ];
5148 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5149 if ( !A.getName().equals( "A" ) ) {
5152 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5153 if ( !gh.getName().equals( "gh" ) ) {
5156 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5157 if ( !ab.getName().equals( "ab" ) ) {
5160 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5161 if ( !ab2.getName().equals( "ab" ) ) {
5164 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5165 if ( !gh2.getName().equals( "gh" ) ) {
5168 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5169 if ( !gh3.getName().equals( "gh" ) ) {
5172 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5173 if ( !abc.getName().equals( "abc" ) ) {
5176 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5177 if ( !abc2.getName().equals( "abc" ) ) {
5180 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5181 if ( !abcd.getName().equals( "abcd" ) ) {
5184 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5185 if ( !abcd2.getName().equals( "abcd" ) ) {
5188 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5189 if ( !abcdef.getName().equals( "abcdef" ) ) {
5192 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5193 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5196 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5197 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5200 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5201 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5204 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5205 if ( !abcde.getName().equals( "abcde" ) ) {
5208 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5209 if ( !abcde2.getName().equals( "abcde" ) ) {
5212 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5213 if ( !r.getName().equals( "abcdefgh" ) ) {
5216 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5217 if ( !r2.getName().equals( "abcdefgh" ) ) {
5220 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5221 if ( !r3.getName().equals( "abcdefgh" ) ) {
5224 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5225 if ( !abcde3.getName().equals( "abcde" ) ) {
5228 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5229 if ( !abcde4.getName().equals( "abcde" ) ) {
5232 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5233 if ( !ab3.getName().equals( "ab" ) ) {
5236 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5237 if ( !ab4.getName().equals( "ab" ) ) {
5240 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5241 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5242 if ( !cd.getName().equals( "cd" ) ) {
5245 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5246 if ( !cd2.getName().equals( "cd" ) ) {
5249 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5250 if ( !cde.getName().equals( "cde" ) ) {
5253 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5254 if ( !cde2.getName().equals( "cde" ) ) {
5257 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5258 if ( !cdef.getName().equals( "cdef" ) ) {
5261 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5262 if ( !cdef2.getName().equals( "cdef" ) ) {
5265 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5266 if ( !cdef3.getName().equals( "cdef" ) ) {
5269 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5270 if ( !rt.getName().equals( "r" ) ) {
5273 final Phylogeny p3 = factory
5274 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5275 new NHXParser() )[ 0 ];
5276 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5277 if ( !bc_3.getName().equals( "bc" ) ) {
5280 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5281 if ( !ac_3.getName().equals( "abc" ) ) {
5284 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5285 if ( !ad_3.getName().equals( "abcde" ) ) {
5288 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5289 if ( !af_3.getName().equals( "abcdef" ) ) {
5292 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5293 if ( !ag_3.getName().equals( "" ) ) {
5296 if ( !ag_3.isRoot() ) {
5299 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5300 if ( !al_3.getName().equals( "" ) ) {
5303 if ( !al_3.isRoot() ) {
5306 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5307 if ( !kl_3.getName().equals( "" ) ) {
5310 if ( !kl_3.isRoot() ) {
5313 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5314 if ( !fl_3.getName().equals( "" ) ) {
5317 if ( !fl_3.isRoot() ) {
5320 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5321 if ( !gk_3.getName().equals( "ghijk" ) ) {
5324 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5325 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5326 if ( !r_4.getName().equals( "r" ) ) {
5329 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5330 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5331 if ( !r_5.getName().equals( "root" ) ) {
5334 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5335 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5336 if ( !r_6.getName().equals( "rot" ) ) {
5339 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5340 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5341 if ( !r_7.getName().equals( "rott" ) ) {
5345 catch ( final Exception e ) {
5346 e.printStackTrace( System.out );
5352 private static boolean testGetLCA2() {
5354 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5355 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5356 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5357 PhylogenyMethods.preOrderReId( p_a );
5358 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5359 p_a.getNode( "a" ) );
5360 if ( !p_a_1.getName().equals( "a" ) ) {
5363 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5364 PhylogenyMethods.preOrderReId( p_b );
5365 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5366 p_b.getNode( "a" ) );
5367 if ( !p_b_1.getName().equals( "b" ) ) {
5370 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5371 p_b.getNode( "b" ) );
5372 if ( !p_b_2.getName().equals( "b" ) ) {
5375 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5376 PhylogenyMethods.preOrderReId( p_c );
5377 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5378 p_c.getNode( "a" ) );
5379 if ( !p_c_1.getName().equals( "b" ) ) {
5382 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5383 p_c.getNode( "c" ) );
5384 if ( !p_c_2.getName().equals( "c" ) ) {
5385 System.out.println( p_c_2.getName() );
5389 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5390 p_c.getNode( "b" ) );
5391 if ( !p_c_3.getName().equals( "b" ) ) {
5394 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5395 p_c.getNode( "a" ) );
5396 if ( !p_c_4.getName().equals( "c" ) ) {
5399 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5400 new NHXParser() )[ 0 ];
5401 PhylogenyMethods.preOrderReId( p1 );
5402 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5403 p1.getNode( "A" ) );
5404 if ( !A.getName().equals( "A" ) ) {
5407 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5408 p1.getNode( "gh" ) );
5409 if ( !gh.getName().equals( "gh" ) ) {
5412 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5413 p1.getNode( "B" ) );
5414 if ( !ab.getName().equals( "ab" ) ) {
5417 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5418 p1.getNode( "A" ) );
5419 if ( !ab2.getName().equals( "ab" ) ) {
5422 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5423 p1.getNode( "G" ) );
5424 if ( !gh2.getName().equals( "gh" ) ) {
5427 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5428 p1.getNode( "H" ) );
5429 if ( !gh3.getName().equals( "gh" ) ) {
5432 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5433 p1.getNode( "A" ) );
5434 if ( !abc.getName().equals( "abc" ) ) {
5437 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5438 p1.getNode( "C" ) );
5439 if ( !abc2.getName().equals( "abc" ) ) {
5442 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5443 p1.getNode( "D" ) );
5444 if ( !abcd.getName().equals( "abcd" ) ) {
5447 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5448 p1.getNode( "A" ) );
5449 if ( !abcd2.getName().equals( "abcd" ) ) {
5452 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5453 p1.getNode( "F" ) );
5454 if ( !abcdef.getName().equals( "abcdef" ) ) {
5457 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5458 p1.getNode( "A" ) );
5459 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5462 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5463 p1.getNode( "F" ) );
5464 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5467 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5468 p1.getNode( "ab" ) );
5469 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5472 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5473 p1.getNode( "E" ) );
5474 if ( !abcde.getName().equals( "abcde" ) ) {
5477 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5478 p1.getNode( "A" ) );
5479 if ( !abcde2.getName().equals( "abcde" ) ) {
5482 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5483 p1.getNode( "abcdefgh" ) );
5484 if ( !r.getName().equals( "abcdefgh" ) ) {
5487 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5488 p1.getNode( "H" ) );
5489 if ( !r2.getName().equals( "abcdefgh" ) ) {
5492 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5493 p1.getNode( "A" ) );
5494 if ( !r3.getName().equals( "abcdefgh" ) ) {
5497 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5498 p1.getNode( "abcde" ) );
5499 if ( !abcde3.getName().equals( "abcde" ) ) {
5502 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5503 p1.getNode( "E" ) );
5504 if ( !abcde4.getName().equals( "abcde" ) ) {
5507 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5508 p1.getNode( "B" ) );
5509 if ( !ab3.getName().equals( "ab" ) ) {
5512 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5513 p1.getNode( "ab" ) );
5514 if ( !ab4.getName().equals( "ab" ) ) {
5517 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5518 PhylogenyMethods.preOrderReId( p2 );
5519 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5520 p2.getNode( "d" ) );
5521 if ( !cd.getName().equals( "cd" ) ) {
5524 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5525 p2.getNode( "c" ) );
5526 if ( !cd2.getName().equals( "cd" ) ) {
5529 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5530 p2.getNode( "e" ) );
5531 if ( !cde.getName().equals( "cde" ) ) {
5534 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5535 p2.getNode( "c" ) );
5536 if ( !cde2.getName().equals( "cde" ) ) {
5539 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5540 p2.getNode( "f" ) );
5541 if ( !cdef.getName().equals( "cdef" ) ) {
5544 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5545 p2.getNode( "f" ) );
5546 if ( !cdef2.getName().equals( "cdef" ) ) {
5549 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5550 p2.getNode( "d" ) );
5551 if ( !cdef3.getName().equals( "cdef" ) ) {
5554 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5555 p2.getNode( "a" ) );
5556 if ( !rt.getName().equals( "r" ) ) {
5559 final Phylogeny p3 = factory
5560 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5561 new NHXParser() )[ 0 ];
5562 PhylogenyMethods.preOrderReId( p3 );
5563 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5564 p3.getNode( "c" ) );
5565 if ( !bc_3.getName().equals( "bc" ) ) {
5568 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5569 p3.getNode( "c" ) );
5570 if ( !ac_3.getName().equals( "abc" ) ) {
5573 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5574 p3.getNode( "d" ) );
5575 if ( !ad_3.getName().equals( "abcde" ) ) {
5578 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5579 p3.getNode( "f" ) );
5580 if ( !af_3.getName().equals( "abcdef" ) ) {
5583 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5584 p3.getNode( "g" ) );
5585 if ( !ag_3.getName().equals( "" ) ) {
5588 if ( !ag_3.isRoot() ) {
5591 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5592 p3.getNode( "l" ) );
5593 if ( !al_3.getName().equals( "" ) ) {
5596 if ( !al_3.isRoot() ) {
5599 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5600 p3.getNode( "l" ) );
5601 if ( !kl_3.getName().equals( "" ) ) {
5604 if ( !kl_3.isRoot() ) {
5607 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5608 p3.getNode( "l" ) );
5609 if ( !fl_3.getName().equals( "" ) ) {
5612 if ( !fl_3.isRoot() ) {
5615 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5616 p3.getNode( "k" ) );
5617 if ( !gk_3.getName().equals( "ghijk" ) ) {
5620 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5621 PhylogenyMethods.preOrderReId( p4 );
5622 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5623 p4.getNode( "c" ) );
5624 if ( !r_4.getName().equals( "r" ) ) {
5627 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5628 PhylogenyMethods.preOrderReId( p5 );
5629 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5630 p5.getNode( "c" ) );
5631 if ( !r_5.getName().equals( "root" ) ) {
5634 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5635 PhylogenyMethods.preOrderReId( p6 );
5636 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5637 p6.getNode( "a" ) );
5638 if ( !r_6.getName().equals( "rot" ) ) {
5641 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5642 PhylogenyMethods.preOrderReId( p7 );
5643 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5644 p7.getNode( "e" ) );
5645 if ( !r_7.getName().equals( "rott" ) ) {
5648 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5649 p7.getNode( "a" ) );
5650 if ( !r_71.getName().equals( "rott" ) ) {
5653 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5654 p7.getNode( "rott" ) );
5655 if ( !r_72.getName().equals( "rott" ) ) {
5658 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5659 p7.getNode( "a" ) );
5660 if ( !r_73.getName().equals( "rott" ) ) {
5663 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5664 p7.getNode( "rott" ) );
5665 if ( !r_74.getName().equals( "rott" ) ) {
5668 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5669 p7.getNode( "e" ) );
5670 if ( !r_75.getName().equals( "e" ) ) {
5674 catch ( final Exception e ) {
5675 e.printStackTrace( System.out );
5681 private static boolean testHmmscanOutputParser() {
5682 final String test_dir = Test.PATH_TO_TEST_DATA;
5684 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5685 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5687 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5688 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5689 final List<Protein> proteins = parser2.parse();
5690 if ( parser2.getProteinsEncountered() != 4 ) {
5693 if ( proteins.size() != 4 ) {
5696 if ( parser2.getDomainsEncountered() != 69 ) {
5699 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5702 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5705 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5708 final Protein p1 = proteins.get( 0 );
5709 if ( p1.getNumberOfProteinDomains() != 15 ) {
5712 if ( p1.getLength() != 850 ) {
5715 final Protein p2 = proteins.get( 1 );
5716 if ( p2.getNumberOfProteinDomains() != 51 ) {
5719 if ( p2.getLength() != 1291 ) {
5722 final Protein p3 = proteins.get( 2 );
5723 if ( p3.getNumberOfProteinDomains() != 2 ) {
5726 final Protein p4 = proteins.get( 3 );
5727 if ( p4.getNumberOfProteinDomains() != 1 ) {
5730 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5733 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5736 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5739 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5742 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5745 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5748 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5752 catch ( final Exception e ) {
5753 e.printStackTrace( System.out );
5759 private static boolean testLastExternalNodeMethods() {
5761 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5762 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5763 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5764 final PhylogenyNode n1 = t0.getNode( "A" );
5765 if ( n1.isLastExternalNode() ) {
5768 final PhylogenyNode n2 = t0.getNode( "B" );
5769 if ( n2.isLastExternalNode() ) {
5772 final PhylogenyNode n3 = t0.getNode( "C" );
5773 if ( n3.isLastExternalNode() ) {
5776 final PhylogenyNode n4 = t0.getNode( "D" );
5777 if ( !n4.isLastExternalNode() ) {
5781 catch ( final Exception e ) {
5782 e.printStackTrace( System.out );
5788 private static boolean testLevelOrderIterator() {
5790 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5791 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5792 PhylogenyNodeIterator it0;
5793 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5796 for( it0.reset(); it0.hasNext(); ) {
5799 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5800 if ( !it.next().getName().equals( "r" ) ) {
5803 if ( !it.next().getName().equals( "ab" ) ) {
5806 if ( !it.next().getName().equals( "cd" ) ) {
5809 if ( !it.next().getName().equals( "A" ) ) {
5812 if ( !it.next().getName().equals( "B" ) ) {
5815 if ( !it.next().getName().equals( "C" ) ) {
5818 if ( !it.next().getName().equals( "D" ) ) {
5821 if ( it.hasNext() ) {
5824 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",
5825 new NHXParser() )[ 0 ];
5826 PhylogenyNodeIterator it2;
5827 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5830 for( it2.reset(); it2.hasNext(); ) {
5833 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5834 if ( !it3.next().getName().equals( "r" ) ) {
5837 if ( !it3.next().getName().equals( "abc" ) ) {
5840 if ( !it3.next().getName().equals( "defg" ) ) {
5843 if ( !it3.next().getName().equals( "A" ) ) {
5846 if ( !it3.next().getName().equals( "B" ) ) {
5849 if ( !it3.next().getName().equals( "C" ) ) {
5852 if ( !it3.next().getName().equals( "D" ) ) {
5855 if ( !it3.next().getName().equals( "E" ) ) {
5858 if ( !it3.next().getName().equals( "F" ) ) {
5861 if ( !it3.next().getName().equals( "G" ) ) {
5864 if ( !it3.next().getName().equals( "1" ) ) {
5867 if ( !it3.next().getName().equals( "2" ) ) {
5870 if ( !it3.next().getName().equals( "3" ) ) {
5873 if ( !it3.next().getName().equals( "4" ) ) {
5876 if ( !it3.next().getName().equals( "5" ) ) {
5879 if ( !it3.next().getName().equals( "6" ) ) {
5882 if ( !it3.next().getName().equals( "f1" ) ) {
5885 if ( !it3.next().getName().equals( "f2" ) ) {
5888 if ( !it3.next().getName().equals( "f3" ) ) {
5891 if ( !it3.next().getName().equals( "a" ) ) {
5894 if ( !it3.next().getName().equals( "b" ) ) {
5897 if ( !it3.next().getName().equals( "f21" ) ) {
5900 if ( !it3.next().getName().equals( "X" ) ) {
5903 if ( !it3.next().getName().equals( "Y" ) ) {
5906 if ( !it3.next().getName().equals( "Z" ) ) {
5909 if ( it3.hasNext() ) {
5912 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5913 PhylogenyNodeIterator it4;
5914 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5917 for( it4.reset(); it4.hasNext(); ) {
5920 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5921 if ( !it5.next().getName().equals( "r" ) ) {
5924 if ( !it5.next().getName().equals( "A" ) ) {
5927 if ( !it5.next().getName().equals( "B" ) ) {
5930 if ( !it5.next().getName().equals( "C" ) ) {
5933 if ( !it5.next().getName().equals( "D" ) ) {
5936 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5937 PhylogenyNodeIterator it6;
5938 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5941 for( it6.reset(); it6.hasNext(); ) {
5944 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5945 if ( !it7.next().getName().equals( "A" ) ) {
5948 if ( it.hasNext() ) {
5952 catch ( final Exception e ) {
5953 e.printStackTrace( System.out );
5959 private static boolean testMafft( final String path ) {
5961 final List<String> opts = new ArrayList<String>();
5962 opts.add( "--maxiterate" );
5964 opts.add( "--localpair" );
5965 opts.add( "--quiet" );
5967 final MsaInferrer mafft = Mafft.createInstance( path );
5968 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5969 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5972 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5976 catch ( final Exception e ) {
5977 e.printStackTrace( System.out );
5983 private static boolean testMidpointrooting() {
5985 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5986 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5987 PhylogenyMethods.midpointRoot( t0 );
5988 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5991 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5994 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5998 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",
5999 new NHXParser() )[ 0 ];
6000 if ( !t1.isRooted() ) {
6003 PhylogenyMethods.midpointRoot( t1 );
6004 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6007 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6010 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6013 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6016 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6019 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6022 t1.reRoot( t1.getNode( "A" ) );
6023 PhylogenyMethods.midpointRoot( t1 );
6024 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6027 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6030 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6033 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6036 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6040 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6044 catch ( final Exception e ) {
6045 e.printStackTrace( System.out );
6051 private static boolean testMsaQualityMethod() {
6053 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6054 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6055 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6056 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6057 final List<Sequence> l = new ArrayList<Sequence>();
6062 final Msa msa = BasicMsa.createInstance( l );
6063 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6066 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6069 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6072 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6075 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6078 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6081 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6085 catch ( final Exception e ) {
6086 e.printStackTrace( System.out );
6092 private static boolean testDeleteableMsa() {
6094 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6095 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6096 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6097 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6098 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6099 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6100 final List<Sequence> l0 = new ArrayList<Sequence>();
6107 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6108 dmsa0.deleteRow( "b" );
6109 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6112 System.out.println();
6113 System.out.println( dmsa0.toString() );
6114 dmsa0.deleteRow( "e" );
6115 System.out.println();
6116 System.out.println( dmsa0.toString() );
6117 dmsa0.deleteRow( "a" );
6118 System.out.println();
6119 System.out.println( dmsa0.toString() );
6120 dmsa0.deleteRow( "f" );
6121 System.out.println();
6122 System.out.println( dmsa0.toString() );
6123 if ( dmsa0.getLength() != 4 ) {
6126 if ( dmsa0.getNumberOfSequences() != 2 ) {
6129 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6132 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6135 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6138 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6141 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6144 dmsa0.deleteRow( "c" );
6145 dmsa0.deleteRow( "d" );
6146 if ( dmsa0.getNumberOfSequences() != 0 ) {
6150 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6151 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6152 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6153 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6154 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6155 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6156 final List<Sequence> l1 = new ArrayList<Sequence>();
6163 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6164 System.out.println( dmsa1.toString() );
6165 dmsa1.deleteGapOnlyColumns();
6166 System.out.println( dmsa1.toString() );
6167 dmsa1.deleteRow( "a" );
6168 dmsa1.deleteRow( "f" );
6169 dmsa1.deleteRow( "d" );
6170 System.out.println( dmsa1.toString() );
6171 dmsa1.deleteGapOnlyColumns();
6172 System.out.println( dmsa1.toString() );
6173 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6176 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6179 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6182 dmsa1.deleteRow( "c" );
6183 dmsa1.deleteGapOnlyColumns();
6184 final Writer w0 = new StringWriter();
6185 dmsa1.write( w0, MSA_FORMAT.FASTA );
6186 System.out.println( w0.toString() );
6187 final Writer w1 = new StringWriter();
6188 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6189 System.out.println( w1.toString() );
6190 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6193 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6197 final Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6198 final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6199 final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6200 final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6201 final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6202 final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6203 final List<Sequence> l2 = new ArrayList<Sequence>();
6210 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6211 System.out.println( dmsa2.toString() );
6212 dmsa2.deleteGapColumns( 0.5 );
6213 System.out.println( dmsa2.toString() );
6215 catch ( final Exception e ) {
6216 e.printStackTrace( System.out );
6222 private static boolean testNextNodeWithCollapsing() {
6224 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6226 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6227 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6228 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6229 t0.getNode( "cd" ).setCollapse( true );
6230 t0.getNode( "cde" ).setCollapse( true );
6231 n = t0.getFirstExternalNode();
6232 while ( n != null ) {
6234 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6236 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6239 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6242 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6245 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6248 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6251 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6255 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6256 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6257 t1.getNode( "ab" ).setCollapse( true );
6258 t1.getNode( "cd" ).setCollapse( true );
6259 t1.getNode( "cde" ).setCollapse( true );
6260 n = t1.getNode( "ab" );
6261 ext = new ArrayList<PhylogenyNode>();
6262 while ( n != null ) {
6264 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6266 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6269 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6272 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6275 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6278 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6284 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6285 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6286 t2.getNode( "ab" ).setCollapse( true );
6287 t2.getNode( "cd" ).setCollapse( true );
6288 t2.getNode( "cde" ).setCollapse( true );
6289 t2.getNode( "c" ).setCollapse( true );
6290 t2.getNode( "d" ).setCollapse( true );
6291 t2.getNode( "e" ).setCollapse( true );
6292 t2.getNode( "gh" ).setCollapse( true );
6293 n = t2.getNode( "ab" );
6294 ext = new ArrayList<PhylogenyNode>();
6295 while ( n != null ) {
6297 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6299 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6302 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6305 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6308 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6314 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6315 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6316 t3.getNode( "ab" ).setCollapse( true );
6317 t3.getNode( "cd" ).setCollapse( true );
6318 t3.getNode( "cde" ).setCollapse( true );
6319 t3.getNode( "c" ).setCollapse( true );
6320 t3.getNode( "d" ).setCollapse( true );
6321 t3.getNode( "e" ).setCollapse( true );
6322 t3.getNode( "gh" ).setCollapse( true );
6323 t3.getNode( "fgh" ).setCollapse( true );
6324 n = t3.getNode( "ab" );
6325 ext = new ArrayList<PhylogenyNode>();
6326 while ( n != null ) {
6328 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6330 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6333 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6336 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6342 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6343 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6344 t4.getNode( "ab" ).setCollapse( true );
6345 t4.getNode( "cd" ).setCollapse( true );
6346 t4.getNode( "cde" ).setCollapse( true );
6347 t4.getNode( "c" ).setCollapse( true );
6348 t4.getNode( "d" ).setCollapse( true );
6349 t4.getNode( "e" ).setCollapse( true );
6350 t4.getNode( "gh" ).setCollapse( true );
6351 t4.getNode( "fgh" ).setCollapse( true );
6352 t4.getNode( "abcdefgh" ).setCollapse( true );
6353 n = t4.getNode( "abcdefgh" );
6354 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6359 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6360 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6362 n = t5.getFirstExternalNode();
6363 while ( n != null ) {
6365 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6367 if ( ext.size() != 8 ) {
6370 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6373 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6376 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6379 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6382 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6385 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6388 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6391 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6396 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6397 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6399 t6.getNode( "ab" ).setCollapse( true );
6400 n = t6.getNode( "ab" );
6401 while ( n != null ) {
6403 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6405 if ( ext.size() != 7 ) {
6408 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6411 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6414 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6417 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6420 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6423 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6426 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6431 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6432 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6434 t7.getNode( "cd" ).setCollapse( true );
6435 n = t7.getNode( "a" );
6436 while ( n != null ) {
6438 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6440 if ( ext.size() != 7 ) {
6443 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6446 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6449 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6452 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6455 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6458 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6461 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6466 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6467 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6469 t8.getNode( "cd" ).setCollapse( true );
6470 t8.getNode( "c" ).setCollapse( true );
6471 t8.getNode( "d" ).setCollapse( true );
6472 n = t8.getNode( "a" );
6473 while ( n != null ) {
6475 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6477 if ( ext.size() != 7 ) {
6480 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6483 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6486 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6487 System.out.println( "2 fail" );
6490 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6493 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6496 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6499 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6504 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6505 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6507 t9.getNode( "gh" ).setCollapse( true );
6508 n = t9.getNode( "a" );
6509 while ( n != null ) {
6511 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6513 if ( ext.size() != 7 ) {
6516 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6519 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6522 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6525 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6528 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6531 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6534 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6539 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6540 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6542 t10.getNode( "gh" ).setCollapse( true );
6543 t10.getNode( "g" ).setCollapse( true );
6544 t10.getNode( "h" ).setCollapse( true );
6545 n = t10.getNode( "a" );
6546 while ( n != null ) {
6548 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6550 if ( ext.size() != 7 ) {
6553 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6556 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6559 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6562 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6565 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6568 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6571 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6576 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6577 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6579 t11.getNode( "gh" ).setCollapse( true );
6580 t11.getNode( "fgh" ).setCollapse( true );
6581 n = t11.getNode( "a" );
6582 while ( n != null ) {
6584 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6586 if ( ext.size() != 6 ) {
6589 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6592 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6595 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6598 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6601 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6604 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6609 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6610 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6612 t12.getNode( "gh" ).setCollapse( true );
6613 t12.getNode( "fgh" ).setCollapse( true );
6614 t12.getNode( "g" ).setCollapse( true );
6615 t12.getNode( "h" ).setCollapse( true );
6616 t12.getNode( "f" ).setCollapse( true );
6617 n = t12.getNode( "a" );
6618 while ( n != null ) {
6620 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6622 if ( ext.size() != 6 ) {
6625 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6628 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6631 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6634 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6637 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6640 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6645 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6646 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6648 t13.getNode( "ab" ).setCollapse( true );
6649 t13.getNode( "b" ).setCollapse( true );
6650 t13.getNode( "fgh" ).setCollapse( true );
6651 t13.getNode( "gh" ).setCollapse( true );
6652 n = t13.getNode( "ab" );
6653 while ( n != null ) {
6655 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6657 if ( ext.size() != 5 ) {
6660 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6663 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6666 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6669 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6672 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6677 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6678 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6680 t14.getNode( "ab" ).setCollapse( true );
6681 t14.getNode( "a" ).setCollapse( true );
6682 t14.getNode( "fgh" ).setCollapse( true );
6683 t14.getNode( "gh" ).setCollapse( true );
6684 n = t14.getNode( "ab" );
6685 while ( n != null ) {
6687 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6689 if ( ext.size() != 5 ) {
6692 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6695 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6698 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6701 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6704 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6709 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" );
6710 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6712 t15.getNode( "ab" ).setCollapse( true );
6713 t15.getNode( "a" ).setCollapse( true );
6714 t15.getNode( "fgh" ).setCollapse( true );
6715 t15.getNode( "gh" ).setCollapse( true );
6716 n = t15.getNode( "ab" );
6717 while ( n != null ) {
6719 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6721 if ( ext.size() != 6 ) {
6724 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6727 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6730 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6733 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6736 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6739 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6744 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" );
6745 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6747 t16.getNode( "ab" ).setCollapse( true );
6748 t16.getNode( "a" ).setCollapse( true );
6749 t16.getNode( "fgh" ).setCollapse( true );
6750 t16.getNode( "gh" ).setCollapse( true );
6751 t16.getNode( "cd" ).setCollapse( true );
6752 t16.getNode( "cde" ).setCollapse( true );
6753 t16.getNode( "d" ).setCollapse( true );
6754 t16.getNode( "x" ).setCollapse( true );
6755 n = t16.getNode( "ab" );
6756 while ( n != null ) {
6758 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6760 if ( ext.size() != 4 ) {
6763 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6766 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6769 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6772 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6776 catch ( final Exception e ) {
6777 e.printStackTrace( System.out );
6783 private static boolean testNexusCharactersParsing() {
6785 final NexusCharactersParser parser = new NexusCharactersParser();
6786 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6788 String[] labels = parser.getCharStateLabels();
6789 if ( labels.length != 7 ) {
6792 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6795 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6798 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6801 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6804 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6807 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6810 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6813 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6815 labels = parser.getCharStateLabels();
6816 if ( labels.length != 7 ) {
6819 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6822 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6825 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6828 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6831 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6834 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6837 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6841 catch ( final Exception e ) {
6842 e.printStackTrace( System.out );
6848 private static boolean testNexusMatrixParsing() {
6850 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6851 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6853 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6854 if ( m.getNumberOfCharacters() != 9 ) {
6857 if ( m.getNumberOfIdentifiers() != 5 ) {
6860 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6863 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6866 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6869 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6872 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6875 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6878 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6881 // if ( labels.length != 7 ) {
6884 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6887 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6890 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6893 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6896 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6899 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6902 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6905 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6907 // labels = parser.getCharStateLabels();
6908 // if ( labels.length != 7 ) {
6911 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6914 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6917 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6920 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6923 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6926 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6929 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6933 catch ( final Exception e ) {
6934 e.printStackTrace( System.out );
6940 private static boolean testNexusTreeParsing() {
6942 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6943 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6944 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6945 if ( phylogenies.length != 1 ) {
6948 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6951 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6955 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6956 if ( phylogenies.length != 1 ) {
6959 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6962 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6966 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6967 if ( phylogenies.length != 1 ) {
6970 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6973 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6976 if ( phylogenies[ 0 ].isRooted() ) {
6980 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6981 if ( phylogenies.length != 18 ) {
6984 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6987 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6990 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6993 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6996 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6999 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7002 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7005 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7008 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7011 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7014 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7017 if ( phylogenies[ 8 ].isRooted() ) {
7020 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7023 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7026 if ( !phylogenies[ 9 ].isRooted() ) {
7029 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7032 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7035 if ( !phylogenies[ 10 ].isRooted() ) {
7038 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7041 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7044 if ( phylogenies[ 11 ].isRooted() ) {
7047 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7050 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7053 if ( !phylogenies[ 12 ].isRooted() ) {
7056 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7059 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7062 if ( !phylogenies[ 13 ].isRooted() ) {
7065 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7068 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7071 if ( !phylogenies[ 14 ].isRooted() ) {
7074 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7077 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7080 if ( phylogenies[ 15 ].isRooted() ) {
7083 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7086 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7089 if ( !phylogenies[ 16 ].isRooted() ) {
7092 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7095 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7098 if ( phylogenies[ 17 ].isRooted() ) {
7101 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7104 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7106 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7107 if ( phylogenies.length != 9 ) {
7110 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7111 .getDistanceToParent() ) ) {
7114 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7115 .getDistanceToParent() ) ) {
7118 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7121 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7124 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7127 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7130 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7134 catch ( final Exception e ) {
7135 e.printStackTrace( System.out );
7141 private static boolean testNexusTreeParsingIterating() {
7143 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7144 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7145 if ( !p.hasNext() ) {
7148 Phylogeny phy = p.next();
7149 if ( phy == null ) {
7152 if ( phy.getNumberOfExternalNodes() != 25 ) {
7155 if ( !phy.getName().equals( "" ) ) {
7158 if ( p.hasNext() ) {
7162 if ( phy != null ) {
7167 if ( !p.hasNext() ) {
7171 if ( phy == null ) {
7174 if ( phy.getNumberOfExternalNodes() != 25 ) {
7177 if ( !phy.getName().equals( "" ) ) {
7180 if ( p.hasNext() ) {
7184 if ( phy != null ) {
7188 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7189 if ( !p.hasNext() ) {
7193 if ( phy == null ) {
7196 if ( phy.getNumberOfExternalNodes() != 10 ) {
7199 if ( !phy.getName().equals( "name" ) ) {
7202 if ( p.hasNext() ) {
7206 if ( phy != null ) {
7211 if ( !p.hasNext() ) {
7215 if ( phy == null ) {
7218 if ( phy.getNumberOfExternalNodes() != 10 ) {
7221 if ( !phy.getName().equals( "name" ) ) {
7224 if ( p.hasNext() ) {
7228 if ( phy != null ) {
7232 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7233 if ( !p.hasNext() ) {
7237 if ( phy == null ) {
7240 if ( phy.getNumberOfExternalNodes() != 3 ) {
7243 if ( !phy.getName().equals( "" ) ) {
7246 if ( phy.isRooted() ) {
7249 if ( p.hasNext() ) {
7253 if ( phy != null ) {
7258 if ( !p.hasNext() ) {
7262 if ( phy == null ) {
7265 if ( phy.getNumberOfExternalNodes() != 3 ) {
7268 if ( !phy.getName().equals( "" ) ) {
7271 if ( p.hasNext() ) {
7275 if ( phy != null ) {
7279 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7280 if ( !p.hasNext() ) {
7285 if ( phy == null ) {
7288 if ( phy.getNumberOfExternalNodes() != 10 ) {
7291 if ( !phy.getName().equals( "tree 0" ) ) {
7295 if ( !p.hasNext() ) {
7299 if ( phy == null ) {
7302 if ( phy.getNumberOfExternalNodes() != 10 ) {
7305 if ( !phy.getName().equals( "tree 1" ) ) {
7309 if ( !p.hasNext() ) {
7313 if ( phy == null ) {
7316 if ( phy.getNumberOfExternalNodes() != 3 ) {
7317 System.out.println( phy.toString() );
7320 if ( !phy.getName().equals( "" ) ) {
7323 if ( phy.isRooted() ) {
7327 if ( !p.hasNext() ) {
7331 if ( phy == null ) {
7334 if ( phy.getNumberOfExternalNodes() != 4 ) {
7337 if ( !phy.getName().equals( "" ) ) {
7340 if ( !phy.isRooted() ) {
7344 if ( !p.hasNext() ) {
7348 if ( phy == null ) {
7351 if ( phy.getNumberOfExternalNodes() != 5 ) {
7352 System.out.println( phy.getNumberOfExternalNodes() );
7355 if ( !phy.getName().equals( "" ) ) {
7358 if ( !phy.isRooted() ) {
7362 if ( !p.hasNext() ) {
7366 if ( phy == null ) {
7369 if ( phy.getNumberOfExternalNodes() != 3 ) {
7372 if ( !phy.getName().equals( "" ) ) {
7375 if ( phy.isRooted() ) {
7379 if ( !p.hasNext() ) {
7383 if ( phy == null ) {
7386 if ( phy.getNumberOfExternalNodes() != 2 ) {
7389 if ( !phy.getName().equals( "" ) ) {
7392 if ( !phy.isRooted() ) {
7396 if ( !p.hasNext() ) {
7400 if ( phy.getNumberOfExternalNodes() != 3 ) {
7403 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7406 if ( !phy.isRooted() ) {
7410 if ( !p.hasNext() ) {
7414 if ( phy.getNumberOfExternalNodes() != 3 ) {
7417 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7420 if ( !phy.getName().equals( "tree 8" ) ) {
7424 if ( !p.hasNext() ) {
7428 if ( phy.getNumberOfExternalNodes() != 3 ) {
7431 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7434 if ( !phy.getName().equals( "tree 9" ) ) {
7438 if ( !p.hasNext() ) {
7442 if ( phy.getNumberOfExternalNodes() != 3 ) {
7445 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7448 if ( !phy.getName().equals( "tree 10" ) ) {
7451 if ( !phy.isRooted() ) {
7455 if ( !p.hasNext() ) {
7459 if ( phy.getNumberOfExternalNodes() != 3 ) {
7462 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7465 if ( !phy.getName().equals( "tree 11" ) ) {
7468 if ( phy.isRooted() ) {
7472 if ( !p.hasNext() ) {
7476 if ( phy.getNumberOfExternalNodes() != 3 ) {
7479 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7482 if ( !phy.getName().equals( "tree 12" ) ) {
7485 if ( !phy.isRooted() ) {
7489 if ( !p.hasNext() ) {
7493 if ( phy.getNumberOfExternalNodes() != 3 ) {
7496 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7499 if ( !phy.getName().equals( "tree 13" ) ) {
7502 if ( !phy.isRooted() ) {
7506 if ( !p.hasNext() ) {
7510 if ( phy.getNumberOfExternalNodes() != 10 ) {
7511 System.out.println( phy.getNumberOfExternalNodes() );
7516 .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;" ) ) {
7517 System.out.println( phy.toNewHampshire() );
7520 if ( !phy.getName().equals( "tree 14" ) ) {
7523 if ( !phy.isRooted() ) {
7527 if ( !p.hasNext() ) {
7531 if ( phy.getNumberOfExternalNodes() != 10 ) {
7532 System.out.println( phy.getNumberOfExternalNodes() );
7537 .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;" ) ) {
7538 System.out.println( phy.toNewHampshire() );
7541 if ( !phy.getName().equals( "tree 15" ) ) {
7544 if ( phy.isRooted() ) {
7548 if ( !p.hasNext() ) {
7552 if ( phy.getNumberOfExternalNodes() != 10 ) {
7553 System.out.println( phy.getNumberOfExternalNodes() );
7558 .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;" ) ) {
7559 System.out.println( phy.toNewHampshire() );
7562 if ( !phy.getName().equals( "tree 16" ) ) {
7565 if ( !phy.isRooted() ) {
7569 if ( !p.hasNext() ) {
7573 if ( phy.getNumberOfExternalNodes() != 10 ) {
7574 System.out.println( phy.getNumberOfExternalNodes() );
7579 .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;" ) ) {
7580 System.out.println( phy.toNewHampshire() );
7583 if ( !phy.getName().equals( "tree 17" ) ) {
7586 if ( phy.isRooted() ) {
7590 if ( p.hasNext() ) {
7594 if ( phy != null ) {
7599 if ( !p.hasNext() ) {
7603 if ( phy == null ) {
7606 if ( phy.getNumberOfExternalNodes() != 10 ) {
7609 if ( !phy.getName().equals( "tree 0" ) ) {
7613 if ( !p.hasNext() ) {
7617 if ( phy == null ) {
7620 if ( phy.getNumberOfExternalNodes() != 10 ) {
7623 if ( !phy.getName().equals( "tree 1" ) ) {
7627 if ( !p.hasNext() ) {
7631 if ( phy == null ) {
7634 if ( phy.getNumberOfExternalNodes() != 3 ) {
7637 if ( !phy.getName().equals( "" ) ) {
7640 if ( phy.isRooted() ) {
7644 if ( !p.hasNext() ) {
7648 if ( phy == null ) {
7651 if ( phy.getNumberOfExternalNodes() != 4 ) {
7654 if ( !phy.getName().equals( "" ) ) {
7657 if ( !phy.isRooted() ) {
7661 if ( !p.hasNext() ) {
7665 if ( phy == null ) {
7668 if ( phy.getNumberOfExternalNodes() != 5 ) {
7669 System.out.println( phy.getNumberOfExternalNodes() );
7672 if ( !phy.getName().equals( "" ) ) {
7675 if ( !phy.isRooted() ) {
7679 if ( !p.hasNext() ) {
7683 if ( phy == null ) {
7686 if ( phy.getNumberOfExternalNodes() != 3 ) {
7689 if ( !phy.getName().equals( "" ) ) {
7692 if ( phy.isRooted() ) {
7696 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7697 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7699 if ( !p2.hasNext() ) {
7703 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7706 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7710 if ( !p2.hasNext() ) {
7715 if ( !p2.hasNext() ) {
7720 if ( !p2.hasNext() ) {
7725 if ( !p2.hasNext() ) {
7730 if ( !p2.hasNext() ) {
7735 if ( !p2.hasNext() ) {
7740 if ( !p2.hasNext() ) {
7745 if ( !p2.hasNext() ) {
7749 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7752 if ( p2.hasNext() ) {
7756 if ( phy != null ) {
7761 if ( !p2.hasNext() ) {
7765 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7768 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7772 catch ( final Exception e ) {
7773 e.printStackTrace( System.out );
7779 private static boolean testNexusTreeParsingTranslating() {
7781 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7782 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7783 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7784 if ( phylogenies.length != 1 ) {
7787 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7790 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7793 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7796 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7799 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7800 .equals( "Aranaeus" ) ) {
7804 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7805 if ( phylogenies.length != 3 ) {
7808 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7811 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7814 if ( phylogenies[ 0 ].isRooted() ) {
7817 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7820 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7823 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7824 .equals( "Aranaeus" ) ) {
7827 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7830 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7833 if ( phylogenies[ 1 ].isRooted() ) {
7836 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7839 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7842 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7843 .equals( "Aranaeus" ) ) {
7846 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7849 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7852 if ( !phylogenies[ 2 ].isRooted() ) {
7855 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7858 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7861 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7862 .equals( "Aranaeus" ) ) {
7866 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7867 if ( phylogenies.length != 3 ) {
7870 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7873 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7876 if ( phylogenies[ 0 ].isRooted() ) {
7879 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7882 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7885 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7886 .equals( "Aranaeus" ) ) {
7889 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7892 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7895 if ( phylogenies[ 1 ].isRooted() ) {
7898 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7901 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7904 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7905 .equals( "Aranaeus" ) ) {
7908 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7911 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7914 if ( !phylogenies[ 2 ].isRooted() ) {
7917 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7920 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7923 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7924 .equals( "Aranaeus" ) ) {
7927 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7928 if ( phylogenies.length != 3 ) {
7931 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7936 catch ( final Exception e ) {
7937 e.printStackTrace( System.out );
7943 private static boolean testNHParsing() {
7945 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7946 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7947 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7950 final NHXParser nhxp = new NHXParser();
7951 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7952 nhxp.setReplaceUnderscores( true );
7953 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7954 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7957 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7960 final Phylogeny p1b = factory
7961 .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 ",
7962 new NHXParser() )[ 0 ];
7963 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7966 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7969 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7970 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7971 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7972 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7973 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7974 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7975 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7976 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7977 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7978 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7979 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7980 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7981 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7983 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7986 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7989 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7992 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7995 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7996 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7997 final String p16_S = "((A,B),C)";
7998 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7999 if ( p16.length != 1 ) {
8002 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8005 final String p17_S = "(C,(A,B))";
8006 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8007 if ( p17.length != 1 ) {
8010 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8013 final String p18_S = "((A,B),(C,D))";
8014 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8015 if ( p18.length != 1 ) {
8018 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8021 final String p19_S = "(((A,B),C),D)";
8022 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8023 if ( p19.length != 1 ) {
8026 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8029 final String p20_S = "(A,(B,(C,D)))";
8030 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8031 if ( p20.length != 1 ) {
8034 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8037 final String p21_S = "(A,(B,(C,(D,E))))";
8038 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8039 if ( p21.length != 1 ) {
8042 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8045 final String p22_S = "((((A,B),C),D),E)";
8046 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8047 if ( p22.length != 1 ) {
8050 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8053 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8054 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8055 if ( p23.length != 1 ) {
8056 System.out.println( "xl=" + p23.length );
8060 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8063 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8064 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8065 if ( p24.length != 1 ) {
8068 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8071 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8072 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8073 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8074 if ( p241.length != 2 ) {
8077 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8080 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8083 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8084 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8085 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8086 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8087 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8088 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8089 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8090 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8091 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8092 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8095 final String p26_S = "(A,B)ab";
8096 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8097 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8100 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8101 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8102 if ( p27s.length != 1 ) {
8103 System.out.println( "xxl=" + p27s.length );
8107 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8108 System.out.println( p27s[ 0 ].toNewHampshireX() );
8112 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8114 if ( p27.length != 1 ) {
8115 System.out.println( "yl=" + p27.length );
8119 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8120 System.out.println( p27[ 0 ].toNewHampshireX() );
8124 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8125 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8126 final String p28_S3 = "(A,B)ab";
8127 final String p28_S4 = "((((A,B),C),D),;E;)";
8128 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8130 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8133 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8136 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8139 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8142 if ( p28.length != 4 ) {
8145 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";
8146 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8147 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8150 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";
8151 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8152 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8155 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8156 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8157 if ( ( p32.length != 0 ) ) {
8160 final String p33_S = "A";
8161 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8162 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8165 final String p34_S = "B;";
8166 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8167 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8170 final String p35_S = "B:0.2";
8171 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8172 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8175 final String p36_S = "(A)";
8176 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8177 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8180 final String p37_S = "((A))";
8181 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8182 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8185 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8186 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8187 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8190 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8191 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8192 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8195 final String p40_S = "(A,B,C)";
8196 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8197 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8200 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8201 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8202 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8205 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8206 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8207 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8210 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)";
8211 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8212 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8215 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)))";
8216 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8217 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8220 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8221 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8222 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8225 final String p46_S = "";
8226 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8227 if ( p46.length != 0 ) {
8230 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8231 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8234 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8235 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8238 final Phylogeny p49 = factory
8239 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8240 new NHXParser() )[ 0 ];
8241 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8244 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8245 if ( p50.getNode( "A" ) == null ) {
8248 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8249 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8252 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8255 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8256 .equals( "((A,B)88:2.0,C);" ) ) {
8259 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8260 if ( p51.getNode( "A(A" ) == null ) {
8263 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8264 if ( p52.getNode( "A(A" ) == null ) {
8267 final Phylogeny p53 = factory
8268 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8269 new NHXParser() )[ 0 ];
8270 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8273 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8274 if ( p54.getNode( "A" ) == null ) {
8277 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8280 final Phylogeny p55 = factory
8281 .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);" ),
8282 new NHXParser() )[ 0 ];
8285 .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);" ) ) {
8286 System.out.println( p55.toNewHampshire() );
8289 final Phylogeny p56 = factory
8290 .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);" ),
8291 new NHXParser() )[ 0 ];
8294 .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);" ) ) {
8295 System.out.println( p56.toNewHampshire() );
8298 final Phylogeny p57 = factory
8299 .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);" ),
8300 new NHXParser() )[ 0 ];
8303 .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);" ) ) {
8304 System.out.println( p56.toNewHampshire() );
8307 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8308 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8309 if ( !p58.toNewHampshire().equals( s58 ) ) {
8310 System.out.println( p58.toNewHampshire() );
8313 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8314 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8315 if ( !p59.toNewHampshire().equals( s59 ) ) {
8316 System.out.println( p59.toNewHampshire() );
8319 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8320 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8321 if ( !p60.toNewHampshire().equals( s60 ) ) {
8322 System.out.println( p60.toNewHampshire() );
8325 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8326 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8327 if ( !p61.toNewHampshire()
8328 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8329 System.out.println( p61.toNewHampshire() );
8333 catch ( final Exception e ) {
8334 e.printStackTrace( System.out );
8340 private static boolean testNHParsingIter() {
8342 final String p0_str = "(A,B);";
8343 final NHXParser p = new NHXParser();
8344 p.setSource( p0_str );
8345 if ( !p.hasNext() ) {
8348 final Phylogeny p0 = p.next();
8349 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8350 System.out.println( p0.toNewHampshire() );
8353 if ( p.hasNext() ) {
8356 if ( p.next() != null ) {
8360 final String p00_str = "(A,B)root;";
8361 p.setSource( p00_str );
8362 final Phylogeny p00 = p.next();
8363 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8364 System.out.println( p00.toNewHampshire() );
8368 final String p000_str = "A;";
8369 p.setSource( p000_str );
8370 final Phylogeny p000 = p.next();
8371 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8372 System.out.println( p000.toNewHampshire() );
8376 final String p0000_str = "A";
8377 p.setSource( p0000_str );
8378 final Phylogeny p0000 = p.next();
8379 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8380 System.out.println( p0000.toNewHampshire() );
8384 p.setSource( "(A)" );
8385 final Phylogeny p00000 = p.next();
8386 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8387 System.out.println( p00000.toNewHampshire() );
8391 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8392 p.setSource( p1_str );
8393 if ( !p.hasNext() ) {
8396 final Phylogeny p1_0 = p.next();
8397 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8398 System.out.println( p1_0.toNewHampshire() );
8401 if ( !p.hasNext() ) {
8404 final Phylogeny p1_1 = p.next();
8405 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8406 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8409 if ( !p.hasNext() ) {
8412 final Phylogeny p1_2 = p.next();
8413 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8414 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8417 if ( !p.hasNext() ) {
8420 final Phylogeny p1_3 = p.next();
8421 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8422 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8425 if ( p.hasNext() ) {
8428 if ( p.next() != null ) {
8432 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8433 p.setSource( p2_str );
8434 if ( !p.hasNext() ) {
8437 Phylogeny p2_0 = p.next();
8438 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8439 System.out.println( p2_0.toNewHampshire() );
8442 if ( !p.hasNext() ) {
8445 Phylogeny p2_1 = p.next();
8446 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8447 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8450 if ( !p.hasNext() ) {
8453 Phylogeny p2_2 = p.next();
8454 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8455 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8458 if ( !p.hasNext() ) {
8461 Phylogeny p2_3 = p.next();
8462 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8463 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8466 if ( !p.hasNext() ) {
8469 Phylogeny p2_4 = p.next();
8470 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8471 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8474 if ( p.hasNext() ) {
8477 if ( p.next() != null ) {
8482 if ( !p.hasNext() ) {
8486 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8487 System.out.println( p2_0.toNewHampshire() );
8490 if ( !p.hasNext() ) {
8494 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8495 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8498 if ( !p.hasNext() ) {
8502 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8503 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8506 if ( !p.hasNext() ) {
8510 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8511 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8514 if ( !p.hasNext() ) {
8518 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8519 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8522 if ( p.hasNext() ) {
8525 if ( p.next() != null ) {
8529 final String p3_str = "((A,B),C)abc";
8530 p.setSource( p3_str );
8531 if ( !p.hasNext() ) {
8534 final Phylogeny p3_0 = p.next();
8535 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8538 if ( p.hasNext() ) {
8541 if ( p.next() != null ) {
8545 final String p4_str = "((A,B)ab,C)abc";
8546 p.setSource( p4_str );
8547 if ( !p.hasNext() ) {
8550 final Phylogeny p4_0 = p.next();
8551 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8554 if ( p.hasNext() ) {
8557 if ( p.next() != null ) {
8561 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8562 p.setSource( p5_str );
8563 if ( !p.hasNext() ) {
8566 final Phylogeny p5_0 = p.next();
8567 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8570 if ( p.hasNext() ) {
8573 if ( p.next() != null ) {
8577 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8578 p.setSource( p6_str );
8579 if ( !p.hasNext() ) {
8582 Phylogeny p6_0 = p.next();
8583 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8586 if ( p.hasNext() ) {
8589 if ( p.next() != null ) {
8593 if ( !p.hasNext() ) {
8597 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8600 if ( p.hasNext() ) {
8603 if ( p.next() != null ) {
8607 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8608 p.setSource( p7_str );
8609 if ( !p.hasNext() ) {
8612 Phylogeny p7_0 = p.next();
8613 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8616 if ( p.hasNext() ) {
8619 if ( p.next() != null ) {
8623 if ( !p.hasNext() ) {
8627 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8630 if ( p.hasNext() ) {
8633 if ( p.next() != null ) {
8637 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8638 p.setSource( p8_str );
8639 if ( !p.hasNext() ) {
8642 Phylogeny p8_0 = p.next();
8643 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8646 if ( !p.hasNext() ) {
8649 if ( !p.hasNext() ) {
8652 Phylogeny p8_1 = p.next();
8653 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8656 if ( p.hasNext() ) {
8659 if ( p.next() != null ) {
8663 if ( !p.hasNext() ) {
8667 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8670 if ( !p.hasNext() ) {
8674 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8677 if ( p.hasNext() ) {
8680 if ( p.next() != null ) {
8686 if ( p.hasNext() ) {
8690 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8691 if ( !p.hasNext() ) {
8694 Phylogeny p_27 = p.next();
8695 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8696 System.out.println( p_27.toNewHampshireX() );
8700 if ( p.hasNext() ) {
8703 if ( p.next() != null ) {
8707 if ( !p.hasNext() ) {
8711 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8712 System.out.println( p_27.toNewHampshireX() );
8716 if ( p.hasNext() ) {
8719 if ( p.next() != null ) {
8723 final String p30_str = "(A,B);(C,D)";
8724 final NHXParser p30 = new NHXParser();
8725 p30.setSource( p30_str );
8726 if ( !p30.hasNext() ) {
8729 Phylogeny phy30 = p30.next();
8730 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8731 System.out.println( phy30.toNewHampshire() );
8734 if ( !p30.hasNext() ) {
8737 Phylogeny phy301 = p30.next();
8738 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8739 System.out.println( phy301.toNewHampshire() );
8742 if ( p30.hasNext() ) {
8745 if ( p30.hasNext() ) {
8748 if ( p30.next() != null ) {
8751 if ( p30.next() != null ) {
8755 if ( !p30.hasNext() ) {
8759 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8760 System.out.println( phy30.toNewHampshire() );
8763 if ( !p30.hasNext() ) {
8766 phy301 = p30.next();
8767 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8768 System.out.println( phy301.toNewHampshire() );
8771 if ( p30.hasNext() ) {
8774 if ( p30.hasNext() ) {
8777 if ( p30.next() != null ) {
8780 if ( p30.next() != null ) {
8784 catch ( final Exception e ) {
8785 e.printStackTrace( System.out );
8791 private static boolean testNHXconversion() {
8793 final PhylogenyNode n1 = new PhylogenyNode();
8794 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8795 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8796 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8797 final PhylogenyNode n5 = PhylogenyNode
8798 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8799 final PhylogenyNode n6 = PhylogenyNode
8800 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8801 if ( !n1.toNewHampshireX().equals( "" ) ) {
8804 if ( !n2.toNewHampshireX().equals( "" ) ) {
8807 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8810 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8813 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8816 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8817 System.out.println( n6.toNewHampshireX() );
8820 final PhylogenyNode n7 = new PhylogenyNode();
8821 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8822 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8823 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8824 System.out.println( n7
8825 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8829 catch ( final Exception e ) {
8830 e.printStackTrace( System.out );
8836 private static boolean testNHXNodeParsing() {
8838 final PhylogenyNode n1 = new PhylogenyNode();
8839 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8840 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8841 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8842 final PhylogenyNode n5 = PhylogenyNode
8843 .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]" );
8844 if ( !n3.getName().equals( "n3" ) ) {
8847 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8850 if ( n3.isDuplication() ) {
8853 if ( n3.isHasAssignedEvent() ) {
8856 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8859 if ( !n4.getName().equals( "n4" ) ) {
8862 if ( n4.getDistanceToParent() != 0.01 ) {
8865 if ( !n5.getName().equals( "n5" ) ) {
8868 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8871 if ( n5.getDistanceToParent() != 0.1 ) {
8874 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8877 if ( !n5.isDuplication() ) {
8880 if ( !n5.isHasAssignedEvent() ) {
8883 final PhylogenyNode n8 = PhylogenyNode
8884 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8885 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8886 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8889 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8892 final PhylogenyNode n9 = PhylogenyNode
8893 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8894 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8895 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8898 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8901 final PhylogenyNode n10 = PhylogenyNode
8902 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8903 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8906 final PhylogenyNode n20 = PhylogenyNode
8907 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8908 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8911 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8914 final PhylogenyNode n20x = PhylogenyNode
8915 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8916 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8919 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8922 final PhylogenyNode n20xx = PhylogenyNode
8923 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8924 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8927 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8930 final PhylogenyNode n20xxx = PhylogenyNode
8931 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8932 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8935 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8938 final PhylogenyNode n20xxxx = PhylogenyNode
8939 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8940 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8943 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8946 final PhylogenyNode n21 = PhylogenyNode
8947 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8948 if ( !n21.getName().equals( "N21_PIG" ) ) {
8951 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8954 final PhylogenyNode n21x = PhylogenyNode
8955 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8956 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8959 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8962 final PhylogenyNode n22 = PhylogenyNode
8963 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8964 if ( !n22.getName().equals( "n22/PIG" ) ) {
8967 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8970 final PhylogenyNode n23 = PhylogenyNode
8971 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8972 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8975 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8978 final PhylogenyNode a = PhylogenyNode
8979 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8980 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8983 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8986 final PhylogenyNode c1 = PhylogenyNode
8987 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8988 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8989 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8992 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8995 final PhylogenyNode c2 = PhylogenyNode
8996 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8997 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8998 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9001 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9004 final PhylogenyNode e3 = PhylogenyNode
9005 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9006 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9009 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9012 final PhylogenyNode n11 = PhylogenyNode
9013 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9014 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9015 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9018 if ( n11.getDistanceToParent() != 0.4 ) {
9021 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9024 final PhylogenyNode n12 = PhylogenyNode
9025 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9026 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9027 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9030 if ( n12.getDistanceToParent() != 0.4 ) {
9033 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9036 final PhylogenyNode o = PhylogenyNode
9037 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9038 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9041 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9044 if ( n1.getName().compareTo( "" ) != 0 ) {
9047 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9050 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9053 if ( n2.getName().compareTo( "" ) != 0 ) {
9056 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9059 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9062 final PhylogenyNode n00 = PhylogenyNode
9063 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9064 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9067 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9070 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9071 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9074 final PhylogenyNode n13 = PhylogenyNode
9075 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9076 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9079 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9082 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9085 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9088 final PhylogenyNode n14 = PhylogenyNode
9089 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9090 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9093 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9096 final PhylogenyNode n15 = PhylogenyNode
9097 .createInstanceFromNhxString( "something_wicked[123]",
9098 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9099 if ( !n15.getName().equals( "something_wicked" ) ) {
9102 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9105 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9108 final PhylogenyNode n16 = PhylogenyNode
9109 .createInstanceFromNhxString( "something_wicked2[9]",
9110 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9111 if ( !n16.getName().equals( "something_wicked2" ) ) {
9114 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9117 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9120 final PhylogenyNode n17 = PhylogenyNode
9121 .createInstanceFromNhxString( "something_wicked3[a]",
9122 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9123 if ( !n17.getName().equals( "something_wicked3" ) ) {
9126 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9129 final PhylogenyNode n18 = PhylogenyNode
9130 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9131 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9134 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9137 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9140 final PhylogenyNode n19 = PhylogenyNode
9141 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9142 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9145 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9148 final PhylogenyNode n30 = PhylogenyNode
9149 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9150 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9151 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9154 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9157 final PhylogenyNode n31 = PhylogenyNode
9158 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9159 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9160 if ( n31.getNodeData().isHasTaxonomy() ) {
9163 final PhylogenyNode n32 = PhylogenyNode
9164 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9165 if ( n32.getNodeData().isHasTaxonomy() ) {
9168 final PhylogenyNode n40 = PhylogenyNode
9169 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9170 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9173 final PhylogenyNode n41 = PhylogenyNode
9174 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9175 if ( n41.getNodeData().isHasTaxonomy() ) {
9178 final PhylogenyNode n42 = PhylogenyNode
9179 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9180 if ( n42.getNodeData().isHasTaxonomy() ) {
9183 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9184 NHXParser.TAXONOMY_EXTRACTION.NO );
9185 if ( n43.getNodeData().isHasTaxonomy() ) {
9188 final PhylogenyNode n44 = PhylogenyNode
9189 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9190 if ( n44.getNodeData().isHasTaxonomy() ) {
9194 catch ( final Exception e ) {
9195 e.printStackTrace( System.out );
9201 private static boolean testNHXParsing() {
9203 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9204 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9205 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9208 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]";
9209 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9210 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9213 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]";
9214 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9215 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9218 final Phylogeny[] p3 = factory
9219 .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]",
9221 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9224 final Phylogeny[] p4 = factory
9225 .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(]",
9227 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9230 final Phylogeny[] p5 = factory
9231 .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(((]",
9233 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9236 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)";
9237 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)";
9238 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9239 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9242 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)))";
9243 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)))";
9244 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9245 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9248 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]) ))[,,, ])))))))";
9249 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9250 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9251 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9254 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9255 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9258 final Phylogeny p10 = factory
9259 .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]",
9260 new NHXParser() )[ 0 ];
9261 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9264 final Phylogeny p11 = factory
9265 .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]",
9266 new NHXParser() )[ 0 ];
9267 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9271 catch ( final Exception e ) {
9272 e.printStackTrace( System.out );
9278 private static boolean testNHXParsingMB() {
9280 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9281 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9282 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9283 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9284 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9285 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9286 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9287 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9288 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9289 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9290 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9293 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9296 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9297 0.1100000000000000e+00 ) ) {
9300 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9303 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9306 final Phylogeny p2 = factory
9307 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9308 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9309 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9310 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9311 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9312 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9313 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9314 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9315 + "7.369400000000000e-02}])",
9316 new NHXParser() )[ 0 ];
9317 if ( p2.getNode( "1" ) == null ) {
9320 if ( p2.getNode( "2" ) == null ) {
9324 catch ( final Exception e ) {
9325 e.printStackTrace( System.out );
9332 private static boolean testNHXParsingQuotes() {
9334 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9335 final NHXParser p = new NHXParser();
9336 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9337 if ( phylogenies_0.length != 5 ) {
9340 final Phylogeny phy = phylogenies_0[ 4 ];
9341 if ( phy.getNumberOfExternalNodes() != 7 ) {
9344 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9347 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9350 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9351 .getScientificName().equals( "hsapiens" ) ) {
9354 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9357 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9360 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9363 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9366 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9369 final NHXParser p1p = new NHXParser();
9370 p1p.setIgnoreQuotes( true );
9371 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9372 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9375 final NHXParser p2p = new NHXParser();
9376 p1p.setIgnoreQuotes( false );
9377 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9378 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9381 final NHXParser p3p = new NHXParser();
9382 p3p.setIgnoreQuotes( false );
9383 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9384 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9387 final NHXParser p4p = new NHXParser();
9388 p4p.setIgnoreQuotes( false );
9389 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9390 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9393 final Phylogeny p10 = factory
9394 .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]",
9395 new NHXParser() )[ 0 ];
9396 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]";
9397 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9400 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9401 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9404 final Phylogeny p12 = factory
9405 .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]",
9406 new NHXParser() )[ 0 ];
9407 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]";
9408 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9411 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9412 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9415 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;";
9416 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9419 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9420 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9424 catch ( final Exception e ) {
9425 e.printStackTrace( System.out );
9431 private static boolean testNodeRemoval() {
9433 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9434 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9435 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9436 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9439 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9440 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9441 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9444 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9445 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9446 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9450 catch ( final Exception e ) {
9451 e.printStackTrace( System.out );
9457 private static boolean testPhylogenyBranch() {
9459 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9460 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9461 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9462 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9463 if ( !a1b1.equals( a1b1 ) ) {
9466 if ( !a1b1.equals( b1a1 ) ) {
9469 if ( !b1a1.equals( a1b1 ) ) {
9472 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9473 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9474 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9475 if ( a1_b1.equals( b1_a1 ) ) {
9478 if ( a1_b1.equals( a1_b1_ ) ) {
9481 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9482 if ( !a1_b1.equals( b1_a1_ ) ) {
9485 if ( a1_b1_.equals( b1_a1_ ) ) {
9488 if ( !a1_b1_.equals( b1_a1 ) ) {
9492 catch ( final Exception e ) {
9493 e.printStackTrace( System.out );
9499 private static boolean testPhyloXMLparsingOfDistributionElement() {
9501 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9502 PhyloXmlParser xml_parser = null;
9504 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9506 catch ( final Exception e ) {
9507 // Do nothing -- means were not running from jar.
9509 if ( xml_parser == null ) {
9510 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9511 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9512 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9515 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9518 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9520 if ( xml_parser.getErrorCount() > 0 ) {
9521 System.out.println( xml_parser.getErrorMessages().toString() );
9524 if ( phylogenies_0.length != 1 ) {
9527 final Phylogeny t1 = phylogenies_0[ 0 ];
9528 PhylogenyNode n = null;
9529 Distribution d = null;
9530 n = t1.getNode( "root node" );
9531 if ( !n.getNodeData().isHasDistribution() ) {
9534 if ( n.getNodeData().getDistributions().size() != 1 ) {
9537 d = n.getNodeData().getDistribution();
9538 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9541 if ( d.getPoints().size() != 1 ) {
9544 if ( d.getPolygons() != null ) {
9547 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9550 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9553 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9556 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9559 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9562 n = t1.getNode( "node a" );
9563 if ( !n.getNodeData().isHasDistribution() ) {
9566 if ( n.getNodeData().getDistributions().size() != 2 ) {
9569 d = n.getNodeData().getDistribution( 1 );
9570 if ( !d.getDesc().equals( "San Diego" ) ) {
9573 if ( d.getPoints().size() != 1 ) {
9576 if ( d.getPolygons() != null ) {
9579 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9582 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9585 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9588 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9591 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9594 n = t1.getNode( "node bb" );
9595 if ( !n.getNodeData().isHasDistribution() ) {
9598 if ( n.getNodeData().getDistributions().size() != 1 ) {
9601 d = n.getNodeData().getDistribution( 0 );
9602 if ( d.getPoints().size() != 3 ) {
9605 if ( d.getPolygons().size() != 2 ) {
9608 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9611 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9614 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9617 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9620 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9623 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9626 Polygon p = d.getPolygons().get( 0 );
9627 if ( p.getPoints().size() != 3 ) {
9630 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9633 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9636 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9639 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9642 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9645 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9648 p = d.getPolygons().get( 1 );
9649 if ( p.getPoints().size() != 3 ) {
9652 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9655 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9658 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9662 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9663 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9664 if ( rt.length != 1 ) {
9667 final Phylogeny t1_rt = rt[ 0 ];
9668 n = t1_rt.getNode( "root node" );
9669 if ( !n.getNodeData().isHasDistribution() ) {
9672 if ( n.getNodeData().getDistributions().size() != 1 ) {
9675 d = n.getNodeData().getDistribution();
9676 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9679 if ( d.getPoints().size() != 1 ) {
9682 if ( d.getPolygons() != null ) {
9685 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9688 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9691 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9694 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9697 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9700 n = t1_rt.getNode( "node a" );
9701 if ( !n.getNodeData().isHasDistribution() ) {
9704 if ( n.getNodeData().getDistributions().size() != 2 ) {
9707 d = n.getNodeData().getDistribution( 1 );
9708 if ( !d.getDesc().equals( "San Diego" ) ) {
9711 if ( d.getPoints().size() != 1 ) {
9714 if ( d.getPolygons() != null ) {
9717 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9720 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9723 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9726 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9729 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9732 n = t1_rt.getNode( "node bb" );
9733 if ( !n.getNodeData().isHasDistribution() ) {
9736 if ( n.getNodeData().getDistributions().size() != 1 ) {
9739 d = n.getNodeData().getDistribution( 0 );
9740 if ( d.getPoints().size() != 3 ) {
9743 if ( d.getPolygons().size() != 2 ) {
9746 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9749 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9752 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9755 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9758 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9761 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9764 p = d.getPolygons().get( 0 );
9765 if ( p.getPoints().size() != 3 ) {
9768 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9771 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9774 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9777 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9780 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9783 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9786 p = d.getPolygons().get( 1 );
9787 if ( p.getPoints().size() != 3 ) {
9790 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9793 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9796 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9800 catch ( final Exception e ) {
9801 e.printStackTrace( System.out );
9807 private static boolean testPostOrderIterator() {
9809 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9810 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9811 PhylogenyNodeIterator it0;
9812 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9815 for( it0.reset(); it0.hasNext(); ) {
9818 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9819 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9820 if ( !it.next().getName().equals( "A" ) ) {
9823 if ( !it.next().getName().equals( "B" ) ) {
9826 if ( !it.next().getName().equals( "ab" ) ) {
9829 if ( !it.next().getName().equals( "C" ) ) {
9832 if ( !it.next().getName().equals( "D" ) ) {
9835 if ( !it.next().getName().equals( "cd" ) ) {
9838 if ( !it.next().getName().equals( "abcd" ) ) {
9841 if ( !it.next().getName().equals( "E" ) ) {
9844 if ( !it.next().getName().equals( "F" ) ) {
9847 if ( !it.next().getName().equals( "ef" ) ) {
9850 if ( !it.next().getName().equals( "G" ) ) {
9853 if ( !it.next().getName().equals( "H" ) ) {
9856 if ( !it.next().getName().equals( "gh" ) ) {
9859 if ( !it.next().getName().equals( "efgh" ) ) {
9862 if ( !it.next().getName().equals( "r" ) ) {
9865 if ( it.hasNext() ) {
9869 catch ( final Exception e ) {
9870 e.printStackTrace( System.out );
9876 private static boolean testPreOrderIterator() {
9878 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9879 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9880 PhylogenyNodeIterator it0;
9881 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9884 for( it0.reset(); it0.hasNext(); ) {
9887 PhylogenyNodeIterator it = t0.iteratorPreorder();
9888 if ( !it.next().getName().equals( "r" ) ) {
9891 if ( !it.next().getName().equals( "ab" ) ) {
9894 if ( !it.next().getName().equals( "A" ) ) {
9897 if ( !it.next().getName().equals( "B" ) ) {
9900 if ( !it.next().getName().equals( "cd" ) ) {
9903 if ( !it.next().getName().equals( "C" ) ) {
9906 if ( !it.next().getName().equals( "D" ) ) {
9909 if ( it.hasNext() ) {
9912 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9913 it = t1.iteratorPreorder();
9914 if ( !it.next().getName().equals( "r" ) ) {
9917 if ( !it.next().getName().equals( "abcd" ) ) {
9920 if ( !it.next().getName().equals( "ab" ) ) {
9923 if ( !it.next().getName().equals( "A" ) ) {
9926 if ( !it.next().getName().equals( "B" ) ) {
9929 if ( !it.next().getName().equals( "cd" ) ) {
9932 if ( !it.next().getName().equals( "C" ) ) {
9935 if ( !it.next().getName().equals( "D" ) ) {
9938 if ( !it.next().getName().equals( "efgh" ) ) {
9941 if ( !it.next().getName().equals( "ef" ) ) {
9944 if ( !it.next().getName().equals( "E" ) ) {
9947 if ( !it.next().getName().equals( "F" ) ) {
9950 if ( !it.next().getName().equals( "gh" ) ) {
9953 if ( !it.next().getName().equals( "G" ) ) {
9956 if ( !it.next().getName().equals( "H" ) ) {
9959 if ( it.hasNext() ) {
9963 catch ( final Exception e ) {
9964 e.printStackTrace( System.out );
9970 private static boolean testPropertiesMap() {
9972 final PropertiesMap pm = new PropertiesMap();
9973 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9974 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9975 final Property p2 = new Property( "something:else",
9977 "improbable:research",
9980 pm.addProperty( p0 );
9981 pm.addProperty( p1 );
9982 pm.addProperty( p2 );
9983 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9986 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9989 if ( pm.getProperties().size() != 3 ) {
9992 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9995 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9998 if ( pm.getProperties().size() != 3 ) {
10001 pm.removeProperty( "dimensions:diameter" );
10002 if ( pm.getProperties().size() != 2 ) {
10005 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10008 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10012 catch ( final Exception e ) {
10013 e.printStackTrace( System.out );
10019 private static boolean testProteinId() {
10021 final ProteinId id1 = new ProteinId( "a" );
10022 final ProteinId id2 = new ProteinId( "a" );
10023 final ProteinId id3 = new ProteinId( "A" );
10024 final ProteinId id4 = new ProteinId( "b" );
10025 if ( !id1.equals( id1 ) ) {
10028 if ( id1.getId().equals( "x" ) ) {
10031 if ( id1.getId().equals( null ) ) {
10034 if ( !id1.equals( id2 ) ) {
10037 if ( id1.equals( id3 ) ) {
10040 if ( id1.hashCode() != id1.hashCode() ) {
10043 if ( id1.hashCode() != id2.hashCode() ) {
10046 if ( id1.hashCode() == id3.hashCode() ) {
10049 if ( id1.compareTo( id1 ) != 0 ) {
10052 if ( id1.compareTo( id2 ) != 0 ) {
10055 if ( id1.compareTo( id3 ) != 0 ) {
10058 if ( id1.compareTo( id4 ) >= 0 ) {
10061 if ( id4.compareTo( id1 ) <= 0 ) {
10064 if ( !id4.getId().equals( "b" ) ) {
10067 final ProteinId id5 = new ProteinId( " C " );
10068 if ( !id5.getId().equals( "C" ) ) {
10071 if ( id5.equals( id1 ) ) {
10075 catch ( final Exception e ) {
10076 e.printStackTrace( System.out );
10082 private static boolean testReIdMethods() {
10084 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10085 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10086 final long count = PhylogenyNode.getNodeCount();
10087 p.levelOrderReID();
10088 if ( p.getNode( "r" ).getId() != count ) {
10091 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10094 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10097 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10100 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10103 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10106 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10109 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10112 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10115 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10118 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10121 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10124 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10127 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10130 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10134 catch ( final Exception e ) {
10135 e.printStackTrace( System.out );
10141 private static boolean testRerooting() {
10143 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10144 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",
10145 new NHXParser() )[ 0 ];
10146 if ( !t1.isRooted() ) {
10149 t1.reRoot( t1.getNode( "D" ) );
10150 t1.reRoot( t1.getNode( "CD" ) );
10151 t1.reRoot( t1.getNode( "A" ) );
10152 t1.reRoot( t1.getNode( "B" ) );
10153 t1.reRoot( t1.getNode( "AB" ) );
10154 t1.reRoot( t1.getNode( "D" ) );
10155 t1.reRoot( t1.getNode( "C" ) );
10156 t1.reRoot( t1.getNode( "CD" ) );
10157 t1.reRoot( t1.getNode( "A" ) );
10158 t1.reRoot( t1.getNode( "B" ) );
10159 t1.reRoot( t1.getNode( "AB" ) );
10160 t1.reRoot( t1.getNode( "D" ) );
10161 t1.reRoot( t1.getNode( "D" ) );
10162 t1.reRoot( t1.getNode( "C" ) );
10163 t1.reRoot( t1.getNode( "A" ) );
10164 t1.reRoot( t1.getNode( "B" ) );
10165 t1.reRoot( t1.getNode( "AB" ) );
10166 t1.reRoot( t1.getNode( "C" ) );
10167 t1.reRoot( t1.getNode( "D" ) );
10168 t1.reRoot( t1.getNode( "CD" ) );
10169 t1.reRoot( t1.getNode( "D" ) );
10170 t1.reRoot( t1.getNode( "A" ) );
10171 t1.reRoot( t1.getNode( "B" ) );
10172 t1.reRoot( t1.getNode( "AB" ) );
10173 t1.reRoot( t1.getNode( "C" ) );
10174 t1.reRoot( t1.getNode( "D" ) );
10175 t1.reRoot( t1.getNode( "CD" ) );
10176 t1.reRoot( t1.getNode( "D" ) );
10177 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10180 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10183 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10186 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10189 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10192 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10195 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",
10196 new NHXParser() )[ 0 ];
10197 t2.reRoot( t2.getNode( "A" ) );
10198 t2.reRoot( t2.getNode( "D" ) );
10199 t2.reRoot( t2.getNode( "ABC" ) );
10200 t2.reRoot( t2.getNode( "A" ) );
10201 t2.reRoot( t2.getNode( "B" ) );
10202 t2.reRoot( t2.getNode( "D" ) );
10203 t2.reRoot( t2.getNode( "C" ) );
10204 t2.reRoot( t2.getNode( "ABC" ) );
10205 t2.reRoot( t2.getNode( "A" ) );
10206 t2.reRoot( t2.getNode( "B" ) );
10207 t2.reRoot( t2.getNode( "AB" ) );
10208 t2.reRoot( t2.getNode( "AB" ) );
10209 t2.reRoot( t2.getNode( "D" ) );
10210 t2.reRoot( t2.getNode( "C" ) );
10211 t2.reRoot( t2.getNode( "B" ) );
10212 t2.reRoot( t2.getNode( "AB" ) );
10213 t2.reRoot( t2.getNode( "D" ) );
10214 t2.reRoot( t2.getNode( "D" ) );
10215 t2.reRoot( t2.getNode( "ABC" ) );
10216 t2.reRoot( t2.getNode( "A" ) );
10217 t2.reRoot( t2.getNode( "B" ) );
10218 t2.reRoot( t2.getNode( "AB" ) );
10219 t2.reRoot( t2.getNode( "D" ) );
10220 t2.reRoot( t2.getNode( "C" ) );
10221 t2.reRoot( t2.getNode( "ABC" ) );
10222 t2.reRoot( t2.getNode( "A" ) );
10223 t2.reRoot( t2.getNode( "B" ) );
10224 t2.reRoot( t2.getNode( "AB" ) );
10225 t2.reRoot( t2.getNode( "D" ) );
10226 t2.reRoot( t2.getNode( "D" ) );
10227 t2.reRoot( t2.getNode( "C" ) );
10228 t2.reRoot( t2.getNode( "A" ) );
10229 t2.reRoot( t2.getNode( "B" ) );
10230 t2.reRoot( t2.getNode( "AB" ) );
10231 t2.reRoot( t2.getNode( "C" ) );
10232 t2.reRoot( t2.getNode( "D" ) );
10233 t2.reRoot( t2.getNode( "ABC" ) );
10234 t2.reRoot( t2.getNode( "D" ) );
10235 t2.reRoot( t2.getNode( "A" ) );
10236 t2.reRoot( t2.getNode( "B" ) );
10237 t2.reRoot( t2.getNode( "AB" ) );
10238 t2.reRoot( t2.getNode( "C" ) );
10239 t2.reRoot( t2.getNode( "D" ) );
10240 t2.reRoot( t2.getNode( "ABC" ) );
10241 t2.reRoot( t2.getNode( "D" ) );
10242 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10245 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10248 t2.reRoot( t2.getNode( "ABC" ) );
10249 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10252 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10255 t2.reRoot( t2.getNode( "AB" ) );
10256 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10259 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10262 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10265 t2.reRoot( t2.getNode( "AB" ) );
10266 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10269 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10272 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10275 t2.reRoot( t2.getNode( "D" ) );
10276 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10279 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10282 t2.reRoot( t2.getNode( "ABC" ) );
10283 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10286 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10289 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10290 new NHXParser() )[ 0 ];
10291 t3.reRoot( t3.getNode( "B" ) );
10292 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10295 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10298 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10301 t3.reRoot( t3.getNode( "B" ) );
10302 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10305 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10308 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10311 t3.reRoot( t3.getRoot() );
10312 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10315 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10318 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10322 catch ( final Exception e ) {
10323 e.printStackTrace( System.out );
10329 private static boolean testSDIse() {
10331 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10332 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10333 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10334 gene1.setRooted( true );
10335 species1.setRooted( true );
10336 final SDI sdi = new SDI( gene1, species1 );
10337 if ( !gene1.getRoot().isDuplication() ) {
10340 final Phylogeny species2 = factory
10341 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10342 new NHXParser() )[ 0 ];
10343 final Phylogeny gene2 = factory
10344 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10345 new NHXParser() )[ 0 ];
10346 species2.setRooted( true );
10347 gene2.setRooted( true );
10348 final SDI sdi2 = new SDI( gene2, species2 );
10349 if ( sdi2.getDuplicationsSum() != 0 ) {
10352 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10355 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10358 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10361 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10364 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10367 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10370 final Phylogeny species3 = factory
10371 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10372 new NHXParser() )[ 0 ];
10373 final Phylogeny gene3 = factory
10374 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10375 new NHXParser() )[ 0 ];
10376 species3.setRooted( true );
10377 gene3.setRooted( true );
10378 final SDI sdi3 = new SDI( gene3, species3 );
10379 if ( sdi3.getDuplicationsSum() != 1 ) {
10382 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10385 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10388 final Phylogeny species4 = factory
10389 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10390 new NHXParser() )[ 0 ];
10391 final Phylogeny gene4 = factory
10392 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10393 new NHXParser() )[ 0 ];
10394 species4.setRooted( true );
10395 gene4.setRooted( true );
10396 final SDI sdi4 = new SDI( gene4, species4 );
10397 if ( sdi4.getDuplicationsSum() != 1 ) {
10400 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10403 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10406 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10409 if ( species4.getNumberOfExternalNodes() != 6 ) {
10412 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10415 final Phylogeny species5 = factory
10416 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10417 new NHXParser() )[ 0 ];
10418 final Phylogeny gene5 = factory
10419 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10420 new NHXParser() )[ 0 ];
10421 species5.setRooted( true );
10422 gene5.setRooted( true );
10423 final SDI sdi5 = new SDI( gene5, species5 );
10424 if ( sdi5.getDuplicationsSum() != 2 ) {
10427 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10430 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10433 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10436 if ( species5.getNumberOfExternalNodes() != 6 ) {
10439 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10442 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10443 // Conjecture for Comparing Molecular Phylogenies"
10444 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10445 final Phylogeny species6 = factory
10446 .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,"
10447 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10448 new NHXParser() )[ 0 ];
10449 final Phylogeny gene6 = factory
10450 .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,"
10451 + "((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,"
10452 + "(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;",
10453 new NHXParser() )[ 0 ];
10454 species6.setRooted( true );
10455 gene6.setRooted( true );
10456 final SDI sdi6 = new SDI( gene6, species6 );
10457 if ( sdi6.getDuplicationsSum() != 3 ) {
10460 if ( !gene6.getNode( "r" ).isDuplication() ) {
10463 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10466 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10469 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10472 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10475 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10478 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10481 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10484 sdi6.computeMappingCostL();
10485 if ( sdi6.computeMappingCostL() != 17 ) {
10488 if ( species6.getNumberOfExternalNodes() != 9 ) {
10491 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10494 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10495 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10496 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10497 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10498 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10499 species7.setRooted( true );
10500 final Phylogeny gene7_1 = Test
10501 .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])" );
10502 gene7_1.setRooted( true );
10503 final SDI sdi7 = new SDI( gene7_1, species7 );
10504 if ( sdi7.getDuplicationsSum() != 0 ) {
10507 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10510 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10513 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10516 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10519 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10522 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10525 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10528 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10531 final Phylogeny gene7_2 = Test
10532 .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])" );
10533 gene7_2.setRooted( true );
10534 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10535 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10538 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10541 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10544 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10547 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10550 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10553 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10556 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10559 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10562 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10566 catch ( final Exception e ) {
10572 private static boolean testSDIunrooted() {
10574 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10575 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10576 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10577 final Iterator<PhylogenyBranch> iter = l.iterator();
10578 PhylogenyBranch br = iter.next();
10579 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10582 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10586 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10589 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10593 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10596 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10600 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10603 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10607 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10610 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10614 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10617 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10621 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10624 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10628 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10631 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10635 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10638 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10642 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10645 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10649 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10652 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10656 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10659 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10663 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10666 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10670 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10673 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10677 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10680 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10683 if ( iter.hasNext() ) {
10686 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10687 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10688 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10690 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10693 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10697 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10700 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10704 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10707 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10710 if ( iter1.hasNext() ) {
10713 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10714 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10715 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10717 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10720 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10724 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10727 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10731 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10734 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10737 if ( iter2.hasNext() ) {
10740 final Phylogeny species0 = factory
10741 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10742 new NHXParser() )[ 0 ];
10743 final Phylogeny gene1 = factory
10744 .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])",
10745 new NHXParser() )[ 0 ];
10746 species0.setRooted( true );
10747 gene1.setRooted( true );
10748 final SDIR sdi_unrooted = new SDIR();
10749 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10750 if ( sdi_unrooted.getCount() != 1 ) {
10753 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10756 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10759 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10762 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10765 final Phylogeny gene2 = factory
10766 .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])",
10767 new NHXParser() )[ 0 ];
10768 gene2.setRooted( true );
10769 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10770 if ( sdi_unrooted.getCount() != 1 ) {
10773 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10776 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10779 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10782 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10785 final Phylogeny species6 = factory
10786 .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,"
10787 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10788 new NHXParser() )[ 0 ];
10789 final Phylogeny gene6 = factory
10790 .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],"
10791 + "(((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],"
10792 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10793 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10794 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10795 new NHXParser() )[ 0 ];
10796 species6.setRooted( true );
10797 gene6.setRooted( true );
10798 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10799 if ( sdi_unrooted.getCount() != 1 ) {
10802 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10805 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10808 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10811 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10814 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10817 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10820 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10823 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10826 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10829 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10832 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10835 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10839 final Phylogeny species7 = factory
10840 .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,"
10841 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10842 new NHXParser() )[ 0 ];
10843 final Phylogeny gene7 = factory
10844 .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],"
10845 + "(((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],"
10846 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10847 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10848 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10849 new NHXParser() )[ 0 ];
10850 species7.setRooted( true );
10851 gene7.setRooted( true );
10852 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10853 if ( sdi_unrooted.getCount() != 1 ) {
10856 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10859 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10862 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10865 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10868 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10871 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10874 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10877 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10880 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10883 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10886 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10889 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10893 final Phylogeny species8 = factory
10894 .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,"
10895 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10896 new NHXParser() )[ 0 ];
10897 final Phylogeny gene8 = factory
10898 .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],"
10899 + "(((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],"
10900 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10901 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10902 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10903 new NHXParser() )[ 0 ];
10904 species8.setRooted( true );
10905 gene8.setRooted( true );
10906 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10907 if ( sdi_unrooted.getCount() != 1 ) {
10910 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10913 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10916 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10919 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10922 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10925 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10928 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10931 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10934 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10937 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10940 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10943 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10948 catch ( final Exception e ) {
10949 e.printStackTrace( System.out );
10955 private static boolean testSequenceDbWsTools1() {
10957 final PhylogenyNode n = new PhylogenyNode();
10958 n.setName( "NP_001025424" );
10959 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10960 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10961 || !acc.getValue().equals( "NP_001025424" ) ) {
10964 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10965 acc = SequenceDbWsTools.obtainSeqAccession( n );
10966 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10967 || !acc.getValue().equals( "NP_001025424" ) ) {
10970 n.setName( "NP_001025424.1" );
10971 acc = SequenceDbWsTools.obtainSeqAccession( n );
10972 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10973 || !acc.getValue().equals( "NP_001025424" ) ) {
10976 n.setName( "NM_001030253" );
10977 acc = SequenceDbWsTools.obtainSeqAccession( n );
10978 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10979 || !acc.getValue().equals( "NM_001030253" ) ) {
10982 n.setName( "BCL2_HUMAN" );
10983 acc = SequenceDbWsTools.obtainSeqAccession( n );
10984 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10985 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10986 System.out.println( acc.toString() );
10989 n.setName( "P10415" );
10990 acc = SequenceDbWsTools.obtainSeqAccession( n );
10991 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10992 || !acc.getValue().equals( "P10415" ) ) {
10993 System.out.println( acc.toString() );
10996 n.setName( " P10415 " );
10997 acc = SequenceDbWsTools.obtainSeqAccession( n );
10998 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10999 || !acc.getValue().equals( "P10415" ) ) {
11000 System.out.println( acc.toString() );
11003 n.setName( "_P10415|" );
11004 acc = SequenceDbWsTools.obtainSeqAccession( n );
11005 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11006 || !acc.getValue().equals( "P10415" ) ) {
11007 System.out.println( acc.toString() );
11010 n.setName( "AY695820" );
11011 acc = SequenceDbWsTools.obtainSeqAccession( n );
11012 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11013 || !acc.getValue().equals( "AY695820" ) ) {
11014 System.out.println( acc.toString() );
11017 n.setName( "_AY695820_" );
11018 acc = SequenceDbWsTools.obtainSeqAccession( n );
11019 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11020 || !acc.getValue().equals( "AY695820" ) ) {
11021 System.out.println( acc.toString() );
11024 n.setName( "AAA59452" );
11025 acc = SequenceDbWsTools.obtainSeqAccession( n );
11026 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11027 || !acc.getValue().equals( "AAA59452" ) ) {
11028 System.out.println( acc.toString() );
11031 n.setName( "_AAA59452_" );
11032 acc = SequenceDbWsTools.obtainSeqAccession( n );
11033 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11034 || !acc.getValue().equals( "AAA59452" ) ) {
11035 System.out.println( acc.toString() );
11038 n.setName( "AAA59452.1" );
11039 acc = SequenceDbWsTools.obtainSeqAccession( n );
11040 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11041 || !acc.getValue().equals( "AAA59452.1" ) ) {
11042 System.out.println( acc.toString() );
11045 n.setName( "_AAA59452.1_" );
11046 acc = SequenceDbWsTools.obtainSeqAccession( n );
11047 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11048 || !acc.getValue().equals( "AAA59452.1" ) ) {
11049 System.out.println( acc.toString() );
11052 n.setName( "GI:94894583" );
11053 acc = SequenceDbWsTools.obtainSeqAccession( n );
11054 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11055 || !acc.getValue().equals( "94894583" ) ) {
11056 System.out.println( acc.toString() );
11059 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11060 acc = SequenceDbWsTools.obtainSeqAccession( n );
11061 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11062 || !acc.getValue().equals( "71845847" ) ) {
11063 System.out.println( acc.toString() );
11066 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11067 acc = SequenceDbWsTools.obtainSeqAccession( n );
11068 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11069 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11070 System.out.println( acc.toString() );
11074 catch ( final Exception e ) {
11080 private static boolean testSequenceDbWsTools2() {
11082 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11083 SequenceDbWsTools.obtainSeqInformation( n1 );
11084 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11087 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11090 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11093 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11096 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11097 SequenceDbWsTools.obtainSeqInformation( n2 );
11098 if ( !n2.getNodeData().getSequence().getName()
11099 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11102 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11105 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11108 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11111 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11112 SequenceDbWsTools.obtainSeqInformation( n3 );
11113 if ( !n3.getNodeData().getSequence().getName()
11114 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11117 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11120 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11123 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11127 catch ( final IOException e ) {
11128 System.out.println();
11129 System.out.println( "the following might be due to absence internet connection:" );
11130 e.printStackTrace( System.out );
11133 catch ( final Exception e ) {
11134 e.printStackTrace();
11140 private static boolean testSequenceIdParsing() {
11142 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11143 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11144 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11145 if ( id != null ) {
11146 System.out.println( "value =" + id.getValue() );
11147 System.out.println( "provider=" + id.getSource() );
11152 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11153 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11154 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11155 if ( id != null ) {
11156 System.out.println( "value =" + id.getValue() );
11157 System.out.println( "provider=" + id.getSource() );
11162 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11163 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11164 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11165 if ( id != null ) {
11166 System.out.println( "value =" + id.getValue() );
11167 System.out.println( "provider=" + id.getSource() );
11172 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11173 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11174 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11175 if ( id != null ) {
11176 System.out.println( "value =" + id.getValue() );
11177 System.out.println( "provider=" + id.getSource() );
11182 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11183 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11184 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11185 if ( id != null ) {
11186 System.out.println( "value =" + id.getValue() );
11187 System.out.println( "provider=" + id.getSource() );
11192 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11193 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11194 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11195 if ( id != null ) {
11196 System.out.println( "value =" + id.getValue() );
11197 System.out.println( "provider=" + id.getSource() );
11202 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11203 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11204 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11205 if ( id != null ) {
11206 System.out.println( "value =" + id.getValue() );
11207 System.out.println( "provider=" + id.getSource() );
11212 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11213 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11214 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11215 if ( id != null ) {
11216 System.out.println( "value =" + id.getValue() );
11217 System.out.println( "provider=" + id.getSource() );
11222 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11223 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11224 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11225 if ( id != null ) {
11226 System.out.println( "value =" + id.getValue() );
11227 System.out.println( "provider=" + id.getSource() );
11232 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11233 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11234 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11235 if ( id != null ) {
11236 System.out.println( "value =" + id.getValue() );
11237 System.out.println( "provider=" + id.getSource() );
11241 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11242 if ( id != null ) {
11243 System.out.println( "value =" + id.getValue() );
11244 System.out.println( "provider=" + id.getSource() );
11248 catch ( final Exception e ) {
11249 e.printStackTrace( System.out );
11255 private static boolean testSequenceWriter() {
11257 final String n = ForesterUtil.LINE_SEPARATOR;
11258 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11261 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11264 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11267 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11270 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11271 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11274 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11275 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11279 catch ( final Exception e ) {
11280 e.printStackTrace();
11286 private static boolean testSpecies() {
11288 final Species s1 = new BasicSpecies( "a" );
11289 final Species s2 = new BasicSpecies( "a" );
11290 final Species s3 = new BasicSpecies( "A" );
11291 final Species s4 = new BasicSpecies( "b" );
11292 if ( !s1.equals( s1 ) ) {
11295 if ( s1.getSpeciesId().equals( "x" ) ) {
11298 if ( s1.getSpeciesId().equals( null ) ) {
11301 if ( !s1.equals( s2 ) ) {
11304 if ( s1.equals( s3 ) ) {
11307 if ( s1.hashCode() != s1.hashCode() ) {
11310 if ( s1.hashCode() != s2.hashCode() ) {
11313 if ( s1.hashCode() == s3.hashCode() ) {
11316 if ( s1.compareTo( s1 ) != 0 ) {
11319 if ( s1.compareTo( s2 ) != 0 ) {
11322 if ( s1.compareTo( s3 ) != 0 ) {
11325 if ( s1.compareTo( s4 ) >= 0 ) {
11328 if ( s4.compareTo( s1 ) <= 0 ) {
11331 if ( !s4.getSpeciesId().equals( "b" ) ) {
11334 final Species s5 = new BasicSpecies( " C " );
11335 if ( !s5.getSpeciesId().equals( "C" ) ) {
11338 if ( s5.equals( s1 ) ) {
11342 catch ( final Exception e ) {
11343 e.printStackTrace( System.out );
11349 private static boolean testSplit() {
11351 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11352 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11353 //Archaeopteryx.createApplication( p0 );
11354 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11355 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11356 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11357 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11358 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11359 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11360 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11361 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11362 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11363 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11364 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11365 // System.out.println( s0.toString() );
11367 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11370 if ( s0.match( query_nodes ) ) {
11373 query_nodes = new HashSet<PhylogenyNode>();
11374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11378 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11381 if ( !s0.match( query_nodes ) ) {
11385 query_nodes = new HashSet<PhylogenyNode>();
11386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11387 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11389 if ( !s0.match( query_nodes ) ) {
11393 query_nodes = new HashSet<PhylogenyNode>();
11394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11398 if ( !s0.match( query_nodes ) ) {
11402 query_nodes = new HashSet<PhylogenyNode>();
11403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11405 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11406 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11407 if ( !s0.match( query_nodes ) ) {
11411 query_nodes = new HashSet<PhylogenyNode>();
11412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11415 if ( !s0.match( query_nodes ) ) {
11419 query_nodes = new HashSet<PhylogenyNode>();
11420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11422 if ( !s0.match( query_nodes ) ) {
11426 query_nodes = new HashSet<PhylogenyNode>();
11427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11430 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11431 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11432 if ( !s0.match( query_nodes ) ) {
11436 query_nodes = new HashSet<PhylogenyNode>();
11437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11438 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11439 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11440 if ( !s0.match( query_nodes ) ) {
11444 query_nodes = new HashSet<PhylogenyNode>();
11445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11446 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11447 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11448 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11449 if ( !s0.match( query_nodes ) ) {
11453 query_nodes = new HashSet<PhylogenyNode>();
11454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11455 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11456 if ( s0.match( query_nodes ) ) {
11460 query_nodes = new HashSet<PhylogenyNode>();
11461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11463 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11465 if ( s0.match( query_nodes ) ) {
11469 query_nodes = new HashSet<PhylogenyNode>();
11470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11475 if ( s0.match( query_nodes ) ) {
11479 query_nodes = new HashSet<PhylogenyNode>();
11480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11482 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11483 if ( s0.match( query_nodes ) ) {
11487 query_nodes = new HashSet<PhylogenyNode>();
11488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11490 if ( s0.match( query_nodes ) ) {
11494 query_nodes = new HashSet<PhylogenyNode>();
11495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11497 if ( s0.match( query_nodes ) ) {
11501 query_nodes = new HashSet<PhylogenyNode>();
11502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11504 if ( s0.match( query_nodes ) ) {
11508 query_nodes = new HashSet<PhylogenyNode>();
11509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11511 if ( s0.match( query_nodes ) ) {
11515 query_nodes = new HashSet<PhylogenyNode>();
11516 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11517 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11518 if ( s0.match( query_nodes ) ) {
11522 query_nodes = new HashSet<PhylogenyNode>();
11523 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11525 if ( s0.match( query_nodes ) ) {
11529 query_nodes = new HashSet<PhylogenyNode>();
11530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11531 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11533 if ( s0.match( query_nodes ) ) {
11537 query_nodes = new HashSet<PhylogenyNode>();
11538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11539 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11540 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11541 if ( s0.match( query_nodes ) ) {
11545 query_nodes = new HashSet<PhylogenyNode>();
11546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11548 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11549 if ( s0.match( query_nodes ) ) {
11553 query_nodes = new HashSet<PhylogenyNode>();
11554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11558 if ( s0.match( query_nodes ) ) {
11562 // query_nodes = new HashSet<PhylogenyNode>();
11563 // query_nodes.add( new PhylogenyNode( "X" ) );
11564 // query_nodes.add( new PhylogenyNode( "Y" ) );
11565 // query_nodes.add( new PhylogenyNode( "A" ) );
11566 // query_nodes.add( new PhylogenyNode( "B" ) );
11567 // query_nodes.add( new PhylogenyNode( "C" ) );
11568 // query_nodes.add( new PhylogenyNode( "D" ) );
11569 // query_nodes.add( new PhylogenyNode( "E" ) );
11570 // query_nodes.add( new PhylogenyNode( "F" ) );
11571 // query_nodes.add( new PhylogenyNode( "G" ) );
11572 // if ( !s0.match( query_nodes ) ) {
11575 // query_nodes = new HashSet<PhylogenyNode>();
11576 // query_nodes.add( new PhylogenyNode( "X" ) );
11577 // query_nodes.add( new PhylogenyNode( "Y" ) );
11578 // query_nodes.add( new PhylogenyNode( "A" ) );
11579 // query_nodes.add( new PhylogenyNode( "B" ) );
11580 // query_nodes.add( new PhylogenyNode( "C" ) );
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( "D" ) );
11589 // query_nodes.add( new PhylogenyNode( "E" ) );
11590 // query_nodes.add( new PhylogenyNode( "F" ) );
11591 // query_nodes.add( new PhylogenyNode( "G" ) );
11592 // if ( !s0.match( query_nodes ) ) {
11596 // query_nodes = new HashSet<PhylogenyNode>();
11597 // query_nodes.add( new PhylogenyNode( "X" ) );
11598 // query_nodes.add( new PhylogenyNode( "Y" ) );
11599 // query_nodes.add( new PhylogenyNode( "A" ) );
11600 // query_nodes.add( new PhylogenyNode( "B" ) );
11601 // query_nodes.add( new PhylogenyNode( "C" ) );
11602 // query_nodes.add( new PhylogenyNode( "D" ) );
11603 // if ( !s0.match( query_nodes ) ) {
11607 // query_nodes = new HashSet<PhylogenyNode>();
11608 // query_nodes.add( new PhylogenyNode( "X" ) );
11609 // query_nodes.add( new PhylogenyNode( "Y" ) );
11610 // query_nodes.add( new PhylogenyNode( "E" ) );
11611 // query_nodes.add( new PhylogenyNode( "F" ) );
11612 // query_nodes.add( new PhylogenyNode( "G" ) );
11613 // if ( !s0.match( query_nodes ) ) {
11617 // query_nodes = new HashSet<PhylogenyNode>();
11618 // query_nodes.add( new PhylogenyNode( "X" ) );
11619 // query_nodes.add( new PhylogenyNode( "Y" ) );
11620 // query_nodes.add( new PhylogenyNode( "F" ) );
11621 // query_nodes.add( new PhylogenyNode( "G" ) );
11622 // if ( !s0.match( query_nodes ) ) {
11626 query_nodes = new HashSet<PhylogenyNode>();
11627 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11631 if ( s0.match( query_nodes ) ) {
11635 query_nodes = new HashSet<PhylogenyNode>();
11636 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11640 if ( s0.match( query_nodes ) ) {
11643 ///////////////////////////
11645 query_nodes = new HashSet<PhylogenyNode>();
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11650 if ( s0.match( query_nodes ) ) {
11654 query_nodes = new HashSet<PhylogenyNode>();
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11659 if ( s0.match( query_nodes ) ) {
11663 query_nodes = new HashSet<PhylogenyNode>();
11664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11668 if ( s0.match( query_nodes ) ) {
11672 query_nodes = new HashSet<PhylogenyNode>();
11673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11677 if ( s0.match( query_nodes ) ) {
11681 query_nodes = new HashSet<PhylogenyNode>();
11682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11686 if ( s0.match( query_nodes ) ) {
11690 query_nodes = new HashSet<PhylogenyNode>();
11691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11692 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11694 if ( s0.match( query_nodes ) ) {
11698 query_nodes = new HashSet<PhylogenyNode>();
11699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11703 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11704 if ( s0.match( query_nodes ) ) {
11708 query_nodes = new HashSet<PhylogenyNode>();
11709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11713 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11714 if ( s0.match( query_nodes ) ) {
11718 query_nodes = new HashSet<PhylogenyNode>();
11719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11724 if ( s0.match( query_nodes ) ) {
11728 query_nodes = new HashSet<PhylogenyNode>();
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11733 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11734 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11735 if ( s0.match( query_nodes ) ) {
11739 catch ( final Exception e ) {
11740 e.printStackTrace();
11746 private static boolean testSplitStrict() {
11748 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11749 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11750 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11751 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11752 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11753 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11754 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11755 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11756 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11757 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11758 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11759 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11761 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11762 if ( s0.match( query_nodes ) ) {
11765 query_nodes = new HashSet<PhylogenyNode>();
11766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11769 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11770 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11773 if ( !s0.match( query_nodes ) ) {
11777 query_nodes = new HashSet<PhylogenyNode>();
11778 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11779 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11781 if ( !s0.match( query_nodes ) ) {
11785 query_nodes = new HashSet<PhylogenyNode>();
11786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11790 if ( !s0.match( query_nodes ) ) {
11794 query_nodes = new HashSet<PhylogenyNode>();
11795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11799 if ( !s0.match( query_nodes ) ) {
11803 query_nodes = new HashSet<PhylogenyNode>();
11804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11807 if ( !s0.match( query_nodes ) ) {
11811 query_nodes = new HashSet<PhylogenyNode>();
11812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11814 if ( !s0.match( query_nodes ) ) {
11818 query_nodes = new HashSet<PhylogenyNode>();
11819 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11824 if ( !s0.match( query_nodes ) ) {
11828 query_nodes = new HashSet<PhylogenyNode>();
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11832 if ( !s0.match( query_nodes ) ) {
11836 query_nodes = new HashSet<PhylogenyNode>();
11837 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11841 if ( !s0.match( query_nodes ) ) {
11845 query_nodes = new HashSet<PhylogenyNode>();
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11848 if ( s0.match( query_nodes ) ) {
11852 query_nodes = new HashSet<PhylogenyNode>();
11853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11855 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11857 if ( s0.match( query_nodes ) ) {
11861 query_nodes = new HashSet<PhylogenyNode>();
11862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11867 if ( s0.match( query_nodes ) ) {
11871 query_nodes = new HashSet<PhylogenyNode>();
11872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11875 if ( s0.match( query_nodes ) ) {
11879 query_nodes = new HashSet<PhylogenyNode>();
11880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11882 if ( s0.match( query_nodes ) ) {
11886 query_nodes = new HashSet<PhylogenyNode>();
11887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11889 if ( s0.match( query_nodes ) ) {
11893 query_nodes = new HashSet<PhylogenyNode>();
11894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11896 if ( s0.match( query_nodes ) ) {
11900 query_nodes = new HashSet<PhylogenyNode>();
11901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11903 if ( s0.match( query_nodes ) ) {
11907 query_nodes = new HashSet<PhylogenyNode>();
11908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11910 if ( s0.match( query_nodes ) ) {
11914 query_nodes = new HashSet<PhylogenyNode>();
11915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11917 if ( s0.match( query_nodes ) ) {
11921 query_nodes = new HashSet<PhylogenyNode>();
11922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11925 if ( s0.match( query_nodes ) ) {
11929 query_nodes = new HashSet<PhylogenyNode>();
11930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11933 if ( s0.match( query_nodes ) ) {
11937 query_nodes = new HashSet<PhylogenyNode>();
11938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11941 if ( s0.match( query_nodes ) ) {
11945 query_nodes = new HashSet<PhylogenyNode>();
11946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11950 if ( s0.match( query_nodes ) ) {
11954 catch ( final Exception e ) {
11955 e.printStackTrace();
11961 private static boolean testSubtreeDeletion() {
11963 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11964 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11965 t1.deleteSubtree( t1.getNode( "A" ), false );
11966 if ( t1.getNumberOfExternalNodes() != 5 ) {
11969 t1.toNewHampshireX();
11970 t1.deleteSubtree( t1.getNode( "E" ), false );
11971 if ( t1.getNumberOfExternalNodes() != 4 ) {
11974 t1.toNewHampshireX();
11975 t1.deleteSubtree( t1.getNode( "F" ), false );
11976 if ( t1.getNumberOfExternalNodes() != 3 ) {
11979 t1.toNewHampshireX();
11980 t1.deleteSubtree( t1.getNode( "D" ), false );
11981 t1.toNewHampshireX();
11982 if ( t1.getNumberOfExternalNodes() != 3 ) {
11985 t1.deleteSubtree( t1.getNode( "def" ), false );
11986 t1.toNewHampshireX();
11987 if ( t1.getNumberOfExternalNodes() != 2 ) {
11990 t1.deleteSubtree( t1.getNode( "B" ), false );
11991 t1.toNewHampshireX();
11992 if ( t1.getNumberOfExternalNodes() != 1 ) {
11995 t1.deleteSubtree( t1.getNode( "C" ), false );
11996 t1.toNewHampshireX();
11997 if ( t1.getNumberOfExternalNodes() != 1 ) {
12000 t1.deleteSubtree( t1.getNode( "abc" ), false );
12001 t1.toNewHampshireX();
12002 if ( t1.getNumberOfExternalNodes() != 1 ) {
12005 t1.deleteSubtree( t1.getNode( "r" ), false );
12006 if ( t1.getNumberOfExternalNodes() != 0 ) {
12009 if ( !t1.isEmpty() ) {
12012 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12013 t2.deleteSubtree( t2.getNode( "A" ), false );
12014 t2.toNewHampshireX();
12015 if ( t2.getNumberOfExternalNodes() != 5 ) {
12018 t2.deleteSubtree( t2.getNode( "abc" ), false );
12019 t2.toNewHampshireX();
12020 if ( t2.getNumberOfExternalNodes() != 3 ) {
12023 t2.deleteSubtree( t2.getNode( "def" ), false );
12024 t2.toNewHampshireX();
12025 if ( t2.getNumberOfExternalNodes() != 1 ) {
12029 catch ( final Exception e ) {
12030 e.printStackTrace( System.out );
12036 private static boolean testSupportCount() {
12038 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12039 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12040 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12041 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12042 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12043 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12044 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12046 SupportCount.count( t0_1, phylogenies_1, true, false );
12047 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12048 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12049 + "(((((A,B),C),D),E),((F,G),X))"
12050 + "(((((A,Y),B),C),D),((F,G),E))"
12051 + "(((((A,B),C),D),E),(F,G))"
12052 + "(((((A,B),C),D),E),(F,G))"
12053 + "(((((A,B),C),D),E),(F,G))"
12054 + "(((((A,B),C),D),E),(F,G),Z)"
12055 + "(((((A,B),C),D),E),(F,G))"
12056 + "((((((A,B),C),D),E),F),G)"
12057 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12059 SupportCount.count( t0_2, phylogenies_2, true, false );
12060 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12061 while ( it.hasNext() ) {
12062 final PhylogenyNode n = it.next();
12063 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12067 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12068 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12069 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12070 SupportCount.count( t0_3, phylogenies_3, true, false );
12071 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12072 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12075 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12078 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12081 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12084 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12087 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12090 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12093 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12096 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12099 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12102 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12103 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12104 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12105 SupportCount.count( t0_4, phylogenies_4, true, false );
12106 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12107 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12110 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12113 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12116 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12119 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12122 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12125 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12128 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12131 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12134 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12137 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12138 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12139 double d = SupportCount.compare( b1, a, true, true, true );
12140 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12143 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12144 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12145 d = SupportCount.compare( b2, a, true, true, true );
12146 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12149 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12150 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12151 d = SupportCount.compare( b3, a, true, true, true );
12152 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12155 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12156 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12157 d = SupportCount.compare( b4, a, true, true, false );
12158 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12162 catch ( final Exception e ) {
12163 e.printStackTrace( System.out );
12169 private static boolean testSupportTransfer() {
12171 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12172 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)",
12173 new NHXParser() )[ 0 ];
12174 final Phylogeny p2 = factory
12175 .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 ];
12176 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12179 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12182 support_transfer.moveBranchLengthsToBootstrap( p1 );
12183 support_transfer.transferSupportValues( p1, p2 );
12184 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12187 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12190 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12193 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12196 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12199 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12202 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12205 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12209 catch ( final Exception e ) {
12210 e.printStackTrace( System.out );
12216 private static boolean testTaxonomyExtraction() {
12218 final PhylogenyNode n0 = PhylogenyNode
12219 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12220 if ( n0.getNodeData().isHasTaxonomy() ) {
12223 final PhylogenyNode n1 = PhylogenyNode
12224 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12225 if ( n1.getNodeData().isHasTaxonomy() ) {
12226 System.out.println( n1.toString() );
12229 final PhylogenyNode n2x = PhylogenyNode
12230 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12231 if ( n2x.getNodeData().isHasTaxonomy() ) {
12234 final PhylogenyNode n3 = PhylogenyNode
12235 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12236 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12237 System.out.println( n3.toString() );
12240 final PhylogenyNode n4 = PhylogenyNode
12241 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12242 if ( n4.getNodeData().isHasTaxonomy() ) {
12243 System.out.println( n4.toString() );
12246 final PhylogenyNode n5 = PhylogenyNode
12247 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12248 if ( n5.getNodeData().isHasTaxonomy() ) {
12249 System.out.println( n5.toString() );
12252 final PhylogenyNode n6 = PhylogenyNode
12253 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12254 if ( n6.getNodeData().isHasTaxonomy() ) {
12255 System.out.println( n6.toString() );
12258 final PhylogenyNode n7 = PhylogenyNode
12259 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12260 if ( n7.getNodeData().isHasTaxonomy() ) {
12261 System.out.println( n7.toString() );
12264 final PhylogenyNode n8 = PhylogenyNode
12265 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12266 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12267 System.out.println( n8.toString() );
12270 final PhylogenyNode n9 = PhylogenyNode
12271 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12272 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12273 System.out.println( n9.toString() );
12276 final PhylogenyNode n10x = PhylogenyNode
12277 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12278 if ( n10x.getNodeData().isHasTaxonomy() ) {
12279 System.out.println( n10x.toString() );
12282 final PhylogenyNode n10xx = PhylogenyNode
12283 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12284 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12285 System.out.println( n10xx.toString() );
12288 final PhylogenyNode n10 = PhylogenyNode
12289 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12290 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12291 System.out.println( n10.toString() );
12294 final PhylogenyNode n11 = PhylogenyNode
12295 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12296 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12297 System.out.println( n11.toString() );
12300 final PhylogenyNode n12 = PhylogenyNode
12301 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12302 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12303 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12304 System.out.println( n12.toString() );
12307 final PhylogenyNode n13 = PhylogenyNode
12308 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12309 if ( n13.getNodeData().isHasTaxonomy() ) {
12310 System.out.println( n13.toString() );
12313 final PhylogenyNode n14 = PhylogenyNode
12314 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12315 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12316 System.out.println( n14.toString() );
12319 final PhylogenyNode n15 = PhylogenyNode
12320 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12321 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12322 System.out.println( n15.toString() );
12325 final PhylogenyNode n16 = PhylogenyNode
12326 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12327 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12328 System.out.println( n16.toString() );
12331 final PhylogenyNode n17 = PhylogenyNode
12332 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12333 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12334 System.out.println( n17.toString() );
12338 final PhylogenyNode n18 = PhylogenyNode
12339 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12340 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12341 System.out.println( n18.toString() );
12344 final PhylogenyNode n19 = PhylogenyNode
12345 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12346 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12347 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12348 System.out.println( n19.toString() );
12351 final PhylogenyNode n20 = PhylogenyNode
12352 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12353 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12354 System.out.println( n20.toString() );
12357 final PhylogenyNode n21 = PhylogenyNode
12358 .createInstanceFromNhxString( "Mus musculus musculus K392",
12359 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12360 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12361 System.out.println( n21.toString() );
12364 final PhylogenyNode n22 = PhylogenyNode
12365 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12366 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12367 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12368 System.out.println( n22.toString() );
12371 final PhylogenyNode n23 = PhylogenyNode
12372 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12373 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12374 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12375 System.out.println( n23.toString() );
12378 final PhylogenyNode n24 = PhylogenyNode
12379 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12380 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12381 System.out.println( n24.toString() );
12385 final PhylogenyNode n25 = PhylogenyNode
12386 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12387 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12388 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12389 System.out.println( n25.toString() );
12392 final PhylogenyNode n26 = PhylogenyNode
12393 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12394 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12395 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12396 System.out.println( n26.toString() );
12399 final PhylogenyNode n27 = PhylogenyNode
12400 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12401 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12402 System.out.println( n27.toString() );
12406 catch ( final Exception e ) {
12407 e.printStackTrace( System.out );
12413 private static boolean testTreeCopy() {
12415 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12416 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12417 final Phylogeny t1 = t0.copy();
12418 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12421 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12424 t0.deleteSubtree( t0.getNode( "c" ), true );
12425 t0.deleteSubtree( t0.getNode( "a" ), true );
12426 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12427 t0.getNode( "b" ).setName( "Bee" );
12428 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12431 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12434 t0.deleteSubtree( t0.getNode( "e" ), true );
12435 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12436 t0.deleteSubtree( t0.getNode( "d" ), true );
12437 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12441 catch ( final Exception e ) {
12442 e.printStackTrace();
12448 private static boolean testTreeMethods() {
12450 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12451 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12452 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12453 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12454 System.out.println( t0.toNewHampshireX() );
12457 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12458 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12459 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12462 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12465 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12469 catch ( final Exception e ) {
12470 e.printStackTrace( System.out );
12476 private static boolean testUniprotEntryRetrieval() {
12478 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12479 if ( !entry.getAccession().equals( "P12345" ) ) {
12482 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12485 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12488 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12491 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12494 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12498 catch ( final IOException e ) {
12499 System.out.println();
12500 System.out.println( "the following might be due to absence internet connection:" );
12501 e.printStackTrace( System.out );
12504 catch ( final Exception e ) {
12510 private static boolean testUniprotTaxonomySearch() {
12512 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12514 if ( results.size() != 1 ) {
12517 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12520 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12523 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12526 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12529 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12533 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12534 if ( results.size() != 1 ) {
12537 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12540 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12543 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12546 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12549 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12553 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12554 if ( results.size() != 1 ) {
12557 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12560 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12563 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12566 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12569 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12573 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12574 if ( results.size() != 1 ) {
12577 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12580 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12583 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12586 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12589 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12592 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12595 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12598 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12599 .equals( "Nematostella vectensis" ) ) {
12600 System.out.println( results.get( 0 ).getLineage() );
12605 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12606 if ( results.size() != 1 ) {
12609 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12612 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12615 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12618 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12621 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12624 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12625 .equals( "Xenopus tropicalis" ) ) {
12626 System.out.println( results.get( 0 ).getLineage() );
12631 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12632 if ( results.size() != 1 ) {
12635 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12638 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12641 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12644 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12647 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12650 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12651 .equals( "Xenopus tropicalis" ) ) {
12652 System.out.println( results.get( 0 ).getLineage() );
12657 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12658 if ( results.size() != 1 ) {
12661 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12664 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12667 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12670 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12673 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12676 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12677 .equals( "Xenopus tropicalis" ) ) {
12678 System.out.println( results.get( 0 ).getLineage() );
12682 catch ( final IOException e ) {
12683 System.out.println();
12684 System.out.println( "the following might be due to absence internet connection:" );
12685 e.printStackTrace( System.out );
12688 catch ( final Exception e ) {
12694 private static boolean testWabiTxSearch() {
12696 String result = "";
12697 result = TxSearch.searchSimple( "nematostella" );
12698 result = TxSearch.getTxId( "nematostella" );
12699 if ( !result.equals( "45350" ) ) {
12702 result = TxSearch.getTxName( "45350" );
12703 if ( !result.equals( "Nematostella" ) ) {
12706 result = TxSearch.getTxId( "nematostella vectensis" );
12707 if ( !result.equals( "45351" ) ) {
12710 result = TxSearch.getTxName( "45351" );
12711 if ( !result.equals( "Nematostella vectensis" ) ) {
12714 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12715 if ( !result.equals( "536089" ) ) {
12718 result = TxSearch.getTxName( "536089" );
12719 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12722 final List<String> queries = new ArrayList<String>();
12723 queries.add( "Campylobacter coli" );
12724 queries.add( "Escherichia coli" );
12725 queries.add( "Arabidopsis" );
12726 queries.add( "Trichoplax" );
12727 queries.add( "Samanea saman" );
12728 queries.add( "Kluyveromyces marxianus" );
12729 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12730 queries.add( "Bornavirus parrot/PDD/2008" );
12731 final List<RANKS> ranks = new ArrayList<RANKS>();
12732 ranks.add( RANKS.SUPERKINGDOM );
12733 ranks.add( RANKS.KINGDOM );
12734 ranks.add( RANKS.FAMILY );
12735 ranks.add( RANKS.GENUS );
12736 ranks.add( RANKS.TRIBE );
12737 result = TxSearch.searchLineage( queries, ranks );
12738 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12739 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12741 catch ( final Exception e ) {
12742 System.out.println();
12743 System.out.println( "the following might be due to absence internet connection:" );
12744 e.printStackTrace( System.out );