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;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.development.DevelopmentTools;
44 import org.forester.evoinference.TestPhylogenyReconstruction;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
47 import org.forester.go.TestGo;
48 import org.forester.io.parsers.FastaParser;
49 import org.forester.io.parsers.GeneralMsaParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
52 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
53 import org.forester.io.parsers.nexus.NexusCharactersParser;
54 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
55 import org.forester.io.parsers.nhx.NHXParser;
56 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
57 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
58 import org.forester.io.parsers.tol.TolParser;
59 import org.forester.io.parsers.util.ParserUtils;
60 import org.forester.io.writers.PhylogenyWriter;
61 import org.forester.io.writers.SequenceWriter;
62 import org.forester.msa.BasicMsa;
63 import org.forester.msa.Mafft;
64 import org.forester.msa.Msa;
65 import org.forester.msa.MsaInferrer;
66 import org.forester.msa.MsaMethods;
67 import org.forester.pccx.TestPccx;
68 import org.forester.phylogeny.Phylogeny;
69 import org.forester.phylogeny.PhylogenyBranch;
70 import org.forester.phylogeny.PhylogenyMethods;
71 import org.forester.phylogeny.PhylogenyNode;
72 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
73 import org.forester.phylogeny.data.Accession;
74 import org.forester.phylogeny.data.Accession.Source;
75 import org.forester.phylogeny.data.BinaryCharacters;
76 import org.forester.phylogeny.data.BranchWidth;
77 import org.forester.phylogeny.data.Confidence;
78 import org.forester.phylogeny.data.Distribution;
79 import org.forester.phylogeny.data.DomainArchitecture;
80 import org.forester.phylogeny.data.Event;
81 import org.forester.phylogeny.data.Identifier;
82 import org.forester.phylogeny.data.PhylogenyData;
83 import org.forester.phylogeny.data.PhylogenyDataUtil;
84 import org.forester.phylogeny.data.Polygon;
85 import org.forester.phylogeny.data.PropertiesMap;
86 import org.forester.phylogeny.data.Property;
87 import org.forester.phylogeny.data.Property.AppliesTo;
88 import org.forester.phylogeny.data.ProteinDomain;
89 import org.forester.phylogeny.data.Taxonomy;
90 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
91 import org.forester.phylogeny.factories.PhylogenyFactory;
92 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
93 import org.forester.protein.BasicDomain;
94 import org.forester.protein.BasicProtein;
95 import org.forester.protein.Domain;
96 import org.forester.protein.Protein;
97 import org.forester.protein.ProteinId;
98 import org.forester.rio.TestRIO;
99 import org.forester.sdi.SDI;
100 import org.forester.sdi.SDIR;
101 import org.forester.sdi.TestGSDI;
102 import org.forester.sequence.BasicSequence;
103 import org.forester.sequence.Sequence;
104 import org.forester.species.BasicSpecies;
105 import org.forester.species.Species;
106 import org.forester.surfacing.TestSurfacing;
107 import org.forester.tools.ConfidenceAssessor;
108 import org.forester.tools.SupportCount;
109 import org.forester.tools.TreeSplitMatrix;
110 import org.forester.util.AsciiHistogram;
111 import org.forester.util.BasicDescriptiveStatistics;
112 import org.forester.util.BasicTable;
113 import org.forester.util.BasicTableParser;
114 import org.forester.util.DescriptiveStatistics;
115 import org.forester.util.ForesterConstants;
116 import org.forester.util.ForesterUtil;
117 import org.forester.util.GeneralTable;
118 import org.forester.util.SequenceAccessionTools;
119 import org.forester.ws.seqdb.SequenceDatabaseEntry;
120 import org.forester.ws.seqdb.SequenceDbWsTools;
121 import org.forester.ws.seqdb.UniProtTaxonomy;
122 import org.forester.ws.wabi.TxSearch;
123 import org.forester.ws.wabi.TxSearch.RANKS;
124 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
125 import org.forester.ws.wabi.TxSearch.TAX_RANK;
127 @SuppressWarnings( "unused")
128 public final class Test {
130 private final static boolean PERFORM_DB_TESTS = true;
131 private final static double ZERO_DIFF = 1.0E-9;
132 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "test_data"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
139 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
142 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
143 + ForesterConstants.PHYLO_XML_VERSION + "/"
144 + ForesterConstants.PHYLO_XML_XSD;
146 public static boolean isEqual( final double a, final double b ) {
147 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
150 public static void main( final String[] args ) {
151 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
152 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
154 Locale.setDefault( Locale.US );
155 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
158 System.out.print( "[Test if directory with files for testing exists/is readable: " );
159 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
160 System.out.println( "OK.]" );
163 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
164 System.out.println( "Testing aborted." );
167 System.out.print( "[Test if resources directory exists/is readable: " );
168 if ( testDir( PATH_TO_RESOURCES ) ) {
169 System.out.println( "OK.]" );
172 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
173 System.out.println( "Testing aborted." );
176 final long start_time = new Date().getTime();
177 System.out.print( "Basic node methods: " );
178 if ( Test.testBasicNodeMethods() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Protein id: " );
187 if ( !testProteinId() ) {
188 System.out.println( "failed." );
194 System.out.println( "OK." );
195 System.out.print( "Species: " );
196 if ( !testSpecies() ) {
197 System.out.println( "failed." );
203 System.out.println( "OK." );
204 System.out.print( "Basic domain: " );
205 if ( !testBasicDomain() ) {
206 System.out.println( "failed." );
212 System.out.println( "OK." );
213 System.out.print( "Basic protein: " );
214 if ( !testBasicProtein() ) {
215 System.out.println( "failed." );
221 System.out.println( "OK." );
222 System.out.print( "Sequence writer: " );
223 if ( testSequenceWriter() ) {
224 System.out.println( "OK." );
228 System.out.println( "failed." );
231 System.out.print( "Sequence id parsing: " );
232 if ( testSequenceIdParsing() ) {
233 System.out.println( "OK." );
237 System.out.println( "failed." );
240 if ( PERFORM_DB_TESTS ) {
241 System.out.print( "Ebi Entry Retrieval: " );
242 if ( Test.testEbiEntryRetrieval() ) {
243 System.out.println( "OK." );
247 System.out.println( "failed." );
252 System.out.print( "UniProtKB id extraction: " );
253 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
254 System.out.println( "OK." );
258 System.out.println( "failed." );
261 System.out.print( "Sequence DB tools 1: " );
262 if ( testSequenceDbWsTools1() ) {
263 System.out.println( "OK." );
267 System.out.println( "failed." );
270 if ( PERFORM_DB_TESTS ) {
271 System.out.print( "Sequence DB tools 2: " );
272 if ( testSequenceDbWsTools2() ) {
273 System.out.println( "OK." );
277 System.out.println( "failed." );
282 System.out.print( "Hmmscan output parser: " );
283 if ( testHmmscanOutputParser() ) {
284 System.out.println( "OK." );
288 System.out.println( "failed." );
291 System.out.print( "Taxonomy code extraction: " );
292 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
293 System.out.println( "OK." );
297 System.out.println( "failed." );
300 System.out.print( "SN extraction: " );
301 if ( Test.testExtractSNFromNodeName() ) {
302 System.out.println( "OK." );
306 System.out.println( "failed." );
309 System.out.print( "Taxonomy extraction (general): " );
310 if ( Test.testTaxonomyExtraction() ) {
311 System.out.println( "OK." );
315 System.out.println( "failed." );
318 System.out.print( "Uri for Aptx web sequence accession: " );
319 if ( Test.testCreateUriForSeqWeb() ) {
320 System.out.println( "OK." );
324 System.out.println( "failed." );
327 System.out.print( "Basic node construction and parsing of NHX (node level): " );
328 if ( Test.testNHXNodeParsing() ) {
329 System.out.println( "OK." );
333 System.out.println( "failed." );
336 System.out.print( "NHX parsing iterating: " );
337 if ( Test.testNHParsingIter() ) {
338 System.out.println( "OK." );
342 System.out.println( "failed." );
345 System.out.print( "NH parsing: " );
346 if ( Test.testNHParsing() ) {
347 System.out.println( "OK." );
351 System.out.println( "failed." );
354 System.out.print( "Conversion to NHX (node level): " );
355 if ( Test.testNHXconversion() ) {
356 System.out.println( "OK." );
360 System.out.println( "failed." );
363 System.out.print( "NHX parsing: " );
364 if ( Test.testNHXParsing() ) {
365 System.out.println( "OK." );
369 System.out.println( "failed." );
372 System.out.print( "NHX parsing with quotes: " );
373 if ( Test.testNHXParsingQuotes() ) {
374 System.out.println( "OK." );
378 System.out.println( "failed." );
381 System.out.print( "NHX parsing (MrBayes): " );
382 if ( Test.testNHXParsingMB() ) {
383 System.out.println( "OK." );
387 System.out.println( "failed." );
390 System.out.print( "Nexus characters parsing: " );
391 if ( Test.testNexusCharactersParsing() ) {
392 System.out.println( "OK." );
396 System.out.println( "failed." );
399 System.out.print( "Nexus tree parsing iterating: " );
400 if ( Test.testNexusTreeParsingIterating() ) {
401 System.out.println( "OK." );
405 System.out.println( "failed." );
408 System.out.print( "Nexus tree parsing: " );
409 if ( Test.testNexusTreeParsing() ) {
410 System.out.println( "OK." );
414 System.out.println( "failed." );
417 System.out.print( "Nexus tree parsing (translating): " );
418 if ( Test.testNexusTreeParsingTranslating() ) {
419 System.out.println( "OK." );
423 System.out.println( "failed." );
426 System.out.print( "Nexus matrix parsing: " );
427 if ( Test.testNexusMatrixParsing() ) {
428 System.out.println( "OK." );
432 System.out.println( "failed." );
435 System.out.print( "Basic phyloXML parsing: " );
436 if ( Test.testBasicPhyloXMLparsing() ) {
437 System.out.println( "OK." );
441 System.out.println( "failed." );
444 System.out.print( "Basic phyloXML parsing (validating against schema): " );
445 if ( testBasicPhyloXMLparsingValidating() ) {
446 System.out.println( "OK." );
450 System.out.println( "failed." );
453 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
454 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
455 System.out.println( "OK." );
459 System.out.println( "failed." );
462 System.out.print( "phyloXML Distribution Element: " );
463 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
464 System.out.println( "OK." );
468 System.out.println( "failed." );
471 System.out.print( "Tol XML parsing: " );
472 if ( Test.testBasicTolXMLparsing() ) {
473 System.out.println( "OK." );
477 System.out.println( "failed." );
480 System.out.print( "Copying of node data: " );
481 if ( Test.testCopyOfNodeData() ) {
482 System.out.println( "OK." );
486 System.out.println( "failed." );
489 System.out.print( "Basic tree methods: " );
490 if ( Test.testBasicTreeMethods() ) {
491 System.out.println( "OK." );
495 System.out.println( "failed." );
498 System.out.print( "Tree methods: " );
499 if ( Test.testTreeMethods() ) {
500 System.out.println( "OK." );
504 System.out.println( "failed." );
507 System.out.print( "Postorder Iterator: " );
508 if ( Test.testPostOrderIterator() ) {
509 System.out.println( "OK." );
513 System.out.println( "failed." );
516 System.out.print( "Preorder Iterator: " );
517 if ( Test.testPreOrderIterator() ) {
518 System.out.println( "OK." );
522 System.out.println( "failed." );
525 System.out.print( "Levelorder Iterator: " );
526 if ( Test.testLevelOrderIterator() ) {
527 System.out.println( "OK." );
531 System.out.println( "failed." );
534 System.out.print( "Re-id methods: " );
535 if ( Test.testReIdMethods() ) {
536 System.out.println( "OK." );
540 System.out.println( "failed." );
543 System.out.print( "Methods on last external nodes: " );
544 if ( Test.testLastExternalNodeMethods() ) {
545 System.out.println( "OK." );
549 System.out.println( "failed." );
552 System.out.print( "Methods on external nodes: " );
553 if ( Test.testExternalNodeRelatedMethods() ) {
554 System.out.println( "OK." );
558 System.out.println( "failed." );
561 System.out.print( "Deletion of external nodes: " );
562 if ( Test.testDeletionOfExternalNodes() ) {
563 System.out.println( "OK." );
567 System.out.println( "failed." );
570 System.out.print( "Subtree deletion: " );
571 if ( Test.testSubtreeDeletion() ) {
572 System.out.println( "OK." );
576 System.out.println( "failed." );
579 System.out.print( "Phylogeny branch: " );
580 if ( Test.testPhylogenyBranch() ) {
581 System.out.println( "OK." );
585 System.out.println( "failed." );
588 System.out.print( "Rerooting: " );
589 if ( Test.testRerooting() ) {
590 System.out.println( "OK." );
594 System.out.println( "failed." );
597 System.out.print( "Mipoint rooting: " );
598 if ( Test.testMidpointrooting() ) {
599 System.out.println( "OK." );
603 System.out.println( "failed." );
606 System.out.print( "Node removal: " );
607 if ( Test.testNodeRemoval() ) {
608 System.out.println( "OK." );
612 System.out.println( "failed." );
615 System.out.print( "Support count: " );
616 if ( Test.testSupportCount() ) {
617 System.out.println( "OK." );
621 System.out.println( "failed." );
624 System.out.print( "Support transfer: " );
625 if ( Test.testSupportTransfer() ) {
626 System.out.println( "OK." );
630 System.out.println( "failed." );
633 System.out.print( "Finding of LCA: " );
634 if ( Test.testGetLCA() ) {
635 System.out.println( "OK." );
639 System.out.println( "failed." );
642 System.out.print( "Finding of LCA 2: " );
643 if ( Test.testGetLCA2() ) {
644 System.out.println( "OK." );
648 System.out.println( "failed." );
651 System.out.print( "Calculation of distance between nodes: " );
652 if ( Test.testGetDistance() ) {
653 System.out.println( "OK." );
657 System.out.println( "failed." );
660 System.out.print( "Descriptive statistics: " );
661 if ( Test.testDescriptiveStatistics() ) {
662 System.out.println( "OK." );
666 System.out.println( "failed." );
669 System.out.print( "Data objects and methods: " );
670 if ( Test.testDataObjects() ) {
671 System.out.println( "OK." );
675 System.out.println( "failed." );
678 System.out.print( "Properties map: " );
679 if ( Test.testPropertiesMap() ) {
680 System.out.println( "OK." );
684 System.out.println( "failed." );
687 System.out.print( "SDIse: " );
688 if ( Test.testSDIse() ) {
689 System.out.println( "OK." );
693 System.out.println( "failed." );
696 System.out.print( "SDIunrooted: " );
697 if ( Test.testSDIunrooted() ) {
698 System.out.println( "OK." );
702 System.out.println( "failed." );
705 System.out.print( "GSDI: " );
706 if ( TestGSDI.test() ) {
707 System.out.println( "OK." );
711 System.out.println( "failed." );
714 System.out.print( "RIO: " );
715 if ( TestRIO.test() ) {
716 System.out.println( "OK." );
720 System.out.println( "failed." );
723 System.out.print( "Phylogeny reconstruction:" );
724 System.out.println();
725 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
726 System.out.println( "OK." );
730 System.out.println( "failed." );
733 System.out.print( "Analysis of domain architectures: " );
734 System.out.println();
735 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
736 System.out.println( "OK." );
740 System.out.println( "failed." );
743 System.out.print( "GO: " );
744 System.out.println();
745 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
746 System.out.println( "OK." );
750 System.out.println( "failed." );
753 System.out.print( "Modeling tools: " );
754 if ( TestPccx.test() ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "Split Matrix strict: " );
763 if ( Test.testSplitStrict() ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "Split Matrix: " );
772 if ( Test.testSplit() ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "Confidence Assessor: " );
781 if ( Test.testConfidenceAssessor() ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "Basic table: " );
790 if ( Test.testBasicTable() ) {
791 System.out.println( "OK." );
795 System.out.println( "failed." );
798 System.out.print( "General table: " );
799 if ( Test.testGeneralTable() ) {
800 System.out.println( "OK." );
804 System.out.println( "failed." );
807 System.out.print( "Amino acid sequence: " );
808 if ( Test.testAminoAcidSequence() ) {
809 System.out.println( "OK." );
813 System.out.println( "failed." );
816 System.out.print( "General MSA parser: " );
817 if ( Test.testGeneralMsaParser() ) {
818 System.out.println( "OK." );
822 System.out.println( "failed." );
825 System.out.print( "Fasta parser for msa: " );
826 if ( Test.testFastaParser() ) {
827 System.out.println( "OK." );
831 System.out.println( "failed." );
834 System.out.print( "Creation of balanced phylogeny: " );
835 if ( Test.testCreateBalancedPhylogeny() ) {
836 System.out.println( "OK." );
840 System.out.println( "failed." );
843 System.out.print( "Genbank accessor parsing: " );
844 if ( Test.testGenbankAccessorParsing() ) {
845 System.out.println( "OK." );
849 System.out.println( "failed." );
852 if ( PERFORM_DB_TESTS ) {
853 System.out.print( "Uniprot Entry Retrieval: " );
854 if ( Test.testUniprotEntryRetrieval() ) {
855 System.out.println( "OK." );
859 System.out.println( "failed." );
863 if ( PERFORM_DB_TESTS ) {
864 System.out.print( "Uniprot Taxonomy Search: " );
865 if ( Test.testUniprotTaxonomySearch() ) {
866 System.out.println( "OK." );
870 System.out.println( "failed." );
876 final String os = ForesterUtil.OS_NAME.toLowerCase();
877 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
878 path = "/usr/local/bin/mafft";
880 else if ( os.indexOf( "win" ) >= 0 ) {
881 path = "C:\\Program Files\\mafft-win\\mafft.bat";
884 path = "/home/czmasek/bin/mafft";
886 if ( !MsaInferrer.isInstalled( path ) ) {
889 if ( !MsaInferrer.isInstalled( path ) ) {
890 path = "/usr/local/bin/mafft";
892 if ( MsaInferrer.isInstalled( path ) ) {
893 System.out.print( "MAFFT (external program): " );
894 if ( Test.testMafft( path ) ) {
895 System.out.println( "OK." );
899 System.out.println( "failed [will not count towards failed tests]" );
903 System.out.print( "Next nodes with collapsed: " );
904 if ( Test.testNextNodeWithCollapsing() ) {
905 System.out.println( "OK." );
909 System.out.println( "failed." );
912 System.out.print( "Simple MSA quality: " );
913 if ( Test.testMsaQualityMethod() ) {
914 System.out.println( "OK." );
918 System.out.println( "failed." );
921 System.out.println();
922 final Runtime rt = java.lang.Runtime.getRuntime();
923 final long free_memory = rt.freeMemory() / 1000000;
924 final long total_memory = rt.totalMemory() / 1000000;
925 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
926 + free_memory + "MB, total memory: " + total_memory + "MB)" );
927 System.out.println();
928 System.out.println( "Successful tests: " + succeeded );
929 System.out.println( "Failed tests: " + failed );
930 System.out.println();
932 System.out.println( "OK." );
935 System.out.println( "Not OK." );
939 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
940 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
944 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
945 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
948 private static boolean testAminoAcidSequence() {
950 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
951 if ( aa1.getLength() != 13 ) {
954 if ( aa1.getResidueAt( 0 ) != 'A' ) {
957 if ( aa1.getResidueAt( 2 ) != 'K' ) {
960 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
963 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
964 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
967 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
968 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
971 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
972 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
976 catch ( final Exception e ) {
983 private static boolean testBasicDomain() {
985 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
986 if ( !pd.getDomainId().equals( "id" ) ) {
989 if ( pd.getNumber() != 1 ) {
992 if ( pd.getTotalCount() != 4 ) {
995 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
998 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
999 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1000 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1001 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1002 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1003 if ( !a1.equals( a1 ) ) {
1006 if ( !a1.equals( a1_copy ) ) {
1009 if ( !a1.equals( a1_equal ) ) {
1012 if ( !a1.equals( a2 ) ) {
1015 if ( a1.equals( a3 ) ) {
1018 if ( a1.compareTo( a1 ) != 0 ) {
1021 if ( a1.compareTo( a1_copy ) != 0 ) {
1024 if ( a1.compareTo( a1_equal ) != 0 ) {
1027 if ( a1.compareTo( a2 ) != 0 ) {
1030 if ( a1.compareTo( a3 ) == 0 ) {
1034 catch ( final Exception e ) {
1035 e.printStackTrace( System.out );
1041 private static boolean testBasicNodeMethods() {
1043 if ( PhylogenyNode.getNodeCount() != 0 ) {
1046 final PhylogenyNode n1 = new PhylogenyNode();
1047 final PhylogenyNode n2 = PhylogenyNode
1048 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1049 final PhylogenyNode n3 = PhylogenyNode
1050 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1051 final PhylogenyNode n4 = PhylogenyNode
1052 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1053 if ( n1.isHasAssignedEvent() ) {
1056 if ( PhylogenyNode.getNodeCount() != 4 ) {
1059 if ( n3.getIndicator() != 0 ) {
1062 if ( n3.getNumberOfExternalNodes() != 1 ) {
1065 if ( !n3.isExternal() ) {
1068 if ( !n3.isRoot() ) {
1071 if ( !n4.getName().equals( "n4" ) ) {
1075 catch ( final Exception e ) {
1076 e.printStackTrace( System.out );
1082 private static boolean testBasicPhyloXMLparsing() {
1084 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1085 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1086 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1088 if ( xml_parser.getErrorCount() > 0 ) {
1089 System.out.println( xml_parser.getErrorMessages().toString() );
1092 if ( phylogenies_0.length != 4 ) {
1095 final Phylogeny t1 = phylogenies_0[ 0 ];
1096 final Phylogeny t2 = phylogenies_0[ 1 ];
1097 final Phylogeny t3 = phylogenies_0[ 2 ];
1098 final Phylogeny t4 = phylogenies_0[ 3 ];
1099 if ( t1.getNumberOfExternalNodes() != 1 ) {
1102 if ( !t1.isRooted() ) {
1105 if ( t1.isRerootable() ) {
1108 if ( !t1.getType().equals( "gene_tree" ) ) {
1111 if ( t2.getNumberOfExternalNodes() != 2 ) {
1114 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1117 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1120 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1123 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1126 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1129 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1132 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1133 .startsWith( "actgtgggggt" ) ) {
1136 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1137 .startsWith( "ctgtgatgcat" ) ) {
1140 if ( t3.getNumberOfExternalNodes() != 4 ) {
1143 if ( !t1.getName().equals( "t1" ) ) {
1146 if ( !t2.getName().equals( "t2" ) ) {
1149 if ( !t3.getName().equals( "t3" ) ) {
1152 if ( !t4.getName().equals( "t4" ) ) {
1155 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1158 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1161 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1164 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1165 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1168 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1171 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1174 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1177 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1178 .equals( "apoptosis" ) ) {
1181 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1182 .equals( "GO:0006915" ) ) {
1185 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1186 .equals( "UniProtKB" ) ) {
1189 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1190 .equals( "experimental" ) ) {
1193 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1194 .equals( "function" ) ) {
1197 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1198 .getValue() != 1 ) {
1201 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1202 .getType().equals( "ml" ) ) {
1205 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1206 .equals( "apoptosis" ) ) {
1209 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1210 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1213 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1214 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1217 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1218 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1221 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1222 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1225 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1226 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1229 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1230 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1233 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1234 .equals( "GO:0005829" ) ) {
1237 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1238 .equals( "intracellular organelle" ) ) {
1241 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1244 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1245 .equals( "UniProt link" ) ) ) {
1248 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1251 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1252 if ( x.size() != 4 ) {
1256 for( final Accession acc : x ) {
1258 if ( !acc.getSource().equals( "KEGG" ) ) {
1261 if ( !acc.getValue().equals( "hsa:596" ) ) {
1268 catch ( final Exception e ) {
1269 e.printStackTrace( System.out );
1275 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1277 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1278 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1279 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1280 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1283 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1285 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1287 if ( xml_parser.getErrorCount() > 0 ) {
1288 System.out.println( xml_parser.getErrorMessages().toString() );
1291 if ( phylogenies_0.length != 4 ) {
1294 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1295 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1296 if ( phylogenies_t1.length != 1 ) {
1299 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1300 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1303 if ( !t1_rt.isRooted() ) {
1306 if ( t1_rt.isRerootable() ) {
1309 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1312 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1313 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1314 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1315 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1318 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1321 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1324 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1327 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1328 .startsWith( "actgtgggggt" ) ) {
1331 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1332 .startsWith( "ctgtgatgcat" ) ) {
1335 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1336 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1337 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1338 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1339 if ( phylogenies_1.length != 1 ) {
1342 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1343 if ( !t3_rt.getName().equals( "t3" ) ) {
1346 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1349 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1352 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1355 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1358 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1359 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1362 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1365 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1368 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1369 .equals( "UniProtKB" ) ) {
1372 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1373 .equals( "apoptosis" ) ) {
1376 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1377 .equals( "GO:0006915" ) ) {
1380 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1381 .equals( "UniProtKB" ) ) {
1384 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1385 .equals( "experimental" ) ) {
1388 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1389 .equals( "function" ) ) {
1392 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1393 .getValue() != 1 ) {
1396 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1397 .getType().equals( "ml" ) ) {
1400 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1401 .equals( "apoptosis" ) ) {
1404 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1405 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1408 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1409 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1412 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1413 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1416 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1417 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1420 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1421 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1424 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1425 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1428 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1429 .equals( "GO:0005829" ) ) {
1432 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1433 .equals( "intracellular organelle" ) ) {
1436 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1439 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1440 .equals( "UniProt link" ) ) ) {
1443 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1446 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1449 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1450 .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." ) ) ) {
1453 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1456 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1459 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1462 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1465 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1466 .equals( "ncbi" ) ) {
1469 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1472 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1473 .getName().equals( "B" ) ) {
1476 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1477 .getFrom() != 21 ) {
1480 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1483 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1484 .getLength() != 24 ) {
1487 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1488 .getConfidence() != 2144 ) {
1491 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1492 .equals( "pfam" ) ) {
1495 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1498 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1501 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1504 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1507 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1508 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1511 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1514 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1517 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1520 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1523 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1526 if ( taxbb.getSynonyms().size() != 2 ) {
1529 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1532 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1535 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1538 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1541 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1544 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1545 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1548 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1551 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1554 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1557 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1560 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1563 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1566 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1570 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1573 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1574 .equalsIgnoreCase( "435" ) ) {
1577 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1580 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1581 .equalsIgnoreCase( "443.7" ) ) {
1584 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1587 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1590 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1591 .equalsIgnoreCase( "433" ) ) {
1594 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1595 .getCrossReferences();
1596 if ( x.size() != 4 ) {
1600 for( final Accession acc : x ) {
1602 if ( !acc.getSource().equals( "KEGG" ) ) {
1605 if ( !acc.getValue().equals( "hsa:596" ) ) {
1612 catch ( final Exception e ) {
1613 e.printStackTrace( System.out );
1619 private static boolean testBasicPhyloXMLparsingValidating() {
1621 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1622 PhyloXmlParser xml_parser = null;
1624 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1626 catch ( final Exception e ) {
1627 // Do nothing -- means were not running from jar.
1629 if ( xml_parser == null ) {
1630 xml_parser = new PhyloXmlParser();
1631 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1632 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1635 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1638 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1640 if ( xml_parser.getErrorCount() > 0 ) {
1641 System.out.println( xml_parser.getErrorMessages().toString() );
1644 if ( phylogenies_0.length != 4 ) {
1647 final Phylogeny t1 = phylogenies_0[ 0 ];
1648 final Phylogeny t2 = phylogenies_0[ 1 ];
1649 final Phylogeny t3 = phylogenies_0[ 2 ];
1650 final Phylogeny t4 = phylogenies_0[ 3 ];
1651 if ( !t1.getName().equals( "t1" ) ) {
1654 if ( !t2.getName().equals( "t2" ) ) {
1657 if ( !t3.getName().equals( "t3" ) ) {
1660 if ( !t4.getName().equals( "t4" ) ) {
1663 if ( t1.getNumberOfExternalNodes() != 1 ) {
1666 if ( t2.getNumberOfExternalNodes() != 2 ) {
1669 if ( t3.getNumberOfExternalNodes() != 4 ) {
1672 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1673 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1674 if ( xml_parser.getErrorCount() > 0 ) {
1675 System.out.println( "errors:" );
1676 System.out.println( xml_parser.getErrorMessages().toString() );
1679 if ( phylogenies_1.length != 4 ) {
1682 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1684 if ( xml_parser.getErrorCount() > 0 ) {
1685 System.out.println( "errors:" );
1686 System.out.println( xml_parser.getErrorMessages().toString() );
1689 if ( phylogenies_2.length != 1 ) {
1692 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1695 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1697 if ( xml_parser.getErrorCount() > 0 ) {
1698 System.out.println( xml_parser.getErrorMessages().toString() );
1701 if ( phylogenies_3.length != 2 ) {
1704 final Phylogeny a = phylogenies_3[ 0 ];
1705 if ( !a.getName().equals( "tree 4" ) ) {
1708 if ( a.getNumberOfExternalNodes() != 3 ) {
1711 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1714 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1717 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1719 if ( xml_parser.getErrorCount() > 0 ) {
1720 System.out.println( xml_parser.getErrorMessages().toString() );
1723 if ( phylogenies_4.length != 1 ) {
1726 final Phylogeny s = phylogenies_4[ 0 ];
1727 if ( s.getNumberOfExternalNodes() != 6 ) {
1730 s.getNode( "first" );
1732 s.getNode( "\"<a'b&c'd\">\"" );
1733 s.getNode( "'''\"" );
1734 s.getNode( "\"\"\"" );
1735 s.getNode( "dick & doof" );
1737 catch ( final Exception e ) {
1738 e.printStackTrace( System.out );
1744 private static boolean testBasicProtein() {
1746 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1747 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1748 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1749 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1750 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1751 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1752 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1753 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1754 p0.addProteinDomain( y );
1755 p0.addProteinDomain( e );
1756 p0.addProteinDomain( b );
1757 p0.addProteinDomain( c );
1758 p0.addProteinDomain( d );
1759 p0.addProteinDomain( a );
1760 p0.addProteinDomain( x );
1761 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1764 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
1768 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
1769 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1770 aa0.addProteinDomain( a1 );
1771 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
1774 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
1778 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
1779 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1780 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1781 aa1.addProteinDomain( a11 );
1782 aa1.addProteinDomain( a12 );
1783 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
1786 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
1789 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1790 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
1793 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1796 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
1799 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1800 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
1803 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1806 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
1809 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
1812 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1813 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
1816 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
1819 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
1822 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
1825 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1826 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
1829 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
1832 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
1835 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
1839 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
1840 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1841 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1842 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1843 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1844 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1845 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
1846 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
1847 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
1848 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
1849 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
1850 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1851 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1852 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
1853 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
1854 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
1855 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
1856 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
1857 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
1858 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
1859 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
1860 p00.addProteinDomain( y0 );
1861 p00.addProteinDomain( e0 );
1862 p00.addProteinDomain( b0 );
1863 p00.addProteinDomain( c0 );
1864 p00.addProteinDomain( d0 );
1865 p00.addProteinDomain( a0 );
1866 p00.addProteinDomain( x0 );
1867 p00.addProteinDomain( y1 );
1868 p00.addProteinDomain( y2 );
1869 p00.addProteinDomain( y3 );
1870 p00.addProteinDomain( e1 );
1871 p00.addProteinDomain( e2 );
1872 p00.addProteinDomain( e3 );
1873 p00.addProteinDomain( e4 );
1874 p00.addProteinDomain( e5 );
1875 p00.addProteinDomain( z0 );
1876 p00.addProteinDomain( z1 );
1877 p00.addProteinDomain( z2 );
1878 p00.addProteinDomain( zz0 );
1879 p00.addProteinDomain( zz1 );
1880 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
1883 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
1886 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1889 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1892 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" ) ) {
1895 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1896 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1897 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1898 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1899 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1900 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1901 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1902 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1903 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1904 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1905 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1906 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1907 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1908 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1909 p.addProteinDomain( B15 );
1910 p.addProteinDomain( C50 );
1911 p.addProteinDomain( A60 );
1912 p.addProteinDomain( A30 );
1913 p.addProteinDomain( C70 );
1914 p.addProteinDomain( B35 );
1915 p.addProteinDomain( B40 );
1916 p.addProteinDomain( A0 );
1917 p.addProteinDomain( A10 );
1918 p.addProteinDomain( A20 );
1919 p.addProteinDomain( B25 );
1920 p.addProteinDomain( D80 );
1921 List<String> domains_ids = new ArrayList<String>();
1922 domains_ids.add( "A" );
1923 domains_ids.add( "B" );
1924 domains_ids.add( "C" );
1925 if ( !p.contains( domains_ids, false ) ) {
1928 if ( !p.contains( domains_ids, true ) ) {
1931 domains_ids.add( "X" );
1932 if ( p.contains( domains_ids, false ) ) {
1935 if ( p.contains( domains_ids, true ) ) {
1938 domains_ids = new ArrayList<String>();
1939 domains_ids.add( "A" );
1940 domains_ids.add( "C" );
1941 domains_ids.add( "D" );
1942 if ( !p.contains( domains_ids, false ) ) {
1945 if ( !p.contains( domains_ids, true ) ) {
1948 domains_ids = new ArrayList<String>();
1949 domains_ids.add( "A" );
1950 domains_ids.add( "D" );
1951 domains_ids.add( "C" );
1952 if ( !p.contains( domains_ids, false ) ) {
1955 if ( p.contains( domains_ids, true ) ) {
1958 domains_ids = new ArrayList<String>();
1959 domains_ids.add( "A" );
1960 domains_ids.add( "A" );
1961 domains_ids.add( "B" );
1962 if ( !p.contains( domains_ids, false ) ) {
1965 if ( !p.contains( domains_ids, true ) ) {
1968 domains_ids = new ArrayList<String>();
1969 domains_ids.add( "A" );
1970 domains_ids.add( "A" );
1971 domains_ids.add( "A" );
1972 domains_ids.add( "B" );
1973 domains_ids.add( "B" );
1974 if ( !p.contains( domains_ids, false ) ) {
1977 if ( !p.contains( domains_ids, true ) ) {
1980 domains_ids = new ArrayList<String>();
1981 domains_ids.add( "A" );
1982 domains_ids.add( "A" );
1983 domains_ids.add( "B" );
1984 domains_ids.add( "A" );
1985 domains_ids.add( "B" );
1986 domains_ids.add( "B" );
1987 domains_ids.add( "A" );
1988 domains_ids.add( "B" );
1989 domains_ids.add( "C" );
1990 domains_ids.add( "A" );
1991 domains_ids.add( "C" );
1992 domains_ids.add( "D" );
1993 if ( !p.contains( domains_ids, false ) ) {
1996 if ( p.contains( domains_ids, true ) ) {
2000 catch ( final Exception e ) {
2001 e.printStackTrace( System.out );
2007 private static boolean testBasicTable() {
2009 final BasicTable<String> t0 = new BasicTable<String>();
2010 if ( t0.getNumberOfColumns() != 0 ) {
2013 if ( t0.getNumberOfRows() != 0 ) {
2016 t0.setValue( 3, 2, "23" );
2017 t0.setValue( 10, 1, "error" );
2018 t0.setValue( 10, 1, "110" );
2019 t0.setValue( 9, 1, "19" );
2020 t0.setValue( 1, 10, "101" );
2021 t0.setValue( 10, 10, "1010" );
2022 t0.setValue( 100, 10, "10100" );
2023 t0.setValue( 0, 0, "00" );
2024 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2027 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2030 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2033 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2036 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2039 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2042 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2045 if ( t0.getNumberOfColumns() != 101 ) {
2048 if ( t0.getNumberOfRows() != 11 ) {
2051 if ( t0.getValueAsString( 49, 4 ) != null ) {
2054 final String l = ForesterUtil.getLineSeparator();
2055 final StringBuffer source = new StringBuffer();
2056 source.append( "" + l );
2057 source.append( "# 1 1 1 1 1 1 1 1" + l );
2058 source.append( " 00 01 02 03" + l );
2059 source.append( " 10 11 12 13 " + l );
2060 source.append( "20 21 22 23 " + l );
2061 source.append( " 30 31 32 33" + l );
2062 source.append( "40 41 42 43" + l );
2063 source.append( " # 1 1 1 1 1 " + l );
2064 source.append( "50 51 52 53 54" + l );
2065 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2066 if ( t1.getNumberOfColumns() != 5 ) {
2069 if ( t1.getNumberOfRows() != 6 ) {
2072 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2075 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2078 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2081 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2084 final StringBuffer source1 = new StringBuffer();
2085 source1.append( "" + l );
2086 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2087 source1.append( " 00; 01 ;02;03" + l );
2088 source1.append( " 10; 11; 12; 13 " + l );
2089 source1.append( "20; 21; 22; 23 " + l );
2090 source1.append( " 30; 31; 32; 33" + l );
2091 source1.append( "40;41;42;43" + l );
2092 source1.append( " # 1 1 1 1 1 " + l );
2093 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2094 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2095 if ( t2.getNumberOfColumns() != 5 ) {
2098 if ( t2.getNumberOfRows() != 6 ) {
2101 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2104 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2107 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2110 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2113 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2116 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2119 final StringBuffer source2 = new StringBuffer();
2120 source2.append( "" + l );
2121 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2122 source2.append( " 00; 01 ;02;03" + l );
2123 source2.append( " 10; 11; 12; 13 " + l );
2124 source2.append( "20; 21; 22; 23 " + l );
2125 source2.append( " " + l );
2126 source2.append( " 30; 31; 32; 33" + l );
2127 source2.append( "40;41;42;43" + l );
2128 source2.append( " comment: 1 1 1 1 1 " + l );
2129 source2.append( ";;;50 ; 52; 53;;54 " + l );
2130 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2136 if ( tl.size() != 2 ) {
2139 final BasicTable<String> t3 = tl.get( 0 );
2140 final BasicTable<String> t4 = tl.get( 1 );
2141 if ( t3.getNumberOfColumns() != 4 ) {
2144 if ( t3.getNumberOfRows() != 3 ) {
2147 if ( t4.getNumberOfColumns() != 4 ) {
2150 if ( t4.getNumberOfRows() != 3 ) {
2153 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2156 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2160 catch ( final Exception e ) {
2161 e.printStackTrace( System.out );
2167 private static boolean testBasicTolXMLparsing() {
2169 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2170 final TolParser parser = new TolParser();
2171 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2172 if ( parser.getErrorCount() > 0 ) {
2173 System.out.println( parser.getErrorMessages().toString() );
2176 if ( phylogenies_0.length != 1 ) {
2179 final Phylogeny t1 = phylogenies_0[ 0 ];
2180 if ( t1.getNumberOfExternalNodes() != 5 ) {
2183 if ( !t1.isRooted() ) {
2186 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2189 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2192 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2195 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2198 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2199 if ( parser.getErrorCount() > 0 ) {
2200 System.out.println( parser.getErrorMessages().toString() );
2203 if ( phylogenies_1.length != 1 ) {
2206 final Phylogeny t2 = phylogenies_1[ 0 ];
2207 if ( t2.getNumberOfExternalNodes() != 664 ) {
2210 if ( !t2.isRooted() ) {
2213 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2216 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2219 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2222 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2225 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2228 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2229 .equals( "Aquifex" ) ) {
2232 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2233 if ( parser.getErrorCount() > 0 ) {
2234 System.out.println( parser.getErrorMessages().toString() );
2237 if ( phylogenies_2.length != 1 ) {
2240 final Phylogeny t3 = phylogenies_2[ 0 ];
2241 if ( t3.getNumberOfExternalNodes() != 184 ) {
2244 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2247 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2250 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2253 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2254 if ( parser.getErrorCount() > 0 ) {
2255 System.out.println( parser.getErrorMessages().toString() );
2258 if ( phylogenies_3.length != 1 ) {
2261 final Phylogeny t4 = phylogenies_3[ 0 ];
2262 if ( t4.getNumberOfExternalNodes() != 1 ) {
2265 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2268 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2271 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2274 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2275 if ( parser.getErrorCount() > 0 ) {
2276 System.out.println( parser.getErrorMessages().toString() );
2279 if ( phylogenies_4.length != 1 ) {
2282 final Phylogeny t5 = phylogenies_4[ 0 ];
2283 if ( t5.getNumberOfExternalNodes() != 13 ) {
2286 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2289 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2292 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2296 catch ( final Exception e ) {
2297 e.printStackTrace( System.out );
2303 private static boolean testBasicTreeMethods() {
2305 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2306 final Phylogeny t1 = factory.create();
2307 if ( !t1.isEmpty() ) {
2310 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2311 if ( t2.getNumberOfExternalNodes() != 4 ) {
2314 if ( t2.getHeight() != 8.5 ) {
2317 if ( !t2.isCompletelyBinary() ) {
2320 if ( t2.isEmpty() ) {
2323 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2324 if ( t3.getNumberOfExternalNodes() != 5 ) {
2327 if ( t3.getHeight() != 11 ) {
2330 if ( t3.isCompletelyBinary() ) {
2333 final PhylogenyNode n = t3.getNode( "ABC" );
2334 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 ];
2335 if ( t4.getNumberOfExternalNodes() != 9 ) {
2338 if ( t4.getHeight() != 11 ) {
2341 if ( t4.isCompletelyBinary() ) {
2344 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)" );
2345 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2346 if ( t5.getNumberOfExternalNodes() != 8 ) {
2349 if ( t5.getHeight() != 15 ) {
2352 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)" );
2353 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2354 if ( t6.getHeight() != 15 ) {
2357 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)" );
2358 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2359 if ( t7.getHeight() != 15 ) {
2362 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)" );
2363 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2364 if ( t8.getNumberOfExternalNodes() != 10 ) {
2367 if ( t8.getHeight() != 15 ) {
2370 final char[] a9 = new char[] { 'a' };
2371 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2372 if ( t9.getHeight() != 0 ) {
2375 final char[] a10 = new char[] { 'a', ':', '6' };
2376 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2377 if ( t10.getHeight() != 6 ) {
2381 catch ( final Exception e ) {
2382 e.printStackTrace( System.out );
2388 private static boolean testConfidenceAssessor() {
2390 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2391 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2392 final Phylogeny[] ev0 = factory
2393 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2395 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2396 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2399 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2402 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2403 final Phylogeny[] ev1 = factory
2404 .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)));",
2406 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2407 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2410 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2413 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2414 final Phylogeny[] ev_b = factory
2415 .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",
2417 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2418 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2421 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2425 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2426 final Phylogeny[] ev1x = factory
2427 .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)));",
2429 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2430 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2433 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2436 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2437 final Phylogeny[] ev_bx = factory
2438 .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",
2440 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2441 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2444 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2448 final Phylogeny[] t2 = factory
2449 .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);",
2451 final Phylogeny[] ev2 = factory
2452 .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);",
2454 for( final Phylogeny target : t2 ) {
2455 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2458 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2459 new NHXParser() )[ 0 ];
2460 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2461 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2462 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2465 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2468 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2472 catch ( final Exception e ) {
2473 e.printStackTrace();
2479 private static boolean testCopyOfNodeData() {
2481 final PhylogenyNode n1 = PhylogenyNode
2482 .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]" );
2483 final PhylogenyNode n2 = n1.copyNodeData();
2484 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2488 catch ( final Exception e ) {
2489 e.printStackTrace();
2495 private static boolean testCreateBalancedPhylogeny() {
2497 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2498 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2501 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2504 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2505 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2508 if ( p1.getNumberOfExternalNodes() != 100 ) {
2512 catch ( final Exception e ) {
2513 e.printStackTrace();
2519 private static boolean testCreateUriForSeqWeb() {
2521 final PhylogenyNode n = new PhylogenyNode();
2522 n.setName( "tr|B3RJ64" );
2523 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2526 n.setName( "B0LM41_HUMAN" );
2527 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2530 n.setName( "NP_001025424" );
2531 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2534 n.setName( "_NM_001030253-" );
2535 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2538 n.setName( "XM_002122186" );
2539 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2542 n.setName( "dgh_AAA34956_gdg" );
2543 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2546 n.setName( "AAA34956" );
2547 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2550 n.setName( "GI:394892" );
2551 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2552 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2555 n.setName( "gi_394892" );
2556 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2557 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2560 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2561 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2562 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2565 n.setName( "P12345" );
2566 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2567 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2570 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2571 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2572 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2576 catch ( final Exception e ) {
2577 e.printStackTrace( System.out );
2583 private static boolean testDataObjects() {
2585 final Confidence s0 = new Confidence();
2586 final Confidence s1 = new Confidence();
2587 if ( !s0.isEqual( s1 ) ) {
2590 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2591 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2592 if ( s2.isEqual( s1 ) ) {
2595 if ( !s2.isEqual( s3 ) ) {
2598 final Confidence s4 = ( Confidence ) s3.copy();
2599 if ( !s4.isEqual( s3 ) ) {
2606 final Taxonomy t1 = new Taxonomy();
2607 final Taxonomy t2 = new Taxonomy();
2608 final Taxonomy t3 = new Taxonomy();
2609 final Taxonomy t4 = new Taxonomy();
2610 final Taxonomy t5 = new Taxonomy();
2611 t1.setIdentifier( new Identifier( "ecoli" ) );
2612 t1.setTaxonomyCode( "ECOLI" );
2613 t1.setScientificName( "E. coli" );
2614 t1.setCommonName( "coli" );
2615 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2616 if ( !t1.isEqual( t0 ) ) {
2619 t2.setIdentifier( new Identifier( "ecoli" ) );
2620 t2.setTaxonomyCode( "OTHER" );
2621 t2.setScientificName( "what" );
2622 t2.setCommonName( "something" );
2623 if ( !t1.isEqual( t2 ) ) {
2626 t2.setIdentifier( new Identifier( "nemve" ) );
2627 if ( t1.isEqual( t2 ) ) {
2630 t1.setIdentifier( null );
2631 t3.setTaxonomyCode( "ECOLI" );
2632 t3.setScientificName( "what" );
2633 t3.setCommonName( "something" );
2634 if ( !t1.isEqual( t3 ) ) {
2637 t1.setIdentifier( null );
2638 t1.setTaxonomyCode( "" );
2639 t4.setScientificName( "E. ColI" );
2640 t4.setCommonName( "something" );
2641 if ( !t1.isEqual( t4 ) ) {
2644 t4.setScientificName( "B. subtilis" );
2645 t4.setCommonName( "something" );
2646 if ( t1.isEqual( t4 ) ) {
2649 t1.setIdentifier( null );
2650 t1.setTaxonomyCode( "" );
2651 t1.setScientificName( "" );
2652 t5.setCommonName( "COLI" );
2653 if ( !t1.isEqual( t5 ) ) {
2656 t5.setCommonName( "vibrio" );
2657 if ( t1.isEqual( t5 ) ) {
2662 final Identifier id0 = new Identifier( "123", "pfam" );
2663 final Identifier id1 = ( Identifier ) id0.copy();
2664 if ( !id1.isEqual( id1 ) ) {
2667 if ( !id1.isEqual( id0 ) ) {
2670 if ( !id0.isEqual( id1 ) ) {
2677 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2678 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2679 if ( !pd1.isEqual( pd1 ) ) {
2682 if ( !pd1.isEqual( pd0 ) ) {
2687 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2688 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2689 if ( !pd3.isEqual( pd3 ) ) {
2692 if ( !pd2.isEqual( pd3 ) ) {
2695 if ( !pd0.isEqual( pd3 ) ) {
2700 // DomainArchitecture
2701 // ------------------
2702 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2703 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2704 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2705 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2706 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2707 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2712 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2713 if ( ds0.getNumberOfDomains() != 4 ) {
2716 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2717 if ( !ds0.isEqual( ds0 ) ) {
2720 if ( !ds0.isEqual( ds1 ) ) {
2723 if ( ds1.getNumberOfDomains() != 4 ) {
2726 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2731 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2732 if ( ds0.isEqual( ds2 ) ) {
2738 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2739 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2740 System.out.println( ds3.toNHX() );
2743 if ( ds3.getNumberOfDomains() != 3 ) {
2748 final Event e1 = new Event( Event.EventType.fusion );
2749 if ( e1.isDuplication() ) {
2752 if ( !e1.isFusion() ) {
2755 if ( !e1.asText().toString().equals( "fusion" ) ) {
2758 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2761 final Event e11 = new Event( Event.EventType.fusion );
2762 if ( !e11.isEqual( e1 ) ) {
2765 if ( !e11.toNHX().toString().equals( "" ) ) {
2768 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2769 if ( e2.isDuplication() ) {
2772 if ( !e2.isSpeciationOrDuplication() ) {
2775 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2778 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2781 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2784 if ( e11.isEqual( e2 ) ) {
2787 final Event e2c = ( Event ) e2.copy();
2788 if ( !e2c.isEqual( e2 ) ) {
2791 Event e3 = new Event( 1, 2, 3 );
2792 if ( e3.isDuplication() ) {
2795 if ( e3.isSpeciation() ) {
2798 if ( e3.isGeneLoss() ) {
2801 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2804 final Event e3c = ( Event ) e3.copy();
2805 final Event e3cc = ( Event ) e3c.copy();
2806 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2810 if ( !e3c.isEqual( e3cc ) ) {
2813 Event e4 = new Event( 1, 2, 3 );
2814 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2817 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2820 final Event e4c = ( Event ) e4.copy();
2822 final Event e4cc = ( Event ) e4c.copy();
2823 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2826 if ( !e4c.isEqual( e4cc ) ) {
2829 final Event e5 = new Event();
2830 if ( !e5.isUnassigned() ) {
2833 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2836 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2839 final Event e6 = new Event( 1, 0, 0 );
2840 if ( !e6.asText().toString().equals( "duplication" ) ) {
2843 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2846 final Event e7 = new Event( 0, 1, 0 );
2847 if ( !e7.asText().toString().equals( "speciation" ) ) {
2850 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2853 final Event e8 = new Event( 0, 0, 1 );
2854 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2857 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2861 catch ( final Exception e ) {
2862 e.printStackTrace( System.out );
2868 private static boolean testDeletionOfExternalNodes() {
2870 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2871 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2872 final PhylogenyWriter w = new PhylogenyWriter();
2873 if ( t0.isEmpty() ) {
2876 if ( t0.getNumberOfExternalNodes() != 1 ) {
2879 t0.deleteSubtree( t0.getNode( "A" ), false );
2880 if ( t0.getNumberOfExternalNodes() != 0 ) {
2883 if ( !t0.isEmpty() ) {
2886 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2887 if ( t1.getNumberOfExternalNodes() != 2 ) {
2890 t1.deleteSubtree( t1.getNode( "A" ), false );
2891 if ( t1.getNumberOfExternalNodes() != 1 ) {
2894 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2897 t1.deleteSubtree( t1.getNode( "B" ), false );
2898 if ( t1.getNumberOfExternalNodes() != 1 ) {
2901 t1.deleteSubtree( t1.getNode( "r" ), false );
2902 if ( !t1.isEmpty() ) {
2905 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2906 if ( t2.getNumberOfExternalNodes() != 3 ) {
2909 t2.deleteSubtree( t2.getNode( "B" ), false );
2910 if ( t2.getNumberOfExternalNodes() != 2 ) {
2913 t2.toNewHampshireX();
2914 PhylogenyNode n = t2.getNode( "A" );
2915 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2918 t2.deleteSubtree( t2.getNode( "A" ), false );
2919 if ( t2.getNumberOfExternalNodes() != 2 ) {
2922 t2.deleteSubtree( t2.getNode( "C" ), true );
2923 if ( t2.getNumberOfExternalNodes() != 1 ) {
2926 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2927 if ( t3.getNumberOfExternalNodes() != 4 ) {
2930 t3.deleteSubtree( t3.getNode( "B" ), true );
2931 if ( t3.getNumberOfExternalNodes() != 3 ) {
2934 n = t3.getNode( "A" );
2935 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2938 n = n.getNextExternalNode();
2939 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2942 t3.deleteSubtree( t3.getNode( "A" ), true );
2943 if ( t3.getNumberOfExternalNodes() != 2 ) {
2946 n = t3.getNode( "C" );
2947 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2950 t3.deleteSubtree( t3.getNode( "C" ), true );
2951 if ( t3.getNumberOfExternalNodes() != 1 ) {
2954 t3.deleteSubtree( t3.getNode( "D" ), true );
2955 if ( t3.getNumberOfExternalNodes() != 0 ) {
2958 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2959 if ( t4.getNumberOfExternalNodes() != 6 ) {
2962 t4.deleteSubtree( t4.getNode( "B2" ), true );
2963 if ( t4.getNumberOfExternalNodes() != 5 ) {
2966 String s = w.toNewHampshire( t4, false, true ).toString();
2967 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2970 t4.deleteSubtree( t4.getNode( "B11" ), true );
2971 if ( t4.getNumberOfExternalNodes() != 4 ) {
2974 t4.deleteSubtree( t4.getNode( "C" ), true );
2975 if ( t4.getNumberOfExternalNodes() != 3 ) {
2978 n = t4.getNode( "A" );
2979 n = n.getNextExternalNode();
2980 if ( !n.getName().equals( "B12" ) ) {
2983 n = n.getNextExternalNode();
2984 if ( !n.getName().equals( "D" ) ) {
2987 s = w.toNewHampshire( t4, false, true ).toString();
2988 if ( !s.equals( "((A,B12),D);" ) ) {
2991 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2992 t5.deleteSubtree( t5.getNode( "A" ), true );
2993 if ( t5.getNumberOfExternalNodes() != 5 ) {
2996 s = w.toNewHampshire( t5, false, true ).toString();
2997 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3000 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3001 t6.deleteSubtree( t6.getNode( "B11" ), true );
3002 if ( t6.getNumberOfExternalNodes() != 5 ) {
3005 s = w.toNewHampshire( t6, false, false ).toString();
3006 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3009 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3010 t7.deleteSubtree( t7.getNode( "B12" ), true );
3011 if ( t7.getNumberOfExternalNodes() != 5 ) {
3014 s = w.toNewHampshire( t7, false, true ).toString();
3015 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3018 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3019 t8.deleteSubtree( t8.getNode( "B2" ), true );
3020 if ( t8.getNumberOfExternalNodes() != 5 ) {
3023 s = w.toNewHampshire( t8, false, false ).toString();
3024 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3027 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3028 t9.deleteSubtree( t9.getNode( "C" ), true );
3029 if ( t9.getNumberOfExternalNodes() != 5 ) {
3032 s = w.toNewHampshire( t9, false, true ).toString();
3033 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3036 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3037 t10.deleteSubtree( t10.getNode( "D" ), true );
3038 if ( t10.getNumberOfExternalNodes() != 5 ) {
3041 s = w.toNewHampshire( t10, false, true ).toString();
3042 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3045 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3046 t11.deleteSubtree( t11.getNode( "A" ), true );
3047 if ( t11.getNumberOfExternalNodes() != 2 ) {
3050 s = w.toNewHampshire( t11, false, true ).toString();
3051 if ( !s.equals( "(B,C);" ) ) {
3054 t11.deleteSubtree( t11.getNode( "C" ), true );
3055 if ( t11.getNumberOfExternalNodes() != 1 ) {
3058 s = w.toNewHampshire( t11, false, false ).toString();
3059 if ( !s.equals( "B;" ) ) {
3062 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3063 t12.deleteSubtree( t12.getNode( "B2" ), true );
3064 if ( t12.getNumberOfExternalNodes() != 8 ) {
3067 s = w.toNewHampshire( t12, false, true ).toString();
3068 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3071 t12.deleteSubtree( t12.getNode( "B3" ), true );
3072 if ( t12.getNumberOfExternalNodes() != 7 ) {
3075 s = w.toNewHampshire( t12, false, true ).toString();
3076 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3079 t12.deleteSubtree( t12.getNode( "C3" ), true );
3080 if ( t12.getNumberOfExternalNodes() != 6 ) {
3083 s = w.toNewHampshire( t12, false, true ).toString();
3084 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3087 t12.deleteSubtree( t12.getNode( "A1" ), true );
3088 if ( t12.getNumberOfExternalNodes() != 5 ) {
3091 s = w.toNewHampshire( t12, false, true ).toString();
3092 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3095 t12.deleteSubtree( t12.getNode( "B1" ), true );
3096 if ( t12.getNumberOfExternalNodes() != 4 ) {
3099 s = w.toNewHampshire( t12, false, true ).toString();
3100 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3103 t12.deleteSubtree( t12.getNode( "A3" ), true );
3104 if ( t12.getNumberOfExternalNodes() != 3 ) {
3107 s = w.toNewHampshire( t12, false, true ).toString();
3108 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3111 t12.deleteSubtree( t12.getNode( "A2" ), true );
3112 if ( t12.getNumberOfExternalNodes() != 2 ) {
3115 s = w.toNewHampshire( t12, false, true ).toString();
3116 if ( !s.equals( "(C1,C2);" ) ) {
3119 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3120 t13.deleteSubtree( t13.getNode( "D" ), true );
3121 if ( t13.getNumberOfExternalNodes() != 4 ) {
3124 s = w.toNewHampshire( t13, false, true ).toString();
3125 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3128 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3129 t14.deleteSubtree( t14.getNode( "E" ), true );
3130 if ( t14.getNumberOfExternalNodes() != 5 ) {
3133 s = w.toNewHampshire( t14, false, true ).toString();
3134 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3137 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3138 t15.deleteSubtree( t15.getNode( "B2" ), true );
3139 if ( t15.getNumberOfExternalNodes() != 11 ) {
3142 t15.deleteSubtree( t15.getNode( "B1" ), true );
3143 if ( t15.getNumberOfExternalNodes() != 10 ) {
3146 t15.deleteSubtree( t15.getNode( "B3" ), true );
3147 if ( t15.getNumberOfExternalNodes() != 9 ) {
3150 t15.deleteSubtree( t15.getNode( "B4" ), true );
3151 if ( t15.getNumberOfExternalNodes() != 8 ) {
3154 t15.deleteSubtree( t15.getNode( "A1" ), true );
3155 if ( t15.getNumberOfExternalNodes() != 7 ) {
3158 t15.deleteSubtree( t15.getNode( "C4" ), true );
3159 if ( t15.getNumberOfExternalNodes() != 6 ) {
3163 catch ( final Exception e ) {
3164 e.printStackTrace( System.out );
3170 private static boolean testDescriptiveStatistics() {
3172 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3173 dss1.addValue( 82 );
3174 dss1.addValue( 78 );
3175 dss1.addValue( 70 );
3176 dss1.addValue( 58 );
3177 dss1.addValue( 42 );
3178 if ( dss1.getN() != 5 ) {
3181 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3184 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3187 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3190 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3193 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3196 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3199 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3202 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3205 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3208 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3211 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3214 dss1.addValue( 123 );
3215 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3218 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3221 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3224 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3225 dss2.addValue( -1.85 );
3226 dss2.addValue( 57.5 );
3227 dss2.addValue( 92.78 );
3228 dss2.addValue( 57.78 );
3229 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3232 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3235 final double[] a = dss2.getDataAsDoubleArray();
3236 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3239 dss2.addValue( -100 );
3240 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3243 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3246 final double[] ds = new double[ 14 ];
3261 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3262 if ( bins.length != 4 ) {
3265 if ( bins[ 0 ] != 2 ) {
3268 if ( bins[ 1 ] != 3 ) {
3271 if ( bins[ 2 ] != 4 ) {
3274 if ( bins[ 3 ] != 5 ) {
3277 final double[] ds1 = new double[ 9 ];
3287 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3288 if ( bins1.length != 4 ) {
3291 if ( bins1[ 0 ] != 2 ) {
3294 if ( bins1[ 1 ] != 3 ) {
3297 if ( bins1[ 2 ] != 0 ) {
3300 if ( bins1[ 3 ] != 4 ) {
3303 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3304 if ( bins1_1.length != 3 ) {
3307 if ( bins1_1[ 0 ] != 3 ) {
3310 if ( bins1_1[ 1 ] != 2 ) {
3313 if ( bins1_1[ 2 ] != 4 ) {
3316 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3317 if ( bins1_2.length != 3 ) {
3320 if ( bins1_2[ 0 ] != 2 ) {
3323 if ( bins1_2[ 1 ] != 2 ) {
3326 if ( bins1_2[ 2 ] != 2 ) {
3329 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3343 dss3.addValue( 10 );
3344 dss3.addValue( 10 );
3345 dss3.addValue( 10 );
3346 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3347 histo.toStringBuffer( 10, '=', 40, 5 );
3348 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3350 catch ( final Exception e ) {
3351 e.printStackTrace( System.out );
3357 private static boolean testDir( final String file ) {
3359 final File f = new File( file );
3360 if ( !f.exists() ) {
3363 if ( !f.isDirectory() ) {
3366 if ( !f.canRead() ) {
3370 catch ( final Exception e ) {
3376 private static boolean testGenbankAccessorParsing() {
3377 //The format for GenBank Accession numbers are:
3378 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3379 //Protein: 3 letters + 5 numerals
3380 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3381 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3384 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3387 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3390 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3393 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3396 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3399 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3402 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3405 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3408 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3411 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3414 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3417 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3420 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3426 private static boolean testExternalNodeRelatedMethods() {
3428 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3429 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3430 PhylogenyNode n = t1.getNode( "A" );
3431 n = n.getNextExternalNode();
3432 if ( !n.getName().equals( "B" ) ) {
3435 n = n.getNextExternalNode();
3436 if ( !n.getName().equals( "C" ) ) {
3439 n = n.getNextExternalNode();
3440 if ( !n.getName().equals( "D" ) ) {
3443 n = t1.getNode( "B" );
3444 while ( !n.isLastExternalNode() ) {
3445 n = n.getNextExternalNode();
3447 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3448 n = t2.getNode( "A" );
3449 n = n.getNextExternalNode();
3450 if ( !n.getName().equals( "B" ) ) {
3453 n = n.getNextExternalNode();
3454 if ( !n.getName().equals( "C" ) ) {
3457 n = n.getNextExternalNode();
3458 if ( !n.getName().equals( "D" ) ) {
3461 n = t2.getNode( "B" );
3462 while ( !n.isLastExternalNode() ) {
3463 n = n.getNextExternalNode();
3465 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3466 n = t3.getNode( "A" );
3467 n = n.getNextExternalNode();
3468 if ( !n.getName().equals( "B" ) ) {
3471 n = n.getNextExternalNode();
3472 if ( !n.getName().equals( "C" ) ) {
3475 n = n.getNextExternalNode();
3476 if ( !n.getName().equals( "D" ) ) {
3479 n = n.getNextExternalNode();
3480 if ( !n.getName().equals( "E" ) ) {
3483 n = n.getNextExternalNode();
3484 if ( !n.getName().equals( "F" ) ) {
3487 n = n.getNextExternalNode();
3488 if ( !n.getName().equals( "G" ) ) {
3491 n = n.getNextExternalNode();
3492 if ( !n.getName().equals( "H" ) ) {
3495 n = t3.getNode( "B" );
3496 while ( !n.isLastExternalNode() ) {
3497 n = n.getNextExternalNode();
3499 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3500 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3501 final PhylogenyNode node = iter.next();
3503 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3504 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3505 final PhylogenyNode node = iter.next();
3507 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3508 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3509 if ( !iter.next().getName().equals( "A" ) ) {
3512 if ( !iter.next().getName().equals( "B" ) ) {
3515 if ( !iter.next().getName().equals( "C" ) ) {
3518 if ( !iter.next().getName().equals( "D" ) ) {
3521 if ( !iter.next().getName().equals( "E" ) ) {
3524 if ( !iter.next().getName().equals( "F" ) ) {
3527 if ( iter.hasNext() ) {
3531 catch ( final Exception e ) {
3532 e.printStackTrace( System.out );
3538 private static boolean testExtractSNFromNodeName() {
3540 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3543 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3544 .equals( "Mus musculus musculus" ) ) {
3547 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3548 .equals( "Mus musculus musculus" ) ) {
3551 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3554 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3555 .equals( "Mus musculus" ) ) {
3559 catch ( final Exception e ) {
3560 e.printStackTrace( System.out );
3566 private static boolean testExtractTaxonomyCodeFromNodeName() {
3568 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3571 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3572 .equals( "SOYBN" ) ) {
3575 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3576 .equals( "ARATH" ) ) {
3579 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3580 .equals( "ARATH" ) ) {
3583 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3586 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3589 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3592 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3593 .equals( "SOYBN" ) ) {
3596 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3597 .equals( "SOYBN" ) ) {
3600 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3601 .equals( "SOYBN" ) ) {
3604 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3605 .equals( "SOYBN" ) ) {
3608 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3609 .equals( "SOYBN" ) ) {
3612 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3613 .equals( "SOYBN" ) ) {
3616 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3617 .equals( "SOYBN" ) ) {
3620 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3621 .equals( "SOYBN" ) ) {
3624 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3627 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3628 .equals( "SOYBN" ) ) {
3631 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3632 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3635 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3636 .equals( "9YX45" ) ) {
3639 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3640 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3641 .equals( "MOUSE" ) ) {
3644 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3645 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3646 .equals( "MOUSE" ) ) {
3649 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3650 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3651 .equals( "MOUSE" ) ) {
3654 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3655 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3658 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3659 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3662 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3663 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3666 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3667 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3670 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3671 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3674 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3675 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3678 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3679 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3682 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3683 .equals( "RAT" ) ) {
3686 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3687 .equals( "PIG" ) ) {
3691 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3692 .equals( "MOUSE" ) ) {
3695 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3696 .equals( "MOUSE" ) ) {
3699 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3703 catch ( final Exception e ) {
3704 e.printStackTrace( System.out );
3710 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3712 PhylogenyNode n = new PhylogenyNode();
3713 n.setName( "tr|B3RJ64" );
3714 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3717 n.setName( "tr.B3RJ64" );
3718 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3721 n.setName( "tr=B3RJ64" );
3722 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3725 n.setName( "tr-B3RJ64" );
3726 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3729 n.setName( "tr/B3RJ64" );
3730 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3733 n.setName( "tr\\B3RJ64" );
3734 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3737 n.setName( "tr_B3RJ64" );
3738 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3741 n.setName( " tr|B3RJ64 " );
3742 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3745 n.setName( "-tr|B3RJ64-" );
3746 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3749 n.setName( "-tr=B3RJ64-" );
3750 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3753 n.setName( "_tr=B3RJ64_" );
3754 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3757 n.setName( " tr_tr|B3RJ64_sp|123 " );
3758 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3761 n.setName( "B3RJ64" );
3762 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3765 n.setName( "sp|B3RJ64" );
3766 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3769 n.setName( "sp|B3RJ64C" );
3770 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3773 n.setName( "sp B3RJ64" );
3774 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3777 n.setName( "sp|B3RJ6X" );
3778 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3781 n.setName( "sp|B3RJ6" );
3782 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3785 n.setName( "K1PYK7_CRAGI" );
3786 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3789 n.setName( "K1PYK7_PEA" );
3790 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
3793 n.setName( "K1PYK7_RAT" );
3794 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
3797 n.setName( "K1PYK7_PIG" );
3798 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3801 n.setName( "~K1PYK7_PIG~" );
3802 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3805 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3806 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3809 n.setName( "K1PYKX_CRAGI" );
3810 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3813 n.setName( "XXXXX_CRAGI" );
3814 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
3817 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3818 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
3821 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3822 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3825 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3826 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
3829 n = new PhylogenyNode();
3830 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3831 seq.setSymbol( "K1PYK7_CRAGI" );
3832 n.getNodeData().addSequence( seq );
3833 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3836 seq.setSymbol( "tr|B3RJ64" );
3837 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3840 n = new PhylogenyNode();
3841 seq = new org.forester.phylogeny.data.Sequence();
3842 seq.setName( "K1PYK7_CRAGI" );
3843 n.getNodeData().addSequence( seq );
3844 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3847 seq.setName( "tr|B3RJ64" );
3848 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3851 n = new PhylogenyNode();
3852 seq = new org.forester.phylogeny.data.Sequence();
3853 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3854 n.getNodeData().addSequence( seq );
3855 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
3858 n = new PhylogenyNode();
3859 seq = new org.forester.phylogeny.data.Sequence();
3860 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3861 n.getNodeData().addSequence( seq );
3862 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3866 n = new PhylogenyNode();
3867 n.setName( "ACP19736" );
3868 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3871 n = new PhylogenyNode();
3872 n.setName( "|ACP19736|" );
3873 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3877 catch ( final Exception e ) {
3878 e.printStackTrace( System.out );
3884 private static boolean testFastaParser() {
3886 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3889 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3892 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3893 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3896 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3899 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3902 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3905 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3908 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3912 catch ( final Exception e ) {
3913 e.printStackTrace();
3919 private static boolean testGeneralMsaParser() {
3921 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3922 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3923 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3924 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3925 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3926 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3927 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3928 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3929 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3932 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3935 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3938 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3941 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3944 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3947 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3950 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3953 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3956 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3959 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3962 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3965 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3966 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3969 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3972 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3975 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3976 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3979 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3982 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3985 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3986 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3989 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3992 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3996 catch ( final Exception e ) {
3997 e.printStackTrace();
4003 private static boolean testGeneralTable() {
4005 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4006 t0.setValue( 3, 2, "23" );
4007 t0.setValue( 10, 1, "error" );
4008 t0.setValue( 10, 1, "110" );
4009 t0.setValue( 9, 1, "19" );
4010 t0.setValue( 1, 10, "101" );
4011 t0.setValue( 10, 10, "1010" );
4012 t0.setValue( 100, 10, "10100" );
4013 t0.setValue( 0, 0, "00" );
4014 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4017 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4020 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4023 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4026 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4029 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4032 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4035 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4038 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4041 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4042 t1.setValue( "3", "2", "23" );
4043 t1.setValue( "10", "1", "error" );
4044 t1.setValue( "10", "1", "110" );
4045 t1.setValue( "9", "1", "19" );
4046 t1.setValue( "1", "10", "101" );
4047 t1.setValue( "10", "10", "1010" );
4048 t1.setValue( "100", "10", "10100" );
4049 t1.setValue( "0", "0", "00" );
4050 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4051 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4054 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4057 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4060 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4063 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4066 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4069 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4072 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4075 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4078 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4082 catch ( final Exception e ) {
4083 e.printStackTrace( System.out );
4089 private static boolean testGetDistance() {
4091 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4092 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",
4093 new NHXParser() )[ 0 ];
4094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4100 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4103 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4106 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4109 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4112 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4115 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4118 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4121 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4124 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4127 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4130 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4133 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4136 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4139 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4142 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4145 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4148 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4151 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4154 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4157 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4160 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4163 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4166 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4169 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4172 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4175 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4178 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4181 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4184 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4187 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",
4188 new NHXParser() )[ 0 ];
4189 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4192 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4195 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4198 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4201 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4204 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4207 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4210 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4213 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4216 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4219 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4223 catch ( final Exception e ) {
4224 e.printStackTrace( System.out );
4230 private static boolean testGetLCA() {
4232 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4233 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4234 new NHXParser() )[ 0 ];
4235 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4236 if ( !A.getName().equals( "A" ) ) {
4239 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4240 if ( !gh.getName().equals( "gh" ) ) {
4243 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4244 if ( !ab.getName().equals( "ab" ) ) {
4247 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4248 if ( !ab2.getName().equals( "ab" ) ) {
4251 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4252 if ( !gh2.getName().equals( "gh" ) ) {
4255 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4256 if ( !gh3.getName().equals( "gh" ) ) {
4259 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4260 if ( !abc.getName().equals( "abc" ) ) {
4263 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4264 if ( !abc2.getName().equals( "abc" ) ) {
4267 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4268 if ( !abcd.getName().equals( "abcd" ) ) {
4271 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4272 if ( !abcd2.getName().equals( "abcd" ) ) {
4275 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4276 if ( !abcdef.getName().equals( "abcdef" ) ) {
4279 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4280 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4283 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4284 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4287 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4288 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4291 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4292 if ( !abcde.getName().equals( "abcde" ) ) {
4295 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4296 if ( !abcde2.getName().equals( "abcde" ) ) {
4299 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4300 if ( !r.getName().equals( "abcdefgh" ) ) {
4303 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4304 if ( !r2.getName().equals( "abcdefgh" ) ) {
4307 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4308 if ( !r3.getName().equals( "abcdefgh" ) ) {
4311 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4312 if ( !abcde3.getName().equals( "abcde" ) ) {
4315 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4316 if ( !abcde4.getName().equals( "abcde" ) ) {
4319 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4320 if ( !ab3.getName().equals( "ab" ) ) {
4323 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4324 if ( !ab4.getName().equals( "ab" ) ) {
4327 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4328 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4329 if ( !cd.getName().equals( "cd" ) ) {
4332 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4333 if ( !cd2.getName().equals( "cd" ) ) {
4336 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4337 if ( !cde.getName().equals( "cde" ) ) {
4340 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4341 if ( !cde2.getName().equals( "cde" ) ) {
4344 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4345 if ( !cdef.getName().equals( "cdef" ) ) {
4348 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4349 if ( !cdef2.getName().equals( "cdef" ) ) {
4352 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4353 if ( !cdef3.getName().equals( "cdef" ) ) {
4356 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4357 if ( !rt.getName().equals( "r" ) ) {
4360 final Phylogeny p3 = factory
4361 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4362 new NHXParser() )[ 0 ];
4363 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4364 if ( !bc_3.getName().equals( "bc" ) ) {
4367 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4368 if ( !ac_3.getName().equals( "abc" ) ) {
4371 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4372 if ( !ad_3.getName().equals( "abcde" ) ) {
4375 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4376 if ( !af_3.getName().equals( "abcdef" ) ) {
4379 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4380 if ( !ag_3.getName().equals( "" ) ) {
4383 if ( !ag_3.isRoot() ) {
4386 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4387 if ( !al_3.getName().equals( "" ) ) {
4390 if ( !al_3.isRoot() ) {
4393 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4394 if ( !kl_3.getName().equals( "" ) ) {
4397 if ( !kl_3.isRoot() ) {
4400 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4401 if ( !fl_3.getName().equals( "" ) ) {
4404 if ( !fl_3.isRoot() ) {
4407 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4408 if ( !gk_3.getName().equals( "ghijk" ) ) {
4411 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4412 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4413 if ( !r_4.getName().equals( "r" ) ) {
4416 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4417 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4418 if ( !r_5.getName().equals( "root" ) ) {
4421 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4422 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4423 if ( !r_6.getName().equals( "rot" ) ) {
4426 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4427 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4428 if ( !r_7.getName().equals( "rott" ) ) {
4432 catch ( final Exception e ) {
4433 e.printStackTrace( System.out );
4439 private static boolean testGetLCA2() {
4441 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4442 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4443 PhylogenyMethods.preOrderReId( p_a );
4444 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4445 p_a.getNode( "a" ) );
4446 if ( !p_a_1.getName().equals( "a" ) ) {
4449 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4450 PhylogenyMethods.preOrderReId( p_b );
4451 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4452 p_b.getNode( "a" ) );
4453 if ( !p_b_1.getName().equals( "b" ) ) {
4456 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4457 p_b.getNode( "b" ) );
4458 if ( !p_b_2.getName().equals( "b" ) ) {
4461 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4462 PhylogenyMethods.preOrderReId( p_c );
4463 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4464 p_c.getNode( "a" ) );
4465 if ( !p_c_1.getName().equals( "b" ) ) {
4468 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4469 p_c.getNode( "c" ) );
4470 if ( !p_c_2.getName().equals( "c" ) ) {
4471 System.out.println( p_c_2.getName() );
4475 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4476 p_c.getNode( "b" ) );
4477 if ( !p_c_3.getName().equals( "b" ) ) {
4480 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4481 p_c.getNode( "a" ) );
4482 if ( !p_c_4.getName().equals( "c" ) ) {
4485 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4486 new NHXParser() )[ 0 ];
4487 PhylogenyMethods.preOrderReId( p1 );
4488 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4489 p1.getNode( "A" ) );
4490 if ( !A.getName().equals( "A" ) ) {
4493 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4494 p1.getNode( "gh" ) );
4495 if ( !gh.getName().equals( "gh" ) ) {
4498 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4499 p1.getNode( "B" ) );
4500 if ( !ab.getName().equals( "ab" ) ) {
4503 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4504 p1.getNode( "A" ) );
4505 if ( !ab2.getName().equals( "ab" ) ) {
4508 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4509 p1.getNode( "G" ) );
4510 if ( !gh2.getName().equals( "gh" ) ) {
4513 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4514 p1.getNode( "H" ) );
4515 if ( !gh3.getName().equals( "gh" ) ) {
4518 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4519 p1.getNode( "A" ) );
4520 if ( !abc.getName().equals( "abc" ) ) {
4523 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4524 p1.getNode( "C" ) );
4525 if ( !abc2.getName().equals( "abc" ) ) {
4528 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4529 p1.getNode( "D" ) );
4530 if ( !abcd.getName().equals( "abcd" ) ) {
4533 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4534 p1.getNode( "A" ) );
4535 if ( !abcd2.getName().equals( "abcd" ) ) {
4538 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4539 p1.getNode( "F" ) );
4540 if ( !abcdef.getName().equals( "abcdef" ) ) {
4543 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4544 p1.getNode( "A" ) );
4545 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4548 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4549 p1.getNode( "F" ) );
4550 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4553 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4554 p1.getNode( "ab" ) );
4555 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4558 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4559 p1.getNode( "E" ) );
4560 if ( !abcde.getName().equals( "abcde" ) ) {
4563 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4564 p1.getNode( "A" ) );
4565 if ( !abcde2.getName().equals( "abcde" ) ) {
4568 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4569 p1.getNode( "abcdefgh" ) );
4570 if ( !r.getName().equals( "abcdefgh" ) ) {
4573 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4574 p1.getNode( "H" ) );
4575 if ( !r2.getName().equals( "abcdefgh" ) ) {
4578 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4579 p1.getNode( "A" ) );
4580 if ( !r3.getName().equals( "abcdefgh" ) ) {
4583 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4584 p1.getNode( "abcde" ) );
4585 if ( !abcde3.getName().equals( "abcde" ) ) {
4588 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4589 p1.getNode( "E" ) );
4590 if ( !abcde4.getName().equals( "abcde" ) ) {
4593 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4594 p1.getNode( "B" ) );
4595 if ( !ab3.getName().equals( "ab" ) ) {
4598 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4599 p1.getNode( "ab" ) );
4600 if ( !ab4.getName().equals( "ab" ) ) {
4603 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4604 PhylogenyMethods.preOrderReId( p2 );
4605 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4606 p2.getNode( "d" ) );
4607 if ( !cd.getName().equals( "cd" ) ) {
4610 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4611 p2.getNode( "c" ) );
4612 if ( !cd2.getName().equals( "cd" ) ) {
4615 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4616 p2.getNode( "e" ) );
4617 if ( !cde.getName().equals( "cde" ) ) {
4620 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4621 p2.getNode( "c" ) );
4622 if ( !cde2.getName().equals( "cde" ) ) {
4625 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4626 p2.getNode( "f" ) );
4627 if ( !cdef.getName().equals( "cdef" ) ) {
4630 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4631 p2.getNode( "f" ) );
4632 if ( !cdef2.getName().equals( "cdef" ) ) {
4635 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4636 p2.getNode( "d" ) );
4637 if ( !cdef3.getName().equals( "cdef" ) ) {
4640 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4641 p2.getNode( "a" ) );
4642 if ( !rt.getName().equals( "r" ) ) {
4645 final Phylogeny p3 = factory
4646 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4647 new NHXParser() )[ 0 ];
4648 PhylogenyMethods.preOrderReId( p3 );
4649 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4650 p3.getNode( "c" ) );
4651 if ( !bc_3.getName().equals( "bc" ) ) {
4654 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4655 p3.getNode( "c" ) );
4656 if ( !ac_3.getName().equals( "abc" ) ) {
4659 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4660 p3.getNode( "d" ) );
4661 if ( !ad_3.getName().equals( "abcde" ) ) {
4664 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4665 p3.getNode( "f" ) );
4666 if ( !af_3.getName().equals( "abcdef" ) ) {
4669 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4670 p3.getNode( "g" ) );
4671 if ( !ag_3.getName().equals( "" ) ) {
4674 if ( !ag_3.isRoot() ) {
4677 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4678 p3.getNode( "l" ) );
4679 if ( !al_3.getName().equals( "" ) ) {
4682 if ( !al_3.isRoot() ) {
4685 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4686 p3.getNode( "l" ) );
4687 if ( !kl_3.getName().equals( "" ) ) {
4690 if ( !kl_3.isRoot() ) {
4693 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4694 p3.getNode( "l" ) );
4695 if ( !fl_3.getName().equals( "" ) ) {
4698 if ( !fl_3.isRoot() ) {
4701 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4702 p3.getNode( "k" ) );
4703 if ( !gk_3.getName().equals( "ghijk" ) ) {
4706 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4707 PhylogenyMethods.preOrderReId( p4 );
4708 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4709 p4.getNode( "c" ) );
4710 if ( !r_4.getName().equals( "r" ) ) {
4713 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4714 PhylogenyMethods.preOrderReId( p5 );
4715 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4716 p5.getNode( "c" ) );
4717 if ( !r_5.getName().equals( "root" ) ) {
4720 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4721 PhylogenyMethods.preOrderReId( p6 );
4722 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4723 p6.getNode( "a" ) );
4724 if ( !r_6.getName().equals( "rot" ) ) {
4727 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4728 PhylogenyMethods.preOrderReId( p7 );
4729 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4730 p7.getNode( "e" ) );
4731 if ( !r_7.getName().equals( "rott" ) ) {
4734 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4735 p7.getNode( "a" ) );
4736 if ( !r_71.getName().equals( "rott" ) ) {
4739 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4740 p7.getNode( "rott" ) );
4741 if ( !r_72.getName().equals( "rott" ) ) {
4744 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4745 p7.getNode( "a" ) );
4746 if ( !r_73.getName().equals( "rott" ) ) {
4749 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4750 p7.getNode( "rott" ) );
4751 if ( !r_74.getName().equals( "rott" ) ) {
4754 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4755 p7.getNode( "e" ) );
4756 if ( !r_75.getName().equals( "e" ) ) {
4760 catch ( final Exception e ) {
4761 e.printStackTrace( System.out );
4767 private static boolean testHmmscanOutputParser() {
4768 final String test_dir = Test.PATH_TO_TEST_DATA;
4770 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4771 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4773 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4774 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4775 final List<Protein> proteins = parser2.parse();
4776 if ( parser2.getProteinsEncountered() != 4 ) {
4779 if ( proteins.size() != 4 ) {
4782 if ( parser2.getDomainsEncountered() != 69 ) {
4785 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4788 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4791 final Protein p1 = proteins.get( 0 );
4792 if ( p1.getNumberOfProteinDomains() != 15 ) {
4795 if ( p1.getLength() != 850 ) {
4798 final Protein p2 = proteins.get( 1 );
4799 if ( p2.getNumberOfProteinDomains() != 51 ) {
4802 if ( p2.getLength() != 1291 ) {
4805 final Protein p3 = proteins.get( 2 );
4806 if ( p3.getNumberOfProteinDomains() != 2 ) {
4809 final Protein p4 = proteins.get( 3 );
4810 if ( p4.getNumberOfProteinDomains() != 1 ) {
4813 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4816 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4819 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4822 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4825 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4828 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4831 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4834 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4837 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4841 catch ( final Exception e ) {
4842 e.printStackTrace( System.out );
4848 private static boolean testLastExternalNodeMethods() {
4850 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4851 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4852 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4853 final PhylogenyNode n1 = t0.getNode( "A" );
4854 if ( n1.isLastExternalNode() ) {
4857 final PhylogenyNode n2 = t0.getNode( "B" );
4858 if ( n2.isLastExternalNode() ) {
4861 final PhylogenyNode n3 = t0.getNode( "C" );
4862 if ( n3.isLastExternalNode() ) {
4865 final PhylogenyNode n4 = t0.getNode( "D" );
4866 if ( !n4.isLastExternalNode() ) {
4870 catch ( final Exception e ) {
4871 e.printStackTrace( System.out );
4877 private static boolean testLevelOrderIterator() {
4879 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4880 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4881 PhylogenyNodeIterator it0;
4882 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4885 for( it0.reset(); it0.hasNext(); ) {
4888 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4889 if ( !it.next().getName().equals( "r" ) ) {
4892 if ( !it.next().getName().equals( "ab" ) ) {
4895 if ( !it.next().getName().equals( "cd" ) ) {
4898 if ( !it.next().getName().equals( "A" ) ) {
4901 if ( !it.next().getName().equals( "B" ) ) {
4904 if ( !it.next().getName().equals( "C" ) ) {
4907 if ( !it.next().getName().equals( "D" ) ) {
4910 if ( it.hasNext() ) {
4913 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",
4914 new NHXParser() )[ 0 ];
4915 PhylogenyNodeIterator it2;
4916 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4919 for( it2.reset(); it2.hasNext(); ) {
4922 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4923 if ( !it3.next().getName().equals( "r" ) ) {
4926 if ( !it3.next().getName().equals( "abc" ) ) {
4929 if ( !it3.next().getName().equals( "defg" ) ) {
4932 if ( !it3.next().getName().equals( "A" ) ) {
4935 if ( !it3.next().getName().equals( "B" ) ) {
4938 if ( !it3.next().getName().equals( "C" ) ) {
4941 if ( !it3.next().getName().equals( "D" ) ) {
4944 if ( !it3.next().getName().equals( "E" ) ) {
4947 if ( !it3.next().getName().equals( "F" ) ) {
4950 if ( !it3.next().getName().equals( "G" ) ) {
4953 if ( !it3.next().getName().equals( "1" ) ) {
4956 if ( !it3.next().getName().equals( "2" ) ) {
4959 if ( !it3.next().getName().equals( "3" ) ) {
4962 if ( !it3.next().getName().equals( "4" ) ) {
4965 if ( !it3.next().getName().equals( "5" ) ) {
4968 if ( !it3.next().getName().equals( "6" ) ) {
4971 if ( !it3.next().getName().equals( "f1" ) ) {
4974 if ( !it3.next().getName().equals( "f2" ) ) {
4977 if ( !it3.next().getName().equals( "f3" ) ) {
4980 if ( !it3.next().getName().equals( "a" ) ) {
4983 if ( !it3.next().getName().equals( "b" ) ) {
4986 if ( !it3.next().getName().equals( "f21" ) ) {
4989 if ( !it3.next().getName().equals( "X" ) ) {
4992 if ( !it3.next().getName().equals( "Y" ) ) {
4995 if ( !it3.next().getName().equals( "Z" ) ) {
4998 if ( it3.hasNext() ) {
5001 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5002 PhylogenyNodeIterator it4;
5003 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5006 for( it4.reset(); it4.hasNext(); ) {
5009 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5010 if ( !it5.next().getName().equals( "r" ) ) {
5013 if ( !it5.next().getName().equals( "A" ) ) {
5016 if ( !it5.next().getName().equals( "B" ) ) {
5019 if ( !it5.next().getName().equals( "C" ) ) {
5022 if ( !it5.next().getName().equals( "D" ) ) {
5025 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5026 PhylogenyNodeIterator it6;
5027 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5030 for( it6.reset(); it6.hasNext(); ) {
5033 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5034 if ( !it7.next().getName().equals( "A" ) ) {
5037 if ( it.hasNext() ) {
5041 catch ( final Exception e ) {
5042 e.printStackTrace( System.out );
5048 private static boolean testMafft( final String path ) {
5050 final List<String> opts = new ArrayList<String>();
5051 opts.add( "--maxiterate" );
5053 opts.add( "--localpair" );
5054 opts.add( "--quiet" );
5056 final MsaInferrer mafft = Mafft.createInstance( path );
5057 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5058 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5061 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5065 catch ( final Exception e ) {
5066 e.printStackTrace( System.out );
5072 private static boolean testMidpointrooting() {
5074 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5075 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5076 PhylogenyMethods.midpointRoot( t0 );
5077 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5080 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5083 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5087 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",
5088 new NHXParser() )[ 0 ];
5089 if ( !t1.isRooted() ) {
5092 PhylogenyMethods.midpointRoot( t1 );
5093 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5096 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5099 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5102 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5105 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5108 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5111 t1.reRoot( t1.getNode( "A" ) );
5112 PhylogenyMethods.midpointRoot( t1 );
5113 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5116 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5119 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5122 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5125 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5129 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5133 catch ( final Exception e ) {
5134 e.printStackTrace( System.out );
5140 private static boolean testMsaQualityMethod() {
5142 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5143 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5144 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5145 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5146 final List<Sequence> l = new ArrayList<Sequence>();
5151 final Msa msa = BasicMsa.createInstance( l );
5152 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5155 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5158 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5161 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5165 catch ( final Exception e ) {
5166 e.printStackTrace( System.out );
5172 private static boolean testNextNodeWithCollapsing() {
5174 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5176 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5177 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5178 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5179 t0.getNode( "cd" ).setCollapse( true );
5180 t0.getNode( "cde" ).setCollapse( true );
5181 n = t0.getFirstExternalNode();
5182 while ( n != null ) {
5184 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5186 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5189 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5192 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5195 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5198 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5201 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5205 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5206 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5207 t1.getNode( "ab" ).setCollapse( true );
5208 t1.getNode( "cd" ).setCollapse( true );
5209 t1.getNode( "cde" ).setCollapse( true );
5210 n = t1.getNode( "ab" );
5211 ext = new ArrayList<PhylogenyNode>();
5212 while ( n != null ) {
5214 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5216 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5219 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5222 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5225 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5228 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5234 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5235 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5236 t2.getNode( "ab" ).setCollapse( true );
5237 t2.getNode( "cd" ).setCollapse( true );
5238 t2.getNode( "cde" ).setCollapse( true );
5239 t2.getNode( "c" ).setCollapse( true );
5240 t2.getNode( "d" ).setCollapse( true );
5241 t2.getNode( "e" ).setCollapse( true );
5242 t2.getNode( "gh" ).setCollapse( true );
5243 n = t2.getNode( "ab" );
5244 ext = new ArrayList<PhylogenyNode>();
5245 while ( n != null ) {
5247 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5249 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5252 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5255 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5258 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5264 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5265 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5266 t3.getNode( "ab" ).setCollapse( true );
5267 t3.getNode( "cd" ).setCollapse( true );
5268 t3.getNode( "cde" ).setCollapse( true );
5269 t3.getNode( "c" ).setCollapse( true );
5270 t3.getNode( "d" ).setCollapse( true );
5271 t3.getNode( "e" ).setCollapse( true );
5272 t3.getNode( "gh" ).setCollapse( true );
5273 t3.getNode( "fgh" ).setCollapse( true );
5274 n = t3.getNode( "ab" );
5275 ext = new ArrayList<PhylogenyNode>();
5276 while ( n != null ) {
5278 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5280 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5283 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5286 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5292 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5293 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5294 t4.getNode( "ab" ).setCollapse( true );
5295 t4.getNode( "cd" ).setCollapse( true );
5296 t4.getNode( "cde" ).setCollapse( true );
5297 t4.getNode( "c" ).setCollapse( true );
5298 t4.getNode( "d" ).setCollapse( true );
5299 t4.getNode( "e" ).setCollapse( true );
5300 t4.getNode( "gh" ).setCollapse( true );
5301 t4.getNode( "fgh" ).setCollapse( true );
5302 t4.getNode( "abcdefgh" ).setCollapse( true );
5303 n = t4.getNode( "abcdefgh" );
5304 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5309 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5310 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5312 n = t5.getFirstExternalNode();
5313 while ( n != null ) {
5315 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5317 if ( ext.size() != 8 ) {
5320 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5323 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5326 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5329 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5332 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5335 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5338 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5341 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5346 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5347 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5349 t6.getNode( "ab" ).setCollapse( true );
5350 n = t6.getNode( "ab" );
5351 while ( n != null ) {
5353 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5355 if ( ext.size() != 7 ) {
5358 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5361 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5364 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5367 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5370 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5373 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5376 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5381 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5382 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5384 t7.getNode( "cd" ).setCollapse( true );
5385 n = t7.getNode( "a" );
5386 while ( n != null ) {
5388 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5390 if ( ext.size() != 7 ) {
5393 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5396 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5399 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5402 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5405 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5408 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5411 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5416 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5417 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5419 t8.getNode( "cd" ).setCollapse( true );
5420 t8.getNode( "c" ).setCollapse( true );
5421 t8.getNode( "d" ).setCollapse( true );
5422 n = t8.getNode( "a" );
5423 while ( n != null ) {
5425 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5427 if ( ext.size() != 7 ) {
5430 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5433 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5436 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5437 System.out.println( "2 fail" );
5440 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5443 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5446 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5449 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5454 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5455 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5457 t9.getNode( "gh" ).setCollapse( true );
5458 n = t9.getNode( "a" );
5459 while ( n != null ) {
5461 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5463 if ( ext.size() != 7 ) {
5466 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5469 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5472 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5475 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5478 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5481 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5484 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5489 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5490 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5492 t10.getNode( "gh" ).setCollapse( true );
5493 t10.getNode( "g" ).setCollapse( true );
5494 t10.getNode( "h" ).setCollapse( true );
5495 n = t10.getNode( "a" );
5496 while ( n != null ) {
5498 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5500 if ( ext.size() != 7 ) {
5503 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5506 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5509 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5512 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5515 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5518 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5521 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5526 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5527 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5529 t11.getNode( "gh" ).setCollapse( true );
5530 t11.getNode( "fgh" ).setCollapse( true );
5531 n = t11.getNode( "a" );
5532 while ( n != null ) {
5534 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5536 if ( ext.size() != 6 ) {
5539 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5542 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5545 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5548 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5551 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5554 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5559 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5560 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5562 t12.getNode( "gh" ).setCollapse( true );
5563 t12.getNode( "fgh" ).setCollapse( true );
5564 t12.getNode( "g" ).setCollapse( true );
5565 t12.getNode( "h" ).setCollapse( true );
5566 t12.getNode( "f" ).setCollapse( true );
5567 n = t12.getNode( "a" );
5568 while ( n != null ) {
5570 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5572 if ( ext.size() != 6 ) {
5575 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5578 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5581 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5584 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5587 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5590 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5595 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5596 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5598 t13.getNode( "ab" ).setCollapse( true );
5599 t13.getNode( "b" ).setCollapse( true );
5600 t13.getNode( "fgh" ).setCollapse( true );
5601 t13.getNode( "gh" ).setCollapse( true );
5602 n = t13.getNode( "ab" );
5603 while ( n != null ) {
5605 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5607 if ( ext.size() != 5 ) {
5610 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5613 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5616 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5619 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5622 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5627 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5628 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5630 t14.getNode( "ab" ).setCollapse( true );
5631 t14.getNode( "a" ).setCollapse( true );
5632 t14.getNode( "fgh" ).setCollapse( true );
5633 t14.getNode( "gh" ).setCollapse( true );
5634 n = t14.getNode( "ab" );
5635 while ( n != null ) {
5637 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5639 if ( ext.size() != 5 ) {
5642 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5645 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5648 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5651 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5654 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5659 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" );
5660 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5662 t15.getNode( "ab" ).setCollapse( true );
5663 t15.getNode( "a" ).setCollapse( true );
5664 t15.getNode( "fgh" ).setCollapse( true );
5665 t15.getNode( "gh" ).setCollapse( true );
5666 n = t15.getNode( "ab" );
5667 while ( n != null ) {
5669 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5671 if ( ext.size() != 6 ) {
5674 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5677 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5680 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5683 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5686 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5689 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5694 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" );
5695 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5697 t16.getNode( "ab" ).setCollapse( true );
5698 t16.getNode( "a" ).setCollapse( true );
5699 t16.getNode( "fgh" ).setCollapse( true );
5700 t16.getNode( "gh" ).setCollapse( true );
5701 t16.getNode( "cd" ).setCollapse( true );
5702 t16.getNode( "cde" ).setCollapse( true );
5703 t16.getNode( "d" ).setCollapse( true );
5704 t16.getNode( "x" ).setCollapse( true );
5705 n = t16.getNode( "ab" );
5706 while ( n != null ) {
5708 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5710 if ( ext.size() != 4 ) {
5713 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5716 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5719 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5722 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5726 catch ( final Exception e ) {
5727 e.printStackTrace( System.out );
5733 private static boolean testNexusCharactersParsing() {
5735 final NexusCharactersParser parser = new NexusCharactersParser();
5736 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5738 String[] labels = parser.getCharStateLabels();
5739 if ( labels.length != 7 ) {
5742 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5745 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5748 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5751 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5754 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5757 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5760 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5763 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5765 labels = parser.getCharStateLabels();
5766 if ( labels.length != 7 ) {
5769 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5772 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5775 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5778 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5781 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5784 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5787 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5791 catch ( final Exception e ) {
5792 e.printStackTrace( System.out );
5798 private static boolean testNexusMatrixParsing() {
5800 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5801 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5803 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5804 if ( m.getNumberOfCharacters() != 9 ) {
5807 if ( m.getNumberOfIdentifiers() != 5 ) {
5810 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5813 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5816 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5819 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5822 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5825 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5828 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5831 // if ( labels.length != 7 ) {
5834 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5837 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5840 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5843 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5846 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5849 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5852 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5855 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5857 // labels = parser.getCharStateLabels();
5858 // if ( labels.length != 7 ) {
5861 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5864 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5867 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5870 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5873 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5876 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5879 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5883 catch ( final Exception e ) {
5884 e.printStackTrace( System.out );
5890 private static boolean testNexusTreeParsing() {
5892 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5893 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5894 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5895 if ( phylogenies.length != 1 ) {
5898 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5901 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5905 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5906 if ( phylogenies.length != 1 ) {
5909 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5912 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5916 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5917 if ( phylogenies.length != 1 ) {
5920 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5923 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5926 if ( phylogenies[ 0 ].isRooted() ) {
5930 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5931 if ( phylogenies.length != 18 ) {
5934 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5937 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5940 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5943 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5946 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5949 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5952 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5955 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5958 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5961 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5964 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5967 if ( phylogenies[ 8 ].isRooted() ) {
5970 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5973 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5976 if ( !phylogenies[ 9 ].isRooted() ) {
5979 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5982 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5985 if ( !phylogenies[ 10 ].isRooted() ) {
5988 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5991 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5994 if ( phylogenies[ 11 ].isRooted() ) {
5997 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6000 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6003 if ( !phylogenies[ 12 ].isRooted() ) {
6006 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6009 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6012 if ( !phylogenies[ 13 ].isRooted() ) {
6015 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6018 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6021 if ( !phylogenies[ 14 ].isRooted() ) {
6024 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6027 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6030 if ( phylogenies[ 15 ].isRooted() ) {
6033 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6036 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6039 if ( !phylogenies[ 16 ].isRooted() ) {
6042 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6045 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6048 if ( phylogenies[ 17 ].isRooted() ) {
6051 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6055 catch ( final Exception e ) {
6056 e.printStackTrace( System.out );
6062 private static boolean testNexusTreeParsingIterating() {
6064 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6065 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6066 if ( !p.hasNext() ) {
6069 Phylogeny phy = p.next();
6070 if ( phy == null ) {
6073 if ( phy.getNumberOfExternalNodes() != 25 ) {
6076 if ( !phy.getName().equals( "" ) ) {
6079 if ( p.hasNext() ) {
6083 if ( phy != null ) {
6088 if ( !p.hasNext() ) {
6092 if ( phy == null ) {
6095 if ( phy.getNumberOfExternalNodes() != 25 ) {
6098 if ( !phy.getName().equals( "" ) ) {
6101 if ( p.hasNext() ) {
6105 if ( phy != null ) {
6109 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6110 if ( !p.hasNext() ) {
6114 if ( phy == null ) {
6117 if ( phy.getNumberOfExternalNodes() != 10 ) {
6120 if ( !phy.getName().equals( "name" ) ) {
6123 if ( p.hasNext() ) {
6127 if ( phy != null ) {
6132 if ( !p.hasNext() ) {
6136 if ( phy == null ) {
6139 if ( phy.getNumberOfExternalNodes() != 10 ) {
6142 if ( !phy.getName().equals( "name" ) ) {
6145 if ( p.hasNext() ) {
6149 if ( phy != null ) {
6153 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6154 if ( !p.hasNext() ) {
6158 if ( phy == null ) {
6161 if ( phy.getNumberOfExternalNodes() != 3 ) {
6164 if ( !phy.getName().equals( "" ) ) {
6167 if ( phy.isRooted() ) {
6170 if ( p.hasNext() ) {
6174 if ( phy != null ) {
6179 if ( !p.hasNext() ) {
6183 if ( phy == null ) {
6186 if ( phy.getNumberOfExternalNodes() != 3 ) {
6189 if ( !phy.getName().equals( "" ) ) {
6192 if ( p.hasNext() ) {
6196 if ( phy != null ) {
6200 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6201 // if ( phylogenies.length != 18 ) {
6205 if ( !p.hasNext() ) {
6209 if ( phy == null ) {
6212 if ( phy.getNumberOfExternalNodes() != 10 ) {
6215 if ( !phy.getName().equals( "tree 0" ) ) {
6219 if ( !p.hasNext() ) {
6223 if ( phy == null ) {
6226 if ( phy.getNumberOfExternalNodes() != 10 ) {
6229 if ( !phy.getName().equals( "tree 1" ) ) {
6233 if ( !p.hasNext() ) {
6237 if ( phy == null ) {
6240 if ( phy.getNumberOfExternalNodes() != 3 ) {
6243 if ( !phy.getName().equals( "" ) ) {
6246 if ( phy.isRooted() ) {
6250 if ( !p.hasNext() ) {
6254 if ( phy == null ) {
6257 if ( phy.getNumberOfExternalNodes() != 4 ) {
6260 if ( !phy.getName().equals( "" ) ) {
6263 if ( !phy.isRooted() ) {
6267 if ( !p.hasNext() ) {
6271 if ( phy == null ) {
6274 if ( phy.getNumberOfExternalNodes() != 5 ) {
6275 System.out.println( phy.getNumberOfExternalNodes() );
6278 if ( !phy.getName().equals( "" ) ) {
6281 if ( !phy.isRooted() ) {
6285 if ( !p.hasNext() ) {
6289 if ( phy == null ) {
6292 if ( phy.getNumberOfExternalNodes() != 3 ) {
6295 if ( !phy.getName().equals( "" ) ) {
6298 if ( phy.isRooted() ) {
6302 if ( !p.hasNext() ) {
6306 if ( phy == null ) {
6309 if ( phy.getNumberOfExternalNodes() != 2 ) {
6312 if ( !phy.getName().equals( "" ) ) {
6315 if ( !phy.isRooted() ) {
6319 if ( !p.hasNext() ) {
6323 if ( phy.getNumberOfExternalNodes() != 3 ) {
6326 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6329 if ( !phy.isRooted() ) {
6333 if ( !p.hasNext() ) {
6337 if ( phy.getNumberOfExternalNodes() != 3 ) {
6340 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6343 if ( !phy.getName().equals( "tree 8" ) ) {
6347 if ( !p.hasNext() ) {
6351 if ( phy.getNumberOfExternalNodes() != 3 ) {
6354 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6357 if ( !phy.getName().equals( "tree 9" ) ) {
6361 if ( !p.hasNext() ) {
6365 if ( phy.getNumberOfExternalNodes() != 3 ) {
6368 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6371 if ( !phy.getName().equals( "tree 10" ) ) {
6374 if ( !phy.isRooted() ) {
6378 if ( !p.hasNext() ) {
6382 if ( phy.getNumberOfExternalNodes() != 3 ) {
6385 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6388 if ( !phy.getName().equals( "tree 11" ) ) {
6391 if ( phy.isRooted() ) {
6395 if ( !p.hasNext() ) {
6399 if ( phy.getNumberOfExternalNodes() != 3 ) {
6402 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6405 if ( !phy.getName().equals( "tree 12" ) ) {
6408 if ( !phy.isRooted() ) {
6412 if ( !p.hasNext() ) {
6416 if ( phy.getNumberOfExternalNodes() != 3 ) {
6419 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6422 if ( !phy.getName().equals( "tree 13" ) ) {
6425 if ( !phy.isRooted() ) {
6429 if ( !p.hasNext() ) {
6433 if ( phy.getNumberOfExternalNodes() != 10 ) {
6434 System.out.println( phy.getNumberOfExternalNodes() );
6439 .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;" ) ) {
6440 System.out.println( phy.toNewHampshire() );
6443 if ( !phy.getName().equals( "tree 14" ) ) {
6446 if ( !phy.isRooted() ) {
6450 if ( !p.hasNext() ) {
6454 if ( phy.getNumberOfExternalNodes() != 10 ) {
6455 System.out.println( phy.getNumberOfExternalNodes() );
6460 .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;" ) ) {
6461 System.out.println( phy.toNewHampshire() );
6464 if ( !phy.getName().equals( "tree 15" ) ) {
6467 if ( phy.isRooted() ) {
6471 if ( !p.hasNext() ) {
6475 if ( phy.getNumberOfExternalNodes() != 10 ) {
6476 System.out.println( phy.getNumberOfExternalNodes() );
6481 .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;" ) ) {
6482 System.out.println( phy.toNewHampshire() );
6485 if ( !phy.getName().equals( "tree 16" ) ) {
6488 if ( !phy.isRooted() ) {
6492 if ( !p.hasNext() ) {
6496 if ( phy.getNumberOfExternalNodes() != 10 ) {
6497 System.out.println( phy.getNumberOfExternalNodes() );
6502 .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;" ) ) {
6503 System.out.println( phy.toNewHampshire() );
6506 if ( !phy.getName().equals( "tree 17" ) ) {
6509 if ( phy.isRooted() ) {
6513 if ( p.hasNext() ) {
6517 if ( phy != null ) {
6522 if ( !p.hasNext() ) {
6526 if ( phy == null ) {
6529 if ( phy.getNumberOfExternalNodes() != 10 ) {
6532 if ( !phy.getName().equals( "tree 0" ) ) {
6536 if ( !p.hasNext() ) {
6540 if ( phy == null ) {
6543 if ( phy.getNumberOfExternalNodes() != 10 ) {
6546 if ( !phy.getName().equals( "tree 1" ) ) {
6550 if ( !p.hasNext() ) {
6554 if ( phy == null ) {
6557 if ( phy.getNumberOfExternalNodes() != 3 ) {
6560 if ( !phy.getName().equals( "" ) ) {
6563 if ( phy.isRooted() ) {
6567 if ( !p.hasNext() ) {
6571 if ( phy == null ) {
6574 if ( phy.getNumberOfExternalNodes() != 4 ) {
6577 if ( !phy.getName().equals( "" ) ) {
6580 if ( !phy.isRooted() ) {
6584 if ( !p.hasNext() ) {
6588 if ( phy == null ) {
6591 if ( phy.getNumberOfExternalNodes() != 5 ) {
6592 System.out.println( phy.getNumberOfExternalNodes() );
6595 if ( !phy.getName().equals( "" ) ) {
6598 if ( !phy.isRooted() ) {
6602 if ( !p.hasNext() ) {
6606 if ( phy == null ) {
6609 if ( phy.getNumberOfExternalNodes() != 3 ) {
6612 if ( !phy.getName().equals( "" ) ) {
6615 if ( phy.isRooted() ) {
6619 catch ( final Exception e ) {
6620 e.printStackTrace( System.out );
6626 private static boolean testNexusTreeParsingTranslating() {
6628 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6629 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6630 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6631 if ( phylogenies.length != 1 ) {
6634 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6637 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6640 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6643 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6646 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6647 .equals( "Aranaeus" ) ) {
6651 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6652 if ( phylogenies.length != 3 ) {
6655 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6658 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6661 if ( phylogenies[ 0 ].isRooted() ) {
6664 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6667 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6670 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6671 .equals( "Aranaeus" ) ) {
6674 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6677 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6680 if ( phylogenies[ 1 ].isRooted() ) {
6683 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6686 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6689 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6690 .equals( "Aranaeus" ) ) {
6693 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6696 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6699 if ( !phylogenies[ 2 ].isRooted() ) {
6702 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6705 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6708 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6709 .equals( "Aranaeus" ) ) {
6713 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6714 if ( phylogenies.length != 3 ) {
6717 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6720 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6723 if ( phylogenies[ 0 ].isRooted() ) {
6726 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6729 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6732 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6733 .equals( "Aranaeus" ) ) {
6736 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6739 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6742 if ( phylogenies[ 1 ].isRooted() ) {
6745 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6748 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6751 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6752 .equals( "Aranaeus" ) ) {
6755 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6758 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6761 if ( !phylogenies[ 2 ].isRooted() ) {
6764 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6767 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6770 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6771 .equals( "Aranaeus" ) ) {
6775 catch ( final Exception e ) {
6776 e.printStackTrace( System.out );
6782 private static boolean testNHParsing() {
6784 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6785 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6786 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6789 final NHXParser nhxp = new NHXParser();
6790 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6791 nhxp.setReplaceUnderscores( true );
6792 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6793 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6796 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6799 final Phylogeny p1b = factory
6800 .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 ",
6801 new NHXParser() )[ 0 ];
6802 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6805 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6808 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6809 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6810 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6811 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6812 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6813 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6814 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6815 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6816 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6817 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6818 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6819 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6820 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6822 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6825 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6828 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6831 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6834 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6835 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6836 final String p16_S = "((A,B),C)";
6837 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6838 if ( p16.length != 1 ) {
6841 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6844 final String p17_S = "(C,(A,B))";
6845 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6846 if ( p17.length != 1 ) {
6849 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6852 final String p18_S = "((A,B),(C,D))";
6853 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6854 if ( p18.length != 1 ) {
6857 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6860 final String p19_S = "(((A,B),C),D)";
6861 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6862 if ( p19.length != 1 ) {
6865 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6868 final String p20_S = "(A,(B,(C,D)))";
6869 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6870 if ( p20.length != 1 ) {
6873 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6876 final String p21_S = "(A,(B,(C,(D,E))))";
6877 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6878 if ( p21.length != 1 ) {
6881 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6884 final String p22_S = "((((A,B),C),D),E)";
6885 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6886 if ( p22.length != 1 ) {
6889 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6892 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6893 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6894 if ( p23.length != 1 ) {
6895 System.out.println( "xl=" + p23.length );
6899 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6902 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6903 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6904 if ( p24.length != 1 ) {
6907 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6910 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6911 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6912 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6913 if ( p241.length != 2 ) {
6916 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6919 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6922 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6923 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6924 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6925 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6926 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6927 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6928 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6929 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6930 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6931 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6934 final String p26_S = "(A,B)ab";
6935 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6936 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6939 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6940 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6941 if ( p27s.length != 1 ) {
6942 System.out.println( "xxl=" + p27s.length );
6946 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6947 System.out.println( p27s[ 0 ].toNewHampshireX() );
6951 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6953 if ( p27.length != 1 ) {
6954 System.out.println( "yl=" + p27.length );
6958 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6959 System.out.println( p27[ 0 ].toNewHampshireX() );
6963 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6964 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6965 final String p28_S3 = "(A,B)ab";
6966 final String p28_S4 = "((((A,B),C),D),;E;)";
6967 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6969 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6972 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6975 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6978 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6981 if ( p28.length != 4 ) {
6984 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";
6985 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6986 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6989 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";
6990 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6991 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6994 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6995 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6996 if ( ( p32.length != 0 ) ) {
6999 final String p33_S = "A";
7000 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7001 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7004 final String p34_S = "B;";
7005 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7006 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7009 final String p35_S = "B:0.2";
7010 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7011 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7014 final String p36_S = "(A)";
7015 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7016 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7019 final String p37_S = "((A))";
7020 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7021 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7024 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7025 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7026 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7029 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7030 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7031 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7034 final String p40_S = "(A,B,C)";
7035 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7036 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7039 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7040 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7041 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7044 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7045 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7046 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7049 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)";
7050 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7051 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7054 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)))";
7055 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7056 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7059 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7060 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7061 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7064 final String p46_S = "";
7065 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7066 if ( p46.length != 0 ) {
7069 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7070 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7073 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7074 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7077 final Phylogeny p49 = factory
7078 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7079 new NHXParser() )[ 0 ];
7080 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7083 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7084 if ( p50.getNode( "A" ) == null ) {
7087 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7088 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7091 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7094 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7095 .equals( "((A,B)88:2.0,C);" ) ) {
7098 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7099 if ( p51.getNode( "A(A" ) == null ) {
7102 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7103 if ( p52.getNode( "A(A" ) == null ) {
7106 final Phylogeny p53 = factory
7107 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7108 new NHXParser() )[ 0 ];
7109 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7113 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7114 if ( p54.getNode( "A" ) == null ) {
7117 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7118 .equals( "((A,B)[88],C);" ) ) {
7122 catch ( final Exception e ) {
7123 e.printStackTrace( System.out );
7129 private static boolean testNHParsingIter() {
7131 final String p0_str = "(A,B);";
7132 final NHXParser p = new NHXParser();
7133 p.setSource( p0_str );
7134 if ( !p.hasNext() ) {
7137 final Phylogeny p0 = p.next();
7138 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7139 System.out.println( p0.toNewHampshire() );
7142 if ( p.hasNext() ) {
7145 if ( p.next() != null ) {
7149 final String p00_str = "(A,B)root;";
7150 p.setSource( p00_str );
7151 final Phylogeny p00 = p.next();
7152 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7153 System.out.println( p00.toNewHampshire() );
7157 final String p000_str = "A;";
7158 p.setSource( p000_str );
7159 final Phylogeny p000 = p.next();
7160 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7161 System.out.println( p000.toNewHampshire() );
7165 final String p0000_str = "A";
7166 p.setSource( p0000_str );
7167 final Phylogeny p0000 = p.next();
7168 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7169 System.out.println( p0000.toNewHampshire() );
7173 p.setSource( "(A)" );
7174 final Phylogeny p00000 = p.next();
7175 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7176 System.out.println( p00000.toNewHampshire() );
7180 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7181 p.setSource( p1_str );
7182 if ( !p.hasNext() ) {
7185 final Phylogeny p1_0 = p.next();
7186 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7187 System.out.println( p1_0.toNewHampshire() );
7190 if ( !p.hasNext() ) {
7193 final Phylogeny p1_1 = p.next();
7194 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7195 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7198 if ( !p.hasNext() ) {
7201 final Phylogeny p1_2 = p.next();
7202 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7203 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7206 if ( !p.hasNext() ) {
7209 final Phylogeny p1_3 = p.next();
7210 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7211 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7214 if ( p.hasNext() ) {
7217 if ( p.next() != null ) {
7221 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7222 p.setSource( p2_str );
7223 if ( !p.hasNext() ) {
7226 Phylogeny p2_0 = p.next();
7227 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7228 System.out.println( p2_0.toNewHampshire() );
7231 if ( !p.hasNext() ) {
7234 Phylogeny p2_1 = p.next();
7235 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7236 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7239 if ( !p.hasNext() ) {
7242 Phylogeny p2_2 = p.next();
7243 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7244 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7247 if ( !p.hasNext() ) {
7250 Phylogeny p2_3 = p.next();
7251 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7252 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7255 if ( !p.hasNext() ) {
7258 Phylogeny p2_4 = p.next();
7259 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7260 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7263 if ( p.hasNext() ) {
7266 if ( p.next() != null ) {
7271 if ( !p.hasNext() ) {
7275 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7276 System.out.println( p2_0.toNewHampshire() );
7279 if ( !p.hasNext() ) {
7283 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7284 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7287 if ( !p.hasNext() ) {
7291 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7292 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7295 if ( !p.hasNext() ) {
7299 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7300 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7303 if ( !p.hasNext() ) {
7307 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7308 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7311 if ( p.hasNext() ) {
7314 if ( p.next() != null ) {
7318 final String p3_str = "((A,B),C)abc";
7319 p.setSource( p3_str );
7320 if ( !p.hasNext() ) {
7323 final Phylogeny p3_0 = p.next();
7324 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7327 if ( p.hasNext() ) {
7330 if ( p.next() != null ) {
7334 final String p4_str = "((A,B)ab,C)abc";
7335 p.setSource( p4_str );
7336 if ( !p.hasNext() ) {
7339 final Phylogeny p4_0 = p.next();
7340 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7343 if ( p.hasNext() ) {
7346 if ( p.next() != null ) {
7350 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7351 p.setSource( p5_str );
7352 if ( !p.hasNext() ) {
7355 final Phylogeny p5_0 = p.next();
7356 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7359 if ( p.hasNext() ) {
7362 if ( p.next() != null ) {
7366 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7367 p.setSource( p6_str );
7368 if ( !p.hasNext() ) {
7371 Phylogeny p6_0 = p.next();
7372 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7375 if ( p.hasNext() ) {
7378 if ( p.next() != null ) {
7382 if ( !p.hasNext() ) {
7386 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7389 if ( p.hasNext() ) {
7392 if ( p.next() != null ) {
7396 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7397 p.setSource( p7_str );
7398 if ( !p.hasNext() ) {
7401 Phylogeny p7_0 = p.next();
7402 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7405 if ( p.hasNext() ) {
7408 if ( p.next() != null ) {
7412 if ( !p.hasNext() ) {
7416 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7419 if ( p.hasNext() ) {
7422 if ( p.next() != null ) {
7426 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7427 p.setSource( p8_str );
7428 if ( !p.hasNext() ) {
7431 Phylogeny p8_0 = p.next();
7432 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7435 if ( !p.hasNext() ) {
7438 if ( !p.hasNext() ) {
7441 Phylogeny p8_1 = p.next();
7442 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7445 if ( p.hasNext() ) {
7448 if ( p.next() != null ) {
7452 if ( !p.hasNext() ) {
7456 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7459 if ( !p.hasNext() ) {
7463 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7466 if ( p.hasNext() ) {
7469 if ( p.next() != null ) {
7475 if ( p.hasNext() ) {
7479 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7480 if ( !p.hasNext() ) {
7483 Phylogeny p_27 = p.next();
7484 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7485 System.out.println( p_27.toNewHampshireX() );
7489 if ( p.hasNext() ) {
7492 if ( p.next() != null ) {
7496 if ( !p.hasNext() ) {
7500 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7501 System.out.println( p_27.toNewHampshireX() );
7505 if ( p.hasNext() ) {
7508 if ( p.next() != null ) {
7512 catch ( final Exception e ) {
7513 e.printStackTrace( System.out );
7519 private static boolean testNHXconversion() {
7521 final PhylogenyNode n1 = new PhylogenyNode();
7522 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7523 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7524 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7525 final PhylogenyNode n5 = PhylogenyNode
7526 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7527 final PhylogenyNode n6 = PhylogenyNode
7528 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7529 if ( !n1.toNewHampshireX().equals( "" ) ) {
7532 if ( !n2.toNewHampshireX().equals( "" ) ) {
7535 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7538 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7541 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7544 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7545 System.out.println( n6.toNewHampshireX() );
7549 catch ( final Exception e ) {
7550 e.printStackTrace( System.out );
7556 private static boolean testNHXNodeParsing() {
7558 final PhylogenyNode n1 = new PhylogenyNode();
7559 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7560 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7561 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7562 final PhylogenyNode n5 = PhylogenyNode
7563 .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]" );
7564 if ( !n3.getName().equals( "n3" ) ) {
7567 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7570 if ( n3.isDuplication() ) {
7573 if ( n3.isHasAssignedEvent() ) {
7576 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7579 if ( !n4.getName().equals( "n4" ) ) {
7582 if ( n4.getDistanceToParent() != 0.01 ) {
7585 if ( !n5.getName().equals( "n5" ) ) {
7588 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7591 if ( n5.getDistanceToParent() != 0.1 ) {
7594 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7597 if ( !n5.isDuplication() ) {
7600 if ( !n5.isHasAssignedEvent() ) {
7603 final PhylogenyNode n8 = PhylogenyNode
7604 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7605 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7606 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7609 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7612 final PhylogenyNode n9 = PhylogenyNode
7613 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7614 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7615 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7618 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7621 final PhylogenyNode n10 = PhylogenyNode
7622 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7623 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7626 final PhylogenyNode n20 = PhylogenyNode
7627 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7628 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7631 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7634 final PhylogenyNode n20x = PhylogenyNode
7635 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7636 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7639 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7642 final PhylogenyNode n20xx = PhylogenyNode
7643 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7644 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7647 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7650 final PhylogenyNode n20xxx = PhylogenyNode
7651 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7652 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7655 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7658 final PhylogenyNode n20xxxx = PhylogenyNode
7659 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7660 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7663 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7666 final PhylogenyNode n21 = PhylogenyNode
7667 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7668 if ( !n21.getName().equals( "N21_PIG" ) ) {
7671 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7674 final PhylogenyNode n21x = PhylogenyNode
7675 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7676 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7679 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7682 final PhylogenyNode n22 = PhylogenyNode
7683 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7684 if ( !n22.getName().equals( "n22/PIG" ) ) {
7687 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7690 final PhylogenyNode n23 = PhylogenyNode
7691 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7692 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7695 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7698 final PhylogenyNode a = PhylogenyNode
7699 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7700 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7703 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7706 final PhylogenyNode c1 = PhylogenyNode
7707 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7708 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7709 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7712 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7715 final PhylogenyNode c2 = PhylogenyNode
7716 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7717 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7718 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7721 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7724 final PhylogenyNode e3 = PhylogenyNode
7725 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7726 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7729 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7732 final PhylogenyNode n11 = PhylogenyNode
7733 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7734 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7735 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7738 if ( n11.getDistanceToParent() != 0.4 ) {
7741 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7744 final PhylogenyNode n12 = PhylogenyNode
7745 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7746 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7747 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7750 if ( n12.getDistanceToParent() != 0.4 ) {
7753 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7756 final PhylogenyNode o = PhylogenyNode
7757 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7758 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7761 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7764 if ( n1.getName().compareTo( "" ) != 0 ) {
7767 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7770 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7773 if ( n2.getName().compareTo( "" ) != 0 ) {
7776 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7779 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7782 final PhylogenyNode n00 = PhylogenyNode
7783 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7784 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7787 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7790 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7791 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7794 final PhylogenyNode n13 = PhylogenyNode
7795 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7796 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7799 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7802 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7805 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7808 final PhylogenyNode n14 = PhylogenyNode
7809 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7810 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7813 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7816 final PhylogenyNode n15 = PhylogenyNode
7817 .createInstanceFromNhxString( "something_wicked[123]",
7818 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7819 if ( !n15.getName().equals( "something_wicked" ) ) {
7822 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7825 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7828 final PhylogenyNode n16 = PhylogenyNode
7829 .createInstanceFromNhxString( "something_wicked2[9]",
7830 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7831 if ( !n16.getName().equals( "something_wicked2" ) ) {
7834 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7837 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7840 final PhylogenyNode n17 = PhylogenyNode
7841 .createInstanceFromNhxString( "something_wicked3[a]",
7842 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7843 if ( !n17.getName().equals( "something_wicked3" ) ) {
7846 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7849 final PhylogenyNode n18 = PhylogenyNode
7850 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7851 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7854 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7857 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7860 final PhylogenyNode n19 = PhylogenyNode
7861 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7862 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7865 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7868 final PhylogenyNode n30 = PhylogenyNode
7869 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7870 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7871 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7874 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7877 final PhylogenyNode n31 = PhylogenyNode
7878 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7879 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7880 if ( n31.getNodeData().isHasTaxonomy() ) {
7883 final PhylogenyNode n32 = PhylogenyNode
7884 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7885 if ( n32.getNodeData().isHasTaxonomy() ) {
7888 final PhylogenyNode n40 = PhylogenyNode
7889 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7890 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7893 final PhylogenyNode n41 = PhylogenyNode
7894 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7895 if ( n41.getNodeData().isHasTaxonomy() ) {
7898 final PhylogenyNode n42 = PhylogenyNode
7899 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7900 if ( n42.getNodeData().isHasTaxonomy() ) {
7903 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7904 NHXParser.TAXONOMY_EXTRACTION.NO );
7905 if ( n43.getNodeData().isHasTaxonomy() ) {
7908 final PhylogenyNode n44 = PhylogenyNode
7909 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7910 if ( n44.getNodeData().isHasTaxonomy() ) {
7914 catch ( final Exception e ) {
7915 e.printStackTrace( System.out );
7921 private static boolean testNHXParsing() {
7923 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7924 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7925 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7928 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]";
7929 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7930 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7933 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]";
7934 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7935 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7938 final Phylogeny[] p3 = factory
7939 .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]",
7941 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7944 final Phylogeny[] p4 = factory
7945 .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(]",
7947 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7950 final Phylogeny[] p5 = factory
7951 .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(((]",
7953 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7956 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)";
7957 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)";
7958 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7959 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7962 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)))";
7963 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)))";
7964 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7965 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7968 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]) ))[,,, ])))))))";
7969 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7970 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7971 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7974 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7975 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7978 final Phylogeny p10 = factory
7979 .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]",
7980 new NHXParser() )[ 0 ];
7981 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7985 catch ( final Exception e ) {
7986 e.printStackTrace( System.out );
7992 private static boolean testNHXParsingMB() {
7994 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7995 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7996 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7997 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7998 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7999 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8000 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8001 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8002 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8003 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8004 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8007 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8010 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8011 0.1100000000000000e+00 ) ) {
8014 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8017 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8020 final Phylogeny p2 = factory
8021 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8022 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8023 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8024 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8025 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8026 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8027 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8028 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8029 + "7.369400000000000e-02}])",
8030 new NHXParser() )[ 0 ];
8031 if ( p2.getNode( "1" ) == null ) {
8034 if ( p2.getNode( "2" ) == null ) {
8038 catch ( final Exception e ) {
8039 e.printStackTrace( System.out );
8046 private static boolean testNHXParsingQuotes() {
8048 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8049 final NHXParser p = new NHXParser();
8050 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8051 if ( phylogenies_0.length != 5 ) {
8054 final Phylogeny phy = phylogenies_0[ 4 ];
8055 if ( phy.getNumberOfExternalNodes() != 7 ) {
8058 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8061 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8064 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8065 .getScientificName().equals( "hsapiens" ) ) {
8068 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8071 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8074 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8077 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8080 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8083 final NHXParser p1p = new NHXParser();
8084 p1p.setIgnoreQuotes( true );
8085 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8086 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8089 final NHXParser p2p = new NHXParser();
8090 p1p.setIgnoreQuotes( false );
8091 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8092 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8095 final NHXParser p3p = new NHXParser();
8096 p3p.setIgnoreQuotes( false );
8097 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8098 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8101 final NHXParser p4p = new NHXParser();
8102 p4p.setIgnoreQuotes( false );
8103 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8104 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8107 final Phylogeny p10 = factory
8108 .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]",
8109 new NHXParser() )[ 0 ];
8110 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]";
8111 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8114 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8115 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8119 final Phylogeny p12 = factory
8120 .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]",
8121 new NHXParser() )[ 0 ];
8122 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]";
8123 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8126 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8127 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8130 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;";
8131 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8134 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8135 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8139 catch ( final Exception e ) {
8140 e.printStackTrace( System.out );
8146 private static boolean testNodeRemoval() {
8148 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8149 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8150 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8151 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8154 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8155 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8156 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8159 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8160 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8161 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8165 catch ( final Exception e ) {
8166 e.printStackTrace( System.out );
8172 private static boolean testPhylogenyBranch() {
8174 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8175 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8176 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8177 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8178 if ( !a1b1.equals( a1b1 ) ) {
8181 if ( !a1b1.equals( b1a1 ) ) {
8184 if ( !b1a1.equals( a1b1 ) ) {
8187 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8188 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8189 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8190 if ( a1_b1.equals( b1_a1 ) ) {
8193 if ( a1_b1.equals( a1_b1_ ) ) {
8196 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8197 if ( !a1_b1.equals( b1_a1_ ) ) {
8200 if ( a1_b1_.equals( b1_a1_ ) ) {
8203 if ( !a1_b1_.equals( b1_a1 ) ) {
8207 catch ( final Exception e ) {
8208 e.printStackTrace( System.out );
8214 private static boolean testPhyloXMLparsingOfDistributionElement() {
8216 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8217 PhyloXmlParser xml_parser = null;
8219 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8221 catch ( final Exception e ) {
8222 // Do nothing -- means were not running from jar.
8224 if ( xml_parser == null ) {
8225 xml_parser = new PhyloXmlParser();
8226 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8227 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8230 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8233 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8235 if ( xml_parser.getErrorCount() > 0 ) {
8236 System.out.println( xml_parser.getErrorMessages().toString() );
8239 if ( phylogenies_0.length != 1 ) {
8242 final Phylogeny t1 = phylogenies_0[ 0 ];
8243 PhylogenyNode n = null;
8244 Distribution d = null;
8245 n = t1.getNode( "root node" );
8246 if ( !n.getNodeData().isHasDistribution() ) {
8249 if ( n.getNodeData().getDistributions().size() != 1 ) {
8252 d = n.getNodeData().getDistribution();
8253 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8256 if ( d.getPoints().size() != 1 ) {
8259 if ( d.getPolygons() != null ) {
8262 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8265 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8268 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8271 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8274 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8277 n = t1.getNode( "node a" );
8278 if ( !n.getNodeData().isHasDistribution() ) {
8281 if ( n.getNodeData().getDistributions().size() != 2 ) {
8284 d = n.getNodeData().getDistribution( 1 );
8285 if ( !d.getDesc().equals( "San Diego" ) ) {
8288 if ( d.getPoints().size() != 1 ) {
8291 if ( d.getPolygons() != null ) {
8294 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8297 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8300 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8303 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8306 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8309 n = t1.getNode( "node bb" );
8310 if ( !n.getNodeData().isHasDistribution() ) {
8313 if ( n.getNodeData().getDistributions().size() != 1 ) {
8316 d = n.getNodeData().getDistribution( 0 );
8317 if ( d.getPoints().size() != 3 ) {
8320 if ( d.getPolygons().size() != 2 ) {
8323 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8326 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8329 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8332 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8335 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8338 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8341 Polygon p = d.getPolygons().get( 0 );
8342 if ( p.getPoints().size() != 3 ) {
8345 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8348 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8351 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8354 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8357 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8360 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8363 p = d.getPolygons().get( 1 );
8364 if ( p.getPoints().size() != 3 ) {
8367 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8370 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8373 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8377 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8378 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8379 if ( rt.length != 1 ) {
8382 final Phylogeny t1_rt = rt[ 0 ];
8383 n = t1_rt.getNode( "root node" );
8384 if ( !n.getNodeData().isHasDistribution() ) {
8387 if ( n.getNodeData().getDistributions().size() != 1 ) {
8390 d = n.getNodeData().getDistribution();
8391 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8394 if ( d.getPoints().size() != 1 ) {
8397 if ( d.getPolygons() != null ) {
8400 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8403 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8406 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8409 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8412 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8415 n = t1_rt.getNode( "node a" );
8416 if ( !n.getNodeData().isHasDistribution() ) {
8419 if ( n.getNodeData().getDistributions().size() != 2 ) {
8422 d = n.getNodeData().getDistribution( 1 );
8423 if ( !d.getDesc().equals( "San Diego" ) ) {
8426 if ( d.getPoints().size() != 1 ) {
8429 if ( d.getPolygons() != null ) {
8432 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8435 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8438 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8441 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8444 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8447 n = t1_rt.getNode( "node bb" );
8448 if ( !n.getNodeData().isHasDistribution() ) {
8451 if ( n.getNodeData().getDistributions().size() != 1 ) {
8454 d = n.getNodeData().getDistribution( 0 );
8455 if ( d.getPoints().size() != 3 ) {
8458 if ( d.getPolygons().size() != 2 ) {
8461 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8464 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8467 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8470 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8473 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8476 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8479 p = d.getPolygons().get( 0 );
8480 if ( p.getPoints().size() != 3 ) {
8483 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8486 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8489 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8492 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8495 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8498 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8501 p = d.getPolygons().get( 1 );
8502 if ( p.getPoints().size() != 3 ) {
8505 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8508 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8511 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8515 catch ( final Exception e ) {
8516 e.printStackTrace( System.out );
8522 private static boolean testPostOrderIterator() {
8524 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8525 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8526 PhylogenyNodeIterator it0;
8527 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8530 for( it0.reset(); it0.hasNext(); ) {
8533 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8534 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8535 if ( !it.next().getName().equals( "A" ) ) {
8538 if ( !it.next().getName().equals( "B" ) ) {
8541 if ( !it.next().getName().equals( "ab" ) ) {
8544 if ( !it.next().getName().equals( "C" ) ) {
8547 if ( !it.next().getName().equals( "D" ) ) {
8550 if ( !it.next().getName().equals( "cd" ) ) {
8553 if ( !it.next().getName().equals( "abcd" ) ) {
8556 if ( !it.next().getName().equals( "E" ) ) {
8559 if ( !it.next().getName().equals( "F" ) ) {
8562 if ( !it.next().getName().equals( "ef" ) ) {
8565 if ( !it.next().getName().equals( "G" ) ) {
8568 if ( !it.next().getName().equals( "H" ) ) {
8571 if ( !it.next().getName().equals( "gh" ) ) {
8574 if ( !it.next().getName().equals( "efgh" ) ) {
8577 if ( !it.next().getName().equals( "r" ) ) {
8580 if ( it.hasNext() ) {
8584 catch ( final Exception e ) {
8585 e.printStackTrace( System.out );
8591 private static boolean testPreOrderIterator() {
8593 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8594 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8595 PhylogenyNodeIterator it0;
8596 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8599 for( it0.reset(); it0.hasNext(); ) {
8602 PhylogenyNodeIterator it = t0.iteratorPreorder();
8603 if ( !it.next().getName().equals( "r" ) ) {
8606 if ( !it.next().getName().equals( "ab" ) ) {
8609 if ( !it.next().getName().equals( "A" ) ) {
8612 if ( !it.next().getName().equals( "B" ) ) {
8615 if ( !it.next().getName().equals( "cd" ) ) {
8618 if ( !it.next().getName().equals( "C" ) ) {
8621 if ( !it.next().getName().equals( "D" ) ) {
8624 if ( it.hasNext() ) {
8627 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8628 it = t1.iteratorPreorder();
8629 if ( !it.next().getName().equals( "r" ) ) {
8632 if ( !it.next().getName().equals( "abcd" ) ) {
8635 if ( !it.next().getName().equals( "ab" ) ) {
8638 if ( !it.next().getName().equals( "A" ) ) {
8641 if ( !it.next().getName().equals( "B" ) ) {
8644 if ( !it.next().getName().equals( "cd" ) ) {
8647 if ( !it.next().getName().equals( "C" ) ) {
8650 if ( !it.next().getName().equals( "D" ) ) {
8653 if ( !it.next().getName().equals( "efgh" ) ) {
8656 if ( !it.next().getName().equals( "ef" ) ) {
8659 if ( !it.next().getName().equals( "E" ) ) {
8662 if ( !it.next().getName().equals( "F" ) ) {
8665 if ( !it.next().getName().equals( "gh" ) ) {
8668 if ( !it.next().getName().equals( "G" ) ) {
8671 if ( !it.next().getName().equals( "H" ) ) {
8674 if ( it.hasNext() ) {
8678 catch ( final Exception e ) {
8679 e.printStackTrace( System.out );
8685 private static boolean testPropertiesMap() {
8687 final PropertiesMap pm = new PropertiesMap();
8688 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8689 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8690 final Property p2 = new Property( "something:else",
8692 "improbable:research",
8695 pm.addProperty( p0 );
8696 pm.addProperty( p1 );
8697 pm.addProperty( p2 );
8698 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8701 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8704 if ( pm.getProperties().size() != 3 ) {
8707 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8710 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8713 if ( pm.getProperties().size() != 3 ) {
8716 pm.removeProperty( "dimensions:diameter" );
8717 if ( pm.getProperties().size() != 2 ) {
8720 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8723 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8727 catch ( final Exception e ) {
8728 e.printStackTrace( System.out );
8734 private static boolean testProteinId() {
8736 final ProteinId id1 = new ProteinId( "a" );
8737 final ProteinId id2 = new ProteinId( "a" );
8738 final ProteinId id3 = new ProteinId( "A" );
8739 final ProteinId id4 = new ProteinId( "b" );
8740 if ( !id1.equals( id1 ) ) {
8743 if ( id1.getId().equals( "x" ) ) {
8746 if ( id1.getId().equals( null ) ) {
8749 if ( !id1.equals( id2 ) ) {
8752 if ( id1.equals( id3 ) ) {
8755 if ( id1.hashCode() != id1.hashCode() ) {
8758 if ( id1.hashCode() != id2.hashCode() ) {
8761 if ( id1.hashCode() == id3.hashCode() ) {
8764 if ( id1.compareTo( id1 ) != 0 ) {
8767 if ( id1.compareTo( id2 ) != 0 ) {
8770 if ( id1.compareTo( id3 ) != 0 ) {
8773 if ( id1.compareTo( id4 ) >= 0 ) {
8776 if ( id4.compareTo( id1 ) <= 0 ) {
8779 if ( !id4.getId().equals( "b" ) ) {
8782 final ProteinId id5 = new ProteinId( " C " );
8783 if ( !id5.getId().equals( "C" ) ) {
8786 if ( id5.equals( id1 ) ) {
8790 catch ( final Exception e ) {
8791 e.printStackTrace( System.out );
8797 private static boolean testReIdMethods() {
8799 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8800 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8801 final long count = PhylogenyNode.getNodeCount();
8803 if ( p.getNode( "r" ).getId() != count ) {
8806 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8809 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8812 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8815 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8818 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8821 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8824 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8827 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8830 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8833 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8836 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8839 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8842 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8845 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8849 catch ( final Exception e ) {
8850 e.printStackTrace( System.out );
8856 private static boolean testRerooting() {
8858 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8859 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",
8860 new NHXParser() )[ 0 ];
8861 if ( !t1.isRooted() ) {
8864 t1.reRoot( t1.getNode( "D" ) );
8865 t1.reRoot( t1.getNode( "CD" ) );
8866 t1.reRoot( t1.getNode( "A" ) );
8867 t1.reRoot( t1.getNode( "B" ) );
8868 t1.reRoot( t1.getNode( "AB" ) );
8869 t1.reRoot( t1.getNode( "D" ) );
8870 t1.reRoot( t1.getNode( "C" ) );
8871 t1.reRoot( t1.getNode( "CD" ) );
8872 t1.reRoot( t1.getNode( "A" ) );
8873 t1.reRoot( t1.getNode( "B" ) );
8874 t1.reRoot( t1.getNode( "AB" ) );
8875 t1.reRoot( t1.getNode( "D" ) );
8876 t1.reRoot( t1.getNode( "D" ) );
8877 t1.reRoot( t1.getNode( "C" ) );
8878 t1.reRoot( t1.getNode( "A" ) );
8879 t1.reRoot( t1.getNode( "B" ) );
8880 t1.reRoot( t1.getNode( "AB" ) );
8881 t1.reRoot( t1.getNode( "C" ) );
8882 t1.reRoot( t1.getNode( "D" ) );
8883 t1.reRoot( t1.getNode( "CD" ) );
8884 t1.reRoot( t1.getNode( "D" ) );
8885 t1.reRoot( t1.getNode( "A" ) );
8886 t1.reRoot( t1.getNode( "B" ) );
8887 t1.reRoot( t1.getNode( "AB" ) );
8888 t1.reRoot( t1.getNode( "C" ) );
8889 t1.reRoot( t1.getNode( "D" ) );
8890 t1.reRoot( t1.getNode( "CD" ) );
8891 t1.reRoot( t1.getNode( "D" ) );
8892 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8895 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8898 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8901 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8904 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8907 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8910 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",
8911 new NHXParser() )[ 0 ];
8912 t2.reRoot( t2.getNode( "A" ) );
8913 t2.reRoot( t2.getNode( "D" ) );
8914 t2.reRoot( t2.getNode( "ABC" ) );
8915 t2.reRoot( t2.getNode( "A" ) );
8916 t2.reRoot( t2.getNode( "B" ) );
8917 t2.reRoot( t2.getNode( "D" ) );
8918 t2.reRoot( t2.getNode( "C" ) );
8919 t2.reRoot( t2.getNode( "ABC" ) );
8920 t2.reRoot( t2.getNode( "A" ) );
8921 t2.reRoot( t2.getNode( "B" ) );
8922 t2.reRoot( t2.getNode( "AB" ) );
8923 t2.reRoot( t2.getNode( "AB" ) );
8924 t2.reRoot( t2.getNode( "D" ) );
8925 t2.reRoot( t2.getNode( "C" ) );
8926 t2.reRoot( t2.getNode( "B" ) );
8927 t2.reRoot( t2.getNode( "AB" ) );
8928 t2.reRoot( t2.getNode( "D" ) );
8929 t2.reRoot( t2.getNode( "D" ) );
8930 t2.reRoot( t2.getNode( "ABC" ) );
8931 t2.reRoot( t2.getNode( "A" ) );
8932 t2.reRoot( t2.getNode( "B" ) );
8933 t2.reRoot( t2.getNode( "AB" ) );
8934 t2.reRoot( t2.getNode( "D" ) );
8935 t2.reRoot( t2.getNode( "C" ) );
8936 t2.reRoot( t2.getNode( "ABC" ) );
8937 t2.reRoot( t2.getNode( "A" ) );
8938 t2.reRoot( t2.getNode( "B" ) );
8939 t2.reRoot( t2.getNode( "AB" ) );
8940 t2.reRoot( t2.getNode( "D" ) );
8941 t2.reRoot( t2.getNode( "D" ) );
8942 t2.reRoot( t2.getNode( "C" ) );
8943 t2.reRoot( t2.getNode( "A" ) );
8944 t2.reRoot( t2.getNode( "B" ) );
8945 t2.reRoot( t2.getNode( "AB" ) );
8946 t2.reRoot( t2.getNode( "C" ) );
8947 t2.reRoot( t2.getNode( "D" ) );
8948 t2.reRoot( t2.getNode( "ABC" ) );
8949 t2.reRoot( t2.getNode( "D" ) );
8950 t2.reRoot( t2.getNode( "A" ) );
8951 t2.reRoot( t2.getNode( "B" ) );
8952 t2.reRoot( t2.getNode( "AB" ) );
8953 t2.reRoot( t2.getNode( "C" ) );
8954 t2.reRoot( t2.getNode( "D" ) );
8955 t2.reRoot( t2.getNode( "ABC" ) );
8956 t2.reRoot( t2.getNode( "D" ) );
8957 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8960 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8963 t2.reRoot( t2.getNode( "ABC" ) );
8964 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8967 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8970 t2.reRoot( t2.getNode( "AB" ) );
8971 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8974 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8977 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8980 t2.reRoot( t2.getNode( "AB" ) );
8981 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8984 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8987 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8990 t2.reRoot( t2.getNode( "D" ) );
8991 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8994 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8997 t2.reRoot( t2.getNode( "ABC" ) );
8998 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9001 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9004 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9005 new NHXParser() )[ 0 ];
9006 t3.reRoot( t3.getNode( "B" ) );
9007 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9010 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9013 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9016 t3.reRoot( t3.getNode( "B" ) );
9017 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9020 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9023 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9026 t3.reRoot( t3.getRoot() );
9027 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9030 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9033 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9037 catch ( final Exception e ) {
9038 e.printStackTrace( System.out );
9044 private static boolean testSDIse() {
9046 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9047 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9048 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9049 gene1.setRooted( true );
9050 species1.setRooted( true );
9051 final SDI sdi = new SDI( gene1, species1 );
9052 if ( !gene1.getRoot().isDuplication() ) {
9055 final Phylogeny species2 = factory
9056 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9057 new NHXParser() )[ 0 ];
9058 final Phylogeny gene2 = factory
9059 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9060 new NHXParser() )[ 0 ];
9061 species2.setRooted( true );
9062 gene2.setRooted( true );
9063 final SDI sdi2 = new SDI( gene2, species2 );
9064 if ( sdi2.getDuplicationsSum() != 0 ) {
9067 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9070 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9073 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9076 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9079 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9082 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9085 final Phylogeny species3 = factory
9086 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9087 new NHXParser() )[ 0 ];
9088 final Phylogeny gene3 = factory
9089 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9090 new NHXParser() )[ 0 ];
9091 species3.setRooted( true );
9092 gene3.setRooted( true );
9093 final SDI sdi3 = new SDI( gene3, species3 );
9094 if ( sdi3.getDuplicationsSum() != 1 ) {
9097 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9100 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9103 final Phylogeny species4 = factory
9104 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9105 new NHXParser() )[ 0 ];
9106 final Phylogeny gene4 = factory
9107 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9108 new NHXParser() )[ 0 ];
9109 species4.setRooted( true );
9110 gene4.setRooted( true );
9111 final SDI sdi4 = new SDI( gene4, species4 );
9112 if ( sdi4.getDuplicationsSum() != 1 ) {
9115 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9118 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9121 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9124 if ( species4.getNumberOfExternalNodes() != 6 ) {
9127 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9130 final Phylogeny species5 = factory
9131 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9132 new NHXParser() )[ 0 ];
9133 final Phylogeny gene5 = factory
9134 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9135 new NHXParser() )[ 0 ];
9136 species5.setRooted( true );
9137 gene5.setRooted( true );
9138 final SDI sdi5 = new SDI( gene5, species5 );
9139 if ( sdi5.getDuplicationsSum() != 2 ) {
9142 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9145 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9148 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9151 if ( species5.getNumberOfExternalNodes() != 6 ) {
9154 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9157 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9158 // Conjecture for Comparing Molecular Phylogenies"
9159 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9160 final Phylogeny species6 = factory
9161 .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,"
9162 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9163 new NHXParser() )[ 0 ];
9164 final Phylogeny gene6 = factory
9165 .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,"
9166 + "((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,"
9167 + "(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;",
9168 new NHXParser() )[ 0 ];
9169 species6.setRooted( true );
9170 gene6.setRooted( true );
9171 final SDI sdi6 = new SDI( gene6, species6 );
9172 if ( sdi6.getDuplicationsSum() != 3 ) {
9175 if ( !gene6.getNode( "r" ).isDuplication() ) {
9178 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9181 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9184 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9187 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9190 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9193 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9196 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9199 sdi6.computeMappingCostL();
9200 if ( sdi6.computeMappingCostL() != 17 ) {
9203 if ( species6.getNumberOfExternalNodes() != 9 ) {
9206 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9209 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9210 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9211 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9212 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9213 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9214 species7.setRooted( true );
9215 final Phylogeny gene7_1 = Test
9216 .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])" );
9217 gene7_1.setRooted( true );
9218 final SDI sdi7 = new SDI( gene7_1, species7 );
9219 if ( sdi7.getDuplicationsSum() != 0 ) {
9222 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9225 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9228 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9231 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9234 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9237 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9240 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9243 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9246 final Phylogeny gene7_2 = Test
9247 .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])" );
9248 gene7_2.setRooted( true );
9249 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9250 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9253 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9256 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9259 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9262 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9265 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9268 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9271 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9274 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9277 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9281 catch ( final Exception e ) {
9287 private static boolean testSDIunrooted() {
9289 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9290 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9291 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9292 final Iterator<PhylogenyBranch> iter = l.iterator();
9293 PhylogenyBranch br = iter.next();
9294 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9297 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9301 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9304 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9308 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9311 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9315 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9318 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9322 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9325 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9329 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9332 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9336 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9339 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9343 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9346 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9350 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9353 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9357 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9360 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9364 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9367 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9371 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9374 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9378 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9381 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9385 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9388 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9392 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9395 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9398 if ( iter.hasNext() ) {
9401 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9402 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9403 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9405 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9408 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9412 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9415 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9419 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9422 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9425 if ( iter1.hasNext() ) {
9428 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9429 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9430 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9432 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9435 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9439 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9442 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9446 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9449 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9452 if ( iter2.hasNext() ) {
9455 final Phylogeny species0 = factory
9456 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9457 new NHXParser() )[ 0 ];
9458 final Phylogeny gene1 = factory
9459 .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])",
9460 new NHXParser() )[ 0 ];
9461 species0.setRooted( true );
9462 gene1.setRooted( true );
9463 final SDIR sdi_unrooted = new SDIR();
9464 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9465 if ( sdi_unrooted.getCount() != 1 ) {
9468 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9471 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9474 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9477 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9480 final Phylogeny gene2 = factory
9481 .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])",
9482 new NHXParser() )[ 0 ];
9483 gene2.setRooted( true );
9484 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9485 if ( sdi_unrooted.getCount() != 1 ) {
9488 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9491 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9494 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9497 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9500 final Phylogeny species6 = factory
9501 .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,"
9502 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9503 new NHXParser() )[ 0 ];
9504 final Phylogeny gene6 = factory
9505 .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],"
9506 + "(((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],"
9507 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9508 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9509 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9510 new NHXParser() )[ 0 ];
9511 species6.setRooted( true );
9512 gene6.setRooted( true );
9513 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9514 if ( sdi_unrooted.getCount() != 1 ) {
9517 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9520 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9523 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9526 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9529 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9532 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9535 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9538 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9541 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9544 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9547 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9550 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9554 final Phylogeny species7 = factory
9555 .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,"
9556 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9557 new NHXParser() )[ 0 ];
9558 final Phylogeny gene7 = factory
9559 .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],"
9560 + "(((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],"
9561 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9562 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9563 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9564 new NHXParser() )[ 0 ];
9565 species7.setRooted( true );
9566 gene7.setRooted( true );
9567 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9568 if ( sdi_unrooted.getCount() != 1 ) {
9571 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9574 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9577 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9580 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9583 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9586 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9589 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9592 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9595 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9598 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9601 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9604 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9608 final Phylogeny species8 = factory
9609 .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,"
9610 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9611 new NHXParser() )[ 0 ];
9612 final Phylogeny gene8 = factory
9613 .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],"
9614 + "(((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],"
9615 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9616 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9617 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9618 new NHXParser() )[ 0 ];
9619 species8.setRooted( true );
9620 gene8.setRooted( true );
9621 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9622 if ( sdi_unrooted.getCount() != 1 ) {
9625 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9628 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9631 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9634 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9637 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9640 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9643 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9646 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9649 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9652 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9655 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9658 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9663 catch ( final Exception e ) {
9664 e.printStackTrace( System.out );
9670 private static boolean testSequenceIdParsing() {
9672 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
9673 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9674 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9676 System.out.println( "value =" + id.getValue() );
9677 System.out.println( "provider=" + id.getSource() );
9682 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
9683 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9684 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9686 System.out.println( "value =" + id.getValue() );
9687 System.out.println( "provider=" + id.getSource() );
9692 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
9693 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9694 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9696 System.out.println( "value =" + id.getValue() );
9697 System.out.println( "provider=" + id.getSource() );
9702 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
9703 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9704 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
9706 System.out.println( "value =" + id.getValue() );
9707 System.out.println( "provider=" + id.getSource() );
9712 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
9713 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9714 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
9716 System.out.println( "value =" + id.getValue() );
9717 System.out.println( "provider=" + id.getSource() );
9722 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
9723 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9724 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
9726 System.out.println( "value =" + id.getValue() );
9727 System.out.println( "provider=" + id.getSource() );
9732 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
9733 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9734 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
9736 System.out.println( "value =" + id.getValue() );
9737 System.out.println( "provider=" + id.getSource() );
9742 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
9743 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9744 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9746 System.out.println( "value =" + id.getValue() );
9747 System.out.println( "provider=" + id.getSource() );
9752 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
9753 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9754 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9756 System.out.println( "value =" + id.getValue() );
9757 System.out.println( "provider=" + id.getSource() );
9762 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
9763 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9764 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
9766 System.out.println( "value =" + id.getValue() );
9767 System.out.println( "provider=" + id.getSource() );
9771 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
9773 System.out.println( "value =" + id.getValue() );
9774 System.out.println( "provider=" + id.getSource() );
9778 catch ( final Exception e ) {
9779 e.printStackTrace( System.out );
9785 private static boolean testSequenceWriter() {
9787 final String n = ForesterUtil.LINE_SEPARATOR;
9788 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9791 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9794 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9797 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9800 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9801 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9804 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9805 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9809 catch ( final Exception e ) {
9810 e.printStackTrace();
9816 private static boolean testSpecies() {
9818 final Species s1 = new BasicSpecies( "a" );
9819 final Species s2 = new BasicSpecies( "a" );
9820 final Species s3 = new BasicSpecies( "A" );
9821 final Species s4 = new BasicSpecies( "b" );
9822 if ( !s1.equals( s1 ) ) {
9825 if ( s1.getSpeciesId().equals( "x" ) ) {
9828 if ( s1.getSpeciesId().equals( null ) ) {
9831 if ( !s1.equals( s2 ) ) {
9834 if ( s1.equals( s3 ) ) {
9837 if ( s1.hashCode() != s1.hashCode() ) {
9840 if ( s1.hashCode() != s2.hashCode() ) {
9843 if ( s1.hashCode() == s3.hashCode() ) {
9846 if ( s1.compareTo( s1 ) != 0 ) {
9849 if ( s1.compareTo( s2 ) != 0 ) {
9852 if ( s1.compareTo( s3 ) != 0 ) {
9855 if ( s1.compareTo( s4 ) >= 0 ) {
9858 if ( s4.compareTo( s1 ) <= 0 ) {
9861 if ( !s4.getSpeciesId().equals( "b" ) ) {
9864 final Species s5 = new BasicSpecies( " C " );
9865 if ( !s5.getSpeciesId().equals( "C" ) ) {
9868 if ( s5.equals( s1 ) ) {
9872 catch ( final Exception e ) {
9873 e.printStackTrace( System.out );
9879 private static boolean testSplit() {
9881 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9882 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9883 //Archaeopteryx.createApplication( p0 );
9884 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9885 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9886 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9887 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9888 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9889 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9890 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9891 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9892 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9893 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9894 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9895 // System.out.println( s0.toString() );
9897 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9900 if ( s0.match( query_nodes ) ) {
9903 query_nodes = new HashSet<PhylogenyNode>();
9904 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9911 if ( !s0.match( query_nodes ) ) {
9915 query_nodes = new HashSet<PhylogenyNode>();
9916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9919 if ( !s0.match( query_nodes ) ) {
9923 query_nodes = new HashSet<PhylogenyNode>();
9924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9928 if ( !s0.match( query_nodes ) ) {
9932 query_nodes = new HashSet<PhylogenyNode>();
9933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9935 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9937 if ( !s0.match( query_nodes ) ) {
9941 query_nodes = new HashSet<PhylogenyNode>();
9942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9943 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9944 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9945 if ( !s0.match( query_nodes ) ) {
9949 query_nodes = new HashSet<PhylogenyNode>();
9950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9951 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9952 if ( !s0.match( query_nodes ) ) {
9956 query_nodes = new HashSet<PhylogenyNode>();
9957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9960 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9962 if ( !s0.match( query_nodes ) ) {
9966 query_nodes = new HashSet<PhylogenyNode>();
9967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9970 if ( !s0.match( query_nodes ) ) {
9974 query_nodes = new HashSet<PhylogenyNode>();
9975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9978 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9979 if ( !s0.match( query_nodes ) ) {
9983 query_nodes = new HashSet<PhylogenyNode>();
9984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9986 if ( s0.match( query_nodes ) ) {
9990 query_nodes = new HashSet<PhylogenyNode>();
9991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9995 if ( s0.match( query_nodes ) ) {
9999 query_nodes = new HashSet<PhylogenyNode>();
10000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10004 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10005 if ( s0.match( query_nodes ) ) {
10009 query_nodes = new HashSet<PhylogenyNode>();
10010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10013 if ( s0.match( query_nodes ) ) {
10017 query_nodes = new HashSet<PhylogenyNode>();
10018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10020 if ( s0.match( query_nodes ) ) {
10024 query_nodes = new HashSet<PhylogenyNode>();
10025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10027 if ( s0.match( query_nodes ) ) {
10031 query_nodes = new HashSet<PhylogenyNode>();
10032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10034 if ( s0.match( query_nodes ) ) {
10038 query_nodes = new HashSet<PhylogenyNode>();
10039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10041 if ( s0.match( query_nodes ) ) {
10045 query_nodes = new HashSet<PhylogenyNode>();
10046 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10048 if ( s0.match( query_nodes ) ) {
10052 query_nodes = new HashSet<PhylogenyNode>();
10053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10055 if ( s0.match( query_nodes ) ) {
10059 query_nodes = new HashSet<PhylogenyNode>();
10060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10063 if ( s0.match( query_nodes ) ) {
10067 query_nodes = new HashSet<PhylogenyNode>();
10068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10071 if ( s0.match( query_nodes ) ) {
10075 query_nodes = new HashSet<PhylogenyNode>();
10076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10077 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10079 if ( s0.match( query_nodes ) ) {
10083 query_nodes = new HashSet<PhylogenyNode>();
10084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10085 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10088 if ( s0.match( query_nodes ) ) {
10092 // query_nodes = new HashSet<PhylogenyNode>();
10093 // query_nodes.add( new PhylogenyNode( "X" ) );
10094 // query_nodes.add( new PhylogenyNode( "Y" ) );
10095 // query_nodes.add( new PhylogenyNode( "A" ) );
10096 // query_nodes.add( new PhylogenyNode( "B" ) );
10097 // query_nodes.add( new PhylogenyNode( "C" ) );
10098 // query_nodes.add( new PhylogenyNode( "D" ) );
10099 // query_nodes.add( new PhylogenyNode( "E" ) );
10100 // query_nodes.add( new PhylogenyNode( "F" ) );
10101 // query_nodes.add( new PhylogenyNode( "G" ) );
10102 // if ( !s0.match( query_nodes ) ) {
10105 // query_nodes = new HashSet<PhylogenyNode>();
10106 // query_nodes.add( new PhylogenyNode( "X" ) );
10107 // query_nodes.add( new PhylogenyNode( "Y" ) );
10108 // query_nodes.add( new PhylogenyNode( "A" ) );
10109 // query_nodes.add( new PhylogenyNode( "B" ) );
10110 // query_nodes.add( new PhylogenyNode( "C" ) );
10111 // if ( !s0.match( query_nodes ) ) {
10115 // query_nodes = new HashSet<PhylogenyNode>();
10116 // query_nodes.add( new PhylogenyNode( "X" ) );
10117 // query_nodes.add( new PhylogenyNode( "Y" ) );
10118 // query_nodes.add( new PhylogenyNode( "D" ) );
10119 // query_nodes.add( new PhylogenyNode( "E" ) );
10120 // query_nodes.add( new PhylogenyNode( "F" ) );
10121 // query_nodes.add( new PhylogenyNode( "G" ) );
10122 // if ( !s0.match( query_nodes ) ) {
10126 // query_nodes = new HashSet<PhylogenyNode>();
10127 // query_nodes.add( new PhylogenyNode( "X" ) );
10128 // query_nodes.add( new PhylogenyNode( "Y" ) );
10129 // query_nodes.add( new PhylogenyNode( "A" ) );
10130 // query_nodes.add( new PhylogenyNode( "B" ) );
10131 // query_nodes.add( new PhylogenyNode( "C" ) );
10132 // query_nodes.add( new PhylogenyNode( "D" ) );
10133 // if ( !s0.match( query_nodes ) ) {
10137 // query_nodes = new HashSet<PhylogenyNode>();
10138 // query_nodes.add( new PhylogenyNode( "X" ) );
10139 // query_nodes.add( new PhylogenyNode( "Y" ) );
10140 // query_nodes.add( new PhylogenyNode( "E" ) );
10141 // query_nodes.add( new PhylogenyNode( "F" ) );
10142 // query_nodes.add( new PhylogenyNode( "G" ) );
10143 // if ( !s0.match( query_nodes ) ) {
10147 // query_nodes = new HashSet<PhylogenyNode>();
10148 // query_nodes.add( new PhylogenyNode( "X" ) );
10149 // query_nodes.add( new PhylogenyNode( "Y" ) );
10150 // query_nodes.add( new PhylogenyNode( "F" ) );
10151 // query_nodes.add( new PhylogenyNode( "G" ) );
10152 // if ( !s0.match( query_nodes ) ) {
10156 query_nodes = new HashSet<PhylogenyNode>();
10157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10161 if ( s0.match( query_nodes ) ) {
10165 query_nodes = new HashSet<PhylogenyNode>();
10166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10170 if ( s0.match( query_nodes ) ) {
10173 ///////////////////////////
10175 query_nodes = new HashSet<PhylogenyNode>();
10176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10180 if ( s0.match( query_nodes ) ) {
10184 query_nodes = new HashSet<PhylogenyNode>();
10185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10187 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10188 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10189 if ( s0.match( query_nodes ) ) {
10193 query_nodes = new HashSet<PhylogenyNode>();
10194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10198 if ( s0.match( query_nodes ) ) {
10202 query_nodes = new HashSet<PhylogenyNode>();
10203 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10207 if ( s0.match( query_nodes ) ) {
10211 query_nodes = new HashSet<PhylogenyNode>();
10212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10215 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10216 if ( s0.match( query_nodes ) ) {
10220 query_nodes = new HashSet<PhylogenyNode>();
10221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10224 if ( s0.match( query_nodes ) ) {
10228 query_nodes = new HashSet<PhylogenyNode>();
10229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10234 if ( s0.match( query_nodes ) ) {
10238 query_nodes = new HashSet<PhylogenyNode>();
10239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10244 if ( s0.match( query_nodes ) ) {
10248 query_nodes = new HashSet<PhylogenyNode>();
10249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10254 if ( s0.match( query_nodes ) ) {
10258 query_nodes = new HashSet<PhylogenyNode>();
10259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10264 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10265 if ( s0.match( query_nodes ) ) {
10269 catch ( final Exception e ) {
10270 e.printStackTrace();
10276 private static boolean testSplitStrict() {
10278 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10279 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10280 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10281 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10282 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10283 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10284 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10285 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10286 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10287 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10288 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10289 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10292 if ( s0.match( query_nodes ) ) {
10295 query_nodes = new HashSet<PhylogenyNode>();
10296 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10303 if ( !s0.match( query_nodes ) ) {
10307 query_nodes = new HashSet<PhylogenyNode>();
10308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10311 if ( !s0.match( query_nodes ) ) {
10315 query_nodes = new HashSet<PhylogenyNode>();
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10320 if ( !s0.match( query_nodes ) ) {
10324 query_nodes = new HashSet<PhylogenyNode>();
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10329 if ( !s0.match( query_nodes ) ) {
10333 query_nodes = new HashSet<PhylogenyNode>();
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10337 if ( !s0.match( query_nodes ) ) {
10341 query_nodes = new HashSet<PhylogenyNode>();
10342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10344 if ( !s0.match( query_nodes ) ) {
10348 query_nodes = new HashSet<PhylogenyNode>();
10349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10354 if ( !s0.match( query_nodes ) ) {
10358 query_nodes = new HashSet<PhylogenyNode>();
10359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10362 if ( !s0.match( query_nodes ) ) {
10366 query_nodes = new HashSet<PhylogenyNode>();
10367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10370 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10371 if ( !s0.match( query_nodes ) ) {
10375 query_nodes = new HashSet<PhylogenyNode>();
10376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10378 if ( s0.match( query_nodes ) ) {
10382 query_nodes = new HashSet<PhylogenyNode>();
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10387 if ( s0.match( query_nodes ) ) {
10391 query_nodes = new HashSet<PhylogenyNode>();
10392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10397 if ( s0.match( query_nodes ) ) {
10401 query_nodes = new HashSet<PhylogenyNode>();
10402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10405 if ( s0.match( query_nodes ) ) {
10409 query_nodes = new HashSet<PhylogenyNode>();
10410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10412 if ( s0.match( query_nodes ) ) {
10416 query_nodes = new HashSet<PhylogenyNode>();
10417 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10418 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10419 if ( s0.match( query_nodes ) ) {
10423 query_nodes = new HashSet<PhylogenyNode>();
10424 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10425 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10426 if ( s0.match( query_nodes ) ) {
10430 query_nodes = new HashSet<PhylogenyNode>();
10431 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10432 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10433 if ( s0.match( query_nodes ) ) {
10437 query_nodes = new HashSet<PhylogenyNode>();
10438 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10439 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10440 if ( s0.match( query_nodes ) ) {
10444 query_nodes = new HashSet<PhylogenyNode>();
10445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10446 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10447 if ( s0.match( query_nodes ) ) {
10451 query_nodes = new HashSet<PhylogenyNode>();
10452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10455 if ( s0.match( query_nodes ) ) {
10459 query_nodes = new HashSet<PhylogenyNode>();
10460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10463 if ( s0.match( query_nodes ) ) {
10467 query_nodes = new HashSet<PhylogenyNode>();
10468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10469 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10471 if ( s0.match( query_nodes ) ) {
10475 query_nodes = new HashSet<PhylogenyNode>();
10476 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10480 if ( s0.match( query_nodes ) ) {
10484 catch ( final Exception e ) {
10485 e.printStackTrace();
10491 private static boolean testSubtreeDeletion() {
10493 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10494 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10495 t1.deleteSubtree( t1.getNode( "A" ), false );
10496 if ( t1.getNumberOfExternalNodes() != 5 ) {
10499 t1.toNewHampshireX();
10500 t1.deleteSubtree( t1.getNode( "E" ), false );
10501 if ( t1.getNumberOfExternalNodes() != 4 ) {
10504 t1.toNewHampshireX();
10505 t1.deleteSubtree( t1.getNode( "F" ), false );
10506 if ( t1.getNumberOfExternalNodes() != 3 ) {
10509 t1.toNewHampshireX();
10510 t1.deleteSubtree( t1.getNode( "D" ), false );
10511 t1.toNewHampshireX();
10512 if ( t1.getNumberOfExternalNodes() != 3 ) {
10515 t1.deleteSubtree( t1.getNode( "def" ), false );
10516 t1.toNewHampshireX();
10517 if ( t1.getNumberOfExternalNodes() != 2 ) {
10520 t1.deleteSubtree( t1.getNode( "B" ), false );
10521 t1.toNewHampshireX();
10522 if ( t1.getNumberOfExternalNodes() != 1 ) {
10525 t1.deleteSubtree( t1.getNode( "C" ), false );
10526 t1.toNewHampshireX();
10527 if ( t1.getNumberOfExternalNodes() != 1 ) {
10530 t1.deleteSubtree( t1.getNode( "abc" ), false );
10531 t1.toNewHampshireX();
10532 if ( t1.getNumberOfExternalNodes() != 1 ) {
10535 t1.deleteSubtree( t1.getNode( "r" ), false );
10536 if ( t1.getNumberOfExternalNodes() != 0 ) {
10539 if ( !t1.isEmpty() ) {
10542 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10543 t2.deleteSubtree( t2.getNode( "A" ), false );
10544 t2.toNewHampshireX();
10545 if ( t2.getNumberOfExternalNodes() != 5 ) {
10548 t2.deleteSubtree( t2.getNode( "abc" ), false );
10549 t2.toNewHampshireX();
10550 if ( t2.getNumberOfExternalNodes() != 3 ) {
10553 t2.deleteSubtree( t2.getNode( "def" ), false );
10554 t2.toNewHampshireX();
10555 if ( t2.getNumberOfExternalNodes() != 1 ) {
10559 catch ( final Exception e ) {
10560 e.printStackTrace( System.out );
10566 private static boolean testSupportCount() {
10568 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10569 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10570 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10571 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10572 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10573 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10574 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10576 SupportCount.count( t0_1, phylogenies_1, true, false );
10577 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10578 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10579 + "(((((A,B),C),D),E),((F,G),X))"
10580 + "(((((A,Y),B),C),D),((F,G),E))"
10581 + "(((((A,B),C),D),E),(F,G))"
10582 + "(((((A,B),C),D),E),(F,G))"
10583 + "(((((A,B),C),D),E),(F,G))"
10584 + "(((((A,B),C),D),E),(F,G),Z)"
10585 + "(((((A,B),C),D),E),(F,G))"
10586 + "((((((A,B),C),D),E),F),G)"
10587 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10589 SupportCount.count( t0_2, phylogenies_2, true, false );
10590 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10591 while ( it.hasNext() ) {
10592 final PhylogenyNode n = it.next();
10593 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10597 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10598 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10599 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10600 SupportCount.count( t0_3, phylogenies_3, true, false );
10601 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10602 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10605 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10608 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10611 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10614 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10617 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10620 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10623 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10626 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10629 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10632 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10633 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10634 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10635 SupportCount.count( t0_4, phylogenies_4, true, false );
10636 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10637 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10640 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10643 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10646 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10649 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10652 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10655 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10658 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10661 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10664 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10667 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10668 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10669 double d = SupportCount.compare( b1, a, true, true, true );
10670 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10673 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10674 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10675 d = SupportCount.compare( b2, a, true, true, true );
10676 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10679 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10680 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10681 d = SupportCount.compare( b3, a, true, true, true );
10682 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10685 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10686 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10687 d = SupportCount.compare( b4, a, true, true, false );
10688 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10692 catch ( final Exception e ) {
10693 e.printStackTrace( System.out );
10699 private static boolean testSupportTransfer() {
10701 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10702 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)",
10703 new NHXParser() )[ 0 ];
10704 final Phylogeny p2 = factory
10705 .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 ];
10706 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10709 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10712 support_transfer.moveBranchLengthsToBootstrap( p1 );
10713 support_transfer.transferSupportValues( p1, p2 );
10714 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10717 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10720 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10723 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10726 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10729 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10732 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10735 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10739 catch ( final Exception e ) {
10740 e.printStackTrace( System.out );
10746 private static boolean testTaxonomyExtraction() {
10748 final PhylogenyNode n0 = PhylogenyNode
10749 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10750 if ( n0.getNodeData().isHasTaxonomy() ) {
10753 final PhylogenyNode n1 = PhylogenyNode
10754 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10755 if ( n1.getNodeData().isHasTaxonomy() ) {
10756 System.out.println( n1.toString() );
10759 final PhylogenyNode n2x = PhylogenyNode
10760 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10761 if ( n2x.getNodeData().isHasTaxonomy() ) {
10764 final PhylogenyNode n3 = PhylogenyNode
10765 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10766 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10767 System.out.println( n3.toString() );
10770 final PhylogenyNode n4 = PhylogenyNode
10771 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10772 if ( n4.getNodeData().isHasTaxonomy() ) {
10773 System.out.println( n4.toString() );
10776 final PhylogenyNode n5 = PhylogenyNode
10777 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10778 if ( n5.getNodeData().isHasTaxonomy() ) {
10779 System.out.println( n5.toString() );
10782 final PhylogenyNode n6 = PhylogenyNode
10783 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10784 if ( n6.getNodeData().isHasTaxonomy() ) {
10785 System.out.println( n6.toString() );
10788 final PhylogenyNode n7 = PhylogenyNode
10789 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10790 if ( n7.getNodeData().isHasTaxonomy() ) {
10791 System.out.println( n7.toString() );
10794 final PhylogenyNode n8 = PhylogenyNode
10795 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10796 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10797 System.out.println( n8.toString() );
10800 final PhylogenyNode n9 = PhylogenyNode
10801 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10802 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10803 System.out.println( n9.toString() );
10806 final PhylogenyNode n10x = PhylogenyNode
10807 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10808 if ( n10x.getNodeData().isHasTaxonomy() ) {
10809 System.out.println( n10x.toString() );
10812 final PhylogenyNode n10xx = PhylogenyNode
10813 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10814 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10815 System.out.println( n10xx.toString() );
10818 final PhylogenyNode n10 = PhylogenyNode
10819 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10820 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10821 System.out.println( n10.toString() );
10824 final PhylogenyNode n11 = PhylogenyNode
10825 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10826 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10827 System.out.println( n11.toString() );
10830 final PhylogenyNode n12 = PhylogenyNode
10831 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10832 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10833 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10834 System.out.println( n12.toString() );
10837 final PhylogenyNode n13 = PhylogenyNode
10838 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10839 if ( n13.getNodeData().isHasTaxonomy() ) {
10840 System.out.println( n13.toString() );
10844 catch ( final Exception e ) {
10845 e.printStackTrace( System.out );
10851 private static boolean testTreeMethods() {
10853 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10854 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10855 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10856 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10857 System.out.println( t0.toNewHampshireX() );
10860 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10861 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10862 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10865 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10868 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10872 catch ( final Exception e ) {
10873 e.printStackTrace( System.out );
10879 private static boolean testSequenceDbWsTools1() {
10881 final PhylogenyNode n = new PhylogenyNode();
10882 n.setName( "NP_001025424" );
10883 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10884 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10885 || !acc.getValue().equals( "NP_001025424" ) ) {
10888 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10889 acc = SequenceDbWsTools.obtainSeqAccession( n );
10890 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10891 || !acc.getValue().equals( "NP_001025424" ) ) {
10894 n.setName( "NP_001025424.1" );
10895 acc = SequenceDbWsTools.obtainSeqAccession( n );
10896 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10897 || !acc.getValue().equals( "NP_001025424" ) ) {
10900 n.setName( "NM_001030253" );
10901 acc = SequenceDbWsTools.obtainSeqAccession( n );
10902 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
10903 || !acc.getValue().equals( "NM_001030253" ) ) {
10906 n.setName( "BCL2_HUMAN" );
10907 acc = SequenceDbWsTools.obtainSeqAccession( n );
10908 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10909 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10910 System.out.println( acc.toString() );
10913 n.setName( "P10415" );
10914 acc = SequenceDbWsTools.obtainSeqAccession( n );
10915 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10916 || !acc.getValue().equals( "P10415" ) ) {
10917 System.out.println( acc.toString() );
10920 n.setName( " P10415 " );
10921 acc = SequenceDbWsTools.obtainSeqAccession( n );
10922 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10923 || !acc.getValue().equals( "P10415" ) ) {
10924 System.out.println( acc.toString() );
10927 n.setName( "_P10415|" );
10928 acc = SequenceDbWsTools.obtainSeqAccession( n );
10929 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
10930 || !acc.getValue().equals( "P10415" ) ) {
10931 System.out.println( acc.toString() );
10934 n.setName( "AY695820" );
10935 acc = SequenceDbWsTools.obtainSeqAccession( n );
10936 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10937 || !acc.getValue().equals( "AY695820" ) ) {
10938 System.out.println( acc.toString() );
10941 n.setName( "_AY695820_" );
10942 acc = SequenceDbWsTools.obtainSeqAccession( n );
10943 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10944 || !acc.getValue().equals( "AY695820" ) ) {
10945 System.out.println( acc.toString() );
10948 n.setName( "AAA59452" );
10949 acc = SequenceDbWsTools.obtainSeqAccession( n );
10950 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10951 || !acc.getValue().equals( "AAA59452" ) ) {
10952 System.out.println( acc.toString() );
10955 n.setName( "_AAA59452_" );
10956 acc = SequenceDbWsTools.obtainSeqAccession( n );
10957 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10958 || !acc.getValue().equals( "AAA59452" ) ) {
10959 System.out.println( acc.toString() );
10962 n.setName( "AAA59452.1" );
10963 acc = SequenceDbWsTools.obtainSeqAccession( n );
10964 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10965 || !acc.getValue().equals( "AAA59452.1" ) ) {
10966 System.out.println( acc.toString() );
10969 n.setName( "_AAA59452.1_" );
10970 acc = SequenceDbWsTools.obtainSeqAccession( n );
10971 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
10972 || !acc.getValue().equals( "AAA59452.1" ) ) {
10973 System.out.println( acc.toString() );
10976 n.setName( "GI:94894583" );
10977 acc = SequenceDbWsTools.obtainSeqAccession( n );
10978 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
10979 || !acc.getValue().equals( "94894583" ) ) {
10980 System.out.println( acc.toString() );
10984 catch ( final Exception e ) {
10990 private static boolean testSequenceDbWsTools2() {
10992 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
10993 SequenceDbWsTools.obtainSeqInformation( n1 );
10994 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10997 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11000 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11003 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11006 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11007 SequenceDbWsTools.obtainSeqInformation( n2 );
11008 System.out.println( n2.toString() );
11009 if ( !n2.getNodeData().getSequence().getName()
11010 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11013 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11016 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11019 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11022 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11023 SequenceDbWsTools.obtainSeqInformation( n3 );
11024 System.out.println( "n=" + n3.toString() );
11025 if ( !n3.getNodeData().getSequence().getName()
11026 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11029 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11032 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11035 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11039 catch ( final IOException e ) {
11040 System.out.println();
11041 System.out.println( "the following might be due to absence internet connection:" );
11042 e.printStackTrace( System.out );
11045 catch ( final Exception e ) {
11046 e.printStackTrace();
11052 private static boolean testEbiEntryRetrieval() {
11054 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
11055 if ( !entry.getAccession().equals( "AAK41263" ) ) {
11056 System.out.println( entry.getAccession() );
11059 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
11060 System.out.println( entry.getTaxonomyScientificName() );
11063 if ( !entry.getSequenceName()
11064 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
11065 System.out.println( entry.getSequenceName() );
11068 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
11069 // System.out.println( entry.getSequenceSymbol() );
11072 if ( !entry.getGeneName().equals( "treX-like" ) ) {
11073 System.out.println( entry.getGeneName() );
11076 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
11077 System.out.println( entry.getTaxonomyIdentifier() );
11080 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
11081 System.out.println( entry.getAnnotations().first().getRefValue() );
11084 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
11085 System.out.println( entry.getAnnotations().first().getRefSource() );
11088 if ( entry.getCrossReferences().size() != 5 ) {
11092 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
11093 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
11096 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
11097 System.out.println( entry1.getTaxonomyScientificName() );
11100 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
11101 System.out.println( entry1.getSequenceName() );
11104 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
11105 System.out.println( entry1.getTaxonomyIdentifier() );
11108 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
11109 System.out.println( entry1.getGeneName() );
11112 if ( entry1.getCrossReferences().size() != 6 ) {
11116 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
11117 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
11120 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11121 System.out.println( entry2.getTaxonomyScientificName() );
11124 if ( !entry2.getSequenceName()
11125 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11126 System.out.println( entry2.getSequenceName() );
11129 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
11130 System.out.println( entry2.getTaxonomyIdentifier() );
11133 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
11134 System.out.println( entry2.getGeneName() );
11137 if ( entry2.getCrossReferences().size() != 3 ) {
11141 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
11142 if ( !entry3.getAccession().equals( "HM043801" ) ) {
11145 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
11146 System.out.println( entry3.getTaxonomyScientificName() );
11149 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
11150 System.out.println( entry3.getSequenceName() );
11153 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
11154 System.out.println( entry3.getTaxonomyIdentifier() );
11157 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
11158 System.out.println( entry3.getSequenceSymbol() );
11161 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
11164 if ( entry3.getCrossReferences().size() != 8 ) {
11169 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
11170 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
11173 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
11174 System.out.println( entry4.getTaxonomyScientificName() );
11177 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
11178 System.out.println( entry4.getSequenceName() );
11181 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
11182 System.out.println( entry4.getTaxonomyIdentifier() );
11185 if ( !entry4.getGeneName().equals( "ras" ) ) {
11186 System.out.println( entry4.getGeneName() );
11191 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
11192 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
11196 catch ( final IOException e ) {
11197 System.out.println();
11198 System.out.println( "the following might be due to absence internet connection:" );
11199 e.printStackTrace( System.out );
11202 catch ( final Exception e ) {
11203 e.printStackTrace();
11209 private static boolean testUniprotEntryRetrieval() {
11211 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11212 if ( !entry.getAccession().equals( "P12345" ) ) {
11215 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11218 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11221 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11224 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11227 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11231 catch ( final IOException e ) {
11232 System.out.println();
11233 System.out.println( "the following might be due to absence internet connection:" );
11234 e.printStackTrace( System.out );
11237 catch ( final Exception e ) {
11243 private static boolean testUniprotTaxonomySearch() {
11245 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11247 if ( results.size() != 1 ) {
11250 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11253 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11256 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11259 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11262 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11266 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11267 if ( results.size() != 1 ) {
11270 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11273 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11276 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11279 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11282 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11286 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11287 if ( results.size() != 1 ) {
11290 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11293 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11296 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11299 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11302 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11306 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11307 if ( results.size() != 1 ) {
11310 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11313 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11316 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11319 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11322 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11325 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11328 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11331 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11332 .equals( "Nematostella vectensis" ) ) {
11333 System.out.println( results.get( 0 ).getLineage() );
11338 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11339 if ( results.size() != 1 ) {
11342 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11345 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11348 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11351 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11354 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11357 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11358 .equals( "Xenopus tropicalis" ) ) {
11359 System.out.println( results.get( 0 ).getLineage() );
11364 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11365 if ( results.size() != 1 ) {
11368 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11371 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11374 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11377 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11380 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11383 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11384 .equals( "Xenopus tropicalis" ) ) {
11385 System.out.println( results.get( 0 ).getLineage() );
11390 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11391 if ( results.size() != 1 ) {
11394 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11397 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11400 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11403 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11406 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11409 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11410 .equals( "Xenopus tropicalis" ) ) {
11411 System.out.println( results.get( 0 ).getLineage() );
11415 catch ( final IOException e ) {
11416 System.out.println();
11417 System.out.println( "the following might be due to absence internet connection:" );
11418 e.printStackTrace( System.out );
11421 catch ( final Exception e ) {
11427 private static boolean testWabiTxSearch() {
11429 String result = "";
11430 result = TxSearch.searchSimple( "nematostella" );
11431 result = TxSearch.getTxId( "nematostella" );
11432 if ( !result.equals( "45350" ) ) {
11435 result = TxSearch.getTxName( "45350" );
11436 if ( !result.equals( "Nematostella" ) ) {
11439 result = TxSearch.getTxId( "nematostella vectensis" );
11440 if ( !result.equals( "45351" ) ) {
11443 result = TxSearch.getTxName( "45351" );
11444 if ( !result.equals( "Nematostella vectensis" ) ) {
11447 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11448 if ( !result.equals( "536089" ) ) {
11451 result = TxSearch.getTxName( "536089" );
11452 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11455 final List<String> queries = new ArrayList<String>();
11456 queries.add( "Campylobacter coli" );
11457 queries.add( "Escherichia coli" );
11458 queries.add( "Arabidopsis" );
11459 queries.add( "Trichoplax" );
11460 queries.add( "Samanea saman" );
11461 queries.add( "Kluyveromyces marxianus" );
11462 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11463 queries.add( "Bornavirus parrot/PDD/2008" );
11464 final List<RANKS> ranks = new ArrayList<RANKS>();
11465 ranks.add( RANKS.SUPERKINGDOM );
11466 ranks.add( RANKS.KINGDOM );
11467 ranks.add( RANKS.FAMILY );
11468 ranks.add( RANKS.GENUS );
11469 ranks.add( RANKS.TRIBE );
11470 result = TxSearch.searchLineage( queries, ranks );
11471 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11472 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11474 catch ( final Exception e ) {
11475 System.out.println();
11476 System.out.println( "the following might be due to absence internet connection:" );
11477 e.printStackTrace( System.out );