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;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.archaeopteryx.webservices.WebserviceUtil;
44 import org.forester.development.DevelopmentTools;
45 import org.forester.evoinference.TestPhylogenyReconstruction;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
48 import org.forester.go.TestGo;
49 import org.forester.io.parsers.FastaParser;
50 import org.forester.io.parsers.GeneralMsaParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
53 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
54 import org.forester.io.parsers.nexus.NexusCharactersParser;
55 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
56 import org.forester.io.parsers.nhx.NHXParser;
57 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
58 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
59 import org.forester.io.parsers.tol.TolParser;
60 import org.forester.io.parsers.util.ParserUtils;
61 import org.forester.io.writers.PhylogenyWriter;
62 import org.forester.io.writers.SequenceWriter;
63 import org.forester.msa.BasicMsa;
64 import org.forester.msa.Mafft;
65 import org.forester.msa.Msa;
66 import org.forester.msa.MsaInferrer;
67 import org.forester.msa.MsaMethods;
68 import org.forester.pccx.TestPccx;
69 import org.forester.phylogeny.Phylogeny;
70 import org.forester.phylogeny.PhylogenyBranch;
71 import org.forester.phylogeny.PhylogenyMethods;
72 import org.forester.phylogeny.PhylogenyNode;
73 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
74 import org.forester.phylogeny.data.Accession;
75 import org.forester.phylogeny.data.Accession.Source;
76 import org.forester.phylogeny.data.BinaryCharacters;
77 import org.forester.phylogeny.data.BranchWidth;
78 import org.forester.phylogeny.data.Confidence;
79 import org.forester.phylogeny.data.Distribution;
80 import org.forester.phylogeny.data.DomainArchitecture;
81 import org.forester.phylogeny.data.Event;
82 import org.forester.phylogeny.data.Identifier;
83 import org.forester.phylogeny.data.PhylogenyData;
84 import org.forester.phylogeny.data.PhylogenyDataUtil;
85 import org.forester.phylogeny.data.Polygon;
86 import org.forester.phylogeny.data.PropertiesMap;
87 import org.forester.phylogeny.data.Property;
88 import org.forester.phylogeny.data.Property.AppliesTo;
89 import org.forester.phylogeny.data.ProteinDomain;
90 import org.forester.phylogeny.data.Taxonomy;
91 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
92 import org.forester.phylogeny.factories.PhylogenyFactory;
93 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
94 import org.forester.protein.BasicDomain;
95 import org.forester.protein.BasicProtein;
96 import org.forester.protein.Domain;
97 import org.forester.protein.Protein;
98 import org.forester.protein.ProteinId;
99 import org.forester.rio.TestRIO;
100 import org.forester.sdi.SDI;
101 import org.forester.sdi.SDIR;
102 import org.forester.sdi.TestGSDI;
103 import org.forester.sequence.BasicSequence;
104 import org.forester.sequence.Sequence;
105 import org.forester.species.BasicSpecies;
106 import org.forester.species.Species;
107 import org.forester.surfacing.TestSurfacing;
108 import org.forester.tools.ConfidenceAssessor;
109 import org.forester.tools.SupportCount;
110 import org.forester.tools.TreeSplitMatrix;
111 import org.forester.util.AsciiHistogram;
112 import org.forester.util.BasicDescriptiveStatistics;
113 import org.forester.util.BasicTable;
114 import org.forester.util.BasicTableParser;
115 import org.forester.util.DescriptiveStatistics;
116 import org.forester.util.ForesterConstants;
117 import org.forester.util.ForesterUtil;
118 import org.forester.util.GeneralTable;
119 import org.forester.util.SequenceAccessionTools;
120 import org.forester.ws.seqdb.SequenceDatabaseEntry;
121 import org.forester.ws.seqdb.SequenceDbWsTools;
122 import org.forester.ws.seqdb.UniProtTaxonomy;
123 import org.forester.ws.wabi.TxSearch;
124 import org.forester.ws.wabi.TxSearch.RANKS;
125 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
126 import org.forester.ws.wabi.TxSearch.TAX_RANK;
128 @SuppressWarnings( "unused")
129 public final class Test {
131 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
132 + ForesterUtil.getFileSeparator() + "resources"
133 + ForesterUtil.getFileSeparator();
134 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
135 + ForesterUtil.getFileSeparator() + "test_data"
136 + ForesterUtil.getFileSeparator();
137 private final static boolean PERFORM_DB_TESTS = false;
138 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
139 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
142 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
143 + ForesterConstants.PHYLO_XML_VERSION + "/"
144 + ForesterConstants.PHYLO_XML_XSD;
145 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
146 private final static double ZERO_DIFF = 1.0E-9;
148 public static boolean isEqual( final double a, final double b ) {
149 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
152 public static void main( final String[] args ) {
153 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
154 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
156 Locale.setDefault( Locale.US );
157 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
160 System.out.print( "[Test if directory with files for testing exists/is readable: " );
161 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
162 System.out.println( "OK.]" );
165 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
166 System.out.println( "Testing aborted." );
169 System.out.print( "[Test if resources directory exists/is readable: " );
170 if ( testDir( PATH_TO_RESOURCES ) ) {
171 System.out.println( "OK.]" );
174 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
175 System.out.println( "Testing aborted." );
178 final long start_time = new Date().getTime();
179 System.out.print( "Basic node methods: " );
180 if ( Test.testBasicNodeMethods() ) {
181 System.out.println( "OK." );
185 System.out.println( "failed." );
188 System.out.print( "Protein id: " );
189 if ( !testProteinId() ) {
190 System.out.println( "failed." );
196 System.out.println( "OK." );
197 System.out.print( "Species: " );
198 if ( !testSpecies() ) {
199 System.out.println( "failed." );
205 System.out.println( "OK." );
206 System.out.print( "Basic domain: " );
207 if ( !testBasicDomain() ) {
208 System.out.println( "failed." );
214 System.out.println( "OK." );
215 System.out.print( "Basic protein: " );
216 if ( !testBasicProtein() ) {
217 System.out.println( "failed." );
223 System.out.println( "OK." );
224 System.out.print( "Sequence writer: " );
225 if ( testSequenceWriter() ) {
226 System.out.println( "OK." );
230 System.out.println( "failed." );
233 System.out.print( "Sequence id parsing: " );
234 if ( testSequenceIdParsing() ) {
235 System.out.println( "OK." );
239 System.out.println( "failed." );
242 System.out.print( "UniProtKB id extraction: " );
243 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
244 System.out.println( "OK." );
248 System.out.println( "failed." );
251 System.out.print( "Sequence DB tools 1: " );
252 if ( testSequenceDbWsTools1() ) {
253 System.out.println( "OK." );
257 System.out.println( "failed." );
260 System.out.print( "Hmmscan output parser: " );
261 if ( testHmmscanOutputParser() ) {
262 System.out.println( "OK." );
266 System.out.println( "failed." );
269 System.out.print( "Overlap removal: " );
270 if ( !org.forester.test.Test.testOverlapRemoval() ) {
271 System.out.println( "failed." );
277 System.out.println( "OK." );
278 System.out.print( "Engulfing overlap removal: " );
279 if ( !Test.testEngulfingOverlapRemoval() ) {
280 System.out.println( "failed." );
286 System.out.println( "OK." );
287 System.out.print( "Taxonomy code extraction: " );
288 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
289 System.out.println( "OK." );
293 System.out.println( "failed." );
296 System.out.print( "SN extraction: " );
297 if ( Test.testExtractSNFromNodeName() ) {
298 System.out.println( "OK." );
302 System.out.println( "failed." );
305 System.out.print( "Taxonomy extraction (general): " );
306 if ( Test.testTaxonomyExtraction() ) {
307 System.out.println( "OK." );
311 System.out.println( "failed." );
314 System.out.print( "Uri for Aptx web sequence accession: " );
315 if ( Test.testCreateUriForSeqWeb() ) {
316 System.out.println( "OK." );
320 System.out.println( "failed." );
323 System.out.print( "Basic node construction and parsing of NHX (node level): " );
324 if ( Test.testNHXNodeParsing() ) {
325 System.out.println( "OK." );
329 System.out.println( "failed." );
332 System.out.print( "NHX parsing iterating: " );
333 if ( Test.testNHParsingIter() ) {
334 System.out.println( "OK." );
338 System.out.println( "failed." );
341 System.out.print( "NH parsing: " );
342 if ( Test.testNHParsing() ) {
343 System.out.println( "OK." );
347 System.out.println( "failed." );
350 System.out.print( "Conversion to NHX (node level): " );
351 if ( Test.testNHXconversion() ) {
352 System.out.println( "OK." );
356 System.out.println( "failed." );
359 System.out.print( "NHX parsing: " );
360 if ( Test.testNHXParsing() ) {
361 System.out.println( "OK." );
365 System.out.println( "failed." );
368 System.out.print( "NHX parsing with quotes: " );
369 if ( Test.testNHXParsingQuotes() ) {
370 System.out.println( "OK." );
374 System.out.println( "failed." );
377 System.out.print( "NHX parsing (MrBayes): " );
378 if ( Test.testNHXParsingMB() ) {
379 System.out.println( "OK." );
383 System.out.println( "failed." );
386 System.out.print( "Nexus characters parsing: " );
387 if ( Test.testNexusCharactersParsing() ) {
388 System.out.println( "OK." );
392 System.out.println( "failed." );
395 System.out.print( "Nexus tree parsing iterating: " );
396 if ( Test.testNexusTreeParsingIterating() ) {
397 System.out.println( "OK." );
401 System.out.println( "failed." );
404 System.out.print( "Nexus tree parsing: " );
405 if ( Test.testNexusTreeParsing() ) {
406 System.out.println( "OK." );
410 System.out.println( "failed." );
413 System.out.print( "Nexus tree parsing (translating): " );
414 if ( Test.testNexusTreeParsingTranslating() ) {
415 System.out.println( "OK." );
419 System.out.println( "failed." );
422 System.out.print( "Nexus matrix parsing: " );
423 if ( Test.testNexusMatrixParsing() ) {
424 System.out.println( "OK." );
428 System.out.println( "failed." );
431 System.out.print( "Basic phyloXML parsing: " );
432 if ( Test.testBasicPhyloXMLparsing() ) {
433 System.out.println( "OK." );
437 System.out.println( "failed." );
440 System.out.print( "Basic phyloXML parsing (validating against schema): " );
441 if ( testBasicPhyloXMLparsingValidating() ) {
442 System.out.println( "OK." );
446 System.out.println( "failed." );
449 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
450 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
451 System.out.println( "OK." );
455 System.out.println( "failed." );
458 System.out.print( "phyloXML Distribution Element: " );
459 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
460 System.out.println( "OK." );
464 System.out.println( "failed." );
467 System.out.print( "Tol XML parsing: " );
468 if ( Test.testBasicTolXMLparsing() ) {
469 System.out.println( "OK." );
473 System.out.println( "failed." );
476 System.out.print( "Copying of node data: " );
477 if ( Test.testCopyOfNodeData() ) {
478 System.out.println( "OK." );
482 System.out.println( "failed." );
485 System.out.print( "Tree copy: " );
486 if ( Test.testTreeCopy() ) {
487 System.out.println( "OK." );
491 System.out.println( "failed." );
494 System.out.print( "Basic tree methods: " );
495 if ( Test.testBasicTreeMethods() ) {
496 System.out.println( "OK." );
500 System.out.println( "failed." );
503 System.out.print( "Tree methods: " );
504 if ( Test.testTreeMethods() ) {
505 System.out.println( "OK." );
509 System.out.println( "failed." );
512 System.out.print( "Postorder Iterator: " );
513 if ( Test.testPostOrderIterator() ) {
514 System.out.println( "OK." );
518 System.out.println( "failed." );
521 System.out.print( "Preorder Iterator: " );
522 if ( Test.testPreOrderIterator() ) {
523 System.out.println( "OK." );
527 System.out.println( "failed." );
530 System.out.print( "Levelorder Iterator: " );
531 if ( Test.testLevelOrderIterator() ) {
532 System.out.println( "OK." );
536 System.out.println( "failed." );
539 System.out.print( "Re-id methods: " );
540 if ( Test.testReIdMethods() ) {
541 System.out.println( "OK." );
545 System.out.println( "failed." );
548 System.out.print( "Methods on last external nodes: " );
549 if ( Test.testLastExternalNodeMethods() ) {
550 System.out.println( "OK." );
554 System.out.println( "failed." );
557 System.out.print( "Methods on external nodes: " );
558 if ( Test.testExternalNodeRelatedMethods() ) {
559 System.out.println( "OK." );
563 System.out.println( "failed." );
566 System.out.print( "Deletion of external nodes: " );
567 if ( Test.testDeletionOfExternalNodes() ) {
568 System.out.println( "OK." );
572 System.out.println( "failed." );
575 System.out.print( "Subtree deletion: " );
576 if ( Test.testSubtreeDeletion() ) {
577 System.out.println( "OK." );
581 System.out.println( "failed." );
584 System.out.print( "Phylogeny branch: " );
585 if ( Test.testPhylogenyBranch() ) {
586 System.out.println( "OK." );
590 System.out.println( "failed." );
593 System.out.print( "Rerooting: " );
594 if ( Test.testRerooting() ) {
595 System.out.println( "OK." );
599 System.out.println( "failed." );
602 System.out.print( "Mipoint rooting: " );
603 if ( Test.testMidpointrooting() ) {
604 System.out.println( "OK." );
608 System.out.println( "failed." );
611 System.out.print( "Node removal: " );
612 if ( Test.testNodeRemoval() ) {
613 System.out.println( "OK." );
617 System.out.println( "failed." );
620 System.out.print( "Support count: " );
621 if ( Test.testSupportCount() ) {
622 System.out.println( "OK." );
626 System.out.println( "failed." );
629 System.out.print( "Support transfer: " );
630 if ( Test.testSupportTransfer() ) {
631 System.out.println( "OK." );
635 System.out.println( "failed." );
638 System.out.print( "Finding of LCA: " );
639 if ( Test.testGetLCA() ) {
640 System.out.println( "OK." );
644 System.out.println( "failed." );
647 System.out.print( "Finding of LCA 2: " );
648 if ( Test.testGetLCA2() ) {
649 System.out.println( "OK." );
653 System.out.println( "failed." );
656 System.out.print( "Calculation of distance between nodes: " );
657 if ( Test.testGetDistance() ) {
658 System.out.println( "OK." );
662 System.out.println( "failed." );
665 System.out.print( "Descriptive statistics: " );
666 if ( Test.testDescriptiveStatistics() ) {
667 System.out.println( "OK." );
671 System.out.println( "failed." );
674 System.out.print( "Data objects and methods: " );
675 if ( Test.testDataObjects() ) {
676 System.out.println( "OK." );
680 System.out.println( "failed." );
683 System.out.print( "Properties map: " );
684 if ( Test.testPropertiesMap() ) {
685 System.out.println( "OK." );
689 System.out.println( "failed." );
692 System.out.print( "SDIse: " );
693 if ( Test.testSDIse() ) {
694 System.out.println( "OK." );
698 System.out.println( "failed." );
701 System.out.print( "SDIunrooted: " );
702 if ( Test.testSDIunrooted() ) {
703 System.out.println( "OK." );
707 System.out.println( "failed." );
710 System.out.print( "GSDI: " );
711 if ( TestGSDI.test() ) {
712 System.out.println( "OK." );
716 System.out.println( "failed." );
719 System.out.print( "RIO: " );
720 if ( TestRIO.test() ) {
721 System.out.println( "OK." );
725 System.out.println( "failed." );
728 System.out.print( "Phylogeny reconstruction:" );
729 System.out.println();
730 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
731 System.out.println( "OK." );
735 System.out.println( "failed." );
738 System.out.print( "Analysis of domain architectures: " );
739 System.out.println();
740 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
741 System.out.println( "OK." );
745 System.out.println( "failed." );
748 System.out.print( "GO: " );
749 System.out.println();
750 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
751 System.out.println( "OK." );
755 System.out.println( "failed." );
758 System.out.print( "Modeling tools: " );
759 if ( TestPccx.test() ) {
760 System.out.println( "OK." );
764 System.out.println( "failed." );
767 System.out.print( "Split Matrix strict: " );
768 if ( Test.testSplitStrict() ) {
769 System.out.println( "OK." );
773 System.out.println( "failed." );
776 System.out.print( "Split Matrix: " );
777 if ( Test.testSplit() ) {
778 System.out.println( "OK." );
782 System.out.println( "failed." );
785 System.out.print( "Confidence Assessor: " );
786 if ( Test.testConfidenceAssessor() ) {
787 System.out.println( "OK." );
791 System.out.println( "failed." );
794 System.out.print( "Basic table: " );
795 if ( Test.testBasicTable() ) {
796 System.out.println( "OK." );
800 System.out.println( "failed." );
803 System.out.print( "General table: " );
804 if ( Test.testGeneralTable() ) {
805 System.out.println( "OK." );
809 System.out.println( "failed." );
812 System.out.print( "Amino acid sequence: " );
813 if ( Test.testAminoAcidSequence() ) {
814 System.out.println( "OK." );
818 System.out.println( "failed." );
821 System.out.print( "General MSA parser: " );
822 if ( Test.testGeneralMsaParser() ) {
823 System.out.println( "OK." );
827 System.out.println( "failed." );
830 System.out.print( "Fasta parser for msa: " );
831 if ( Test.testFastaParser() ) {
832 System.out.println( "OK." );
836 System.out.println( "failed." );
839 System.out.print( "Creation of balanced phylogeny: " );
840 if ( Test.testCreateBalancedPhylogeny() ) {
841 System.out.println( "OK." );
845 System.out.println( "failed." );
848 System.out.print( "Genbank accessor parsing: " );
849 if ( Test.testGenbankAccessorParsing() ) {
850 System.out.println( "OK." );
854 System.out.println( "failed." );
858 final String os = ForesterUtil.OS_NAME.toLowerCase();
859 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
860 path = "/usr/local/bin/mafft";
862 else if ( os.indexOf( "win" ) >= 0 ) {
863 path = "C:\\Program Files\\mafft-win\\mafft.bat";
867 if ( !MsaInferrer.isInstalled( path ) ) {
868 path = "/usr/bin/mafft";
870 if ( !MsaInferrer.isInstalled( path ) ) {
871 path = "/usr/local/bin/mafft";
874 if ( MsaInferrer.isInstalled( path ) ) {
875 System.out.print( "MAFFT (external program): " );
876 if ( Test.testMafft( path ) ) {
877 System.out.println( "OK." );
881 System.out.println( "failed [will not count towards failed tests]" );
884 System.out.print( "Next nodes with collapsed: " );
885 if ( Test.testNextNodeWithCollapsing() ) {
886 System.out.println( "OK." );
890 System.out.println( "failed." );
893 System.out.print( "Simple MSA quality: " );
894 if ( Test.testMsaQualityMethod() ) {
895 System.out.println( "OK." );
899 System.out.println( "failed." );
902 if ( PERFORM_DB_TESTS ) {
903 System.out.print( "Uniprot Entry Retrieval: " );
904 if ( Test.testUniprotEntryRetrieval() ) {
905 System.out.println( "OK." );
909 System.out.println( "failed." );
912 System.out.print( "Ebi Entry Retrieval: " );
913 if ( Test.testEbiEntryRetrieval() ) {
914 System.out.println( "OK." );
918 System.out.println( "failed." );
921 System.out.print( "Sequence DB tools 2: " );
922 if ( testSequenceDbWsTools2() ) {
923 System.out.println( "OK." );
927 System.out.println( "failed." );
931 System.out.print( "Uniprot Taxonomy Search: " );
932 if ( Test.testUniprotTaxonomySearch() ) {
933 System.out.println( "OK." );
937 System.out.println( "failed." );
941 if ( PERFORM_WEB_TREE_ACCESS ) {
942 System.out.print( "NHX parsing from URL: " );
943 if ( Test.testNHXparsingFromURL() ) {
944 System.out.println( "OK." );
948 System.out.println( "failed." );
951 System.out.print( "phyloXML parsing from URL: " );
952 if ( Test.testPhyloXMLparsingFromURL() ) {
953 System.out.println( "OK." );
957 System.out.println( "failed." );
960 System.out.print( "TreeBase acccess: " );
961 if ( Test.testTreeBaseReading() ) {
962 System.out.println( "OK." );
966 System.out.println( "failed." );
970 System.out.print( "ToL access: " );
971 if ( Test.testToLReading() ) {
972 System.out.println( "OK." );
976 System.out.println( "failed." );
980 System.out.print( "TreeFam access: " );
981 if ( Test.testTreeFamReading() ) {
982 System.out.println( "OK." );
986 System.out.println( "failed." );
991 System.out.print( "Pfam tree access: " );
992 if ( Test.testPfamTreeReading() ) {
993 System.out.println( "OK." );
997 System.out.println( "failed." );
1001 System.out.println();
1002 final Runtime rt = java.lang.Runtime.getRuntime();
1003 final long free_memory = rt.freeMemory() / 1000000;
1004 final long total_memory = rt.totalMemory() / 1000000;
1005 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1006 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1007 System.out.println();
1008 System.out.println( "Successful tests: " + succeeded );
1009 System.out.println( "Failed tests: " + failed );
1010 System.out.println();
1012 System.out.println( "OK." );
1015 System.out.println( "Not OK." );
1019 public static boolean testEngulfingOverlapRemoval() {
1021 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1022 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1023 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1024 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1025 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1026 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1027 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1028 final List<Boolean> covered = new ArrayList<Boolean>();
1029 covered.add( true ); // 0
1030 covered.add( false ); // 1
1031 covered.add( true ); // 2
1032 covered.add( false ); // 3
1033 covered.add( true ); // 4
1034 covered.add( true ); // 5
1035 covered.add( false ); // 6
1036 covered.add( true ); // 7
1037 covered.add( true ); // 8
1038 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1041 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1044 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1047 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1050 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1053 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1056 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1059 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1060 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1061 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1062 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1063 abc.addProteinDomain( a );
1064 abc.addProteinDomain( b );
1065 abc.addProteinDomain( c );
1066 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1067 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1068 if ( abc.getNumberOfProteinDomains() != 3 ) {
1071 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1074 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1077 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1080 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1083 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1084 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1085 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1086 final Protein def = new BasicProtein( "def", "nemve", 0 );
1087 def.addProteinDomain( d );
1088 def.addProteinDomain( e );
1089 def.addProteinDomain( f );
1090 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1091 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1092 if ( def.getNumberOfProteinDomains() != 3 ) {
1095 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1098 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1101 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1104 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1107 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1111 catch ( final Exception e ) {
1112 e.printStackTrace( System.out );
1118 public static final boolean testNHXparsingFromURL() {
1120 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1121 final URL u = new URL( s );
1122 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1123 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1124 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1127 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1128 System.out.println( phys[ 0 ].toNewHampshire() );
1131 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1132 System.out.println( phys[ 1 ].toNewHampshire() );
1135 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1136 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1139 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1140 System.out.println( phys2[ 0 ].toNewHampshire() );
1143 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1144 final NHXParser p = new NHXParser();
1145 final URL u2 = new URL( s );
1147 if ( !p.hasNext() ) {
1150 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1153 if ( !p.hasNext() ) {
1157 if ( !p.hasNext() ) {
1160 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1163 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1167 if ( !p.hasNext() ) {
1170 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1173 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1177 catch ( final Exception e ) {
1178 e.printStackTrace();
1183 public static boolean testOverlapRemoval() {
1185 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1186 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1187 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1188 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1189 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1190 final List<Boolean> covered = new ArrayList<Boolean>();
1191 covered.add( true ); // 0
1192 covered.add( false ); // 1
1193 covered.add( true ); // 2
1194 covered.add( false ); // 3
1195 covered.add( true ); // 4
1196 covered.add( true ); // 5
1197 covered.add( false ); // 6
1198 covered.add( true ); // 7
1199 covered.add( true ); // 8
1200 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1203 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1206 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1209 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1212 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1215 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1216 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1217 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1218 ab.addProteinDomain( a );
1219 ab.addProteinDomain( b );
1220 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1221 if ( ab.getNumberOfProteinDomains() != 2 ) {
1224 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1227 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1230 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1231 if ( ab.getNumberOfProteinDomains() != 2 ) {
1234 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1237 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1238 final Domain d = new BasicDomain( "d",
1245 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1246 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1247 cde.addProteinDomain( c );
1248 cde.addProteinDomain( d );
1249 cde.addProteinDomain( e );
1250 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1251 if ( cde.getNumberOfProteinDomains() != 3 ) {
1254 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1257 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1258 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1259 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1260 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1261 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1262 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1263 fghi.addProteinDomain( f );
1264 fghi.addProteinDomain( g );
1265 fghi.addProteinDomain( h );
1266 fghi.addProteinDomain( i );
1267 fghi.addProteinDomain( i );
1268 fghi.addProteinDomain( i );
1269 fghi.addProteinDomain( i2 );
1270 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1271 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1274 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1277 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1280 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1281 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1284 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1287 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1288 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1289 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1290 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1291 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1292 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1293 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1294 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1295 jklm.addProteinDomain( j );
1296 jklm.addProteinDomain( k );
1297 jklm.addProteinDomain( l );
1298 jklm.addProteinDomain( m );
1299 jklm.addProteinDomain( m0 );
1300 jklm.addProteinDomain( m1 );
1301 jklm.addProteinDomain( m2 );
1302 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1303 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1306 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1309 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1312 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1313 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1316 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1319 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1320 final Protein od = new BasicProtein( "od", "varanus", 0 );
1321 od.addProteinDomain( only );
1322 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1323 if ( od.getNumberOfProteinDomains() != 1 ) {
1326 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1330 catch ( final Exception e ) {
1331 e.printStackTrace( System.out );
1337 public static final boolean testPfamTreeReading() {
1339 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1340 final NHXParser parser = new NHXParser();
1341 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1342 parser.setReplaceUnderscores( false );
1343 parser.setGuessRootedness( true );
1344 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1345 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1346 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1349 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1353 catch ( final Exception e ) {
1354 e.printStackTrace();
1359 public static final boolean testPhyloXMLparsingFromURL() {
1361 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1362 final URL u = new URL( s );
1363 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1364 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1365 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1369 catch ( final Exception e ) {
1370 e.printStackTrace();
1375 public static final boolean testToLReading() {
1377 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1378 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1379 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1380 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1383 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1386 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1389 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1393 catch ( final Exception e ) {
1394 e.printStackTrace();
1399 public static final boolean testTreeBaseReading() {
1401 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1402 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1403 parser.setReplaceUnderscores( true );
1404 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1405 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1406 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1409 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1410 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1411 parser2.setReplaceUnderscores( true );
1412 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1413 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1414 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1418 catch ( final Exception e ) {
1419 e.printStackTrace();
1424 public static final boolean testTreeFamReading() {
1426 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1427 final NHXParser parser = new NHXParser();
1428 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1429 parser.setReplaceUnderscores( false );
1430 parser.setGuessRootedness( true );
1431 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1432 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1433 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1436 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1440 catch ( final Exception e ) {
1441 e.printStackTrace();
1446 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1447 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1451 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1452 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1455 private static boolean testAminoAcidSequence() {
1457 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1458 if ( aa1.getLength() != 13 ) {
1461 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1464 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1467 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1470 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1471 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1474 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1475 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1478 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1479 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1483 catch ( final Exception e ) {
1484 e.printStackTrace();
1490 private static boolean testBasicDomain() {
1492 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1493 if ( !pd.getDomainId().equals( "id" ) ) {
1496 if ( pd.getNumber() != 1 ) {
1499 if ( pd.getTotalCount() != 4 ) {
1502 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1505 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1506 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1507 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1508 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1509 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1510 if ( !a1.equals( a1 ) ) {
1513 if ( !a1.equals( a1_copy ) ) {
1516 if ( !a1.equals( a1_equal ) ) {
1519 if ( !a1.equals( a2 ) ) {
1522 if ( a1.equals( a3 ) ) {
1525 if ( a1.compareTo( a1 ) != 0 ) {
1528 if ( a1.compareTo( a1_copy ) != 0 ) {
1531 if ( a1.compareTo( a1_equal ) != 0 ) {
1534 if ( a1.compareTo( a2 ) != 0 ) {
1537 if ( a1.compareTo( a3 ) == 0 ) {
1541 catch ( final Exception e ) {
1542 e.printStackTrace( System.out );
1548 private static boolean testBasicNodeMethods() {
1550 if ( PhylogenyNode.getNodeCount() != 0 ) {
1553 final PhylogenyNode n1 = new PhylogenyNode();
1554 final PhylogenyNode n2 = PhylogenyNode
1555 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1556 final PhylogenyNode n3 = PhylogenyNode
1557 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1558 final PhylogenyNode n4 = PhylogenyNode
1559 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1560 if ( n1.isHasAssignedEvent() ) {
1563 if ( PhylogenyNode.getNodeCount() != 4 ) {
1566 if ( n3.getIndicator() != 0 ) {
1569 if ( n3.getNumberOfExternalNodes() != 1 ) {
1572 if ( !n3.isExternal() ) {
1575 if ( !n3.isRoot() ) {
1578 if ( !n4.getName().equals( "n4" ) ) {
1582 catch ( final Exception e ) {
1583 e.printStackTrace( System.out );
1589 private static boolean testBasicPhyloXMLparsing() {
1591 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1592 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1593 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1595 if ( xml_parser.getErrorCount() > 0 ) {
1596 System.out.println( xml_parser.getErrorMessages().toString() );
1599 if ( phylogenies_0.length != 4 ) {
1602 final Phylogeny t1 = phylogenies_0[ 0 ];
1603 final Phylogeny t2 = phylogenies_0[ 1 ];
1604 final Phylogeny t3 = phylogenies_0[ 2 ];
1605 final Phylogeny t4 = phylogenies_0[ 3 ];
1606 if ( t1.getNumberOfExternalNodes() != 1 ) {
1609 if ( !t1.isRooted() ) {
1612 if ( t1.isRerootable() ) {
1615 if ( !t1.getType().equals( "gene_tree" ) ) {
1618 if ( t2.getNumberOfExternalNodes() != 2 ) {
1621 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1624 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1627 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1630 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1633 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1636 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1639 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1640 .startsWith( "actgtgggggt" ) ) {
1643 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1644 .startsWith( "ctgtgatgcat" ) ) {
1647 if ( t3.getNumberOfExternalNodes() != 4 ) {
1650 if ( !t1.getName().equals( "t1" ) ) {
1653 if ( !t2.getName().equals( "t2" ) ) {
1656 if ( !t3.getName().equals( "t3" ) ) {
1659 if ( !t4.getName().equals( "t4" ) ) {
1662 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1665 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1668 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1671 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1672 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1675 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1678 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1681 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1684 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1685 .equals( "apoptosis" ) ) {
1688 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1689 .equals( "GO:0006915" ) ) {
1692 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1693 .equals( "UniProtKB" ) ) {
1696 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1697 .equals( "experimental" ) ) {
1700 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1701 .equals( "function" ) ) {
1704 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1705 .getValue() != 1 ) {
1708 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1709 .getType().equals( "ml" ) ) {
1712 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1713 .equals( "apoptosis" ) ) {
1716 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1717 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1720 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1721 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1724 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1725 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1728 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1729 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1732 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1733 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1736 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1737 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1740 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1741 .equals( "GO:0005829" ) ) {
1744 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1745 .equals( "intracellular organelle" ) ) {
1748 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1751 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1752 .equals( "UniProt link" ) ) ) {
1755 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1758 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1759 if ( x.size() != 4 ) {
1763 for( final Accession acc : x ) {
1765 if ( !acc.getSource().equals( "KEGG" ) ) {
1768 if ( !acc.getValue().equals( "hsa:596" ) ) {
1775 catch ( final Exception e ) {
1776 e.printStackTrace( System.out );
1782 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1785 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1786 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1787 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1790 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1792 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1794 if ( xml_parser.getErrorCount() > 0 ) {
1795 System.out.println( xml_parser.getErrorMessages().toString() );
1798 if ( phylogenies_0.length != 4 ) {
1801 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1802 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1803 if ( phylogenies_t1.length != 1 ) {
1806 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1807 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1810 if ( !t1_rt.isRooted() ) {
1813 if ( t1_rt.isRerootable() ) {
1816 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1819 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1820 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1821 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1822 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1825 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1828 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1831 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1834 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1835 .startsWith( "actgtgggggt" ) ) {
1838 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1839 .startsWith( "ctgtgatgcat" ) ) {
1842 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1843 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1844 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1845 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1846 if ( phylogenies_1.length != 1 ) {
1849 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1850 if ( !t3_rt.getName().equals( "t3" ) ) {
1853 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1856 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1859 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1862 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1865 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1866 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1869 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1872 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1875 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1876 .equals( "UniProtKB" ) ) {
1879 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1880 .equals( "apoptosis" ) ) {
1883 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1884 .equals( "GO:0006915" ) ) {
1887 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1888 .equals( "UniProtKB" ) ) {
1891 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1892 .equals( "experimental" ) ) {
1895 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1896 .equals( "function" ) ) {
1899 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1900 .getValue() != 1 ) {
1903 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1904 .getType().equals( "ml" ) ) {
1907 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1908 .equals( "apoptosis" ) ) {
1911 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1912 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1915 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1916 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1919 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1920 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1923 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1924 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1927 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1928 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1931 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1932 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1935 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1936 .equals( "GO:0005829" ) ) {
1939 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1940 .equals( "intracellular organelle" ) ) {
1943 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1946 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1947 .equals( "UniProt link" ) ) ) {
1950 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1953 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1956 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1957 .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." ) ) ) {
1960 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1963 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1966 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1969 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1972 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1973 .equals( "ncbi" ) ) {
1976 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1979 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1980 .getName().equals( "B" ) ) {
1983 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1984 .getFrom() != 21 ) {
1987 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1990 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1991 .getLength() != 24 ) {
1994 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1995 .getConfidence() != 2144 ) {
1998 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1999 .equals( "pfam" ) ) {
2002 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2005 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2008 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2011 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2014 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2015 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2018 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2021 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2024 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2027 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2030 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2033 if ( taxbb.getSynonyms().size() != 2 ) {
2036 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2039 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2042 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2045 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2048 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2051 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2052 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2055 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2058 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2061 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2064 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2067 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2070 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2073 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2077 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2080 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2081 .equalsIgnoreCase( "435" ) ) {
2084 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2087 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2088 .equalsIgnoreCase( "443.7" ) ) {
2091 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2094 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2097 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2098 .equalsIgnoreCase( "433" ) ) {
2101 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2102 .getCrossReferences();
2103 if ( x.size() != 4 ) {
2107 for( final Accession acc : x ) {
2109 if ( !acc.getSource().equals( "KEGG" ) ) {
2112 if ( !acc.getValue().equals( "hsa:596" ) ) {
2119 catch ( final Exception e ) {
2120 e.printStackTrace( System.out );
2126 private static boolean testBasicPhyloXMLparsingValidating() {
2128 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2129 PhyloXmlParser xml_parser = null;
2131 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2133 catch ( final Exception e ) {
2134 // Do nothing -- means were not running from jar.
2136 if ( xml_parser == null ) {
2137 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2138 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2139 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2142 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2145 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2147 if ( xml_parser.getErrorCount() > 0 ) {
2148 System.out.println( xml_parser.getErrorMessages().toString() );
2151 if ( phylogenies_0.length != 4 ) {
2154 final Phylogeny t1 = phylogenies_0[ 0 ];
2155 final Phylogeny t2 = phylogenies_0[ 1 ];
2156 final Phylogeny t3 = phylogenies_0[ 2 ];
2157 final Phylogeny t4 = phylogenies_0[ 3 ];
2158 if ( !t1.getName().equals( "t1" ) ) {
2161 if ( !t2.getName().equals( "t2" ) ) {
2164 if ( !t3.getName().equals( "t3" ) ) {
2167 if ( !t4.getName().equals( "t4" ) ) {
2170 if ( t1.getNumberOfExternalNodes() != 1 ) {
2173 if ( t2.getNumberOfExternalNodes() != 2 ) {
2176 if ( t3.getNumberOfExternalNodes() != 4 ) {
2179 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2180 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2181 if ( xml_parser.getErrorCount() > 0 ) {
2182 System.out.println( "errors:" );
2183 System.out.println( xml_parser.getErrorMessages().toString() );
2186 if ( phylogenies_1.length != 4 ) {
2189 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2191 if ( xml_parser.getErrorCount() > 0 ) {
2192 System.out.println( "errors:" );
2193 System.out.println( xml_parser.getErrorMessages().toString() );
2196 if ( phylogenies_2.length != 1 ) {
2199 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2202 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2204 if ( xml_parser.getErrorCount() > 0 ) {
2205 System.out.println( xml_parser.getErrorMessages().toString() );
2208 if ( phylogenies_3.length != 2 ) {
2211 final Phylogeny a = phylogenies_3[ 0 ];
2212 if ( !a.getName().equals( "tree 4" ) ) {
2215 if ( a.getNumberOfExternalNodes() != 3 ) {
2218 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2221 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2224 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2226 if ( xml_parser.getErrorCount() > 0 ) {
2227 System.out.println( xml_parser.getErrorMessages().toString() );
2230 if ( phylogenies_4.length != 1 ) {
2233 final Phylogeny s = phylogenies_4[ 0 ];
2234 if ( s.getNumberOfExternalNodes() != 6 ) {
2237 s.getNode( "first" );
2239 s.getNode( "\"<a'b&c'd\">\"" );
2240 s.getNode( "'''\"" );
2241 s.getNode( "\"\"\"" );
2242 s.getNode( "dick & doof" );
2244 catch ( final Exception e ) {
2245 e.printStackTrace( System.out );
2251 private static boolean testBasicProtein() {
2253 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2254 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2255 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2256 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2257 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2258 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2259 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2260 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2261 p0.addProteinDomain( y );
2262 p0.addProteinDomain( e );
2263 p0.addProteinDomain( b );
2264 p0.addProteinDomain( c );
2265 p0.addProteinDomain( d );
2266 p0.addProteinDomain( a );
2267 p0.addProteinDomain( x );
2268 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2271 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2275 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2276 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2277 aa0.addProteinDomain( a1 );
2278 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2281 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2285 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2286 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2287 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2288 aa1.addProteinDomain( a11 );
2289 aa1.addProteinDomain( a12 );
2290 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2293 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2296 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2297 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2300 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2303 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2306 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2307 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2310 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2313 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2316 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2319 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2320 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2323 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2326 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2329 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2332 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2333 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2336 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2339 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2342 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2346 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2347 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2348 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2349 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2350 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2351 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2352 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2353 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2354 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2355 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2356 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2357 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2358 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2360 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2361 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 p00.addProteinDomain( y0 );
2368 p00.addProteinDomain( e0 );
2369 p00.addProteinDomain( b0 );
2370 p00.addProteinDomain( c0 );
2371 p00.addProteinDomain( d0 );
2372 p00.addProteinDomain( a0 );
2373 p00.addProteinDomain( x0 );
2374 p00.addProteinDomain( y1 );
2375 p00.addProteinDomain( y2 );
2376 p00.addProteinDomain( y3 );
2377 p00.addProteinDomain( e1 );
2378 p00.addProteinDomain( e2 );
2379 p00.addProteinDomain( e3 );
2380 p00.addProteinDomain( e4 );
2381 p00.addProteinDomain( e5 );
2382 p00.addProteinDomain( z0 );
2383 p00.addProteinDomain( z1 );
2384 p00.addProteinDomain( z2 );
2385 p00.addProteinDomain( zz0 );
2386 p00.addProteinDomain( zz1 );
2387 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2390 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2393 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2396 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2399 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" ) ) {
2402 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2403 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2404 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2405 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2406 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2407 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2408 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2409 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2410 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2411 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2412 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2413 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2414 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2415 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2416 p.addProteinDomain( B15 );
2417 p.addProteinDomain( C50 );
2418 p.addProteinDomain( A60 );
2419 p.addProteinDomain( A30 );
2420 p.addProteinDomain( C70 );
2421 p.addProteinDomain( B35 );
2422 p.addProteinDomain( B40 );
2423 p.addProteinDomain( A0 );
2424 p.addProteinDomain( A10 );
2425 p.addProteinDomain( A20 );
2426 p.addProteinDomain( B25 );
2427 p.addProteinDomain( D80 );
2428 List<String> domains_ids = new ArrayList<String>();
2429 domains_ids.add( "A" );
2430 domains_ids.add( "B" );
2431 domains_ids.add( "C" );
2432 if ( !p.contains( domains_ids, false ) ) {
2435 if ( !p.contains( domains_ids, true ) ) {
2438 domains_ids.add( "X" );
2439 if ( p.contains( domains_ids, false ) ) {
2442 if ( p.contains( domains_ids, true ) ) {
2445 domains_ids = new ArrayList<String>();
2446 domains_ids.add( "A" );
2447 domains_ids.add( "C" );
2448 domains_ids.add( "D" );
2449 if ( !p.contains( domains_ids, false ) ) {
2452 if ( !p.contains( domains_ids, true ) ) {
2455 domains_ids = new ArrayList<String>();
2456 domains_ids.add( "A" );
2457 domains_ids.add( "D" );
2458 domains_ids.add( "C" );
2459 if ( !p.contains( domains_ids, false ) ) {
2462 if ( p.contains( domains_ids, true ) ) {
2465 domains_ids = new ArrayList<String>();
2466 domains_ids.add( "A" );
2467 domains_ids.add( "A" );
2468 domains_ids.add( "B" );
2469 if ( !p.contains( domains_ids, false ) ) {
2472 if ( !p.contains( domains_ids, true ) ) {
2475 domains_ids = new ArrayList<String>();
2476 domains_ids.add( "A" );
2477 domains_ids.add( "A" );
2478 domains_ids.add( "A" );
2479 domains_ids.add( "B" );
2480 domains_ids.add( "B" );
2481 if ( !p.contains( domains_ids, false ) ) {
2484 if ( !p.contains( domains_ids, true ) ) {
2487 domains_ids = new ArrayList<String>();
2488 domains_ids.add( "A" );
2489 domains_ids.add( "A" );
2490 domains_ids.add( "B" );
2491 domains_ids.add( "A" );
2492 domains_ids.add( "B" );
2493 domains_ids.add( "B" );
2494 domains_ids.add( "A" );
2495 domains_ids.add( "B" );
2496 domains_ids.add( "C" );
2497 domains_ids.add( "A" );
2498 domains_ids.add( "C" );
2499 domains_ids.add( "D" );
2500 if ( !p.contains( domains_ids, false ) ) {
2503 if ( p.contains( domains_ids, true ) ) {
2507 catch ( final Exception e ) {
2508 e.printStackTrace( System.out );
2514 private static boolean testBasicTable() {
2516 final BasicTable<String> t0 = new BasicTable<String>();
2517 if ( t0.getNumberOfColumns() != 0 ) {
2520 if ( t0.getNumberOfRows() != 0 ) {
2523 t0.setValue( 3, 2, "23" );
2524 t0.setValue( 10, 1, "error" );
2525 t0.setValue( 10, 1, "110" );
2526 t0.setValue( 9, 1, "19" );
2527 t0.setValue( 1, 10, "101" );
2528 t0.setValue( 10, 10, "1010" );
2529 t0.setValue( 100, 10, "10100" );
2530 t0.setValue( 0, 0, "00" );
2531 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2534 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2537 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2540 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2543 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2546 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2549 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2552 if ( t0.getNumberOfColumns() != 101 ) {
2555 if ( t0.getNumberOfRows() != 11 ) {
2558 if ( t0.getValueAsString( 49, 4 ) != null ) {
2561 final String l = ForesterUtil.getLineSeparator();
2562 final StringBuffer source = new StringBuffer();
2563 source.append( "" + l );
2564 source.append( "# 1 1 1 1 1 1 1 1" + l );
2565 source.append( " 00 01 02 03" + l );
2566 source.append( " 10 11 12 13 " + l );
2567 source.append( "20 21 22 23 " + l );
2568 source.append( " 30 31 32 33" + l );
2569 source.append( "40 41 42 43" + l );
2570 source.append( " # 1 1 1 1 1 " + l );
2571 source.append( "50 51 52 53 54" + l );
2572 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2573 if ( t1.getNumberOfColumns() != 5 ) {
2576 if ( t1.getNumberOfRows() != 6 ) {
2579 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2582 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2585 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2588 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2591 final StringBuffer source1 = new StringBuffer();
2592 source1.append( "" + l );
2593 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2594 source1.append( " 00; 01 ;02;03" + l );
2595 source1.append( " 10; 11; 12; 13 " + l );
2596 source1.append( "20; 21; 22; 23 " + l );
2597 source1.append( " 30; 31; 32; 33" + l );
2598 source1.append( "40;41;42;43" + l );
2599 source1.append( " # 1 1 1 1 1 " + l );
2600 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2601 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2602 if ( t2.getNumberOfColumns() != 5 ) {
2605 if ( t2.getNumberOfRows() != 6 ) {
2608 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2611 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2614 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2617 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2620 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2623 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2626 final StringBuffer source2 = new StringBuffer();
2627 source2.append( "" + l );
2628 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2629 source2.append( " 00; 01 ;02;03" + l );
2630 source2.append( " 10; 11; 12; 13 " + l );
2631 source2.append( "20; 21; 22; 23 " + l );
2632 source2.append( " " + l );
2633 source2.append( " 30; 31; 32; 33" + l );
2634 source2.append( "40;41;42;43" + l );
2635 source2.append( " comment: 1 1 1 1 1 " + l );
2636 source2.append( ";;;50 ; 52; 53;;54 " + l );
2637 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2643 if ( tl.size() != 2 ) {
2646 final BasicTable<String> t3 = tl.get( 0 );
2647 final BasicTable<String> t4 = tl.get( 1 );
2648 if ( t3.getNumberOfColumns() != 4 ) {
2651 if ( t3.getNumberOfRows() != 3 ) {
2654 if ( t4.getNumberOfColumns() != 4 ) {
2657 if ( t4.getNumberOfRows() != 3 ) {
2660 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2663 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2667 catch ( final Exception e ) {
2668 e.printStackTrace( System.out );
2674 private static boolean testBasicTolXMLparsing() {
2676 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2677 final TolParser parser = new TolParser();
2678 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2679 if ( parser.getErrorCount() > 0 ) {
2680 System.out.println( parser.getErrorMessages().toString() );
2683 if ( phylogenies_0.length != 1 ) {
2686 final Phylogeny t1 = phylogenies_0[ 0 ];
2687 if ( t1.getNumberOfExternalNodes() != 5 ) {
2690 if ( !t1.isRooted() ) {
2693 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2696 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2699 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2702 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2705 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2706 if ( parser.getErrorCount() > 0 ) {
2707 System.out.println( parser.getErrorMessages().toString() );
2710 if ( phylogenies_1.length != 1 ) {
2713 final Phylogeny t2 = phylogenies_1[ 0 ];
2714 if ( t2.getNumberOfExternalNodes() != 664 ) {
2717 if ( !t2.isRooted() ) {
2720 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2723 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2726 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2729 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2732 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2735 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2736 .equals( "Aquifex" ) ) {
2739 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2740 if ( parser.getErrorCount() > 0 ) {
2741 System.out.println( parser.getErrorMessages().toString() );
2744 if ( phylogenies_2.length != 1 ) {
2747 final Phylogeny t3 = phylogenies_2[ 0 ];
2748 if ( t3.getNumberOfExternalNodes() != 184 ) {
2751 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2754 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2757 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2760 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2761 if ( parser.getErrorCount() > 0 ) {
2762 System.out.println( parser.getErrorMessages().toString() );
2765 if ( phylogenies_3.length != 1 ) {
2768 final Phylogeny t4 = phylogenies_3[ 0 ];
2769 if ( t4.getNumberOfExternalNodes() != 1 ) {
2772 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2775 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2778 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2781 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2782 if ( parser.getErrorCount() > 0 ) {
2783 System.out.println( parser.getErrorMessages().toString() );
2786 if ( phylogenies_4.length != 1 ) {
2789 final Phylogeny t5 = phylogenies_4[ 0 ];
2790 if ( t5.getNumberOfExternalNodes() != 13 ) {
2793 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2796 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2799 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2803 catch ( final Exception e ) {
2804 e.printStackTrace( System.out );
2810 private static boolean testBasicTreeMethods() {
2812 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2813 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2814 if ( t2.getNumberOfExternalNodes() != 4 ) {
2817 if ( t2.getHeight() != 8.5 ) {
2820 if ( !t2.isCompletelyBinary() ) {
2823 if ( t2.isEmpty() ) {
2826 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2827 if ( t3.getNumberOfExternalNodes() != 5 ) {
2830 if ( t3.getHeight() != 11 ) {
2833 if ( t3.isCompletelyBinary() ) {
2836 final PhylogenyNode n = t3.getNode( "ABC" );
2837 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 ];
2838 if ( t4.getNumberOfExternalNodes() != 9 ) {
2841 if ( t4.getHeight() != 11 ) {
2844 if ( t4.isCompletelyBinary() ) {
2847 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)" );
2848 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2849 if ( t5.getNumberOfExternalNodes() != 8 ) {
2852 if ( t5.getHeight() != 15 ) {
2855 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)" );
2856 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2857 if ( t6.getHeight() != 15 ) {
2860 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)" );
2861 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2862 if ( t7.getHeight() != 15 ) {
2865 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)" );
2866 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2867 if ( t8.getNumberOfExternalNodes() != 10 ) {
2870 if ( t8.getHeight() != 15 ) {
2873 final char[] a9 = new char[] { 'a' };
2874 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2875 if ( t9.getHeight() != 0 ) {
2878 final char[] a10 = new char[] { 'a', ':', '6' };
2879 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2880 if ( t10.getHeight() != 6 ) {
2884 catch ( final Exception e ) {
2885 e.printStackTrace( System.out );
2891 private static boolean testConfidenceAssessor() {
2893 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2894 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2895 final Phylogeny[] ev0 = factory
2896 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2898 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2899 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2902 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2905 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2906 final Phylogeny[] ev1 = factory
2907 .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)));",
2909 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2910 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2913 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2916 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2917 final Phylogeny[] ev_b = factory
2918 .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",
2920 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2921 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2924 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2928 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2929 final Phylogeny[] ev1x = factory
2930 .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)));",
2932 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2933 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2936 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2939 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2940 final Phylogeny[] ev_bx = factory
2941 .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",
2943 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2944 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2947 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2951 final Phylogeny[] t2 = factory
2952 .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);",
2954 final Phylogeny[] ev2 = factory
2955 .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);",
2957 for( final Phylogeny target : t2 ) {
2958 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2961 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2962 new NHXParser() )[ 0 ];
2963 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2964 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2965 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2968 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2971 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2975 catch ( final Exception e ) {
2976 e.printStackTrace();
2982 private static boolean testCopyOfNodeData() {
2984 final PhylogenyNode n1 = PhylogenyNode
2985 .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]" );
2986 final PhylogenyNode n2 = n1.copyNodeData();
2987 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2991 catch ( final Exception e ) {
2992 e.printStackTrace();
2998 private static boolean testCreateBalancedPhylogeny() {
3000 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3001 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3004 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3007 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3008 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3011 if ( p1.getNumberOfExternalNodes() != 100 ) {
3015 catch ( final Exception e ) {
3016 e.printStackTrace();
3022 private static boolean testCreateUriForSeqWeb() {
3024 final PhylogenyNode n = new PhylogenyNode();
3025 n.setName( "tr|B3RJ64" );
3026 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3029 n.setName( "B0LM41_HUMAN" );
3030 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3033 n.setName( "NP_001025424" );
3034 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3037 n.setName( "_NM_001030253-" );
3038 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3041 n.setName( "XM_002122186" );
3042 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3045 n.setName( "dgh_AAA34956_gdg" );
3046 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3049 n.setName( "AAA34956" );
3050 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3053 n.setName( "GI:394892" );
3054 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3055 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3058 n.setName( "gi_394892" );
3059 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3060 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3063 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3064 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3065 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3068 n.setName( "P12345" );
3069 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3070 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3073 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3074 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3075 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3079 catch ( final Exception e ) {
3080 e.printStackTrace( System.out );
3086 private static boolean testDataObjects() {
3088 final Confidence s0 = new Confidence();
3089 final Confidence s1 = new Confidence();
3090 if ( !s0.isEqual( s1 ) ) {
3093 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3094 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3095 if ( s2.isEqual( s1 ) ) {
3098 if ( !s2.isEqual( s3 ) ) {
3101 final Confidence s4 = ( Confidence ) s3.copy();
3102 if ( !s4.isEqual( s3 ) ) {
3109 final Taxonomy t1 = new Taxonomy();
3110 final Taxonomy t2 = new Taxonomy();
3111 final Taxonomy t3 = new Taxonomy();
3112 final Taxonomy t4 = new Taxonomy();
3113 final Taxonomy t5 = new Taxonomy();
3114 t1.setIdentifier( new Identifier( "ecoli" ) );
3115 t1.setTaxonomyCode( "ECOLI" );
3116 t1.setScientificName( "E. coli" );
3117 t1.setCommonName( "coli" );
3118 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3119 if ( !t1.isEqual( t0 ) ) {
3122 t2.setIdentifier( new Identifier( "ecoli" ) );
3123 t2.setTaxonomyCode( "OTHER" );
3124 t2.setScientificName( "what" );
3125 t2.setCommonName( "something" );
3126 if ( !t1.isEqual( t2 ) ) {
3129 t2.setIdentifier( new Identifier( "nemve" ) );
3130 if ( t1.isEqual( t2 ) ) {
3133 t1.setIdentifier( null );
3134 t3.setTaxonomyCode( "ECOLI" );
3135 t3.setScientificName( "what" );
3136 t3.setCommonName( "something" );
3137 if ( !t1.isEqual( t3 ) ) {
3140 t1.setIdentifier( null );
3141 t1.setTaxonomyCode( "" );
3142 t4.setScientificName( "E. ColI" );
3143 t4.setCommonName( "something" );
3144 if ( !t1.isEqual( t4 ) ) {
3147 t4.setScientificName( "B. subtilis" );
3148 t4.setCommonName( "something" );
3149 if ( t1.isEqual( t4 ) ) {
3152 t1.setIdentifier( null );
3153 t1.setTaxonomyCode( "" );
3154 t1.setScientificName( "" );
3155 t5.setCommonName( "COLI" );
3156 if ( !t1.isEqual( t5 ) ) {
3159 t5.setCommonName( "vibrio" );
3160 if ( t1.isEqual( t5 ) ) {
3165 final Identifier id0 = new Identifier( "123", "pfam" );
3166 final Identifier id1 = ( Identifier ) id0.copy();
3167 if ( !id1.isEqual( id1 ) ) {
3170 if ( !id1.isEqual( id0 ) ) {
3173 if ( !id0.isEqual( id1 ) ) {
3180 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3181 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3182 if ( !pd1.isEqual( pd1 ) ) {
3185 if ( !pd1.isEqual( pd0 ) ) {
3190 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3191 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3192 if ( !pd3.isEqual( pd3 ) ) {
3195 if ( !pd2.isEqual( pd3 ) ) {
3198 if ( !pd0.isEqual( pd3 ) ) {
3203 // DomainArchitecture
3204 // ------------------
3205 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3206 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3207 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3208 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3209 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3210 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3215 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3216 if ( ds0.getNumberOfDomains() != 4 ) {
3219 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3220 if ( !ds0.isEqual( ds0 ) ) {
3223 if ( !ds0.isEqual( ds1 ) ) {
3226 if ( ds1.getNumberOfDomains() != 4 ) {
3229 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3234 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3235 if ( ds0.isEqual( ds2 ) ) {
3241 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3242 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3243 System.out.println( ds3.toNHX() );
3246 if ( ds3.getNumberOfDomains() != 3 ) {
3251 final Event e1 = new Event( Event.EventType.fusion );
3252 if ( e1.isDuplication() ) {
3255 if ( !e1.isFusion() ) {
3258 if ( !e1.asText().toString().equals( "fusion" ) ) {
3261 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3264 final Event e11 = new Event( Event.EventType.fusion );
3265 if ( !e11.isEqual( e1 ) ) {
3268 if ( !e11.toNHX().toString().equals( "" ) ) {
3271 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3272 if ( e2.isDuplication() ) {
3275 if ( !e2.isSpeciationOrDuplication() ) {
3278 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3281 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3284 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3287 if ( e11.isEqual( e2 ) ) {
3290 final Event e2c = ( Event ) e2.copy();
3291 if ( !e2c.isEqual( e2 ) ) {
3294 Event e3 = new Event( 1, 2, 3 );
3295 if ( e3.isDuplication() ) {
3298 if ( e3.isSpeciation() ) {
3301 if ( e3.isGeneLoss() ) {
3304 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3307 final Event e3c = ( Event ) e3.copy();
3308 final Event e3cc = ( Event ) e3c.copy();
3309 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3313 if ( !e3c.isEqual( e3cc ) ) {
3316 Event e4 = new Event( 1, 2, 3 );
3317 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3320 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3323 final Event e4c = ( Event ) e4.copy();
3325 final Event e4cc = ( Event ) e4c.copy();
3326 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3329 if ( !e4c.isEqual( e4cc ) ) {
3332 final Event e5 = new Event();
3333 if ( !e5.isUnassigned() ) {
3336 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3339 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3342 final Event e6 = new Event( 1, 0, 0 );
3343 if ( !e6.asText().toString().equals( "duplication" ) ) {
3346 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3349 final Event e7 = new Event( 0, 1, 0 );
3350 if ( !e7.asText().toString().equals( "speciation" ) ) {
3353 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3356 final Event e8 = new Event( 0, 0, 1 );
3357 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3360 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3364 catch ( final Exception e ) {
3365 e.printStackTrace( System.out );
3371 private static boolean testDeletionOfExternalNodes() {
3373 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3374 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3375 final PhylogenyWriter w = new PhylogenyWriter();
3376 if ( t0.isEmpty() ) {
3379 if ( t0.getNumberOfExternalNodes() != 1 ) {
3382 t0.deleteSubtree( t0.getNode( "A" ), false );
3383 if ( t0.getNumberOfExternalNodes() != 0 ) {
3386 if ( !t0.isEmpty() ) {
3389 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3390 if ( t1.getNumberOfExternalNodes() != 2 ) {
3393 t1.deleteSubtree( t1.getNode( "A" ), false );
3394 if ( t1.getNumberOfExternalNodes() != 1 ) {
3397 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3400 t1.deleteSubtree( t1.getNode( "B" ), false );
3401 if ( t1.getNumberOfExternalNodes() != 1 ) {
3404 t1.deleteSubtree( t1.getNode( "r" ), false );
3405 if ( !t1.isEmpty() ) {
3408 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3409 if ( t2.getNumberOfExternalNodes() != 3 ) {
3412 t2.deleteSubtree( t2.getNode( "B" ), false );
3413 if ( t2.getNumberOfExternalNodes() != 2 ) {
3416 t2.toNewHampshireX();
3417 PhylogenyNode n = t2.getNode( "A" );
3418 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3421 t2.deleteSubtree( t2.getNode( "A" ), false );
3422 if ( t2.getNumberOfExternalNodes() != 2 ) {
3425 t2.deleteSubtree( t2.getNode( "C" ), true );
3426 if ( t2.getNumberOfExternalNodes() != 1 ) {
3429 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3430 if ( t3.getNumberOfExternalNodes() != 4 ) {
3433 t3.deleteSubtree( t3.getNode( "B" ), true );
3434 if ( t3.getNumberOfExternalNodes() != 3 ) {
3437 n = t3.getNode( "A" );
3438 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3441 n = n.getNextExternalNode();
3442 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3445 t3.deleteSubtree( t3.getNode( "A" ), true );
3446 if ( t3.getNumberOfExternalNodes() != 2 ) {
3449 n = t3.getNode( "C" );
3450 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3453 t3.deleteSubtree( t3.getNode( "C" ), true );
3454 if ( t3.getNumberOfExternalNodes() != 1 ) {
3457 t3.deleteSubtree( t3.getNode( "D" ), true );
3458 if ( t3.getNumberOfExternalNodes() != 0 ) {
3461 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3462 if ( t4.getNumberOfExternalNodes() != 6 ) {
3465 t4.deleteSubtree( t4.getNode( "B2" ), true );
3466 if ( t4.getNumberOfExternalNodes() != 5 ) {
3469 String s = w.toNewHampshire( t4, true ).toString();
3470 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3473 t4.deleteSubtree( t4.getNode( "B11" ), true );
3474 if ( t4.getNumberOfExternalNodes() != 4 ) {
3477 t4.deleteSubtree( t4.getNode( "C" ), true );
3478 if ( t4.getNumberOfExternalNodes() != 3 ) {
3481 n = t4.getNode( "A" );
3482 n = n.getNextExternalNode();
3483 if ( !n.getName().equals( "B12" ) ) {
3486 n = n.getNextExternalNode();
3487 if ( !n.getName().equals( "D" ) ) {
3490 s = w.toNewHampshire( t4, true ).toString();
3491 if ( !s.equals( "((A,B12),D);" ) ) {
3494 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3495 t5.deleteSubtree( t5.getNode( "A" ), true );
3496 if ( t5.getNumberOfExternalNodes() != 5 ) {
3499 s = w.toNewHampshire( t5, true ).toString();
3500 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3503 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3504 t6.deleteSubtree( t6.getNode( "B11" ), true );
3505 if ( t6.getNumberOfExternalNodes() != 5 ) {
3508 s = w.toNewHampshire( t6, false ).toString();
3509 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3512 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3513 t7.deleteSubtree( t7.getNode( "B12" ), true );
3514 if ( t7.getNumberOfExternalNodes() != 5 ) {
3517 s = w.toNewHampshire( t7, true ).toString();
3518 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3521 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3522 t8.deleteSubtree( t8.getNode( "B2" ), true );
3523 if ( t8.getNumberOfExternalNodes() != 5 ) {
3526 s = w.toNewHampshire( t8, false ).toString();
3527 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3530 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3531 t9.deleteSubtree( t9.getNode( "C" ), true );
3532 if ( t9.getNumberOfExternalNodes() != 5 ) {
3535 s = w.toNewHampshire( t9, true ).toString();
3536 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3539 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3540 t10.deleteSubtree( t10.getNode( "D" ), true );
3541 if ( t10.getNumberOfExternalNodes() != 5 ) {
3544 s = w.toNewHampshire( t10, true ).toString();
3545 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3548 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3549 t11.deleteSubtree( t11.getNode( "A" ), true );
3550 if ( t11.getNumberOfExternalNodes() != 2 ) {
3553 s = w.toNewHampshire( t11, true ).toString();
3554 if ( !s.equals( "(B,C);" ) ) {
3557 t11.deleteSubtree( t11.getNode( "C" ), true );
3558 if ( t11.getNumberOfExternalNodes() != 1 ) {
3561 s = w.toNewHampshire( t11, false ).toString();
3562 if ( !s.equals( "B;" ) ) {
3565 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3566 t12.deleteSubtree( t12.getNode( "B2" ), true );
3567 if ( t12.getNumberOfExternalNodes() != 8 ) {
3570 s = w.toNewHampshire( t12, true ).toString();
3571 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3574 t12.deleteSubtree( t12.getNode( "B3" ), true );
3575 if ( t12.getNumberOfExternalNodes() != 7 ) {
3578 s = w.toNewHampshire( t12, true ).toString();
3579 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3582 t12.deleteSubtree( t12.getNode( "C3" ), true );
3583 if ( t12.getNumberOfExternalNodes() != 6 ) {
3586 s = w.toNewHampshire( t12, true ).toString();
3587 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3590 t12.deleteSubtree( t12.getNode( "A1" ), true );
3591 if ( t12.getNumberOfExternalNodes() != 5 ) {
3594 s = w.toNewHampshire( t12, true ).toString();
3595 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3598 t12.deleteSubtree( t12.getNode( "B1" ), true );
3599 if ( t12.getNumberOfExternalNodes() != 4 ) {
3602 s = w.toNewHampshire( t12, true ).toString();
3603 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3606 t12.deleteSubtree( t12.getNode( "A3" ), true );
3607 if ( t12.getNumberOfExternalNodes() != 3 ) {
3610 s = w.toNewHampshire( t12, true ).toString();
3611 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3614 t12.deleteSubtree( t12.getNode( "A2" ), true );
3615 if ( t12.getNumberOfExternalNodes() != 2 ) {
3618 s = w.toNewHampshire( t12, true ).toString();
3619 if ( !s.equals( "(C1,C2);" ) ) {
3622 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3623 t13.deleteSubtree( t13.getNode( "D" ), true );
3624 if ( t13.getNumberOfExternalNodes() != 4 ) {
3627 s = w.toNewHampshire( t13, true ).toString();
3628 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3631 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3632 t14.deleteSubtree( t14.getNode( "E" ), true );
3633 if ( t14.getNumberOfExternalNodes() != 5 ) {
3636 s = w.toNewHampshire( t14, true ).toString();
3637 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3640 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3641 t15.deleteSubtree( t15.getNode( "B2" ), true );
3642 if ( t15.getNumberOfExternalNodes() != 11 ) {
3645 t15.deleteSubtree( t15.getNode( "B1" ), true );
3646 if ( t15.getNumberOfExternalNodes() != 10 ) {
3649 t15.deleteSubtree( t15.getNode( "B3" ), true );
3650 if ( t15.getNumberOfExternalNodes() != 9 ) {
3653 t15.deleteSubtree( t15.getNode( "B4" ), true );
3654 if ( t15.getNumberOfExternalNodes() != 8 ) {
3657 t15.deleteSubtree( t15.getNode( "A1" ), true );
3658 if ( t15.getNumberOfExternalNodes() != 7 ) {
3661 t15.deleteSubtree( t15.getNode( "C4" ), true );
3662 if ( t15.getNumberOfExternalNodes() != 6 ) {
3666 catch ( final Exception e ) {
3667 e.printStackTrace( System.out );
3673 private static boolean testDescriptiveStatistics() {
3675 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3676 dss1.addValue( 82 );
3677 dss1.addValue( 78 );
3678 dss1.addValue( 70 );
3679 dss1.addValue( 58 );
3680 dss1.addValue( 42 );
3681 if ( dss1.getN() != 5 ) {
3684 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3687 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3690 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3693 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3696 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3699 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3702 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3705 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3708 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3711 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3714 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3717 dss1.addValue( 123 );
3718 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3721 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3724 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3727 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3728 dss2.addValue( -1.85 );
3729 dss2.addValue( 57.5 );
3730 dss2.addValue( 92.78 );
3731 dss2.addValue( 57.78 );
3732 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3735 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3738 final double[] a = dss2.getDataAsDoubleArray();
3739 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3742 dss2.addValue( -100 );
3743 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3746 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3749 final double[] ds = new double[ 14 ];
3764 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3765 if ( bins.length != 4 ) {
3768 if ( bins[ 0 ] != 2 ) {
3771 if ( bins[ 1 ] != 3 ) {
3774 if ( bins[ 2 ] != 4 ) {
3777 if ( bins[ 3 ] != 5 ) {
3780 final double[] ds1 = new double[ 9 ];
3790 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3791 if ( bins1.length != 4 ) {
3794 if ( bins1[ 0 ] != 2 ) {
3797 if ( bins1[ 1 ] != 3 ) {
3800 if ( bins1[ 2 ] != 0 ) {
3803 if ( bins1[ 3 ] != 4 ) {
3806 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3807 if ( bins1_1.length != 3 ) {
3810 if ( bins1_1[ 0 ] != 3 ) {
3813 if ( bins1_1[ 1 ] != 2 ) {
3816 if ( bins1_1[ 2 ] != 4 ) {
3819 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3820 if ( bins1_2.length != 3 ) {
3823 if ( bins1_2[ 0 ] != 2 ) {
3826 if ( bins1_2[ 1 ] != 2 ) {
3829 if ( bins1_2[ 2 ] != 2 ) {
3832 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3846 dss3.addValue( 10 );
3847 dss3.addValue( 10 );
3848 dss3.addValue( 10 );
3849 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3850 histo.toStringBuffer( 10, '=', 40, 5 );
3851 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3853 catch ( final Exception e ) {
3854 e.printStackTrace( System.out );
3860 private static boolean testDir( final String file ) {
3862 final File f = new File( file );
3863 if ( !f.exists() ) {
3866 if ( !f.isDirectory() ) {
3869 if ( !f.canRead() ) {
3873 catch ( final Exception e ) {
3879 private static boolean testEbiEntryRetrieval() {
3881 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3882 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3883 System.out.println( entry.getAccession() );
3886 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3887 System.out.println( entry.getTaxonomyScientificName() );
3890 if ( !entry.getSequenceName()
3891 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3892 System.out.println( entry.getSequenceName() );
3895 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3896 // System.out.println( entry.getSequenceSymbol() );
3899 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3900 System.out.println( entry.getGeneName() );
3903 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3904 System.out.println( entry.getTaxonomyIdentifier() );
3907 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3908 System.out.println( entry.getAnnotations().first().getRefValue() );
3911 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3912 System.out.println( entry.getAnnotations().first().getRefSource() );
3915 if ( entry.getCrossReferences().size() != 5 ) {
3919 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3920 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3923 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3924 System.out.println( entry1.getTaxonomyScientificName() );
3927 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3928 System.out.println( entry1.getSequenceName() );
3931 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3932 System.out.println( entry1.getTaxonomyIdentifier() );
3935 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3936 System.out.println( entry1.getGeneName() );
3939 if ( entry1.getCrossReferences().size() != 6 ) {
3943 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3944 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3947 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3948 System.out.println( entry2.getTaxonomyScientificName() );
3951 if ( !entry2.getSequenceName()
3952 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3953 System.out.println( entry2.getSequenceName() );
3956 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3957 System.out.println( entry2.getTaxonomyIdentifier() );
3960 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3961 System.out.println( entry2.getGeneName() );
3964 if ( entry2.getCrossReferences().size() != 3 ) {
3968 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3969 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3972 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3973 System.out.println( entry3.getTaxonomyScientificName() );
3976 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3977 System.out.println( entry3.getSequenceName() );
3980 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3981 System.out.println( entry3.getTaxonomyIdentifier() );
3984 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3985 System.out.println( entry3.getSequenceSymbol() );
3988 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3991 if ( entry3.getCrossReferences().size() != 8 ) {
3996 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3997 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4000 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4001 System.out.println( entry4.getTaxonomyScientificName() );
4004 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4005 System.out.println( entry4.getSequenceName() );
4008 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4009 System.out.println( entry4.getTaxonomyIdentifier() );
4012 if ( !entry4.getGeneName().equals( "ras" ) ) {
4013 System.out.println( entry4.getGeneName() );
4016 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4017 // System.out.println( entry4.getChromosome() );
4020 // if ( !entry4.getMap().equals( "ras" ) ) {
4021 // System.out.println( entry4.getMap() );
4027 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4028 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4031 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4032 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4035 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4036 System.out.println( entry5.getTaxonomyScientificName() );
4039 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4040 System.out.println( entry5.getSequenceName() );
4043 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4044 System.out.println( entry5.getTaxonomyIdentifier() );
4048 catch ( final IOException e ) {
4049 System.out.println();
4050 System.out.println( "the following might be due to absence internet connection:" );
4051 e.printStackTrace( System.out );
4054 catch ( final Exception e ) {
4055 e.printStackTrace();
4061 private static boolean testExternalNodeRelatedMethods() {
4063 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4064 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4065 PhylogenyNode n = t1.getNode( "A" );
4066 n = n.getNextExternalNode();
4067 if ( !n.getName().equals( "B" ) ) {
4070 n = n.getNextExternalNode();
4071 if ( !n.getName().equals( "C" ) ) {
4074 n = n.getNextExternalNode();
4075 if ( !n.getName().equals( "D" ) ) {
4078 n = t1.getNode( "B" );
4079 while ( !n.isLastExternalNode() ) {
4080 n = n.getNextExternalNode();
4082 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4083 n = t2.getNode( "A" );
4084 n = n.getNextExternalNode();
4085 if ( !n.getName().equals( "B" ) ) {
4088 n = n.getNextExternalNode();
4089 if ( !n.getName().equals( "C" ) ) {
4092 n = n.getNextExternalNode();
4093 if ( !n.getName().equals( "D" ) ) {
4096 n = t2.getNode( "B" );
4097 while ( !n.isLastExternalNode() ) {
4098 n = n.getNextExternalNode();
4100 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4101 n = t3.getNode( "A" );
4102 n = n.getNextExternalNode();
4103 if ( !n.getName().equals( "B" ) ) {
4106 n = n.getNextExternalNode();
4107 if ( !n.getName().equals( "C" ) ) {
4110 n = n.getNextExternalNode();
4111 if ( !n.getName().equals( "D" ) ) {
4114 n = n.getNextExternalNode();
4115 if ( !n.getName().equals( "E" ) ) {
4118 n = n.getNextExternalNode();
4119 if ( !n.getName().equals( "F" ) ) {
4122 n = n.getNextExternalNode();
4123 if ( !n.getName().equals( "G" ) ) {
4126 n = n.getNextExternalNode();
4127 if ( !n.getName().equals( "H" ) ) {
4130 n = t3.getNode( "B" );
4131 while ( !n.isLastExternalNode() ) {
4132 n = n.getNextExternalNode();
4134 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4135 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4136 final PhylogenyNode node = iter.next();
4138 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4139 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4140 final PhylogenyNode node = iter.next();
4142 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4143 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4144 if ( !iter.next().getName().equals( "A" ) ) {
4147 if ( !iter.next().getName().equals( "B" ) ) {
4150 if ( !iter.next().getName().equals( "C" ) ) {
4153 if ( !iter.next().getName().equals( "D" ) ) {
4156 if ( !iter.next().getName().equals( "E" ) ) {
4159 if ( !iter.next().getName().equals( "F" ) ) {
4162 if ( iter.hasNext() ) {
4166 catch ( final Exception e ) {
4167 e.printStackTrace( System.out );
4173 private static boolean testExtractSNFromNodeName() {
4175 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4178 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4181 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4184 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4185 .equals( "Mus musculus musculus" ) ) {
4188 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4189 .equals( "Mus musculus musculus" ) ) {
4192 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4193 .equals( "Mus musculus musculus" ) ) {
4196 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4197 .equals( "Mus musculus musculus" ) ) {
4200 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4203 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4204 .equals( "Mus musculus musculus" ) ) {
4207 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4208 .equals( "Mus musculus musculus" ) ) {
4211 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4214 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4217 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4220 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4223 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4224 .equals( "Mus musculus musculus" ) ) {
4227 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4230 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4233 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4236 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4239 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4242 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4245 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4248 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4251 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4252 .equals( "Mus musculus" ) ) {
4255 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4256 .equals( "Mus musculus" ) ) {
4259 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4262 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4263 .equals( "Mus musculus musculus" ) ) {
4266 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4267 .equals( "Mus musculus musculus" ) ) {
4270 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4271 .equals( "Mus musculus musculus" ) ) {
4274 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4277 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4278 .equals( "Pilostyles mexicana" ) ) {
4281 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4282 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4285 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4286 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4289 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4290 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4293 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4294 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4297 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4298 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4301 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4302 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4305 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4306 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4309 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4310 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4313 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4314 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4317 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4318 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4321 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4322 .equals( "Escherichia coli (strain K12)" ) ) {
4325 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4326 .equals( "Escherichia coli (strain K12)" ) ) {
4329 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4330 .equals( "Escherichia coli (str. K12)" ) ) {
4333 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4334 .equals( "Escherichia coli (str. K12)" ) ) {
4337 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4338 .equals( "Escherichia coli (str. K12)" ) ) {
4341 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4342 .equals( "Escherichia coli (var. K12)" ) ) {
4345 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4346 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4349 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4350 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4354 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4355 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4358 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4359 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4363 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4364 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4367 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4368 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4371 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4372 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4375 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4378 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4381 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4384 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4385 .equals( "Macrocera sp." ) ) {
4388 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4391 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4392 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4395 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4396 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4399 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4400 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4403 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4404 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4408 catch ( final Exception e ) {
4409 e.printStackTrace( System.out );
4415 private static boolean testExtractTaxonomyCodeFromNodeName() {
4417 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4420 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4421 .equals( "SOYBN" ) ) {
4424 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4425 .equals( "ARATH" ) ) {
4428 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4429 .equals( "ARATH" ) ) {
4432 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4435 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4438 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4441 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4442 .equals( "SOYBN" ) ) {
4445 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4446 .equals( "SOYBN" ) ) {
4449 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4450 .equals( "SOYBN" ) ) {
4453 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4454 .equals( "SOYBN" ) ) {
4457 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4458 .equals( "SOYBN" ) ) {
4461 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4462 .equals( "SOYBN" ) ) {
4465 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4466 .equals( "SOYBN" ) ) {
4469 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4470 .equals( "SOYBN" ) ) {
4473 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4476 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4477 .equals( "SOYBN" ) ) {
4480 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4481 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4484 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4485 .equals( "9YX45" ) ) {
4488 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4489 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4490 .equals( "MOUSE" ) ) {
4493 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4494 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4495 .equals( "MOUSE" ) ) {
4498 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4499 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4500 .equals( "MOUSE" ) ) {
4503 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4504 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4507 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4508 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4511 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4512 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4515 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4516 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4519 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4520 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4523 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4524 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4527 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4528 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4531 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4532 .equals( "RAT" ) ) {
4535 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4536 .equals( "PIG" ) ) {
4540 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4541 .equals( "MOUSE" ) ) {
4544 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4545 .equals( "MOUSE" ) ) {
4548 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4552 catch ( final Exception e ) {
4553 e.printStackTrace( System.out );
4559 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4561 PhylogenyNode n = new PhylogenyNode();
4562 n.setName( "tr|B3RJ64" );
4563 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4566 n.setName( "tr.B3RJ64" );
4567 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4570 n.setName( "tr=B3RJ64" );
4571 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4574 n.setName( "tr-B3RJ64" );
4575 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4578 n.setName( "tr/B3RJ64" );
4579 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4582 n.setName( "tr\\B3RJ64" );
4583 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4586 n.setName( "tr_B3RJ64" );
4587 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4590 n.setName( " tr|B3RJ64 " );
4591 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4594 n.setName( "-tr|B3RJ64-" );
4595 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4598 n.setName( "-tr=B3RJ64-" );
4599 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4602 n.setName( "_tr=B3RJ64_" );
4603 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4606 n.setName( " tr_tr|B3RJ64_sp|123 " );
4607 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4610 n.setName( "B3RJ64" );
4611 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4614 n.setName( "sp|B3RJ64" );
4615 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4618 n.setName( "sp|B3RJ64C" );
4619 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4622 n.setName( "sp B3RJ64" );
4623 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4626 n.setName( "sp|B3RJ6X" );
4627 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4630 n.setName( "sp|B3RJ6" );
4631 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4634 n.setName( "K1PYK7_CRAGI" );
4635 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4638 n.setName( "K1PYK7_PEA" );
4639 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4642 n.setName( "K1PYK7_RAT" );
4643 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4646 n.setName( "K1PYK7_PIG" );
4647 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4650 n.setName( "~K1PYK7_PIG~" );
4651 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4654 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4655 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4658 n.setName( "K1PYKX_CRAGI" );
4659 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4662 n.setName( "XXXXX_CRAGI" );
4663 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4666 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4667 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4670 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4671 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4674 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4675 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4678 n = new PhylogenyNode();
4679 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4680 seq.setSymbol( "K1PYK7_CRAGI" );
4681 n.getNodeData().addSequence( seq );
4682 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4685 seq.setSymbol( "tr|B3RJ64" );
4686 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4689 n = new PhylogenyNode();
4690 seq = new org.forester.phylogeny.data.Sequence();
4691 seq.setName( "K1PYK7_CRAGI" );
4692 n.getNodeData().addSequence( seq );
4693 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4696 seq.setName( "tr|B3RJ64" );
4697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4700 n = new PhylogenyNode();
4701 seq = new org.forester.phylogeny.data.Sequence();
4702 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4703 n.getNodeData().addSequence( seq );
4704 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4707 n = new PhylogenyNode();
4708 seq = new org.forester.phylogeny.data.Sequence();
4709 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4710 n.getNodeData().addSequence( seq );
4711 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4715 n = new PhylogenyNode();
4716 n.setName( "ACP19736" );
4717 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4720 n = new PhylogenyNode();
4721 n.setName( "|ACP19736|" );
4722 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4726 catch ( final Exception e ) {
4727 e.printStackTrace( System.out );
4733 private static boolean testFastaParser() {
4735 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4738 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4741 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4742 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4745 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4748 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4751 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4754 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4757 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4761 catch ( final Exception e ) {
4762 e.printStackTrace();
4768 private static boolean testGenbankAccessorParsing() {
4769 //The format for GenBank Accession numbers are:
4770 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4771 //Protein: 3 letters + 5 numerals
4772 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4773 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4776 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4779 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4782 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4785 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4788 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4791 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4794 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4797 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4800 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4803 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4806 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4809 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4812 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4818 private static boolean testGeneralMsaParser() {
4820 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4821 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4822 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4823 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4824 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4825 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4826 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4827 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4828 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4831 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4834 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4837 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4840 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4843 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4846 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4849 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4852 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4855 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4858 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4861 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4864 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4865 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4868 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4871 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4874 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4875 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4878 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4881 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4884 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4885 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4888 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4891 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4895 catch ( final Exception e ) {
4896 e.printStackTrace();
4902 private static boolean testGeneralTable() {
4904 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4905 t0.setValue( 3, 2, "23" );
4906 t0.setValue( 10, 1, "error" );
4907 t0.setValue( 10, 1, "110" );
4908 t0.setValue( 9, 1, "19" );
4909 t0.setValue( 1, 10, "101" );
4910 t0.setValue( 10, 10, "1010" );
4911 t0.setValue( 100, 10, "10100" );
4912 t0.setValue( 0, 0, "00" );
4913 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4916 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4919 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4922 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4925 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4928 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4931 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4934 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4937 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4940 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4941 t1.setValue( "3", "2", "23" );
4942 t1.setValue( "10", "1", "error" );
4943 t1.setValue( "10", "1", "110" );
4944 t1.setValue( "9", "1", "19" );
4945 t1.setValue( "1", "10", "101" );
4946 t1.setValue( "10", "10", "1010" );
4947 t1.setValue( "100", "10", "10100" );
4948 t1.setValue( "0", "0", "00" );
4949 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4950 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4953 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4956 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4959 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4962 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4965 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4968 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4971 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4974 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4977 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4981 catch ( final Exception e ) {
4982 e.printStackTrace( System.out );
4988 private static boolean testGetDistance() {
4990 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4991 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",
4992 new NHXParser() )[ 0 ];
4993 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4996 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4999 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5002 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5005 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5008 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5011 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5014 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5017 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5020 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5023 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5026 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5029 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5032 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5035 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5038 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5041 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5044 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5047 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5050 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5053 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5056 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5059 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5062 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5065 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5068 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5071 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5074 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5077 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5080 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5083 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5086 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",
5087 new NHXParser() )[ 0 ];
5088 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5091 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5094 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5097 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5100 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5103 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5106 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5109 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5112 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5115 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5118 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5122 catch ( final Exception e ) {
5123 e.printStackTrace( System.out );
5129 private static boolean testGetLCA() {
5131 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5132 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5133 new NHXParser() )[ 0 ];
5134 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5135 if ( !A.getName().equals( "A" ) ) {
5138 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5139 if ( !gh.getName().equals( "gh" ) ) {
5142 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5143 if ( !ab.getName().equals( "ab" ) ) {
5146 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5147 if ( !ab2.getName().equals( "ab" ) ) {
5150 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5151 if ( !gh2.getName().equals( "gh" ) ) {
5154 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5155 if ( !gh3.getName().equals( "gh" ) ) {
5158 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5159 if ( !abc.getName().equals( "abc" ) ) {
5162 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5163 if ( !abc2.getName().equals( "abc" ) ) {
5166 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5167 if ( !abcd.getName().equals( "abcd" ) ) {
5170 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5171 if ( !abcd2.getName().equals( "abcd" ) ) {
5174 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5175 if ( !abcdef.getName().equals( "abcdef" ) ) {
5178 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5179 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5182 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5183 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5186 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5187 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5190 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5191 if ( !abcde.getName().equals( "abcde" ) ) {
5194 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5195 if ( !abcde2.getName().equals( "abcde" ) ) {
5198 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5199 if ( !r.getName().equals( "abcdefgh" ) ) {
5202 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5203 if ( !r2.getName().equals( "abcdefgh" ) ) {
5206 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5207 if ( !r3.getName().equals( "abcdefgh" ) ) {
5210 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5211 if ( !abcde3.getName().equals( "abcde" ) ) {
5214 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5215 if ( !abcde4.getName().equals( "abcde" ) ) {
5218 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5219 if ( !ab3.getName().equals( "ab" ) ) {
5222 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5223 if ( !ab4.getName().equals( "ab" ) ) {
5226 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5227 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5228 if ( !cd.getName().equals( "cd" ) ) {
5231 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5232 if ( !cd2.getName().equals( "cd" ) ) {
5235 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5236 if ( !cde.getName().equals( "cde" ) ) {
5239 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5240 if ( !cde2.getName().equals( "cde" ) ) {
5243 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5244 if ( !cdef.getName().equals( "cdef" ) ) {
5247 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5248 if ( !cdef2.getName().equals( "cdef" ) ) {
5251 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5252 if ( !cdef3.getName().equals( "cdef" ) ) {
5255 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5256 if ( !rt.getName().equals( "r" ) ) {
5259 final Phylogeny p3 = factory
5260 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5261 new NHXParser() )[ 0 ];
5262 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5263 if ( !bc_3.getName().equals( "bc" ) ) {
5266 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5267 if ( !ac_3.getName().equals( "abc" ) ) {
5270 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5271 if ( !ad_3.getName().equals( "abcde" ) ) {
5274 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5275 if ( !af_3.getName().equals( "abcdef" ) ) {
5278 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5279 if ( !ag_3.getName().equals( "" ) ) {
5282 if ( !ag_3.isRoot() ) {
5285 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5286 if ( !al_3.getName().equals( "" ) ) {
5289 if ( !al_3.isRoot() ) {
5292 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5293 if ( !kl_3.getName().equals( "" ) ) {
5296 if ( !kl_3.isRoot() ) {
5299 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5300 if ( !fl_3.getName().equals( "" ) ) {
5303 if ( !fl_3.isRoot() ) {
5306 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5307 if ( !gk_3.getName().equals( "ghijk" ) ) {
5310 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5311 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5312 if ( !r_4.getName().equals( "r" ) ) {
5315 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5316 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5317 if ( !r_5.getName().equals( "root" ) ) {
5320 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5321 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5322 if ( !r_6.getName().equals( "rot" ) ) {
5325 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5326 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5327 if ( !r_7.getName().equals( "rott" ) ) {
5331 catch ( final Exception e ) {
5332 e.printStackTrace( System.out );
5338 private static boolean testGetLCA2() {
5340 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5341 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5342 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5343 PhylogenyMethods.preOrderReId( p_a );
5344 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5345 p_a.getNode( "a" ) );
5346 if ( !p_a_1.getName().equals( "a" ) ) {
5349 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5350 PhylogenyMethods.preOrderReId( p_b );
5351 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5352 p_b.getNode( "a" ) );
5353 if ( !p_b_1.getName().equals( "b" ) ) {
5356 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5357 p_b.getNode( "b" ) );
5358 if ( !p_b_2.getName().equals( "b" ) ) {
5361 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5362 PhylogenyMethods.preOrderReId( p_c );
5363 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5364 p_c.getNode( "a" ) );
5365 if ( !p_c_1.getName().equals( "b" ) ) {
5368 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5369 p_c.getNode( "c" ) );
5370 if ( !p_c_2.getName().equals( "c" ) ) {
5371 System.out.println( p_c_2.getName() );
5375 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5376 p_c.getNode( "b" ) );
5377 if ( !p_c_3.getName().equals( "b" ) ) {
5380 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5381 p_c.getNode( "a" ) );
5382 if ( !p_c_4.getName().equals( "c" ) ) {
5385 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5386 new NHXParser() )[ 0 ];
5387 PhylogenyMethods.preOrderReId( p1 );
5388 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5389 p1.getNode( "A" ) );
5390 if ( !A.getName().equals( "A" ) ) {
5393 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5394 p1.getNode( "gh" ) );
5395 if ( !gh.getName().equals( "gh" ) ) {
5398 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5399 p1.getNode( "B" ) );
5400 if ( !ab.getName().equals( "ab" ) ) {
5403 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5404 p1.getNode( "A" ) );
5405 if ( !ab2.getName().equals( "ab" ) ) {
5408 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5409 p1.getNode( "G" ) );
5410 if ( !gh2.getName().equals( "gh" ) ) {
5413 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5414 p1.getNode( "H" ) );
5415 if ( !gh3.getName().equals( "gh" ) ) {
5418 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5419 p1.getNode( "A" ) );
5420 if ( !abc.getName().equals( "abc" ) ) {
5423 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5424 p1.getNode( "C" ) );
5425 if ( !abc2.getName().equals( "abc" ) ) {
5428 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5429 p1.getNode( "D" ) );
5430 if ( !abcd.getName().equals( "abcd" ) ) {
5433 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5434 p1.getNode( "A" ) );
5435 if ( !abcd2.getName().equals( "abcd" ) ) {
5438 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5439 p1.getNode( "F" ) );
5440 if ( !abcdef.getName().equals( "abcdef" ) ) {
5443 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5444 p1.getNode( "A" ) );
5445 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5448 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5449 p1.getNode( "F" ) );
5450 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5453 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5454 p1.getNode( "ab" ) );
5455 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5458 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5459 p1.getNode( "E" ) );
5460 if ( !abcde.getName().equals( "abcde" ) ) {
5463 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5464 p1.getNode( "A" ) );
5465 if ( !abcde2.getName().equals( "abcde" ) ) {
5468 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5469 p1.getNode( "abcdefgh" ) );
5470 if ( !r.getName().equals( "abcdefgh" ) ) {
5473 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5474 p1.getNode( "H" ) );
5475 if ( !r2.getName().equals( "abcdefgh" ) ) {
5478 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5479 p1.getNode( "A" ) );
5480 if ( !r3.getName().equals( "abcdefgh" ) ) {
5483 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5484 p1.getNode( "abcde" ) );
5485 if ( !abcde3.getName().equals( "abcde" ) ) {
5488 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5489 p1.getNode( "E" ) );
5490 if ( !abcde4.getName().equals( "abcde" ) ) {
5493 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5494 p1.getNode( "B" ) );
5495 if ( !ab3.getName().equals( "ab" ) ) {
5498 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5499 p1.getNode( "ab" ) );
5500 if ( !ab4.getName().equals( "ab" ) ) {
5503 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5504 PhylogenyMethods.preOrderReId( p2 );
5505 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5506 p2.getNode( "d" ) );
5507 if ( !cd.getName().equals( "cd" ) ) {
5510 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5511 p2.getNode( "c" ) );
5512 if ( !cd2.getName().equals( "cd" ) ) {
5515 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5516 p2.getNode( "e" ) );
5517 if ( !cde.getName().equals( "cde" ) ) {
5520 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5521 p2.getNode( "c" ) );
5522 if ( !cde2.getName().equals( "cde" ) ) {
5525 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5526 p2.getNode( "f" ) );
5527 if ( !cdef.getName().equals( "cdef" ) ) {
5530 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5531 p2.getNode( "f" ) );
5532 if ( !cdef2.getName().equals( "cdef" ) ) {
5535 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5536 p2.getNode( "d" ) );
5537 if ( !cdef3.getName().equals( "cdef" ) ) {
5540 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5541 p2.getNode( "a" ) );
5542 if ( !rt.getName().equals( "r" ) ) {
5545 final Phylogeny p3 = factory
5546 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5547 new NHXParser() )[ 0 ];
5548 PhylogenyMethods.preOrderReId( p3 );
5549 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5550 p3.getNode( "c" ) );
5551 if ( !bc_3.getName().equals( "bc" ) ) {
5554 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5555 p3.getNode( "c" ) );
5556 if ( !ac_3.getName().equals( "abc" ) ) {
5559 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5560 p3.getNode( "d" ) );
5561 if ( !ad_3.getName().equals( "abcde" ) ) {
5564 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5565 p3.getNode( "f" ) );
5566 if ( !af_3.getName().equals( "abcdef" ) ) {
5569 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5570 p3.getNode( "g" ) );
5571 if ( !ag_3.getName().equals( "" ) ) {
5574 if ( !ag_3.isRoot() ) {
5577 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5578 p3.getNode( "l" ) );
5579 if ( !al_3.getName().equals( "" ) ) {
5582 if ( !al_3.isRoot() ) {
5585 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5586 p3.getNode( "l" ) );
5587 if ( !kl_3.getName().equals( "" ) ) {
5590 if ( !kl_3.isRoot() ) {
5593 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5594 p3.getNode( "l" ) );
5595 if ( !fl_3.getName().equals( "" ) ) {
5598 if ( !fl_3.isRoot() ) {
5601 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5602 p3.getNode( "k" ) );
5603 if ( !gk_3.getName().equals( "ghijk" ) ) {
5606 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5607 PhylogenyMethods.preOrderReId( p4 );
5608 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5609 p4.getNode( "c" ) );
5610 if ( !r_4.getName().equals( "r" ) ) {
5613 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5614 PhylogenyMethods.preOrderReId( p5 );
5615 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5616 p5.getNode( "c" ) );
5617 if ( !r_5.getName().equals( "root" ) ) {
5620 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5621 PhylogenyMethods.preOrderReId( p6 );
5622 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5623 p6.getNode( "a" ) );
5624 if ( !r_6.getName().equals( "rot" ) ) {
5627 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5628 PhylogenyMethods.preOrderReId( p7 );
5629 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5630 p7.getNode( "e" ) );
5631 if ( !r_7.getName().equals( "rott" ) ) {
5634 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5635 p7.getNode( "a" ) );
5636 if ( !r_71.getName().equals( "rott" ) ) {
5639 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5640 p7.getNode( "rott" ) );
5641 if ( !r_72.getName().equals( "rott" ) ) {
5644 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5645 p7.getNode( "a" ) );
5646 if ( !r_73.getName().equals( "rott" ) ) {
5649 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5650 p7.getNode( "rott" ) );
5651 if ( !r_74.getName().equals( "rott" ) ) {
5654 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5655 p7.getNode( "e" ) );
5656 if ( !r_75.getName().equals( "e" ) ) {
5660 catch ( final Exception e ) {
5661 e.printStackTrace( System.out );
5667 private static boolean testHmmscanOutputParser() {
5668 final String test_dir = Test.PATH_TO_TEST_DATA;
5670 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5671 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5673 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5674 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5675 final List<Protein> proteins = parser2.parse();
5676 if ( parser2.getProteinsEncountered() != 4 ) {
5679 if ( proteins.size() != 4 ) {
5682 if ( parser2.getDomainsEncountered() != 69 ) {
5685 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5688 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5691 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5694 final Protein p1 = proteins.get( 0 );
5695 if ( p1.getNumberOfProteinDomains() != 15 ) {
5698 if ( p1.getLength() != 850 ) {
5701 final Protein p2 = proteins.get( 1 );
5702 if ( p2.getNumberOfProteinDomains() != 51 ) {
5705 if ( p2.getLength() != 1291 ) {
5708 final Protein p3 = proteins.get( 2 );
5709 if ( p3.getNumberOfProteinDomains() != 2 ) {
5712 final Protein p4 = proteins.get( 3 );
5713 if ( p4.getNumberOfProteinDomains() != 1 ) {
5716 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5719 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5722 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5725 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5728 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5731 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5734 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5738 catch ( final Exception e ) {
5739 e.printStackTrace( System.out );
5745 private static boolean testLastExternalNodeMethods() {
5747 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5748 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5749 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5750 final PhylogenyNode n1 = t0.getNode( "A" );
5751 if ( n1.isLastExternalNode() ) {
5754 final PhylogenyNode n2 = t0.getNode( "B" );
5755 if ( n2.isLastExternalNode() ) {
5758 final PhylogenyNode n3 = t0.getNode( "C" );
5759 if ( n3.isLastExternalNode() ) {
5762 final PhylogenyNode n4 = t0.getNode( "D" );
5763 if ( !n4.isLastExternalNode() ) {
5767 catch ( final Exception e ) {
5768 e.printStackTrace( System.out );
5774 private static boolean testLevelOrderIterator() {
5776 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5777 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5778 PhylogenyNodeIterator it0;
5779 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5782 for( it0.reset(); it0.hasNext(); ) {
5785 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5786 if ( !it.next().getName().equals( "r" ) ) {
5789 if ( !it.next().getName().equals( "ab" ) ) {
5792 if ( !it.next().getName().equals( "cd" ) ) {
5795 if ( !it.next().getName().equals( "A" ) ) {
5798 if ( !it.next().getName().equals( "B" ) ) {
5801 if ( !it.next().getName().equals( "C" ) ) {
5804 if ( !it.next().getName().equals( "D" ) ) {
5807 if ( it.hasNext() ) {
5810 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",
5811 new NHXParser() )[ 0 ];
5812 PhylogenyNodeIterator it2;
5813 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5816 for( it2.reset(); it2.hasNext(); ) {
5819 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5820 if ( !it3.next().getName().equals( "r" ) ) {
5823 if ( !it3.next().getName().equals( "abc" ) ) {
5826 if ( !it3.next().getName().equals( "defg" ) ) {
5829 if ( !it3.next().getName().equals( "A" ) ) {
5832 if ( !it3.next().getName().equals( "B" ) ) {
5835 if ( !it3.next().getName().equals( "C" ) ) {
5838 if ( !it3.next().getName().equals( "D" ) ) {
5841 if ( !it3.next().getName().equals( "E" ) ) {
5844 if ( !it3.next().getName().equals( "F" ) ) {
5847 if ( !it3.next().getName().equals( "G" ) ) {
5850 if ( !it3.next().getName().equals( "1" ) ) {
5853 if ( !it3.next().getName().equals( "2" ) ) {
5856 if ( !it3.next().getName().equals( "3" ) ) {
5859 if ( !it3.next().getName().equals( "4" ) ) {
5862 if ( !it3.next().getName().equals( "5" ) ) {
5865 if ( !it3.next().getName().equals( "6" ) ) {
5868 if ( !it3.next().getName().equals( "f1" ) ) {
5871 if ( !it3.next().getName().equals( "f2" ) ) {
5874 if ( !it3.next().getName().equals( "f3" ) ) {
5877 if ( !it3.next().getName().equals( "a" ) ) {
5880 if ( !it3.next().getName().equals( "b" ) ) {
5883 if ( !it3.next().getName().equals( "f21" ) ) {
5886 if ( !it3.next().getName().equals( "X" ) ) {
5889 if ( !it3.next().getName().equals( "Y" ) ) {
5892 if ( !it3.next().getName().equals( "Z" ) ) {
5895 if ( it3.hasNext() ) {
5898 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5899 PhylogenyNodeIterator it4;
5900 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5903 for( it4.reset(); it4.hasNext(); ) {
5906 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5907 if ( !it5.next().getName().equals( "r" ) ) {
5910 if ( !it5.next().getName().equals( "A" ) ) {
5913 if ( !it5.next().getName().equals( "B" ) ) {
5916 if ( !it5.next().getName().equals( "C" ) ) {
5919 if ( !it5.next().getName().equals( "D" ) ) {
5922 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5923 PhylogenyNodeIterator it6;
5924 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5927 for( it6.reset(); it6.hasNext(); ) {
5930 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5931 if ( !it7.next().getName().equals( "A" ) ) {
5934 if ( it.hasNext() ) {
5938 catch ( final Exception e ) {
5939 e.printStackTrace( System.out );
5945 private static boolean testMafft( final String path ) {
5947 final List<String> opts = new ArrayList<String>();
5948 opts.add( "--maxiterate" );
5950 opts.add( "--localpair" );
5951 opts.add( "--quiet" );
5953 final MsaInferrer mafft = Mafft.createInstance( path );
5954 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5955 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5958 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5962 catch ( final Exception e ) {
5963 e.printStackTrace( System.out );
5969 private static boolean testMidpointrooting() {
5971 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5972 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5973 PhylogenyMethods.midpointRoot( t0 );
5974 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5977 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5980 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5984 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",
5985 new NHXParser() )[ 0 ];
5986 if ( !t1.isRooted() ) {
5989 PhylogenyMethods.midpointRoot( t1 );
5990 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5993 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5996 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5999 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6002 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6005 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6008 t1.reRoot( t1.getNode( "A" ) );
6009 PhylogenyMethods.midpointRoot( t1 );
6010 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6013 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6016 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6019 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6022 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6026 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6030 catch ( final Exception e ) {
6031 e.printStackTrace( System.out );
6037 private static boolean testMsaQualityMethod() {
6039 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6040 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6041 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6042 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6043 final List<Sequence> l = new ArrayList<Sequence>();
6048 final Msa msa = BasicMsa.createInstance( l );
6049 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6052 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6055 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6058 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6061 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6064 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6067 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6071 catch ( final Exception e ) {
6072 e.printStackTrace( System.out );
6078 private static boolean testNextNodeWithCollapsing() {
6080 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6082 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6083 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6084 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6085 t0.getNode( "cd" ).setCollapse( true );
6086 t0.getNode( "cde" ).setCollapse( true );
6087 n = t0.getFirstExternalNode();
6088 while ( n != null ) {
6090 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6092 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6095 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6098 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6101 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6104 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6107 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6111 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6112 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6113 t1.getNode( "ab" ).setCollapse( true );
6114 t1.getNode( "cd" ).setCollapse( true );
6115 t1.getNode( "cde" ).setCollapse( true );
6116 n = t1.getNode( "ab" );
6117 ext = new ArrayList<PhylogenyNode>();
6118 while ( n != null ) {
6120 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6122 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6125 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6128 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6131 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6134 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6140 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6141 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6142 t2.getNode( "ab" ).setCollapse( true );
6143 t2.getNode( "cd" ).setCollapse( true );
6144 t2.getNode( "cde" ).setCollapse( true );
6145 t2.getNode( "c" ).setCollapse( true );
6146 t2.getNode( "d" ).setCollapse( true );
6147 t2.getNode( "e" ).setCollapse( true );
6148 t2.getNode( "gh" ).setCollapse( true );
6149 n = t2.getNode( "ab" );
6150 ext = new ArrayList<PhylogenyNode>();
6151 while ( n != null ) {
6153 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6155 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6158 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6161 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6164 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6170 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6171 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6172 t3.getNode( "ab" ).setCollapse( true );
6173 t3.getNode( "cd" ).setCollapse( true );
6174 t3.getNode( "cde" ).setCollapse( true );
6175 t3.getNode( "c" ).setCollapse( true );
6176 t3.getNode( "d" ).setCollapse( true );
6177 t3.getNode( "e" ).setCollapse( true );
6178 t3.getNode( "gh" ).setCollapse( true );
6179 t3.getNode( "fgh" ).setCollapse( true );
6180 n = t3.getNode( "ab" );
6181 ext = new ArrayList<PhylogenyNode>();
6182 while ( n != null ) {
6184 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6186 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6189 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6192 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6198 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6199 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6200 t4.getNode( "ab" ).setCollapse( true );
6201 t4.getNode( "cd" ).setCollapse( true );
6202 t4.getNode( "cde" ).setCollapse( true );
6203 t4.getNode( "c" ).setCollapse( true );
6204 t4.getNode( "d" ).setCollapse( true );
6205 t4.getNode( "e" ).setCollapse( true );
6206 t4.getNode( "gh" ).setCollapse( true );
6207 t4.getNode( "fgh" ).setCollapse( true );
6208 t4.getNode( "abcdefgh" ).setCollapse( true );
6209 n = t4.getNode( "abcdefgh" );
6210 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6215 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6216 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6218 n = t5.getFirstExternalNode();
6219 while ( n != null ) {
6221 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6223 if ( ext.size() != 8 ) {
6226 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6229 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6232 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6235 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6238 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6241 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6244 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6247 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6252 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6253 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6255 t6.getNode( "ab" ).setCollapse( true );
6256 n = t6.getNode( "ab" );
6257 while ( n != null ) {
6259 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6261 if ( ext.size() != 7 ) {
6264 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6267 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6270 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6273 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6276 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6279 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6282 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6287 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6288 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6290 t7.getNode( "cd" ).setCollapse( true );
6291 n = t7.getNode( "a" );
6292 while ( n != null ) {
6294 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6296 if ( ext.size() != 7 ) {
6299 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6302 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6305 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6308 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6311 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6314 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6317 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6322 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6323 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6325 t8.getNode( "cd" ).setCollapse( true );
6326 t8.getNode( "c" ).setCollapse( true );
6327 t8.getNode( "d" ).setCollapse( true );
6328 n = t8.getNode( "a" );
6329 while ( n != null ) {
6331 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6333 if ( ext.size() != 7 ) {
6336 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6339 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6342 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6343 System.out.println( "2 fail" );
6346 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6349 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6352 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6355 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6360 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6361 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6363 t9.getNode( "gh" ).setCollapse( true );
6364 n = t9.getNode( "a" );
6365 while ( n != null ) {
6367 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6369 if ( ext.size() != 7 ) {
6372 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6375 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6378 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6381 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6384 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6387 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6390 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6395 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6396 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6398 t10.getNode( "gh" ).setCollapse( true );
6399 t10.getNode( "g" ).setCollapse( true );
6400 t10.getNode( "h" ).setCollapse( true );
6401 n = t10.getNode( "a" );
6402 while ( n != null ) {
6404 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6406 if ( ext.size() != 7 ) {
6409 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6412 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6415 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6418 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6421 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6424 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6427 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6432 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6433 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6435 t11.getNode( "gh" ).setCollapse( true );
6436 t11.getNode( "fgh" ).setCollapse( true );
6437 n = t11.getNode( "a" );
6438 while ( n != null ) {
6440 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6442 if ( ext.size() != 6 ) {
6445 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6448 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6451 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6454 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6457 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6460 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6465 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6466 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6468 t12.getNode( "gh" ).setCollapse( true );
6469 t12.getNode( "fgh" ).setCollapse( true );
6470 t12.getNode( "g" ).setCollapse( true );
6471 t12.getNode( "h" ).setCollapse( true );
6472 t12.getNode( "f" ).setCollapse( true );
6473 n = t12.getNode( "a" );
6474 while ( n != null ) {
6476 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6478 if ( ext.size() != 6 ) {
6481 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6484 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6487 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6490 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6493 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6496 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6501 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6502 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6504 t13.getNode( "ab" ).setCollapse( true );
6505 t13.getNode( "b" ).setCollapse( true );
6506 t13.getNode( "fgh" ).setCollapse( true );
6507 t13.getNode( "gh" ).setCollapse( true );
6508 n = t13.getNode( "ab" );
6509 while ( n != null ) {
6511 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6513 if ( ext.size() != 5 ) {
6516 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6519 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6522 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6525 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6528 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6533 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6534 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6536 t14.getNode( "ab" ).setCollapse( true );
6537 t14.getNode( "a" ).setCollapse( true );
6538 t14.getNode( "fgh" ).setCollapse( true );
6539 t14.getNode( "gh" ).setCollapse( true );
6540 n = t14.getNode( "ab" );
6541 while ( n != null ) {
6543 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6545 if ( ext.size() != 5 ) {
6548 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6551 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6554 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6557 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6560 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6565 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" );
6566 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6568 t15.getNode( "ab" ).setCollapse( true );
6569 t15.getNode( "a" ).setCollapse( true );
6570 t15.getNode( "fgh" ).setCollapse( true );
6571 t15.getNode( "gh" ).setCollapse( true );
6572 n = t15.getNode( "ab" );
6573 while ( n != null ) {
6575 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6577 if ( ext.size() != 6 ) {
6580 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6583 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6586 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6589 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6592 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6595 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6600 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" );
6601 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6603 t16.getNode( "ab" ).setCollapse( true );
6604 t16.getNode( "a" ).setCollapse( true );
6605 t16.getNode( "fgh" ).setCollapse( true );
6606 t16.getNode( "gh" ).setCollapse( true );
6607 t16.getNode( "cd" ).setCollapse( true );
6608 t16.getNode( "cde" ).setCollapse( true );
6609 t16.getNode( "d" ).setCollapse( true );
6610 t16.getNode( "x" ).setCollapse( true );
6611 n = t16.getNode( "ab" );
6612 while ( n != null ) {
6614 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6616 if ( ext.size() != 4 ) {
6619 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6622 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6625 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6628 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6632 catch ( final Exception e ) {
6633 e.printStackTrace( System.out );
6639 private static boolean testNexusCharactersParsing() {
6641 final NexusCharactersParser parser = new NexusCharactersParser();
6642 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6644 String[] labels = parser.getCharStateLabels();
6645 if ( labels.length != 7 ) {
6648 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6651 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6654 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6657 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6660 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6663 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6666 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6669 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6671 labels = parser.getCharStateLabels();
6672 if ( labels.length != 7 ) {
6675 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6678 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6681 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6684 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6687 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6690 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6693 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6697 catch ( final Exception e ) {
6698 e.printStackTrace( System.out );
6704 private static boolean testNexusMatrixParsing() {
6706 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6707 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6709 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6710 if ( m.getNumberOfCharacters() != 9 ) {
6713 if ( m.getNumberOfIdentifiers() != 5 ) {
6716 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6719 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6722 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6725 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6728 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6731 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6734 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6737 // if ( labels.length != 7 ) {
6740 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6743 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6746 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6749 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6752 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6755 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6758 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6761 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6763 // labels = parser.getCharStateLabels();
6764 // if ( labels.length != 7 ) {
6767 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6770 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6773 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6776 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6779 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6782 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6785 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6789 catch ( final Exception e ) {
6790 e.printStackTrace( System.out );
6796 private static boolean testNexusTreeParsing() {
6798 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6799 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6800 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6801 if ( phylogenies.length != 1 ) {
6804 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6807 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6811 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6812 if ( phylogenies.length != 1 ) {
6815 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6818 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6822 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6823 if ( phylogenies.length != 1 ) {
6826 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6829 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6832 if ( phylogenies[ 0 ].isRooted() ) {
6836 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6837 if ( phylogenies.length != 18 ) {
6840 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6843 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6846 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6849 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6852 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6855 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6858 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6861 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6864 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6867 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6870 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6873 if ( phylogenies[ 8 ].isRooted() ) {
6876 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6879 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6882 if ( !phylogenies[ 9 ].isRooted() ) {
6885 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6888 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6891 if ( !phylogenies[ 10 ].isRooted() ) {
6894 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6897 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6900 if ( phylogenies[ 11 ].isRooted() ) {
6903 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6906 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6909 if ( !phylogenies[ 12 ].isRooted() ) {
6912 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6915 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6918 if ( !phylogenies[ 13 ].isRooted() ) {
6921 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6924 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6927 if ( !phylogenies[ 14 ].isRooted() ) {
6930 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6933 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6936 if ( phylogenies[ 15 ].isRooted() ) {
6939 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6942 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6945 if ( !phylogenies[ 16 ].isRooted() ) {
6948 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6951 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6954 if ( phylogenies[ 17 ].isRooted() ) {
6957 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6960 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
6962 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
6963 if ( phylogenies.length != 9 ) {
6966 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
6967 .getDistanceToParent() ) ) {
6970 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
6971 .getDistanceToParent() ) ) {
6974 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
6977 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6980 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6983 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6986 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6990 catch ( final Exception e ) {
6991 e.printStackTrace( System.out );
6997 private static boolean testNexusTreeParsingIterating() {
6999 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7000 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7001 if ( !p.hasNext() ) {
7004 Phylogeny phy = p.next();
7005 if ( phy == null ) {
7008 if ( phy.getNumberOfExternalNodes() != 25 ) {
7011 if ( !phy.getName().equals( "" ) ) {
7014 if ( p.hasNext() ) {
7018 if ( phy != null ) {
7023 if ( !p.hasNext() ) {
7027 if ( phy == null ) {
7030 if ( phy.getNumberOfExternalNodes() != 25 ) {
7033 if ( !phy.getName().equals( "" ) ) {
7036 if ( p.hasNext() ) {
7040 if ( phy != null ) {
7044 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7045 if ( !p.hasNext() ) {
7049 if ( phy == null ) {
7052 if ( phy.getNumberOfExternalNodes() != 10 ) {
7055 if ( !phy.getName().equals( "name" ) ) {
7058 if ( p.hasNext() ) {
7062 if ( phy != null ) {
7067 if ( !p.hasNext() ) {
7071 if ( phy == null ) {
7074 if ( phy.getNumberOfExternalNodes() != 10 ) {
7077 if ( !phy.getName().equals( "name" ) ) {
7080 if ( p.hasNext() ) {
7084 if ( phy != null ) {
7088 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7089 if ( !p.hasNext() ) {
7093 if ( phy == null ) {
7096 if ( phy.getNumberOfExternalNodes() != 3 ) {
7099 if ( !phy.getName().equals( "" ) ) {
7102 if ( phy.isRooted() ) {
7105 if ( p.hasNext() ) {
7109 if ( phy != null ) {
7114 if ( !p.hasNext() ) {
7118 if ( phy == null ) {
7121 if ( phy.getNumberOfExternalNodes() != 3 ) {
7124 if ( !phy.getName().equals( "" ) ) {
7127 if ( p.hasNext() ) {
7131 if ( phy != null ) {
7135 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7136 if ( !p.hasNext() ) {
7141 if ( phy == null ) {
7144 if ( phy.getNumberOfExternalNodes() != 10 ) {
7147 if ( !phy.getName().equals( "tree 0" ) ) {
7151 if ( !p.hasNext() ) {
7155 if ( phy == null ) {
7158 if ( phy.getNumberOfExternalNodes() != 10 ) {
7161 if ( !phy.getName().equals( "tree 1" ) ) {
7165 if ( !p.hasNext() ) {
7169 if ( phy == null ) {
7172 if ( phy.getNumberOfExternalNodes() != 3 ) {
7173 System.out.println( phy.toString() );
7176 if ( !phy.getName().equals( "" ) ) {
7179 if ( phy.isRooted() ) {
7183 if ( !p.hasNext() ) {
7187 if ( phy == null ) {
7190 if ( phy.getNumberOfExternalNodes() != 4 ) {
7193 if ( !phy.getName().equals( "" ) ) {
7196 if ( !phy.isRooted() ) {
7200 if ( !p.hasNext() ) {
7204 if ( phy == null ) {
7207 if ( phy.getNumberOfExternalNodes() != 5 ) {
7208 System.out.println( phy.getNumberOfExternalNodes() );
7211 if ( !phy.getName().equals( "" ) ) {
7214 if ( !phy.isRooted() ) {
7218 if ( !p.hasNext() ) {
7222 if ( phy == null ) {
7225 if ( phy.getNumberOfExternalNodes() != 3 ) {
7228 if ( !phy.getName().equals( "" ) ) {
7231 if ( phy.isRooted() ) {
7235 if ( !p.hasNext() ) {
7239 if ( phy == null ) {
7242 if ( phy.getNumberOfExternalNodes() != 2 ) {
7245 if ( !phy.getName().equals( "" ) ) {
7248 if ( !phy.isRooted() ) {
7252 if ( !p.hasNext() ) {
7256 if ( phy.getNumberOfExternalNodes() != 3 ) {
7259 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7262 if ( !phy.isRooted() ) {
7266 if ( !p.hasNext() ) {
7270 if ( phy.getNumberOfExternalNodes() != 3 ) {
7273 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7276 if ( !phy.getName().equals( "tree 8" ) ) {
7280 if ( !p.hasNext() ) {
7284 if ( phy.getNumberOfExternalNodes() != 3 ) {
7287 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7290 if ( !phy.getName().equals( "tree 9" ) ) {
7294 if ( !p.hasNext() ) {
7298 if ( phy.getNumberOfExternalNodes() != 3 ) {
7301 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7304 if ( !phy.getName().equals( "tree 10" ) ) {
7307 if ( !phy.isRooted() ) {
7311 if ( !p.hasNext() ) {
7315 if ( phy.getNumberOfExternalNodes() != 3 ) {
7318 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7321 if ( !phy.getName().equals( "tree 11" ) ) {
7324 if ( phy.isRooted() ) {
7328 if ( !p.hasNext() ) {
7332 if ( phy.getNumberOfExternalNodes() != 3 ) {
7335 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7338 if ( !phy.getName().equals( "tree 12" ) ) {
7341 if ( !phy.isRooted() ) {
7345 if ( !p.hasNext() ) {
7349 if ( phy.getNumberOfExternalNodes() != 3 ) {
7352 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7355 if ( !phy.getName().equals( "tree 13" ) ) {
7358 if ( !phy.isRooted() ) {
7362 if ( !p.hasNext() ) {
7366 if ( phy.getNumberOfExternalNodes() != 10 ) {
7367 System.out.println( phy.getNumberOfExternalNodes() );
7372 .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;" ) ) {
7373 System.out.println( phy.toNewHampshire() );
7376 if ( !phy.getName().equals( "tree 14" ) ) {
7379 if ( !phy.isRooted() ) {
7383 if ( !p.hasNext() ) {
7387 if ( phy.getNumberOfExternalNodes() != 10 ) {
7388 System.out.println( phy.getNumberOfExternalNodes() );
7393 .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;" ) ) {
7394 System.out.println( phy.toNewHampshire() );
7397 if ( !phy.getName().equals( "tree 15" ) ) {
7400 if ( phy.isRooted() ) {
7404 if ( !p.hasNext() ) {
7408 if ( phy.getNumberOfExternalNodes() != 10 ) {
7409 System.out.println( phy.getNumberOfExternalNodes() );
7414 .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;" ) ) {
7415 System.out.println( phy.toNewHampshire() );
7418 if ( !phy.getName().equals( "tree 16" ) ) {
7421 if ( !phy.isRooted() ) {
7425 if ( !p.hasNext() ) {
7429 if ( phy.getNumberOfExternalNodes() != 10 ) {
7430 System.out.println( phy.getNumberOfExternalNodes() );
7435 .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;" ) ) {
7436 System.out.println( phy.toNewHampshire() );
7439 if ( !phy.getName().equals( "tree 17" ) ) {
7442 if ( phy.isRooted() ) {
7446 if ( p.hasNext() ) {
7450 if ( phy != null ) {
7455 if ( !p.hasNext() ) {
7459 if ( phy == null ) {
7462 if ( phy.getNumberOfExternalNodes() != 10 ) {
7465 if ( !phy.getName().equals( "tree 0" ) ) {
7469 if ( !p.hasNext() ) {
7473 if ( phy == null ) {
7476 if ( phy.getNumberOfExternalNodes() != 10 ) {
7479 if ( !phy.getName().equals( "tree 1" ) ) {
7483 if ( !p.hasNext() ) {
7487 if ( phy == null ) {
7490 if ( phy.getNumberOfExternalNodes() != 3 ) {
7493 if ( !phy.getName().equals( "" ) ) {
7496 if ( phy.isRooted() ) {
7500 if ( !p.hasNext() ) {
7504 if ( phy == null ) {
7507 if ( phy.getNumberOfExternalNodes() != 4 ) {
7510 if ( !phy.getName().equals( "" ) ) {
7513 if ( !phy.isRooted() ) {
7517 if ( !p.hasNext() ) {
7521 if ( phy == null ) {
7524 if ( phy.getNumberOfExternalNodes() != 5 ) {
7525 System.out.println( phy.getNumberOfExternalNodes() );
7528 if ( !phy.getName().equals( "" ) ) {
7531 if ( !phy.isRooted() ) {
7535 if ( !p.hasNext() ) {
7539 if ( phy == null ) {
7542 if ( phy.getNumberOfExternalNodes() != 3 ) {
7545 if ( !phy.getName().equals( "" ) ) {
7548 if ( phy.isRooted() ) {
7552 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7553 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7555 if ( !p2.hasNext() ) {
7559 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7562 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7566 if ( !p2.hasNext() ) {
7571 if ( !p2.hasNext() ) {
7576 if ( !p2.hasNext() ) {
7581 if ( !p2.hasNext() ) {
7586 if ( !p2.hasNext() ) {
7591 if ( !p2.hasNext() ) {
7596 if ( !p2.hasNext() ) {
7601 if ( !p2.hasNext() ) {
7605 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7608 if ( p2.hasNext() ) {
7612 if ( phy != null ) {
7617 if ( !p2.hasNext() ) {
7621 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7624 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7628 catch ( final Exception e ) {
7629 e.printStackTrace( System.out );
7635 private static boolean testNexusTreeParsingTranslating() {
7637 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7638 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7639 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7640 if ( phylogenies.length != 1 ) {
7643 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7646 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7649 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7652 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7655 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7656 .equals( "Aranaeus" ) ) {
7660 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7661 if ( phylogenies.length != 3 ) {
7664 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7667 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7670 if ( phylogenies[ 0 ].isRooted() ) {
7673 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7676 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7679 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7680 .equals( "Aranaeus" ) ) {
7683 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7686 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7689 if ( phylogenies[ 1 ].isRooted() ) {
7692 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7695 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7698 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7699 .equals( "Aranaeus" ) ) {
7702 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7705 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7708 if ( !phylogenies[ 2 ].isRooted() ) {
7711 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7714 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7717 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7718 .equals( "Aranaeus" ) ) {
7722 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7723 if ( phylogenies.length != 3 ) {
7726 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7729 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7732 if ( phylogenies[ 0 ].isRooted() ) {
7735 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7738 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7741 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7742 .equals( "Aranaeus" ) ) {
7745 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7748 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7751 if ( phylogenies[ 1 ].isRooted() ) {
7754 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7757 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7760 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7761 .equals( "Aranaeus" ) ) {
7764 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7767 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7770 if ( !phylogenies[ 2 ].isRooted() ) {
7773 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7776 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7779 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7780 .equals( "Aranaeus" ) ) {
7783 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7784 if ( phylogenies.length != 3 ) {
7787 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7792 catch ( final Exception e ) {
7793 e.printStackTrace( System.out );
7799 private static boolean testNHParsing() {
7801 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7802 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7803 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7806 final NHXParser nhxp = new NHXParser();
7807 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7808 nhxp.setReplaceUnderscores( true );
7809 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7810 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
7813 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
7816 final Phylogeny p1b = factory
7817 .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 ",
7818 new NHXParser() )[ 0 ];
7819 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7822 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7825 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7826 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7827 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7828 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7829 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7830 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7831 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7832 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7833 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7834 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7835 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7836 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7837 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7839 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7842 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7845 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7848 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7851 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7852 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7853 final String p16_S = "((A,B),C)";
7854 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7855 if ( p16.length != 1 ) {
7858 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7861 final String p17_S = "(C,(A,B))";
7862 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7863 if ( p17.length != 1 ) {
7866 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7869 final String p18_S = "((A,B),(C,D))";
7870 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7871 if ( p18.length != 1 ) {
7874 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7877 final String p19_S = "(((A,B),C),D)";
7878 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7879 if ( p19.length != 1 ) {
7882 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7885 final String p20_S = "(A,(B,(C,D)))";
7886 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7887 if ( p20.length != 1 ) {
7890 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7893 final String p21_S = "(A,(B,(C,(D,E))))";
7894 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7895 if ( p21.length != 1 ) {
7898 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7901 final String p22_S = "((((A,B),C),D),E)";
7902 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7903 if ( p22.length != 1 ) {
7906 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7909 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7910 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7911 if ( p23.length != 1 ) {
7912 System.out.println( "xl=" + p23.length );
7916 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7919 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7920 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7921 if ( p24.length != 1 ) {
7924 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7927 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7928 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7929 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7930 if ( p241.length != 2 ) {
7933 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7936 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7939 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7940 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7941 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7942 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7943 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7944 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7945 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7946 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7947 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7948 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7951 final String p26_S = "(A,B)ab";
7952 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7953 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7956 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7957 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7958 if ( p27s.length != 1 ) {
7959 System.out.println( "xxl=" + p27s.length );
7963 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7964 System.out.println( p27s[ 0 ].toNewHampshireX() );
7968 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7970 if ( p27.length != 1 ) {
7971 System.out.println( "yl=" + p27.length );
7975 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7976 System.out.println( p27[ 0 ].toNewHampshireX() );
7980 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7981 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7982 final String p28_S3 = "(A,B)ab";
7983 final String p28_S4 = "((((A,B),C),D),;E;)";
7984 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7986 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7989 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7992 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7995 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7998 if ( p28.length != 4 ) {
8001 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";
8002 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8003 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8006 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";
8007 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8008 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8011 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8012 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8013 if ( ( p32.length != 0 ) ) {
8016 final String p33_S = "A";
8017 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8018 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8021 final String p34_S = "B;";
8022 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8023 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8026 final String p35_S = "B:0.2";
8027 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8028 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8031 final String p36_S = "(A)";
8032 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8033 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8036 final String p37_S = "((A))";
8037 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8038 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8041 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8042 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8043 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8046 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8047 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8048 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8051 final String p40_S = "(A,B,C)";
8052 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8053 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8056 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8057 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8058 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8061 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8062 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8063 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8066 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)";
8067 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8068 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8071 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)))";
8072 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8073 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8076 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8077 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8078 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8081 final String p46_S = "";
8082 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8083 if ( p46.length != 0 ) {
8086 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8087 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8090 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8091 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8094 final Phylogeny p49 = factory
8095 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8096 new NHXParser() )[ 0 ];
8097 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8100 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8101 if ( p50.getNode( "A" ) == null ) {
8104 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8105 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8108 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8111 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8112 .equals( "((A,B)88:2.0,C);" ) ) {
8115 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8116 if ( p51.getNode( "A(A" ) == null ) {
8119 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8120 if ( p52.getNode( "A(A" ) == null ) {
8123 final Phylogeny p53 = factory
8124 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8125 new NHXParser() )[ 0 ];
8126 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8129 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8130 if ( p54.getNode( "A" ) == null ) {
8133 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8136 final Phylogeny p55 = factory
8137 .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);" ),
8138 new NHXParser() )[ 0 ];
8141 .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);" ) ) {
8142 System.out.println( p55.toNewHampshire() );
8145 final Phylogeny p56 = factory
8146 .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);" ),
8147 new NHXParser() )[ 0 ];
8150 .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);" ) ) {
8151 System.out.println( p56.toNewHampshire() );
8154 final Phylogeny p57 = factory
8155 .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);" ),
8156 new NHXParser() )[ 0 ];
8159 .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);" ) ) {
8160 System.out.println( p56.toNewHampshire() );
8163 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8164 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8165 if ( !p58.toNewHampshire().equals( s58 ) ) {
8166 System.out.println( p58.toNewHampshire() );
8169 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8170 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8171 if ( !p59.toNewHampshire().equals( s59 ) ) {
8172 System.out.println( p59.toNewHampshire() );
8175 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8176 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8177 if ( !p60.toNewHampshire().equals( s60 ) ) {
8178 System.out.println( p60.toNewHampshire() );
8181 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8182 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8183 if ( !p61.toNewHampshire()
8184 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8185 System.out.println( p61.toNewHampshire() );
8189 catch ( final Exception e ) {
8190 e.printStackTrace( System.out );
8196 private static boolean testNHParsingIter() {
8198 final String p0_str = "(A,B);";
8199 final NHXParser p = new NHXParser();
8200 p.setSource( p0_str );
8201 if ( !p.hasNext() ) {
8204 final Phylogeny p0 = p.next();
8205 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8206 System.out.println( p0.toNewHampshire() );
8209 if ( p.hasNext() ) {
8212 if ( p.next() != null ) {
8216 final String p00_str = "(A,B)root;";
8217 p.setSource( p00_str );
8218 final Phylogeny p00 = p.next();
8219 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8220 System.out.println( p00.toNewHampshire() );
8224 final String p000_str = "A;";
8225 p.setSource( p000_str );
8226 final Phylogeny p000 = p.next();
8227 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8228 System.out.println( p000.toNewHampshire() );
8232 final String p0000_str = "A";
8233 p.setSource( p0000_str );
8234 final Phylogeny p0000 = p.next();
8235 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8236 System.out.println( p0000.toNewHampshire() );
8240 p.setSource( "(A)" );
8241 final Phylogeny p00000 = p.next();
8242 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8243 System.out.println( p00000.toNewHampshire() );
8247 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8248 p.setSource( p1_str );
8249 if ( !p.hasNext() ) {
8252 final Phylogeny p1_0 = p.next();
8253 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8254 System.out.println( p1_0.toNewHampshire() );
8257 if ( !p.hasNext() ) {
8260 final Phylogeny p1_1 = p.next();
8261 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8262 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8265 if ( !p.hasNext() ) {
8268 final Phylogeny p1_2 = p.next();
8269 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8270 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8273 if ( !p.hasNext() ) {
8276 final Phylogeny p1_3 = p.next();
8277 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8278 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8281 if ( p.hasNext() ) {
8284 if ( p.next() != null ) {
8288 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8289 p.setSource( p2_str );
8290 if ( !p.hasNext() ) {
8293 Phylogeny p2_0 = p.next();
8294 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8295 System.out.println( p2_0.toNewHampshire() );
8298 if ( !p.hasNext() ) {
8301 Phylogeny p2_1 = p.next();
8302 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8303 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8306 if ( !p.hasNext() ) {
8309 Phylogeny p2_2 = p.next();
8310 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8311 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8314 if ( !p.hasNext() ) {
8317 Phylogeny p2_3 = p.next();
8318 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8319 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8322 if ( !p.hasNext() ) {
8325 Phylogeny p2_4 = p.next();
8326 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8327 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8330 if ( p.hasNext() ) {
8333 if ( p.next() != null ) {
8338 if ( !p.hasNext() ) {
8342 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8343 System.out.println( p2_0.toNewHampshire() );
8346 if ( !p.hasNext() ) {
8350 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8351 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8354 if ( !p.hasNext() ) {
8358 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8359 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8362 if ( !p.hasNext() ) {
8366 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8367 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8370 if ( !p.hasNext() ) {
8374 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8375 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8378 if ( p.hasNext() ) {
8381 if ( p.next() != null ) {
8385 final String p3_str = "((A,B),C)abc";
8386 p.setSource( p3_str );
8387 if ( !p.hasNext() ) {
8390 final Phylogeny p3_0 = p.next();
8391 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8394 if ( p.hasNext() ) {
8397 if ( p.next() != null ) {
8401 final String p4_str = "((A,B)ab,C)abc";
8402 p.setSource( p4_str );
8403 if ( !p.hasNext() ) {
8406 final Phylogeny p4_0 = p.next();
8407 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8410 if ( p.hasNext() ) {
8413 if ( p.next() != null ) {
8417 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8418 p.setSource( p5_str );
8419 if ( !p.hasNext() ) {
8422 final Phylogeny p5_0 = p.next();
8423 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8426 if ( p.hasNext() ) {
8429 if ( p.next() != null ) {
8433 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8434 p.setSource( p6_str );
8435 if ( !p.hasNext() ) {
8438 Phylogeny p6_0 = p.next();
8439 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8442 if ( p.hasNext() ) {
8445 if ( p.next() != null ) {
8449 if ( !p.hasNext() ) {
8453 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8456 if ( p.hasNext() ) {
8459 if ( p.next() != null ) {
8463 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8464 p.setSource( p7_str );
8465 if ( !p.hasNext() ) {
8468 Phylogeny p7_0 = p.next();
8469 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8472 if ( p.hasNext() ) {
8475 if ( p.next() != null ) {
8479 if ( !p.hasNext() ) {
8483 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8486 if ( p.hasNext() ) {
8489 if ( p.next() != null ) {
8493 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8494 p.setSource( p8_str );
8495 if ( !p.hasNext() ) {
8498 Phylogeny p8_0 = p.next();
8499 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8502 if ( !p.hasNext() ) {
8505 if ( !p.hasNext() ) {
8508 Phylogeny p8_1 = p.next();
8509 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8512 if ( p.hasNext() ) {
8515 if ( p.next() != null ) {
8519 if ( !p.hasNext() ) {
8523 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8526 if ( !p.hasNext() ) {
8530 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8533 if ( p.hasNext() ) {
8536 if ( p.next() != null ) {
8542 if ( p.hasNext() ) {
8546 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8547 if ( !p.hasNext() ) {
8550 Phylogeny p_27 = p.next();
8551 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8552 System.out.println( p_27.toNewHampshireX() );
8556 if ( p.hasNext() ) {
8559 if ( p.next() != null ) {
8563 if ( !p.hasNext() ) {
8567 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8568 System.out.println( p_27.toNewHampshireX() );
8572 if ( p.hasNext() ) {
8575 if ( p.next() != null ) {
8579 final String p30_str = "(A,B);(C,D)";
8580 final NHXParser p30 = new NHXParser();
8581 p30.setSource( p30_str );
8582 if ( !p30.hasNext() ) {
8585 Phylogeny phy30 = p30.next();
8586 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8587 System.out.println( phy30.toNewHampshire() );
8590 if ( !p30.hasNext() ) {
8593 Phylogeny phy301 = p30.next();
8594 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8595 System.out.println( phy301.toNewHampshire() );
8598 if ( p30.hasNext() ) {
8601 if ( p30.hasNext() ) {
8604 if ( p30.next() != null ) {
8607 if ( p30.next() != null ) {
8611 if ( !p30.hasNext() ) {
8615 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8616 System.out.println( phy30.toNewHampshire() );
8619 if ( !p30.hasNext() ) {
8622 phy301 = p30.next();
8623 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8624 System.out.println( phy301.toNewHampshire() );
8627 if ( p30.hasNext() ) {
8630 if ( p30.hasNext() ) {
8633 if ( p30.next() != null ) {
8636 if ( p30.next() != null ) {
8640 catch ( final Exception e ) {
8641 e.printStackTrace( System.out );
8647 private static boolean testNHXconversion() {
8649 final PhylogenyNode n1 = new PhylogenyNode();
8650 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8651 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8652 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8653 final PhylogenyNode n5 = PhylogenyNode
8654 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8655 final PhylogenyNode n6 = PhylogenyNode
8656 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8657 if ( !n1.toNewHampshireX().equals( "" ) ) {
8660 if ( !n2.toNewHampshireX().equals( "" ) ) {
8663 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8666 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8669 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8672 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8673 System.out.println( n6.toNewHampshireX() );
8676 final PhylogenyNode n7 = new PhylogenyNode();
8677 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8678 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8679 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8680 System.out.println( n7
8681 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8685 catch ( final Exception e ) {
8686 e.printStackTrace( System.out );
8692 private static boolean testNHXNodeParsing() {
8694 final PhylogenyNode n1 = new PhylogenyNode();
8695 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8696 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8697 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8698 final PhylogenyNode n5 = PhylogenyNode
8699 .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]" );
8700 if ( !n3.getName().equals( "n3" ) ) {
8703 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8706 if ( n3.isDuplication() ) {
8709 if ( n3.isHasAssignedEvent() ) {
8712 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8715 if ( !n4.getName().equals( "n4" ) ) {
8718 if ( n4.getDistanceToParent() != 0.01 ) {
8721 if ( !n5.getName().equals( "n5" ) ) {
8724 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8727 if ( n5.getDistanceToParent() != 0.1 ) {
8730 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8733 if ( !n5.isDuplication() ) {
8736 if ( !n5.isHasAssignedEvent() ) {
8739 final PhylogenyNode n8 = PhylogenyNode
8740 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8741 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8742 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8745 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8748 final PhylogenyNode n9 = PhylogenyNode
8749 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8750 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8751 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8754 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8757 final PhylogenyNode n10 = PhylogenyNode
8758 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8759 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8762 final PhylogenyNode n20 = PhylogenyNode
8763 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8764 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8767 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8770 final PhylogenyNode n20x = PhylogenyNode
8771 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8772 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8775 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8778 final PhylogenyNode n20xx = PhylogenyNode
8779 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8780 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8783 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8786 final PhylogenyNode n20xxx = PhylogenyNode
8787 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8788 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8791 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8794 final PhylogenyNode n20xxxx = PhylogenyNode
8795 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8796 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8799 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8802 final PhylogenyNode n21 = PhylogenyNode
8803 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8804 if ( !n21.getName().equals( "N21_PIG" ) ) {
8807 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8810 final PhylogenyNode n21x = PhylogenyNode
8811 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8812 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8815 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8818 final PhylogenyNode n22 = PhylogenyNode
8819 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8820 if ( !n22.getName().equals( "n22/PIG" ) ) {
8823 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8826 final PhylogenyNode n23 = PhylogenyNode
8827 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8828 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8831 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8834 final PhylogenyNode a = PhylogenyNode
8835 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8836 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8839 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8842 final PhylogenyNode c1 = PhylogenyNode
8843 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8844 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8845 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8848 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8851 final PhylogenyNode c2 = PhylogenyNode
8852 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8853 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8854 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8857 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8860 final PhylogenyNode e3 = PhylogenyNode
8861 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8862 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8865 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8868 final PhylogenyNode n11 = PhylogenyNode
8869 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8870 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8871 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8874 if ( n11.getDistanceToParent() != 0.4 ) {
8877 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8880 final PhylogenyNode n12 = PhylogenyNode
8881 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8882 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8883 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8886 if ( n12.getDistanceToParent() != 0.4 ) {
8889 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8892 final PhylogenyNode o = PhylogenyNode
8893 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8894 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8897 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8900 if ( n1.getName().compareTo( "" ) != 0 ) {
8903 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8906 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8909 if ( n2.getName().compareTo( "" ) != 0 ) {
8912 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8915 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8918 final PhylogenyNode n00 = PhylogenyNode
8919 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8920 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8923 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8926 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8927 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8930 final PhylogenyNode n13 = PhylogenyNode
8931 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8932 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
8935 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8938 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8941 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8944 final PhylogenyNode n14 = PhylogenyNode
8945 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8946 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8949 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8952 final PhylogenyNode n15 = PhylogenyNode
8953 .createInstanceFromNhxString( "something_wicked[123]",
8954 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8955 if ( !n15.getName().equals( "something_wicked" ) ) {
8958 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8961 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8964 final PhylogenyNode n16 = PhylogenyNode
8965 .createInstanceFromNhxString( "something_wicked2[9]",
8966 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8967 if ( !n16.getName().equals( "something_wicked2" ) ) {
8970 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8973 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8976 final PhylogenyNode n17 = PhylogenyNode
8977 .createInstanceFromNhxString( "something_wicked3[a]",
8978 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8979 if ( !n17.getName().equals( "something_wicked3" ) ) {
8982 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8985 final PhylogenyNode n18 = PhylogenyNode
8986 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8987 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8990 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8993 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8996 final PhylogenyNode n19 = PhylogenyNode
8997 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8998 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9001 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9004 final PhylogenyNode n30 = PhylogenyNode
9005 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9006 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9007 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9010 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9013 final PhylogenyNode n31 = PhylogenyNode
9014 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9015 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9016 if ( n31.getNodeData().isHasTaxonomy() ) {
9019 final PhylogenyNode n32 = PhylogenyNode
9020 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9021 if ( n32.getNodeData().isHasTaxonomy() ) {
9024 final PhylogenyNode n40 = PhylogenyNode
9025 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9026 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9029 final PhylogenyNode n41 = PhylogenyNode
9030 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9031 if ( n41.getNodeData().isHasTaxonomy() ) {
9034 final PhylogenyNode n42 = PhylogenyNode
9035 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9036 if ( n42.getNodeData().isHasTaxonomy() ) {
9039 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9040 NHXParser.TAXONOMY_EXTRACTION.NO );
9041 if ( n43.getNodeData().isHasTaxonomy() ) {
9044 final PhylogenyNode n44 = PhylogenyNode
9045 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9046 if ( n44.getNodeData().isHasTaxonomy() ) {
9050 catch ( final Exception e ) {
9051 e.printStackTrace( System.out );
9057 private static boolean testNHXParsing() {
9059 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9060 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9061 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9064 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]";
9065 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9066 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9069 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]";
9070 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9071 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9074 final Phylogeny[] p3 = factory
9075 .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]",
9077 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9080 final Phylogeny[] p4 = factory
9081 .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(]",
9083 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9086 final Phylogeny[] p5 = factory
9087 .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(((]",
9089 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9092 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)";
9093 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)";
9094 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9095 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9098 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)))";
9099 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)))";
9100 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9101 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9104 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]) ))[,,, ])))))))";
9105 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9106 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9107 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9110 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9111 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9114 final Phylogeny p10 = factory
9115 .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]",
9116 new NHXParser() )[ 0 ];
9117 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9120 final Phylogeny p11 = factory
9121 .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]",
9122 new NHXParser() )[ 0 ];
9123 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9127 catch ( final Exception e ) {
9128 e.printStackTrace( System.out );
9134 private static boolean testNHXParsingMB() {
9136 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9137 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9138 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9139 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9140 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9141 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9142 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9143 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9144 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9145 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9146 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9149 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9152 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9153 0.1100000000000000e+00 ) ) {
9156 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9159 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9162 final Phylogeny p2 = factory
9163 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9164 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9165 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9166 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9167 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9168 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9169 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9170 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9171 + "7.369400000000000e-02}])",
9172 new NHXParser() )[ 0 ];
9173 if ( p2.getNode( "1" ) == null ) {
9176 if ( p2.getNode( "2" ) == null ) {
9180 catch ( final Exception e ) {
9181 e.printStackTrace( System.out );
9188 private static boolean testNHXParsingQuotes() {
9190 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9191 final NHXParser p = new NHXParser();
9192 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9193 if ( phylogenies_0.length != 5 ) {
9196 final Phylogeny phy = phylogenies_0[ 4 ];
9197 if ( phy.getNumberOfExternalNodes() != 7 ) {
9200 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9203 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9206 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9207 .getScientificName().equals( "hsapiens" ) ) {
9210 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9213 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9216 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9219 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9222 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9225 final NHXParser p1p = new NHXParser();
9226 p1p.setIgnoreQuotes( true );
9227 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9228 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9231 final NHXParser p2p = new NHXParser();
9232 p1p.setIgnoreQuotes( false );
9233 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9234 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9237 final NHXParser p3p = new NHXParser();
9238 p3p.setIgnoreQuotes( false );
9239 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9240 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9243 final NHXParser p4p = new NHXParser();
9244 p4p.setIgnoreQuotes( false );
9245 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9246 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9249 final Phylogeny p10 = factory
9250 .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]",
9251 new NHXParser() )[ 0 ];
9252 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]";
9253 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9256 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9257 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9260 final Phylogeny p12 = factory
9261 .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]",
9262 new NHXParser() )[ 0 ];
9263 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]";
9264 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9267 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9268 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9271 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;";
9272 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9275 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9276 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9280 catch ( final Exception e ) {
9281 e.printStackTrace( System.out );
9287 private static boolean testNodeRemoval() {
9289 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9290 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9291 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9292 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9295 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9296 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9297 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9300 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9301 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9302 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9306 catch ( final Exception e ) {
9307 e.printStackTrace( System.out );
9313 private static boolean testPhylogenyBranch() {
9315 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9316 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9317 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9318 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9319 if ( !a1b1.equals( a1b1 ) ) {
9322 if ( !a1b1.equals( b1a1 ) ) {
9325 if ( !b1a1.equals( a1b1 ) ) {
9328 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9329 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9330 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9331 if ( a1_b1.equals( b1_a1 ) ) {
9334 if ( a1_b1.equals( a1_b1_ ) ) {
9337 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9338 if ( !a1_b1.equals( b1_a1_ ) ) {
9341 if ( a1_b1_.equals( b1_a1_ ) ) {
9344 if ( !a1_b1_.equals( b1_a1 ) ) {
9348 catch ( final Exception e ) {
9349 e.printStackTrace( System.out );
9355 private static boolean testPhyloXMLparsingOfDistributionElement() {
9357 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9358 PhyloXmlParser xml_parser = null;
9360 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9362 catch ( final Exception e ) {
9363 // Do nothing -- means were not running from jar.
9365 if ( xml_parser == null ) {
9366 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9367 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9368 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9371 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9374 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9376 if ( xml_parser.getErrorCount() > 0 ) {
9377 System.out.println( xml_parser.getErrorMessages().toString() );
9380 if ( phylogenies_0.length != 1 ) {
9383 final Phylogeny t1 = phylogenies_0[ 0 ];
9384 PhylogenyNode n = null;
9385 Distribution d = null;
9386 n = t1.getNode( "root node" );
9387 if ( !n.getNodeData().isHasDistribution() ) {
9390 if ( n.getNodeData().getDistributions().size() != 1 ) {
9393 d = n.getNodeData().getDistribution();
9394 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9397 if ( d.getPoints().size() != 1 ) {
9400 if ( d.getPolygons() != null ) {
9403 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9406 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9409 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9412 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9415 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9418 n = t1.getNode( "node a" );
9419 if ( !n.getNodeData().isHasDistribution() ) {
9422 if ( n.getNodeData().getDistributions().size() != 2 ) {
9425 d = n.getNodeData().getDistribution( 1 );
9426 if ( !d.getDesc().equals( "San Diego" ) ) {
9429 if ( d.getPoints().size() != 1 ) {
9432 if ( d.getPolygons() != null ) {
9435 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9438 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9441 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9444 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9447 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9450 n = t1.getNode( "node bb" );
9451 if ( !n.getNodeData().isHasDistribution() ) {
9454 if ( n.getNodeData().getDistributions().size() != 1 ) {
9457 d = n.getNodeData().getDistribution( 0 );
9458 if ( d.getPoints().size() != 3 ) {
9461 if ( d.getPolygons().size() != 2 ) {
9464 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9467 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9470 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9473 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9476 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9479 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9482 Polygon p = d.getPolygons().get( 0 );
9483 if ( p.getPoints().size() != 3 ) {
9486 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9489 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9492 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9495 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9498 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9501 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9504 p = d.getPolygons().get( 1 );
9505 if ( p.getPoints().size() != 3 ) {
9508 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9511 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9514 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9518 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9519 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9520 if ( rt.length != 1 ) {
9523 final Phylogeny t1_rt = rt[ 0 ];
9524 n = t1_rt.getNode( "root node" );
9525 if ( !n.getNodeData().isHasDistribution() ) {
9528 if ( n.getNodeData().getDistributions().size() != 1 ) {
9531 d = n.getNodeData().getDistribution();
9532 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9535 if ( d.getPoints().size() != 1 ) {
9538 if ( d.getPolygons() != null ) {
9541 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9544 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9547 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9550 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9553 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9556 n = t1_rt.getNode( "node a" );
9557 if ( !n.getNodeData().isHasDistribution() ) {
9560 if ( n.getNodeData().getDistributions().size() != 2 ) {
9563 d = n.getNodeData().getDistribution( 1 );
9564 if ( !d.getDesc().equals( "San Diego" ) ) {
9567 if ( d.getPoints().size() != 1 ) {
9570 if ( d.getPolygons() != null ) {
9573 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9576 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9579 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9582 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9585 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9588 n = t1_rt.getNode( "node bb" );
9589 if ( !n.getNodeData().isHasDistribution() ) {
9592 if ( n.getNodeData().getDistributions().size() != 1 ) {
9595 d = n.getNodeData().getDistribution( 0 );
9596 if ( d.getPoints().size() != 3 ) {
9599 if ( d.getPolygons().size() != 2 ) {
9602 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9605 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9608 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9611 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9614 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9617 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9620 p = d.getPolygons().get( 0 );
9621 if ( p.getPoints().size() != 3 ) {
9624 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9627 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9630 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9633 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9636 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9639 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9642 p = d.getPolygons().get( 1 );
9643 if ( p.getPoints().size() != 3 ) {
9646 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9649 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9652 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9656 catch ( final Exception e ) {
9657 e.printStackTrace( System.out );
9663 private static boolean testPostOrderIterator() {
9665 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9666 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9667 PhylogenyNodeIterator it0;
9668 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9671 for( it0.reset(); it0.hasNext(); ) {
9674 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9675 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9676 if ( !it.next().getName().equals( "A" ) ) {
9679 if ( !it.next().getName().equals( "B" ) ) {
9682 if ( !it.next().getName().equals( "ab" ) ) {
9685 if ( !it.next().getName().equals( "C" ) ) {
9688 if ( !it.next().getName().equals( "D" ) ) {
9691 if ( !it.next().getName().equals( "cd" ) ) {
9694 if ( !it.next().getName().equals( "abcd" ) ) {
9697 if ( !it.next().getName().equals( "E" ) ) {
9700 if ( !it.next().getName().equals( "F" ) ) {
9703 if ( !it.next().getName().equals( "ef" ) ) {
9706 if ( !it.next().getName().equals( "G" ) ) {
9709 if ( !it.next().getName().equals( "H" ) ) {
9712 if ( !it.next().getName().equals( "gh" ) ) {
9715 if ( !it.next().getName().equals( "efgh" ) ) {
9718 if ( !it.next().getName().equals( "r" ) ) {
9721 if ( it.hasNext() ) {
9725 catch ( final Exception e ) {
9726 e.printStackTrace( System.out );
9732 private static boolean testPreOrderIterator() {
9734 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9735 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9736 PhylogenyNodeIterator it0;
9737 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9740 for( it0.reset(); it0.hasNext(); ) {
9743 PhylogenyNodeIterator it = t0.iteratorPreorder();
9744 if ( !it.next().getName().equals( "r" ) ) {
9747 if ( !it.next().getName().equals( "ab" ) ) {
9750 if ( !it.next().getName().equals( "A" ) ) {
9753 if ( !it.next().getName().equals( "B" ) ) {
9756 if ( !it.next().getName().equals( "cd" ) ) {
9759 if ( !it.next().getName().equals( "C" ) ) {
9762 if ( !it.next().getName().equals( "D" ) ) {
9765 if ( it.hasNext() ) {
9768 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9769 it = t1.iteratorPreorder();
9770 if ( !it.next().getName().equals( "r" ) ) {
9773 if ( !it.next().getName().equals( "abcd" ) ) {
9776 if ( !it.next().getName().equals( "ab" ) ) {
9779 if ( !it.next().getName().equals( "A" ) ) {
9782 if ( !it.next().getName().equals( "B" ) ) {
9785 if ( !it.next().getName().equals( "cd" ) ) {
9788 if ( !it.next().getName().equals( "C" ) ) {
9791 if ( !it.next().getName().equals( "D" ) ) {
9794 if ( !it.next().getName().equals( "efgh" ) ) {
9797 if ( !it.next().getName().equals( "ef" ) ) {
9800 if ( !it.next().getName().equals( "E" ) ) {
9803 if ( !it.next().getName().equals( "F" ) ) {
9806 if ( !it.next().getName().equals( "gh" ) ) {
9809 if ( !it.next().getName().equals( "G" ) ) {
9812 if ( !it.next().getName().equals( "H" ) ) {
9815 if ( it.hasNext() ) {
9819 catch ( final Exception e ) {
9820 e.printStackTrace( System.out );
9826 private static boolean testPropertiesMap() {
9828 final PropertiesMap pm = new PropertiesMap();
9829 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9830 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9831 final Property p2 = new Property( "something:else",
9833 "improbable:research",
9836 pm.addProperty( p0 );
9837 pm.addProperty( p1 );
9838 pm.addProperty( p2 );
9839 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9842 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9845 if ( pm.getProperties().size() != 3 ) {
9848 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9851 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9854 if ( pm.getProperties().size() != 3 ) {
9857 pm.removeProperty( "dimensions:diameter" );
9858 if ( pm.getProperties().size() != 2 ) {
9861 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9864 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9868 catch ( final Exception e ) {
9869 e.printStackTrace( System.out );
9875 private static boolean testProteinId() {
9877 final ProteinId id1 = new ProteinId( "a" );
9878 final ProteinId id2 = new ProteinId( "a" );
9879 final ProteinId id3 = new ProteinId( "A" );
9880 final ProteinId id4 = new ProteinId( "b" );
9881 if ( !id1.equals( id1 ) ) {
9884 if ( id1.getId().equals( "x" ) ) {
9887 if ( id1.getId().equals( null ) ) {
9890 if ( !id1.equals( id2 ) ) {
9893 if ( id1.equals( id3 ) ) {
9896 if ( id1.hashCode() != id1.hashCode() ) {
9899 if ( id1.hashCode() != id2.hashCode() ) {
9902 if ( id1.hashCode() == id3.hashCode() ) {
9905 if ( id1.compareTo( id1 ) != 0 ) {
9908 if ( id1.compareTo( id2 ) != 0 ) {
9911 if ( id1.compareTo( id3 ) != 0 ) {
9914 if ( id1.compareTo( id4 ) >= 0 ) {
9917 if ( id4.compareTo( id1 ) <= 0 ) {
9920 if ( !id4.getId().equals( "b" ) ) {
9923 final ProteinId id5 = new ProteinId( " C " );
9924 if ( !id5.getId().equals( "C" ) ) {
9927 if ( id5.equals( id1 ) ) {
9931 catch ( final Exception e ) {
9932 e.printStackTrace( System.out );
9938 private static boolean testReIdMethods() {
9940 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9941 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9942 final long count = PhylogenyNode.getNodeCount();
9944 if ( p.getNode( "r" ).getId() != count ) {
9947 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9950 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9953 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9956 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9959 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9962 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9965 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9968 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9971 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9974 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9977 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9980 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9983 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9986 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9990 catch ( final Exception e ) {
9991 e.printStackTrace( System.out );
9997 private static boolean testRerooting() {
9999 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10000 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",
10001 new NHXParser() )[ 0 ];
10002 if ( !t1.isRooted() ) {
10005 t1.reRoot( t1.getNode( "D" ) );
10006 t1.reRoot( t1.getNode( "CD" ) );
10007 t1.reRoot( t1.getNode( "A" ) );
10008 t1.reRoot( t1.getNode( "B" ) );
10009 t1.reRoot( t1.getNode( "AB" ) );
10010 t1.reRoot( t1.getNode( "D" ) );
10011 t1.reRoot( t1.getNode( "C" ) );
10012 t1.reRoot( t1.getNode( "CD" ) );
10013 t1.reRoot( t1.getNode( "A" ) );
10014 t1.reRoot( t1.getNode( "B" ) );
10015 t1.reRoot( t1.getNode( "AB" ) );
10016 t1.reRoot( t1.getNode( "D" ) );
10017 t1.reRoot( t1.getNode( "D" ) );
10018 t1.reRoot( t1.getNode( "C" ) );
10019 t1.reRoot( t1.getNode( "A" ) );
10020 t1.reRoot( t1.getNode( "B" ) );
10021 t1.reRoot( t1.getNode( "AB" ) );
10022 t1.reRoot( t1.getNode( "C" ) );
10023 t1.reRoot( t1.getNode( "D" ) );
10024 t1.reRoot( t1.getNode( "CD" ) );
10025 t1.reRoot( t1.getNode( "D" ) );
10026 t1.reRoot( t1.getNode( "A" ) );
10027 t1.reRoot( t1.getNode( "B" ) );
10028 t1.reRoot( t1.getNode( "AB" ) );
10029 t1.reRoot( t1.getNode( "C" ) );
10030 t1.reRoot( t1.getNode( "D" ) );
10031 t1.reRoot( t1.getNode( "CD" ) );
10032 t1.reRoot( t1.getNode( "D" ) );
10033 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10036 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10039 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10042 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10045 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10048 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10051 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",
10052 new NHXParser() )[ 0 ];
10053 t2.reRoot( t2.getNode( "A" ) );
10054 t2.reRoot( t2.getNode( "D" ) );
10055 t2.reRoot( t2.getNode( "ABC" ) );
10056 t2.reRoot( t2.getNode( "A" ) );
10057 t2.reRoot( t2.getNode( "B" ) );
10058 t2.reRoot( t2.getNode( "D" ) );
10059 t2.reRoot( t2.getNode( "C" ) );
10060 t2.reRoot( t2.getNode( "ABC" ) );
10061 t2.reRoot( t2.getNode( "A" ) );
10062 t2.reRoot( t2.getNode( "B" ) );
10063 t2.reRoot( t2.getNode( "AB" ) );
10064 t2.reRoot( t2.getNode( "AB" ) );
10065 t2.reRoot( t2.getNode( "D" ) );
10066 t2.reRoot( t2.getNode( "C" ) );
10067 t2.reRoot( t2.getNode( "B" ) );
10068 t2.reRoot( t2.getNode( "AB" ) );
10069 t2.reRoot( t2.getNode( "D" ) );
10070 t2.reRoot( t2.getNode( "D" ) );
10071 t2.reRoot( t2.getNode( "ABC" ) );
10072 t2.reRoot( t2.getNode( "A" ) );
10073 t2.reRoot( t2.getNode( "B" ) );
10074 t2.reRoot( t2.getNode( "AB" ) );
10075 t2.reRoot( t2.getNode( "D" ) );
10076 t2.reRoot( t2.getNode( "C" ) );
10077 t2.reRoot( t2.getNode( "ABC" ) );
10078 t2.reRoot( t2.getNode( "A" ) );
10079 t2.reRoot( t2.getNode( "B" ) );
10080 t2.reRoot( t2.getNode( "AB" ) );
10081 t2.reRoot( t2.getNode( "D" ) );
10082 t2.reRoot( t2.getNode( "D" ) );
10083 t2.reRoot( t2.getNode( "C" ) );
10084 t2.reRoot( t2.getNode( "A" ) );
10085 t2.reRoot( t2.getNode( "B" ) );
10086 t2.reRoot( t2.getNode( "AB" ) );
10087 t2.reRoot( t2.getNode( "C" ) );
10088 t2.reRoot( t2.getNode( "D" ) );
10089 t2.reRoot( t2.getNode( "ABC" ) );
10090 t2.reRoot( t2.getNode( "D" ) );
10091 t2.reRoot( t2.getNode( "A" ) );
10092 t2.reRoot( t2.getNode( "B" ) );
10093 t2.reRoot( t2.getNode( "AB" ) );
10094 t2.reRoot( t2.getNode( "C" ) );
10095 t2.reRoot( t2.getNode( "D" ) );
10096 t2.reRoot( t2.getNode( "ABC" ) );
10097 t2.reRoot( t2.getNode( "D" ) );
10098 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10101 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10104 t2.reRoot( t2.getNode( "ABC" ) );
10105 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10108 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10111 t2.reRoot( t2.getNode( "AB" ) );
10112 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10115 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10118 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10121 t2.reRoot( t2.getNode( "AB" ) );
10122 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10125 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10128 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10131 t2.reRoot( t2.getNode( "D" ) );
10132 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10135 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10138 t2.reRoot( t2.getNode( "ABC" ) );
10139 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10142 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10145 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10146 new NHXParser() )[ 0 ];
10147 t3.reRoot( t3.getNode( "B" ) );
10148 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10151 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10154 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10157 t3.reRoot( t3.getNode( "B" ) );
10158 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10161 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10164 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10167 t3.reRoot( t3.getRoot() );
10168 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10171 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10174 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10178 catch ( final Exception e ) {
10179 e.printStackTrace( System.out );
10185 private static boolean testSDIse() {
10187 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10188 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10189 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10190 gene1.setRooted( true );
10191 species1.setRooted( true );
10192 final SDI sdi = new SDI( gene1, species1 );
10193 if ( !gene1.getRoot().isDuplication() ) {
10196 final Phylogeny species2 = factory
10197 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10198 new NHXParser() )[ 0 ];
10199 final Phylogeny gene2 = factory
10200 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10201 new NHXParser() )[ 0 ];
10202 species2.setRooted( true );
10203 gene2.setRooted( true );
10204 final SDI sdi2 = new SDI( gene2, species2 );
10205 if ( sdi2.getDuplicationsSum() != 0 ) {
10208 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10211 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10214 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10217 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10220 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10223 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10226 final Phylogeny species3 = factory
10227 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10228 new NHXParser() )[ 0 ];
10229 final Phylogeny gene3 = factory
10230 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10231 new NHXParser() )[ 0 ];
10232 species3.setRooted( true );
10233 gene3.setRooted( true );
10234 final SDI sdi3 = new SDI( gene3, species3 );
10235 if ( sdi3.getDuplicationsSum() != 1 ) {
10238 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10241 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10244 final Phylogeny species4 = factory
10245 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10246 new NHXParser() )[ 0 ];
10247 final Phylogeny gene4 = factory
10248 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10249 new NHXParser() )[ 0 ];
10250 species4.setRooted( true );
10251 gene4.setRooted( true );
10252 final SDI sdi4 = new SDI( gene4, species4 );
10253 if ( sdi4.getDuplicationsSum() != 1 ) {
10256 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10259 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10262 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10265 if ( species4.getNumberOfExternalNodes() != 6 ) {
10268 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10271 final Phylogeny species5 = factory
10272 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10273 new NHXParser() )[ 0 ];
10274 final Phylogeny gene5 = factory
10275 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10276 new NHXParser() )[ 0 ];
10277 species5.setRooted( true );
10278 gene5.setRooted( true );
10279 final SDI sdi5 = new SDI( gene5, species5 );
10280 if ( sdi5.getDuplicationsSum() != 2 ) {
10283 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10286 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10289 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10292 if ( species5.getNumberOfExternalNodes() != 6 ) {
10295 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10298 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10299 // Conjecture for Comparing Molecular Phylogenies"
10300 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10301 final Phylogeny species6 = factory
10302 .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,"
10303 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10304 new NHXParser() )[ 0 ];
10305 final Phylogeny gene6 = factory
10306 .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,"
10307 + "((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,"
10308 + "(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;",
10309 new NHXParser() )[ 0 ];
10310 species6.setRooted( true );
10311 gene6.setRooted( true );
10312 final SDI sdi6 = new SDI( gene6, species6 );
10313 if ( sdi6.getDuplicationsSum() != 3 ) {
10316 if ( !gene6.getNode( "r" ).isDuplication() ) {
10319 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10322 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10325 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10328 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10331 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10334 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10337 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10340 sdi6.computeMappingCostL();
10341 if ( sdi6.computeMappingCostL() != 17 ) {
10344 if ( species6.getNumberOfExternalNodes() != 9 ) {
10347 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10350 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10351 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10352 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10353 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10354 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10355 species7.setRooted( true );
10356 final Phylogeny gene7_1 = Test
10357 .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])" );
10358 gene7_1.setRooted( true );
10359 final SDI sdi7 = new SDI( gene7_1, species7 );
10360 if ( sdi7.getDuplicationsSum() != 0 ) {
10363 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10366 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10369 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10372 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10375 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10378 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10381 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10384 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10387 final Phylogeny gene7_2 = Test
10388 .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])" );
10389 gene7_2.setRooted( true );
10390 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10391 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10394 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10397 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10400 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10403 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10406 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10409 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10412 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10415 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10418 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10422 catch ( final Exception e ) {
10428 private static boolean testSDIunrooted() {
10430 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10431 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10432 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10433 final Iterator<PhylogenyBranch> iter = l.iterator();
10434 PhylogenyBranch br = iter.next();
10435 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10438 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10442 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10445 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10449 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10452 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10456 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10459 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10463 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10466 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10470 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10473 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10477 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10480 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10484 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10487 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10491 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10494 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10498 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10501 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10505 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10508 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10512 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10515 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10519 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10522 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10526 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10529 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10533 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10536 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10539 if ( iter.hasNext() ) {
10542 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10543 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10544 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10546 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10549 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10553 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10556 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10560 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10563 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10566 if ( iter1.hasNext() ) {
10569 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10570 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10571 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10573 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10576 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10580 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10583 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10587 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10590 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10593 if ( iter2.hasNext() ) {
10596 final Phylogeny species0 = factory
10597 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10598 new NHXParser() )[ 0 ];
10599 final Phylogeny gene1 = factory
10600 .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])",
10601 new NHXParser() )[ 0 ];
10602 species0.setRooted( true );
10603 gene1.setRooted( true );
10604 final SDIR sdi_unrooted = new SDIR();
10605 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10606 if ( sdi_unrooted.getCount() != 1 ) {
10609 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10612 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10615 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10618 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10621 final Phylogeny gene2 = factory
10622 .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])",
10623 new NHXParser() )[ 0 ];
10624 gene2.setRooted( true );
10625 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10626 if ( sdi_unrooted.getCount() != 1 ) {
10629 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10632 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10635 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10638 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10641 final Phylogeny species6 = factory
10642 .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,"
10643 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10644 new NHXParser() )[ 0 ];
10645 final Phylogeny gene6 = factory
10646 .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],"
10647 + "(((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],"
10648 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10649 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10650 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10651 new NHXParser() )[ 0 ];
10652 species6.setRooted( true );
10653 gene6.setRooted( true );
10654 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10655 if ( sdi_unrooted.getCount() != 1 ) {
10658 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10661 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10664 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10667 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10670 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10673 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10676 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10679 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10682 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10685 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10688 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10691 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10695 final Phylogeny species7 = factory
10696 .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,"
10697 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10698 new NHXParser() )[ 0 ];
10699 final Phylogeny gene7 = factory
10700 .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],"
10701 + "(((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],"
10702 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10703 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10704 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10705 new NHXParser() )[ 0 ];
10706 species7.setRooted( true );
10707 gene7.setRooted( true );
10708 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10709 if ( sdi_unrooted.getCount() != 1 ) {
10712 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10715 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10718 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10721 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10724 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10727 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10730 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10733 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10736 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10739 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10742 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10745 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10749 final Phylogeny species8 = factory
10750 .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,"
10751 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10752 new NHXParser() )[ 0 ];
10753 final Phylogeny gene8 = factory
10754 .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],"
10755 + "(((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],"
10756 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10757 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10758 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10759 new NHXParser() )[ 0 ];
10760 species8.setRooted( true );
10761 gene8.setRooted( true );
10762 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10763 if ( sdi_unrooted.getCount() != 1 ) {
10766 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10769 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10772 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10775 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10778 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10781 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10784 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10787 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10790 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10793 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10796 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10799 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10804 catch ( final Exception e ) {
10805 e.printStackTrace( System.out );
10811 private static boolean testSequenceDbWsTools1() {
10813 final PhylogenyNode n = new PhylogenyNode();
10814 n.setName( "NP_001025424" );
10815 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10816 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10817 || !acc.getValue().equals( "NP_001025424" ) ) {
10820 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10821 acc = SequenceDbWsTools.obtainSeqAccession( n );
10822 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10823 || !acc.getValue().equals( "NP_001025424" ) ) {
10826 n.setName( "NP_001025424.1" );
10827 acc = SequenceDbWsTools.obtainSeqAccession( n );
10828 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10829 || !acc.getValue().equals( "NP_001025424" ) ) {
10832 n.setName( "NM_001030253" );
10833 acc = SequenceDbWsTools.obtainSeqAccession( n );
10834 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10835 || !acc.getValue().equals( "NM_001030253" ) ) {
10838 n.setName( "BCL2_HUMAN" );
10839 acc = SequenceDbWsTools.obtainSeqAccession( n );
10840 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10841 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10842 System.out.println( acc.toString() );
10845 n.setName( "P10415" );
10846 acc = SequenceDbWsTools.obtainSeqAccession( n );
10847 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10848 || !acc.getValue().equals( "P10415" ) ) {
10849 System.out.println( acc.toString() );
10852 n.setName( " P10415 " );
10853 acc = SequenceDbWsTools.obtainSeqAccession( n );
10854 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10855 || !acc.getValue().equals( "P10415" ) ) {
10856 System.out.println( acc.toString() );
10859 n.setName( "_P10415|" );
10860 acc = SequenceDbWsTools.obtainSeqAccession( n );
10861 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10862 || !acc.getValue().equals( "P10415" ) ) {
10863 System.out.println( acc.toString() );
10866 n.setName( "AY695820" );
10867 acc = SequenceDbWsTools.obtainSeqAccession( n );
10868 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10869 || !acc.getValue().equals( "AY695820" ) ) {
10870 System.out.println( acc.toString() );
10873 n.setName( "_AY695820_" );
10874 acc = SequenceDbWsTools.obtainSeqAccession( n );
10875 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10876 || !acc.getValue().equals( "AY695820" ) ) {
10877 System.out.println( acc.toString() );
10880 n.setName( "AAA59452" );
10881 acc = SequenceDbWsTools.obtainSeqAccession( n );
10882 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10883 || !acc.getValue().equals( "AAA59452" ) ) {
10884 System.out.println( acc.toString() );
10887 n.setName( "_AAA59452_" );
10888 acc = SequenceDbWsTools.obtainSeqAccession( n );
10889 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10890 || !acc.getValue().equals( "AAA59452" ) ) {
10891 System.out.println( acc.toString() );
10894 n.setName( "AAA59452.1" );
10895 acc = SequenceDbWsTools.obtainSeqAccession( n );
10896 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10897 || !acc.getValue().equals( "AAA59452.1" ) ) {
10898 System.out.println( acc.toString() );
10901 n.setName( "_AAA59452.1_" );
10902 acc = SequenceDbWsTools.obtainSeqAccession( n );
10903 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10904 || !acc.getValue().equals( "AAA59452.1" ) ) {
10905 System.out.println( acc.toString() );
10908 n.setName( "GI:94894583" );
10909 acc = SequenceDbWsTools.obtainSeqAccession( n );
10910 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10911 || !acc.getValue().equals( "94894583" ) ) {
10912 System.out.println( acc.toString() );
10915 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10916 acc = SequenceDbWsTools.obtainSeqAccession( n );
10917 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10918 || !acc.getValue().equals( "71845847" ) ) {
10919 System.out.println( acc.toString() );
10922 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10923 acc = SequenceDbWsTools.obtainSeqAccession( n );
10924 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10925 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10926 System.out.println( acc.toString() );
10930 catch ( final Exception e ) {
10936 private static boolean testSequenceDbWsTools2() {
10938 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10939 SequenceDbWsTools.obtainSeqInformation( n1 );
10940 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10943 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10946 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10949 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10952 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10953 SequenceDbWsTools.obtainSeqInformation( n2 );
10954 if ( !n2.getNodeData().getSequence().getName()
10955 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10958 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10961 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10964 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10967 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10968 SequenceDbWsTools.obtainSeqInformation( n3 );
10969 if ( !n3.getNodeData().getSequence().getName()
10970 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10973 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10976 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10979 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10983 catch ( final IOException e ) {
10984 System.out.println();
10985 System.out.println( "the following might be due to absence internet connection:" );
10986 e.printStackTrace( System.out );
10989 catch ( final Exception e ) {
10990 e.printStackTrace();
10996 private static boolean testSequenceIdParsing() {
10998 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10999 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11000 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11001 if ( id != null ) {
11002 System.out.println( "value =" + id.getValue() );
11003 System.out.println( "provider=" + id.getSource() );
11008 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11009 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11010 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11011 if ( id != null ) {
11012 System.out.println( "value =" + id.getValue() );
11013 System.out.println( "provider=" + id.getSource() );
11018 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11019 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11020 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11021 if ( id != null ) {
11022 System.out.println( "value =" + id.getValue() );
11023 System.out.println( "provider=" + id.getSource() );
11028 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11029 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11030 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11031 if ( id != null ) {
11032 System.out.println( "value =" + id.getValue() );
11033 System.out.println( "provider=" + id.getSource() );
11038 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11039 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11040 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11041 if ( id != null ) {
11042 System.out.println( "value =" + id.getValue() );
11043 System.out.println( "provider=" + id.getSource() );
11048 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11049 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11050 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11051 if ( id != null ) {
11052 System.out.println( "value =" + id.getValue() );
11053 System.out.println( "provider=" + id.getSource() );
11058 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11059 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11060 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11061 if ( id != null ) {
11062 System.out.println( "value =" + id.getValue() );
11063 System.out.println( "provider=" + id.getSource() );
11068 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11069 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11070 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11071 if ( id != null ) {
11072 System.out.println( "value =" + id.getValue() );
11073 System.out.println( "provider=" + id.getSource() );
11078 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11079 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11080 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11081 if ( id != null ) {
11082 System.out.println( "value =" + id.getValue() );
11083 System.out.println( "provider=" + id.getSource() );
11088 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11089 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11090 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11091 if ( id != null ) {
11092 System.out.println( "value =" + id.getValue() );
11093 System.out.println( "provider=" + id.getSource() );
11097 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11098 if ( id != null ) {
11099 System.out.println( "value =" + id.getValue() );
11100 System.out.println( "provider=" + id.getSource() );
11104 catch ( final Exception e ) {
11105 e.printStackTrace( System.out );
11111 private static boolean testSequenceWriter() {
11113 final String n = ForesterUtil.LINE_SEPARATOR;
11114 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11117 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11120 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11123 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11126 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11127 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11130 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11131 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11135 catch ( final Exception e ) {
11136 e.printStackTrace();
11142 private static boolean testSpecies() {
11144 final Species s1 = new BasicSpecies( "a" );
11145 final Species s2 = new BasicSpecies( "a" );
11146 final Species s3 = new BasicSpecies( "A" );
11147 final Species s4 = new BasicSpecies( "b" );
11148 if ( !s1.equals( s1 ) ) {
11151 if ( s1.getSpeciesId().equals( "x" ) ) {
11154 if ( s1.getSpeciesId().equals( null ) ) {
11157 if ( !s1.equals( s2 ) ) {
11160 if ( s1.equals( s3 ) ) {
11163 if ( s1.hashCode() != s1.hashCode() ) {
11166 if ( s1.hashCode() != s2.hashCode() ) {
11169 if ( s1.hashCode() == s3.hashCode() ) {
11172 if ( s1.compareTo( s1 ) != 0 ) {
11175 if ( s1.compareTo( s2 ) != 0 ) {
11178 if ( s1.compareTo( s3 ) != 0 ) {
11181 if ( s1.compareTo( s4 ) >= 0 ) {
11184 if ( s4.compareTo( s1 ) <= 0 ) {
11187 if ( !s4.getSpeciesId().equals( "b" ) ) {
11190 final Species s5 = new BasicSpecies( " C " );
11191 if ( !s5.getSpeciesId().equals( "C" ) ) {
11194 if ( s5.equals( s1 ) ) {
11198 catch ( final Exception e ) {
11199 e.printStackTrace( System.out );
11205 private static boolean testSplit() {
11207 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11208 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11209 //Archaeopteryx.createApplication( p0 );
11210 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11211 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11212 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11213 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11214 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11215 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11216 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11217 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11218 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11219 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11220 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11221 // System.out.println( s0.toString() );
11223 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11226 if ( s0.match( query_nodes ) ) {
11229 query_nodes = new HashSet<PhylogenyNode>();
11230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11237 if ( !s0.match( query_nodes ) ) {
11241 query_nodes = new HashSet<PhylogenyNode>();
11242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11245 if ( !s0.match( query_nodes ) ) {
11249 query_nodes = new HashSet<PhylogenyNode>();
11250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11254 if ( !s0.match( query_nodes ) ) {
11258 query_nodes = new HashSet<PhylogenyNode>();
11259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11263 if ( !s0.match( query_nodes ) ) {
11267 query_nodes = new HashSet<PhylogenyNode>();
11268 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11269 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11270 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11271 if ( !s0.match( query_nodes ) ) {
11275 query_nodes = new HashSet<PhylogenyNode>();
11276 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11277 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11278 if ( !s0.match( query_nodes ) ) {
11282 query_nodes = new HashSet<PhylogenyNode>();
11283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11285 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11286 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11287 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11288 if ( !s0.match( query_nodes ) ) {
11292 query_nodes = new HashSet<PhylogenyNode>();
11293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11294 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11295 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11296 if ( !s0.match( query_nodes ) ) {
11300 query_nodes = new HashSet<PhylogenyNode>();
11301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11303 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11304 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11305 if ( !s0.match( query_nodes ) ) {
11309 query_nodes = new HashSet<PhylogenyNode>();
11310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11312 if ( s0.match( query_nodes ) ) {
11316 query_nodes = new HashSet<PhylogenyNode>();
11317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11320 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11321 if ( s0.match( query_nodes ) ) {
11325 query_nodes = new HashSet<PhylogenyNode>();
11326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11331 if ( s0.match( query_nodes ) ) {
11335 query_nodes = new HashSet<PhylogenyNode>();
11336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11337 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11338 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11339 if ( s0.match( query_nodes ) ) {
11343 query_nodes = new HashSet<PhylogenyNode>();
11344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11345 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11346 if ( s0.match( query_nodes ) ) {
11350 query_nodes = new HashSet<PhylogenyNode>();
11351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11353 if ( s0.match( query_nodes ) ) {
11357 query_nodes = new HashSet<PhylogenyNode>();
11358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11360 if ( s0.match( query_nodes ) ) {
11364 query_nodes = new HashSet<PhylogenyNode>();
11365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11367 if ( s0.match( query_nodes ) ) {
11371 query_nodes = new HashSet<PhylogenyNode>();
11372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11374 if ( s0.match( query_nodes ) ) {
11378 query_nodes = new HashSet<PhylogenyNode>();
11379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
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( "F" ) );
11388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11389 if ( s0.match( query_nodes ) ) {
11393 query_nodes = new HashSet<PhylogenyNode>();
11394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11397 if ( s0.match( query_nodes ) ) {
11401 query_nodes = new HashSet<PhylogenyNode>();
11402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11405 if ( s0.match( query_nodes ) ) {
11409 query_nodes = new HashSet<PhylogenyNode>();
11410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11414 if ( s0.match( query_nodes ) ) {
11418 // query_nodes = new HashSet<PhylogenyNode>();
11419 // query_nodes.add( new PhylogenyNode( "X" ) );
11420 // query_nodes.add( new PhylogenyNode( "Y" ) );
11421 // query_nodes.add( new PhylogenyNode( "A" ) );
11422 // query_nodes.add( new PhylogenyNode( "B" ) );
11423 // query_nodes.add( new PhylogenyNode( "C" ) );
11424 // query_nodes.add( new PhylogenyNode( "D" ) );
11425 // query_nodes.add( new PhylogenyNode( "E" ) );
11426 // query_nodes.add( new PhylogenyNode( "F" ) );
11427 // query_nodes.add( new PhylogenyNode( "G" ) );
11428 // if ( !s0.match( query_nodes ) ) {
11431 // query_nodes = new HashSet<PhylogenyNode>();
11432 // query_nodes.add( new PhylogenyNode( "X" ) );
11433 // query_nodes.add( new PhylogenyNode( "Y" ) );
11434 // query_nodes.add( new PhylogenyNode( "A" ) );
11435 // query_nodes.add( new PhylogenyNode( "B" ) );
11436 // query_nodes.add( new PhylogenyNode( "C" ) );
11437 // if ( !s0.match( query_nodes ) ) {
11441 // query_nodes = new HashSet<PhylogenyNode>();
11442 // query_nodes.add( new PhylogenyNode( "X" ) );
11443 // query_nodes.add( new PhylogenyNode( "Y" ) );
11444 // query_nodes.add( new PhylogenyNode( "D" ) );
11445 // query_nodes.add( new PhylogenyNode( "E" ) );
11446 // query_nodes.add( new PhylogenyNode( "F" ) );
11447 // query_nodes.add( new PhylogenyNode( "G" ) );
11448 // if ( !s0.match( query_nodes ) ) {
11452 // query_nodes = new HashSet<PhylogenyNode>();
11453 // query_nodes.add( new PhylogenyNode( "X" ) );
11454 // query_nodes.add( new PhylogenyNode( "Y" ) );
11455 // query_nodes.add( new PhylogenyNode( "A" ) );
11456 // query_nodes.add( new PhylogenyNode( "B" ) );
11457 // query_nodes.add( new PhylogenyNode( "C" ) );
11458 // query_nodes.add( new PhylogenyNode( "D" ) );
11459 // if ( !s0.match( query_nodes ) ) {
11463 // query_nodes = new HashSet<PhylogenyNode>();
11464 // query_nodes.add( new PhylogenyNode( "X" ) );
11465 // query_nodes.add( new PhylogenyNode( "Y" ) );
11466 // query_nodes.add( new PhylogenyNode( "E" ) );
11467 // query_nodes.add( new PhylogenyNode( "F" ) );
11468 // query_nodes.add( new PhylogenyNode( "G" ) );
11469 // if ( !s0.match( query_nodes ) ) {
11473 // query_nodes = new HashSet<PhylogenyNode>();
11474 // query_nodes.add( new PhylogenyNode( "X" ) );
11475 // query_nodes.add( new PhylogenyNode( "Y" ) );
11476 // query_nodes.add( new PhylogenyNode( "F" ) );
11477 // query_nodes.add( new PhylogenyNode( "G" ) );
11478 // if ( !s0.match( query_nodes ) ) {
11482 query_nodes = new HashSet<PhylogenyNode>();
11483 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11484 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11487 if ( s0.match( query_nodes ) ) {
11491 query_nodes = new HashSet<PhylogenyNode>();
11492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11496 if ( s0.match( query_nodes ) ) {
11499 ///////////////////////////
11501 query_nodes = new HashSet<PhylogenyNode>();
11502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11505 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11506 if ( s0.match( query_nodes ) ) {
11510 query_nodes = new HashSet<PhylogenyNode>();
11511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11513 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11514 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11515 if ( s0.match( query_nodes ) ) {
11519 query_nodes = new HashSet<PhylogenyNode>();
11520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11522 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11523 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11524 if ( s0.match( query_nodes ) ) {
11528 query_nodes = new HashSet<PhylogenyNode>();
11529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11531 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11533 if ( s0.match( query_nodes ) ) {
11537 query_nodes = new HashSet<PhylogenyNode>();
11538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11539 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11540 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11541 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11542 if ( s0.match( query_nodes ) ) {
11546 query_nodes = new HashSet<PhylogenyNode>();
11547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11548 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11549 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11550 if ( s0.match( query_nodes ) ) {
11554 query_nodes = new HashSet<PhylogenyNode>();
11555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11558 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11559 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11560 if ( s0.match( query_nodes ) ) {
11564 query_nodes = new HashSet<PhylogenyNode>();
11565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11570 if ( s0.match( query_nodes ) ) {
11574 query_nodes = new HashSet<PhylogenyNode>();
11575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11580 if ( s0.match( query_nodes ) ) {
11584 query_nodes = new HashSet<PhylogenyNode>();
11585 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11586 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11590 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11591 if ( s0.match( query_nodes ) ) {
11595 catch ( final Exception e ) {
11596 e.printStackTrace();
11602 private static boolean testSplitStrict() {
11604 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11605 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11606 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11607 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11608 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11609 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11610 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11611 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11612 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11613 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11614 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11615 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11618 if ( s0.match( query_nodes ) ) {
11621 query_nodes = new HashSet<PhylogenyNode>();
11622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11626 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11627 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11629 if ( !s0.match( query_nodes ) ) {
11633 query_nodes = new HashSet<PhylogenyNode>();
11634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11635 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11636 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11637 if ( !s0.match( query_nodes ) ) {
11641 query_nodes = new HashSet<PhylogenyNode>();
11642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11644 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11645 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11646 if ( !s0.match( query_nodes ) ) {
11650 query_nodes = new HashSet<PhylogenyNode>();
11651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11655 if ( !s0.match( query_nodes ) ) {
11659 query_nodes = new HashSet<PhylogenyNode>();
11660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11663 if ( !s0.match( query_nodes ) ) {
11667 query_nodes = new HashSet<PhylogenyNode>();
11668 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11670 if ( !s0.match( query_nodes ) ) {
11674 query_nodes = new HashSet<PhylogenyNode>();
11675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11680 if ( !s0.match( query_nodes ) ) {
11684 query_nodes = new HashSet<PhylogenyNode>();
11685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11688 if ( !s0.match( query_nodes ) ) {
11692 query_nodes = new HashSet<PhylogenyNode>();
11693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11697 if ( !s0.match( query_nodes ) ) {
11701 query_nodes = new HashSet<PhylogenyNode>();
11702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11703 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11704 if ( s0.match( query_nodes ) ) {
11708 query_nodes = new HashSet<PhylogenyNode>();
11709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11713 if ( s0.match( query_nodes ) ) {
11717 query_nodes = new HashSet<PhylogenyNode>();
11718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11719 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11720 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11723 if ( s0.match( query_nodes ) ) {
11727 query_nodes = new HashSet<PhylogenyNode>();
11728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11731 if ( s0.match( query_nodes ) ) {
11735 query_nodes = new HashSet<PhylogenyNode>();
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11738 if ( s0.match( query_nodes ) ) {
11742 query_nodes = new HashSet<PhylogenyNode>();
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11745 if ( s0.match( query_nodes ) ) {
11749 query_nodes = new HashSet<PhylogenyNode>();
11750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11752 if ( s0.match( query_nodes ) ) {
11756 query_nodes = new HashSet<PhylogenyNode>();
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11758 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11759 if ( s0.match( query_nodes ) ) {
11763 query_nodes = new HashSet<PhylogenyNode>();
11764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11766 if ( s0.match( query_nodes ) ) {
11770 query_nodes = new HashSet<PhylogenyNode>();
11771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
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( "F" ) );
11780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11781 if ( s0.match( query_nodes ) ) {
11785 query_nodes = new HashSet<PhylogenyNode>();
11786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11789 if ( s0.match( query_nodes ) ) {
11793 query_nodes = new HashSet<PhylogenyNode>();
11794 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11797 if ( s0.match( query_nodes ) ) {
11801 query_nodes = new HashSet<PhylogenyNode>();
11802 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11806 if ( s0.match( query_nodes ) ) {
11810 catch ( final Exception e ) {
11811 e.printStackTrace();
11817 private static boolean testSubtreeDeletion() {
11819 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11820 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11821 t1.deleteSubtree( t1.getNode( "A" ), false );
11822 if ( t1.getNumberOfExternalNodes() != 5 ) {
11825 t1.toNewHampshireX();
11826 t1.deleteSubtree( t1.getNode( "E" ), false );
11827 if ( t1.getNumberOfExternalNodes() != 4 ) {
11830 t1.toNewHampshireX();
11831 t1.deleteSubtree( t1.getNode( "F" ), false );
11832 if ( t1.getNumberOfExternalNodes() != 3 ) {
11835 t1.toNewHampshireX();
11836 t1.deleteSubtree( t1.getNode( "D" ), false );
11837 t1.toNewHampshireX();
11838 if ( t1.getNumberOfExternalNodes() != 3 ) {
11841 t1.deleteSubtree( t1.getNode( "def" ), false );
11842 t1.toNewHampshireX();
11843 if ( t1.getNumberOfExternalNodes() != 2 ) {
11846 t1.deleteSubtree( t1.getNode( "B" ), false );
11847 t1.toNewHampshireX();
11848 if ( t1.getNumberOfExternalNodes() != 1 ) {
11851 t1.deleteSubtree( t1.getNode( "C" ), false );
11852 t1.toNewHampshireX();
11853 if ( t1.getNumberOfExternalNodes() != 1 ) {
11856 t1.deleteSubtree( t1.getNode( "abc" ), false );
11857 t1.toNewHampshireX();
11858 if ( t1.getNumberOfExternalNodes() != 1 ) {
11861 t1.deleteSubtree( t1.getNode( "r" ), false );
11862 if ( t1.getNumberOfExternalNodes() != 0 ) {
11865 if ( !t1.isEmpty() ) {
11868 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11869 t2.deleteSubtree( t2.getNode( "A" ), false );
11870 t2.toNewHampshireX();
11871 if ( t2.getNumberOfExternalNodes() != 5 ) {
11874 t2.deleteSubtree( t2.getNode( "abc" ), false );
11875 t2.toNewHampshireX();
11876 if ( t2.getNumberOfExternalNodes() != 3 ) {
11879 t2.deleteSubtree( t2.getNode( "def" ), false );
11880 t2.toNewHampshireX();
11881 if ( t2.getNumberOfExternalNodes() != 1 ) {
11885 catch ( final Exception e ) {
11886 e.printStackTrace( System.out );
11892 private static boolean testSupportCount() {
11894 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11895 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11896 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11897 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11898 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11899 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11900 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11902 SupportCount.count( t0_1, phylogenies_1, true, false );
11903 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11904 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11905 + "(((((A,B),C),D),E),((F,G),X))"
11906 + "(((((A,Y),B),C),D),((F,G),E))"
11907 + "(((((A,B),C),D),E),(F,G))"
11908 + "(((((A,B),C),D),E),(F,G))"
11909 + "(((((A,B),C),D),E),(F,G))"
11910 + "(((((A,B),C),D),E),(F,G),Z)"
11911 + "(((((A,B),C),D),E),(F,G))"
11912 + "((((((A,B),C),D),E),F),G)"
11913 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11915 SupportCount.count( t0_2, phylogenies_2, true, false );
11916 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11917 while ( it.hasNext() ) {
11918 final PhylogenyNode n = it.next();
11919 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11923 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11924 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11925 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11926 SupportCount.count( t0_3, phylogenies_3, true, false );
11927 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11928 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11931 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11934 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11937 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11940 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11943 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11946 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11949 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11952 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11955 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11958 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11959 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11960 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11961 SupportCount.count( t0_4, phylogenies_4, true, false );
11962 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11963 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11966 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11969 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11972 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11975 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11978 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11981 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11984 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11987 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11990 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11993 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11994 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11995 double d = SupportCount.compare( b1, a, true, true, true );
11996 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11999 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12000 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12001 d = SupportCount.compare( b2, a, true, true, true );
12002 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12005 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12006 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12007 d = SupportCount.compare( b3, a, true, true, true );
12008 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12011 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12012 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12013 d = SupportCount.compare( b4, a, true, true, false );
12014 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12018 catch ( final Exception e ) {
12019 e.printStackTrace( System.out );
12025 private static boolean testSupportTransfer() {
12027 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12028 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)",
12029 new NHXParser() )[ 0 ];
12030 final Phylogeny p2 = factory
12031 .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 ];
12032 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12035 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12038 support_transfer.moveBranchLengthsToBootstrap( p1 );
12039 support_transfer.transferSupportValues( p1, p2 );
12040 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12043 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12046 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12049 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12052 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12055 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12058 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12061 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12065 catch ( final Exception e ) {
12066 e.printStackTrace( System.out );
12072 private static boolean testTaxonomyExtraction() {
12074 final PhylogenyNode n0 = PhylogenyNode
12075 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12076 if ( n0.getNodeData().isHasTaxonomy() ) {
12079 final PhylogenyNode n1 = PhylogenyNode
12080 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12081 if ( n1.getNodeData().isHasTaxonomy() ) {
12082 System.out.println( n1.toString() );
12085 final PhylogenyNode n2x = PhylogenyNode
12086 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12087 if ( n2x.getNodeData().isHasTaxonomy() ) {
12090 final PhylogenyNode n3 = PhylogenyNode
12091 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12092 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12093 System.out.println( n3.toString() );
12096 final PhylogenyNode n4 = PhylogenyNode
12097 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12098 if ( n4.getNodeData().isHasTaxonomy() ) {
12099 System.out.println( n4.toString() );
12102 final PhylogenyNode n5 = PhylogenyNode
12103 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12104 if ( n5.getNodeData().isHasTaxonomy() ) {
12105 System.out.println( n5.toString() );
12108 final PhylogenyNode n6 = PhylogenyNode
12109 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12110 if ( n6.getNodeData().isHasTaxonomy() ) {
12111 System.out.println( n6.toString() );
12114 final PhylogenyNode n7 = PhylogenyNode
12115 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12116 if ( n7.getNodeData().isHasTaxonomy() ) {
12117 System.out.println( n7.toString() );
12120 final PhylogenyNode n8 = PhylogenyNode
12121 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12122 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12123 System.out.println( n8.toString() );
12126 final PhylogenyNode n9 = PhylogenyNode
12127 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12128 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12129 System.out.println( n9.toString() );
12132 final PhylogenyNode n10x = PhylogenyNode
12133 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12134 if ( n10x.getNodeData().isHasTaxonomy() ) {
12135 System.out.println( n10x.toString() );
12138 final PhylogenyNode n10xx = PhylogenyNode
12139 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12140 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12141 System.out.println( n10xx.toString() );
12144 final PhylogenyNode n10 = PhylogenyNode
12145 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12146 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12147 System.out.println( n10.toString() );
12150 final PhylogenyNode n11 = PhylogenyNode
12151 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12152 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12153 System.out.println( n11.toString() );
12156 final PhylogenyNode n12 = PhylogenyNode
12157 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12158 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12159 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12160 System.out.println( n12.toString() );
12163 final PhylogenyNode n13 = PhylogenyNode
12164 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12165 if ( n13.getNodeData().isHasTaxonomy() ) {
12166 System.out.println( n13.toString() );
12169 final PhylogenyNode n14 = PhylogenyNode
12170 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12171 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12172 System.out.println( n14.toString() );
12175 final PhylogenyNode n15 = PhylogenyNode
12176 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12177 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12178 System.out.println( n15.toString() );
12181 final PhylogenyNode n16 = PhylogenyNode
12182 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12183 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12184 System.out.println( n16.toString() );
12187 final PhylogenyNode n17 = PhylogenyNode
12188 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12189 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12190 System.out.println( n17.toString() );
12194 final PhylogenyNode n18 = PhylogenyNode
12195 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12196 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12197 System.out.println( n18.toString() );
12200 final PhylogenyNode n19 = PhylogenyNode
12201 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12202 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12203 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12204 System.out.println( n19.toString() );
12207 final PhylogenyNode n20 = PhylogenyNode
12208 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12209 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12210 System.out.println( n20.toString() );
12213 final PhylogenyNode n21 = PhylogenyNode
12214 .createInstanceFromNhxString( "Mus musculus musculus K392",
12215 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12216 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12217 System.out.println( n21.toString() );
12220 final PhylogenyNode n22 = PhylogenyNode
12221 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12222 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12223 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12224 System.out.println( n22.toString() );
12227 final PhylogenyNode n23 = PhylogenyNode
12228 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12229 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12230 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12231 System.out.println( n23.toString() );
12234 final PhylogenyNode n24 = PhylogenyNode
12235 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12236 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12237 System.out.println( n24.toString() );
12241 final PhylogenyNode n25 = PhylogenyNode
12242 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12243 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12244 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12245 System.out.println( n25.toString() );
12248 final PhylogenyNode n26 = PhylogenyNode
12249 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12250 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12251 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12252 System.out.println( n26.toString() );
12255 final PhylogenyNode n27 = PhylogenyNode
12256 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12257 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12258 System.out.println( n27.toString() );
12262 catch ( final Exception e ) {
12263 e.printStackTrace( System.out );
12269 private static boolean testTreeCopy() {
12271 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12272 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12273 final Phylogeny t1 = t0.copy();
12274 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12277 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12280 t0.deleteSubtree( t0.getNode( "c" ), true );
12281 t0.deleteSubtree( t0.getNode( "a" ), true );
12282 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12283 t0.getNode( "b" ).setName( "Bee" );
12284 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12287 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12290 t0.deleteSubtree( t0.getNode( "e" ), true );
12291 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12292 t0.deleteSubtree( t0.getNode( "d" ), true );
12293 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12297 catch ( final Exception e ) {
12298 e.printStackTrace();
12304 private static boolean testTreeMethods() {
12306 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12307 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12308 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12309 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12310 System.out.println( t0.toNewHampshireX() );
12313 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12314 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12315 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12318 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12321 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12325 catch ( final Exception e ) {
12326 e.printStackTrace( System.out );
12332 private static boolean testUniprotEntryRetrieval() {
12334 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12335 if ( !entry.getAccession().equals( "P12345" ) ) {
12338 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12341 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12344 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12347 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12350 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12354 catch ( final IOException e ) {
12355 System.out.println();
12356 System.out.println( "the following might be due to absence internet connection:" );
12357 e.printStackTrace( System.out );
12360 catch ( final Exception e ) {
12366 private static boolean testUniprotTaxonomySearch() {
12368 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12370 if ( results.size() != 1 ) {
12373 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12376 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12379 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12382 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12385 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12389 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12390 if ( results.size() != 1 ) {
12393 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12396 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12399 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12402 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12405 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12409 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12410 if ( results.size() != 1 ) {
12413 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12416 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12419 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12422 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12425 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12429 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12430 if ( results.size() != 1 ) {
12433 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12436 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12439 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12442 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12445 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12448 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12451 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12454 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12455 .equals( "Nematostella vectensis" ) ) {
12456 System.out.println( results.get( 0 ).getLineage() );
12461 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12462 if ( results.size() != 1 ) {
12465 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12468 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12471 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12474 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12477 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12480 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12481 .equals( "Xenopus tropicalis" ) ) {
12482 System.out.println( results.get( 0 ).getLineage() );
12487 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12488 if ( results.size() != 1 ) {
12491 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12494 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12497 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12500 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12503 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12506 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12507 .equals( "Xenopus tropicalis" ) ) {
12508 System.out.println( results.get( 0 ).getLineage() );
12513 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12514 if ( results.size() != 1 ) {
12517 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12520 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12523 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12526 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12529 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12532 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12533 .equals( "Xenopus tropicalis" ) ) {
12534 System.out.println( results.get( 0 ).getLineage() );
12538 catch ( final IOException e ) {
12539 System.out.println();
12540 System.out.println( "the following might be due to absence internet connection:" );
12541 e.printStackTrace( System.out );
12544 catch ( final Exception e ) {
12550 private static boolean testWabiTxSearch() {
12552 String result = "";
12553 result = TxSearch.searchSimple( "nematostella" );
12554 result = TxSearch.getTxId( "nematostella" );
12555 if ( !result.equals( "45350" ) ) {
12558 result = TxSearch.getTxName( "45350" );
12559 if ( !result.equals( "Nematostella" ) ) {
12562 result = TxSearch.getTxId( "nematostella vectensis" );
12563 if ( !result.equals( "45351" ) ) {
12566 result = TxSearch.getTxName( "45351" );
12567 if ( !result.equals( "Nematostella vectensis" ) ) {
12570 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12571 if ( !result.equals( "536089" ) ) {
12574 result = TxSearch.getTxName( "536089" );
12575 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12578 final List<String> queries = new ArrayList<String>();
12579 queries.add( "Campylobacter coli" );
12580 queries.add( "Escherichia coli" );
12581 queries.add( "Arabidopsis" );
12582 queries.add( "Trichoplax" );
12583 queries.add( "Samanea saman" );
12584 queries.add( "Kluyveromyces marxianus" );
12585 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12586 queries.add( "Bornavirus parrot/PDD/2008" );
12587 final List<RANKS> ranks = new ArrayList<RANKS>();
12588 ranks.add( RANKS.SUPERKINGDOM );
12589 ranks.add( RANKS.KINGDOM );
12590 ranks.add( RANKS.FAMILY );
12591 ranks.add( RANKS.GENUS );
12592 ranks.add( RANKS.TRIBE );
12593 result = TxSearch.searchLineage( queries, ranks );
12594 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12595 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12597 catch ( final Exception e ) {
12598 System.out.println();
12599 System.out.println( "the following might be due to absence internet connection:" );
12600 e.printStackTrace( System.out );