2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
33 import java.util.ArrayList;
34 import java.util.Date;
35 import java.util.HashSet;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Locale;
40 import java.util.SortedSet;
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.archaeopteryx.webservices.WebserviceUtil;
45 import org.forester.development.DevelopmentTools;
46 import org.forester.evoinference.TestPhylogenyReconstruction;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
48 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
49 import org.forester.go.TestGo;
50 import org.forester.io.parsers.FastaParser;
51 import org.forester.io.parsers.GeneralMsaParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser;
53 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
54 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
55 import org.forester.io.parsers.nexus.NexusCharactersParser;
56 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
57 import org.forester.io.parsers.nhx.NHXParser;
58 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
59 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
60 import org.forester.io.parsers.tol.TolParser;
61 import org.forester.io.parsers.util.ParserUtils;
62 import org.forester.io.writers.PhylogenyWriter;
63 import org.forester.io.writers.SequenceWriter;
64 import org.forester.msa.BasicMsa;
65 import org.forester.msa.Mafft;
66 import org.forester.msa.Msa;
67 import org.forester.msa.MsaInferrer;
68 import org.forester.msa.MsaMethods;
69 import org.forester.pccx.TestPccx;
70 import org.forester.phylogeny.Phylogeny;
71 import org.forester.phylogeny.PhylogenyBranch;
72 import org.forester.phylogeny.PhylogenyMethods;
73 import org.forester.phylogeny.PhylogenyNode;
74 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
75 import org.forester.phylogeny.data.Accession;
76 import org.forester.phylogeny.data.Accession.Source;
77 import org.forester.phylogeny.data.BinaryCharacters;
78 import org.forester.phylogeny.data.BranchWidth;
79 import org.forester.phylogeny.data.Confidence;
80 import org.forester.phylogeny.data.Distribution;
81 import org.forester.phylogeny.data.DomainArchitecture;
82 import org.forester.phylogeny.data.Event;
83 import org.forester.phylogeny.data.Identifier;
84 import org.forester.phylogeny.data.PhylogenyData;
85 import org.forester.phylogeny.data.PhylogenyDataUtil;
86 import org.forester.phylogeny.data.Polygon;
87 import org.forester.phylogeny.data.PropertiesMap;
88 import org.forester.phylogeny.data.Property;
89 import org.forester.phylogeny.data.Property.AppliesTo;
90 import org.forester.phylogeny.data.ProteinDomain;
91 import org.forester.phylogeny.data.Taxonomy;
92 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
93 import org.forester.phylogeny.factories.PhylogenyFactory;
94 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
95 import org.forester.protein.BasicDomain;
96 import org.forester.protein.BasicProtein;
97 import org.forester.protein.Domain;
98 import org.forester.protein.Protein;
99 import org.forester.protein.ProteinId;
100 import org.forester.rio.TestRIO;
101 import org.forester.sdi.SDI;
102 import org.forester.sdi.SDIR;
103 import org.forester.sdi.TestGSDI;
104 import org.forester.sequence.BasicSequence;
105 import org.forester.sequence.Sequence;
106 import org.forester.species.BasicSpecies;
107 import org.forester.species.Species;
108 import org.forester.surfacing.TestSurfacing;
109 import org.forester.tools.ConfidenceAssessor;
110 import org.forester.tools.SupportCount;
111 import org.forester.tools.TreeSplitMatrix;
112 import org.forester.util.AsciiHistogram;
113 import org.forester.util.BasicDescriptiveStatistics;
114 import org.forester.util.BasicTable;
115 import org.forester.util.BasicTableParser;
116 import org.forester.util.DescriptiveStatistics;
117 import org.forester.util.ForesterConstants;
118 import org.forester.util.ForesterUtil;
119 import org.forester.util.GeneralTable;
120 import org.forester.util.SequenceAccessionTools;
121 import org.forester.ws.seqdb.SequenceDatabaseEntry;
122 import org.forester.ws.seqdb.SequenceDbWsTools;
123 import org.forester.ws.seqdb.UniProtTaxonomy;
124 import org.forester.ws.wabi.TxSearch;
125 import org.forester.ws.wabi.TxSearch.RANKS;
126 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
127 import org.forester.ws.wabi.TxSearch.TAX_RANK;
129 @SuppressWarnings( "unused")
130 public final class Test {
132 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "resources"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "test_data"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean PERFORM_DB_TESTS = false;
139 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
140 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/"
142 + ForesterConstants.PHYLO_XML_XSD;
143 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
144 + ForesterConstants.PHYLO_XML_VERSION + "/"
145 + ForesterConstants.PHYLO_XML_XSD;
146 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
147 private final static double ZERO_DIFF = 1.0E-9;
149 public static boolean isEqual( final double a, final double b ) {
150 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
153 public static void main( final String[] args ) {
154 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
155 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
157 Locale.setDefault( Locale.US );
158 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
161 System.out.print( "[Test if directory with files for testing exists/is readable: " );
162 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
163 System.out.println( "OK.]" );
166 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
167 System.out.println( "Testing aborted." );
170 System.out.print( "[Test if resources directory exists/is readable: " );
171 if ( testDir( PATH_TO_RESOURCES ) ) {
172 System.out.println( "OK.]" );
175 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
176 System.out.println( "Testing aborted." );
179 final long start_time = new Date().getTime();
180 System.out.print( "Basic node methods: " );
181 if ( Test.testBasicNodeMethods() ) {
182 System.out.println( "OK." );
186 System.out.println( "failed." );
189 System.out.print( "Protein id: " );
190 if ( !testProteinId() ) {
191 System.out.println( "failed." );
197 System.out.println( "OK." );
198 System.out.print( "Species: " );
199 if ( !testSpecies() ) {
200 System.out.println( "failed." );
206 System.out.println( "OK." );
207 System.out.print( "Basic domain: " );
208 if ( !testBasicDomain() ) {
209 System.out.println( "failed." );
215 System.out.println( "OK." );
216 System.out.print( "Basic protein: " );
217 if ( !testBasicProtein() ) {
218 System.out.println( "failed." );
224 System.out.println( "OK." );
225 System.out.print( "Sequence writer: " );
226 if ( testSequenceWriter() ) {
227 System.out.println( "OK." );
231 System.out.println( "failed." );
234 System.out.print( "Sequence id parsing: " );
235 if ( testSequenceIdParsing() ) {
236 System.out.println( "OK." );
240 System.out.println( "failed." );
243 System.out.print( "UniProtKB id extraction: " );
244 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
245 System.out.println( "OK." );
249 System.out.println( "failed." );
252 System.out.print( "Sequence DB tools 1: " );
253 if ( testSequenceDbWsTools1() ) {
254 System.out.println( "OK." );
258 System.out.println( "failed." );
261 System.out.print( "Hmmscan output parser: " );
262 if ( testHmmscanOutputParser() ) {
263 System.out.println( "OK." );
267 System.out.println( "failed." );
270 System.out.print( "Overlap removal: " );
271 if ( !org.forester.test.Test.testOverlapRemoval() ) {
272 System.out.println( "failed." );
278 System.out.println( "OK." );
279 System.out.print( "Engulfing overlap removal: " );
280 if ( !Test.testEngulfingOverlapRemoval() ) {
281 System.out.println( "failed." );
287 System.out.println( "OK." );
288 System.out.print( "Taxonomy code extraction: " );
289 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
290 System.out.println( "OK." );
294 System.out.println( "failed." );
297 System.out.print( "SN extraction: " );
298 if ( Test.testExtractSNFromNodeName() ) {
299 System.out.println( "OK." );
303 System.out.println( "failed." );
306 System.out.print( "Taxonomy extraction (general): " );
307 if ( Test.testTaxonomyExtraction() ) {
308 System.out.println( "OK." );
312 System.out.println( "failed." );
316 System.out.print( "Uri for Aptx web sequence accession: " );
317 if ( Test.testCreateUriForSeqWeb() ) {
318 System.out.println( "OK." );
322 System.out.println( "failed." );
325 System.out.print( "Basic node construction and parsing of NHX (node level): " );
326 if ( Test.testNHXNodeParsing() ) {
327 System.out.println( "OK." );
331 System.out.println( "failed." );
334 System.out.print( "NHX parsing iterating: " );
335 if ( Test.testNHParsingIter() ) {
336 System.out.println( "OK." );
340 System.out.println( "failed." );
343 System.out.print( "NH parsing: " );
344 if ( Test.testNHParsing() ) {
345 System.out.println( "OK." );
349 System.out.println( "failed." );
352 System.out.print( "Conversion to NHX (node level): " );
353 if ( Test.testNHXconversion() ) {
354 System.out.println( "OK." );
358 System.out.println( "failed." );
361 System.out.print( "NHX parsing: " );
362 if ( Test.testNHXParsing() ) {
363 System.out.println( "OK." );
367 System.out.println( "failed." );
370 System.out.print( "NHX parsing with quotes: " );
371 if ( Test.testNHXParsingQuotes() ) {
372 System.out.println( "OK." );
376 System.out.println( "failed." );
379 System.out.print( "NHX parsing (MrBayes): " );
380 if ( Test.testNHXParsingMB() ) {
381 System.out.println( "OK." );
385 System.out.println( "failed." );
388 System.out.print( "Nexus characters parsing: " );
389 if ( Test.testNexusCharactersParsing() ) {
390 System.out.println( "OK." );
394 System.out.println( "failed." );
397 System.out.print( "Nexus tree parsing iterating: " );
398 if ( Test.testNexusTreeParsingIterating() ) {
399 System.out.println( "OK." );
403 System.out.println( "failed." );
406 System.out.print( "Nexus tree parsing: " );
407 if ( Test.testNexusTreeParsing() ) {
408 System.out.println( "OK." );
412 System.out.println( "failed." );
415 System.out.print( "Nexus tree parsing (translating): " );
416 if ( Test.testNexusTreeParsingTranslating() ) {
417 System.out.println( "OK." );
421 System.out.println( "failed." );
424 System.out.print( "Nexus matrix parsing: " );
425 if ( Test.testNexusMatrixParsing() ) {
426 System.out.println( "OK." );
430 System.out.println( "failed." );
433 System.out.print( "Basic phyloXML parsing: " );
434 if ( Test.testBasicPhyloXMLparsing() ) {
435 System.out.println( "OK." );
439 System.out.println( "failed." );
442 System.out.print( "Basic phyloXML parsing (validating against schema): " );
443 if ( testBasicPhyloXMLparsingValidating() ) {
444 System.out.println( "OK." );
448 System.out.println( "failed." );
451 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
452 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
453 System.out.println( "OK." );
457 System.out.println( "failed." );
460 System.out.print( "phyloXML Distribution Element: " );
461 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
462 System.out.println( "OK." );
466 System.out.println( "failed." );
469 System.out.print( "Tol XML parsing: " );
470 if ( Test.testBasicTolXMLparsing() ) {
471 System.out.println( "OK." );
475 System.out.println( "failed." );
478 System.out.print( "Copying of node data: " );
479 if ( Test.testCopyOfNodeData() ) {
480 System.out.println( "OK." );
484 System.out.println( "failed." );
487 System.out.print( "Tree copy: " );
488 if ( Test.testTreeCopy() ) {
489 System.out.println( "OK." );
493 System.out.println( "failed." );
496 System.out.print( "Basic tree methods: " );
497 if ( Test.testBasicTreeMethods() ) {
498 System.out.println( "OK." );
502 System.out.println( "failed." );
505 System.out.print( "Tree methods: " );
506 if ( Test.testTreeMethods() ) {
507 System.out.println( "OK." );
511 System.out.println( "failed." );
514 System.out.print( "Postorder Iterator: " );
515 if ( Test.testPostOrderIterator() ) {
516 System.out.println( "OK." );
520 System.out.println( "failed." );
523 System.out.print( "Preorder Iterator: " );
524 if ( Test.testPreOrderIterator() ) {
525 System.out.println( "OK." );
529 System.out.println( "failed." );
532 System.out.print( "Levelorder Iterator: " );
533 if ( Test.testLevelOrderIterator() ) {
534 System.out.println( "OK." );
538 System.out.println( "failed." );
541 System.out.print( "Re-id methods: " );
542 if ( Test.testReIdMethods() ) {
543 System.out.println( "OK." );
547 System.out.println( "failed." );
550 System.out.print( "Methods on last external nodes: " );
551 if ( Test.testLastExternalNodeMethods() ) {
552 System.out.println( "OK." );
556 System.out.println( "failed." );
559 System.out.print( "Methods on external nodes: " );
560 if ( Test.testExternalNodeRelatedMethods() ) {
561 System.out.println( "OK." );
565 System.out.println( "failed." );
568 System.out.print( "Deletion of external nodes: " );
569 if ( Test.testDeletionOfExternalNodes() ) {
570 System.out.println( "OK." );
574 System.out.println( "failed." );
577 System.out.print( "Subtree deletion: " );
578 if ( Test.testSubtreeDeletion() ) {
579 System.out.println( "OK." );
583 System.out.println( "failed." );
586 System.out.print( "Phylogeny branch: " );
587 if ( Test.testPhylogenyBranch() ) {
588 System.out.println( "OK." );
592 System.out.println( "failed." );
595 System.out.print( "Rerooting: " );
596 if ( Test.testRerooting() ) {
597 System.out.println( "OK." );
601 System.out.println( "failed." );
604 System.out.print( "Mipoint rooting: " );
605 if ( Test.testMidpointrooting() ) {
606 System.out.println( "OK." );
610 System.out.println( "failed." );
613 System.out.print( "Node removal: " );
614 if ( Test.testNodeRemoval() ) {
615 System.out.println( "OK." );
619 System.out.println( "failed." );
622 System.out.print( "Support count: " );
623 if ( Test.testSupportCount() ) {
624 System.out.println( "OK." );
628 System.out.println( "failed." );
631 System.out.print( "Support transfer: " );
632 if ( Test.testSupportTransfer() ) {
633 System.out.println( "OK." );
637 System.out.println( "failed." );
640 System.out.print( "Finding of LCA: " );
641 if ( Test.testGetLCA() ) {
642 System.out.println( "OK." );
646 System.out.println( "failed." );
649 System.out.print( "Finding of LCA 2: " );
650 if ( Test.testGetLCA2() ) {
651 System.out.println( "OK." );
655 System.out.println( "failed." );
658 System.out.print( "Calculation of distance between nodes: " );
659 if ( Test.testGetDistance() ) {
660 System.out.println( "OK." );
664 System.out.println( "failed." );
667 System.out.print( "Descriptive statistics: " );
668 if ( Test.testDescriptiveStatistics() ) {
669 System.out.println( "OK." );
673 System.out.println( "failed." );
676 System.out.print( "Data objects and methods: " );
677 if ( Test.testDataObjects() ) {
678 System.out.println( "OK." );
682 System.out.println( "failed." );
685 System.out.print( "Properties map: " );
686 if ( Test.testPropertiesMap() ) {
687 System.out.println( "OK." );
691 System.out.println( "failed." );
694 System.out.print( "SDIse: " );
695 if ( Test.testSDIse() ) {
696 System.out.println( "OK." );
700 System.out.println( "failed." );
703 System.out.print( "SDIunrooted: " );
704 if ( Test.testSDIunrooted() ) {
705 System.out.println( "OK." );
709 System.out.println( "failed." );
712 System.out.print( "GSDI: " );
713 if ( TestGSDI.test() ) {
714 System.out.println( "OK." );
718 System.out.println( "failed." );
721 System.out.print( "RIO: " );
722 if ( TestRIO.test() ) {
723 System.out.println( "OK." );
727 System.out.println( "failed." );
730 System.out.print( "Phylogeny reconstruction:" );
731 System.out.println();
732 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
733 System.out.println( "OK." );
737 System.out.println( "failed." );
740 System.out.print( "Analysis of domain architectures: " );
741 System.out.println();
742 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
743 System.out.println( "OK." );
747 System.out.println( "failed." );
750 System.out.print( "GO: " );
751 System.out.println();
752 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
753 System.out.println( "OK." );
757 System.out.println( "failed." );
760 System.out.print( "Modeling tools: " );
761 if ( TestPccx.test() ) {
762 System.out.println( "OK." );
766 System.out.println( "failed." );
769 System.out.print( "Split Matrix strict: " );
770 if ( Test.testSplitStrict() ) {
771 System.out.println( "OK." );
775 System.out.println( "failed." );
778 System.out.print( "Split Matrix: " );
779 if ( Test.testSplit() ) {
780 System.out.println( "OK." );
784 System.out.println( "failed." );
787 System.out.print( "Confidence Assessor: " );
788 if ( Test.testConfidenceAssessor() ) {
789 System.out.println( "OK." );
793 System.out.println( "failed." );
796 System.out.print( "Basic table: " );
797 if ( Test.testBasicTable() ) {
798 System.out.println( "OK." );
802 System.out.println( "failed." );
805 System.out.print( "General table: " );
806 if ( Test.testGeneralTable() ) {
807 System.out.println( "OK." );
811 System.out.println( "failed." );
814 System.out.print( "Amino acid sequence: " );
815 if ( Test.testAminoAcidSequence() ) {
816 System.out.println( "OK." );
820 System.out.println( "failed." );
823 System.out.print( "General MSA parser: " );
824 if ( Test.testGeneralMsaParser() ) {
825 System.out.println( "OK." );
829 System.out.println( "failed." );
832 System.out.print( "Fasta parser for msa: " );
833 if ( Test.testFastaParser() ) {
834 System.out.println( "OK." );
838 System.out.println( "failed." );
841 System.out.print( "Creation of balanced phylogeny: " );
842 if ( Test.testCreateBalancedPhylogeny() ) {
843 System.out.println( "OK." );
847 System.out.println( "failed." );
850 System.out.print( "Genbank accessor parsing: " );
851 if ( Test.testGenbankAccessorParsing() ) {
852 System.out.println( "OK." );
856 System.out.println( "failed." );
860 final String os = ForesterUtil.OS_NAME.toLowerCase();
861 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
862 path = "/usr/local/bin/mafft";
864 else if ( os.indexOf( "win" ) >= 0 ) {
865 path = "C:\\Program Files\\mafft-win\\mafft.bat";
869 if ( !MsaInferrer.isInstalled( path ) ) {
870 path = "/usr/bin/mafft";
872 if ( !MsaInferrer.isInstalled( path ) ) {
873 path = "/usr/local/bin/mafft";
876 if ( MsaInferrer.isInstalled( path ) ) {
877 System.out.print( "MAFFT (external program): " );
878 if ( Test.testMafft( path ) ) {
879 System.out.println( "OK." );
883 System.out.println( "failed [will not count towards failed tests]" );
886 System.out.print( "Next nodes with collapsed: " );
887 if ( Test.testNextNodeWithCollapsing() ) {
888 System.out.println( "OK." );
892 System.out.println( "failed." );
895 System.out.print( "Simple MSA quality: " );
896 if ( Test.testMsaQualityMethod() ) {
897 System.out.println( "OK." );
901 System.out.println( "failed." );
904 if ( PERFORM_DB_TESTS ) {
905 System.out.print( "Uniprot Entry Retrieval: " );
906 if ( Test.testUniprotEntryRetrieval() ) {
907 System.out.println( "OK." );
911 System.out.println( "failed." );
914 System.out.print( "Ebi Entry Retrieval: " );
915 if ( Test.testEbiEntryRetrieval() ) {
916 System.out.println( "OK." );
920 System.out.println( "failed." );
923 System.out.print( "Sequence DB tools 2: " );
924 if ( testSequenceDbWsTools2() ) {
925 System.out.println( "OK." );
929 System.out.println( "failed." );
933 System.out.print( "Uniprot Taxonomy Search: " );
934 if ( Test.testUniprotTaxonomySearch() ) {
935 System.out.println( "OK." );
939 System.out.println( "failed." );
943 if ( PERFORM_WEB_TREE_ACCESS ) {
944 System.out.print( "NHX parsing from URL: " );
945 if ( Test.testNHXparsingFromURL() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
953 System.out.print( "phyloXML parsing from URL: " );
954 if ( Test.testPhyloXMLparsingFromURL() ) {
955 System.out.println( "OK." );
959 System.out.println( "failed." );
962 System.out.print( "TreeBase acccess: " );
963 if ( Test.testTreeBaseReading() ) {
964 System.out.println( "OK." );
968 System.out.println( "failed." );
972 System.out.print( "ToL access: " );
973 if ( Test.testToLReading() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
982 System.out.print( "TreeFam access: " );
983 if ( Test.testTreeFamReading() ) {
984 System.out.println( "OK." );
988 System.out.println( "failed." );
993 System.out.print( "Pfam tree access: " );
994 if ( Test.testPfamTreeReading() ) {
995 System.out.println( "OK." );
999 System.out.println( "failed." );
1003 System.out.println();
1004 final Runtime rt = java.lang.Runtime.getRuntime();
1005 final long free_memory = rt.freeMemory() / 1000000;
1006 final long total_memory = rt.totalMemory() / 1000000;
1007 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1008 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1009 System.out.println();
1010 System.out.println( "Successful tests: " + succeeded );
1011 System.out.println( "Failed tests: " + failed );
1012 System.out.println();
1014 System.out.println( "OK." );
1017 System.out.println( "Not OK." );
1021 public static boolean testEngulfingOverlapRemoval() {
1023 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1024 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1025 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1026 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1027 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1028 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1029 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1030 final List<Boolean> covered = new ArrayList<Boolean>();
1031 covered.add( true ); // 0
1032 covered.add( false ); // 1
1033 covered.add( true ); // 2
1034 covered.add( false ); // 3
1035 covered.add( true ); // 4
1036 covered.add( true ); // 5
1037 covered.add( false ); // 6
1038 covered.add( true ); // 7
1039 covered.add( true ); // 8
1040 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1043 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1046 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1049 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1052 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1055 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1058 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1061 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1062 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1063 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1064 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1065 abc.addProteinDomain( a );
1066 abc.addProteinDomain( b );
1067 abc.addProteinDomain( c );
1068 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1069 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1070 if ( abc.getNumberOfProteinDomains() != 3 ) {
1073 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1076 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1079 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1082 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1085 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1086 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1087 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1088 final Protein def = new BasicProtein( "def", "nemve", 0 );
1089 def.addProteinDomain( d );
1090 def.addProteinDomain( e );
1091 def.addProteinDomain( f );
1092 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1093 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1094 if ( def.getNumberOfProteinDomains() != 3 ) {
1097 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1100 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1103 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1106 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1109 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1113 catch ( final Exception e ) {
1114 e.printStackTrace( System.out );
1120 public static final boolean testNHXparsingFromURL() {
1122 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1123 final URL u = new URL( s );
1124 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1125 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1126 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1129 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1130 System.out.println( phys[ 0 ].toNewHampshire() );
1133 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1134 System.out.println( phys[ 1 ].toNewHampshire() );
1137 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1138 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1141 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1142 System.out.println( phys2[ 0 ].toNewHampshire() );
1145 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1146 final NHXParser p = new NHXParser();
1147 final URL u2 = new URL( s );
1149 if ( !p.hasNext() ) {
1152 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1155 if ( !p.hasNext() ) {
1159 if ( !p.hasNext() ) {
1162 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1165 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1169 if ( !p.hasNext() ) {
1172 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1175 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1179 catch ( final Exception e ) {
1180 e.printStackTrace();
1185 public static boolean testOverlapRemoval() {
1187 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1188 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1189 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1190 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1191 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1192 final List<Boolean> covered = new ArrayList<Boolean>();
1193 covered.add( true ); // 0
1194 covered.add( false ); // 1
1195 covered.add( true ); // 2
1196 covered.add( false ); // 3
1197 covered.add( true ); // 4
1198 covered.add( true ); // 5
1199 covered.add( false ); // 6
1200 covered.add( true ); // 7
1201 covered.add( true ); // 8
1202 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1205 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1208 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1211 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1214 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1217 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1218 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1219 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1220 ab.addProteinDomain( a );
1221 ab.addProteinDomain( b );
1222 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1223 if ( ab.getNumberOfProteinDomains() != 2 ) {
1226 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1229 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1232 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1233 if ( ab.getNumberOfProteinDomains() != 2 ) {
1236 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1239 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1240 final Domain d = new BasicDomain( "d",
1247 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1248 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1249 cde.addProteinDomain( c );
1250 cde.addProteinDomain( d );
1251 cde.addProteinDomain( e );
1252 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1253 if ( cde.getNumberOfProteinDomains() != 3 ) {
1256 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1259 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1260 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1261 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1262 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1263 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1264 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1265 fghi.addProteinDomain( f );
1266 fghi.addProteinDomain( g );
1267 fghi.addProteinDomain( h );
1268 fghi.addProteinDomain( i );
1269 fghi.addProteinDomain( i );
1270 fghi.addProteinDomain( i );
1271 fghi.addProteinDomain( i2 );
1272 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1273 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1276 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1279 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1282 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1283 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1286 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1289 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1290 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1291 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1292 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1293 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1294 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1295 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1296 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1297 jklm.addProteinDomain( j );
1298 jklm.addProteinDomain( k );
1299 jklm.addProteinDomain( l );
1300 jklm.addProteinDomain( m );
1301 jklm.addProteinDomain( m0 );
1302 jklm.addProteinDomain( m1 );
1303 jklm.addProteinDomain( m2 );
1304 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1305 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1308 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1311 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1314 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1315 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1318 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1321 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1322 final Protein od = new BasicProtein( "od", "varanus", 0 );
1323 od.addProteinDomain( only );
1324 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1325 if ( od.getNumberOfProteinDomains() != 1 ) {
1328 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1332 catch ( final Exception e ) {
1333 e.printStackTrace( System.out );
1339 public static final boolean testPfamTreeReading() {
1341 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1342 final NHXParser parser = new NHXParser();
1343 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1344 parser.setReplaceUnderscores( false );
1345 parser.setGuessRootedness( true );
1346 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1347 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1348 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1351 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1355 catch ( final Exception e ) {
1356 e.printStackTrace();
1361 public static final boolean testPhyloXMLparsingFromURL() {
1363 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1364 final URL u = new URL( s );
1365 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1366 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1367 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1371 catch ( final Exception e ) {
1372 e.printStackTrace();
1377 public static final boolean testToLReading() {
1379 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1380 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1381 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1382 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1385 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1388 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1391 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1395 catch ( final Exception e ) {
1396 e.printStackTrace();
1401 public static final boolean testTreeBaseReading() {
1403 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1404 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1405 parser.setReplaceUnderscores( true );
1406 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1407 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1408 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1411 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1412 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1413 parser2.setReplaceUnderscores( true );
1414 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1415 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1416 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1420 catch ( final Exception e ) {
1421 e.printStackTrace();
1426 public static final boolean testTreeFamReading() {
1428 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1429 final NHXParser parser = new NHXParser();
1430 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1431 parser.setReplaceUnderscores( false );
1432 parser.setGuessRootedness( true );
1433 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1434 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1435 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1438 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1442 catch ( final Exception e ) {
1443 e.printStackTrace();
1448 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1449 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1453 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1454 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1457 private static boolean testAminoAcidSequence() {
1459 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1460 if ( aa1.getLength() != 13 ) {
1463 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1466 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1469 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1472 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1473 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1476 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1477 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1480 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1481 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1485 catch ( final Exception e ) {
1486 e.printStackTrace();
1492 private static boolean testBasicDomain() {
1494 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1495 if ( !pd.getDomainId().equals( "id" ) ) {
1498 if ( pd.getNumber() != 1 ) {
1501 if ( pd.getTotalCount() != 4 ) {
1504 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1507 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1508 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1509 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1510 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1511 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1512 if ( !a1.equals( a1 ) ) {
1515 if ( !a1.equals( a1_copy ) ) {
1518 if ( !a1.equals( a1_equal ) ) {
1521 if ( !a1.equals( a2 ) ) {
1524 if ( a1.equals( a3 ) ) {
1527 if ( a1.compareTo( a1 ) != 0 ) {
1530 if ( a1.compareTo( a1_copy ) != 0 ) {
1533 if ( a1.compareTo( a1_equal ) != 0 ) {
1536 if ( a1.compareTo( a2 ) != 0 ) {
1539 if ( a1.compareTo( a3 ) == 0 ) {
1543 catch ( final Exception e ) {
1544 e.printStackTrace( System.out );
1550 private static boolean testBasicNodeMethods() {
1552 if ( PhylogenyNode.getNodeCount() != 0 ) {
1555 final PhylogenyNode n1 = new PhylogenyNode();
1556 final PhylogenyNode n2 = PhylogenyNode
1557 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1558 final PhylogenyNode n3 = PhylogenyNode
1559 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1560 final PhylogenyNode n4 = PhylogenyNode
1561 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1562 if ( n1.isHasAssignedEvent() ) {
1565 if ( PhylogenyNode.getNodeCount() != 4 ) {
1568 if ( n3.getIndicator() != 0 ) {
1571 if ( n3.getNumberOfExternalNodes() != 1 ) {
1574 if ( !n3.isExternal() ) {
1577 if ( !n3.isRoot() ) {
1580 if ( !n4.getName().equals( "n4" ) ) {
1584 catch ( final Exception e ) {
1585 e.printStackTrace( System.out );
1591 private static boolean testBasicPhyloXMLparsing() {
1593 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1594 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1595 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1597 if ( xml_parser.getErrorCount() > 0 ) {
1598 System.out.println( xml_parser.getErrorMessages().toString() );
1601 if ( phylogenies_0.length != 4 ) {
1604 final Phylogeny t1 = phylogenies_0[ 0 ];
1605 final Phylogeny t2 = phylogenies_0[ 1 ];
1606 final Phylogeny t3 = phylogenies_0[ 2 ];
1607 final Phylogeny t4 = phylogenies_0[ 3 ];
1608 if ( t1.getNumberOfExternalNodes() != 1 ) {
1611 if ( !t1.isRooted() ) {
1614 if ( t1.isRerootable() ) {
1617 if ( !t1.getType().equals( "gene_tree" ) ) {
1620 if ( t2.getNumberOfExternalNodes() != 2 ) {
1623 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1626 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1629 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1632 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1635 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1638 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1641 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1642 .startsWith( "actgtgggggt" ) ) {
1645 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1646 .startsWith( "ctgtgatgcat" ) ) {
1649 if ( t3.getNumberOfExternalNodes() != 4 ) {
1652 if ( !t1.getName().equals( "t1" ) ) {
1655 if ( !t2.getName().equals( "t2" ) ) {
1658 if ( !t3.getName().equals( "t3" ) ) {
1661 if ( !t4.getName().equals( "t4" ) ) {
1664 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1667 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1670 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1673 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1674 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1677 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1680 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1683 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1686 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1687 .equals( "apoptosis" ) ) {
1690 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1691 .equals( "GO:0006915" ) ) {
1694 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1695 .equals( "UniProtKB" ) ) {
1698 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1699 .equals( "experimental" ) ) {
1702 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1703 .equals( "function" ) ) {
1706 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1707 .getValue() != 1 ) {
1710 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1711 .getType().equals( "ml" ) ) {
1714 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1715 .equals( "apoptosis" ) ) {
1718 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1719 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1722 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1723 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1726 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1727 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1730 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1731 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1734 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1735 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1738 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1739 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1742 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1743 .equals( "GO:0005829" ) ) {
1746 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1747 .equals( "intracellular organelle" ) ) {
1750 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1753 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1754 .equals( "UniProt link" ) ) ) {
1757 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1760 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1761 if ( x.size() != 4 ) {
1765 for( final Accession acc : x ) {
1767 if ( !acc.getSource().equals( "KEGG" ) ) {
1770 if ( !acc.getValue().equals( "hsa:596" ) ) {
1777 catch ( final Exception e ) {
1778 e.printStackTrace( System.out );
1784 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1786 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1787 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1788 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1789 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1792 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1794 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1796 if ( xml_parser.getErrorCount() > 0 ) {
1797 System.out.println( xml_parser.getErrorMessages().toString() );
1800 if ( phylogenies_0.length != 4 ) {
1803 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1804 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1805 if ( phylogenies_t1.length != 1 ) {
1808 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1809 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1812 if ( !t1_rt.isRooted() ) {
1815 if ( t1_rt.isRerootable() ) {
1818 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1821 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1822 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1823 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1824 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1827 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1830 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1833 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1836 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1837 .startsWith( "actgtgggggt" ) ) {
1840 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1841 .startsWith( "ctgtgatgcat" ) ) {
1844 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1845 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1846 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1847 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1848 if ( phylogenies_1.length != 1 ) {
1851 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1852 if ( !t3_rt.getName().equals( "t3" ) ) {
1855 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1858 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1861 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1864 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1867 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1868 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1871 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1874 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1877 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1878 .equals( "UniProtKB" ) ) {
1881 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1882 .equals( "apoptosis" ) ) {
1885 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1886 .equals( "GO:0006915" ) ) {
1889 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1890 .equals( "UniProtKB" ) ) {
1893 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1894 .equals( "experimental" ) ) {
1897 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1898 .equals( "function" ) ) {
1901 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1902 .getValue() != 1 ) {
1905 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1906 .getType().equals( "ml" ) ) {
1909 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1910 .equals( "apoptosis" ) ) {
1913 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1914 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1917 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1918 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1921 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1922 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1925 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1926 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1929 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1930 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1933 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1934 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1937 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1938 .equals( "GO:0005829" ) ) {
1941 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1942 .equals( "intracellular organelle" ) ) {
1945 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1948 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1949 .equals( "UniProt link" ) ) ) {
1952 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1955 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1958 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1959 .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." ) ) ) {
1962 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1965 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1968 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1971 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1974 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1975 .equals( "ncbi" ) ) {
1978 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1981 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1982 .getName().equals( "B" ) ) {
1985 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1986 .getFrom() != 21 ) {
1989 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1992 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1993 .getLength() != 24 ) {
1996 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1997 .getConfidence() != 2144 ) {
2000 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2001 .equals( "pfam" ) ) {
2004 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2007 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2010 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2013 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2016 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2017 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2020 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2023 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2026 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2029 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2032 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2035 if ( taxbb.getSynonyms().size() != 2 ) {
2038 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2041 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2044 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2047 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2050 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2053 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2054 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2057 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2060 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2063 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2066 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2069 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2072 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2075 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2079 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2082 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2083 .equalsIgnoreCase( "435" ) ) {
2086 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2089 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2090 .equalsIgnoreCase( "443.7" ) ) {
2093 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2096 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2099 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2100 .equalsIgnoreCase( "433" ) ) {
2103 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2104 .getCrossReferences();
2105 if ( x.size() != 4 ) {
2109 for( final Accession acc : x ) {
2111 if ( !acc.getSource().equals( "KEGG" ) ) {
2114 if ( !acc.getValue().equals( "hsa:596" ) ) {
2121 catch ( final Exception e ) {
2122 e.printStackTrace( System.out );
2128 private static boolean testBasicPhyloXMLparsingValidating() {
2130 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2131 PhyloXmlParser xml_parser = null;
2133 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2135 catch ( final Exception e ) {
2136 // Do nothing -- means were not running from jar.
2138 if ( xml_parser == null ) {
2139 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2140 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2141 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2144 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2147 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2149 if ( xml_parser.getErrorCount() > 0 ) {
2150 System.out.println( xml_parser.getErrorMessages().toString() );
2153 if ( phylogenies_0.length != 4 ) {
2156 final Phylogeny t1 = phylogenies_0[ 0 ];
2157 final Phylogeny t2 = phylogenies_0[ 1 ];
2158 final Phylogeny t3 = phylogenies_0[ 2 ];
2159 final Phylogeny t4 = phylogenies_0[ 3 ];
2160 if ( !t1.getName().equals( "t1" ) ) {
2163 if ( !t2.getName().equals( "t2" ) ) {
2166 if ( !t3.getName().equals( "t3" ) ) {
2169 if ( !t4.getName().equals( "t4" ) ) {
2172 if ( t1.getNumberOfExternalNodes() != 1 ) {
2175 if ( t2.getNumberOfExternalNodes() != 2 ) {
2178 if ( t3.getNumberOfExternalNodes() != 4 ) {
2181 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2182 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2183 if ( xml_parser.getErrorCount() > 0 ) {
2184 System.out.println( "errors:" );
2185 System.out.println( xml_parser.getErrorMessages().toString() );
2188 if ( phylogenies_1.length != 4 ) {
2191 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2193 if ( xml_parser.getErrorCount() > 0 ) {
2194 System.out.println( "errors:" );
2195 System.out.println( xml_parser.getErrorMessages().toString() );
2198 if ( phylogenies_2.length != 1 ) {
2201 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2204 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2206 if ( xml_parser.getErrorCount() > 0 ) {
2207 System.out.println( xml_parser.getErrorMessages().toString() );
2210 if ( phylogenies_3.length != 2 ) {
2213 final Phylogeny a = phylogenies_3[ 0 ];
2214 if ( !a.getName().equals( "tree 4" ) ) {
2217 if ( a.getNumberOfExternalNodes() != 3 ) {
2220 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2223 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2226 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2228 if ( xml_parser.getErrorCount() > 0 ) {
2229 System.out.println( xml_parser.getErrorMessages().toString() );
2232 if ( phylogenies_4.length != 1 ) {
2235 final Phylogeny s = phylogenies_4[ 0 ];
2236 if ( s.getNumberOfExternalNodes() != 6 ) {
2239 s.getNode( "first" );
2241 s.getNode( "\"<a'b&c'd\">\"" );
2242 s.getNode( "'''\"" );
2243 s.getNode( "\"\"\"" );
2244 s.getNode( "dick & doof" );
2246 catch ( final Exception e ) {
2247 e.printStackTrace( System.out );
2253 private static boolean testBasicProtein() {
2255 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2256 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2257 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2258 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2259 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2260 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2261 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2262 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2263 p0.addProteinDomain( y );
2264 p0.addProteinDomain( e );
2265 p0.addProteinDomain( b );
2266 p0.addProteinDomain( c );
2267 p0.addProteinDomain( d );
2268 p0.addProteinDomain( a );
2269 p0.addProteinDomain( x );
2270 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2273 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2277 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2278 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2279 aa0.addProteinDomain( a1 );
2280 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2283 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2287 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2288 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2289 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2290 aa1.addProteinDomain( a11 );
2291 aa1.addProteinDomain( a12 );
2292 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2295 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2298 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2299 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2302 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2305 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2308 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2309 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2312 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2315 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2318 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2321 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2322 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2325 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2328 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2331 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2334 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2335 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2338 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2341 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2344 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2348 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2349 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2350 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2351 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2352 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2353 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2354 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2355 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2356 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2357 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2358 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2360 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2361 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2362 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2363 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2364 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2365 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2366 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2367 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2368 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2369 p00.addProteinDomain( y0 );
2370 p00.addProteinDomain( e0 );
2371 p00.addProteinDomain( b0 );
2372 p00.addProteinDomain( c0 );
2373 p00.addProteinDomain( d0 );
2374 p00.addProteinDomain( a0 );
2375 p00.addProteinDomain( x0 );
2376 p00.addProteinDomain( y1 );
2377 p00.addProteinDomain( y2 );
2378 p00.addProteinDomain( y3 );
2379 p00.addProteinDomain( e1 );
2380 p00.addProteinDomain( e2 );
2381 p00.addProteinDomain( e3 );
2382 p00.addProteinDomain( e4 );
2383 p00.addProteinDomain( e5 );
2384 p00.addProteinDomain( z0 );
2385 p00.addProteinDomain( z1 );
2386 p00.addProteinDomain( z2 );
2387 p00.addProteinDomain( zz0 );
2388 p00.addProteinDomain( zz1 );
2389 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2392 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2395 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2398 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2401 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" ) ) {
2404 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2405 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2406 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2407 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2408 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2409 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2410 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2411 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2412 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2413 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2414 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2415 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2416 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2417 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2418 p.addProteinDomain( B15 );
2419 p.addProteinDomain( C50 );
2420 p.addProteinDomain( A60 );
2421 p.addProteinDomain( A30 );
2422 p.addProteinDomain( C70 );
2423 p.addProteinDomain( B35 );
2424 p.addProteinDomain( B40 );
2425 p.addProteinDomain( A0 );
2426 p.addProteinDomain( A10 );
2427 p.addProteinDomain( A20 );
2428 p.addProteinDomain( B25 );
2429 p.addProteinDomain( D80 );
2430 List<String> domains_ids = new ArrayList<String>();
2431 domains_ids.add( "A" );
2432 domains_ids.add( "B" );
2433 domains_ids.add( "C" );
2434 if ( !p.contains( domains_ids, false ) ) {
2437 if ( !p.contains( domains_ids, true ) ) {
2440 domains_ids.add( "X" );
2441 if ( p.contains( domains_ids, false ) ) {
2444 if ( p.contains( domains_ids, true ) ) {
2447 domains_ids = new ArrayList<String>();
2448 domains_ids.add( "A" );
2449 domains_ids.add( "C" );
2450 domains_ids.add( "D" );
2451 if ( !p.contains( domains_ids, false ) ) {
2454 if ( !p.contains( domains_ids, true ) ) {
2457 domains_ids = new ArrayList<String>();
2458 domains_ids.add( "A" );
2459 domains_ids.add( "D" );
2460 domains_ids.add( "C" );
2461 if ( !p.contains( domains_ids, false ) ) {
2464 if ( p.contains( domains_ids, true ) ) {
2467 domains_ids = new ArrayList<String>();
2468 domains_ids.add( "A" );
2469 domains_ids.add( "A" );
2470 domains_ids.add( "B" );
2471 if ( !p.contains( domains_ids, false ) ) {
2474 if ( !p.contains( domains_ids, true ) ) {
2477 domains_ids = new ArrayList<String>();
2478 domains_ids.add( "A" );
2479 domains_ids.add( "A" );
2480 domains_ids.add( "A" );
2481 domains_ids.add( "B" );
2482 domains_ids.add( "B" );
2483 if ( !p.contains( domains_ids, false ) ) {
2486 if ( !p.contains( domains_ids, true ) ) {
2489 domains_ids = new ArrayList<String>();
2490 domains_ids.add( "A" );
2491 domains_ids.add( "A" );
2492 domains_ids.add( "B" );
2493 domains_ids.add( "A" );
2494 domains_ids.add( "B" );
2495 domains_ids.add( "B" );
2496 domains_ids.add( "A" );
2497 domains_ids.add( "B" );
2498 domains_ids.add( "C" );
2499 domains_ids.add( "A" );
2500 domains_ids.add( "C" );
2501 domains_ids.add( "D" );
2502 if ( !p.contains( domains_ids, false ) ) {
2505 if ( p.contains( domains_ids, true ) ) {
2509 catch ( final Exception e ) {
2510 e.printStackTrace( System.out );
2516 private static boolean testBasicTable() {
2518 final BasicTable<String> t0 = new BasicTable<String>();
2519 if ( t0.getNumberOfColumns() != 0 ) {
2522 if ( t0.getNumberOfRows() != 0 ) {
2525 t0.setValue( 3, 2, "23" );
2526 t0.setValue( 10, 1, "error" );
2527 t0.setValue( 10, 1, "110" );
2528 t0.setValue( 9, 1, "19" );
2529 t0.setValue( 1, 10, "101" );
2530 t0.setValue( 10, 10, "1010" );
2531 t0.setValue( 100, 10, "10100" );
2532 t0.setValue( 0, 0, "00" );
2533 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2536 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2539 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2542 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2545 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2548 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2551 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2554 if ( t0.getNumberOfColumns() != 101 ) {
2557 if ( t0.getNumberOfRows() != 11 ) {
2560 if ( t0.getValueAsString( 49, 4 ) != null ) {
2563 final String l = ForesterUtil.getLineSeparator();
2564 final StringBuffer source = new StringBuffer();
2565 source.append( "" + l );
2566 source.append( "# 1 1 1 1 1 1 1 1" + l );
2567 source.append( " 00 01 02 03" + l );
2568 source.append( " 10 11 12 13 " + l );
2569 source.append( "20 21 22 23 " + l );
2570 source.append( " 30 31 32 33" + l );
2571 source.append( "40 41 42 43" + l );
2572 source.append( " # 1 1 1 1 1 " + l );
2573 source.append( "50 51 52 53 54" + l );
2574 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2575 if ( t1.getNumberOfColumns() != 5 ) {
2578 if ( t1.getNumberOfRows() != 6 ) {
2581 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2584 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2587 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2590 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2593 final StringBuffer source1 = new StringBuffer();
2594 source1.append( "" + l );
2595 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2596 source1.append( " 00; 01 ;02;03" + l );
2597 source1.append( " 10; 11; 12; 13 " + l );
2598 source1.append( "20; 21; 22; 23 " + l );
2599 source1.append( " 30; 31; 32; 33" + l );
2600 source1.append( "40;41;42;43" + l );
2601 source1.append( " # 1 1 1 1 1 " + l );
2602 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2603 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2604 if ( t2.getNumberOfColumns() != 5 ) {
2607 if ( t2.getNumberOfRows() != 6 ) {
2610 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2613 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2616 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2619 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2622 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2625 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2628 final StringBuffer source2 = new StringBuffer();
2629 source2.append( "" + l );
2630 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2631 source2.append( " 00; 01 ;02;03" + l );
2632 source2.append( " 10; 11; 12; 13 " + l );
2633 source2.append( "20; 21; 22; 23 " + l );
2634 source2.append( " " + l );
2635 source2.append( " 30; 31; 32; 33" + l );
2636 source2.append( "40;41;42;43" + l );
2637 source2.append( " comment: 1 1 1 1 1 " + l );
2638 source2.append( ";;;50 ; 52; 53;;54 " + l );
2639 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2645 if ( tl.size() != 2 ) {
2648 final BasicTable<String> t3 = tl.get( 0 );
2649 final BasicTable<String> t4 = tl.get( 1 );
2650 if ( t3.getNumberOfColumns() != 4 ) {
2653 if ( t3.getNumberOfRows() != 3 ) {
2656 if ( t4.getNumberOfColumns() != 4 ) {
2659 if ( t4.getNumberOfRows() != 3 ) {
2662 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2665 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2669 catch ( final Exception e ) {
2670 e.printStackTrace( System.out );
2676 private static boolean testBasicTolXMLparsing() {
2678 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2679 final TolParser parser = new TolParser();
2680 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2681 if ( parser.getErrorCount() > 0 ) {
2682 System.out.println( parser.getErrorMessages().toString() );
2685 if ( phylogenies_0.length != 1 ) {
2688 final Phylogeny t1 = phylogenies_0[ 0 ];
2689 if ( t1.getNumberOfExternalNodes() != 5 ) {
2692 if ( !t1.isRooted() ) {
2695 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2698 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2701 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2704 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2707 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2708 if ( parser.getErrorCount() > 0 ) {
2709 System.out.println( parser.getErrorMessages().toString() );
2712 if ( phylogenies_1.length != 1 ) {
2715 final Phylogeny t2 = phylogenies_1[ 0 ];
2716 if ( t2.getNumberOfExternalNodes() != 664 ) {
2719 if ( !t2.isRooted() ) {
2722 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2725 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2728 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2731 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2734 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2737 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2738 .equals( "Aquifex" ) ) {
2741 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2742 if ( parser.getErrorCount() > 0 ) {
2743 System.out.println( parser.getErrorMessages().toString() );
2746 if ( phylogenies_2.length != 1 ) {
2749 final Phylogeny t3 = phylogenies_2[ 0 ];
2750 if ( t3.getNumberOfExternalNodes() != 184 ) {
2753 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2756 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2759 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2762 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2763 if ( parser.getErrorCount() > 0 ) {
2764 System.out.println( parser.getErrorMessages().toString() );
2767 if ( phylogenies_3.length != 1 ) {
2770 final Phylogeny t4 = phylogenies_3[ 0 ];
2771 if ( t4.getNumberOfExternalNodes() != 1 ) {
2774 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2777 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2780 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2783 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2784 if ( parser.getErrorCount() > 0 ) {
2785 System.out.println( parser.getErrorMessages().toString() );
2788 if ( phylogenies_4.length != 1 ) {
2791 final Phylogeny t5 = phylogenies_4[ 0 ];
2792 if ( t5.getNumberOfExternalNodes() != 13 ) {
2795 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2798 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2801 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2805 catch ( final Exception e ) {
2806 e.printStackTrace( System.out );
2812 private static boolean testBasicTreeMethods() {
2814 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2815 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2816 if ( t2.getNumberOfExternalNodes() != 4 ) {
2819 if ( t2.getHeight() != 8.5 ) {
2822 if ( !t2.isCompletelyBinary() ) {
2825 if ( t2.isEmpty() ) {
2828 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2829 if ( t3.getNumberOfExternalNodes() != 5 ) {
2832 if ( t3.getHeight() != 11 ) {
2835 if ( t3.isCompletelyBinary() ) {
2838 final PhylogenyNode n = t3.getNode( "ABC" );
2839 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 ];
2840 if ( t4.getNumberOfExternalNodes() != 9 ) {
2843 if ( t4.getHeight() != 11 ) {
2846 if ( t4.isCompletelyBinary() ) {
2849 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)" );
2850 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2851 if ( t5.getNumberOfExternalNodes() != 8 ) {
2854 if ( t5.getHeight() != 15 ) {
2857 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)" );
2858 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2859 if ( t6.getHeight() != 15 ) {
2862 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)" );
2863 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2864 if ( t7.getHeight() != 15 ) {
2867 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)" );
2868 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2869 if ( t8.getNumberOfExternalNodes() != 10 ) {
2872 if ( t8.getHeight() != 15 ) {
2875 final char[] a9 = new char[] { 'a' };
2876 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2877 if ( t9.getHeight() != 0 ) {
2880 final char[] a10 = new char[] { 'a', ':', '6' };
2881 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2882 if ( t10.getHeight() != 6 ) {
2886 catch ( final Exception e ) {
2887 e.printStackTrace( System.out );
2893 private static boolean testConfidenceAssessor() {
2895 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2896 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2897 final Phylogeny[] ev0 = factory
2898 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2900 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2901 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2904 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2907 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2908 final Phylogeny[] ev1 = factory
2909 .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)));",
2911 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2912 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2915 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2918 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2919 final Phylogeny[] ev_b = factory
2920 .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",
2922 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2923 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2926 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2930 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2931 final Phylogeny[] ev1x = factory
2932 .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)));",
2934 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2935 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2938 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2941 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2942 final Phylogeny[] ev_bx = factory
2943 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
2945 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2946 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2949 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2953 final Phylogeny[] t2 = factory
2954 .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);",
2956 final Phylogeny[] ev2 = factory
2957 .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);",
2959 for( final Phylogeny target : t2 ) {
2960 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2963 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2964 new NHXParser() )[ 0 ];
2965 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2966 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2967 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2970 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2973 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2977 catch ( final Exception e ) {
2978 e.printStackTrace();
2984 private static boolean testCopyOfNodeData() {
2986 final PhylogenyNode n1 = PhylogenyNode
2987 .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]" );
2988 final PhylogenyNode n2 = n1.copyNodeData();
2989 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2993 catch ( final Exception e ) {
2994 e.printStackTrace();
3000 private static boolean testCreateBalancedPhylogeny() {
3002 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3003 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3006 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3009 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3010 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3013 if ( p1.getNumberOfExternalNodes() != 100 ) {
3017 catch ( final Exception e ) {
3018 e.printStackTrace();
3024 private static boolean testCreateUriForSeqWeb() {
3026 final PhylogenyNode n = new PhylogenyNode();
3027 n.setName( "tr|B3RJ64" );
3028 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3031 n.setName( "B0LM41_HUMAN" );
3032 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3035 n.setName( "NP_001025424" );
3036 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3039 n.setName( "_NM_001030253-" );
3040 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3043 n.setName( "XM_002122186" );
3044 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3047 n.setName( "dgh_AAA34956_gdg" );
3048 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3051 n.setName( "AAA34956" );
3052 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3055 n.setName( "GI:394892" );
3056 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3057 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3060 n.setName( "gi_394892" );
3061 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3062 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3065 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3066 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3067 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3070 n.setName( "P12345" );
3071 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3072 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3075 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3076 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3077 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3081 catch ( final Exception e ) {
3082 e.printStackTrace( System.out );
3088 private static boolean testDataObjects() {
3090 final Confidence s0 = new Confidence();
3091 final Confidence s1 = new Confidence();
3092 if ( !s0.isEqual( s1 ) ) {
3095 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3096 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3097 if ( s2.isEqual( s1 ) ) {
3100 if ( !s2.isEqual( s3 ) ) {
3103 final Confidence s4 = ( Confidence ) s3.copy();
3104 if ( !s4.isEqual( s3 ) ) {
3111 final Taxonomy t1 = new Taxonomy();
3112 final Taxonomy t2 = new Taxonomy();
3113 final Taxonomy t3 = new Taxonomy();
3114 final Taxonomy t4 = new Taxonomy();
3115 final Taxonomy t5 = new Taxonomy();
3116 t1.setIdentifier( new Identifier( "ecoli" ) );
3117 t1.setTaxonomyCode( "ECOLI" );
3118 t1.setScientificName( "E. coli" );
3119 t1.setCommonName( "coli" );
3120 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3121 if ( !t1.isEqual( t0 ) ) {
3124 t2.setIdentifier( new Identifier( "ecoli" ) );
3125 t2.setTaxonomyCode( "OTHER" );
3126 t2.setScientificName( "what" );
3127 t2.setCommonName( "something" );
3128 if ( !t1.isEqual( t2 ) ) {
3131 t2.setIdentifier( new Identifier( "nemve" ) );
3132 if ( t1.isEqual( t2 ) ) {
3135 t1.setIdentifier( null );
3136 t3.setTaxonomyCode( "ECOLI" );
3137 t3.setScientificName( "what" );
3138 t3.setCommonName( "something" );
3139 if ( !t1.isEqual( t3 ) ) {
3142 t1.setIdentifier( null );
3143 t1.setTaxonomyCode( "" );
3144 t4.setScientificName( "E. ColI" );
3145 t4.setCommonName( "something" );
3146 if ( !t1.isEqual( t4 ) ) {
3149 t4.setScientificName( "B. subtilis" );
3150 t4.setCommonName( "something" );
3151 if ( t1.isEqual( t4 ) ) {
3154 t1.setIdentifier( null );
3155 t1.setTaxonomyCode( "" );
3156 t1.setScientificName( "" );
3157 t5.setCommonName( "COLI" );
3158 if ( !t1.isEqual( t5 ) ) {
3161 t5.setCommonName( "vibrio" );
3162 if ( t1.isEqual( t5 ) ) {
3167 final Identifier id0 = new Identifier( "123", "pfam" );
3168 final Identifier id1 = ( Identifier ) id0.copy();
3169 if ( !id1.isEqual( id1 ) ) {
3172 if ( !id1.isEqual( id0 ) ) {
3175 if ( !id0.isEqual( id1 ) ) {
3182 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3183 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3184 if ( !pd1.isEqual( pd1 ) ) {
3187 if ( !pd1.isEqual( pd0 ) ) {
3192 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3193 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3194 if ( !pd3.isEqual( pd3 ) ) {
3197 if ( !pd2.isEqual( pd3 ) ) {
3200 if ( !pd0.isEqual( pd3 ) ) {
3205 // DomainArchitecture
3206 // ------------------
3207 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3208 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3209 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3210 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3211 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3212 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3217 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3218 if ( ds0.getNumberOfDomains() != 4 ) {
3221 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3222 if ( !ds0.isEqual( ds0 ) ) {
3225 if ( !ds0.isEqual( ds1 ) ) {
3228 if ( ds1.getNumberOfDomains() != 4 ) {
3231 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3236 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3237 if ( ds0.isEqual( ds2 ) ) {
3243 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3244 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3245 System.out.println( ds3.toNHX() );
3248 if ( ds3.getNumberOfDomains() != 3 ) {
3253 final Event e1 = new Event( Event.EventType.fusion );
3254 if ( e1.isDuplication() ) {
3257 if ( !e1.isFusion() ) {
3260 if ( !e1.asText().toString().equals( "fusion" ) ) {
3263 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3266 final Event e11 = new Event( Event.EventType.fusion );
3267 if ( !e11.isEqual( e1 ) ) {
3270 if ( !e11.toNHX().toString().equals( "" ) ) {
3273 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3274 if ( e2.isDuplication() ) {
3277 if ( !e2.isSpeciationOrDuplication() ) {
3280 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3283 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3286 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3289 if ( e11.isEqual( e2 ) ) {
3292 final Event e2c = ( Event ) e2.copy();
3293 if ( !e2c.isEqual( e2 ) ) {
3296 Event e3 = new Event( 1, 2, 3 );
3297 if ( e3.isDuplication() ) {
3300 if ( e3.isSpeciation() ) {
3303 if ( e3.isGeneLoss() ) {
3306 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3309 final Event e3c = ( Event ) e3.copy();
3310 final Event e3cc = ( Event ) e3c.copy();
3311 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3315 if ( !e3c.isEqual( e3cc ) ) {
3318 Event e4 = new Event( 1, 2, 3 );
3319 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3322 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3325 final Event e4c = ( Event ) e4.copy();
3327 final Event e4cc = ( Event ) e4c.copy();
3328 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3331 if ( !e4c.isEqual( e4cc ) ) {
3334 final Event e5 = new Event();
3335 if ( !e5.isUnassigned() ) {
3338 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3341 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3344 final Event e6 = new Event( 1, 0, 0 );
3345 if ( !e6.asText().toString().equals( "duplication" ) ) {
3348 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3351 final Event e7 = new Event( 0, 1, 0 );
3352 if ( !e7.asText().toString().equals( "speciation" ) ) {
3355 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3358 final Event e8 = new Event( 0, 0, 1 );
3359 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3362 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3366 catch ( final Exception e ) {
3367 e.printStackTrace( System.out );
3373 private static boolean testDeletionOfExternalNodes() {
3375 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3376 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3377 final PhylogenyWriter w = new PhylogenyWriter();
3378 if ( t0.isEmpty() ) {
3381 if ( t0.getNumberOfExternalNodes() != 1 ) {
3384 t0.deleteSubtree( t0.getNode( "A" ), false );
3385 if ( t0.getNumberOfExternalNodes() != 0 ) {
3388 if ( !t0.isEmpty() ) {
3391 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3392 if ( t1.getNumberOfExternalNodes() != 2 ) {
3395 t1.deleteSubtree( t1.getNode( "A" ), false );
3396 if ( t1.getNumberOfExternalNodes() != 1 ) {
3399 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3402 t1.deleteSubtree( t1.getNode( "B" ), false );
3403 if ( t1.getNumberOfExternalNodes() != 1 ) {
3406 t1.deleteSubtree( t1.getNode( "r" ), false );
3407 if ( !t1.isEmpty() ) {
3410 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3411 if ( t2.getNumberOfExternalNodes() != 3 ) {
3414 t2.deleteSubtree( t2.getNode( "B" ), false );
3415 if ( t2.getNumberOfExternalNodes() != 2 ) {
3418 t2.toNewHampshireX();
3419 PhylogenyNode n = t2.getNode( "A" );
3420 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3423 t2.deleteSubtree( t2.getNode( "A" ), false );
3424 if ( t2.getNumberOfExternalNodes() != 2 ) {
3427 t2.deleteSubtree( t2.getNode( "C" ), true );
3428 if ( t2.getNumberOfExternalNodes() != 1 ) {
3431 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3432 if ( t3.getNumberOfExternalNodes() != 4 ) {
3435 t3.deleteSubtree( t3.getNode( "B" ), true );
3436 if ( t3.getNumberOfExternalNodes() != 3 ) {
3439 n = t3.getNode( "A" );
3440 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3443 n = n.getNextExternalNode();
3444 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3447 t3.deleteSubtree( t3.getNode( "A" ), true );
3448 if ( t3.getNumberOfExternalNodes() != 2 ) {
3451 n = t3.getNode( "C" );
3452 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3455 t3.deleteSubtree( t3.getNode( "C" ), true );
3456 if ( t3.getNumberOfExternalNodes() != 1 ) {
3459 t3.deleteSubtree( t3.getNode( "D" ), true );
3460 if ( t3.getNumberOfExternalNodes() != 0 ) {
3463 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3464 if ( t4.getNumberOfExternalNodes() != 6 ) {
3467 t4.deleteSubtree( t4.getNode( "B2" ), true );
3468 if ( t4.getNumberOfExternalNodes() != 5 ) {
3471 String s = w.toNewHampshire( t4, false, true ).toString();
3472 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3475 t4.deleteSubtree( t4.getNode( "B11" ), true );
3476 if ( t4.getNumberOfExternalNodes() != 4 ) {
3479 t4.deleteSubtree( t4.getNode( "C" ), true );
3480 if ( t4.getNumberOfExternalNodes() != 3 ) {
3483 n = t4.getNode( "A" );
3484 n = n.getNextExternalNode();
3485 if ( !n.getName().equals( "B12" ) ) {
3488 n = n.getNextExternalNode();
3489 if ( !n.getName().equals( "D" ) ) {
3492 s = w.toNewHampshire( t4, false, true ).toString();
3493 if ( !s.equals( "((A,B12),D);" ) ) {
3496 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3497 t5.deleteSubtree( t5.getNode( "A" ), true );
3498 if ( t5.getNumberOfExternalNodes() != 5 ) {
3501 s = w.toNewHampshire( t5, false, true ).toString();
3502 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3505 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3506 t6.deleteSubtree( t6.getNode( "B11" ), true );
3507 if ( t6.getNumberOfExternalNodes() != 5 ) {
3510 s = w.toNewHampshire( t6, false, false ).toString();
3511 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3514 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3515 t7.deleteSubtree( t7.getNode( "B12" ), true );
3516 if ( t7.getNumberOfExternalNodes() != 5 ) {
3519 s = w.toNewHampshire( t7, false, true ).toString();
3520 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3523 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3524 t8.deleteSubtree( t8.getNode( "B2" ), true );
3525 if ( t8.getNumberOfExternalNodes() != 5 ) {
3528 s = w.toNewHampshire( t8, false, false ).toString();
3529 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3532 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3533 t9.deleteSubtree( t9.getNode( "C" ), true );
3534 if ( t9.getNumberOfExternalNodes() != 5 ) {
3537 s = w.toNewHampshire( t9, false, true ).toString();
3538 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3541 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3542 t10.deleteSubtree( t10.getNode( "D" ), true );
3543 if ( t10.getNumberOfExternalNodes() != 5 ) {
3546 s = w.toNewHampshire( t10, false, true ).toString();
3547 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3550 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3551 t11.deleteSubtree( t11.getNode( "A" ), true );
3552 if ( t11.getNumberOfExternalNodes() != 2 ) {
3555 s = w.toNewHampshire( t11, false, true ).toString();
3556 if ( !s.equals( "(B,C);" ) ) {
3559 t11.deleteSubtree( t11.getNode( "C" ), true );
3560 if ( t11.getNumberOfExternalNodes() != 1 ) {
3563 s = w.toNewHampshire( t11, false, false ).toString();
3564 if ( !s.equals( "B;" ) ) {
3567 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3568 t12.deleteSubtree( t12.getNode( "B2" ), true );
3569 if ( t12.getNumberOfExternalNodes() != 8 ) {
3572 s = w.toNewHampshire( t12, false, true ).toString();
3573 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3576 t12.deleteSubtree( t12.getNode( "B3" ), true );
3577 if ( t12.getNumberOfExternalNodes() != 7 ) {
3580 s = w.toNewHampshire( t12, false, true ).toString();
3581 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3584 t12.deleteSubtree( t12.getNode( "C3" ), true );
3585 if ( t12.getNumberOfExternalNodes() != 6 ) {
3588 s = w.toNewHampshire( t12, false, true ).toString();
3589 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3592 t12.deleteSubtree( t12.getNode( "A1" ), true );
3593 if ( t12.getNumberOfExternalNodes() != 5 ) {
3596 s = w.toNewHampshire( t12, false, true ).toString();
3597 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3600 t12.deleteSubtree( t12.getNode( "B1" ), true );
3601 if ( t12.getNumberOfExternalNodes() != 4 ) {
3604 s = w.toNewHampshire( t12, false, true ).toString();
3605 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3608 t12.deleteSubtree( t12.getNode( "A3" ), true );
3609 if ( t12.getNumberOfExternalNodes() != 3 ) {
3612 s = w.toNewHampshire( t12, false, true ).toString();
3613 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3616 t12.deleteSubtree( t12.getNode( "A2" ), true );
3617 if ( t12.getNumberOfExternalNodes() != 2 ) {
3620 s = w.toNewHampshire( t12, false, true ).toString();
3621 if ( !s.equals( "(C1,C2);" ) ) {
3624 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3625 t13.deleteSubtree( t13.getNode( "D" ), true );
3626 if ( t13.getNumberOfExternalNodes() != 4 ) {
3629 s = w.toNewHampshire( t13, false, true ).toString();
3630 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3633 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3634 t14.deleteSubtree( t14.getNode( "E" ), true );
3635 if ( t14.getNumberOfExternalNodes() != 5 ) {
3638 s = w.toNewHampshire( t14, false, true ).toString();
3639 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3642 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3643 t15.deleteSubtree( t15.getNode( "B2" ), true );
3644 if ( t15.getNumberOfExternalNodes() != 11 ) {
3647 t15.deleteSubtree( t15.getNode( "B1" ), true );
3648 if ( t15.getNumberOfExternalNodes() != 10 ) {
3651 t15.deleteSubtree( t15.getNode( "B3" ), true );
3652 if ( t15.getNumberOfExternalNodes() != 9 ) {
3655 t15.deleteSubtree( t15.getNode( "B4" ), true );
3656 if ( t15.getNumberOfExternalNodes() != 8 ) {
3659 t15.deleteSubtree( t15.getNode( "A1" ), true );
3660 if ( t15.getNumberOfExternalNodes() != 7 ) {
3663 t15.deleteSubtree( t15.getNode( "C4" ), true );
3664 if ( t15.getNumberOfExternalNodes() != 6 ) {
3668 catch ( final Exception e ) {
3669 e.printStackTrace( System.out );
3675 private static boolean testDescriptiveStatistics() {
3677 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3678 dss1.addValue( 82 );
3679 dss1.addValue( 78 );
3680 dss1.addValue( 70 );
3681 dss1.addValue( 58 );
3682 dss1.addValue( 42 );
3683 if ( dss1.getN() != 5 ) {
3686 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3689 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3692 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3695 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3698 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3701 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3704 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3707 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3710 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3713 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3716 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3719 dss1.addValue( 123 );
3720 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3723 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3726 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3729 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3730 dss2.addValue( -1.85 );
3731 dss2.addValue( 57.5 );
3732 dss2.addValue( 92.78 );
3733 dss2.addValue( 57.78 );
3734 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3737 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3740 final double[] a = dss2.getDataAsDoubleArray();
3741 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3744 dss2.addValue( -100 );
3745 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3748 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3751 final double[] ds = new double[ 14 ];
3766 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3767 if ( bins.length != 4 ) {
3770 if ( bins[ 0 ] != 2 ) {
3773 if ( bins[ 1 ] != 3 ) {
3776 if ( bins[ 2 ] != 4 ) {
3779 if ( bins[ 3 ] != 5 ) {
3782 final double[] ds1 = new double[ 9 ];
3792 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3793 if ( bins1.length != 4 ) {
3796 if ( bins1[ 0 ] != 2 ) {
3799 if ( bins1[ 1 ] != 3 ) {
3802 if ( bins1[ 2 ] != 0 ) {
3805 if ( bins1[ 3 ] != 4 ) {
3808 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3809 if ( bins1_1.length != 3 ) {
3812 if ( bins1_1[ 0 ] != 3 ) {
3815 if ( bins1_1[ 1 ] != 2 ) {
3818 if ( bins1_1[ 2 ] != 4 ) {
3821 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3822 if ( bins1_2.length != 3 ) {
3825 if ( bins1_2[ 0 ] != 2 ) {
3828 if ( bins1_2[ 1 ] != 2 ) {
3831 if ( bins1_2[ 2 ] != 2 ) {
3834 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3848 dss3.addValue( 10 );
3849 dss3.addValue( 10 );
3850 dss3.addValue( 10 );
3851 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3852 histo.toStringBuffer( 10, '=', 40, 5 );
3853 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3855 catch ( final Exception e ) {
3856 e.printStackTrace( System.out );
3862 private static boolean testDir( final String file ) {
3864 final File f = new File( file );
3865 if ( !f.exists() ) {
3868 if ( !f.isDirectory() ) {
3871 if ( !f.canRead() ) {
3875 catch ( final Exception e ) {
3881 private static boolean testEbiEntryRetrieval() {
3883 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3884 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3885 System.out.println( entry.getAccession() );
3888 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3889 System.out.println( entry.getTaxonomyScientificName() );
3892 if ( !entry.getSequenceName()
3893 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3894 System.out.println( entry.getSequenceName() );
3897 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3898 // System.out.println( entry.getSequenceSymbol() );
3901 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3902 System.out.println( entry.getGeneName() );
3905 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3906 System.out.println( entry.getTaxonomyIdentifier() );
3909 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3910 System.out.println( entry.getAnnotations().first().getRefValue() );
3913 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3914 System.out.println( entry.getAnnotations().first().getRefSource() );
3917 if ( entry.getCrossReferences().size() != 5 ) {
3921 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3922 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3925 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3926 System.out.println( entry1.getTaxonomyScientificName() );
3929 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3930 System.out.println( entry1.getSequenceName() );
3933 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3934 System.out.println( entry1.getTaxonomyIdentifier() );
3937 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3938 System.out.println( entry1.getGeneName() );
3941 if ( entry1.getCrossReferences().size() != 6 ) {
3945 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3946 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3949 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3950 System.out.println( entry2.getTaxonomyScientificName() );
3953 if ( !entry2.getSequenceName()
3954 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3955 System.out.println( entry2.getSequenceName() );
3958 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3959 System.out.println( entry2.getTaxonomyIdentifier() );
3962 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3963 System.out.println( entry2.getGeneName() );
3966 if ( entry2.getCrossReferences().size() != 3 ) {
3970 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3971 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3974 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3975 System.out.println( entry3.getTaxonomyScientificName() );
3978 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
3979 System.out.println( entry3.getSequenceName() );
3982 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
3983 System.out.println( entry3.getTaxonomyIdentifier() );
3986 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
3987 System.out.println( entry3.getSequenceSymbol() );
3990 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
3993 if ( entry3.getCrossReferences().size() != 8 ) {
3998 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
3999 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4002 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4003 System.out.println( entry4.getTaxonomyScientificName() );
4006 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4007 System.out.println( entry4.getSequenceName() );
4010 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4011 System.out.println( entry4.getTaxonomyIdentifier() );
4014 if ( !entry4.getGeneName().equals( "ras" ) ) {
4015 System.out.println( entry4.getGeneName() );
4018 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4019 // System.out.println( entry4.getChromosome() );
4022 // if ( !entry4.getMap().equals( "ras" ) ) {
4023 // System.out.println( entry4.getMap() );
4029 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4030 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4033 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4034 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4037 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4038 System.out.println( entry5.getTaxonomyScientificName() );
4041 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4042 System.out.println( entry5.getSequenceName() );
4045 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4046 System.out.println( entry5.getTaxonomyIdentifier() );
4050 catch ( final IOException e ) {
4051 System.out.println();
4052 System.out.println( "the following might be due to absence internet connection:" );
4053 e.printStackTrace( System.out );
4056 catch ( final Exception e ) {
4057 e.printStackTrace();
4063 private static boolean testExternalNodeRelatedMethods() {
4065 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4066 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4067 PhylogenyNode n = t1.getNode( "A" );
4068 n = n.getNextExternalNode();
4069 if ( !n.getName().equals( "B" ) ) {
4072 n = n.getNextExternalNode();
4073 if ( !n.getName().equals( "C" ) ) {
4076 n = n.getNextExternalNode();
4077 if ( !n.getName().equals( "D" ) ) {
4080 n = t1.getNode( "B" );
4081 while ( !n.isLastExternalNode() ) {
4082 n = n.getNextExternalNode();
4084 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4085 n = t2.getNode( "A" );
4086 n = n.getNextExternalNode();
4087 if ( !n.getName().equals( "B" ) ) {
4090 n = n.getNextExternalNode();
4091 if ( !n.getName().equals( "C" ) ) {
4094 n = n.getNextExternalNode();
4095 if ( !n.getName().equals( "D" ) ) {
4098 n = t2.getNode( "B" );
4099 while ( !n.isLastExternalNode() ) {
4100 n = n.getNextExternalNode();
4102 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4103 n = t3.getNode( "A" );
4104 n = n.getNextExternalNode();
4105 if ( !n.getName().equals( "B" ) ) {
4108 n = n.getNextExternalNode();
4109 if ( !n.getName().equals( "C" ) ) {
4112 n = n.getNextExternalNode();
4113 if ( !n.getName().equals( "D" ) ) {
4116 n = n.getNextExternalNode();
4117 if ( !n.getName().equals( "E" ) ) {
4120 n = n.getNextExternalNode();
4121 if ( !n.getName().equals( "F" ) ) {
4124 n = n.getNextExternalNode();
4125 if ( !n.getName().equals( "G" ) ) {
4128 n = n.getNextExternalNode();
4129 if ( !n.getName().equals( "H" ) ) {
4132 n = t3.getNode( "B" );
4133 while ( !n.isLastExternalNode() ) {
4134 n = n.getNextExternalNode();
4136 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4137 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4138 final PhylogenyNode node = iter.next();
4140 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4141 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4142 final PhylogenyNode node = iter.next();
4144 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4145 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4146 if ( !iter.next().getName().equals( "A" ) ) {
4149 if ( !iter.next().getName().equals( "B" ) ) {
4152 if ( !iter.next().getName().equals( "C" ) ) {
4155 if ( !iter.next().getName().equals( "D" ) ) {
4158 if ( !iter.next().getName().equals( "E" ) ) {
4161 if ( !iter.next().getName().equals( "F" ) ) {
4164 if ( iter.hasNext() ) {
4168 catch ( final Exception e ) {
4169 e.printStackTrace( System.out );
4175 private static boolean testExtractSNFromNodeName() {
4177 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4180 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
4181 .equals( "Mus musculus musculus" ) ) {
4184 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
4185 .equals( "Mus musculus musculus" ) ) {
4188 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
4191 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
4192 .equals( "Mus musculus" ) ) {
4195 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4198 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus" )
4199 .equals( "Mus musculus musculus" ) ) {
4202 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4203 .equals( "Mus musculus musculus" ) ) {
4206 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4209 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" ).equals( "Pilostyles mexicana" ) ) {
4212 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4213 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4216 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4217 .equals( "Escherichia coli str K12/DH10B" ) ) {
4220 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4221 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4224 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4225 .equals( "Arabidopsis lyrata subsp lyrata" ) ) {
4228 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4229 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4232 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4233 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4236 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4237 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4240 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4241 .equals( "Arabidopsis lyrata subsp lyrata" ) ) {
4244 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4245 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4248 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4249 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4252 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4253 .equals( "Escherichia coli (strain K12)" ) ) {
4256 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4257 .equals( "Escherichia coli (strain K12)" ) ) {
4260 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4261 .equals( "Escherichia coli (str. K12)" ) ) {
4264 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4265 .equals( "Escherichia coli (str. K12)" ) ) {
4268 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." )
4269 .equals( "Macrocera sp." ) ) {
4273 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" )
4274 .equals( "Macrocera sp." ) ) {
4278 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" )
4279 .equals( "Macrocera sp." ) ) {
4284 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4285 .equals( "Macrocera sp." ) ) {
4289 } if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" )
4290 .equals( "Macrocera sp" ) ) {
4296 catch ( final Exception e ) {
4297 e.printStackTrace( System.out );
4303 private static boolean testExtractTaxonomyCodeFromNodeName() {
4305 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4308 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4309 .equals( "SOYBN" ) ) {
4312 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4313 .equals( "ARATH" ) ) {
4316 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4317 .equals( "ARATH" ) ) {
4320 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4323 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4326 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4329 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4330 .equals( "SOYBN" ) ) {
4333 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4334 .equals( "SOYBN" ) ) {
4337 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4338 .equals( "SOYBN" ) ) {
4341 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4342 .equals( "SOYBN" ) ) {
4345 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4346 .equals( "SOYBN" ) ) {
4349 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4350 .equals( "SOYBN" ) ) {
4353 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4354 .equals( "SOYBN" ) ) {
4357 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4358 .equals( "SOYBN" ) ) {
4361 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4364 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4365 .equals( "SOYBN" ) ) {
4368 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4369 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4372 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4373 .equals( "9YX45" ) ) {
4376 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4377 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4378 .equals( "MOUSE" ) ) {
4381 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4382 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4383 .equals( "MOUSE" ) ) {
4386 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4387 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4388 .equals( "MOUSE" ) ) {
4391 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4392 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4395 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4396 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4399 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4400 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4403 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4404 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4407 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4408 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4411 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4412 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4415 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4416 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4419 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4420 .equals( "RAT" ) ) {
4423 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4424 .equals( "PIG" ) ) {
4428 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4429 .equals( "MOUSE" ) ) {
4432 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4433 .equals( "MOUSE" ) ) {
4436 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4440 catch ( final Exception e ) {
4441 e.printStackTrace( System.out );
4447 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4449 PhylogenyNode n = new PhylogenyNode();
4450 n.setName( "tr|B3RJ64" );
4451 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4454 n.setName( "tr.B3RJ64" );
4455 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4458 n.setName( "tr=B3RJ64" );
4459 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4462 n.setName( "tr-B3RJ64" );
4463 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4466 n.setName( "tr/B3RJ64" );
4467 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4470 n.setName( "tr\\B3RJ64" );
4471 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4474 n.setName( "tr_B3RJ64" );
4475 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4478 n.setName( " tr|B3RJ64 " );
4479 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4482 n.setName( "-tr|B3RJ64-" );
4483 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4486 n.setName( "-tr=B3RJ64-" );
4487 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4490 n.setName( "_tr=B3RJ64_" );
4491 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4494 n.setName( " tr_tr|B3RJ64_sp|123 " );
4495 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4498 n.setName( "B3RJ64" );
4499 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4502 n.setName( "sp|B3RJ64" );
4503 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4506 n.setName( "sp|B3RJ64C" );
4507 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4510 n.setName( "sp B3RJ64" );
4511 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4514 n.setName( "sp|B3RJ6X" );
4515 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4518 n.setName( "sp|B3RJ6" );
4519 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4522 n.setName( "K1PYK7_CRAGI" );
4523 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4526 n.setName( "K1PYK7_PEA" );
4527 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4530 n.setName( "K1PYK7_RAT" );
4531 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4534 n.setName( "K1PYK7_PIG" );
4535 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4538 n.setName( "~K1PYK7_PIG~" );
4539 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4542 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4543 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4546 n.setName( "K1PYKX_CRAGI" );
4547 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4550 n.setName( "XXXXX_CRAGI" );
4551 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4554 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4555 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4558 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4559 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4562 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4563 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4566 n = new PhylogenyNode();
4567 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4568 seq.setSymbol( "K1PYK7_CRAGI" );
4569 n.getNodeData().addSequence( seq );
4570 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4573 seq.setSymbol( "tr|B3RJ64" );
4574 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4577 n = new PhylogenyNode();
4578 seq = new org.forester.phylogeny.data.Sequence();
4579 seq.setName( "K1PYK7_CRAGI" );
4580 n.getNodeData().addSequence( seq );
4581 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4584 seq.setName( "tr|B3RJ64" );
4585 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4588 n = new PhylogenyNode();
4589 seq = new org.forester.phylogeny.data.Sequence();
4590 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4591 n.getNodeData().addSequence( seq );
4592 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4595 n = new PhylogenyNode();
4596 seq = new org.forester.phylogeny.data.Sequence();
4597 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4598 n.getNodeData().addSequence( seq );
4599 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4603 n = new PhylogenyNode();
4604 n.setName( "ACP19736" );
4605 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4608 n = new PhylogenyNode();
4609 n.setName( "|ACP19736|" );
4610 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4614 catch ( final Exception e ) {
4615 e.printStackTrace( System.out );
4621 private static boolean testFastaParser() {
4623 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4626 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4629 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4630 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4633 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4636 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4639 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4642 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4645 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4649 catch ( final Exception e ) {
4650 e.printStackTrace();
4656 private static boolean testGenbankAccessorParsing() {
4657 //The format for GenBank Accession numbers are:
4658 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4659 //Protein: 3 letters + 5 numerals
4660 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4661 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4664 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4667 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4670 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4673 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4676 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4679 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4682 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4685 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4688 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4691 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4694 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4697 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4700 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4706 private static boolean testGeneralMsaParser() {
4708 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4709 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4710 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4711 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4712 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4713 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4714 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4715 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4716 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4719 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4722 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4725 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4728 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4731 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4734 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4737 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4740 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4743 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4746 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4749 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4752 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4753 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4756 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4759 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4762 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4763 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4766 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4769 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4772 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4773 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4776 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4779 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4783 catch ( final Exception e ) {
4784 e.printStackTrace();
4790 private static boolean testGeneralTable() {
4792 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4793 t0.setValue( 3, 2, "23" );
4794 t0.setValue( 10, 1, "error" );
4795 t0.setValue( 10, 1, "110" );
4796 t0.setValue( 9, 1, "19" );
4797 t0.setValue( 1, 10, "101" );
4798 t0.setValue( 10, 10, "1010" );
4799 t0.setValue( 100, 10, "10100" );
4800 t0.setValue( 0, 0, "00" );
4801 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4804 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4807 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4810 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4813 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4816 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4819 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4822 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4825 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4828 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4829 t1.setValue( "3", "2", "23" );
4830 t1.setValue( "10", "1", "error" );
4831 t1.setValue( "10", "1", "110" );
4832 t1.setValue( "9", "1", "19" );
4833 t1.setValue( "1", "10", "101" );
4834 t1.setValue( "10", "10", "1010" );
4835 t1.setValue( "100", "10", "10100" );
4836 t1.setValue( "0", "0", "00" );
4837 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4838 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4841 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4844 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4847 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4850 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4853 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4856 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4859 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4862 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4865 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4869 catch ( final Exception e ) {
4870 e.printStackTrace( System.out );
4876 private static boolean testGetDistance() {
4878 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4879 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",
4880 new NHXParser() )[ 0 ];
4881 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4884 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4887 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4890 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4893 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4896 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4899 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4902 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4905 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4908 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4911 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4914 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4917 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4920 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4923 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4926 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4929 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4932 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4935 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4938 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4941 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4944 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4947 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4950 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4953 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4956 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4959 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4962 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4965 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4968 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4971 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4974 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",
4975 new NHXParser() )[ 0 ];
4976 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4979 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4982 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4985 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4988 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4991 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4994 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4997 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5000 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5003 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5006 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5010 catch ( final Exception e ) {
5011 e.printStackTrace( System.out );
5017 private static boolean testGetLCA() {
5019 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5020 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5021 new NHXParser() )[ 0 ];
5022 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5023 if ( !A.getName().equals( "A" ) ) {
5026 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5027 if ( !gh.getName().equals( "gh" ) ) {
5030 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5031 if ( !ab.getName().equals( "ab" ) ) {
5034 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5035 if ( !ab2.getName().equals( "ab" ) ) {
5038 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5039 if ( !gh2.getName().equals( "gh" ) ) {
5042 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5043 if ( !gh3.getName().equals( "gh" ) ) {
5046 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5047 if ( !abc.getName().equals( "abc" ) ) {
5050 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5051 if ( !abc2.getName().equals( "abc" ) ) {
5054 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5055 if ( !abcd.getName().equals( "abcd" ) ) {
5058 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5059 if ( !abcd2.getName().equals( "abcd" ) ) {
5062 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5063 if ( !abcdef.getName().equals( "abcdef" ) ) {
5066 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5067 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5070 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5071 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5074 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5075 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5078 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5079 if ( !abcde.getName().equals( "abcde" ) ) {
5082 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5083 if ( !abcde2.getName().equals( "abcde" ) ) {
5086 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5087 if ( !r.getName().equals( "abcdefgh" ) ) {
5090 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5091 if ( !r2.getName().equals( "abcdefgh" ) ) {
5094 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5095 if ( !r3.getName().equals( "abcdefgh" ) ) {
5098 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5099 if ( !abcde3.getName().equals( "abcde" ) ) {
5102 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5103 if ( !abcde4.getName().equals( "abcde" ) ) {
5106 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5107 if ( !ab3.getName().equals( "ab" ) ) {
5110 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5111 if ( !ab4.getName().equals( "ab" ) ) {
5114 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5115 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5116 if ( !cd.getName().equals( "cd" ) ) {
5119 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5120 if ( !cd2.getName().equals( "cd" ) ) {
5123 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5124 if ( !cde.getName().equals( "cde" ) ) {
5127 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5128 if ( !cde2.getName().equals( "cde" ) ) {
5131 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5132 if ( !cdef.getName().equals( "cdef" ) ) {
5135 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5136 if ( !cdef2.getName().equals( "cdef" ) ) {
5139 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5140 if ( !cdef3.getName().equals( "cdef" ) ) {
5143 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5144 if ( !rt.getName().equals( "r" ) ) {
5147 final Phylogeny p3 = factory
5148 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5149 new NHXParser() )[ 0 ];
5150 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5151 if ( !bc_3.getName().equals( "bc" ) ) {
5154 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5155 if ( !ac_3.getName().equals( "abc" ) ) {
5158 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5159 if ( !ad_3.getName().equals( "abcde" ) ) {
5162 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5163 if ( !af_3.getName().equals( "abcdef" ) ) {
5166 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5167 if ( !ag_3.getName().equals( "" ) ) {
5170 if ( !ag_3.isRoot() ) {
5173 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5174 if ( !al_3.getName().equals( "" ) ) {
5177 if ( !al_3.isRoot() ) {
5180 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5181 if ( !kl_3.getName().equals( "" ) ) {
5184 if ( !kl_3.isRoot() ) {
5187 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5188 if ( !fl_3.getName().equals( "" ) ) {
5191 if ( !fl_3.isRoot() ) {
5194 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5195 if ( !gk_3.getName().equals( "ghijk" ) ) {
5198 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5199 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5200 if ( !r_4.getName().equals( "r" ) ) {
5203 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5204 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5205 if ( !r_5.getName().equals( "root" ) ) {
5208 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5209 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5210 if ( !r_6.getName().equals( "rot" ) ) {
5213 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5214 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5215 if ( !r_7.getName().equals( "rott" ) ) {
5219 catch ( final Exception e ) {
5220 e.printStackTrace( System.out );
5226 private static boolean testGetLCA2() {
5228 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5229 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5230 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5231 PhylogenyMethods.preOrderReId( p_a );
5232 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5233 p_a.getNode( "a" ) );
5234 if ( !p_a_1.getName().equals( "a" ) ) {
5237 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5238 PhylogenyMethods.preOrderReId( p_b );
5239 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5240 p_b.getNode( "a" ) );
5241 if ( !p_b_1.getName().equals( "b" ) ) {
5244 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5245 p_b.getNode( "b" ) );
5246 if ( !p_b_2.getName().equals( "b" ) ) {
5249 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5250 PhylogenyMethods.preOrderReId( p_c );
5251 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5252 p_c.getNode( "a" ) );
5253 if ( !p_c_1.getName().equals( "b" ) ) {
5256 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5257 p_c.getNode( "c" ) );
5258 if ( !p_c_2.getName().equals( "c" ) ) {
5259 System.out.println( p_c_2.getName() );
5263 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5264 p_c.getNode( "b" ) );
5265 if ( !p_c_3.getName().equals( "b" ) ) {
5268 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5269 p_c.getNode( "a" ) );
5270 if ( !p_c_4.getName().equals( "c" ) ) {
5273 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5274 new NHXParser() )[ 0 ];
5275 PhylogenyMethods.preOrderReId( p1 );
5276 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5277 p1.getNode( "A" ) );
5278 if ( !A.getName().equals( "A" ) ) {
5281 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5282 p1.getNode( "gh" ) );
5283 if ( !gh.getName().equals( "gh" ) ) {
5286 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5287 p1.getNode( "B" ) );
5288 if ( !ab.getName().equals( "ab" ) ) {
5291 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5292 p1.getNode( "A" ) );
5293 if ( !ab2.getName().equals( "ab" ) ) {
5296 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5297 p1.getNode( "G" ) );
5298 if ( !gh2.getName().equals( "gh" ) ) {
5301 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5302 p1.getNode( "H" ) );
5303 if ( !gh3.getName().equals( "gh" ) ) {
5306 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5307 p1.getNode( "A" ) );
5308 if ( !abc.getName().equals( "abc" ) ) {
5311 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5312 p1.getNode( "C" ) );
5313 if ( !abc2.getName().equals( "abc" ) ) {
5316 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5317 p1.getNode( "D" ) );
5318 if ( !abcd.getName().equals( "abcd" ) ) {
5321 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5322 p1.getNode( "A" ) );
5323 if ( !abcd2.getName().equals( "abcd" ) ) {
5326 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5327 p1.getNode( "F" ) );
5328 if ( !abcdef.getName().equals( "abcdef" ) ) {
5331 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5332 p1.getNode( "A" ) );
5333 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5336 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5337 p1.getNode( "F" ) );
5338 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5341 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5342 p1.getNode( "ab" ) );
5343 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5346 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5347 p1.getNode( "E" ) );
5348 if ( !abcde.getName().equals( "abcde" ) ) {
5351 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5352 p1.getNode( "A" ) );
5353 if ( !abcde2.getName().equals( "abcde" ) ) {
5356 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5357 p1.getNode( "abcdefgh" ) );
5358 if ( !r.getName().equals( "abcdefgh" ) ) {
5361 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5362 p1.getNode( "H" ) );
5363 if ( !r2.getName().equals( "abcdefgh" ) ) {
5366 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5367 p1.getNode( "A" ) );
5368 if ( !r3.getName().equals( "abcdefgh" ) ) {
5371 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5372 p1.getNode( "abcde" ) );
5373 if ( !abcde3.getName().equals( "abcde" ) ) {
5376 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5377 p1.getNode( "E" ) );
5378 if ( !abcde4.getName().equals( "abcde" ) ) {
5381 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5382 p1.getNode( "B" ) );
5383 if ( !ab3.getName().equals( "ab" ) ) {
5386 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5387 p1.getNode( "ab" ) );
5388 if ( !ab4.getName().equals( "ab" ) ) {
5391 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5392 PhylogenyMethods.preOrderReId( p2 );
5393 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5394 p2.getNode( "d" ) );
5395 if ( !cd.getName().equals( "cd" ) ) {
5398 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5399 p2.getNode( "c" ) );
5400 if ( !cd2.getName().equals( "cd" ) ) {
5403 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5404 p2.getNode( "e" ) );
5405 if ( !cde.getName().equals( "cde" ) ) {
5408 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5409 p2.getNode( "c" ) );
5410 if ( !cde2.getName().equals( "cde" ) ) {
5413 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5414 p2.getNode( "f" ) );
5415 if ( !cdef.getName().equals( "cdef" ) ) {
5418 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5419 p2.getNode( "f" ) );
5420 if ( !cdef2.getName().equals( "cdef" ) ) {
5423 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5424 p2.getNode( "d" ) );
5425 if ( !cdef3.getName().equals( "cdef" ) ) {
5428 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5429 p2.getNode( "a" ) );
5430 if ( !rt.getName().equals( "r" ) ) {
5433 final Phylogeny p3 = factory
5434 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5435 new NHXParser() )[ 0 ];
5436 PhylogenyMethods.preOrderReId( p3 );
5437 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5438 p3.getNode( "c" ) );
5439 if ( !bc_3.getName().equals( "bc" ) ) {
5442 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5443 p3.getNode( "c" ) );
5444 if ( !ac_3.getName().equals( "abc" ) ) {
5447 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5448 p3.getNode( "d" ) );
5449 if ( !ad_3.getName().equals( "abcde" ) ) {
5452 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5453 p3.getNode( "f" ) );
5454 if ( !af_3.getName().equals( "abcdef" ) ) {
5457 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5458 p3.getNode( "g" ) );
5459 if ( !ag_3.getName().equals( "" ) ) {
5462 if ( !ag_3.isRoot() ) {
5465 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5466 p3.getNode( "l" ) );
5467 if ( !al_3.getName().equals( "" ) ) {
5470 if ( !al_3.isRoot() ) {
5473 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5474 p3.getNode( "l" ) );
5475 if ( !kl_3.getName().equals( "" ) ) {
5478 if ( !kl_3.isRoot() ) {
5481 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5482 p3.getNode( "l" ) );
5483 if ( !fl_3.getName().equals( "" ) ) {
5486 if ( !fl_3.isRoot() ) {
5489 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5490 p3.getNode( "k" ) );
5491 if ( !gk_3.getName().equals( "ghijk" ) ) {
5494 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5495 PhylogenyMethods.preOrderReId( p4 );
5496 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5497 p4.getNode( "c" ) );
5498 if ( !r_4.getName().equals( "r" ) ) {
5501 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5502 PhylogenyMethods.preOrderReId( p5 );
5503 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5504 p5.getNode( "c" ) );
5505 if ( !r_5.getName().equals( "root" ) ) {
5508 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5509 PhylogenyMethods.preOrderReId( p6 );
5510 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5511 p6.getNode( "a" ) );
5512 if ( !r_6.getName().equals( "rot" ) ) {
5515 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5516 PhylogenyMethods.preOrderReId( p7 );
5517 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5518 p7.getNode( "e" ) );
5519 if ( !r_7.getName().equals( "rott" ) ) {
5522 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5523 p7.getNode( "a" ) );
5524 if ( !r_71.getName().equals( "rott" ) ) {
5527 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5528 p7.getNode( "rott" ) );
5529 if ( !r_72.getName().equals( "rott" ) ) {
5532 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5533 p7.getNode( "a" ) );
5534 if ( !r_73.getName().equals( "rott" ) ) {
5537 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5538 p7.getNode( "rott" ) );
5539 if ( !r_74.getName().equals( "rott" ) ) {
5542 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5543 p7.getNode( "e" ) );
5544 if ( !r_75.getName().equals( "e" ) ) {
5548 catch ( final Exception e ) {
5549 e.printStackTrace( System.out );
5555 private static boolean testHmmscanOutputParser() {
5556 final String test_dir = Test.PATH_TO_TEST_DATA;
5558 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5559 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5561 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5562 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5563 final List<Protein> proteins = parser2.parse();
5564 if ( parser2.getProteinsEncountered() != 4 ) {
5567 if ( proteins.size() != 4 ) {
5570 if ( parser2.getDomainsEncountered() != 69 ) {
5573 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5576 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5579 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5582 final Protein p1 = proteins.get( 0 );
5583 if ( p1.getNumberOfProteinDomains() != 15 ) {
5586 if ( p1.getLength() != 850 ) {
5589 final Protein p2 = proteins.get( 1 );
5590 if ( p2.getNumberOfProteinDomains() != 51 ) {
5593 if ( p2.getLength() != 1291 ) {
5596 final Protein p3 = proteins.get( 2 );
5597 if ( p3.getNumberOfProteinDomains() != 2 ) {
5600 final Protein p4 = proteins.get( 3 );
5601 if ( p4.getNumberOfProteinDomains() != 1 ) {
5604 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5607 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5610 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5613 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5616 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5619 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5622 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5626 catch ( final Exception e ) {
5627 e.printStackTrace( System.out );
5633 private static boolean testLastExternalNodeMethods() {
5635 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5636 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5637 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5638 final PhylogenyNode n1 = t0.getNode( "A" );
5639 if ( n1.isLastExternalNode() ) {
5642 final PhylogenyNode n2 = t0.getNode( "B" );
5643 if ( n2.isLastExternalNode() ) {
5646 final PhylogenyNode n3 = t0.getNode( "C" );
5647 if ( n3.isLastExternalNode() ) {
5650 final PhylogenyNode n4 = t0.getNode( "D" );
5651 if ( !n4.isLastExternalNode() ) {
5655 catch ( final Exception e ) {
5656 e.printStackTrace( System.out );
5662 private static boolean testLevelOrderIterator() {
5664 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5665 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5666 PhylogenyNodeIterator it0;
5667 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5670 for( it0.reset(); it0.hasNext(); ) {
5673 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5674 if ( !it.next().getName().equals( "r" ) ) {
5677 if ( !it.next().getName().equals( "ab" ) ) {
5680 if ( !it.next().getName().equals( "cd" ) ) {
5683 if ( !it.next().getName().equals( "A" ) ) {
5686 if ( !it.next().getName().equals( "B" ) ) {
5689 if ( !it.next().getName().equals( "C" ) ) {
5692 if ( !it.next().getName().equals( "D" ) ) {
5695 if ( it.hasNext() ) {
5698 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",
5699 new NHXParser() )[ 0 ];
5700 PhylogenyNodeIterator it2;
5701 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5704 for( it2.reset(); it2.hasNext(); ) {
5707 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5708 if ( !it3.next().getName().equals( "r" ) ) {
5711 if ( !it3.next().getName().equals( "abc" ) ) {
5714 if ( !it3.next().getName().equals( "defg" ) ) {
5717 if ( !it3.next().getName().equals( "A" ) ) {
5720 if ( !it3.next().getName().equals( "B" ) ) {
5723 if ( !it3.next().getName().equals( "C" ) ) {
5726 if ( !it3.next().getName().equals( "D" ) ) {
5729 if ( !it3.next().getName().equals( "E" ) ) {
5732 if ( !it3.next().getName().equals( "F" ) ) {
5735 if ( !it3.next().getName().equals( "G" ) ) {
5738 if ( !it3.next().getName().equals( "1" ) ) {
5741 if ( !it3.next().getName().equals( "2" ) ) {
5744 if ( !it3.next().getName().equals( "3" ) ) {
5747 if ( !it3.next().getName().equals( "4" ) ) {
5750 if ( !it3.next().getName().equals( "5" ) ) {
5753 if ( !it3.next().getName().equals( "6" ) ) {
5756 if ( !it3.next().getName().equals( "f1" ) ) {
5759 if ( !it3.next().getName().equals( "f2" ) ) {
5762 if ( !it3.next().getName().equals( "f3" ) ) {
5765 if ( !it3.next().getName().equals( "a" ) ) {
5768 if ( !it3.next().getName().equals( "b" ) ) {
5771 if ( !it3.next().getName().equals( "f21" ) ) {
5774 if ( !it3.next().getName().equals( "X" ) ) {
5777 if ( !it3.next().getName().equals( "Y" ) ) {
5780 if ( !it3.next().getName().equals( "Z" ) ) {
5783 if ( it3.hasNext() ) {
5786 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5787 PhylogenyNodeIterator it4;
5788 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5791 for( it4.reset(); it4.hasNext(); ) {
5794 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5795 if ( !it5.next().getName().equals( "r" ) ) {
5798 if ( !it5.next().getName().equals( "A" ) ) {
5801 if ( !it5.next().getName().equals( "B" ) ) {
5804 if ( !it5.next().getName().equals( "C" ) ) {
5807 if ( !it5.next().getName().equals( "D" ) ) {
5810 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5811 PhylogenyNodeIterator it6;
5812 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5815 for( it6.reset(); it6.hasNext(); ) {
5818 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5819 if ( !it7.next().getName().equals( "A" ) ) {
5822 if ( it.hasNext() ) {
5826 catch ( final Exception e ) {
5827 e.printStackTrace( System.out );
5833 private static boolean testMafft( final String path ) {
5835 final List<String> opts = new ArrayList<String>();
5836 opts.add( "--maxiterate" );
5838 opts.add( "--localpair" );
5839 opts.add( "--quiet" );
5841 final MsaInferrer mafft = Mafft.createInstance( path );
5842 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5843 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5846 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5850 catch ( final Exception e ) {
5851 e.printStackTrace( System.out );
5857 private static boolean testMidpointrooting() {
5859 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5860 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5861 PhylogenyMethods.midpointRoot( t0 );
5862 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5865 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5868 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5872 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",
5873 new NHXParser() )[ 0 ];
5874 if ( !t1.isRooted() ) {
5877 PhylogenyMethods.midpointRoot( t1 );
5878 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5881 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5884 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5887 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5890 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5893 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5896 t1.reRoot( t1.getNode( "A" ) );
5897 PhylogenyMethods.midpointRoot( t1 );
5898 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5901 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5904 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5907 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5910 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5914 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5918 catch ( final Exception e ) {
5919 e.printStackTrace( System.out );
5925 private static boolean testMsaQualityMethod() {
5927 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
5928 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
5929 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
5930 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
5931 final List<Sequence> l = new ArrayList<Sequence>();
5936 final Msa msa = BasicMsa.createInstance( l );
5937 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5940 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5943 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5946 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5949 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
5952 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
5955 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
5959 catch ( final Exception e ) {
5960 e.printStackTrace( System.out );
5966 private static boolean testNextNodeWithCollapsing() {
5968 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5970 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5971 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5972 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5973 t0.getNode( "cd" ).setCollapse( true );
5974 t0.getNode( "cde" ).setCollapse( true );
5975 n = t0.getFirstExternalNode();
5976 while ( n != null ) {
5978 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5980 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5983 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5986 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5989 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5992 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5995 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5999 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6000 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6001 t1.getNode( "ab" ).setCollapse( true );
6002 t1.getNode( "cd" ).setCollapse( true );
6003 t1.getNode( "cde" ).setCollapse( true );
6004 n = t1.getNode( "ab" );
6005 ext = new ArrayList<PhylogenyNode>();
6006 while ( n != null ) {
6008 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6010 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6013 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6016 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6019 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6022 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6028 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6029 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6030 t2.getNode( "ab" ).setCollapse( true );
6031 t2.getNode( "cd" ).setCollapse( true );
6032 t2.getNode( "cde" ).setCollapse( true );
6033 t2.getNode( "c" ).setCollapse( true );
6034 t2.getNode( "d" ).setCollapse( true );
6035 t2.getNode( "e" ).setCollapse( true );
6036 t2.getNode( "gh" ).setCollapse( true );
6037 n = t2.getNode( "ab" );
6038 ext = new ArrayList<PhylogenyNode>();
6039 while ( n != null ) {
6041 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6043 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6046 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6049 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6052 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6058 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6059 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6060 t3.getNode( "ab" ).setCollapse( true );
6061 t3.getNode( "cd" ).setCollapse( true );
6062 t3.getNode( "cde" ).setCollapse( true );
6063 t3.getNode( "c" ).setCollapse( true );
6064 t3.getNode( "d" ).setCollapse( true );
6065 t3.getNode( "e" ).setCollapse( true );
6066 t3.getNode( "gh" ).setCollapse( true );
6067 t3.getNode( "fgh" ).setCollapse( true );
6068 n = t3.getNode( "ab" );
6069 ext = new ArrayList<PhylogenyNode>();
6070 while ( n != null ) {
6072 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6074 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6077 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6080 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6086 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6087 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6088 t4.getNode( "ab" ).setCollapse( true );
6089 t4.getNode( "cd" ).setCollapse( true );
6090 t4.getNode( "cde" ).setCollapse( true );
6091 t4.getNode( "c" ).setCollapse( true );
6092 t4.getNode( "d" ).setCollapse( true );
6093 t4.getNode( "e" ).setCollapse( true );
6094 t4.getNode( "gh" ).setCollapse( true );
6095 t4.getNode( "fgh" ).setCollapse( true );
6096 t4.getNode( "abcdefgh" ).setCollapse( true );
6097 n = t4.getNode( "abcdefgh" );
6098 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6103 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6104 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6106 n = t5.getFirstExternalNode();
6107 while ( n != null ) {
6109 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6111 if ( ext.size() != 8 ) {
6114 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6117 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6120 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6123 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6126 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6129 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6132 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6135 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6140 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6141 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6143 t6.getNode( "ab" ).setCollapse( true );
6144 n = t6.getNode( "ab" );
6145 while ( n != null ) {
6147 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6149 if ( ext.size() != 7 ) {
6152 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6155 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6158 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6161 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6164 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6167 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6170 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6175 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6176 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6178 t7.getNode( "cd" ).setCollapse( true );
6179 n = t7.getNode( "a" );
6180 while ( n != null ) {
6182 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6184 if ( ext.size() != 7 ) {
6187 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6190 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6193 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6196 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6199 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6202 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6205 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6210 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6211 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6213 t8.getNode( "cd" ).setCollapse( true );
6214 t8.getNode( "c" ).setCollapse( true );
6215 t8.getNode( "d" ).setCollapse( true );
6216 n = t8.getNode( "a" );
6217 while ( n != null ) {
6219 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6221 if ( ext.size() != 7 ) {
6224 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6227 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6230 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6231 System.out.println( "2 fail" );
6234 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6237 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6240 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6243 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6248 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6249 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6251 t9.getNode( "gh" ).setCollapse( true );
6252 n = t9.getNode( "a" );
6253 while ( n != null ) {
6255 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6257 if ( ext.size() != 7 ) {
6260 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6263 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6266 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6269 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6272 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6275 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6278 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6283 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6284 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6286 t10.getNode( "gh" ).setCollapse( true );
6287 t10.getNode( "g" ).setCollapse( true );
6288 t10.getNode( "h" ).setCollapse( true );
6289 n = t10.getNode( "a" );
6290 while ( n != null ) {
6292 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6294 if ( ext.size() != 7 ) {
6297 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6300 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6303 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6306 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6309 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6312 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6315 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6320 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6321 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6323 t11.getNode( "gh" ).setCollapse( true );
6324 t11.getNode( "fgh" ).setCollapse( true );
6325 n = t11.getNode( "a" );
6326 while ( n != null ) {
6328 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6330 if ( ext.size() != 6 ) {
6333 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6336 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6339 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6342 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6345 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6348 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6353 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6354 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6356 t12.getNode( "gh" ).setCollapse( true );
6357 t12.getNode( "fgh" ).setCollapse( true );
6358 t12.getNode( "g" ).setCollapse( true );
6359 t12.getNode( "h" ).setCollapse( true );
6360 t12.getNode( "f" ).setCollapse( true );
6361 n = t12.getNode( "a" );
6362 while ( n != null ) {
6364 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6366 if ( ext.size() != 6 ) {
6369 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6372 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6375 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6378 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6381 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6384 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6389 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6390 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6392 t13.getNode( "ab" ).setCollapse( true );
6393 t13.getNode( "b" ).setCollapse( true );
6394 t13.getNode( "fgh" ).setCollapse( true );
6395 t13.getNode( "gh" ).setCollapse( true );
6396 n = t13.getNode( "ab" );
6397 while ( n != null ) {
6399 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6401 if ( ext.size() != 5 ) {
6404 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6407 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6410 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6413 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6416 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6421 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6422 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6424 t14.getNode( "ab" ).setCollapse( true );
6425 t14.getNode( "a" ).setCollapse( true );
6426 t14.getNode( "fgh" ).setCollapse( true );
6427 t14.getNode( "gh" ).setCollapse( true );
6428 n = t14.getNode( "ab" );
6429 while ( n != null ) {
6431 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6433 if ( ext.size() != 5 ) {
6436 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6439 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6442 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6445 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6448 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6453 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" );
6454 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6456 t15.getNode( "ab" ).setCollapse( true );
6457 t15.getNode( "a" ).setCollapse( true );
6458 t15.getNode( "fgh" ).setCollapse( true );
6459 t15.getNode( "gh" ).setCollapse( true );
6460 n = t15.getNode( "ab" );
6461 while ( n != null ) {
6463 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6465 if ( ext.size() != 6 ) {
6468 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6471 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6474 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6477 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6480 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6483 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6488 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" );
6489 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6491 t16.getNode( "ab" ).setCollapse( true );
6492 t16.getNode( "a" ).setCollapse( true );
6493 t16.getNode( "fgh" ).setCollapse( true );
6494 t16.getNode( "gh" ).setCollapse( true );
6495 t16.getNode( "cd" ).setCollapse( true );
6496 t16.getNode( "cde" ).setCollapse( true );
6497 t16.getNode( "d" ).setCollapse( true );
6498 t16.getNode( "x" ).setCollapse( true );
6499 n = t16.getNode( "ab" );
6500 while ( n != null ) {
6502 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6504 if ( ext.size() != 4 ) {
6507 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6510 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6513 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6516 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6520 catch ( final Exception e ) {
6521 e.printStackTrace( System.out );
6527 private static boolean testNexusCharactersParsing() {
6529 final NexusCharactersParser parser = new NexusCharactersParser();
6530 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6532 String[] labels = parser.getCharStateLabels();
6533 if ( labels.length != 7 ) {
6536 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6539 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6542 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6545 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6548 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6551 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6554 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6557 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6559 labels = parser.getCharStateLabels();
6560 if ( labels.length != 7 ) {
6563 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6566 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6569 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6572 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6575 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6578 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6581 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6585 catch ( final Exception e ) {
6586 e.printStackTrace( System.out );
6592 private static boolean testNexusMatrixParsing() {
6594 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6595 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6597 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6598 if ( m.getNumberOfCharacters() != 9 ) {
6601 if ( m.getNumberOfIdentifiers() != 5 ) {
6604 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6607 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6610 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6613 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6616 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6619 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6622 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6625 // if ( labels.length != 7 ) {
6628 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6631 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6634 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6637 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6640 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6643 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6646 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6649 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6651 // labels = parser.getCharStateLabels();
6652 // if ( labels.length != 7 ) {
6655 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6658 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6661 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6664 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6667 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6670 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6673 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6677 catch ( final Exception e ) {
6678 e.printStackTrace( System.out );
6684 private static boolean testNexusTreeParsing() {
6686 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6687 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6688 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
6689 if ( phylogenies.length != 1 ) {
6692 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
6695 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6699 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
6700 if ( phylogenies.length != 1 ) {
6703 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6706 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
6710 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
6711 if ( phylogenies.length != 1 ) {
6714 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6717 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
6720 if ( phylogenies[ 0 ].isRooted() ) {
6724 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
6725 if ( phylogenies.length != 18 ) {
6728 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
6731 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
6734 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
6737 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
6740 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6743 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
6746 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
6749 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
6752 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
6755 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
6758 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
6761 if ( phylogenies[ 8 ].isRooted() ) {
6764 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
6767 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
6770 if ( !phylogenies[ 9 ].isRooted() ) {
6773 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6776 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6779 if ( !phylogenies[ 10 ].isRooted() ) {
6782 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6785 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6788 if ( phylogenies[ 11 ].isRooted() ) {
6791 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6794 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6797 if ( !phylogenies[ 12 ].isRooted() ) {
6800 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6803 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6806 if ( !phylogenies[ 13 ].isRooted() ) {
6809 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6812 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6815 if ( !phylogenies[ 14 ].isRooted() ) {
6818 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6821 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6824 if ( phylogenies[ 15 ].isRooted() ) {
6827 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6830 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6833 if ( !phylogenies[ 16 ].isRooted() ) {
6836 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6839 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6842 if ( phylogenies[ 17 ].isRooted() ) {
6845 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6848 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
6850 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
6851 if ( phylogenies.length != 9 ) {
6854 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
6855 .getDistanceToParent() ) ) {
6858 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
6859 .getDistanceToParent() ) ) {
6862 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
6865 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6868 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
6871 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6874 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
6878 catch ( final Exception e ) {
6879 e.printStackTrace( System.out );
6885 private static boolean testNexusTreeParsingIterating() {
6887 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6888 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6889 if ( !p.hasNext() ) {
6892 Phylogeny phy = p.next();
6893 if ( phy == null ) {
6896 if ( phy.getNumberOfExternalNodes() != 25 ) {
6899 if ( !phy.getName().equals( "" ) ) {
6902 if ( p.hasNext() ) {
6906 if ( phy != null ) {
6911 if ( !p.hasNext() ) {
6915 if ( phy == null ) {
6918 if ( phy.getNumberOfExternalNodes() != 25 ) {
6921 if ( !phy.getName().equals( "" ) ) {
6924 if ( p.hasNext() ) {
6928 if ( phy != null ) {
6932 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6933 if ( !p.hasNext() ) {
6937 if ( phy == null ) {
6940 if ( phy.getNumberOfExternalNodes() != 10 ) {
6943 if ( !phy.getName().equals( "name" ) ) {
6946 if ( p.hasNext() ) {
6950 if ( phy != null ) {
6955 if ( !p.hasNext() ) {
6959 if ( phy == null ) {
6962 if ( phy.getNumberOfExternalNodes() != 10 ) {
6965 if ( !phy.getName().equals( "name" ) ) {
6968 if ( p.hasNext() ) {
6972 if ( phy != null ) {
6976 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6977 if ( !p.hasNext() ) {
6981 if ( phy == null ) {
6984 if ( phy.getNumberOfExternalNodes() != 3 ) {
6987 if ( !phy.getName().equals( "" ) ) {
6990 if ( phy.isRooted() ) {
6993 if ( p.hasNext() ) {
6997 if ( phy != null ) {
7002 if ( !p.hasNext() ) {
7006 if ( phy == null ) {
7009 if ( phy.getNumberOfExternalNodes() != 3 ) {
7012 if ( !phy.getName().equals( "" ) ) {
7015 if ( p.hasNext() ) {
7019 if ( phy != null ) {
7023 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7024 if ( !p.hasNext() ) {
7029 if ( phy == null ) {
7032 if ( phy.getNumberOfExternalNodes() != 10 ) {
7035 if ( !phy.getName().equals( "tree 0" ) ) {
7039 if ( !p.hasNext() ) {
7043 if ( phy == null ) {
7046 if ( phy.getNumberOfExternalNodes() != 10 ) {
7049 if ( !phy.getName().equals( "tree 1" ) ) {
7053 if ( !p.hasNext() ) {
7057 if ( phy == null ) {
7060 if ( phy.getNumberOfExternalNodes() != 3 ) {
7061 System.out.println( phy.toString() );
7064 if ( !phy.getName().equals( "" ) ) {
7067 if ( phy.isRooted() ) {
7071 if ( !p.hasNext() ) {
7075 if ( phy == null ) {
7078 if ( phy.getNumberOfExternalNodes() != 4 ) {
7081 if ( !phy.getName().equals( "" ) ) {
7084 if ( !phy.isRooted() ) {
7088 if ( !p.hasNext() ) {
7092 if ( phy == null ) {
7095 if ( phy.getNumberOfExternalNodes() != 5 ) {
7096 System.out.println( phy.getNumberOfExternalNodes() );
7099 if ( !phy.getName().equals( "" ) ) {
7102 if ( !phy.isRooted() ) {
7106 if ( !p.hasNext() ) {
7110 if ( phy == null ) {
7113 if ( phy.getNumberOfExternalNodes() != 3 ) {
7116 if ( !phy.getName().equals( "" ) ) {
7119 if ( phy.isRooted() ) {
7123 if ( !p.hasNext() ) {
7127 if ( phy == null ) {
7130 if ( phy.getNumberOfExternalNodes() != 2 ) {
7133 if ( !phy.getName().equals( "" ) ) {
7136 if ( !phy.isRooted() ) {
7140 if ( !p.hasNext() ) {
7144 if ( phy.getNumberOfExternalNodes() != 3 ) {
7147 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7150 if ( !phy.isRooted() ) {
7154 if ( !p.hasNext() ) {
7158 if ( phy.getNumberOfExternalNodes() != 3 ) {
7161 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7164 if ( !phy.getName().equals( "tree 8" ) ) {
7168 if ( !p.hasNext() ) {
7172 if ( phy.getNumberOfExternalNodes() != 3 ) {
7175 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7178 if ( !phy.getName().equals( "tree 9" ) ) {
7182 if ( !p.hasNext() ) {
7186 if ( phy.getNumberOfExternalNodes() != 3 ) {
7189 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7192 if ( !phy.getName().equals( "tree 10" ) ) {
7195 if ( !phy.isRooted() ) {
7199 if ( !p.hasNext() ) {
7203 if ( phy.getNumberOfExternalNodes() != 3 ) {
7206 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7209 if ( !phy.getName().equals( "tree 11" ) ) {
7212 if ( phy.isRooted() ) {
7216 if ( !p.hasNext() ) {
7220 if ( phy.getNumberOfExternalNodes() != 3 ) {
7223 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7226 if ( !phy.getName().equals( "tree 12" ) ) {
7229 if ( !phy.isRooted() ) {
7233 if ( !p.hasNext() ) {
7237 if ( phy.getNumberOfExternalNodes() != 3 ) {
7240 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7243 if ( !phy.getName().equals( "tree 13" ) ) {
7246 if ( !phy.isRooted() ) {
7250 if ( !p.hasNext() ) {
7254 if ( phy.getNumberOfExternalNodes() != 10 ) {
7255 System.out.println( phy.getNumberOfExternalNodes() );
7260 .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;" ) ) {
7261 System.out.println( phy.toNewHampshire() );
7264 if ( !phy.getName().equals( "tree 14" ) ) {
7267 if ( !phy.isRooted() ) {
7271 if ( !p.hasNext() ) {
7275 if ( phy.getNumberOfExternalNodes() != 10 ) {
7276 System.out.println( phy.getNumberOfExternalNodes() );
7281 .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;" ) ) {
7282 System.out.println( phy.toNewHampshire() );
7285 if ( !phy.getName().equals( "tree 15" ) ) {
7288 if ( phy.isRooted() ) {
7292 if ( !p.hasNext() ) {
7296 if ( phy.getNumberOfExternalNodes() != 10 ) {
7297 System.out.println( phy.getNumberOfExternalNodes() );
7302 .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;" ) ) {
7303 System.out.println( phy.toNewHampshire() );
7306 if ( !phy.getName().equals( "tree 16" ) ) {
7309 if ( !phy.isRooted() ) {
7313 if ( !p.hasNext() ) {
7317 if ( phy.getNumberOfExternalNodes() != 10 ) {
7318 System.out.println( phy.getNumberOfExternalNodes() );
7323 .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;" ) ) {
7324 System.out.println( phy.toNewHampshire() );
7327 if ( !phy.getName().equals( "tree 17" ) ) {
7330 if ( phy.isRooted() ) {
7334 if ( p.hasNext() ) {
7338 if ( phy != null ) {
7343 if ( !p.hasNext() ) {
7347 if ( phy == null ) {
7350 if ( phy.getNumberOfExternalNodes() != 10 ) {
7353 if ( !phy.getName().equals( "tree 0" ) ) {
7357 if ( !p.hasNext() ) {
7361 if ( phy == null ) {
7364 if ( phy.getNumberOfExternalNodes() != 10 ) {
7367 if ( !phy.getName().equals( "tree 1" ) ) {
7371 if ( !p.hasNext() ) {
7375 if ( phy == null ) {
7378 if ( phy.getNumberOfExternalNodes() != 3 ) {
7381 if ( !phy.getName().equals( "" ) ) {
7384 if ( phy.isRooted() ) {
7388 if ( !p.hasNext() ) {
7392 if ( phy == null ) {
7395 if ( phy.getNumberOfExternalNodes() != 4 ) {
7398 if ( !phy.getName().equals( "" ) ) {
7401 if ( !phy.isRooted() ) {
7405 if ( !p.hasNext() ) {
7409 if ( phy == null ) {
7412 if ( phy.getNumberOfExternalNodes() != 5 ) {
7413 System.out.println( phy.getNumberOfExternalNodes() );
7416 if ( !phy.getName().equals( "" ) ) {
7419 if ( !phy.isRooted() ) {
7423 if ( !p.hasNext() ) {
7427 if ( phy == null ) {
7430 if ( phy.getNumberOfExternalNodes() != 3 ) {
7433 if ( !phy.getName().equals( "" ) ) {
7436 if ( phy.isRooted() ) {
7440 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7441 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7443 if ( !p2.hasNext() ) {
7447 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7450 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7454 if ( !p2.hasNext() ) {
7459 if ( !p2.hasNext() ) {
7464 if ( !p2.hasNext() ) {
7469 if ( !p2.hasNext() ) {
7474 if ( !p2.hasNext() ) {
7479 if ( !p2.hasNext() ) {
7484 if ( !p2.hasNext() ) {
7489 if ( !p2.hasNext() ) {
7493 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7496 if ( p2.hasNext() ) {
7500 if ( phy != null ) {
7505 if ( !p2.hasNext() ) {
7509 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7512 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7516 catch ( final Exception e ) {
7517 e.printStackTrace( System.out );
7523 private static boolean testNexusTreeParsingTranslating() {
7525 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7526 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7527 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7528 if ( phylogenies.length != 1 ) {
7531 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7534 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7537 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7540 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7543 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7544 .equals( "Aranaeus" ) ) {
7548 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7549 if ( phylogenies.length != 3 ) {
7552 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7555 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7558 if ( phylogenies[ 0 ].isRooted() ) {
7561 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7564 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7567 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7568 .equals( "Aranaeus" ) ) {
7571 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7574 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7577 if ( phylogenies[ 1 ].isRooted() ) {
7580 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7583 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7586 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7587 .equals( "Aranaeus" ) ) {
7590 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7593 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7596 if ( !phylogenies[ 2 ].isRooted() ) {
7599 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7602 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7605 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7606 .equals( "Aranaeus" ) ) {
7610 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7611 if ( phylogenies.length != 3 ) {
7614 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7617 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7620 if ( phylogenies[ 0 ].isRooted() ) {
7623 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7626 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7629 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7630 .equals( "Aranaeus" ) ) {
7633 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7636 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7639 if ( phylogenies[ 1 ].isRooted() ) {
7642 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7645 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7648 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7649 .equals( "Aranaeus" ) ) {
7652 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7655 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7658 if ( !phylogenies[ 2 ].isRooted() ) {
7661 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7664 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7667 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7668 .equals( "Aranaeus" ) ) {
7671 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
7672 if ( phylogenies.length != 3 ) {
7675 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
7680 catch ( final Exception e ) {
7681 e.printStackTrace( System.out );
7687 private static boolean testNHParsing() {
7689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7690 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
7691 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
7694 final NHXParser nhxp = new NHXParser();
7695 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
7696 nhxp.setReplaceUnderscores( true );
7697 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
7698 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
7701 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
7704 final Phylogeny p1b = factory
7705 .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 ",
7706 new NHXParser() )[ 0 ];
7707 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
7710 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
7713 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
7714 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
7715 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
7716 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
7717 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
7718 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
7719 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
7720 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
7721 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
7722 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
7723 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
7724 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
7725 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
7727 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
7730 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
7733 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
7736 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
7739 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
7740 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
7741 final String p16_S = "((A,B),C)";
7742 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
7743 if ( p16.length != 1 ) {
7746 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
7749 final String p17_S = "(C,(A,B))";
7750 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
7751 if ( p17.length != 1 ) {
7754 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
7757 final String p18_S = "((A,B),(C,D))";
7758 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
7759 if ( p18.length != 1 ) {
7762 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
7765 final String p19_S = "(((A,B),C),D)";
7766 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
7767 if ( p19.length != 1 ) {
7770 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
7773 final String p20_S = "(A,(B,(C,D)))";
7774 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
7775 if ( p20.length != 1 ) {
7778 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
7781 final String p21_S = "(A,(B,(C,(D,E))))";
7782 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
7783 if ( p21.length != 1 ) {
7786 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
7789 final String p22_S = "((((A,B),C),D),E)";
7790 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
7791 if ( p22.length != 1 ) {
7794 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
7797 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7798 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
7799 if ( p23.length != 1 ) {
7800 System.out.println( "xl=" + p23.length );
7804 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
7807 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7808 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
7809 if ( p24.length != 1 ) {
7812 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
7815 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7816 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7817 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
7818 if ( p241.length != 2 ) {
7821 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
7824 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
7827 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
7828 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
7829 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
7830 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
7831 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
7832 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
7833 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
7834 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
7835 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
7836 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
7839 final String p26_S = "(A,B)ab";
7840 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
7841 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
7844 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7845 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
7846 if ( p27s.length != 1 ) {
7847 System.out.println( "xxl=" + p27s.length );
7851 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7852 System.out.println( p27s[ 0 ].toNewHampshireX() );
7856 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
7858 if ( p27.length != 1 ) {
7859 System.out.println( "yl=" + p27.length );
7863 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
7864 System.out.println( p27[ 0 ].toNewHampshireX() );
7868 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7869 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7870 final String p28_S3 = "(A,B)ab";
7871 final String p28_S4 = "((((A,B),C),D),;E;)";
7872 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
7874 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
7877 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
7880 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
7883 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7886 if ( p28.length != 4 ) {
7889 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";
7890 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7891 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7894 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";
7895 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7896 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7899 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7900 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7901 if ( ( p32.length != 0 ) ) {
7904 final String p33_S = "A";
7905 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7906 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7909 final String p34_S = "B;";
7910 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7911 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7914 final String p35_S = "B:0.2";
7915 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7916 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7919 final String p36_S = "(A)";
7920 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7921 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7924 final String p37_S = "((A))";
7925 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7926 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7929 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7930 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7931 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7934 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7935 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7936 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7939 final String p40_S = "(A,B,C)";
7940 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7941 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7944 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7945 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7946 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7949 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7950 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7951 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7954 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)";
7955 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7956 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7959 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)))";
7960 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7961 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7964 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7965 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7966 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7969 final String p46_S = "";
7970 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7971 if ( p46.length != 0 ) {
7974 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7975 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7978 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7979 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7982 final Phylogeny p49 = factory
7983 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7984 new NHXParser() )[ 0 ];
7985 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7988 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7989 if ( p50.getNode( "A" ) == null ) {
7992 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7993 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7996 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7999 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8000 .equals( "((A,B)88:2.0,C);" ) ) {
8003 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8004 if ( p51.getNode( "A(A" ) == null ) {
8007 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8008 if ( p52.getNode( "A(A" ) == null ) {
8011 final Phylogeny p53 = factory
8012 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8013 new NHXParser() )[ 0 ];
8014 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8018 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8019 if ( p54.getNode( "A" ) == null ) {
8022 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8023 .equals( "((A,B)[88],C);" ) ) {
8027 catch ( final Exception e ) {
8028 e.printStackTrace( System.out );
8034 private static boolean testNHParsingIter() {
8036 final String p0_str = "(A,B);";
8037 final NHXParser p = new NHXParser();
8038 p.setSource( p0_str );
8039 if ( !p.hasNext() ) {
8042 final Phylogeny p0 = p.next();
8043 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8044 System.out.println( p0.toNewHampshire() );
8047 if ( p.hasNext() ) {
8050 if ( p.next() != null ) {
8054 final String p00_str = "(A,B)root;";
8055 p.setSource( p00_str );
8056 final Phylogeny p00 = p.next();
8057 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8058 System.out.println( p00.toNewHampshire() );
8062 final String p000_str = "A;";
8063 p.setSource( p000_str );
8064 final Phylogeny p000 = p.next();
8065 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8066 System.out.println( p000.toNewHampshire() );
8070 final String p0000_str = "A";
8071 p.setSource( p0000_str );
8072 final Phylogeny p0000 = p.next();
8073 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8074 System.out.println( p0000.toNewHampshire() );
8078 p.setSource( "(A)" );
8079 final Phylogeny p00000 = p.next();
8080 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8081 System.out.println( p00000.toNewHampshire() );
8085 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8086 p.setSource( p1_str );
8087 if ( !p.hasNext() ) {
8090 final Phylogeny p1_0 = p.next();
8091 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8092 System.out.println( p1_0.toNewHampshire() );
8095 if ( !p.hasNext() ) {
8098 final Phylogeny p1_1 = p.next();
8099 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8100 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8103 if ( !p.hasNext() ) {
8106 final Phylogeny p1_2 = p.next();
8107 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8108 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8111 if ( !p.hasNext() ) {
8114 final Phylogeny p1_3 = p.next();
8115 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8116 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8119 if ( p.hasNext() ) {
8122 if ( p.next() != null ) {
8126 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8127 p.setSource( p2_str );
8128 if ( !p.hasNext() ) {
8131 Phylogeny p2_0 = p.next();
8132 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8133 System.out.println( p2_0.toNewHampshire() );
8136 if ( !p.hasNext() ) {
8139 Phylogeny p2_1 = p.next();
8140 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8141 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8144 if ( !p.hasNext() ) {
8147 Phylogeny p2_2 = p.next();
8148 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8149 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8152 if ( !p.hasNext() ) {
8155 Phylogeny p2_3 = p.next();
8156 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8157 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8160 if ( !p.hasNext() ) {
8163 Phylogeny p2_4 = p.next();
8164 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8165 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8168 if ( p.hasNext() ) {
8171 if ( p.next() != null ) {
8176 if ( !p.hasNext() ) {
8180 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8181 System.out.println( p2_0.toNewHampshire() );
8184 if ( !p.hasNext() ) {
8188 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8189 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8192 if ( !p.hasNext() ) {
8196 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8197 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8200 if ( !p.hasNext() ) {
8204 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8205 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8208 if ( !p.hasNext() ) {
8212 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8213 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8216 if ( p.hasNext() ) {
8219 if ( p.next() != null ) {
8223 final String p3_str = "((A,B),C)abc";
8224 p.setSource( p3_str );
8225 if ( !p.hasNext() ) {
8228 final Phylogeny p3_0 = p.next();
8229 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8232 if ( p.hasNext() ) {
8235 if ( p.next() != null ) {
8239 final String p4_str = "((A,B)ab,C)abc";
8240 p.setSource( p4_str );
8241 if ( !p.hasNext() ) {
8244 final Phylogeny p4_0 = p.next();
8245 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8248 if ( p.hasNext() ) {
8251 if ( p.next() != null ) {
8255 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8256 p.setSource( p5_str );
8257 if ( !p.hasNext() ) {
8260 final Phylogeny p5_0 = p.next();
8261 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8264 if ( p.hasNext() ) {
8267 if ( p.next() != null ) {
8271 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8272 p.setSource( p6_str );
8273 if ( !p.hasNext() ) {
8276 Phylogeny p6_0 = p.next();
8277 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8280 if ( p.hasNext() ) {
8283 if ( p.next() != null ) {
8287 if ( !p.hasNext() ) {
8291 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8294 if ( p.hasNext() ) {
8297 if ( p.next() != null ) {
8301 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8302 p.setSource( p7_str );
8303 if ( !p.hasNext() ) {
8306 Phylogeny p7_0 = p.next();
8307 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8310 if ( p.hasNext() ) {
8313 if ( p.next() != null ) {
8317 if ( !p.hasNext() ) {
8321 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8324 if ( p.hasNext() ) {
8327 if ( p.next() != null ) {
8331 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8332 p.setSource( p8_str );
8333 if ( !p.hasNext() ) {
8336 Phylogeny p8_0 = p.next();
8337 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8340 if ( !p.hasNext() ) {
8343 if ( !p.hasNext() ) {
8346 Phylogeny p8_1 = p.next();
8347 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8350 if ( p.hasNext() ) {
8353 if ( p.next() != null ) {
8357 if ( !p.hasNext() ) {
8361 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8364 if ( !p.hasNext() ) {
8368 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8371 if ( p.hasNext() ) {
8374 if ( p.next() != null ) {
8380 if ( p.hasNext() ) {
8384 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8385 if ( !p.hasNext() ) {
8388 Phylogeny p_27 = p.next();
8389 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8390 System.out.println( p_27.toNewHampshireX() );
8394 if ( p.hasNext() ) {
8397 if ( p.next() != null ) {
8401 if ( !p.hasNext() ) {
8405 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8406 System.out.println( p_27.toNewHampshireX() );
8410 if ( p.hasNext() ) {
8413 if ( p.next() != null ) {
8417 final String p30_str = "(A,B);(C,D)";
8418 final NHXParser p30 = new NHXParser();
8419 p30.setSource( p30_str );
8420 if ( !p30.hasNext() ) {
8423 Phylogeny phy30 = p30.next();
8424 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8425 System.out.println( phy30.toNewHampshire() );
8428 if ( !p30.hasNext() ) {
8431 Phylogeny phy301 = p30.next();
8432 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8433 System.out.println( phy301.toNewHampshire() );
8436 if ( p30.hasNext() ) {
8439 if ( p30.hasNext() ) {
8442 if ( p30.next() != null ) {
8445 if ( p30.next() != null ) {
8449 if ( !p30.hasNext() ) {
8453 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8454 System.out.println( phy30.toNewHampshire() );
8457 if ( !p30.hasNext() ) {
8460 phy301 = p30.next();
8461 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8462 System.out.println( phy301.toNewHampshire() );
8465 if ( p30.hasNext() ) {
8468 if ( p30.hasNext() ) {
8471 if ( p30.next() != null ) {
8474 if ( p30.next() != null ) {
8478 catch ( final Exception e ) {
8479 e.printStackTrace( System.out );
8485 private static boolean testNHXconversion() {
8487 final PhylogenyNode n1 = new PhylogenyNode();
8488 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8489 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8490 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8491 final PhylogenyNode n5 = PhylogenyNode
8492 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8493 final PhylogenyNode n6 = PhylogenyNode
8494 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8495 if ( !n1.toNewHampshireX().equals( "" ) ) {
8498 if ( !n2.toNewHampshireX().equals( "" ) ) {
8501 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8504 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8507 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8510 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8511 System.out.println( n6.toNewHampshireX() );
8515 catch ( final Exception e ) {
8516 e.printStackTrace( System.out );
8522 private static boolean testNHXNodeParsing() {
8524 final PhylogenyNode n1 = new PhylogenyNode();
8525 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8526 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8527 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8528 final PhylogenyNode n5 = PhylogenyNode
8529 .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]" );
8530 if ( !n3.getName().equals( "n3" ) ) {
8533 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8536 if ( n3.isDuplication() ) {
8539 if ( n3.isHasAssignedEvent() ) {
8542 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8545 if ( !n4.getName().equals( "n4" ) ) {
8548 if ( n4.getDistanceToParent() != 0.01 ) {
8551 if ( !n5.getName().equals( "n5" ) ) {
8554 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8557 if ( n5.getDistanceToParent() != 0.1 ) {
8560 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8563 if ( !n5.isDuplication() ) {
8566 if ( !n5.isHasAssignedEvent() ) {
8569 final PhylogenyNode n8 = PhylogenyNode
8570 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8571 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8572 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8575 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8578 final PhylogenyNode n9 = PhylogenyNode
8579 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8580 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8581 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8584 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
8587 final PhylogenyNode n10 = PhylogenyNode
8588 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8589 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
8592 final PhylogenyNode n20 = PhylogenyNode
8593 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8594 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8597 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
8600 final PhylogenyNode n20x = PhylogenyNode
8601 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8602 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
8605 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
8608 final PhylogenyNode n20xx = PhylogenyNode
8609 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8610 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
8613 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
8616 final PhylogenyNode n20xxx = PhylogenyNode
8617 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8618 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
8621 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
8624 final PhylogenyNode n20xxxx = PhylogenyNode
8625 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8626 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
8629 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
8632 final PhylogenyNode n21 = PhylogenyNode
8633 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8634 if ( !n21.getName().equals( "N21_PIG" ) ) {
8637 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
8640 final PhylogenyNode n21x = PhylogenyNode
8641 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8642 if ( !n21x.getName().equals( "n21_PIG" ) ) {
8645 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
8648 final PhylogenyNode n22 = PhylogenyNode
8649 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8650 if ( !n22.getName().equals( "n22/PIG" ) ) {
8653 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
8656 final PhylogenyNode n23 = PhylogenyNode
8657 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8658 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
8661 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
8664 final PhylogenyNode a = PhylogenyNode
8665 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8666 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8669 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
8672 final PhylogenyNode c1 = PhylogenyNode
8673 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
8674 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8675 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
8678 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
8681 final PhylogenyNode c2 = PhylogenyNode
8682 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
8683 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8684 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
8687 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
8690 final PhylogenyNode e3 = PhylogenyNode
8691 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8692 if ( !e3.getName().equals( "n10_RAT~" ) ) {
8695 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
8698 final PhylogenyNode n11 = PhylogenyNode
8699 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
8700 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8701 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
8704 if ( n11.getDistanceToParent() != 0.4 ) {
8707 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
8710 final PhylogenyNode n12 = PhylogenyNode
8711 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
8712 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8713 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
8716 if ( n12.getDistanceToParent() != 0.4 ) {
8719 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
8722 final PhylogenyNode o = PhylogenyNode
8723 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8724 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
8727 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
8730 if ( n1.getName().compareTo( "" ) != 0 ) {
8733 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8736 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8739 if ( n2.getName().compareTo( "" ) != 0 ) {
8742 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
8745 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8748 final PhylogenyNode n00 = PhylogenyNode
8749 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
8750 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
8753 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
8756 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
8757 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
8760 final PhylogenyNode n13 = PhylogenyNode
8761 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8762 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
8765 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
8768 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8771 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8774 final PhylogenyNode n14 = PhylogenyNode
8775 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8776 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
8779 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
8782 final PhylogenyNode n15 = PhylogenyNode
8783 .createInstanceFromNhxString( "something_wicked[123]",
8784 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8785 if ( !n15.getName().equals( "something_wicked" ) ) {
8788 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
8791 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
8794 final PhylogenyNode n16 = PhylogenyNode
8795 .createInstanceFromNhxString( "something_wicked2[9]",
8796 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8797 if ( !n16.getName().equals( "something_wicked2" ) ) {
8800 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
8803 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
8806 final PhylogenyNode n17 = PhylogenyNode
8807 .createInstanceFromNhxString( "something_wicked3[a]",
8808 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8809 if ( !n17.getName().equals( "something_wicked3" ) ) {
8812 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
8815 final PhylogenyNode n18 = PhylogenyNode
8816 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8817 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
8820 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
8823 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
8826 final PhylogenyNode n19 = PhylogenyNode
8827 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8828 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
8831 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8834 final PhylogenyNode n30 = PhylogenyNode
8835 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
8836 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8837 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
8840 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
8843 final PhylogenyNode n31 = PhylogenyNode
8844 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
8845 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8846 if ( n31.getNodeData().isHasTaxonomy() ) {
8849 final PhylogenyNode n32 = PhylogenyNode
8850 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8851 if ( n32.getNodeData().isHasTaxonomy() ) {
8854 final PhylogenyNode n40 = PhylogenyNode
8855 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8856 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
8859 final PhylogenyNode n41 = PhylogenyNode
8860 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8861 if ( n41.getNodeData().isHasTaxonomy() ) {
8864 final PhylogenyNode n42 = PhylogenyNode
8865 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8866 if ( n42.getNodeData().isHasTaxonomy() ) {
8869 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
8870 NHXParser.TAXONOMY_EXTRACTION.NO );
8871 if ( n43.getNodeData().isHasTaxonomy() ) {
8874 final PhylogenyNode n44 = PhylogenyNode
8875 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
8876 if ( n44.getNodeData().isHasTaxonomy() ) {
8880 catch ( final Exception e ) {
8881 e.printStackTrace( System.out );
8887 private static boolean testNHXParsing() {
8889 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8890 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
8891 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
8894 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]";
8895 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
8896 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8899 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]";
8900 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
8901 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
8904 final Phylogeny[] p3 = factory
8905 .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]",
8907 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8910 final Phylogeny[] p4 = factory
8911 .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(]",
8913 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8916 final Phylogeny[] p5 = factory
8917 .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(((]",
8919 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
8922 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)";
8923 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)";
8924 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
8925 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
8928 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)))";
8929 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)))";
8930 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
8931 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
8934 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]) ))[,,, ])))))))";
8935 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
8936 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
8937 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
8940 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
8941 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8944 final Phylogeny p10 = factory
8945 .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]",
8946 new NHXParser() )[ 0 ];
8947 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8951 catch ( final Exception e ) {
8952 e.printStackTrace( System.out );
8958 private static boolean testNHXParsingMB() {
8960 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8961 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8962 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8963 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8964 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8965 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8966 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8967 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8968 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8969 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8970 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8973 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8976 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8977 0.1100000000000000e+00 ) ) {
8980 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8983 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8986 final Phylogeny p2 = factory
8987 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8988 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8989 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8990 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8991 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8992 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8993 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8994 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8995 + "7.369400000000000e-02}])",
8996 new NHXParser() )[ 0 ];
8997 if ( p2.getNode( "1" ) == null ) {
9000 if ( p2.getNode( "2" ) == null ) {
9004 catch ( final Exception e ) {
9005 e.printStackTrace( System.out );
9012 private static boolean testNHXParsingQuotes() {
9014 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9015 final NHXParser p = new NHXParser();
9016 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9017 if ( phylogenies_0.length != 5 ) {
9020 final Phylogeny phy = phylogenies_0[ 4 ];
9021 if ( phy.getNumberOfExternalNodes() != 7 ) {
9024 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9027 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9030 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9031 .getScientificName().equals( "hsapiens" ) ) {
9034 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9037 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9040 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
9043 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9046 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9049 final NHXParser p1p = new NHXParser();
9050 p1p.setIgnoreQuotes( true );
9051 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9052 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9055 final NHXParser p2p = new NHXParser();
9056 p1p.setIgnoreQuotes( false );
9057 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9058 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9061 final NHXParser p3p = new NHXParser();
9062 p3p.setIgnoreQuotes( false );
9063 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9064 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9067 final NHXParser p4p = new NHXParser();
9068 p4p.setIgnoreQuotes( false );
9069 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9070 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9073 final Phylogeny p10 = factory
9074 .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]",
9075 new NHXParser() )[ 0 ];
9076 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]";
9077 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9080 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9081 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9085 final Phylogeny p12 = factory
9086 .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]",
9087 new NHXParser() )[ 0 ];
9088 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]";
9089 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9092 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9093 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9096 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;";
9097 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9100 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9101 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9105 catch ( final Exception e ) {
9106 e.printStackTrace( System.out );
9112 private static boolean testNodeRemoval() {
9114 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9115 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9116 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9117 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9120 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9121 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9122 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9125 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9126 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9127 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9131 catch ( final Exception e ) {
9132 e.printStackTrace( System.out );
9138 private static boolean testPhylogenyBranch() {
9140 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9141 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9142 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9143 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9144 if ( !a1b1.equals( a1b1 ) ) {
9147 if ( !a1b1.equals( b1a1 ) ) {
9150 if ( !b1a1.equals( a1b1 ) ) {
9153 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9154 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9155 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9156 if ( a1_b1.equals( b1_a1 ) ) {
9159 if ( a1_b1.equals( a1_b1_ ) ) {
9162 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9163 if ( !a1_b1.equals( b1_a1_ ) ) {
9166 if ( a1_b1_.equals( b1_a1_ ) ) {
9169 if ( !a1_b1_.equals( b1_a1 ) ) {
9173 catch ( final Exception e ) {
9174 e.printStackTrace( System.out );
9180 private static boolean testPhyloXMLparsingOfDistributionElement() {
9182 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9183 PhyloXmlParser xml_parser = null;
9185 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9187 catch ( final Exception e ) {
9188 // Do nothing -- means were not running from jar.
9190 if ( xml_parser == null ) {
9191 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9192 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9193 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9196 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9199 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9201 if ( xml_parser.getErrorCount() > 0 ) {
9202 System.out.println( xml_parser.getErrorMessages().toString() );
9205 if ( phylogenies_0.length != 1 ) {
9208 final Phylogeny t1 = phylogenies_0[ 0 ];
9209 PhylogenyNode n = null;
9210 Distribution d = null;
9211 n = t1.getNode( "root node" );
9212 if ( !n.getNodeData().isHasDistribution() ) {
9215 if ( n.getNodeData().getDistributions().size() != 1 ) {
9218 d = n.getNodeData().getDistribution();
9219 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9222 if ( d.getPoints().size() != 1 ) {
9225 if ( d.getPolygons() != null ) {
9228 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9231 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9234 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9237 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9240 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9243 n = t1.getNode( "node a" );
9244 if ( !n.getNodeData().isHasDistribution() ) {
9247 if ( n.getNodeData().getDistributions().size() != 2 ) {
9250 d = n.getNodeData().getDistribution( 1 );
9251 if ( !d.getDesc().equals( "San Diego" ) ) {
9254 if ( d.getPoints().size() != 1 ) {
9257 if ( d.getPolygons() != null ) {
9260 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9263 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9266 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9269 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9272 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9275 n = t1.getNode( "node bb" );
9276 if ( !n.getNodeData().isHasDistribution() ) {
9279 if ( n.getNodeData().getDistributions().size() != 1 ) {
9282 d = n.getNodeData().getDistribution( 0 );
9283 if ( d.getPoints().size() != 3 ) {
9286 if ( d.getPolygons().size() != 2 ) {
9289 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9292 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9295 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9298 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9301 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9304 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9307 Polygon p = d.getPolygons().get( 0 );
9308 if ( p.getPoints().size() != 3 ) {
9311 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9314 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9317 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9320 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9323 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9326 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9329 p = d.getPolygons().get( 1 );
9330 if ( p.getPoints().size() != 3 ) {
9333 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9336 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9339 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9343 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9344 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9345 if ( rt.length != 1 ) {
9348 final Phylogeny t1_rt = rt[ 0 ];
9349 n = t1_rt.getNode( "root node" );
9350 if ( !n.getNodeData().isHasDistribution() ) {
9353 if ( n.getNodeData().getDistributions().size() != 1 ) {
9356 d = n.getNodeData().getDistribution();
9357 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9360 if ( d.getPoints().size() != 1 ) {
9363 if ( d.getPolygons() != null ) {
9366 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9369 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9372 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9375 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9378 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9381 n = t1_rt.getNode( "node a" );
9382 if ( !n.getNodeData().isHasDistribution() ) {
9385 if ( n.getNodeData().getDistributions().size() != 2 ) {
9388 d = n.getNodeData().getDistribution( 1 );
9389 if ( !d.getDesc().equals( "San Diego" ) ) {
9392 if ( d.getPoints().size() != 1 ) {
9395 if ( d.getPolygons() != null ) {
9398 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9401 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9404 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9407 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9410 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9413 n = t1_rt.getNode( "node bb" );
9414 if ( !n.getNodeData().isHasDistribution() ) {
9417 if ( n.getNodeData().getDistributions().size() != 1 ) {
9420 d = n.getNodeData().getDistribution( 0 );
9421 if ( d.getPoints().size() != 3 ) {
9424 if ( d.getPolygons().size() != 2 ) {
9427 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9430 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9433 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9436 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9439 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9442 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9445 p = d.getPolygons().get( 0 );
9446 if ( p.getPoints().size() != 3 ) {
9449 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9452 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9455 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9458 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9461 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9464 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9467 p = d.getPolygons().get( 1 );
9468 if ( p.getPoints().size() != 3 ) {
9471 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9474 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9477 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9481 catch ( final Exception e ) {
9482 e.printStackTrace( System.out );
9488 private static boolean testPostOrderIterator() {
9490 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9491 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9492 PhylogenyNodeIterator it0;
9493 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9496 for( it0.reset(); it0.hasNext(); ) {
9499 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9500 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9501 if ( !it.next().getName().equals( "A" ) ) {
9504 if ( !it.next().getName().equals( "B" ) ) {
9507 if ( !it.next().getName().equals( "ab" ) ) {
9510 if ( !it.next().getName().equals( "C" ) ) {
9513 if ( !it.next().getName().equals( "D" ) ) {
9516 if ( !it.next().getName().equals( "cd" ) ) {
9519 if ( !it.next().getName().equals( "abcd" ) ) {
9522 if ( !it.next().getName().equals( "E" ) ) {
9525 if ( !it.next().getName().equals( "F" ) ) {
9528 if ( !it.next().getName().equals( "ef" ) ) {
9531 if ( !it.next().getName().equals( "G" ) ) {
9534 if ( !it.next().getName().equals( "H" ) ) {
9537 if ( !it.next().getName().equals( "gh" ) ) {
9540 if ( !it.next().getName().equals( "efgh" ) ) {
9543 if ( !it.next().getName().equals( "r" ) ) {
9546 if ( it.hasNext() ) {
9550 catch ( final Exception e ) {
9551 e.printStackTrace( System.out );
9557 private static boolean testPreOrderIterator() {
9559 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9560 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9561 PhylogenyNodeIterator it0;
9562 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9565 for( it0.reset(); it0.hasNext(); ) {
9568 PhylogenyNodeIterator it = t0.iteratorPreorder();
9569 if ( !it.next().getName().equals( "r" ) ) {
9572 if ( !it.next().getName().equals( "ab" ) ) {
9575 if ( !it.next().getName().equals( "A" ) ) {
9578 if ( !it.next().getName().equals( "B" ) ) {
9581 if ( !it.next().getName().equals( "cd" ) ) {
9584 if ( !it.next().getName().equals( "C" ) ) {
9587 if ( !it.next().getName().equals( "D" ) ) {
9590 if ( it.hasNext() ) {
9593 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9594 it = t1.iteratorPreorder();
9595 if ( !it.next().getName().equals( "r" ) ) {
9598 if ( !it.next().getName().equals( "abcd" ) ) {
9601 if ( !it.next().getName().equals( "ab" ) ) {
9604 if ( !it.next().getName().equals( "A" ) ) {
9607 if ( !it.next().getName().equals( "B" ) ) {
9610 if ( !it.next().getName().equals( "cd" ) ) {
9613 if ( !it.next().getName().equals( "C" ) ) {
9616 if ( !it.next().getName().equals( "D" ) ) {
9619 if ( !it.next().getName().equals( "efgh" ) ) {
9622 if ( !it.next().getName().equals( "ef" ) ) {
9625 if ( !it.next().getName().equals( "E" ) ) {
9628 if ( !it.next().getName().equals( "F" ) ) {
9631 if ( !it.next().getName().equals( "gh" ) ) {
9634 if ( !it.next().getName().equals( "G" ) ) {
9637 if ( !it.next().getName().equals( "H" ) ) {
9640 if ( it.hasNext() ) {
9644 catch ( final Exception e ) {
9645 e.printStackTrace( System.out );
9651 private static boolean testPropertiesMap() {
9653 final PropertiesMap pm = new PropertiesMap();
9654 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9655 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
9656 final Property p2 = new Property( "something:else",
9658 "improbable:research",
9661 pm.addProperty( p0 );
9662 pm.addProperty( p1 );
9663 pm.addProperty( p2 );
9664 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
9667 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
9670 if ( pm.getProperties().size() != 3 ) {
9673 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
9676 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9679 if ( pm.getProperties().size() != 3 ) {
9682 pm.removeProperty( "dimensions:diameter" );
9683 if ( pm.getProperties().size() != 2 ) {
9686 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
9689 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
9693 catch ( final Exception e ) {
9694 e.printStackTrace( System.out );
9700 private static boolean testProteinId() {
9702 final ProteinId id1 = new ProteinId( "a" );
9703 final ProteinId id2 = new ProteinId( "a" );
9704 final ProteinId id3 = new ProteinId( "A" );
9705 final ProteinId id4 = new ProteinId( "b" );
9706 if ( !id1.equals( id1 ) ) {
9709 if ( id1.getId().equals( "x" ) ) {
9712 if ( id1.getId().equals( null ) ) {
9715 if ( !id1.equals( id2 ) ) {
9718 if ( id1.equals( id3 ) ) {
9721 if ( id1.hashCode() != id1.hashCode() ) {
9724 if ( id1.hashCode() != id2.hashCode() ) {
9727 if ( id1.hashCode() == id3.hashCode() ) {
9730 if ( id1.compareTo( id1 ) != 0 ) {
9733 if ( id1.compareTo( id2 ) != 0 ) {
9736 if ( id1.compareTo( id3 ) != 0 ) {
9739 if ( id1.compareTo( id4 ) >= 0 ) {
9742 if ( id4.compareTo( id1 ) <= 0 ) {
9745 if ( !id4.getId().equals( "b" ) ) {
9748 final ProteinId id5 = new ProteinId( " C " );
9749 if ( !id5.getId().equals( "C" ) ) {
9752 if ( id5.equals( id1 ) ) {
9756 catch ( final Exception e ) {
9757 e.printStackTrace( System.out );
9763 private static boolean testReIdMethods() {
9765 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9766 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
9767 final long count = PhylogenyNode.getNodeCount();
9769 if ( p.getNode( "r" ).getId() != count ) {
9772 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
9775 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
9778 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
9781 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
9784 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
9787 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
9790 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
9793 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
9796 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
9799 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
9802 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
9805 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
9808 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
9811 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
9815 catch ( final Exception e ) {
9816 e.printStackTrace( System.out );
9822 private static boolean testRerooting() {
9824 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9825 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",
9826 new NHXParser() )[ 0 ];
9827 if ( !t1.isRooted() ) {
9830 t1.reRoot( t1.getNode( "D" ) );
9831 t1.reRoot( t1.getNode( "CD" ) );
9832 t1.reRoot( t1.getNode( "A" ) );
9833 t1.reRoot( t1.getNode( "B" ) );
9834 t1.reRoot( t1.getNode( "AB" ) );
9835 t1.reRoot( t1.getNode( "D" ) );
9836 t1.reRoot( t1.getNode( "C" ) );
9837 t1.reRoot( t1.getNode( "CD" ) );
9838 t1.reRoot( t1.getNode( "A" ) );
9839 t1.reRoot( t1.getNode( "B" ) );
9840 t1.reRoot( t1.getNode( "AB" ) );
9841 t1.reRoot( t1.getNode( "D" ) );
9842 t1.reRoot( t1.getNode( "D" ) );
9843 t1.reRoot( t1.getNode( "C" ) );
9844 t1.reRoot( t1.getNode( "A" ) );
9845 t1.reRoot( t1.getNode( "B" ) );
9846 t1.reRoot( t1.getNode( "AB" ) );
9847 t1.reRoot( t1.getNode( "C" ) );
9848 t1.reRoot( t1.getNode( "D" ) );
9849 t1.reRoot( t1.getNode( "CD" ) );
9850 t1.reRoot( t1.getNode( "D" ) );
9851 t1.reRoot( t1.getNode( "A" ) );
9852 t1.reRoot( t1.getNode( "B" ) );
9853 t1.reRoot( t1.getNode( "AB" ) );
9854 t1.reRoot( t1.getNode( "C" ) );
9855 t1.reRoot( t1.getNode( "D" ) );
9856 t1.reRoot( t1.getNode( "CD" ) );
9857 t1.reRoot( t1.getNode( "D" ) );
9858 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
9861 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
9864 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
9867 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
9870 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
9873 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
9876 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",
9877 new NHXParser() )[ 0 ];
9878 t2.reRoot( t2.getNode( "A" ) );
9879 t2.reRoot( t2.getNode( "D" ) );
9880 t2.reRoot( t2.getNode( "ABC" ) );
9881 t2.reRoot( t2.getNode( "A" ) );
9882 t2.reRoot( t2.getNode( "B" ) );
9883 t2.reRoot( t2.getNode( "D" ) );
9884 t2.reRoot( t2.getNode( "C" ) );
9885 t2.reRoot( t2.getNode( "ABC" ) );
9886 t2.reRoot( t2.getNode( "A" ) );
9887 t2.reRoot( t2.getNode( "B" ) );
9888 t2.reRoot( t2.getNode( "AB" ) );
9889 t2.reRoot( t2.getNode( "AB" ) );
9890 t2.reRoot( t2.getNode( "D" ) );
9891 t2.reRoot( t2.getNode( "C" ) );
9892 t2.reRoot( t2.getNode( "B" ) );
9893 t2.reRoot( t2.getNode( "AB" ) );
9894 t2.reRoot( t2.getNode( "D" ) );
9895 t2.reRoot( t2.getNode( "D" ) );
9896 t2.reRoot( t2.getNode( "ABC" ) );
9897 t2.reRoot( t2.getNode( "A" ) );
9898 t2.reRoot( t2.getNode( "B" ) );
9899 t2.reRoot( t2.getNode( "AB" ) );
9900 t2.reRoot( t2.getNode( "D" ) );
9901 t2.reRoot( t2.getNode( "C" ) );
9902 t2.reRoot( t2.getNode( "ABC" ) );
9903 t2.reRoot( t2.getNode( "A" ) );
9904 t2.reRoot( t2.getNode( "B" ) );
9905 t2.reRoot( t2.getNode( "AB" ) );
9906 t2.reRoot( t2.getNode( "D" ) );
9907 t2.reRoot( t2.getNode( "D" ) );
9908 t2.reRoot( t2.getNode( "C" ) );
9909 t2.reRoot( t2.getNode( "A" ) );
9910 t2.reRoot( t2.getNode( "B" ) );
9911 t2.reRoot( t2.getNode( "AB" ) );
9912 t2.reRoot( t2.getNode( "C" ) );
9913 t2.reRoot( t2.getNode( "D" ) );
9914 t2.reRoot( t2.getNode( "ABC" ) );
9915 t2.reRoot( t2.getNode( "D" ) );
9916 t2.reRoot( t2.getNode( "A" ) );
9917 t2.reRoot( t2.getNode( "B" ) );
9918 t2.reRoot( t2.getNode( "AB" ) );
9919 t2.reRoot( t2.getNode( "C" ) );
9920 t2.reRoot( t2.getNode( "D" ) );
9921 t2.reRoot( t2.getNode( "ABC" ) );
9922 t2.reRoot( t2.getNode( "D" ) );
9923 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9926 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9929 t2.reRoot( t2.getNode( "ABC" ) );
9930 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9933 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9936 t2.reRoot( t2.getNode( "AB" ) );
9937 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9940 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9943 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9946 t2.reRoot( t2.getNode( "AB" ) );
9947 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9950 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9953 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9956 t2.reRoot( t2.getNode( "D" ) );
9957 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9960 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9963 t2.reRoot( t2.getNode( "ABC" ) );
9964 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9967 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9970 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9971 new NHXParser() )[ 0 ];
9972 t3.reRoot( t3.getNode( "B" ) );
9973 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9976 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9979 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9982 t3.reRoot( t3.getNode( "B" ) );
9983 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9986 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9989 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9992 t3.reRoot( t3.getRoot() );
9993 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9996 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9999 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10003 catch ( final Exception e ) {
10004 e.printStackTrace( System.out );
10010 private static boolean testSDIse() {
10012 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10013 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10014 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10015 gene1.setRooted( true );
10016 species1.setRooted( true );
10017 final SDI sdi = new SDI( gene1, species1 );
10018 if ( !gene1.getRoot().isDuplication() ) {
10021 final Phylogeny species2 = factory
10022 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10023 new NHXParser() )[ 0 ];
10024 final Phylogeny gene2 = factory
10025 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10026 new NHXParser() )[ 0 ];
10027 species2.setRooted( true );
10028 gene2.setRooted( true );
10029 final SDI sdi2 = new SDI( gene2, species2 );
10030 if ( sdi2.getDuplicationsSum() != 0 ) {
10033 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10036 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10039 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10042 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10045 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10048 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10051 final Phylogeny species3 = factory
10052 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10053 new NHXParser() )[ 0 ];
10054 final Phylogeny gene3 = factory
10055 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10056 new NHXParser() )[ 0 ];
10057 species3.setRooted( true );
10058 gene3.setRooted( true );
10059 final SDI sdi3 = new SDI( gene3, species3 );
10060 if ( sdi3.getDuplicationsSum() != 1 ) {
10063 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10066 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10069 final Phylogeny species4 = factory
10070 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10071 new NHXParser() )[ 0 ];
10072 final Phylogeny gene4 = factory
10073 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10074 new NHXParser() )[ 0 ];
10075 species4.setRooted( true );
10076 gene4.setRooted( true );
10077 final SDI sdi4 = new SDI( gene4, species4 );
10078 if ( sdi4.getDuplicationsSum() != 1 ) {
10081 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10084 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10087 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10090 if ( species4.getNumberOfExternalNodes() != 6 ) {
10093 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10096 final Phylogeny species5 = factory
10097 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10098 new NHXParser() )[ 0 ];
10099 final Phylogeny gene5 = factory
10100 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10101 new NHXParser() )[ 0 ];
10102 species5.setRooted( true );
10103 gene5.setRooted( true );
10104 final SDI sdi5 = new SDI( gene5, species5 );
10105 if ( sdi5.getDuplicationsSum() != 2 ) {
10108 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10111 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10114 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10117 if ( species5.getNumberOfExternalNodes() != 6 ) {
10120 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10123 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10124 // Conjecture for Comparing Molecular Phylogenies"
10125 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10126 final Phylogeny species6 = factory
10127 .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,"
10128 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10129 new NHXParser() )[ 0 ];
10130 final Phylogeny gene6 = factory
10131 .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,"
10132 + "((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,"
10133 + "(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;",
10134 new NHXParser() )[ 0 ];
10135 species6.setRooted( true );
10136 gene6.setRooted( true );
10137 final SDI sdi6 = new SDI( gene6, species6 );
10138 if ( sdi6.getDuplicationsSum() != 3 ) {
10141 if ( !gene6.getNode( "r" ).isDuplication() ) {
10144 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10147 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10150 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10153 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10156 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10159 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10162 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10165 sdi6.computeMappingCostL();
10166 if ( sdi6.computeMappingCostL() != 17 ) {
10169 if ( species6.getNumberOfExternalNodes() != 9 ) {
10172 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10175 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10176 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10177 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10178 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10179 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10180 species7.setRooted( true );
10181 final Phylogeny gene7_1 = Test
10182 .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])" );
10183 gene7_1.setRooted( true );
10184 final SDI sdi7 = new SDI( gene7_1, species7 );
10185 if ( sdi7.getDuplicationsSum() != 0 ) {
10188 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10191 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10194 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10197 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10200 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10203 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10206 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10209 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10212 final Phylogeny gene7_2 = Test
10213 .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])" );
10214 gene7_2.setRooted( true );
10215 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10216 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10219 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10222 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10225 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10228 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10231 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10234 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10237 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10240 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10243 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10247 catch ( final Exception e ) {
10253 private static boolean testSDIunrooted() {
10255 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10256 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10257 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10258 final Iterator<PhylogenyBranch> iter = l.iterator();
10259 PhylogenyBranch br = iter.next();
10260 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10263 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10267 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10270 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10274 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10277 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10281 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10284 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10288 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10291 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10295 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10298 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10302 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10305 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10309 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10312 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10316 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10319 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10323 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10326 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10330 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10333 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10337 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10340 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10344 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10347 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10351 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10354 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10358 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10361 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10364 if ( iter.hasNext() ) {
10367 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10368 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10369 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10371 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10374 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10378 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10381 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10385 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10388 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10391 if ( iter1.hasNext() ) {
10394 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10395 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10396 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10398 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10401 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10405 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10408 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10412 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10415 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10418 if ( iter2.hasNext() ) {
10421 final Phylogeny species0 = factory
10422 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10423 new NHXParser() )[ 0 ];
10424 final Phylogeny gene1 = factory
10425 .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])",
10426 new NHXParser() )[ 0 ];
10427 species0.setRooted( true );
10428 gene1.setRooted( true );
10429 final SDIR sdi_unrooted = new SDIR();
10430 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10431 if ( sdi_unrooted.getCount() != 1 ) {
10434 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10437 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10440 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10443 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10446 final Phylogeny gene2 = factory
10447 .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])",
10448 new NHXParser() )[ 0 ];
10449 gene2.setRooted( true );
10450 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10451 if ( sdi_unrooted.getCount() != 1 ) {
10454 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10457 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10460 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10463 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10466 final Phylogeny species6 = factory
10467 .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,"
10468 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10469 new NHXParser() )[ 0 ];
10470 final Phylogeny gene6 = factory
10471 .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],"
10472 + "(((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],"
10473 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10474 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10475 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10476 new NHXParser() )[ 0 ];
10477 species6.setRooted( true );
10478 gene6.setRooted( true );
10479 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10480 if ( sdi_unrooted.getCount() != 1 ) {
10483 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10486 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10489 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10492 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10495 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10498 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10501 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10504 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10507 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10510 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10513 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10516 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10520 final Phylogeny species7 = factory
10521 .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,"
10522 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10523 new NHXParser() )[ 0 ];
10524 final Phylogeny gene7 = factory
10525 .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],"
10526 + "(((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],"
10527 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10528 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10529 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10530 new NHXParser() )[ 0 ];
10531 species7.setRooted( true );
10532 gene7.setRooted( true );
10533 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10534 if ( sdi_unrooted.getCount() != 1 ) {
10537 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10540 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10543 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10546 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10549 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10552 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10555 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10558 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10561 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10564 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10567 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10570 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10574 final Phylogeny species8 = factory
10575 .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,"
10576 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10577 new NHXParser() )[ 0 ];
10578 final Phylogeny gene8 = factory
10579 .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],"
10580 + "(((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],"
10581 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10582 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10583 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10584 new NHXParser() )[ 0 ];
10585 species8.setRooted( true );
10586 gene8.setRooted( true );
10587 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
10588 if ( sdi_unrooted.getCount() != 1 ) {
10591 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10594 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10597 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10600 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10603 if ( !p8[ 0 ].getRoot().isDuplication() ) {
10606 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10609 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10612 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
10615 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10618 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
10621 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
10624 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10629 catch ( final Exception e ) {
10630 e.printStackTrace( System.out );
10636 private static boolean testSequenceDbWsTools1() {
10638 final PhylogenyNode n = new PhylogenyNode();
10639 n.setName( "NP_001025424" );
10640 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10641 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10642 || !acc.getValue().equals( "NP_001025424" ) ) {
10645 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10646 acc = SequenceDbWsTools.obtainSeqAccession( n );
10647 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10648 || !acc.getValue().equals( "NP_001025424" ) ) {
10651 n.setName( "NP_001025424.1" );
10652 acc = SequenceDbWsTools.obtainSeqAccession( n );
10653 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10654 || !acc.getValue().equals( "NP_001025424" ) ) {
10657 n.setName( "NM_001030253" );
10658 acc = SequenceDbWsTools.obtainSeqAccession( n );
10659 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10660 || !acc.getValue().equals( "NM_001030253" ) ) {
10663 n.setName( "BCL2_HUMAN" );
10664 acc = SequenceDbWsTools.obtainSeqAccession( n );
10665 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10666 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10667 System.out.println( acc.toString() );
10670 n.setName( "P10415" );
10671 acc = SequenceDbWsTools.obtainSeqAccession( n );
10672 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10673 || !acc.getValue().equals( "P10415" ) ) {
10674 System.out.println( acc.toString() );
10677 n.setName( " P10415 " );
10678 acc = SequenceDbWsTools.obtainSeqAccession( n );
10679 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10680 || !acc.getValue().equals( "P10415" ) ) {
10681 System.out.println( acc.toString() );
10684 n.setName( "_P10415|" );
10685 acc = SequenceDbWsTools.obtainSeqAccession( n );
10686 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10687 || !acc.getValue().equals( "P10415" ) ) {
10688 System.out.println( acc.toString() );
10691 n.setName( "AY695820" );
10692 acc = SequenceDbWsTools.obtainSeqAccession( n );
10693 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10694 || !acc.getValue().equals( "AY695820" ) ) {
10695 System.out.println( acc.toString() );
10698 n.setName( "_AY695820_" );
10699 acc = SequenceDbWsTools.obtainSeqAccession( n );
10700 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10701 || !acc.getValue().equals( "AY695820" ) ) {
10702 System.out.println( acc.toString() );
10705 n.setName( "AAA59452" );
10706 acc = SequenceDbWsTools.obtainSeqAccession( n );
10707 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10708 || !acc.getValue().equals( "AAA59452" ) ) {
10709 System.out.println( acc.toString() );
10712 n.setName( "_AAA59452_" );
10713 acc = SequenceDbWsTools.obtainSeqAccession( n );
10714 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10715 || !acc.getValue().equals( "AAA59452" ) ) {
10716 System.out.println( acc.toString() );
10719 n.setName( "AAA59452.1" );
10720 acc = SequenceDbWsTools.obtainSeqAccession( n );
10721 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10722 || !acc.getValue().equals( "AAA59452.1" ) ) {
10723 System.out.println( acc.toString() );
10726 n.setName( "_AAA59452.1_" );
10727 acc = SequenceDbWsTools.obtainSeqAccession( n );
10728 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10729 || !acc.getValue().equals( "AAA59452.1" ) ) {
10730 System.out.println( acc.toString() );
10733 n.setName( "GI:94894583" );
10734 acc = SequenceDbWsTools.obtainSeqAccession( n );
10735 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10736 || !acc.getValue().equals( "94894583" ) ) {
10737 System.out.println( acc.toString() );
10740 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10741 acc = SequenceDbWsTools.obtainSeqAccession( n );
10742 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10743 || !acc.getValue().equals( "71845847" ) ) {
10744 System.out.println( acc.toString() );
10747 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
10748 acc = SequenceDbWsTools.obtainSeqAccession( n );
10749 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10750 || !acc.getValue().equals( "AAZ45343.1" ) ) {
10751 System.out.println( acc.toString() );
10755 catch ( final Exception e ) {
10761 private static boolean testSequenceDbWsTools2() {
10763 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10764 SequenceDbWsTools.obtainSeqInformation( n1 );
10765 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10768 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10771 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10774 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
10777 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
10778 SequenceDbWsTools.obtainSeqInformation( n2 );
10779 if ( !n2.getNodeData().getSequence().getName()
10780 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10783 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10786 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10789 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
10792 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
10793 SequenceDbWsTools.obtainSeqInformation( n3 );
10794 if ( !n3.getNodeData().getSequence().getName()
10795 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
10798 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
10801 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
10804 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
10808 catch ( final IOException e ) {
10809 System.out.println();
10810 System.out.println( "the following might be due to absence internet connection:" );
10811 e.printStackTrace( System.out );
10814 catch ( final Exception e ) {
10815 e.printStackTrace();
10821 private static boolean testSequenceIdParsing() {
10823 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
10824 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10825 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10826 if ( id != null ) {
10827 System.out.println( "value =" + id.getValue() );
10828 System.out.println( "provider=" + id.getSource() );
10833 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
10834 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10835 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10836 if ( id != null ) {
10837 System.out.println( "value =" + id.getValue() );
10838 System.out.println( "provider=" + id.getSource() );
10843 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
10844 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10845 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
10846 if ( id != null ) {
10847 System.out.println( "value =" + id.getValue() );
10848 System.out.println( "provider=" + id.getSource() );
10853 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
10854 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10855 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
10856 if ( id != null ) {
10857 System.out.println( "value =" + id.getValue() );
10858 System.out.println( "provider=" + id.getSource() );
10863 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
10864 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10865 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
10866 if ( id != null ) {
10867 System.out.println( "value =" + id.getValue() );
10868 System.out.println( "provider=" + id.getSource() );
10873 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
10874 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10875 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
10876 if ( id != null ) {
10877 System.out.println( "value =" + id.getValue() );
10878 System.out.println( "provider=" + id.getSource() );
10883 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
10884 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10885 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
10886 if ( id != null ) {
10887 System.out.println( "value =" + id.getValue() );
10888 System.out.println( "provider=" + id.getSource() );
10893 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
10894 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10895 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10896 if ( id != null ) {
10897 System.out.println( "value =" + id.getValue() );
10898 System.out.println( "provider=" + id.getSource() );
10903 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
10904 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10905 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
10906 if ( id != null ) {
10907 System.out.println( "value =" + id.getValue() );
10908 System.out.println( "provider=" + id.getSource() );
10913 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
10914 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
10915 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
10916 if ( id != null ) {
10917 System.out.println( "value =" + id.getValue() );
10918 System.out.println( "provider=" + id.getSource() );
10922 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
10923 if ( id != null ) {
10924 System.out.println( "value =" + id.getValue() );
10925 System.out.println( "provider=" + id.getSource() );
10929 catch ( final Exception e ) {
10930 e.printStackTrace( System.out );
10936 private static boolean testSequenceWriter() {
10938 final String n = ForesterUtil.LINE_SEPARATOR;
10939 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
10942 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
10945 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
10948 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
10951 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
10952 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
10955 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
10956 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
10960 catch ( final Exception e ) {
10961 e.printStackTrace();
10967 private static boolean testSpecies() {
10969 final Species s1 = new BasicSpecies( "a" );
10970 final Species s2 = new BasicSpecies( "a" );
10971 final Species s3 = new BasicSpecies( "A" );
10972 final Species s4 = new BasicSpecies( "b" );
10973 if ( !s1.equals( s1 ) ) {
10976 if ( s1.getSpeciesId().equals( "x" ) ) {
10979 if ( s1.getSpeciesId().equals( null ) ) {
10982 if ( !s1.equals( s2 ) ) {
10985 if ( s1.equals( s3 ) ) {
10988 if ( s1.hashCode() != s1.hashCode() ) {
10991 if ( s1.hashCode() != s2.hashCode() ) {
10994 if ( s1.hashCode() == s3.hashCode() ) {
10997 if ( s1.compareTo( s1 ) != 0 ) {
11000 if ( s1.compareTo( s2 ) != 0 ) {
11003 if ( s1.compareTo( s3 ) != 0 ) {
11006 if ( s1.compareTo( s4 ) >= 0 ) {
11009 if ( s4.compareTo( s1 ) <= 0 ) {
11012 if ( !s4.getSpeciesId().equals( "b" ) ) {
11015 final Species s5 = new BasicSpecies( " C " );
11016 if ( !s5.getSpeciesId().equals( "C" ) ) {
11019 if ( s5.equals( s1 ) ) {
11023 catch ( final Exception e ) {
11024 e.printStackTrace( System.out );
11030 private static boolean testSplit() {
11032 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11033 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11034 //Archaeopteryx.createApplication( p0 );
11035 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11036 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11037 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11038 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11039 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11040 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11041 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11042 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11043 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11044 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11045 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11046 // System.out.println( s0.toString() );
11048 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11051 if ( s0.match( query_nodes ) ) {
11054 query_nodes = new HashSet<PhylogenyNode>();
11055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11056 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11062 if ( !s0.match( query_nodes ) ) {
11066 query_nodes = new HashSet<PhylogenyNode>();
11067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11070 if ( !s0.match( query_nodes ) ) {
11074 query_nodes = new HashSet<PhylogenyNode>();
11075 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11077 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11079 if ( !s0.match( query_nodes ) ) {
11083 query_nodes = new HashSet<PhylogenyNode>();
11084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11085 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11088 if ( !s0.match( query_nodes ) ) {
11092 query_nodes = new HashSet<PhylogenyNode>();
11093 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11094 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11095 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11096 if ( !s0.match( query_nodes ) ) {
11100 query_nodes = new HashSet<PhylogenyNode>();
11101 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11102 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11103 if ( !s0.match( query_nodes ) ) {
11107 query_nodes = new HashSet<PhylogenyNode>();
11108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11111 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11112 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11113 if ( !s0.match( query_nodes ) ) {
11117 query_nodes = new HashSet<PhylogenyNode>();
11118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11119 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11120 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11121 if ( !s0.match( query_nodes ) ) {
11125 query_nodes = new HashSet<PhylogenyNode>();
11126 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11127 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11128 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11129 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11130 if ( !s0.match( query_nodes ) ) {
11134 query_nodes = new HashSet<PhylogenyNode>();
11135 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11136 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11137 if ( s0.match( query_nodes ) ) {
11141 query_nodes = new HashSet<PhylogenyNode>();
11142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11144 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11146 if ( s0.match( query_nodes ) ) {
11150 query_nodes = new HashSet<PhylogenyNode>();
11151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11153 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11154 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11155 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11156 if ( s0.match( query_nodes ) ) {
11160 query_nodes = new HashSet<PhylogenyNode>();
11161 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11162 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11163 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11164 if ( s0.match( query_nodes ) ) {
11168 query_nodes = new HashSet<PhylogenyNode>();
11169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11171 if ( s0.match( query_nodes ) ) {
11175 query_nodes = new HashSet<PhylogenyNode>();
11176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11178 if ( s0.match( query_nodes ) ) {
11182 query_nodes = new HashSet<PhylogenyNode>();
11183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11185 if ( s0.match( query_nodes ) ) {
11189 query_nodes = new HashSet<PhylogenyNode>();
11190 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11192 if ( s0.match( query_nodes ) ) {
11196 query_nodes = new HashSet<PhylogenyNode>();
11197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11199 if ( s0.match( query_nodes ) ) {
11203 query_nodes = new HashSet<PhylogenyNode>();
11204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11206 if ( s0.match( query_nodes ) ) {
11210 query_nodes = new HashSet<PhylogenyNode>();
11211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11214 if ( s0.match( query_nodes ) ) {
11218 query_nodes = new HashSet<PhylogenyNode>();
11219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11222 if ( s0.match( query_nodes ) ) {
11226 query_nodes = new HashSet<PhylogenyNode>();
11227 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11228 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11230 if ( s0.match( query_nodes ) ) {
11234 query_nodes = new HashSet<PhylogenyNode>();
11235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11239 if ( s0.match( query_nodes ) ) {
11243 // query_nodes = new HashSet<PhylogenyNode>();
11244 // query_nodes.add( new PhylogenyNode( "X" ) );
11245 // query_nodes.add( new PhylogenyNode( "Y" ) );
11246 // query_nodes.add( new PhylogenyNode( "A" ) );
11247 // query_nodes.add( new PhylogenyNode( "B" ) );
11248 // query_nodes.add( new PhylogenyNode( "C" ) );
11249 // query_nodes.add( new PhylogenyNode( "D" ) );
11250 // query_nodes.add( new PhylogenyNode( "E" ) );
11251 // query_nodes.add( new PhylogenyNode( "F" ) );
11252 // query_nodes.add( new PhylogenyNode( "G" ) );
11253 // if ( !s0.match( query_nodes ) ) {
11256 // query_nodes = new HashSet<PhylogenyNode>();
11257 // query_nodes.add( new PhylogenyNode( "X" ) );
11258 // query_nodes.add( new PhylogenyNode( "Y" ) );
11259 // query_nodes.add( new PhylogenyNode( "A" ) );
11260 // query_nodes.add( new PhylogenyNode( "B" ) );
11261 // query_nodes.add( new PhylogenyNode( "C" ) );
11262 // if ( !s0.match( query_nodes ) ) {
11266 // query_nodes = new HashSet<PhylogenyNode>();
11267 // query_nodes.add( new PhylogenyNode( "X" ) );
11268 // query_nodes.add( new PhylogenyNode( "Y" ) );
11269 // query_nodes.add( new PhylogenyNode( "D" ) );
11270 // query_nodes.add( new PhylogenyNode( "E" ) );
11271 // query_nodes.add( new PhylogenyNode( "F" ) );
11272 // query_nodes.add( new PhylogenyNode( "G" ) );
11273 // if ( !s0.match( query_nodes ) ) {
11277 // query_nodes = new HashSet<PhylogenyNode>();
11278 // query_nodes.add( new PhylogenyNode( "X" ) );
11279 // query_nodes.add( new PhylogenyNode( "Y" ) );
11280 // query_nodes.add( new PhylogenyNode( "A" ) );
11281 // query_nodes.add( new PhylogenyNode( "B" ) );
11282 // query_nodes.add( new PhylogenyNode( "C" ) );
11283 // query_nodes.add( new PhylogenyNode( "D" ) );
11284 // if ( !s0.match( query_nodes ) ) {
11288 // query_nodes = new HashSet<PhylogenyNode>();
11289 // query_nodes.add( new PhylogenyNode( "X" ) );
11290 // query_nodes.add( new PhylogenyNode( "Y" ) );
11291 // query_nodes.add( new PhylogenyNode( "E" ) );
11292 // query_nodes.add( new PhylogenyNode( "F" ) );
11293 // query_nodes.add( new PhylogenyNode( "G" ) );
11294 // if ( !s0.match( query_nodes ) ) {
11298 // query_nodes = new HashSet<PhylogenyNode>();
11299 // query_nodes.add( new PhylogenyNode( "X" ) );
11300 // query_nodes.add( new PhylogenyNode( "Y" ) );
11301 // query_nodes.add( new PhylogenyNode( "F" ) );
11302 // query_nodes.add( new PhylogenyNode( "G" ) );
11303 // if ( !s0.match( query_nodes ) ) {
11307 query_nodes = new HashSet<PhylogenyNode>();
11308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11312 if ( s0.match( query_nodes ) ) {
11316 query_nodes = new HashSet<PhylogenyNode>();
11317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11320 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11321 if ( s0.match( query_nodes ) ) {
11324 ///////////////////////////
11326 query_nodes = new HashSet<PhylogenyNode>();
11327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11331 if ( s0.match( query_nodes ) ) {
11335 query_nodes = new HashSet<PhylogenyNode>();
11336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11337 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11338 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11339 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11340 if ( s0.match( query_nodes ) ) {
11344 query_nodes = new HashSet<PhylogenyNode>();
11345 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11346 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11349 if ( s0.match( query_nodes ) ) {
11353 query_nodes = new HashSet<PhylogenyNode>();
11354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11358 if ( s0.match( query_nodes ) ) {
11362 query_nodes = new HashSet<PhylogenyNode>();
11363 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11364 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11367 if ( s0.match( query_nodes ) ) {
11371 query_nodes = new HashSet<PhylogenyNode>();
11372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11375 if ( s0.match( query_nodes ) ) {
11379 query_nodes = new HashSet<PhylogenyNode>();
11380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11385 if ( s0.match( query_nodes ) ) {
11389 query_nodes = new HashSet<PhylogenyNode>();
11390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11395 if ( s0.match( query_nodes ) ) {
11399 query_nodes = new HashSet<PhylogenyNode>();
11400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
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( "X" ) );
11411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11415 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11416 if ( s0.match( query_nodes ) ) {
11420 catch ( final Exception e ) {
11421 e.printStackTrace();
11427 private static boolean testSplitStrict() {
11429 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11430 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11431 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11432 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11433 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11434 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11435 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11436 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11437 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11438 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11439 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11440 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11441 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11443 if ( s0.match( query_nodes ) ) {
11446 query_nodes = new HashSet<PhylogenyNode>();
11447 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11448 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11454 if ( !s0.match( query_nodes ) ) {
11458 query_nodes = new HashSet<PhylogenyNode>();
11459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11462 if ( !s0.match( query_nodes ) ) {
11466 query_nodes = new HashSet<PhylogenyNode>();
11467 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11469 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11471 if ( !s0.match( query_nodes ) ) {
11475 query_nodes = new HashSet<PhylogenyNode>();
11476 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11480 if ( !s0.match( query_nodes ) ) {
11484 query_nodes = new HashSet<PhylogenyNode>();
11485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11488 if ( !s0.match( query_nodes ) ) {
11492 query_nodes = new HashSet<PhylogenyNode>();
11493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11495 if ( !s0.match( query_nodes ) ) {
11499 query_nodes = new HashSet<PhylogenyNode>();
11500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11505 if ( !s0.match( query_nodes ) ) {
11509 query_nodes = new HashSet<PhylogenyNode>();
11510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11513 if ( !s0.match( query_nodes ) ) {
11517 query_nodes = new HashSet<PhylogenyNode>();
11518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11522 if ( !s0.match( query_nodes ) ) {
11526 query_nodes = new HashSet<PhylogenyNode>();
11527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11529 if ( s0.match( query_nodes ) ) {
11533 query_nodes = new HashSet<PhylogenyNode>();
11534 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11535 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11537 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11538 if ( s0.match( query_nodes ) ) {
11542 query_nodes = new HashSet<PhylogenyNode>();
11543 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11548 if ( s0.match( query_nodes ) ) {
11552 query_nodes = new HashSet<PhylogenyNode>();
11553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11556 if ( s0.match( query_nodes ) ) {
11560 query_nodes = new HashSet<PhylogenyNode>();
11561 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11563 if ( s0.match( query_nodes ) ) {
11567 query_nodes = new HashSet<PhylogenyNode>();
11568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11570 if ( s0.match( query_nodes ) ) {
11574 query_nodes = new HashSet<PhylogenyNode>();
11575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11577 if ( s0.match( query_nodes ) ) {
11581 query_nodes = new HashSet<PhylogenyNode>();
11582 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11583 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11584 if ( s0.match( query_nodes ) ) {
11588 query_nodes = new HashSet<PhylogenyNode>();
11589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11590 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11591 if ( s0.match( query_nodes ) ) {
11595 query_nodes = new HashSet<PhylogenyNode>();
11596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11598 if ( s0.match( query_nodes ) ) {
11602 query_nodes = new HashSet<PhylogenyNode>();
11603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11606 if ( s0.match( query_nodes ) ) {
11610 query_nodes = new HashSet<PhylogenyNode>();
11611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11614 if ( s0.match( query_nodes ) ) {
11618 query_nodes = new HashSet<PhylogenyNode>();
11619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11622 if ( s0.match( query_nodes ) ) {
11626 query_nodes = new HashSet<PhylogenyNode>();
11627 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11631 if ( s0.match( query_nodes ) ) {
11635 catch ( final Exception e ) {
11636 e.printStackTrace();
11642 private static boolean testSubtreeDeletion() {
11644 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11645 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11646 t1.deleteSubtree( t1.getNode( "A" ), false );
11647 if ( t1.getNumberOfExternalNodes() != 5 ) {
11650 t1.toNewHampshireX();
11651 t1.deleteSubtree( t1.getNode( "E" ), false );
11652 if ( t1.getNumberOfExternalNodes() != 4 ) {
11655 t1.toNewHampshireX();
11656 t1.deleteSubtree( t1.getNode( "F" ), false );
11657 if ( t1.getNumberOfExternalNodes() != 3 ) {
11660 t1.toNewHampshireX();
11661 t1.deleteSubtree( t1.getNode( "D" ), false );
11662 t1.toNewHampshireX();
11663 if ( t1.getNumberOfExternalNodes() != 3 ) {
11666 t1.deleteSubtree( t1.getNode( "def" ), false );
11667 t1.toNewHampshireX();
11668 if ( t1.getNumberOfExternalNodes() != 2 ) {
11671 t1.deleteSubtree( t1.getNode( "B" ), false );
11672 t1.toNewHampshireX();
11673 if ( t1.getNumberOfExternalNodes() != 1 ) {
11676 t1.deleteSubtree( t1.getNode( "C" ), false );
11677 t1.toNewHampshireX();
11678 if ( t1.getNumberOfExternalNodes() != 1 ) {
11681 t1.deleteSubtree( t1.getNode( "abc" ), false );
11682 t1.toNewHampshireX();
11683 if ( t1.getNumberOfExternalNodes() != 1 ) {
11686 t1.deleteSubtree( t1.getNode( "r" ), false );
11687 if ( t1.getNumberOfExternalNodes() != 0 ) {
11690 if ( !t1.isEmpty() ) {
11693 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
11694 t2.deleteSubtree( t2.getNode( "A" ), false );
11695 t2.toNewHampshireX();
11696 if ( t2.getNumberOfExternalNodes() != 5 ) {
11699 t2.deleteSubtree( t2.getNode( "abc" ), false );
11700 t2.toNewHampshireX();
11701 if ( t2.getNumberOfExternalNodes() != 3 ) {
11704 t2.deleteSubtree( t2.getNode( "def" ), false );
11705 t2.toNewHampshireX();
11706 if ( t2.getNumberOfExternalNodes() != 1 ) {
11710 catch ( final Exception e ) {
11711 e.printStackTrace( System.out );
11717 private static boolean testSupportCount() {
11719 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11720 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
11721 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
11722 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
11723 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
11724 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
11725 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
11727 SupportCount.count( t0_1, phylogenies_1, true, false );
11728 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
11729 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
11730 + "(((((A,B),C),D),E),((F,G),X))"
11731 + "(((((A,Y),B),C),D),((F,G),E))"
11732 + "(((((A,B),C),D),E),(F,G))"
11733 + "(((((A,B),C),D),E),(F,G))"
11734 + "(((((A,B),C),D),E),(F,G))"
11735 + "(((((A,B),C),D),E),(F,G),Z)"
11736 + "(((((A,B),C),D),E),(F,G))"
11737 + "((((((A,B),C),D),E),F),G)"
11738 + "(((((X,Y),F,G),E),((A,B),C)),D)",
11740 SupportCount.count( t0_2, phylogenies_2, true, false );
11741 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
11742 while ( it.hasNext() ) {
11743 final PhylogenyNode n = it.next();
11744 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
11748 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
11749 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
11750 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
11751 SupportCount.count( t0_3, phylogenies_3, true, false );
11752 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
11753 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
11756 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
11759 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
11762 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
11765 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
11768 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
11771 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
11774 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
11777 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
11780 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
11783 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11784 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
11785 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
11786 SupportCount.count( t0_4, phylogenies_4, true, false );
11787 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
11788 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
11791 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
11794 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
11797 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
11800 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
11803 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
11806 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
11809 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
11812 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
11815 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
11818 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11819 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11820 double d = SupportCount.compare( b1, a, true, true, true );
11821 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
11824 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11825 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11826 d = SupportCount.compare( b2, a, true, true, true );
11827 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
11830 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
11831 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
11832 d = SupportCount.compare( b3, a, true, true, true );
11833 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
11836 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
11837 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
11838 d = SupportCount.compare( b4, a, true, true, false );
11839 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
11843 catch ( final Exception e ) {
11844 e.printStackTrace( System.out );
11850 private static boolean testSupportTransfer() {
11852 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11853 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)",
11854 new NHXParser() )[ 0 ];
11855 final Phylogeny p2 = factory
11856 .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 ];
11857 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
11860 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
11863 support_transfer.moveBranchLengthsToBootstrap( p1 );
11864 support_transfer.transferSupportValues( p1, p2 );
11865 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
11868 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
11871 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
11874 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
11877 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
11880 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
11883 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
11886 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
11890 catch ( final Exception e ) {
11891 e.printStackTrace( System.out );
11897 private static boolean testTaxonomyExtraction() {
11899 final PhylogenyNode n0 = PhylogenyNode
11900 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11901 if ( n0.getNodeData().isHasTaxonomy() ) {
11904 final PhylogenyNode n1 = PhylogenyNode
11905 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11906 if ( n1.getNodeData().isHasTaxonomy() ) {
11907 System.out.println( n1.toString() );
11910 final PhylogenyNode n2x = PhylogenyNode
11911 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11912 if ( n2x.getNodeData().isHasTaxonomy() ) {
11915 final PhylogenyNode n3 = PhylogenyNode
11916 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11917 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11918 System.out.println( n3.toString() );
11921 final PhylogenyNode n4 = PhylogenyNode
11922 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11923 if ( n4.getNodeData().isHasTaxonomy() ) {
11924 System.out.println( n4.toString() );
11927 final PhylogenyNode n5 = PhylogenyNode
11928 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11929 if ( n5.getNodeData().isHasTaxonomy() ) {
11930 System.out.println( n5.toString() );
11933 final PhylogenyNode n6 = PhylogenyNode
11934 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11935 if ( n6.getNodeData().isHasTaxonomy() ) {
11936 System.out.println( n6.toString() );
11939 final PhylogenyNode n7 = PhylogenyNode
11940 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11941 if ( n7.getNodeData().isHasTaxonomy() ) {
11942 System.out.println( n7.toString() );
11945 final PhylogenyNode n8 = PhylogenyNode
11946 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11947 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11948 System.out.println( n8.toString() );
11951 final PhylogenyNode n9 = PhylogenyNode
11952 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11953 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
11954 System.out.println( n9.toString() );
11957 final PhylogenyNode n10x = PhylogenyNode
11958 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11959 if ( n10x.getNodeData().isHasTaxonomy() ) {
11960 System.out.println( n10x.toString() );
11963 final PhylogenyNode n10xx = PhylogenyNode
11964 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11965 if ( n10xx.getNodeData().isHasTaxonomy() ) {
11966 System.out.println( n10xx.toString() );
11969 final PhylogenyNode n10 = PhylogenyNode
11970 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
11971 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
11972 System.out.println( n10.toString() );
11975 final PhylogenyNode n11 = PhylogenyNode
11976 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11977 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11978 System.out.println( n11.toString() );
11981 final PhylogenyNode n12 = PhylogenyNode
11982 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
11983 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11984 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
11985 System.out.println( n12.toString() );
11988 final PhylogenyNode n13 = PhylogenyNode
11989 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11990 if ( n13.getNodeData().isHasTaxonomy() ) {
11991 System.out.println( n13.toString() );
11994 final PhylogenyNode n14 = PhylogenyNode
11995 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
11996 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
11997 System.out.println( n14.toString() );
12000 final PhylogenyNode n15 = PhylogenyNode
12001 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12002 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12003 System.out.println( n15.toString() );
12006 final PhylogenyNode n16 = PhylogenyNode
12007 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12008 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12009 System.out.println( n16.toString() );
12012 final PhylogenyNode n17 = PhylogenyNode
12013 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12014 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12015 System.out.println( n17.toString() );
12019 final PhylogenyNode n18 = PhylogenyNode
12020 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12021 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12022 System.out.println( n18.toString() );
12025 final PhylogenyNode n19 = PhylogenyNode
12026 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12027 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12028 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12029 System.out.println( n19.toString() );
12032 final PhylogenyNode n20 = PhylogenyNode
12033 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12034 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12035 System.out.println( n20.toString() );
12038 final PhylogenyNode n21 = PhylogenyNode
12039 .createInstanceFromNhxString( "Mus musculus musculus K392",
12040 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12041 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12042 System.out.println( n21.toString() );
12046 catch ( final Exception e ) {
12047 e.printStackTrace( System.out );
12053 private static boolean testTreeCopy() {
12055 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12056 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12057 final Phylogeny t1 = t0.copy();
12058 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12061 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12064 t0.deleteSubtree( t0.getNode( "c" ), true );
12065 t0.deleteSubtree( t0.getNode( "a" ), true );
12066 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12067 t0.getNode( "b" ).setName( "Bee" );
12068 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12071 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12074 t0.deleteSubtree( t0.getNode( "e" ), true );
12075 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12076 t0.deleteSubtree( t0.getNode( "d" ), true );
12077 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12081 catch ( final Exception e ) {
12082 e.printStackTrace();
12088 private static boolean testTreeMethods() {
12090 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12091 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12092 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12093 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12094 System.out.println( t0.toNewHampshireX() );
12097 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12098 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12099 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12102 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12105 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12109 catch ( final Exception e ) {
12110 e.printStackTrace( System.out );
12116 private static boolean testUniprotEntryRetrieval() {
12118 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12119 if ( !entry.getAccession().equals( "P12345" ) ) {
12122 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12125 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12128 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12131 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12134 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12138 catch ( final IOException e ) {
12139 System.out.println();
12140 System.out.println( "the following might be due to absence internet connection:" );
12141 e.printStackTrace( System.out );
12144 catch ( final Exception e ) {
12150 private static boolean testUniprotTaxonomySearch() {
12152 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12154 if ( results.size() != 1 ) {
12157 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12160 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12163 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12166 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12169 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12173 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12174 if ( results.size() != 1 ) {
12177 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12180 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12183 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12186 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12189 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12193 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12194 if ( results.size() != 1 ) {
12197 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12200 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12203 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12206 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12209 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12213 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12214 if ( results.size() != 1 ) {
12217 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12220 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12223 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12226 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12229 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12232 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12235 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12238 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12239 .equals( "Nematostella vectensis" ) ) {
12240 System.out.println( results.get( 0 ).getLineage() );
12245 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12246 if ( results.size() != 1 ) {
12249 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12252 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12255 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12258 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12261 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12264 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12265 .equals( "Xenopus tropicalis" ) ) {
12266 System.out.println( results.get( 0 ).getLineage() );
12271 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12272 if ( results.size() != 1 ) {
12275 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12278 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12281 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12284 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12287 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12290 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12291 .equals( "Xenopus tropicalis" ) ) {
12292 System.out.println( results.get( 0 ).getLineage() );
12297 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12298 if ( results.size() != 1 ) {
12301 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12304 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12307 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12310 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12313 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12316 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12317 .equals( "Xenopus tropicalis" ) ) {
12318 System.out.println( results.get( 0 ).getLineage() );
12322 catch ( final IOException e ) {
12323 System.out.println();
12324 System.out.println( "the following might be due to absence internet connection:" );
12325 e.printStackTrace( System.out );
12328 catch ( final Exception e ) {
12334 private static boolean testWabiTxSearch() {
12336 String result = "";
12337 result = TxSearch.searchSimple( "nematostella" );
12338 result = TxSearch.getTxId( "nematostella" );
12339 if ( !result.equals( "45350" ) ) {
12342 result = TxSearch.getTxName( "45350" );
12343 if ( !result.equals( "Nematostella" ) ) {
12346 result = TxSearch.getTxId( "nematostella vectensis" );
12347 if ( !result.equals( "45351" ) ) {
12350 result = TxSearch.getTxName( "45351" );
12351 if ( !result.equals( "Nematostella vectensis" ) ) {
12354 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12355 if ( !result.equals( "536089" ) ) {
12358 result = TxSearch.getTxName( "536089" );
12359 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12362 final List<String> queries = new ArrayList<String>();
12363 queries.add( "Campylobacter coli" );
12364 queries.add( "Escherichia coli" );
12365 queries.add( "Arabidopsis" );
12366 queries.add( "Trichoplax" );
12367 queries.add( "Samanea saman" );
12368 queries.add( "Kluyveromyces marxianus" );
12369 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12370 queries.add( "Bornavirus parrot/PDD/2008" );
12371 final List<RANKS> ranks = new ArrayList<RANKS>();
12372 ranks.add( RANKS.SUPERKINGDOM );
12373 ranks.add( RANKS.KINGDOM );
12374 ranks.add( RANKS.FAMILY );
12375 ranks.add( RANKS.GENUS );
12376 ranks.add( RANKS.TRIBE );
12377 result = TxSearch.searchLineage( queries, ranks );
12378 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12379 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12381 catch ( final Exception e ) {
12382 System.out.println();
12383 System.out.println( "the following might be due to absence internet connection:" );
12384 e.printStackTrace( System.out );