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;
40 import org.forester.application.support_transfer;
41 import org.forester.archaeopteryx.AptxUtil;
42 import org.forester.development.DevelopmentTools;
43 import org.forester.evoinference.TestPhylogenyReconstruction;
44 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
46 import org.forester.go.TestGo;
47 import org.forester.io.parsers.FastaParser;
48 import org.forester.io.parsers.GeneralMsaParser;
49 import org.forester.io.parsers.HmmscanPerDomainTableParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
51 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
52 import org.forester.io.parsers.nexus.NexusCharactersParser;
53 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
54 import org.forester.io.parsers.nhx.NHXParser;
55 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
56 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
57 import org.forester.io.parsers.tol.TolParser;
58 import org.forester.io.parsers.util.ParserUtils;
59 import org.forester.io.writers.PhylogenyWriter;
60 import org.forester.io.writers.SequenceWriter;
61 import org.forester.msa.BasicMsa;
62 import org.forester.msa.Mafft;
63 import org.forester.msa.Msa;
64 import org.forester.msa.MsaInferrer;
65 import org.forester.msa.MsaMethods;
66 import org.forester.pccx.TestPccx;
67 import org.forester.phylogeny.Phylogeny;
68 import org.forester.phylogeny.PhylogenyBranch;
69 import org.forester.phylogeny.PhylogenyMethods;
70 import org.forester.phylogeny.PhylogenyNode;
71 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
72 import org.forester.phylogeny.data.Accession;
73 import org.forester.phylogeny.data.BinaryCharacters;
74 import org.forester.phylogeny.data.BranchWidth;
75 import org.forester.phylogeny.data.Confidence;
76 import org.forester.phylogeny.data.Distribution;
77 import org.forester.phylogeny.data.DomainArchitecture;
78 import org.forester.phylogeny.data.Event;
79 import org.forester.phylogeny.data.Identifier;
80 import org.forester.phylogeny.data.PhylogenyData;
81 import org.forester.phylogeny.data.PhylogenyDataUtil;
82 import org.forester.phylogeny.data.Polygon;
83 import org.forester.phylogeny.data.PropertiesMap;
84 import org.forester.phylogeny.data.Property;
85 import org.forester.phylogeny.data.Property.AppliesTo;
86 import org.forester.phylogeny.data.ProteinDomain;
87 import org.forester.phylogeny.data.Taxonomy;
88 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
89 import org.forester.phylogeny.factories.PhylogenyFactory;
90 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
91 import org.forester.protein.BasicDomain;
92 import org.forester.protein.BasicProtein;
93 import org.forester.protein.Domain;
94 import org.forester.protein.Protein;
95 import org.forester.protein.ProteinId;
96 import org.forester.rio.TestRIO;
97 import org.forester.sdi.SDI;
98 import org.forester.sdi.SDIR;
99 import org.forester.sdi.TestGSDI;
100 import org.forester.sequence.BasicSequence;
101 import org.forester.sequence.Sequence;
102 import org.forester.species.BasicSpecies;
103 import org.forester.species.Species;
104 import org.forester.surfacing.TestSurfacing;
105 import org.forester.tools.ConfidenceAssessor;
106 import org.forester.tools.SupportCount;
107 import org.forester.tools.TreeSplitMatrix;
108 import org.forester.util.AsciiHistogram;
109 import org.forester.util.BasicDescriptiveStatistics;
110 import org.forester.util.BasicTable;
111 import org.forester.util.BasicTableParser;
112 import org.forester.util.DescriptiveStatistics;
113 import org.forester.util.ForesterConstants;
114 import org.forester.util.ForesterUtil;
115 import org.forester.util.GeneralTable;
116 import org.forester.util.SequenceIdParser;
117 import org.forester.ws.seqdb.SequenceDatabaseEntry;
118 import org.forester.ws.seqdb.SequenceDbWsTools;
119 import org.forester.ws.seqdb.UniProtTaxonomy;
120 import org.forester.ws.wabi.TxSearch;
121 import org.forester.ws.wabi.TxSearch.RANKS;
122 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
123 import org.forester.ws.wabi.TxSearch.TAX_RANK;
125 @SuppressWarnings( "unused")
126 public final class Test {
128 private final static double ZERO_DIFF = 1.0E-9;
129 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
130 + ForesterUtil.getFileSeparator() + "test_data"
131 + ForesterUtil.getFileSeparator();
132 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "resources"
134 + ForesterUtil.getFileSeparator();
135 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
136 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
137 + ForesterConstants.PHYLO_XML_VERSION + "/"
138 + ForesterConstants.PHYLO_XML_XSD;
139 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
143 public static boolean isEqual( final double a, final double b ) {
144 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
147 public static void main( final String[] args ) {
148 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
149 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
151 Locale.setDefault( Locale.US );
152 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
155 System.out.print( "[Test if directory with files for testing exists/is readable: " );
156 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
157 System.out.println( "OK.]" );
160 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
161 System.out.println( "Testing aborted." );
164 System.out.print( "[Test if resources directory exists/is readable: " );
165 if ( testDir( PATH_TO_RESOURCES ) ) {
166 System.out.println( "OK.]" );
169 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
170 System.out.println( "Testing aborted." );
173 final long start_time = new Date().getTime();
174 System.out.print( "Protein id: " );
175 if ( !testProteinId() ) {
176 System.out.println( "failed." );
182 System.out.println( "OK." );
183 System.out.print( "Species: " );
184 if ( !testSpecies() ) {
185 System.out.println( "failed." );
191 System.out.println( "OK." );
192 System.out.print( "Basic domain: " );
193 if ( !testBasicDomain() ) {
194 System.out.println( "failed." );
200 System.out.println( "OK." );
201 System.out.print( "Basic protein: " );
202 if ( !testBasicProtein() ) {
203 System.out.println( "failed." );
209 System.out.println( "OK." );
210 System.out.print( "Sequence writer: " );
211 if ( testSequenceWriter() ) {
212 System.out.println( "OK." );
216 System.out.println( "failed." );
219 System.out.print( "Sequence id parsing: " );
220 if ( testSequenceIdParsing() ) {
221 System.out.println( "OK." );
225 System.out.println( "failed." );
228 System.out.print( "Hmmscan output parser: " );
229 if ( testHmmscanOutputParser() ) {
230 System.out.println( "OK." );
234 System.out.println( "failed." );
237 System.out.print( "Basic node methods: " );
238 if ( Test.testBasicNodeMethods() ) {
239 System.out.println( "OK." );
243 System.out.println( "failed." );
246 System.out.print( "Taxonomy code extraction: " );
247 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
248 System.out.println( "OK." );
252 System.out.println( "failed." );
255 System.out.print( "SN extraction: " );
256 if ( Test.testExtractSNFromNodeName() ) {
257 System.out.println( "OK." );
261 System.out.println( "failed." );
264 System.out.print( "Taxonomy extraction (general): " );
265 if ( Test.testTaxonomyExtraction() ) {
266 System.out.println( "OK." );
270 System.out.println( "failed." );
273 System.out.print( "UniProtKB id extraction: " );
274 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
275 System.out.println( "OK." );
279 System.out.println( "failed." );
282 System.out.print( "Uri for Aptx web sequence accession: " );
283 if ( Test.testCreateUriForSeqWeb() ) {
284 System.out.println( "OK." );
288 System.out.println( "failed." );
291 System.out.print( "Basic node construction and parsing of NHX (node level): " );
292 if ( Test.testNHXNodeParsing() ) {
293 System.out.println( "OK." );
297 System.out.println( "failed." );
300 System.out.print( "NHX parsing iterating: " );
301 if ( Test.testNHParsingIter() ) {
302 System.out.println( "OK." );
306 System.out.println( "failed." );
309 System.out.print( "NH parsing: " );
310 if ( Test.testNHParsing() ) {
311 System.out.println( "OK." );
315 System.out.println( "failed." );
318 System.out.print( "Conversion to NHX (node level): " );
319 if ( Test.testNHXconversion() ) {
320 System.out.println( "OK." );
324 System.out.println( "failed." );
327 System.out.print( "NHX parsing: " );
328 if ( Test.testNHXParsing() ) {
329 System.out.println( "OK." );
333 System.out.println( "failed." );
336 System.out.print( "NHX parsing with quotes: " );
337 if ( Test.testNHXParsingQuotes() ) {
338 System.out.println( "OK." );
342 System.out.println( "failed." );
345 System.out.print( "NHX parsing (MrBayes): " );
346 if ( Test.testNHXParsingMB() ) {
347 System.out.println( "OK." );
351 System.out.println( "failed." );
354 System.out.print( "Nexus characters parsing: " );
355 if ( Test.testNexusCharactersParsing() ) {
356 System.out.println( "OK." );
360 System.out.println( "failed." );
363 System.out.print( "Nexus tree parsing iterating: " );
364 if ( Test.testNexusTreeParsingIterating() ) {
365 System.out.println( "OK." );
369 System.out.println( "failed." );
372 System.out.print( "Nexus tree parsing: " );
373 if ( Test.testNexusTreeParsing() ) {
374 System.out.println( "OK." );
378 System.out.println( "failed." );
381 System.out.print( "Nexus tree parsing (translating): " );
382 if ( Test.testNexusTreeParsingTranslating() ) {
383 System.out.println( "OK." );
387 System.out.println( "failed." );
390 System.out.print( "Nexus matrix parsing: " );
391 if ( Test.testNexusMatrixParsing() ) {
392 System.out.println( "OK." );
396 System.out.println( "failed." );
399 System.out.print( "Basic phyloXML parsing: " );
400 if ( Test.testBasicPhyloXMLparsing() ) {
401 System.out.println( "OK." );
405 System.out.println( "failed." );
408 System.out.print( "Basic phyloXML parsing (validating against schema): " );
409 if ( testBasicPhyloXMLparsingValidating() ) {
410 System.out.println( "OK." );
414 System.out.println( "failed." );
417 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
418 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
419 System.out.println( "OK." );
423 System.out.println( "failed." );
426 System.out.print( "phyloXML Distribution Element: " );
427 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
428 System.out.println( "OK." );
432 System.out.println( "failed." );
435 System.out.print( "Tol XML parsing: " );
436 if ( Test.testBasicTolXMLparsing() ) {
437 System.out.println( "OK." );
441 System.out.println( "failed." );
444 System.out.print( "Copying of node data: " );
445 if ( Test.testCopyOfNodeData() ) {
446 System.out.println( "OK." );
450 System.out.println( "failed." );
453 System.out.print( "Basic tree methods: " );
454 if ( Test.testBasicTreeMethods() ) {
455 System.out.println( "OK." );
459 System.out.println( "failed." );
462 System.out.print( "Tree methods: " );
463 if ( Test.testTreeMethods() ) {
464 System.out.println( "OK." );
468 System.out.println( "failed." );
471 System.out.print( "Postorder Iterator: " );
472 if ( Test.testPostOrderIterator() ) {
473 System.out.println( "OK." );
477 System.out.println( "failed." );
480 System.out.print( "Preorder Iterator: " );
481 if ( Test.testPreOrderIterator() ) {
482 System.out.println( "OK." );
486 System.out.println( "failed." );
489 System.out.print( "Levelorder Iterator: " );
490 if ( Test.testLevelOrderIterator() ) {
491 System.out.println( "OK." );
495 System.out.println( "failed." );
498 System.out.print( "Re-id methods: " );
499 if ( Test.testReIdMethods() ) {
500 System.out.println( "OK." );
504 System.out.println( "failed." );
507 System.out.print( "Methods on last external nodes: " );
508 if ( Test.testLastExternalNodeMethods() ) {
509 System.out.println( "OK." );
513 System.out.println( "failed." );
516 System.out.print( "Methods on external nodes: " );
517 if ( Test.testExternalNodeRelatedMethods() ) {
518 System.out.println( "OK." );
522 System.out.println( "failed." );
525 System.out.print( "Deletion of external nodes: " );
526 if ( Test.testDeletionOfExternalNodes() ) {
527 System.out.println( "OK." );
531 System.out.println( "failed." );
534 System.out.print( "Subtree deletion: " );
535 if ( Test.testSubtreeDeletion() ) {
536 System.out.println( "OK." );
540 System.out.println( "failed." );
543 System.out.print( "Phylogeny branch: " );
544 if ( Test.testPhylogenyBranch() ) {
545 System.out.println( "OK." );
549 System.out.println( "failed." );
552 System.out.print( "Rerooting: " );
553 if ( Test.testRerooting() ) {
554 System.out.println( "OK." );
558 System.out.println( "failed." );
561 System.out.print( "Mipoint rooting: " );
562 if ( Test.testMidpointrooting() ) {
563 System.out.println( "OK." );
567 System.out.println( "failed." );
570 System.out.print( "Node removal: " );
571 if ( Test.testNodeRemoval() ) {
572 System.out.println( "OK." );
576 System.out.println( "failed." );
579 System.out.print( "Support count: " );
580 if ( Test.testSupportCount() ) {
581 System.out.println( "OK." );
585 System.out.println( "failed." );
588 System.out.print( "Support transfer: " );
589 if ( Test.testSupportTransfer() ) {
590 System.out.println( "OK." );
594 System.out.println( "failed." );
597 System.out.print( "Finding of LCA: " );
598 if ( Test.testGetLCA() ) {
599 System.out.println( "OK." );
603 System.out.println( "failed." );
606 System.out.print( "Finding of LCA 2: " );
607 if ( Test.testGetLCA2() ) {
608 System.out.println( "OK." );
612 System.out.println( "failed." );
615 System.out.print( "Calculation of distance between nodes: " );
616 if ( Test.testGetDistance() ) {
617 System.out.println( "OK." );
621 System.out.println( "failed." );
624 System.out.print( "Descriptive statistics: " );
625 if ( Test.testDescriptiveStatistics() ) {
626 System.out.println( "OK." );
630 System.out.println( "failed." );
633 System.out.print( "Data objects and methods: " );
634 if ( Test.testDataObjects() ) {
635 System.out.println( "OK." );
639 System.out.println( "failed." );
642 System.out.print( "Properties map: " );
643 if ( Test.testPropertiesMap() ) {
644 System.out.println( "OK." );
648 System.out.println( "failed." );
651 System.out.print( "SDIse: " );
652 if ( Test.testSDIse() ) {
653 System.out.println( "OK." );
657 System.out.println( "failed." );
660 System.out.print( "SDIunrooted: " );
661 if ( Test.testSDIunrooted() ) {
662 System.out.println( "OK." );
666 System.out.println( "failed." );
669 System.out.print( "GSDI: " );
670 if ( TestGSDI.test() ) {
671 System.out.println( "OK." );
675 System.out.println( "failed." );
678 System.out.print( "RIO: " );
679 if ( TestRIO.test() ) {
680 System.out.println( "OK." );
684 System.out.println( "failed." );
687 System.out.print( "Phylogeny reconstruction:" );
688 System.out.println();
689 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
690 System.out.println( "OK." );
694 System.out.println( "failed." );
697 System.out.print( "Analysis of domain architectures: " );
698 System.out.println();
699 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "GO: " );
708 System.out.println();
709 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
710 System.out.println( "OK." );
714 System.out.println( "failed." );
717 System.out.print( "Modeling tools: " );
718 if ( TestPccx.test() ) {
719 System.out.println( "OK." );
723 System.out.println( "failed." );
726 System.out.print( "Split Matrix strict: " );
727 if ( Test.testSplitStrict() ) {
728 System.out.println( "OK." );
732 System.out.println( "failed." );
735 System.out.print( "Split Matrix: " );
736 if ( Test.testSplit() ) {
737 System.out.println( "OK." );
741 System.out.println( "failed." );
744 System.out.print( "Confidence Assessor: " );
745 if ( Test.testConfidenceAssessor() ) {
746 System.out.println( "OK." );
750 System.out.println( "failed." );
753 System.out.print( "Basic table: " );
754 if ( Test.testBasicTable() ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "General table: " );
763 if ( Test.testGeneralTable() ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "Amino acid sequence: " );
772 if ( Test.testAminoAcidSequence() ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "General MSA parser: " );
781 if ( Test.testGeneralMsaParser() ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "Fasta parser for msa: " );
790 if ( Test.testFastaParser() ) {
791 System.out.println( "OK." );
795 System.out.println( "failed." );
798 System.out.print( "Creation of balanced phylogeny: " );
799 if ( Test.testCreateBalancedPhylogeny() ) {
800 System.out.println( "OK." );
804 System.out.println( "failed." );
807 System.out.print( "EMBL Entry Retrieval: " );
808 if ( Test.testEmblEntryRetrieval() ) {
809 System.out.println( "OK." );
813 System.out.println( "failed." );
816 System.out.print( "Uniprot Entry Retrieval: " );
817 if ( Test.testUniprotEntryRetrieval() ) {
818 System.out.println( "OK." );
822 System.out.println( "failed." );
825 System.out.print( "Uniprot Taxonomy Search: " );
826 if ( Test.testUniprotTaxonomySearch() ) {
827 System.out.println( "OK." );
831 System.out.println( "failed." );
836 final String os = ForesterUtil.OS_NAME.toLowerCase();
837 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
838 path = "/usr/local/bin/mafft";
840 else if ( os.indexOf( "win" ) >= 0 ) {
841 path = "C:\\Program Files\\mafft-win\\mafft.bat";
844 path = "/home/czmasek/bin/mafft";
846 if ( !MsaInferrer.isInstalled( path ) ) {
849 if ( !MsaInferrer.isInstalled( path ) ) {
850 path = "/usr/local/bin/mafft";
852 if ( MsaInferrer.isInstalled( path ) ) {
853 System.out.print( "MAFFT (external program): " );
854 if ( Test.testMafft( path ) ) {
855 System.out.println( "OK." );
859 System.out.println( "failed [will not count towards failed tests]" );
863 System.out.print( "Next nodes with collapsed: " );
864 if ( Test.testNextNodeWithCollapsing() ) {
865 System.out.println( "OK." );
869 System.out.println( "failed." );
872 System.out.print( "Simple MSA quality: " );
873 if ( Test.testMsaQualityMethod() ) {
874 System.out.println( "OK." );
878 System.out.println( "failed." );
881 System.out.println();
882 final Runtime rt = java.lang.Runtime.getRuntime();
883 final long free_memory = rt.freeMemory() / 1000000;
884 final long total_memory = rt.totalMemory() / 1000000;
885 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
886 + free_memory + "MB, total memory: " + total_memory + "MB)" );
887 System.out.println();
888 System.out.println( "Successful tests: " + succeeded );
889 System.out.println( "Failed tests: " + failed );
890 System.out.println();
892 System.out.println( "OK." );
895 System.out.println( "Not OK." );
899 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
900 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
904 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
905 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
908 private static boolean testAminoAcidSequence() {
910 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
911 if ( aa1.getLength() != 13 ) {
914 if ( aa1.getResidueAt( 0 ) != 'A' ) {
917 if ( aa1.getResidueAt( 2 ) != 'K' ) {
920 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
923 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
924 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
927 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
928 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
931 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
932 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
936 catch ( final Exception e ) {
943 private static boolean testBasicDomain() {
945 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
946 if ( !pd.getDomainId().equals( "id" ) ) {
949 if ( pd.getNumber() != 1 ) {
952 if ( pd.getTotalCount() != 4 ) {
955 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
958 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
959 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
960 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
961 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
962 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
963 if ( !a1.equals( a1 ) ) {
966 if ( !a1.equals( a1_copy ) ) {
969 if ( !a1.equals( a1_equal ) ) {
972 if ( !a1.equals( a2 ) ) {
975 if ( a1.equals( a3 ) ) {
978 if ( a1.compareTo( a1 ) != 0 ) {
981 if ( a1.compareTo( a1_copy ) != 0 ) {
984 if ( a1.compareTo( a1_equal ) != 0 ) {
987 if ( a1.compareTo( a2 ) != 0 ) {
990 if ( a1.compareTo( a3 ) == 0 ) {
994 catch ( final Exception e ) {
995 e.printStackTrace( System.out );
1001 private static boolean testBasicNodeMethods() {
1003 if ( PhylogenyNode.getNodeCount() != 0 ) {
1006 final PhylogenyNode n1 = new PhylogenyNode();
1007 final PhylogenyNode n2 = PhylogenyNode
1008 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1009 final PhylogenyNode n3 = PhylogenyNode
1010 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1011 final PhylogenyNode n4 = PhylogenyNode
1012 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1013 if ( n1.isHasAssignedEvent() ) {
1016 if ( PhylogenyNode.getNodeCount() != 4 ) {
1019 if ( n3.getIndicator() != 0 ) {
1022 if ( n3.getNumberOfExternalNodes() != 1 ) {
1025 if ( !n3.isExternal() ) {
1028 if ( !n3.isRoot() ) {
1031 if ( !n4.getName().equals( "n4" ) ) {
1035 catch ( final Exception e ) {
1036 e.printStackTrace( System.out );
1042 private static boolean testBasicPhyloXMLparsing() {
1044 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1045 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1046 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1048 if ( xml_parser.getErrorCount() > 0 ) {
1049 System.out.println( xml_parser.getErrorMessages().toString() );
1052 if ( phylogenies_0.length != 4 ) {
1055 final Phylogeny t1 = phylogenies_0[ 0 ];
1056 final Phylogeny t2 = phylogenies_0[ 1 ];
1057 final Phylogeny t3 = phylogenies_0[ 2 ];
1058 final Phylogeny t4 = phylogenies_0[ 3 ];
1059 if ( t1.getNumberOfExternalNodes() != 1 ) {
1062 if ( !t1.isRooted() ) {
1065 if ( t1.isRerootable() ) {
1068 if ( !t1.getType().equals( "gene_tree" ) ) {
1071 if ( t2.getNumberOfExternalNodes() != 2 ) {
1074 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1077 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1080 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1083 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1086 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1089 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1092 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1093 .startsWith( "actgtgggggt" ) ) {
1096 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1097 .startsWith( "ctgtgatgcat" ) ) {
1100 if ( t3.getNumberOfExternalNodes() != 4 ) {
1103 if ( !t1.getName().equals( "t1" ) ) {
1106 if ( !t2.getName().equals( "t2" ) ) {
1109 if ( !t3.getName().equals( "t3" ) ) {
1112 if ( !t4.getName().equals( "t4" ) ) {
1115 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1118 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1121 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1124 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1125 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1128 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1131 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1134 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1137 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1138 .equals( "apoptosis" ) ) {
1141 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1142 .equals( "GO:0006915" ) ) {
1145 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1146 .equals( "UniProtKB" ) ) {
1149 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1150 .equals( "experimental" ) ) {
1153 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1154 .equals( "function" ) ) {
1157 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1158 .getValue() != 1 ) {
1161 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1162 .getType().equals( "ml" ) ) {
1165 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1166 .equals( "apoptosis" ) ) {
1169 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1170 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1173 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1174 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1177 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1178 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1181 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1182 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1185 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1186 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1189 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1190 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1193 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1194 .equals( "GO:0005829" ) ) {
1197 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1198 .equals( "intracellular organelle" ) ) {
1201 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1204 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1205 .equals( "UniProt link" ) ) ) {
1208 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1212 catch ( final Exception e ) {
1213 e.printStackTrace( System.out );
1219 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1221 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1222 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1223 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1224 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1227 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1229 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1231 if ( xml_parser.getErrorCount() > 0 ) {
1232 System.out.println( xml_parser.getErrorMessages().toString() );
1235 if ( phylogenies_0.length != 4 ) {
1238 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1239 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1240 if ( phylogenies_t1.length != 1 ) {
1243 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1244 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1247 if ( !t1_rt.isRooted() ) {
1250 if ( t1_rt.isRerootable() ) {
1253 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1256 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1257 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1258 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1259 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1262 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1265 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1268 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1271 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1272 .startsWith( "actgtgggggt" ) ) {
1275 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1276 .startsWith( "ctgtgatgcat" ) ) {
1279 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1280 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1281 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1282 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1283 if ( phylogenies_1.length != 1 ) {
1286 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1287 if ( !t3_rt.getName().equals( "t3" ) ) {
1290 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1293 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1296 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1299 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1302 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1303 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1306 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1309 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1312 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1313 .equals( "UniProtKB" ) ) {
1316 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1317 .equals( "apoptosis" ) ) {
1320 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1321 .equals( "GO:0006915" ) ) {
1324 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1325 .equals( "UniProtKB" ) ) {
1328 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1329 .equals( "experimental" ) ) {
1332 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1333 .equals( "function" ) ) {
1336 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1337 .getValue() != 1 ) {
1340 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1341 .getType().equals( "ml" ) ) {
1344 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1345 .equals( "apoptosis" ) ) {
1348 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1349 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1352 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1353 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1356 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1357 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1360 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1361 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1364 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1365 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1368 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1369 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1372 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1373 .equals( "GO:0005829" ) ) {
1376 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1377 .equals( "intracellular organelle" ) ) {
1380 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1383 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1384 .equals( "UniProt link" ) ) ) {
1387 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1390 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1393 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1394 .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." ) ) ) {
1397 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1400 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1403 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1406 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1409 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1410 .equals( "ncbi" ) ) {
1413 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1416 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1417 .getName().equals( "B" ) ) {
1420 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1421 .getFrom() != 21 ) {
1424 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1427 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1428 .getLength() != 24 ) {
1431 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1432 .getConfidence() != 2144 ) {
1435 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1436 .equals( "pfam" ) ) {
1439 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1442 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1445 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1448 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1451 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1452 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1455 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1458 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1461 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1464 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1467 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1470 if ( taxbb.getSynonyms().size() != 2 ) {
1473 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1476 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1479 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1482 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1485 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1488 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1489 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1493 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1496 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1499 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1502 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1505 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1508 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1511 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1515 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1518 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1519 .equalsIgnoreCase( "435" ) ) {
1522 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1525 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1526 .equalsIgnoreCase( "443.7" ) ) {
1529 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1532 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1535 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1536 .equalsIgnoreCase( "433" ) ) {
1540 catch ( final Exception e ) {
1541 e.printStackTrace( System.out );
1547 private static boolean testBasicPhyloXMLparsingValidating() {
1549 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1550 PhyloXmlParser xml_parser = null;
1552 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1554 catch ( final Exception e ) {
1555 // Do nothing -- means were not running from jar.
1557 if ( xml_parser == null ) {
1558 xml_parser = new PhyloXmlParser();
1559 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1560 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1563 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1566 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1568 if ( xml_parser.getErrorCount() > 0 ) {
1569 System.out.println( xml_parser.getErrorMessages().toString() );
1572 if ( phylogenies_0.length != 4 ) {
1575 final Phylogeny t1 = phylogenies_0[ 0 ];
1576 final Phylogeny t2 = phylogenies_0[ 1 ];
1577 final Phylogeny t3 = phylogenies_0[ 2 ];
1578 final Phylogeny t4 = phylogenies_0[ 3 ];
1579 if ( !t1.getName().equals( "t1" ) ) {
1582 if ( !t2.getName().equals( "t2" ) ) {
1585 if ( !t3.getName().equals( "t3" ) ) {
1588 if ( !t4.getName().equals( "t4" ) ) {
1591 if ( t1.getNumberOfExternalNodes() != 1 ) {
1594 if ( t2.getNumberOfExternalNodes() != 2 ) {
1597 if ( t3.getNumberOfExternalNodes() != 4 ) {
1600 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1601 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1602 if ( xml_parser.getErrorCount() > 0 ) {
1603 System.out.println( "errors:" );
1604 System.out.println( xml_parser.getErrorMessages().toString() );
1607 if ( phylogenies_1.length != 4 ) {
1610 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1612 if ( xml_parser.getErrorCount() > 0 ) {
1613 System.out.println( "errors:" );
1614 System.out.println( xml_parser.getErrorMessages().toString() );
1617 if ( phylogenies_2.length != 1 ) {
1620 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1623 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1625 if ( xml_parser.getErrorCount() > 0 ) {
1626 System.out.println( xml_parser.getErrorMessages().toString() );
1629 if ( phylogenies_3.length != 2 ) {
1632 final Phylogeny a = phylogenies_3[ 0 ];
1633 if ( !a.getName().equals( "tree 4" ) ) {
1636 if ( a.getNumberOfExternalNodes() != 3 ) {
1639 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1642 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1645 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1647 if ( xml_parser.getErrorCount() > 0 ) {
1648 System.out.println( xml_parser.getErrorMessages().toString() );
1651 if ( phylogenies_4.length != 1 ) {
1654 final Phylogeny s = phylogenies_4[ 0 ];
1655 if ( s.getNumberOfExternalNodes() != 6 ) {
1658 s.getNode( "first" );
1660 s.getNode( "\"<a'b&c'd\">\"" );
1661 s.getNode( "'''\"" );
1662 s.getNode( "\"\"\"" );
1663 s.getNode( "dick & doof" );
1665 catch ( final Exception e ) {
1666 e.printStackTrace( System.out );
1672 private static boolean testBasicProtein() {
1674 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1675 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1676 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1677 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1678 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1679 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1680 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1681 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1682 p0.addProteinDomain( y );
1683 p0.addProteinDomain( e );
1684 p0.addProteinDomain( b );
1685 p0.addProteinDomain( c );
1686 p0.addProteinDomain( d );
1687 p0.addProteinDomain( a );
1688 p0.addProteinDomain( x );
1689 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1692 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
1696 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
1697 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1698 aa0.addProteinDomain( a1 );
1699 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
1702 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
1706 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
1707 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1708 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1709 aa1.addProteinDomain( a11 );
1710 aa1.addProteinDomain( a12 );
1711 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
1714 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
1717 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1718 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
1721 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1724 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
1727 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1728 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
1731 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1734 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
1737 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
1740 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1741 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
1744 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
1747 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
1750 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
1753 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1754 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
1757 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
1760 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
1763 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
1767 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
1768 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1769 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1770 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1771 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1772 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1773 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
1774 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
1775 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
1776 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
1777 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
1778 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1779 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1780 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
1781 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
1782 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
1783 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
1784 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
1785 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
1786 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
1787 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
1788 p00.addProteinDomain( y0 );
1789 p00.addProteinDomain( e0 );
1790 p00.addProteinDomain( b0 );
1791 p00.addProteinDomain( c0 );
1792 p00.addProteinDomain( d0 );
1793 p00.addProteinDomain( a0 );
1794 p00.addProteinDomain( x0 );
1795 p00.addProteinDomain( y1 );
1796 p00.addProteinDomain( y2 );
1797 p00.addProteinDomain( y3 );
1798 p00.addProteinDomain( e1 );
1799 p00.addProteinDomain( e2 );
1800 p00.addProteinDomain( e3 );
1801 p00.addProteinDomain( e4 );
1802 p00.addProteinDomain( e5 );
1803 p00.addProteinDomain( z0 );
1804 p00.addProteinDomain( z1 );
1805 p00.addProteinDomain( z2 );
1806 p00.addProteinDomain( zz0 );
1807 p00.addProteinDomain( zz1 );
1808 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
1811 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
1814 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1817 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1820 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" ) ) {
1823 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1824 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1825 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1826 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1827 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1828 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1829 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1830 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1831 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1832 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1833 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1834 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1835 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1836 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1837 p.addProteinDomain( B15 );
1838 p.addProteinDomain( C50 );
1839 p.addProteinDomain( A60 );
1840 p.addProteinDomain( A30 );
1841 p.addProteinDomain( C70 );
1842 p.addProteinDomain( B35 );
1843 p.addProteinDomain( B40 );
1844 p.addProteinDomain( A0 );
1845 p.addProteinDomain( A10 );
1846 p.addProteinDomain( A20 );
1847 p.addProteinDomain( B25 );
1848 p.addProteinDomain( D80 );
1849 List<String> domains_ids = new ArrayList<String>();
1850 domains_ids.add( "A" );
1851 domains_ids.add( "B" );
1852 domains_ids.add( "C" );
1853 if ( !p.contains( domains_ids, false ) ) {
1856 if ( !p.contains( domains_ids, true ) ) {
1859 domains_ids.add( "X" );
1860 if ( p.contains( domains_ids, false ) ) {
1863 if ( p.contains( domains_ids, true ) ) {
1866 domains_ids = new ArrayList<String>();
1867 domains_ids.add( "A" );
1868 domains_ids.add( "C" );
1869 domains_ids.add( "D" );
1870 if ( !p.contains( domains_ids, false ) ) {
1873 if ( !p.contains( domains_ids, true ) ) {
1876 domains_ids = new ArrayList<String>();
1877 domains_ids.add( "A" );
1878 domains_ids.add( "D" );
1879 domains_ids.add( "C" );
1880 if ( !p.contains( domains_ids, false ) ) {
1883 if ( p.contains( domains_ids, true ) ) {
1886 domains_ids = new ArrayList<String>();
1887 domains_ids.add( "A" );
1888 domains_ids.add( "A" );
1889 domains_ids.add( "B" );
1890 if ( !p.contains( domains_ids, false ) ) {
1893 if ( !p.contains( domains_ids, true ) ) {
1896 domains_ids = new ArrayList<String>();
1897 domains_ids.add( "A" );
1898 domains_ids.add( "A" );
1899 domains_ids.add( "A" );
1900 domains_ids.add( "B" );
1901 domains_ids.add( "B" );
1902 if ( !p.contains( domains_ids, false ) ) {
1905 if ( !p.contains( domains_ids, true ) ) {
1908 domains_ids = new ArrayList<String>();
1909 domains_ids.add( "A" );
1910 domains_ids.add( "A" );
1911 domains_ids.add( "B" );
1912 domains_ids.add( "A" );
1913 domains_ids.add( "B" );
1914 domains_ids.add( "B" );
1915 domains_ids.add( "A" );
1916 domains_ids.add( "B" );
1917 domains_ids.add( "C" );
1918 domains_ids.add( "A" );
1919 domains_ids.add( "C" );
1920 domains_ids.add( "D" );
1921 if ( !p.contains( domains_ids, false ) ) {
1924 if ( p.contains( domains_ids, true ) ) {
1928 catch ( final Exception e ) {
1929 e.printStackTrace( System.out );
1935 private static boolean testBasicTable() {
1937 final BasicTable<String> t0 = new BasicTable<String>();
1938 if ( t0.getNumberOfColumns() != 0 ) {
1941 if ( t0.getNumberOfRows() != 0 ) {
1944 t0.setValue( 3, 2, "23" );
1945 t0.setValue( 10, 1, "error" );
1946 t0.setValue( 10, 1, "110" );
1947 t0.setValue( 9, 1, "19" );
1948 t0.setValue( 1, 10, "101" );
1949 t0.setValue( 10, 10, "1010" );
1950 t0.setValue( 100, 10, "10100" );
1951 t0.setValue( 0, 0, "00" );
1952 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1955 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1958 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
1961 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
1964 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
1967 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
1970 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
1973 if ( t0.getNumberOfColumns() != 101 ) {
1976 if ( t0.getNumberOfRows() != 11 ) {
1979 if ( t0.getValueAsString( 49, 4 ) != null ) {
1982 final String l = ForesterUtil.getLineSeparator();
1983 final StringBuffer source = new StringBuffer();
1984 source.append( "" + l );
1985 source.append( "# 1 1 1 1 1 1 1 1" + l );
1986 source.append( " 00 01 02 03" + l );
1987 source.append( " 10 11 12 13 " + l );
1988 source.append( "20 21 22 23 " + l );
1989 source.append( " 30 31 32 33" + l );
1990 source.append( "40 41 42 43" + l );
1991 source.append( " # 1 1 1 1 1 " + l );
1992 source.append( "50 51 52 53 54" + l );
1993 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
1994 if ( t1.getNumberOfColumns() != 5 ) {
1997 if ( t1.getNumberOfRows() != 6 ) {
2000 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2003 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2006 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2009 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2012 final StringBuffer source1 = new StringBuffer();
2013 source1.append( "" + l );
2014 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2015 source1.append( " 00; 01 ;02;03" + l );
2016 source1.append( " 10; 11; 12; 13 " + l );
2017 source1.append( "20; 21; 22; 23 " + l );
2018 source1.append( " 30; 31; 32; 33" + l );
2019 source1.append( "40;41;42;43" + l );
2020 source1.append( " # 1 1 1 1 1 " + l );
2021 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2022 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2023 if ( t2.getNumberOfColumns() != 5 ) {
2026 if ( t2.getNumberOfRows() != 6 ) {
2029 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2032 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2035 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2038 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2041 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2044 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2047 final StringBuffer source2 = new StringBuffer();
2048 source2.append( "" + l );
2049 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2050 source2.append( " 00; 01 ;02;03" + l );
2051 source2.append( " 10; 11; 12; 13 " + l );
2052 source2.append( "20; 21; 22; 23 " + l );
2053 source2.append( " " + l );
2054 source2.append( " 30; 31; 32; 33" + l );
2055 source2.append( "40;41;42;43" + l );
2056 source2.append( " comment: 1 1 1 1 1 " + l );
2057 source2.append( ";;;50 ; 52; 53;;54 " + l );
2058 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2064 if ( tl.size() != 2 ) {
2067 final BasicTable<String> t3 = tl.get( 0 );
2068 final BasicTable<String> t4 = tl.get( 1 );
2069 if ( t3.getNumberOfColumns() != 4 ) {
2072 if ( t3.getNumberOfRows() != 3 ) {
2075 if ( t4.getNumberOfColumns() != 4 ) {
2078 if ( t4.getNumberOfRows() != 3 ) {
2081 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2084 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2088 catch ( final Exception e ) {
2089 e.printStackTrace( System.out );
2095 private static boolean testBasicTolXMLparsing() {
2097 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2098 final TolParser parser = new TolParser();
2099 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2100 if ( parser.getErrorCount() > 0 ) {
2101 System.out.println( parser.getErrorMessages().toString() );
2104 if ( phylogenies_0.length != 1 ) {
2107 final Phylogeny t1 = phylogenies_0[ 0 ];
2108 if ( t1.getNumberOfExternalNodes() != 5 ) {
2111 if ( !t1.isRooted() ) {
2114 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2117 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2120 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2123 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2126 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2127 if ( parser.getErrorCount() > 0 ) {
2128 System.out.println( parser.getErrorMessages().toString() );
2131 if ( phylogenies_1.length != 1 ) {
2134 final Phylogeny t2 = phylogenies_1[ 0 ];
2135 if ( t2.getNumberOfExternalNodes() != 664 ) {
2138 if ( !t2.isRooted() ) {
2141 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2144 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2147 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2150 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2153 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2156 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2157 .equals( "Aquifex" ) ) {
2160 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2161 if ( parser.getErrorCount() > 0 ) {
2162 System.out.println( parser.getErrorMessages().toString() );
2165 if ( phylogenies_2.length != 1 ) {
2168 final Phylogeny t3 = phylogenies_2[ 0 ];
2169 if ( t3.getNumberOfExternalNodes() != 184 ) {
2172 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2175 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2178 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2181 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2182 if ( parser.getErrorCount() > 0 ) {
2183 System.out.println( parser.getErrorMessages().toString() );
2186 if ( phylogenies_3.length != 1 ) {
2189 final Phylogeny t4 = phylogenies_3[ 0 ];
2190 if ( t4.getNumberOfExternalNodes() != 1 ) {
2193 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2196 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2199 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2202 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2203 if ( parser.getErrorCount() > 0 ) {
2204 System.out.println( parser.getErrorMessages().toString() );
2207 if ( phylogenies_4.length != 1 ) {
2210 final Phylogeny t5 = phylogenies_4[ 0 ];
2211 if ( t5.getNumberOfExternalNodes() != 13 ) {
2214 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2217 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2220 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2224 catch ( final Exception e ) {
2225 e.printStackTrace( System.out );
2231 private static boolean testBasicTreeMethods() {
2233 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2234 final Phylogeny t1 = factory.create();
2235 if ( !t1.isEmpty() ) {
2238 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2239 if ( t2.getNumberOfExternalNodes() != 4 ) {
2242 if ( t2.getHeight() != 8.5 ) {
2245 if ( !t2.isCompletelyBinary() ) {
2248 if ( t2.isEmpty() ) {
2251 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2252 if ( t3.getNumberOfExternalNodes() != 5 ) {
2255 if ( t3.getHeight() != 11 ) {
2258 if ( t3.isCompletelyBinary() ) {
2261 final PhylogenyNode n = t3.getNode( "ABC" );
2262 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 ];
2263 if ( t4.getNumberOfExternalNodes() != 9 ) {
2266 if ( t4.getHeight() != 11 ) {
2269 if ( t4.isCompletelyBinary() ) {
2272 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)" );
2273 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2274 if ( t5.getNumberOfExternalNodes() != 8 ) {
2277 if ( t5.getHeight() != 15 ) {
2280 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)" );
2281 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2282 if ( t6.getHeight() != 15 ) {
2285 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)" );
2286 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2287 if ( t7.getHeight() != 15 ) {
2290 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)" );
2291 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2292 if ( t8.getNumberOfExternalNodes() != 10 ) {
2295 if ( t8.getHeight() != 15 ) {
2298 final char[] a9 = new char[] { 'a' };
2299 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2300 if ( t9.getHeight() != 0 ) {
2303 final char[] a10 = new char[] { 'a', ':', '6' };
2304 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2305 if ( t10.getHeight() != 6 ) {
2309 catch ( final Exception e ) {
2310 e.printStackTrace( System.out );
2316 private static boolean testConfidenceAssessor() {
2318 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2319 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2320 final Phylogeny[] ev0 = factory
2321 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2323 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2324 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2327 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2330 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2331 final Phylogeny[] ev1 = factory
2332 .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)));",
2334 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2335 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2338 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2341 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2342 final Phylogeny[] ev_b = factory
2343 .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",
2345 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2346 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2349 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2353 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2354 final Phylogeny[] ev1x = factory
2355 .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)));",
2357 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2358 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2361 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2364 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2365 final Phylogeny[] ev_bx = factory
2366 .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",
2368 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2369 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2372 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2376 final Phylogeny[] t2 = factory
2377 .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);",
2379 final Phylogeny[] ev2 = factory
2380 .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);",
2382 for( final Phylogeny target : t2 ) {
2383 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2386 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2387 new NHXParser() )[ 0 ];
2388 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2389 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2390 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2393 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2396 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2400 catch ( final Exception e ) {
2401 e.printStackTrace();
2407 private static boolean testCopyOfNodeData() {
2409 final PhylogenyNode n1 = PhylogenyNode
2410 .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]" );
2411 final PhylogenyNode n2 = n1.copyNodeData();
2412 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2416 catch ( final Exception e ) {
2417 e.printStackTrace();
2423 private static boolean testCreateBalancedPhylogeny() {
2425 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2426 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2429 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2432 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2433 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2436 if ( p1.getNumberOfExternalNodes() != 100 ) {
2440 catch ( final Exception e ) {
2441 e.printStackTrace();
2447 private static boolean testCreateUriForSeqWeb() {
2449 final PhylogenyNode n = new PhylogenyNode();
2450 n.setName( "tr|B3RJ64" );
2451 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2454 n.setName( "B0LM41_HUMAN" );
2455 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2458 n.setName( "NP_001025424" );
2459 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2462 n.setName( "_NM_001030253-" );
2463 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2466 n.setName( "XM_002122186" );
2467 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2470 n.setName( "dgh_AAA34956_gdg" );
2471 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2474 n.setName( "j40f4_Q06891.1_fndn2 fnr3" );
2475 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "Q06891.1" ) ) {
2478 n.setName( "GI:394892" );
2479 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2480 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2483 n.setName( "gi_394892" );
2484 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2485 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2488 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2489 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2490 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2494 catch ( final Exception e ) {
2495 e.printStackTrace( System.out );
2501 private static boolean testDataObjects() {
2503 final Confidence s0 = new Confidence();
2504 final Confidence s1 = new Confidence();
2505 if ( !s0.isEqual( s1 ) ) {
2508 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2509 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2510 if ( s2.isEqual( s1 ) ) {
2513 if ( !s2.isEqual( s3 ) ) {
2516 final Confidence s4 = ( Confidence ) s3.copy();
2517 if ( !s4.isEqual( s3 ) ) {
2524 final Taxonomy t1 = new Taxonomy();
2525 final Taxonomy t2 = new Taxonomy();
2526 final Taxonomy t3 = new Taxonomy();
2527 final Taxonomy t4 = new Taxonomy();
2528 final Taxonomy t5 = new Taxonomy();
2529 t1.setIdentifier( new Identifier( "ecoli" ) );
2530 t1.setTaxonomyCode( "ECOLI" );
2531 t1.setScientificName( "E. coli" );
2532 t1.setCommonName( "coli" );
2533 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2534 if ( !t1.isEqual( t0 ) ) {
2537 t2.setIdentifier( new Identifier( "ecoli" ) );
2538 t2.setTaxonomyCode( "OTHER" );
2539 t2.setScientificName( "what" );
2540 t2.setCommonName( "something" );
2541 if ( !t1.isEqual( t2 ) ) {
2544 t2.setIdentifier( new Identifier( "nemve" ) );
2545 if ( t1.isEqual( t2 ) ) {
2548 t1.setIdentifier( null );
2549 t3.setTaxonomyCode( "ECOLI" );
2550 t3.setScientificName( "what" );
2551 t3.setCommonName( "something" );
2552 if ( !t1.isEqual( t3 ) ) {
2555 t1.setIdentifier( null );
2556 t1.setTaxonomyCode( "" );
2557 t4.setScientificName( "E. ColI" );
2558 t4.setCommonName( "something" );
2559 if ( !t1.isEqual( t4 ) ) {
2562 t4.setScientificName( "B. subtilis" );
2563 t4.setCommonName( "something" );
2564 if ( t1.isEqual( t4 ) ) {
2567 t1.setIdentifier( null );
2568 t1.setTaxonomyCode( "" );
2569 t1.setScientificName( "" );
2570 t5.setCommonName( "COLI" );
2571 if ( !t1.isEqual( t5 ) ) {
2574 t5.setCommonName( "vibrio" );
2575 if ( t1.isEqual( t5 ) ) {
2580 final Identifier id0 = new Identifier( "123", "pfam" );
2581 final Identifier id1 = ( Identifier ) id0.copy();
2582 if ( !id1.isEqual( id1 ) ) {
2585 if ( !id1.isEqual( id0 ) ) {
2588 if ( !id0.isEqual( id1 ) ) {
2595 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2596 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2597 if ( !pd1.isEqual( pd1 ) ) {
2600 if ( !pd1.isEqual( pd0 ) ) {
2605 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2606 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2607 if ( !pd3.isEqual( pd3 ) ) {
2610 if ( !pd2.isEqual( pd3 ) ) {
2613 if ( !pd0.isEqual( pd3 ) ) {
2618 // DomainArchitecture
2619 // ------------------
2620 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2621 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2622 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2623 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2624 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2625 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2630 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2631 if ( ds0.getNumberOfDomains() != 4 ) {
2634 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2635 if ( !ds0.isEqual( ds0 ) ) {
2638 if ( !ds0.isEqual( ds1 ) ) {
2641 if ( ds1.getNumberOfDomains() != 4 ) {
2644 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2649 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2650 if ( ds0.isEqual( ds2 ) ) {
2656 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2657 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2658 System.out.println( ds3.toNHX() );
2661 if ( ds3.getNumberOfDomains() != 3 ) {
2666 final Event e1 = new Event( Event.EventType.fusion );
2667 if ( e1.isDuplication() ) {
2670 if ( !e1.isFusion() ) {
2673 if ( !e1.asText().toString().equals( "fusion" ) ) {
2676 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2679 final Event e11 = new Event( Event.EventType.fusion );
2680 if ( !e11.isEqual( e1 ) ) {
2683 if ( !e11.toNHX().toString().equals( "" ) ) {
2686 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2687 if ( e2.isDuplication() ) {
2690 if ( !e2.isSpeciationOrDuplication() ) {
2693 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2696 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2699 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2702 if ( e11.isEqual( e2 ) ) {
2705 final Event e2c = ( Event ) e2.copy();
2706 if ( !e2c.isEqual( e2 ) ) {
2709 Event e3 = new Event( 1, 2, 3 );
2710 if ( e3.isDuplication() ) {
2713 if ( e3.isSpeciation() ) {
2716 if ( e3.isGeneLoss() ) {
2719 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2722 final Event e3c = ( Event ) e3.copy();
2723 final Event e3cc = ( Event ) e3c.copy();
2724 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2728 if ( !e3c.isEqual( e3cc ) ) {
2731 Event e4 = new Event( 1, 2, 3 );
2732 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2735 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2738 final Event e4c = ( Event ) e4.copy();
2740 final Event e4cc = ( Event ) e4c.copy();
2741 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2744 if ( !e4c.isEqual( e4cc ) ) {
2747 final Event e5 = new Event();
2748 if ( !e5.isUnassigned() ) {
2751 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2754 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2757 final Event e6 = new Event( 1, 0, 0 );
2758 if ( !e6.asText().toString().equals( "duplication" ) ) {
2761 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2764 final Event e7 = new Event( 0, 1, 0 );
2765 if ( !e7.asText().toString().equals( "speciation" ) ) {
2768 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2771 final Event e8 = new Event( 0, 0, 1 );
2772 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2775 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2779 catch ( final Exception e ) {
2780 e.printStackTrace( System.out );
2786 private static boolean testDeletionOfExternalNodes() {
2788 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2789 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2790 final PhylogenyWriter w = new PhylogenyWriter();
2791 if ( t0.isEmpty() ) {
2794 if ( t0.getNumberOfExternalNodes() != 1 ) {
2797 t0.deleteSubtree( t0.getNode( "A" ), false );
2798 if ( t0.getNumberOfExternalNodes() != 0 ) {
2801 if ( !t0.isEmpty() ) {
2804 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2805 if ( t1.getNumberOfExternalNodes() != 2 ) {
2808 t1.deleteSubtree( t1.getNode( "A" ), false );
2809 if ( t1.getNumberOfExternalNodes() != 1 ) {
2812 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2815 t1.deleteSubtree( t1.getNode( "B" ), false );
2816 if ( t1.getNumberOfExternalNodes() != 1 ) {
2819 t1.deleteSubtree( t1.getNode( "r" ), false );
2820 if ( !t1.isEmpty() ) {
2823 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2824 if ( t2.getNumberOfExternalNodes() != 3 ) {
2827 t2.deleteSubtree( t2.getNode( "B" ), false );
2828 if ( t2.getNumberOfExternalNodes() != 2 ) {
2831 t2.toNewHampshireX();
2832 PhylogenyNode n = t2.getNode( "A" );
2833 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2836 t2.deleteSubtree( t2.getNode( "A" ), false );
2837 if ( t2.getNumberOfExternalNodes() != 2 ) {
2840 t2.deleteSubtree( t2.getNode( "C" ), true );
2841 if ( t2.getNumberOfExternalNodes() != 1 ) {
2844 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2845 if ( t3.getNumberOfExternalNodes() != 4 ) {
2848 t3.deleteSubtree( t3.getNode( "B" ), true );
2849 if ( t3.getNumberOfExternalNodes() != 3 ) {
2852 n = t3.getNode( "A" );
2853 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2856 n = n.getNextExternalNode();
2857 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2860 t3.deleteSubtree( t3.getNode( "A" ), true );
2861 if ( t3.getNumberOfExternalNodes() != 2 ) {
2864 n = t3.getNode( "C" );
2865 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2868 t3.deleteSubtree( t3.getNode( "C" ), true );
2869 if ( t3.getNumberOfExternalNodes() != 1 ) {
2872 t3.deleteSubtree( t3.getNode( "D" ), true );
2873 if ( t3.getNumberOfExternalNodes() != 0 ) {
2876 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2877 if ( t4.getNumberOfExternalNodes() != 6 ) {
2880 t4.deleteSubtree( t4.getNode( "B2" ), true );
2881 if ( t4.getNumberOfExternalNodes() != 5 ) {
2884 String s = w.toNewHampshire( t4, false, true ).toString();
2885 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2888 t4.deleteSubtree( t4.getNode( "B11" ), true );
2889 if ( t4.getNumberOfExternalNodes() != 4 ) {
2892 t4.deleteSubtree( t4.getNode( "C" ), true );
2893 if ( t4.getNumberOfExternalNodes() != 3 ) {
2896 n = t4.getNode( "A" );
2897 n = n.getNextExternalNode();
2898 if ( !n.getName().equals( "B12" ) ) {
2901 n = n.getNextExternalNode();
2902 if ( !n.getName().equals( "D" ) ) {
2905 s = w.toNewHampshire( t4, false, true ).toString();
2906 if ( !s.equals( "((A,B12),D);" ) ) {
2909 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2910 t5.deleteSubtree( t5.getNode( "A" ), true );
2911 if ( t5.getNumberOfExternalNodes() != 5 ) {
2914 s = w.toNewHampshire( t5, false, true ).toString();
2915 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2918 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2919 t6.deleteSubtree( t6.getNode( "B11" ), true );
2920 if ( t6.getNumberOfExternalNodes() != 5 ) {
2923 s = w.toNewHampshire( t6, false, false ).toString();
2924 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2927 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2928 t7.deleteSubtree( t7.getNode( "B12" ), true );
2929 if ( t7.getNumberOfExternalNodes() != 5 ) {
2932 s = w.toNewHampshire( t7, false, true ).toString();
2933 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2936 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2937 t8.deleteSubtree( t8.getNode( "B2" ), true );
2938 if ( t8.getNumberOfExternalNodes() != 5 ) {
2941 s = w.toNewHampshire( t8, false, false ).toString();
2942 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2945 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2946 t9.deleteSubtree( t9.getNode( "C" ), true );
2947 if ( t9.getNumberOfExternalNodes() != 5 ) {
2950 s = w.toNewHampshire( t9, false, true ).toString();
2951 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2954 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2955 t10.deleteSubtree( t10.getNode( "D" ), true );
2956 if ( t10.getNumberOfExternalNodes() != 5 ) {
2959 s = w.toNewHampshire( t10, false, true ).toString();
2960 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
2963 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
2964 t11.deleteSubtree( t11.getNode( "A" ), true );
2965 if ( t11.getNumberOfExternalNodes() != 2 ) {
2968 s = w.toNewHampshire( t11, false, true ).toString();
2969 if ( !s.equals( "(B,C);" ) ) {
2972 t11.deleteSubtree( t11.getNode( "C" ), true );
2973 if ( t11.getNumberOfExternalNodes() != 1 ) {
2976 s = w.toNewHampshire( t11, false, false ).toString();
2977 if ( !s.equals( "B;" ) ) {
2980 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
2981 t12.deleteSubtree( t12.getNode( "B2" ), true );
2982 if ( t12.getNumberOfExternalNodes() != 8 ) {
2985 s = w.toNewHampshire( t12, false, true ).toString();
2986 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
2989 t12.deleteSubtree( t12.getNode( "B3" ), true );
2990 if ( t12.getNumberOfExternalNodes() != 7 ) {
2993 s = w.toNewHampshire( t12, false, true ).toString();
2994 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
2997 t12.deleteSubtree( t12.getNode( "C3" ), true );
2998 if ( t12.getNumberOfExternalNodes() != 6 ) {
3001 s = w.toNewHampshire( t12, false, true ).toString();
3002 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3005 t12.deleteSubtree( t12.getNode( "A1" ), true );
3006 if ( t12.getNumberOfExternalNodes() != 5 ) {
3009 s = w.toNewHampshire( t12, false, true ).toString();
3010 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3013 t12.deleteSubtree( t12.getNode( "B1" ), true );
3014 if ( t12.getNumberOfExternalNodes() != 4 ) {
3017 s = w.toNewHampshire( t12, false, true ).toString();
3018 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3021 t12.deleteSubtree( t12.getNode( "A3" ), true );
3022 if ( t12.getNumberOfExternalNodes() != 3 ) {
3025 s = w.toNewHampshire( t12, false, true ).toString();
3026 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3029 t12.deleteSubtree( t12.getNode( "A2" ), true );
3030 if ( t12.getNumberOfExternalNodes() != 2 ) {
3033 s = w.toNewHampshire( t12, false, true ).toString();
3034 if ( !s.equals( "(C1,C2);" ) ) {
3037 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3038 t13.deleteSubtree( t13.getNode( "D" ), true );
3039 if ( t13.getNumberOfExternalNodes() != 4 ) {
3042 s = w.toNewHampshire( t13, false, true ).toString();
3043 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3046 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3047 t14.deleteSubtree( t14.getNode( "E" ), true );
3048 if ( t14.getNumberOfExternalNodes() != 5 ) {
3051 s = w.toNewHampshire( t14, false, true ).toString();
3052 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3055 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3056 t15.deleteSubtree( t15.getNode( "B2" ), true );
3057 if ( t15.getNumberOfExternalNodes() != 11 ) {
3060 t15.deleteSubtree( t15.getNode( "B1" ), true );
3061 if ( t15.getNumberOfExternalNodes() != 10 ) {
3064 t15.deleteSubtree( t15.getNode( "B3" ), true );
3065 if ( t15.getNumberOfExternalNodes() != 9 ) {
3068 t15.deleteSubtree( t15.getNode( "B4" ), true );
3069 if ( t15.getNumberOfExternalNodes() != 8 ) {
3072 t15.deleteSubtree( t15.getNode( "A1" ), true );
3073 if ( t15.getNumberOfExternalNodes() != 7 ) {
3076 t15.deleteSubtree( t15.getNode( "C4" ), true );
3077 if ( t15.getNumberOfExternalNodes() != 6 ) {
3081 catch ( final Exception e ) {
3082 e.printStackTrace( System.out );
3088 private static boolean testDescriptiveStatistics() {
3090 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3091 dss1.addValue( 82 );
3092 dss1.addValue( 78 );
3093 dss1.addValue( 70 );
3094 dss1.addValue( 58 );
3095 dss1.addValue( 42 );
3096 if ( dss1.getN() != 5 ) {
3099 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3102 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3105 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3108 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3111 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3114 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3117 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3120 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3123 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3126 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3129 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3132 dss1.addValue( 123 );
3133 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3136 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3139 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3142 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3143 dss2.addValue( -1.85 );
3144 dss2.addValue( 57.5 );
3145 dss2.addValue( 92.78 );
3146 dss2.addValue( 57.78 );
3147 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3150 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3153 final double[] a = dss2.getDataAsDoubleArray();
3154 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3157 dss2.addValue( -100 );
3158 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3161 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3164 final double[] ds = new double[ 14 ];
3179 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3180 if ( bins.length != 4 ) {
3183 if ( bins[ 0 ] != 2 ) {
3186 if ( bins[ 1 ] != 3 ) {
3189 if ( bins[ 2 ] != 4 ) {
3192 if ( bins[ 3 ] != 5 ) {
3195 final double[] ds1 = new double[ 9 ];
3205 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3206 if ( bins1.length != 4 ) {
3209 if ( bins1[ 0 ] != 2 ) {
3212 if ( bins1[ 1 ] != 3 ) {
3215 if ( bins1[ 2 ] != 0 ) {
3218 if ( bins1[ 3 ] != 4 ) {
3221 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3222 if ( bins1_1.length != 3 ) {
3225 if ( bins1_1[ 0 ] != 3 ) {
3228 if ( bins1_1[ 1 ] != 2 ) {
3231 if ( bins1_1[ 2 ] != 4 ) {
3234 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3235 if ( bins1_2.length != 3 ) {
3238 if ( bins1_2[ 0 ] != 2 ) {
3241 if ( bins1_2[ 1 ] != 2 ) {
3244 if ( bins1_2[ 2 ] != 2 ) {
3247 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3261 dss3.addValue( 10 );
3262 dss3.addValue( 10 );
3263 dss3.addValue( 10 );
3264 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3265 histo.toStringBuffer( 10, '=', 40, 5 );
3266 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3268 catch ( final Exception e ) {
3269 e.printStackTrace( System.out );
3275 private static boolean testDir( final String file ) {
3277 final File f = new File( file );
3278 if ( !f.exists() ) {
3281 if ( !f.isDirectory() ) {
3284 if ( !f.canRead() ) {
3288 catch ( final Exception e ) {
3294 private static boolean testEmblEntryRetrieval() {
3295 //The format for GenBank Accession numbers are:
3296 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3297 //Protein: 3 letters + 5 numerals
3298 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3299 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
3302 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3305 if ( !SequenceIdParser.parseGenbankAccessor( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3308 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
3311 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
3314 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
3317 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
3320 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
3323 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
3326 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
3329 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
3332 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
3335 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
3338 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
3344 private static boolean testExternalNodeRelatedMethods() {
3346 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3347 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3348 PhylogenyNode n = t1.getNode( "A" );
3349 n = n.getNextExternalNode();
3350 if ( !n.getName().equals( "B" ) ) {
3353 n = n.getNextExternalNode();
3354 if ( !n.getName().equals( "C" ) ) {
3357 n = n.getNextExternalNode();
3358 if ( !n.getName().equals( "D" ) ) {
3361 n = t1.getNode( "B" );
3362 while ( !n.isLastExternalNode() ) {
3363 n = n.getNextExternalNode();
3365 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3366 n = t2.getNode( "A" );
3367 n = n.getNextExternalNode();
3368 if ( !n.getName().equals( "B" ) ) {
3371 n = n.getNextExternalNode();
3372 if ( !n.getName().equals( "C" ) ) {
3375 n = n.getNextExternalNode();
3376 if ( !n.getName().equals( "D" ) ) {
3379 n = t2.getNode( "B" );
3380 while ( !n.isLastExternalNode() ) {
3381 n = n.getNextExternalNode();
3383 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3384 n = t3.getNode( "A" );
3385 n = n.getNextExternalNode();
3386 if ( !n.getName().equals( "B" ) ) {
3389 n = n.getNextExternalNode();
3390 if ( !n.getName().equals( "C" ) ) {
3393 n = n.getNextExternalNode();
3394 if ( !n.getName().equals( "D" ) ) {
3397 n = n.getNextExternalNode();
3398 if ( !n.getName().equals( "E" ) ) {
3401 n = n.getNextExternalNode();
3402 if ( !n.getName().equals( "F" ) ) {
3405 n = n.getNextExternalNode();
3406 if ( !n.getName().equals( "G" ) ) {
3409 n = n.getNextExternalNode();
3410 if ( !n.getName().equals( "H" ) ) {
3413 n = t3.getNode( "B" );
3414 while ( !n.isLastExternalNode() ) {
3415 n = n.getNextExternalNode();
3417 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3418 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3419 final PhylogenyNode node = iter.next();
3421 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3422 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3423 final PhylogenyNode node = iter.next();
3425 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3426 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3427 if ( !iter.next().getName().equals( "A" ) ) {
3430 if ( !iter.next().getName().equals( "B" ) ) {
3433 if ( !iter.next().getName().equals( "C" ) ) {
3436 if ( !iter.next().getName().equals( "D" ) ) {
3439 if ( !iter.next().getName().equals( "E" ) ) {
3442 if ( !iter.next().getName().equals( "F" ) ) {
3445 if ( iter.hasNext() ) {
3449 catch ( final Exception e ) {
3450 e.printStackTrace( System.out );
3456 private static boolean testExtractSNFromNodeName() {
3458 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3461 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3462 .equals( "Mus musculus musculus" ) ) {
3465 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3466 .equals( "Mus musculus musculus" ) ) {
3469 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3472 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3473 .equals( "Mus musculus" ) ) {
3477 catch ( final Exception e ) {
3478 e.printStackTrace( System.out );
3484 private static boolean testExtractTaxonomyCodeFromNodeName() {
3486 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3489 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3490 .equals( "SOYBN" ) ) {
3493 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3494 .equals( "ARATH" ) ) {
3497 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3498 .equals( "ARATH" ) ) {
3501 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3504 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3507 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3510 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3511 .equals( "SOYBN" ) ) {
3514 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3515 .equals( "SOYBN" ) ) {
3518 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3519 .equals( "SOYBN" ) ) {
3522 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3523 .equals( "SOYBN" ) ) {
3526 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3527 .equals( "SOYBN" ) ) {
3530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3531 .equals( "SOYBN" ) ) {
3534 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3535 .equals( "SOYBN" ) ) {
3538 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3539 .equals( "SOYBN" ) ) {
3542 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3545 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3546 .equals( "SOYBN" ) ) {
3549 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3550 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3553 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3554 .equals( "9YX45" ) ) {
3557 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3558 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3559 .equals( "MOUSE" ) ) {
3562 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3563 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3564 .equals( "MOUSE" ) ) {
3567 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3568 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3569 .equals( "MOUSE" ) ) {
3572 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3573 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3576 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3577 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3580 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3581 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3584 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3585 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3588 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3589 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3592 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3593 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3596 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3597 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3600 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3601 .equals( "RAT" ) ) {
3604 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3605 .equals( "PIG" ) ) {
3609 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3610 .equals( "MOUSE" ) ) {
3613 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3614 .equals( "MOUSE" ) ) {
3617 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3621 catch ( final Exception e ) {
3622 e.printStackTrace( System.out );
3628 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3630 PhylogenyNode n = new PhylogenyNode();
3631 n.setName( "tr|B3RJ64" );
3632 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3635 n.setName( "tr.B3RJ64" );
3636 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3639 n.setName( "tr=B3RJ64" );
3640 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3643 n.setName( "tr-B3RJ64" );
3644 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3647 n.setName( "tr/B3RJ64" );
3648 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3651 n.setName( "tr\\B3RJ64" );
3652 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3655 n.setName( "tr_B3RJ64" );
3656 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3659 n.setName( " tr|B3RJ64 " );
3660 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3663 n.setName( "-tr|B3RJ64-" );
3664 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3667 n.setName( "-tr=B3RJ64-" );
3668 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3671 n.setName( "_tr=B3RJ64_" );
3672 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3675 n.setName( " tr_tr|B3RJ64_sp|123 " );
3676 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3679 n.setName( "sp|B3RJ64" );
3680 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3683 n.setName( "ssp|B3RJ64" );
3684 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3687 n.setName( "sp|B3RJ64C" );
3688 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3691 n.setName( "sp B3RJ64" );
3692 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3695 n.setName( "sp|B3RJ6X" );
3696 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3699 n.setName( "sp|B3RJ6" );
3700 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3703 n.setName( "K1PYK7_CRAGI" );
3704 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3707 n.setName( "K1PYK7_PEA" );
3708 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PEA" ) ) {
3711 n.setName( "K1PYK7_RAT" );
3712 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_RAT" ) ) {
3715 n.setName( "K1PYK7_PIG" );
3716 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3719 n.setName( "~K1PYK7_PIG~" );
3720 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3723 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3724 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3727 n.setName( "K1PYKX_CRAGI" );
3728 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3731 n.setName( "XXXXX_CRAGI" );
3732 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "XXXXX_CRAGI" ) ) {
3735 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3736 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "H3IB65" ) ) {
3739 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3740 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3743 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3744 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "Q86U06" ) ) {
3747 n = new PhylogenyNode();
3748 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3749 seq.setSymbol( "K1PYK7_CRAGI" );
3750 n.getNodeData().addSequence( seq );
3751 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3754 seq.setSymbol( "tr|B3RJ64" );
3755 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3758 n = new PhylogenyNode();
3759 seq = new org.forester.phylogeny.data.Sequence();
3760 seq.setName( "K1PYK7_CRAGI" );
3761 n.getNodeData().addSequence( seq );
3762 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3765 seq.setName( "tr|B3RJ64" );
3766 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3769 n = new PhylogenyNode();
3770 seq = new org.forester.phylogeny.data.Sequence();
3771 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3772 n.getNodeData().addSequence( seq );
3773 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK8_CRAGI" ) ) {
3776 n = new PhylogenyNode();
3777 seq = new org.forester.phylogeny.data.Sequence();
3778 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3779 n.getNodeData().addSequence( seq );
3780 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3784 n = new PhylogenyNode();
3785 n.setName( "ACP19736" );
3786 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3789 n = new PhylogenyNode();
3790 n.setName( "_ACP19736_" );
3791 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3795 catch ( final Exception e ) {
3796 e.printStackTrace( System.out );
3802 private static boolean testFastaParser() {
3804 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3807 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3810 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3811 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3814 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3817 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3820 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3823 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3826 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3830 catch ( final Exception e ) {
3831 e.printStackTrace();
3837 private static boolean testGeneralMsaParser() {
3839 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3840 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3841 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3842 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3843 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3844 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3845 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3846 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3847 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3850 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3853 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3856 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3859 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3862 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3865 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3868 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3871 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3874 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3877 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3880 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3883 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3884 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3887 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3890 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3893 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3894 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3897 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3900 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3903 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3904 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3907 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3910 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3914 catch ( final Exception e ) {
3915 e.printStackTrace();
3921 private static boolean testGeneralTable() {
3923 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3924 t0.setValue( 3, 2, "23" );
3925 t0.setValue( 10, 1, "error" );
3926 t0.setValue( 10, 1, "110" );
3927 t0.setValue( 9, 1, "19" );
3928 t0.setValue( 1, 10, "101" );
3929 t0.setValue( 10, 10, "1010" );
3930 t0.setValue( 100, 10, "10100" );
3931 t0.setValue( 0, 0, "00" );
3932 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3935 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3938 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3941 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3944 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3947 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3950 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3953 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
3956 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
3959 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
3960 t1.setValue( "3", "2", "23" );
3961 t1.setValue( "10", "1", "error" );
3962 t1.setValue( "10", "1", "110" );
3963 t1.setValue( "9", "1", "19" );
3964 t1.setValue( "1", "10", "101" );
3965 t1.setValue( "10", "10", "1010" );
3966 t1.setValue( "100", "10", "10100" );
3967 t1.setValue( "0", "0", "00" );
3968 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
3969 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
3972 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
3975 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
3978 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
3981 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
3984 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
3987 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
3990 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
3993 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
3996 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4000 catch ( final Exception e ) {
4001 e.printStackTrace( System.out );
4007 private static boolean testGetDistance() {
4009 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4010 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",
4011 new NHXParser() )[ 0 ];
4012 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4015 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4018 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4021 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4024 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4027 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4030 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4033 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4036 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4039 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4042 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4045 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4048 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4051 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4054 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4057 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4060 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4063 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4066 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4069 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4072 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4075 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4078 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4081 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4084 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4087 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4090 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4093 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4096 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4099 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4102 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4105 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",
4106 new NHXParser() )[ 0 ];
4107 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4110 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4113 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4116 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4119 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4122 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4125 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4128 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4131 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4134 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4137 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4141 catch ( final Exception e ) {
4142 e.printStackTrace( System.out );
4148 private static boolean testGetLCA() {
4150 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4151 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4152 new NHXParser() )[ 0 ];
4153 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4154 if ( !A.getName().equals( "A" ) ) {
4157 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4158 if ( !gh.getName().equals( "gh" ) ) {
4161 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4162 if ( !ab.getName().equals( "ab" ) ) {
4165 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4166 if ( !ab2.getName().equals( "ab" ) ) {
4169 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4170 if ( !gh2.getName().equals( "gh" ) ) {
4173 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4174 if ( !gh3.getName().equals( "gh" ) ) {
4177 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4178 if ( !abc.getName().equals( "abc" ) ) {
4181 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4182 if ( !abc2.getName().equals( "abc" ) ) {
4185 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4186 if ( !abcd.getName().equals( "abcd" ) ) {
4189 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4190 if ( !abcd2.getName().equals( "abcd" ) ) {
4193 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4194 if ( !abcdef.getName().equals( "abcdef" ) ) {
4197 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4198 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4201 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4202 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4205 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4206 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4209 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4210 if ( !abcde.getName().equals( "abcde" ) ) {
4213 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4214 if ( !abcde2.getName().equals( "abcde" ) ) {
4217 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4218 if ( !r.getName().equals( "abcdefgh" ) ) {
4221 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4222 if ( !r2.getName().equals( "abcdefgh" ) ) {
4225 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4226 if ( !r3.getName().equals( "abcdefgh" ) ) {
4229 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4230 if ( !abcde3.getName().equals( "abcde" ) ) {
4233 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4234 if ( !abcde4.getName().equals( "abcde" ) ) {
4237 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4238 if ( !ab3.getName().equals( "ab" ) ) {
4241 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4242 if ( !ab4.getName().equals( "ab" ) ) {
4245 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4246 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4247 if ( !cd.getName().equals( "cd" ) ) {
4250 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4251 if ( !cd2.getName().equals( "cd" ) ) {
4254 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4255 if ( !cde.getName().equals( "cde" ) ) {
4258 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4259 if ( !cde2.getName().equals( "cde" ) ) {
4262 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4263 if ( !cdef.getName().equals( "cdef" ) ) {
4266 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4267 if ( !cdef2.getName().equals( "cdef" ) ) {
4270 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4271 if ( !cdef3.getName().equals( "cdef" ) ) {
4274 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4275 if ( !rt.getName().equals( "r" ) ) {
4278 final Phylogeny p3 = factory
4279 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4280 new NHXParser() )[ 0 ];
4281 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4282 if ( !bc_3.getName().equals( "bc" ) ) {
4285 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4286 if ( !ac_3.getName().equals( "abc" ) ) {
4289 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4290 if ( !ad_3.getName().equals( "abcde" ) ) {
4293 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4294 if ( !af_3.getName().equals( "abcdef" ) ) {
4297 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4298 if ( !ag_3.getName().equals( "" ) ) {
4301 if ( !ag_3.isRoot() ) {
4304 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4305 if ( !al_3.getName().equals( "" ) ) {
4308 if ( !al_3.isRoot() ) {
4311 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4312 if ( !kl_3.getName().equals( "" ) ) {
4315 if ( !kl_3.isRoot() ) {
4318 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4319 if ( !fl_3.getName().equals( "" ) ) {
4322 if ( !fl_3.isRoot() ) {
4325 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4326 if ( !gk_3.getName().equals( "ghijk" ) ) {
4329 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4330 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4331 if ( !r_4.getName().equals( "r" ) ) {
4334 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4335 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4336 if ( !r_5.getName().equals( "root" ) ) {
4339 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4340 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4341 if ( !r_6.getName().equals( "rot" ) ) {
4344 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4345 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4346 if ( !r_7.getName().equals( "rott" ) ) {
4350 catch ( final Exception e ) {
4351 e.printStackTrace( System.out );
4357 private static boolean testGetLCA2() {
4359 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4360 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4361 PhylogenyMethods.preOrderReId( p_a );
4362 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4363 p_a.getNode( "a" ) );
4364 if ( !p_a_1.getName().equals( "a" ) ) {
4367 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4368 PhylogenyMethods.preOrderReId( p_b );
4369 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4370 p_b.getNode( "a" ) );
4371 if ( !p_b_1.getName().equals( "b" ) ) {
4374 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4375 p_b.getNode( "b" ) );
4376 if ( !p_b_2.getName().equals( "b" ) ) {
4379 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4380 PhylogenyMethods.preOrderReId( p_c );
4381 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4382 p_c.getNode( "a" ) );
4383 if ( !p_c_1.getName().equals( "b" ) ) {
4386 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4387 p_c.getNode( "c" ) );
4388 if ( !p_c_2.getName().equals( "c" ) ) {
4389 System.out.println( p_c_2.getName() );
4393 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4394 p_c.getNode( "b" ) );
4395 if ( !p_c_3.getName().equals( "b" ) ) {
4398 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4399 p_c.getNode( "a" ) );
4400 if ( !p_c_4.getName().equals( "c" ) ) {
4403 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4404 new NHXParser() )[ 0 ];
4405 PhylogenyMethods.preOrderReId( p1 );
4406 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4407 p1.getNode( "A" ) );
4408 if ( !A.getName().equals( "A" ) ) {
4411 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4412 p1.getNode( "gh" ) );
4413 if ( !gh.getName().equals( "gh" ) ) {
4416 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4417 p1.getNode( "B" ) );
4418 if ( !ab.getName().equals( "ab" ) ) {
4421 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4422 p1.getNode( "A" ) );
4423 if ( !ab2.getName().equals( "ab" ) ) {
4426 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4427 p1.getNode( "G" ) );
4428 if ( !gh2.getName().equals( "gh" ) ) {
4431 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4432 p1.getNode( "H" ) );
4433 if ( !gh3.getName().equals( "gh" ) ) {
4436 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4437 p1.getNode( "A" ) );
4438 if ( !abc.getName().equals( "abc" ) ) {
4441 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4442 p1.getNode( "C" ) );
4443 if ( !abc2.getName().equals( "abc" ) ) {
4446 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4447 p1.getNode( "D" ) );
4448 if ( !abcd.getName().equals( "abcd" ) ) {
4451 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4452 p1.getNode( "A" ) );
4453 if ( !abcd2.getName().equals( "abcd" ) ) {
4456 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4457 p1.getNode( "F" ) );
4458 if ( !abcdef.getName().equals( "abcdef" ) ) {
4461 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4462 p1.getNode( "A" ) );
4463 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4466 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4467 p1.getNode( "F" ) );
4468 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4471 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4472 p1.getNode( "ab" ) );
4473 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4476 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4477 p1.getNode( "E" ) );
4478 if ( !abcde.getName().equals( "abcde" ) ) {
4481 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4482 p1.getNode( "A" ) );
4483 if ( !abcde2.getName().equals( "abcde" ) ) {
4486 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4487 p1.getNode( "abcdefgh" ) );
4488 if ( !r.getName().equals( "abcdefgh" ) ) {
4491 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4492 p1.getNode( "H" ) );
4493 if ( !r2.getName().equals( "abcdefgh" ) ) {
4496 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4497 p1.getNode( "A" ) );
4498 if ( !r3.getName().equals( "abcdefgh" ) ) {
4501 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4502 p1.getNode( "abcde" ) );
4503 if ( !abcde3.getName().equals( "abcde" ) ) {
4506 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4507 p1.getNode( "E" ) );
4508 if ( !abcde4.getName().equals( "abcde" ) ) {
4511 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4512 p1.getNode( "B" ) );
4513 if ( !ab3.getName().equals( "ab" ) ) {
4516 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4517 p1.getNode( "ab" ) );
4518 if ( !ab4.getName().equals( "ab" ) ) {
4521 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4522 PhylogenyMethods.preOrderReId( p2 );
4523 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4524 p2.getNode( "d" ) );
4525 if ( !cd.getName().equals( "cd" ) ) {
4528 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4529 p2.getNode( "c" ) );
4530 if ( !cd2.getName().equals( "cd" ) ) {
4533 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4534 p2.getNode( "e" ) );
4535 if ( !cde.getName().equals( "cde" ) ) {
4538 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4539 p2.getNode( "c" ) );
4540 if ( !cde2.getName().equals( "cde" ) ) {
4543 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4544 p2.getNode( "f" ) );
4545 if ( !cdef.getName().equals( "cdef" ) ) {
4548 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4549 p2.getNode( "f" ) );
4550 if ( !cdef2.getName().equals( "cdef" ) ) {
4553 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4554 p2.getNode( "d" ) );
4555 if ( !cdef3.getName().equals( "cdef" ) ) {
4558 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4559 p2.getNode( "a" ) );
4560 if ( !rt.getName().equals( "r" ) ) {
4563 final Phylogeny p3 = factory
4564 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4565 new NHXParser() )[ 0 ];
4566 PhylogenyMethods.preOrderReId( p3 );
4567 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4568 p3.getNode( "c" ) );
4569 if ( !bc_3.getName().equals( "bc" ) ) {
4572 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4573 p3.getNode( "c" ) );
4574 if ( !ac_3.getName().equals( "abc" ) ) {
4577 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4578 p3.getNode( "d" ) );
4579 if ( !ad_3.getName().equals( "abcde" ) ) {
4582 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4583 p3.getNode( "f" ) );
4584 if ( !af_3.getName().equals( "abcdef" ) ) {
4587 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4588 p3.getNode( "g" ) );
4589 if ( !ag_3.getName().equals( "" ) ) {
4592 if ( !ag_3.isRoot() ) {
4595 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4596 p3.getNode( "l" ) );
4597 if ( !al_3.getName().equals( "" ) ) {
4600 if ( !al_3.isRoot() ) {
4603 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4604 p3.getNode( "l" ) );
4605 if ( !kl_3.getName().equals( "" ) ) {
4608 if ( !kl_3.isRoot() ) {
4611 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4612 p3.getNode( "l" ) );
4613 if ( !fl_3.getName().equals( "" ) ) {
4616 if ( !fl_3.isRoot() ) {
4619 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4620 p3.getNode( "k" ) );
4621 if ( !gk_3.getName().equals( "ghijk" ) ) {
4624 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4625 PhylogenyMethods.preOrderReId( p4 );
4626 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4627 p4.getNode( "c" ) );
4628 if ( !r_4.getName().equals( "r" ) ) {
4631 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4632 PhylogenyMethods.preOrderReId( p5 );
4633 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4634 p5.getNode( "c" ) );
4635 if ( !r_5.getName().equals( "root" ) ) {
4638 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4639 PhylogenyMethods.preOrderReId( p6 );
4640 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4641 p6.getNode( "a" ) );
4642 if ( !r_6.getName().equals( "rot" ) ) {
4645 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4646 PhylogenyMethods.preOrderReId( p7 );
4647 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4648 p7.getNode( "e" ) );
4649 if ( !r_7.getName().equals( "rott" ) ) {
4652 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4653 p7.getNode( "a" ) );
4654 if ( !r_71.getName().equals( "rott" ) ) {
4657 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4658 p7.getNode( "rott" ) );
4659 if ( !r_72.getName().equals( "rott" ) ) {
4662 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4663 p7.getNode( "a" ) );
4664 if ( !r_73.getName().equals( "rott" ) ) {
4667 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4668 p7.getNode( "rott" ) );
4669 if ( !r_74.getName().equals( "rott" ) ) {
4672 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4673 p7.getNode( "e" ) );
4674 if ( !r_75.getName().equals( "e" ) ) {
4678 catch ( final Exception e ) {
4679 e.printStackTrace( System.out );
4685 private static boolean testHmmscanOutputParser() {
4686 final String test_dir = Test.PATH_TO_TEST_DATA;
4688 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4689 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4691 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4692 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4693 final List<Protein> proteins = parser2.parse();
4694 if ( parser2.getProteinsEncountered() != 4 ) {
4697 if ( proteins.size() != 4 ) {
4700 if ( parser2.getDomainsEncountered() != 69 ) {
4703 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4706 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4709 final Protein p1 = proteins.get( 0 );
4710 if ( p1.getNumberOfProteinDomains() != 15 ) {
4713 if ( p1.getLength() != 850 ) {
4716 final Protein p2 = proteins.get( 1 );
4717 if ( p2.getNumberOfProteinDomains() != 51 ) {
4720 if ( p2.getLength() != 1291 ) {
4723 final Protein p3 = proteins.get( 2 );
4724 if ( p3.getNumberOfProteinDomains() != 2 ) {
4727 final Protein p4 = proteins.get( 3 );
4728 if ( p4.getNumberOfProteinDomains() != 1 ) {
4731 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4734 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4737 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4740 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4743 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4746 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4749 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4752 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4755 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4759 catch ( final Exception e ) {
4760 e.printStackTrace( System.out );
4766 private static boolean testLastExternalNodeMethods() {
4768 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4769 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4770 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4771 final PhylogenyNode n1 = t0.getNode( "A" );
4772 if ( n1.isLastExternalNode() ) {
4775 final PhylogenyNode n2 = t0.getNode( "B" );
4776 if ( n2.isLastExternalNode() ) {
4779 final PhylogenyNode n3 = t0.getNode( "C" );
4780 if ( n3.isLastExternalNode() ) {
4783 final PhylogenyNode n4 = t0.getNode( "D" );
4784 if ( !n4.isLastExternalNode() ) {
4788 catch ( final Exception e ) {
4789 e.printStackTrace( System.out );
4795 private static boolean testLevelOrderIterator() {
4797 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4798 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4799 PhylogenyNodeIterator it0;
4800 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4803 for( it0.reset(); it0.hasNext(); ) {
4806 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4807 if ( !it.next().getName().equals( "r" ) ) {
4810 if ( !it.next().getName().equals( "ab" ) ) {
4813 if ( !it.next().getName().equals( "cd" ) ) {
4816 if ( !it.next().getName().equals( "A" ) ) {
4819 if ( !it.next().getName().equals( "B" ) ) {
4822 if ( !it.next().getName().equals( "C" ) ) {
4825 if ( !it.next().getName().equals( "D" ) ) {
4828 if ( it.hasNext() ) {
4831 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",
4832 new NHXParser() )[ 0 ];
4833 PhylogenyNodeIterator it2;
4834 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4837 for( it2.reset(); it2.hasNext(); ) {
4840 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4841 if ( !it3.next().getName().equals( "r" ) ) {
4844 if ( !it3.next().getName().equals( "abc" ) ) {
4847 if ( !it3.next().getName().equals( "defg" ) ) {
4850 if ( !it3.next().getName().equals( "A" ) ) {
4853 if ( !it3.next().getName().equals( "B" ) ) {
4856 if ( !it3.next().getName().equals( "C" ) ) {
4859 if ( !it3.next().getName().equals( "D" ) ) {
4862 if ( !it3.next().getName().equals( "E" ) ) {
4865 if ( !it3.next().getName().equals( "F" ) ) {
4868 if ( !it3.next().getName().equals( "G" ) ) {
4871 if ( !it3.next().getName().equals( "1" ) ) {
4874 if ( !it3.next().getName().equals( "2" ) ) {
4877 if ( !it3.next().getName().equals( "3" ) ) {
4880 if ( !it3.next().getName().equals( "4" ) ) {
4883 if ( !it3.next().getName().equals( "5" ) ) {
4886 if ( !it3.next().getName().equals( "6" ) ) {
4889 if ( !it3.next().getName().equals( "f1" ) ) {
4892 if ( !it3.next().getName().equals( "f2" ) ) {
4895 if ( !it3.next().getName().equals( "f3" ) ) {
4898 if ( !it3.next().getName().equals( "a" ) ) {
4901 if ( !it3.next().getName().equals( "b" ) ) {
4904 if ( !it3.next().getName().equals( "f21" ) ) {
4907 if ( !it3.next().getName().equals( "X" ) ) {
4910 if ( !it3.next().getName().equals( "Y" ) ) {
4913 if ( !it3.next().getName().equals( "Z" ) ) {
4916 if ( it3.hasNext() ) {
4919 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4920 PhylogenyNodeIterator it4;
4921 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4924 for( it4.reset(); it4.hasNext(); ) {
4927 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4928 if ( !it5.next().getName().equals( "r" ) ) {
4931 if ( !it5.next().getName().equals( "A" ) ) {
4934 if ( !it5.next().getName().equals( "B" ) ) {
4937 if ( !it5.next().getName().equals( "C" ) ) {
4940 if ( !it5.next().getName().equals( "D" ) ) {
4943 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
4944 PhylogenyNodeIterator it6;
4945 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
4948 for( it6.reset(); it6.hasNext(); ) {
4951 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
4952 if ( !it7.next().getName().equals( "A" ) ) {
4955 if ( it.hasNext() ) {
4959 catch ( final Exception e ) {
4960 e.printStackTrace( System.out );
4966 private static boolean testMafft( final String path ) {
4968 final List<String> opts = new ArrayList<String>();
4969 opts.add( "--maxiterate" );
4971 opts.add( "--localpair" );
4972 opts.add( "--quiet" );
4974 final MsaInferrer mafft = Mafft.createInstance( path );
4975 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
4976 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
4979 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
4983 catch ( final Exception e ) {
4984 e.printStackTrace( System.out );
4990 private static boolean testMidpointrooting() {
4992 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4993 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
4994 PhylogenyMethods.midpointRoot( t0 );
4995 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
4998 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5001 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5005 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",
5006 new NHXParser() )[ 0 ];
5007 if ( !t1.isRooted() ) {
5010 PhylogenyMethods.midpointRoot( t1 );
5011 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5014 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5017 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5020 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5023 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5026 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5029 t1.reRoot( t1.getNode( "A" ) );
5030 PhylogenyMethods.midpointRoot( t1 );
5031 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5034 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5037 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5040 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5043 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5047 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5051 catch ( final Exception e ) {
5052 e.printStackTrace( System.out );
5058 private static boolean testMsaQualityMethod() {
5060 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5061 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5062 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5063 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5064 final List<Sequence> l = new ArrayList<Sequence>();
5069 final Msa msa = BasicMsa.createInstance( l );
5070 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5073 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5076 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5079 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5083 catch ( final Exception e ) {
5084 e.printStackTrace( System.out );
5090 private static boolean testNextNodeWithCollapsing() {
5092 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5094 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5095 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5096 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5097 t0.getNode( "cd" ).setCollapse( true );
5098 t0.getNode( "cde" ).setCollapse( true );
5099 n = t0.getFirstExternalNode();
5100 while ( n != null ) {
5102 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5104 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5107 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5110 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5113 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5116 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5119 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5123 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5124 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5125 t1.getNode( "ab" ).setCollapse( true );
5126 t1.getNode( "cd" ).setCollapse( true );
5127 t1.getNode( "cde" ).setCollapse( true );
5128 n = t1.getNode( "ab" );
5129 ext = new ArrayList<PhylogenyNode>();
5130 while ( n != null ) {
5132 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5134 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5137 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5140 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5143 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5146 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5152 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5153 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5154 t2.getNode( "ab" ).setCollapse( true );
5155 t2.getNode( "cd" ).setCollapse( true );
5156 t2.getNode( "cde" ).setCollapse( true );
5157 t2.getNode( "c" ).setCollapse( true );
5158 t2.getNode( "d" ).setCollapse( true );
5159 t2.getNode( "e" ).setCollapse( true );
5160 t2.getNode( "gh" ).setCollapse( true );
5161 n = t2.getNode( "ab" );
5162 ext = new ArrayList<PhylogenyNode>();
5163 while ( n != null ) {
5165 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5167 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5170 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5173 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5176 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5182 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5183 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5184 t3.getNode( "ab" ).setCollapse( true );
5185 t3.getNode( "cd" ).setCollapse( true );
5186 t3.getNode( "cde" ).setCollapse( true );
5187 t3.getNode( "c" ).setCollapse( true );
5188 t3.getNode( "d" ).setCollapse( true );
5189 t3.getNode( "e" ).setCollapse( true );
5190 t3.getNode( "gh" ).setCollapse( true );
5191 t3.getNode( "fgh" ).setCollapse( true );
5192 n = t3.getNode( "ab" );
5193 ext = new ArrayList<PhylogenyNode>();
5194 while ( n != null ) {
5196 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5198 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5201 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5204 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5210 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5211 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5212 t4.getNode( "ab" ).setCollapse( true );
5213 t4.getNode( "cd" ).setCollapse( true );
5214 t4.getNode( "cde" ).setCollapse( true );
5215 t4.getNode( "c" ).setCollapse( true );
5216 t4.getNode( "d" ).setCollapse( true );
5217 t4.getNode( "e" ).setCollapse( true );
5218 t4.getNode( "gh" ).setCollapse( true );
5219 t4.getNode( "fgh" ).setCollapse( true );
5220 t4.getNode( "abcdefgh" ).setCollapse( true );
5221 n = t4.getNode( "abcdefgh" );
5222 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5227 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5228 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5230 n = t5.getFirstExternalNode();
5231 while ( n != null ) {
5233 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5235 if ( ext.size() != 8 ) {
5238 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5241 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5244 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5247 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5250 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5253 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5256 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5259 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5264 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5265 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5267 t6.getNode( "ab" ).setCollapse( true );
5268 n = t6.getNode( "ab" );
5269 while ( n != null ) {
5271 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5273 if ( ext.size() != 7 ) {
5276 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5279 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5282 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5285 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5288 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5291 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5294 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5299 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5300 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5302 t7.getNode( "cd" ).setCollapse( true );
5303 n = t7.getNode( "a" );
5304 while ( n != null ) {
5306 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5308 if ( ext.size() != 7 ) {
5311 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5314 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5317 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5320 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5323 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5326 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5329 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5334 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5335 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5337 t8.getNode( "cd" ).setCollapse( true );
5338 t8.getNode( "c" ).setCollapse( true );
5339 t8.getNode( "d" ).setCollapse( true );
5340 n = t8.getNode( "a" );
5341 while ( n != null ) {
5343 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5345 if ( ext.size() != 7 ) {
5348 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5351 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5354 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5355 System.out.println( "2 fail" );
5358 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5361 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5364 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5367 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5372 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5373 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5375 t9.getNode( "gh" ).setCollapse( true );
5376 n = t9.getNode( "a" );
5377 while ( n != null ) {
5379 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5381 if ( ext.size() != 7 ) {
5384 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5387 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5390 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5393 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5396 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5399 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5402 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5407 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5408 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5410 t10.getNode( "gh" ).setCollapse( true );
5411 t10.getNode( "g" ).setCollapse( true );
5412 t10.getNode( "h" ).setCollapse( true );
5413 n = t10.getNode( "a" );
5414 while ( n != null ) {
5416 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5418 if ( ext.size() != 7 ) {
5421 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5424 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5427 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5430 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5433 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5436 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5439 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5444 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5445 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5447 t11.getNode( "gh" ).setCollapse( true );
5448 t11.getNode( "fgh" ).setCollapse( true );
5449 n = t11.getNode( "a" );
5450 while ( n != null ) {
5452 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5454 if ( ext.size() != 6 ) {
5457 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5460 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5463 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5466 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5469 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5472 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5477 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5478 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5480 t12.getNode( "gh" ).setCollapse( true );
5481 t12.getNode( "fgh" ).setCollapse( true );
5482 t12.getNode( "g" ).setCollapse( true );
5483 t12.getNode( "h" ).setCollapse( true );
5484 t12.getNode( "f" ).setCollapse( true );
5485 n = t12.getNode( "a" );
5486 while ( n != null ) {
5488 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5490 if ( ext.size() != 6 ) {
5493 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5496 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5499 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5502 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5505 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5508 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5513 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5514 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5516 t13.getNode( "ab" ).setCollapse( true );
5517 t13.getNode( "b" ).setCollapse( true );
5518 t13.getNode( "fgh" ).setCollapse( true );
5519 t13.getNode( "gh" ).setCollapse( true );
5520 n = t13.getNode( "ab" );
5521 while ( n != null ) {
5523 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5525 if ( ext.size() != 5 ) {
5528 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5531 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5534 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5537 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5540 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5545 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5546 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5548 t14.getNode( "ab" ).setCollapse( true );
5549 t14.getNode( "a" ).setCollapse( true );
5550 t14.getNode( "fgh" ).setCollapse( true );
5551 t14.getNode( "gh" ).setCollapse( true );
5552 n = t14.getNode( "ab" );
5553 while ( n != null ) {
5555 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5557 if ( ext.size() != 5 ) {
5560 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5563 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5566 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5569 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5572 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5577 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" );
5578 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5580 t15.getNode( "ab" ).setCollapse( true );
5581 t15.getNode( "a" ).setCollapse( true );
5582 t15.getNode( "fgh" ).setCollapse( true );
5583 t15.getNode( "gh" ).setCollapse( true );
5584 n = t15.getNode( "ab" );
5585 while ( n != null ) {
5587 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5589 if ( ext.size() != 6 ) {
5592 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5595 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5598 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5601 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5604 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5607 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5612 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" );
5613 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5615 t16.getNode( "ab" ).setCollapse( true );
5616 t16.getNode( "a" ).setCollapse( true );
5617 t16.getNode( "fgh" ).setCollapse( true );
5618 t16.getNode( "gh" ).setCollapse( true );
5619 t16.getNode( "cd" ).setCollapse( true );
5620 t16.getNode( "cde" ).setCollapse( true );
5621 t16.getNode( "d" ).setCollapse( true );
5622 t16.getNode( "x" ).setCollapse( true );
5623 n = t16.getNode( "ab" );
5624 while ( n != null ) {
5626 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5628 if ( ext.size() != 4 ) {
5631 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5634 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5637 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5640 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5644 catch ( final Exception e ) {
5645 e.printStackTrace( System.out );
5651 private static boolean testNexusCharactersParsing() {
5653 final NexusCharactersParser parser = new NexusCharactersParser();
5654 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5656 String[] labels = parser.getCharStateLabels();
5657 if ( labels.length != 7 ) {
5660 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5663 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5666 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5669 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5672 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5675 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5678 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5681 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5683 labels = parser.getCharStateLabels();
5684 if ( labels.length != 7 ) {
5687 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5690 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5693 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5696 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5699 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5702 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5705 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5709 catch ( final Exception e ) {
5710 e.printStackTrace( System.out );
5716 private static boolean testNexusMatrixParsing() {
5718 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5719 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5721 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5722 if ( m.getNumberOfCharacters() != 9 ) {
5725 if ( m.getNumberOfIdentifiers() != 5 ) {
5728 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5731 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5734 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5737 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5740 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5743 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5746 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5749 // if ( labels.length != 7 ) {
5752 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5755 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5758 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5761 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5764 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5767 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5770 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5773 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5775 // labels = parser.getCharStateLabels();
5776 // if ( labels.length != 7 ) {
5779 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5782 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5785 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5788 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5791 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5794 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5797 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5801 catch ( final Exception e ) {
5802 e.printStackTrace( System.out );
5808 private static boolean testNexusTreeParsing() {
5810 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5811 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5812 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5813 if ( phylogenies.length != 1 ) {
5816 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5819 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5823 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5824 if ( phylogenies.length != 1 ) {
5827 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5830 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5834 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5835 if ( phylogenies.length != 1 ) {
5838 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5841 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5844 if ( phylogenies[ 0 ].isRooted() ) {
5848 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5849 if ( phylogenies.length != 18 ) {
5852 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5855 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5858 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5861 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5864 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5867 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5870 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5873 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5876 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5879 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5882 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5885 if ( phylogenies[ 8 ].isRooted() ) {
5888 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5891 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5894 if ( !phylogenies[ 9 ].isRooted() ) {
5897 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5900 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5903 if ( !phylogenies[ 10 ].isRooted() ) {
5906 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5909 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5912 if ( phylogenies[ 11 ].isRooted() ) {
5915 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
5918 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
5921 if ( !phylogenies[ 12 ].isRooted() ) {
5924 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
5927 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
5930 if ( !phylogenies[ 13 ].isRooted() ) {
5933 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
5936 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
5939 if ( !phylogenies[ 14 ].isRooted() ) {
5942 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
5945 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
5948 if ( phylogenies[ 15 ].isRooted() ) {
5951 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
5954 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
5957 if ( !phylogenies[ 16 ].isRooted() ) {
5960 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
5963 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
5966 if ( phylogenies[ 17 ].isRooted() ) {
5969 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
5973 catch ( final Exception e ) {
5974 e.printStackTrace( System.out );
5980 private static boolean testNexusTreeParsingIterating() {
5982 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
5983 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
5984 if ( !p.hasNext() ) {
5987 Phylogeny phy = p.next();
5988 if ( phy == null ) {
5991 if ( phy.getNumberOfExternalNodes() != 25 ) {
5994 if ( !phy.getName().equals( "" ) ) {
5997 if ( p.hasNext() ) {
6001 if ( phy != null ) {
6006 if ( !p.hasNext() ) {
6010 if ( phy == null ) {
6013 if ( phy.getNumberOfExternalNodes() != 25 ) {
6016 if ( !phy.getName().equals( "" ) ) {
6019 if ( p.hasNext() ) {
6023 if ( phy != null ) {
6027 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6028 if ( !p.hasNext() ) {
6032 if ( phy == null ) {
6035 if ( phy.getNumberOfExternalNodes() != 10 ) {
6038 if ( !phy.getName().equals( "name" ) ) {
6041 if ( p.hasNext() ) {
6045 if ( phy != null ) {
6050 if ( !p.hasNext() ) {
6054 if ( phy == null ) {
6057 if ( phy.getNumberOfExternalNodes() != 10 ) {
6060 if ( !phy.getName().equals( "name" ) ) {
6063 if ( p.hasNext() ) {
6067 if ( phy != null ) {
6071 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6072 if ( !p.hasNext() ) {
6076 if ( phy == null ) {
6079 if ( phy.getNumberOfExternalNodes() != 3 ) {
6082 if ( !phy.getName().equals( "" ) ) {
6085 if ( phy.isRooted() ) {
6088 if ( p.hasNext() ) {
6092 if ( phy != null ) {
6097 if ( !p.hasNext() ) {
6101 if ( phy == null ) {
6104 if ( phy.getNumberOfExternalNodes() != 3 ) {
6107 if ( !phy.getName().equals( "" ) ) {
6110 if ( p.hasNext() ) {
6114 if ( phy != null ) {
6118 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6119 // if ( phylogenies.length != 18 ) {
6123 if ( !p.hasNext() ) {
6127 if ( phy == null ) {
6130 if ( phy.getNumberOfExternalNodes() != 10 ) {
6133 if ( !phy.getName().equals( "tree 0" ) ) {
6137 if ( !p.hasNext() ) {
6141 if ( phy == null ) {
6144 if ( phy.getNumberOfExternalNodes() != 10 ) {
6147 if ( !phy.getName().equals( "tree 1" ) ) {
6151 if ( !p.hasNext() ) {
6155 if ( phy == null ) {
6158 if ( phy.getNumberOfExternalNodes() != 3 ) {
6161 if ( !phy.getName().equals( "" ) ) {
6164 if ( phy.isRooted() ) {
6168 if ( !p.hasNext() ) {
6172 if ( phy == null ) {
6175 if ( phy.getNumberOfExternalNodes() != 4 ) {
6178 if ( !phy.getName().equals( "" ) ) {
6181 if ( !phy.isRooted() ) {
6185 if ( !p.hasNext() ) {
6189 if ( phy == null ) {
6192 if ( phy.getNumberOfExternalNodes() != 5 ) {
6193 System.out.println( phy.getNumberOfExternalNodes() );
6196 if ( !phy.getName().equals( "" ) ) {
6199 if ( !phy.isRooted() ) {
6203 if ( !p.hasNext() ) {
6207 if ( phy == null ) {
6210 if ( phy.getNumberOfExternalNodes() != 3 ) {
6213 if ( !phy.getName().equals( "" ) ) {
6216 if ( phy.isRooted() ) {
6220 if ( !p.hasNext() ) {
6224 if ( phy == null ) {
6227 if ( phy.getNumberOfExternalNodes() != 2 ) {
6230 if ( !phy.getName().equals( "" ) ) {
6233 if ( !phy.isRooted() ) {
6237 if ( !p.hasNext() ) {
6241 if ( phy.getNumberOfExternalNodes() != 3 ) {
6244 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6247 if ( !phy.isRooted() ) {
6251 if ( !p.hasNext() ) {
6255 if ( phy.getNumberOfExternalNodes() != 3 ) {
6258 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6261 if ( !phy.getName().equals( "tree 8" ) ) {
6265 if ( !p.hasNext() ) {
6269 if ( phy.getNumberOfExternalNodes() != 3 ) {
6272 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6275 if ( !phy.getName().equals( "tree 9" ) ) {
6279 if ( !p.hasNext() ) {
6283 if ( phy.getNumberOfExternalNodes() != 3 ) {
6286 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6289 if ( !phy.getName().equals( "tree 10" ) ) {
6292 if ( !phy.isRooted() ) {
6296 if ( !p.hasNext() ) {
6300 if ( phy.getNumberOfExternalNodes() != 3 ) {
6303 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6306 if ( !phy.getName().equals( "tree 11" ) ) {
6309 if ( phy.isRooted() ) {
6313 if ( !p.hasNext() ) {
6317 if ( phy.getNumberOfExternalNodes() != 3 ) {
6320 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6323 if ( !phy.getName().equals( "tree 12" ) ) {
6326 if ( !phy.isRooted() ) {
6330 if ( !p.hasNext() ) {
6334 if ( phy.getNumberOfExternalNodes() != 3 ) {
6337 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6340 if ( !phy.getName().equals( "tree 13" ) ) {
6343 if ( !phy.isRooted() ) {
6347 if ( !p.hasNext() ) {
6351 if ( phy.getNumberOfExternalNodes() != 10 ) {
6352 System.out.println( phy.getNumberOfExternalNodes() );
6357 .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;" ) ) {
6358 System.out.println( phy.toNewHampshire() );
6361 if ( !phy.getName().equals( "tree 14" ) ) {
6364 if ( !phy.isRooted() ) {
6368 if ( !p.hasNext() ) {
6372 if ( phy.getNumberOfExternalNodes() != 10 ) {
6373 System.out.println( phy.getNumberOfExternalNodes() );
6378 .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;" ) ) {
6379 System.out.println( phy.toNewHampshire() );
6382 if ( !phy.getName().equals( "tree 15" ) ) {
6385 if ( phy.isRooted() ) {
6389 if ( !p.hasNext() ) {
6393 if ( phy.getNumberOfExternalNodes() != 10 ) {
6394 System.out.println( phy.getNumberOfExternalNodes() );
6399 .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;" ) ) {
6400 System.out.println( phy.toNewHampshire() );
6403 if ( !phy.getName().equals( "tree 16" ) ) {
6406 if ( !phy.isRooted() ) {
6410 if ( !p.hasNext() ) {
6414 if ( phy.getNumberOfExternalNodes() != 10 ) {
6415 System.out.println( phy.getNumberOfExternalNodes() );
6420 .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;" ) ) {
6421 System.out.println( phy.toNewHampshire() );
6424 if ( !phy.getName().equals( "tree 17" ) ) {
6427 if ( phy.isRooted() ) {
6431 if ( p.hasNext() ) {
6435 if ( phy != null ) {
6440 if ( !p.hasNext() ) {
6444 if ( phy == null ) {
6447 if ( phy.getNumberOfExternalNodes() != 10 ) {
6450 if ( !phy.getName().equals( "tree 0" ) ) {
6454 if ( !p.hasNext() ) {
6458 if ( phy == null ) {
6461 if ( phy.getNumberOfExternalNodes() != 10 ) {
6464 if ( !phy.getName().equals( "tree 1" ) ) {
6468 if ( !p.hasNext() ) {
6472 if ( phy == null ) {
6475 if ( phy.getNumberOfExternalNodes() != 3 ) {
6478 if ( !phy.getName().equals( "" ) ) {
6481 if ( phy.isRooted() ) {
6485 if ( !p.hasNext() ) {
6489 if ( phy == null ) {
6492 if ( phy.getNumberOfExternalNodes() != 4 ) {
6495 if ( !phy.getName().equals( "" ) ) {
6498 if ( !phy.isRooted() ) {
6502 if ( !p.hasNext() ) {
6506 if ( phy == null ) {
6509 if ( phy.getNumberOfExternalNodes() != 5 ) {
6510 System.out.println( phy.getNumberOfExternalNodes() );
6513 if ( !phy.getName().equals( "" ) ) {
6516 if ( !phy.isRooted() ) {
6520 if ( !p.hasNext() ) {
6524 if ( phy == null ) {
6527 if ( phy.getNumberOfExternalNodes() != 3 ) {
6530 if ( !phy.getName().equals( "" ) ) {
6533 if ( phy.isRooted() ) {
6537 catch ( final Exception e ) {
6538 e.printStackTrace( System.out );
6544 private static boolean testNexusTreeParsingTranslating() {
6546 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6547 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6548 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6549 if ( phylogenies.length != 1 ) {
6552 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6555 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6558 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6561 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6564 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6565 .equals( "Aranaeus" ) ) {
6569 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6570 if ( phylogenies.length != 3 ) {
6573 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6576 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6579 if ( phylogenies[ 0 ].isRooted() ) {
6582 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6585 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6588 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6589 .equals( "Aranaeus" ) ) {
6592 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6595 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6598 if ( phylogenies[ 1 ].isRooted() ) {
6601 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6604 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6607 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6608 .equals( "Aranaeus" ) ) {
6611 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6614 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6617 if ( !phylogenies[ 2 ].isRooted() ) {
6620 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6623 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6626 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6627 .equals( "Aranaeus" ) ) {
6631 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6632 if ( phylogenies.length != 3 ) {
6635 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6638 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6641 if ( phylogenies[ 0 ].isRooted() ) {
6644 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6647 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6650 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6651 .equals( "Aranaeus" ) ) {
6654 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6657 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6660 if ( phylogenies[ 1 ].isRooted() ) {
6663 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6666 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6669 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6670 .equals( "Aranaeus" ) ) {
6673 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6676 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6679 if ( !phylogenies[ 2 ].isRooted() ) {
6682 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6685 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6688 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6689 .equals( "Aranaeus" ) ) {
6693 catch ( final Exception e ) {
6694 e.printStackTrace( System.out );
6700 private static boolean testNHParsing() {
6702 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6703 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6704 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6707 final NHXParser nhxp = new NHXParser();
6708 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6709 nhxp.setReplaceUnderscores( true );
6710 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6711 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6714 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6717 final Phylogeny p1b = factory
6718 .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 ",
6719 new NHXParser() )[ 0 ];
6720 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6723 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6726 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6727 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6728 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6729 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6730 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6731 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6732 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6733 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6734 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6735 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6736 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6737 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6738 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6740 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6743 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6746 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6749 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6752 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6753 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6754 final String p16_S = "((A,B),C)";
6755 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6756 if ( p16.length != 1 ) {
6759 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6762 final String p17_S = "(C,(A,B))";
6763 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6764 if ( p17.length != 1 ) {
6767 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6770 final String p18_S = "((A,B),(C,D))";
6771 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6772 if ( p18.length != 1 ) {
6775 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6778 final String p19_S = "(((A,B),C),D)";
6779 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6780 if ( p19.length != 1 ) {
6783 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6786 final String p20_S = "(A,(B,(C,D)))";
6787 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6788 if ( p20.length != 1 ) {
6791 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6794 final String p21_S = "(A,(B,(C,(D,E))))";
6795 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6796 if ( p21.length != 1 ) {
6799 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6802 final String p22_S = "((((A,B),C),D),E)";
6803 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6804 if ( p22.length != 1 ) {
6807 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6810 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6811 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6812 if ( p23.length != 1 ) {
6813 System.out.println( "xl=" + p23.length );
6817 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6820 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6821 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6822 if ( p24.length != 1 ) {
6825 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6828 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6829 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6830 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6831 if ( p241.length != 2 ) {
6834 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6837 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6840 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6841 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6842 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6843 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6844 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6845 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6846 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6847 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6848 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6849 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6852 final String p26_S = "(A,B)ab";
6853 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6854 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6857 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6858 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6859 if ( p27s.length != 1 ) {
6860 System.out.println( "xxl=" + p27s.length );
6864 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6865 System.out.println( p27s[ 0 ].toNewHampshireX() );
6869 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6871 if ( p27.length != 1 ) {
6872 System.out.println( "yl=" + p27.length );
6876 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6877 System.out.println( p27[ 0 ].toNewHampshireX() );
6881 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6882 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6883 final String p28_S3 = "(A,B)ab";
6884 final String p28_S4 = "((((A,B),C),D),;E;)";
6885 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6887 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6890 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6893 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6896 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6899 if ( p28.length != 4 ) {
6902 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";
6903 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6904 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6907 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";
6908 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6909 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6912 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6913 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6914 if ( ( p32.length != 0 ) ) {
6917 final String p33_S = "A";
6918 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
6919 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
6922 final String p34_S = "B;";
6923 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
6924 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
6927 final String p35_S = "B:0.2";
6928 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
6929 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
6932 final String p36_S = "(A)";
6933 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
6934 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
6937 final String p37_S = "((A))";
6938 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
6939 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
6942 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6943 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
6944 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
6947 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6948 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
6949 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
6952 final String p40_S = "(A,B,C)";
6953 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
6954 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
6957 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
6958 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
6959 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
6962 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
6963 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
6964 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
6967 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)";
6968 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
6969 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
6972 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)))";
6973 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
6974 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
6977 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
6978 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
6979 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
6982 final String p46_S = "";
6983 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
6984 if ( p46.length != 0 ) {
6987 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
6988 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
6991 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
6992 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
6995 final Phylogeny p49 = factory
6996 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
6997 new NHXParser() )[ 0 ];
6998 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7001 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7002 if ( p50.getNode( "A" ) == null ) {
7005 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7006 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7009 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7012 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7013 .equals( "((A,B)88:2.0,C);" ) ) {
7016 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7017 if ( p51.getNode( "A(A" ) == null ) {
7020 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7021 if ( p52.getNode( "A(A" ) == null ) {
7024 final Phylogeny p53 = factory
7025 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7026 new NHXParser() )[ 0 ];
7027 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7031 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7032 if ( p54.getNode( "A" ) == null ) {
7035 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7036 .equals( "((A,B)[88],C);" ) ) {
7040 catch ( final Exception e ) {
7041 e.printStackTrace( System.out );
7047 private static boolean testNHParsingIter() {
7049 final String p0_str = "(A,B);";
7050 final NHXParser p = new NHXParser();
7051 p.setSource( p0_str );
7052 if ( !p.hasNext() ) {
7055 final Phylogeny p0 = p.next();
7056 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7057 System.out.println( p0.toNewHampshire() );
7060 if ( p.hasNext() ) {
7063 if ( p.next() != null ) {
7067 final String p00_str = "(A,B)root;";
7068 p.setSource( p00_str );
7069 final Phylogeny p00 = p.next();
7070 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7071 System.out.println( p00.toNewHampshire() );
7075 final String p000_str = "A;";
7076 p.setSource( p000_str );
7077 final Phylogeny p000 = p.next();
7078 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7079 System.out.println( p000.toNewHampshire() );
7083 final String p0000_str = "A";
7084 p.setSource( p0000_str );
7085 final Phylogeny p0000 = p.next();
7086 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7087 System.out.println( p0000.toNewHampshire() );
7091 p.setSource( "(A)" );
7092 final Phylogeny p00000 = p.next();
7093 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7094 System.out.println( p00000.toNewHampshire() );
7098 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7099 p.setSource( p1_str );
7100 if ( !p.hasNext() ) {
7103 final Phylogeny p1_0 = p.next();
7104 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7105 System.out.println( p1_0.toNewHampshire() );
7108 if ( !p.hasNext() ) {
7111 final Phylogeny p1_1 = p.next();
7112 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7113 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7116 if ( !p.hasNext() ) {
7119 final Phylogeny p1_2 = p.next();
7120 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7121 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7124 if ( !p.hasNext() ) {
7127 final Phylogeny p1_3 = p.next();
7128 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7129 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7132 if ( p.hasNext() ) {
7135 if ( p.next() != null ) {
7139 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7140 p.setSource( p2_str );
7141 if ( !p.hasNext() ) {
7144 Phylogeny p2_0 = p.next();
7145 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7146 System.out.println( p2_0.toNewHampshire() );
7149 if ( !p.hasNext() ) {
7152 Phylogeny p2_1 = p.next();
7153 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7154 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7157 if ( !p.hasNext() ) {
7160 Phylogeny p2_2 = p.next();
7161 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7162 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7165 if ( !p.hasNext() ) {
7168 Phylogeny p2_3 = p.next();
7169 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7170 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7173 if ( !p.hasNext() ) {
7176 Phylogeny p2_4 = p.next();
7177 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7178 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7181 if ( p.hasNext() ) {
7184 if ( p.next() != null ) {
7189 if ( !p.hasNext() ) {
7193 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7194 System.out.println( p2_0.toNewHampshire() );
7197 if ( !p.hasNext() ) {
7201 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7202 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7205 if ( !p.hasNext() ) {
7209 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7210 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7213 if ( !p.hasNext() ) {
7217 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7218 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7221 if ( !p.hasNext() ) {
7225 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7226 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7229 if ( p.hasNext() ) {
7232 if ( p.next() != null ) {
7236 final String p3_str = "((A,B),C)abc";
7237 p.setSource( p3_str );
7238 if ( !p.hasNext() ) {
7241 final Phylogeny p3_0 = p.next();
7242 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7245 if ( p.hasNext() ) {
7248 if ( p.next() != null ) {
7252 final String p4_str = "((A,B)ab,C)abc";
7253 p.setSource( p4_str );
7254 if ( !p.hasNext() ) {
7257 final Phylogeny p4_0 = p.next();
7258 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7261 if ( p.hasNext() ) {
7264 if ( p.next() != null ) {
7268 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7269 p.setSource( p5_str );
7270 if ( !p.hasNext() ) {
7273 final Phylogeny p5_0 = p.next();
7274 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7277 if ( p.hasNext() ) {
7280 if ( p.next() != null ) {
7284 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7285 p.setSource( p6_str );
7286 if ( !p.hasNext() ) {
7289 Phylogeny p6_0 = p.next();
7290 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7293 if ( p.hasNext() ) {
7296 if ( p.next() != null ) {
7300 if ( !p.hasNext() ) {
7304 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7307 if ( p.hasNext() ) {
7310 if ( p.next() != null ) {
7314 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7315 p.setSource( p7_str );
7316 if ( !p.hasNext() ) {
7319 Phylogeny p7_0 = p.next();
7320 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7323 if ( p.hasNext() ) {
7326 if ( p.next() != null ) {
7330 if ( !p.hasNext() ) {
7334 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7337 if ( p.hasNext() ) {
7340 if ( p.next() != null ) {
7344 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7345 p.setSource( p8_str );
7346 if ( !p.hasNext() ) {
7349 Phylogeny p8_0 = p.next();
7350 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7353 if ( !p.hasNext() ) {
7356 if ( !p.hasNext() ) {
7359 Phylogeny p8_1 = p.next();
7360 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7363 if ( p.hasNext() ) {
7366 if ( p.next() != null ) {
7370 if ( !p.hasNext() ) {
7374 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7377 if ( !p.hasNext() ) {
7381 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7384 if ( p.hasNext() ) {
7387 if ( p.next() != null ) {
7393 if ( p.hasNext() ) {
7397 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7398 if ( !p.hasNext() ) {
7401 Phylogeny p_27 = p.next();
7402 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7403 System.out.println( p_27.toNewHampshireX() );
7407 if ( p.hasNext() ) {
7410 if ( p.next() != null ) {
7414 if ( !p.hasNext() ) {
7418 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7419 System.out.println( p_27.toNewHampshireX() );
7423 if ( p.hasNext() ) {
7426 if ( p.next() != null ) {
7430 catch ( final Exception e ) {
7431 e.printStackTrace( System.out );
7437 private static boolean testNHXconversion() {
7439 final PhylogenyNode n1 = new PhylogenyNode();
7440 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7441 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7442 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7443 final PhylogenyNode n5 = PhylogenyNode
7444 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7445 final PhylogenyNode n6 = PhylogenyNode
7446 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7447 if ( !n1.toNewHampshireX().equals( "" ) ) {
7450 if ( !n2.toNewHampshireX().equals( "" ) ) {
7453 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7456 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7459 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7462 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7463 System.out.println( n6.toNewHampshireX() );
7467 catch ( final Exception e ) {
7468 e.printStackTrace( System.out );
7474 private static boolean testNHXNodeParsing() {
7476 final PhylogenyNode n1 = new PhylogenyNode();
7477 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7478 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7479 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7480 final PhylogenyNode n5 = PhylogenyNode
7481 .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]" );
7482 if ( !n3.getName().equals( "n3" ) ) {
7485 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7488 if ( n3.isDuplication() ) {
7491 if ( n3.isHasAssignedEvent() ) {
7494 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7497 if ( !n4.getName().equals( "n4" ) ) {
7500 if ( n4.getDistanceToParent() != 0.01 ) {
7503 if ( !n5.getName().equals( "n5" ) ) {
7506 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7509 if ( n5.getDistanceToParent() != 0.1 ) {
7512 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7515 if ( !n5.isDuplication() ) {
7518 if ( !n5.isHasAssignedEvent() ) {
7521 final PhylogenyNode n8 = PhylogenyNode
7522 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7523 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7524 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7527 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7530 final PhylogenyNode n9 = PhylogenyNode
7531 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7532 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7533 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7536 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7539 final PhylogenyNode n10 = PhylogenyNode
7540 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7541 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7544 final PhylogenyNode n20 = PhylogenyNode
7545 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7546 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7549 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7552 final PhylogenyNode n20x = PhylogenyNode
7553 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7554 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7557 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7560 final PhylogenyNode n20xx = PhylogenyNode
7561 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7562 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7565 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7568 final PhylogenyNode n20xxx = PhylogenyNode
7569 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7570 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7573 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7576 final PhylogenyNode n20xxxx = PhylogenyNode
7577 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7578 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7581 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7584 final PhylogenyNode n21 = PhylogenyNode
7585 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7586 if ( !n21.getName().equals( "N21_PIG" ) ) {
7589 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7592 final PhylogenyNode n21x = PhylogenyNode
7593 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7594 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7597 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7600 final PhylogenyNode n22 = PhylogenyNode
7601 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7602 if ( !n22.getName().equals( "n22/PIG" ) ) {
7605 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7608 final PhylogenyNode n23 = PhylogenyNode
7609 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7610 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7613 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7616 final PhylogenyNode a = PhylogenyNode
7617 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7618 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7621 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7624 final PhylogenyNode c1 = PhylogenyNode
7625 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7626 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7627 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7630 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7633 final PhylogenyNode c2 = PhylogenyNode
7634 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7635 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7636 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7639 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7642 final PhylogenyNode e3 = PhylogenyNode
7643 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7644 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7647 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7650 final PhylogenyNode n11 = PhylogenyNode
7651 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7652 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7653 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7656 if ( n11.getDistanceToParent() != 0.4 ) {
7659 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7662 final PhylogenyNode n12 = PhylogenyNode
7663 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7664 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7665 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7668 if ( n12.getDistanceToParent() != 0.4 ) {
7671 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7674 final PhylogenyNode o = PhylogenyNode
7675 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7676 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7679 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7682 if ( n1.getName().compareTo( "" ) != 0 ) {
7685 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7688 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7691 if ( n2.getName().compareTo( "" ) != 0 ) {
7694 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7697 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7700 final PhylogenyNode n00 = PhylogenyNode
7701 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7702 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7705 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7708 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7709 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7712 final PhylogenyNode n13 = PhylogenyNode
7713 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7714 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7717 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7720 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7723 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7726 final PhylogenyNode n14 = PhylogenyNode
7727 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7728 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7731 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7734 final PhylogenyNode n15 = PhylogenyNode
7735 .createInstanceFromNhxString( "something_wicked[123]",
7736 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7737 if ( !n15.getName().equals( "something_wicked" ) ) {
7740 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7743 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7746 final PhylogenyNode n16 = PhylogenyNode
7747 .createInstanceFromNhxString( "something_wicked2[9]",
7748 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7749 if ( !n16.getName().equals( "something_wicked2" ) ) {
7752 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7755 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7758 final PhylogenyNode n17 = PhylogenyNode
7759 .createInstanceFromNhxString( "something_wicked3[a]",
7760 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7761 if ( !n17.getName().equals( "something_wicked3" ) ) {
7764 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7767 final PhylogenyNode n18 = PhylogenyNode
7768 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7769 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7772 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7775 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7778 final PhylogenyNode n19 = PhylogenyNode
7779 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7780 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7783 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7786 final PhylogenyNode n30 = PhylogenyNode
7787 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7788 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7789 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7792 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7795 final PhylogenyNode n31 = PhylogenyNode
7796 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7797 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7798 if ( n31.getNodeData().isHasTaxonomy() ) {
7801 final PhylogenyNode n32 = PhylogenyNode
7802 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7803 if ( n32.getNodeData().isHasTaxonomy() ) {
7806 final PhylogenyNode n40 = PhylogenyNode
7807 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7808 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7811 final PhylogenyNode n41 = PhylogenyNode
7812 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7813 if ( n41.getNodeData().isHasTaxonomy() ) {
7816 final PhylogenyNode n42 = PhylogenyNode
7817 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7818 if ( n42.getNodeData().isHasTaxonomy() ) {
7821 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7822 NHXParser.TAXONOMY_EXTRACTION.NO );
7823 if ( n43.getNodeData().isHasTaxonomy() ) {
7826 final PhylogenyNode n44 = PhylogenyNode
7827 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7828 if ( n44.getNodeData().isHasTaxonomy() ) {
7832 catch ( final Exception e ) {
7833 e.printStackTrace( System.out );
7839 private static boolean testNHXParsing() {
7841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7842 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7843 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7846 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]";
7847 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7848 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7851 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]";
7852 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7853 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7856 final Phylogeny[] p3 = factory
7857 .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]",
7859 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7862 final Phylogeny[] p4 = factory
7863 .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(]",
7865 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7868 final Phylogeny[] p5 = factory
7869 .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(((]",
7871 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7874 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)";
7875 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)";
7876 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7877 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7880 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)))";
7881 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)))";
7882 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7883 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7886 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]) ))[,,, ])))))))";
7887 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7888 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7889 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7892 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7893 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7896 final Phylogeny p10 = factory
7897 .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]",
7898 new NHXParser() )[ 0 ];
7899 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7903 catch ( final Exception e ) {
7904 e.printStackTrace( System.out );
7910 private static boolean testNHXParsingMB() {
7912 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7913 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7914 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7915 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7916 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7917 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7918 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7919 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7920 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7921 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7922 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7925 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7928 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
7929 0.1100000000000000e+00 ) ) {
7932 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
7935 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
7938 final Phylogeny p2 = factory
7939 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
7940 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7941 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7942 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7943 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7944 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7945 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7946 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7947 + "7.369400000000000e-02}])",
7948 new NHXParser() )[ 0 ];
7949 if ( p2.getNode( "1" ) == null ) {
7952 if ( p2.getNode( "2" ) == null ) {
7956 catch ( final Exception e ) {
7957 e.printStackTrace( System.out );
7964 private static boolean testNHXParsingQuotes() {
7966 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7967 final NHXParser p = new NHXParser();
7968 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
7969 if ( phylogenies_0.length != 5 ) {
7972 final Phylogeny phy = phylogenies_0[ 4 ];
7973 if ( phy.getNumberOfExternalNodes() != 7 ) {
7976 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
7979 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
7982 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
7983 .getScientificName().equals( "hsapiens" ) ) {
7986 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
7989 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
7992 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
7995 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
7998 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8001 final NHXParser p1p = new NHXParser();
8002 p1p.setIgnoreQuotes( true );
8003 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8004 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8007 final NHXParser p2p = new NHXParser();
8008 p1p.setIgnoreQuotes( false );
8009 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8010 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8013 final NHXParser p3p = new NHXParser();
8014 p3p.setIgnoreQuotes( false );
8015 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8016 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8019 final NHXParser p4p = new NHXParser();
8020 p4p.setIgnoreQuotes( false );
8021 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8022 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8025 final Phylogeny p10 = factory
8026 .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]",
8027 new NHXParser() )[ 0 ];
8028 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]";
8029 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8032 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8033 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8037 final Phylogeny p12 = factory
8038 .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]",
8039 new NHXParser() )[ 0 ];
8040 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]";
8041 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8044 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8045 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8048 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;";
8049 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8052 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8053 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8057 catch ( final Exception e ) {
8058 e.printStackTrace( System.out );
8064 private static boolean testNodeRemoval() {
8066 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8067 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8068 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8069 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8072 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8073 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8074 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8077 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8078 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8079 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8083 catch ( final Exception e ) {
8084 e.printStackTrace( System.out );
8090 private static boolean testPhylogenyBranch() {
8092 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8093 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8094 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8095 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8096 if ( !a1b1.equals( a1b1 ) ) {
8099 if ( !a1b1.equals( b1a1 ) ) {
8102 if ( !b1a1.equals( a1b1 ) ) {
8105 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8106 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8107 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8108 if ( a1_b1.equals( b1_a1 ) ) {
8111 if ( a1_b1.equals( a1_b1_ ) ) {
8114 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8115 if ( !a1_b1.equals( b1_a1_ ) ) {
8118 if ( a1_b1_.equals( b1_a1_ ) ) {
8121 if ( !a1_b1_.equals( b1_a1 ) ) {
8125 catch ( final Exception e ) {
8126 e.printStackTrace( System.out );
8132 private static boolean testPhyloXMLparsingOfDistributionElement() {
8134 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8135 PhyloXmlParser xml_parser = null;
8137 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8139 catch ( final Exception e ) {
8140 // Do nothing -- means were not running from jar.
8142 if ( xml_parser == null ) {
8143 xml_parser = new PhyloXmlParser();
8144 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8145 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8148 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8151 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8153 if ( xml_parser.getErrorCount() > 0 ) {
8154 System.out.println( xml_parser.getErrorMessages().toString() );
8157 if ( phylogenies_0.length != 1 ) {
8160 final Phylogeny t1 = phylogenies_0[ 0 ];
8161 PhylogenyNode n = null;
8162 Distribution d = null;
8163 n = t1.getNode( "root node" );
8164 if ( !n.getNodeData().isHasDistribution() ) {
8167 if ( n.getNodeData().getDistributions().size() != 1 ) {
8170 d = n.getNodeData().getDistribution();
8171 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8174 if ( d.getPoints().size() != 1 ) {
8177 if ( d.getPolygons() != null ) {
8180 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8183 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8186 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8189 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8192 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8195 n = t1.getNode( "node a" );
8196 if ( !n.getNodeData().isHasDistribution() ) {
8199 if ( n.getNodeData().getDistributions().size() != 2 ) {
8202 d = n.getNodeData().getDistribution( 1 );
8203 if ( !d.getDesc().equals( "San Diego" ) ) {
8206 if ( d.getPoints().size() != 1 ) {
8209 if ( d.getPolygons() != null ) {
8212 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8215 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8218 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8221 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8224 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8227 n = t1.getNode( "node bb" );
8228 if ( !n.getNodeData().isHasDistribution() ) {
8231 if ( n.getNodeData().getDistributions().size() != 1 ) {
8234 d = n.getNodeData().getDistribution( 0 );
8235 if ( d.getPoints().size() != 3 ) {
8238 if ( d.getPolygons().size() != 2 ) {
8241 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8244 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8247 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8250 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8253 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8256 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8259 Polygon p = d.getPolygons().get( 0 );
8260 if ( p.getPoints().size() != 3 ) {
8263 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8266 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8269 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8272 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8275 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8278 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8281 p = d.getPolygons().get( 1 );
8282 if ( p.getPoints().size() != 3 ) {
8285 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8288 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8291 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8295 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8296 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8297 if ( rt.length != 1 ) {
8300 final Phylogeny t1_rt = rt[ 0 ];
8301 n = t1_rt.getNode( "root node" );
8302 if ( !n.getNodeData().isHasDistribution() ) {
8305 if ( n.getNodeData().getDistributions().size() != 1 ) {
8308 d = n.getNodeData().getDistribution();
8309 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8312 if ( d.getPoints().size() != 1 ) {
8315 if ( d.getPolygons() != null ) {
8318 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8321 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8324 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8327 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8330 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8333 n = t1_rt.getNode( "node a" );
8334 if ( !n.getNodeData().isHasDistribution() ) {
8337 if ( n.getNodeData().getDistributions().size() != 2 ) {
8340 d = n.getNodeData().getDistribution( 1 );
8341 if ( !d.getDesc().equals( "San Diego" ) ) {
8344 if ( d.getPoints().size() != 1 ) {
8347 if ( d.getPolygons() != null ) {
8350 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8353 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8356 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8359 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8362 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8365 n = t1_rt.getNode( "node bb" );
8366 if ( !n.getNodeData().isHasDistribution() ) {
8369 if ( n.getNodeData().getDistributions().size() != 1 ) {
8372 d = n.getNodeData().getDistribution( 0 );
8373 if ( d.getPoints().size() != 3 ) {
8376 if ( d.getPolygons().size() != 2 ) {
8379 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8382 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8385 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8388 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8391 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8394 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8397 p = d.getPolygons().get( 0 );
8398 if ( p.getPoints().size() != 3 ) {
8401 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8404 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8407 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8410 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8413 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8416 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8419 p = d.getPolygons().get( 1 );
8420 if ( p.getPoints().size() != 3 ) {
8423 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8426 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8429 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8433 catch ( final Exception e ) {
8434 e.printStackTrace( System.out );
8440 private static boolean testPostOrderIterator() {
8442 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8443 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8444 PhylogenyNodeIterator it0;
8445 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8448 for( it0.reset(); it0.hasNext(); ) {
8451 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8452 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8453 if ( !it.next().getName().equals( "A" ) ) {
8456 if ( !it.next().getName().equals( "B" ) ) {
8459 if ( !it.next().getName().equals( "ab" ) ) {
8462 if ( !it.next().getName().equals( "C" ) ) {
8465 if ( !it.next().getName().equals( "D" ) ) {
8468 if ( !it.next().getName().equals( "cd" ) ) {
8471 if ( !it.next().getName().equals( "abcd" ) ) {
8474 if ( !it.next().getName().equals( "E" ) ) {
8477 if ( !it.next().getName().equals( "F" ) ) {
8480 if ( !it.next().getName().equals( "ef" ) ) {
8483 if ( !it.next().getName().equals( "G" ) ) {
8486 if ( !it.next().getName().equals( "H" ) ) {
8489 if ( !it.next().getName().equals( "gh" ) ) {
8492 if ( !it.next().getName().equals( "efgh" ) ) {
8495 if ( !it.next().getName().equals( "r" ) ) {
8498 if ( it.hasNext() ) {
8502 catch ( final Exception e ) {
8503 e.printStackTrace( System.out );
8509 private static boolean testPreOrderIterator() {
8511 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8512 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8513 PhylogenyNodeIterator it0;
8514 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8517 for( it0.reset(); it0.hasNext(); ) {
8520 PhylogenyNodeIterator it = t0.iteratorPreorder();
8521 if ( !it.next().getName().equals( "r" ) ) {
8524 if ( !it.next().getName().equals( "ab" ) ) {
8527 if ( !it.next().getName().equals( "A" ) ) {
8530 if ( !it.next().getName().equals( "B" ) ) {
8533 if ( !it.next().getName().equals( "cd" ) ) {
8536 if ( !it.next().getName().equals( "C" ) ) {
8539 if ( !it.next().getName().equals( "D" ) ) {
8542 if ( it.hasNext() ) {
8545 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8546 it = t1.iteratorPreorder();
8547 if ( !it.next().getName().equals( "r" ) ) {
8550 if ( !it.next().getName().equals( "abcd" ) ) {
8553 if ( !it.next().getName().equals( "ab" ) ) {
8556 if ( !it.next().getName().equals( "A" ) ) {
8559 if ( !it.next().getName().equals( "B" ) ) {
8562 if ( !it.next().getName().equals( "cd" ) ) {
8565 if ( !it.next().getName().equals( "C" ) ) {
8568 if ( !it.next().getName().equals( "D" ) ) {
8571 if ( !it.next().getName().equals( "efgh" ) ) {
8574 if ( !it.next().getName().equals( "ef" ) ) {
8577 if ( !it.next().getName().equals( "E" ) ) {
8580 if ( !it.next().getName().equals( "F" ) ) {
8583 if ( !it.next().getName().equals( "gh" ) ) {
8586 if ( !it.next().getName().equals( "G" ) ) {
8589 if ( !it.next().getName().equals( "H" ) ) {
8592 if ( it.hasNext() ) {
8596 catch ( final Exception e ) {
8597 e.printStackTrace( System.out );
8603 private static boolean testPropertiesMap() {
8605 final PropertiesMap pm = new PropertiesMap();
8606 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8607 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8608 final Property p2 = new Property( "something:else",
8610 "improbable:research",
8613 pm.addProperty( p0 );
8614 pm.addProperty( p1 );
8615 pm.addProperty( p2 );
8616 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8619 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8622 if ( pm.getProperties().size() != 3 ) {
8625 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8628 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8631 if ( pm.getProperties().size() != 3 ) {
8634 pm.removeProperty( "dimensions:diameter" );
8635 if ( pm.getProperties().size() != 2 ) {
8638 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8641 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8645 catch ( final Exception e ) {
8646 e.printStackTrace( System.out );
8652 private static boolean testProteinId() {
8654 final ProteinId id1 = new ProteinId( "a" );
8655 final ProteinId id2 = new ProteinId( "a" );
8656 final ProteinId id3 = new ProteinId( "A" );
8657 final ProteinId id4 = new ProteinId( "b" );
8658 if ( !id1.equals( id1 ) ) {
8661 if ( id1.getId().equals( "x" ) ) {
8664 if ( id1.getId().equals( null ) ) {
8667 if ( !id1.equals( id2 ) ) {
8670 if ( id1.equals( id3 ) ) {
8673 if ( id1.hashCode() != id1.hashCode() ) {
8676 if ( id1.hashCode() != id2.hashCode() ) {
8679 if ( id1.hashCode() == id3.hashCode() ) {
8682 if ( id1.compareTo( id1 ) != 0 ) {
8685 if ( id1.compareTo( id2 ) != 0 ) {
8688 if ( id1.compareTo( id3 ) != 0 ) {
8691 if ( id1.compareTo( id4 ) >= 0 ) {
8694 if ( id4.compareTo( id1 ) <= 0 ) {
8697 if ( !id4.getId().equals( "b" ) ) {
8700 final ProteinId id5 = new ProteinId( " C " );
8701 if ( !id5.getId().equals( "C" ) ) {
8704 if ( id5.equals( id1 ) ) {
8708 catch ( final Exception e ) {
8709 e.printStackTrace( System.out );
8715 private static boolean testReIdMethods() {
8717 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8718 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8719 final long count = PhylogenyNode.getNodeCount();
8721 if ( p.getNode( "r" ).getId() != count ) {
8724 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8727 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8730 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8733 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8736 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8739 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8742 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8745 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8748 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8751 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8754 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8757 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8760 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8763 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8767 catch ( final Exception e ) {
8768 e.printStackTrace( System.out );
8774 private static boolean testRerooting() {
8776 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8777 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",
8778 new NHXParser() )[ 0 ];
8779 if ( !t1.isRooted() ) {
8782 t1.reRoot( t1.getNode( "D" ) );
8783 t1.reRoot( t1.getNode( "CD" ) );
8784 t1.reRoot( t1.getNode( "A" ) );
8785 t1.reRoot( t1.getNode( "B" ) );
8786 t1.reRoot( t1.getNode( "AB" ) );
8787 t1.reRoot( t1.getNode( "D" ) );
8788 t1.reRoot( t1.getNode( "C" ) );
8789 t1.reRoot( t1.getNode( "CD" ) );
8790 t1.reRoot( t1.getNode( "A" ) );
8791 t1.reRoot( t1.getNode( "B" ) );
8792 t1.reRoot( t1.getNode( "AB" ) );
8793 t1.reRoot( t1.getNode( "D" ) );
8794 t1.reRoot( t1.getNode( "D" ) );
8795 t1.reRoot( t1.getNode( "C" ) );
8796 t1.reRoot( t1.getNode( "A" ) );
8797 t1.reRoot( t1.getNode( "B" ) );
8798 t1.reRoot( t1.getNode( "AB" ) );
8799 t1.reRoot( t1.getNode( "C" ) );
8800 t1.reRoot( t1.getNode( "D" ) );
8801 t1.reRoot( t1.getNode( "CD" ) );
8802 t1.reRoot( t1.getNode( "D" ) );
8803 t1.reRoot( t1.getNode( "A" ) );
8804 t1.reRoot( t1.getNode( "B" ) );
8805 t1.reRoot( t1.getNode( "AB" ) );
8806 t1.reRoot( t1.getNode( "C" ) );
8807 t1.reRoot( t1.getNode( "D" ) );
8808 t1.reRoot( t1.getNode( "CD" ) );
8809 t1.reRoot( t1.getNode( "D" ) );
8810 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8813 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8816 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8819 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8822 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8825 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8828 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",
8829 new NHXParser() )[ 0 ];
8830 t2.reRoot( t2.getNode( "A" ) );
8831 t2.reRoot( t2.getNode( "D" ) );
8832 t2.reRoot( t2.getNode( "ABC" ) );
8833 t2.reRoot( t2.getNode( "A" ) );
8834 t2.reRoot( t2.getNode( "B" ) );
8835 t2.reRoot( t2.getNode( "D" ) );
8836 t2.reRoot( t2.getNode( "C" ) );
8837 t2.reRoot( t2.getNode( "ABC" ) );
8838 t2.reRoot( t2.getNode( "A" ) );
8839 t2.reRoot( t2.getNode( "B" ) );
8840 t2.reRoot( t2.getNode( "AB" ) );
8841 t2.reRoot( t2.getNode( "AB" ) );
8842 t2.reRoot( t2.getNode( "D" ) );
8843 t2.reRoot( t2.getNode( "C" ) );
8844 t2.reRoot( t2.getNode( "B" ) );
8845 t2.reRoot( t2.getNode( "AB" ) );
8846 t2.reRoot( t2.getNode( "D" ) );
8847 t2.reRoot( t2.getNode( "D" ) );
8848 t2.reRoot( t2.getNode( "ABC" ) );
8849 t2.reRoot( t2.getNode( "A" ) );
8850 t2.reRoot( t2.getNode( "B" ) );
8851 t2.reRoot( t2.getNode( "AB" ) );
8852 t2.reRoot( t2.getNode( "D" ) );
8853 t2.reRoot( t2.getNode( "C" ) );
8854 t2.reRoot( t2.getNode( "ABC" ) );
8855 t2.reRoot( t2.getNode( "A" ) );
8856 t2.reRoot( t2.getNode( "B" ) );
8857 t2.reRoot( t2.getNode( "AB" ) );
8858 t2.reRoot( t2.getNode( "D" ) );
8859 t2.reRoot( t2.getNode( "D" ) );
8860 t2.reRoot( t2.getNode( "C" ) );
8861 t2.reRoot( t2.getNode( "A" ) );
8862 t2.reRoot( t2.getNode( "B" ) );
8863 t2.reRoot( t2.getNode( "AB" ) );
8864 t2.reRoot( t2.getNode( "C" ) );
8865 t2.reRoot( t2.getNode( "D" ) );
8866 t2.reRoot( t2.getNode( "ABC" ) );
8867 t2.reRoot( t2.getNode( "D" ) );
8868 t2.reRoot( t2.getNode( "A" ) );
8869 t2.reRoot( t2.getNode( "B" ) );
8870 t2.reRoot( t2.getNode( "AB" ) );
8871 t2.reRoot( t2.getNode( "C" ) );
8872 t2.reRoot( t2.getNode( "D" ) );
8873 t2.reRoot( t2.getNode( "ABC" ) );
8874 t2.reRoot( t2.getNode( "D" ) );
8875 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8878 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8881 t2.reRoot( t2.getNode( "ABC" ) );
8882 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8885 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8888 t2.reRoot( t2.getNode( "AB" ) );
8889 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8892 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8895 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8898 t2.reRoot( t2.getNode( "AB" ) );
8899 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8902 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8905 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8908 t2.reRoot( t2.getNode( "D" ) );
8909 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8912 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8915 t2.reRoot( t2.getNode( "ABC" ) );
8916 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8919 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8922 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
8923 new NHXParser() )[ 0 ];
8924 t3.reRoot( t3.getNode( "B" ) );
8925 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8928 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8931 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8934 t3.reRoot( t3.getNode( "B" ) );
8935 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8938 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8941 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8944 t3.reRoot( t3.getRoot() );
8945 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8948 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8951 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8955 catch ( final Exception e ) {
8956 e.printStackTrace( System.out );
8962 private static boolean testSDIse() {
8964 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8965 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
8966 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
8967 gene1.setRooted( true );
8968 species1.setRooted( true );
8969 final SDI sdi = new SDI( gene1, species1 );
8970 if ( !gene1.getRoot().isDuplication() ) {
8973 final Phylogeny species2 = factory
8974 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
8975 new NHXParser() )[ 0 ];
8976 final Phylogeny gene2 = factory
8977 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
8978 new NHXParser() )[ 0 ];
8979 species2.setRooted( true );
8980 gene2.setRooted( true );
8981 final SDI sdi2 = new SDI( gene2, species2 );
8982 if ( sdi2.getDuplicationsSum() != 0 ) {
8985 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
8988 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
8991 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
8994 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
8997 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9000 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9003 final Phylogeny species3 = factory
9004 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9005 new NHXParser() )[ 0 ];
9006 final Phylogeny gene3 = factory
9007 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9008 new NHXParser() )[ 0 ];
9009 species3.setRooted( true );
9010 gene3.setRooted( true );
9011 final SDI sdi3 = new SDI( gene3, species3 );
9012 if ( sdi3.getDuplicationsSum() != 1 ) {
9015 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9018 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9021 final Phylogeny species4 = factory
9022 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9023 new NHXParser() )[ 0 ];
9024 final Phylogeny gene4 = factory
9025 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9026 new NHXParser() )[ 0 ];
9027 species4.setRooted( true );
9028 gene4.setRooted( true );
9029 final SDI sdi4 = new SDI( gene4, species4 );
9030 if ( sdi4.getDuplicationsSum() != 1 ) {
9033 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9036 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9039 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9042 if ( species4.getNumberOfExternalNodes() != 6 ) {
9045 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9048 final Phylogeny species5 = factory
9049 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9050 new NHXParser() )[ 0 ];
9051 final Phylogeny gene5 = factory
9052 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9053 new NHXParser() )[ 0 ];
9054 species5.setRooted( true );
9055 gene5.setRooted( true );
9056 final SDI sdi5 = new SDI( gene5, species5 );
9057 if ( sdi5.getDuplicationsSum() != 2 ) {
9060 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9063 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9066 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9069 if ( species5.getNumberOfExternalNodes() != 6 ) {
9072 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9075 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9076 // Conjecture for Comparing Molecular Phylogenies"
9077 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9078 final Phylogeny species6 = factory
9079 .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,"
9080 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9081 new NHXParser() )[ 0 ];
9082 final Phylogeny gene6 = factory
9083 .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,"
9084 + "((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,"
9085 + "(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;",
9086 new NHXParser() )[ 0 ];
9087 species6.setRooted( true );
9088 gene6.setRooted( true );
9089 final SDI sdi6 = new SDI( gene6, species6 );
9090 if ( sdi6.getDuplicationsSum() != 3 ) {
9093 if ( !gene6.getNode( "r" ).isDuplication() ) {
9096 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9099 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9102 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9105 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9108 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9111 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9114 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9117 sdi6.computeMappingCostL();
9118 if ( sdi6.computeMappingCostL() != 17 ) {
9121 if ( species6.getNumberOfExternalNodes() != 9 ) {
9124 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9127 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9128 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9129 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9130 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9131 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9132 species7.setRooted( true );
9133 final Phylogeny gene7_1 = Test
9134 .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])" );
9135 gene7_1.setRooted( true );
9136 final SDI sdi7 = new SDI( gene7_1, species7 );
9137 if ( sdi7.getDuplicationsSum() != 0 ) {
9140 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9143 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9146 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9149 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9152 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9155 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9158 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9161 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9164 final Phylogeny gene7_2 = Test
9165 .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])" );
9166 gene7_2.setRooted( true );
9167 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9168 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9171 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9174 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9177 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9180 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9183 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9186 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9189 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9192 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9195 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9199 catch ( final Exception e ) {
9205 private static boolean testSDIunrooted() {
9207 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9208 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9209 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9210 final Iterator<PhylogenyBranch> iter = l.iterator();
9211 PhylogenyBranch br = iter.next();
9212 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9215 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9219 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9222 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9226 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9229 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9233 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9236 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9240 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9243 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9247 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9250 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9254 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9257 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9261 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9264 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9268 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9271 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9275 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9278 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9282 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9285 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9289 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9292 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9296 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9299 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9303 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9306 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9310 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9313 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9316 if ( iter.hasNext() ) {
9319 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9320 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9321 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9323 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9326 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9330 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9333 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9337 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9340 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9343 if ( iter1.hasNext() ) {
9346 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9347 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9348 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9350 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9353 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9357 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9360 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9364 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9367 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9370 if ( iter2.hasNext() ) {
9373 final Phylogeny species0 = factory
9374 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9375 new NHXParser() )[ 0 ];
9376 final Phylogeny gene1 = factory
9377 .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])",
9378 new NHXParser() )[ 0 ];
9379 species0.setRooted( true );
9380 gene1.setRooted( true );
9381 final SDIR sdi_unrooted = new SDIR();
9382 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9383 if ( sdi_unrooted.getCount() != 1 ) {
9386 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9389 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9392 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9395 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9398 final Phylogeny gene2 = factory
9399 .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])",
9400 new NHXParser() )[ 0 ];
9401 gene2.setRooted( true );
9402 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9403 if ( sdi_unrooted.getCount() != 1 ) {
9406 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9409 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9412 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9415 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9418 final Phylogeny species6 = factory
9419 .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,"
9420 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9421 new NHXParser() )[ 0 ];
9422 final Phylogeny gene6 = factory
9423 .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],"
9424 + "(((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],"
9425 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9426 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9427 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9428 new NHXParser() )[ 0 ];
9429 species6.setRooted( true );
9430 gene6.setRooted( true );
9431 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9432 if ( sdi_unrooted.getCount() != 1 ) {
9435 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9438 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9441 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9444 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9447 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9450 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9453 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9456 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9459 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9462 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9465 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9468 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9472 final Phylogeny species7 = factory
9473 .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,"
9474 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9475 new NHXParser() )[ 0 ];
9476 final Phylogeny gene7 = factory
9477 .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],"
9478 + "(((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],"
9479 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9480 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9481 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9482 new NHXParser() )[ 0 ];
9483 species7.setRooted( true );
9484 gene7.setRooted( true );
9485 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9486 if ( sdi_unrooted.getCount() != 1 ) {
9489 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9492 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9495 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9498 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9501 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9504 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9507 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9510 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9513 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9516 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9519 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9522 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9526 final Phylogeny species8 = factory
9527 .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,"
9528 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9529 new NHXParser() )[ 0 ];
9530 final Phylogeny gene8 = factory
9531 .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],"
9532 + "(((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],"
9533 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9534 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9535 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9536 new NHXParser() )[ 0 ];
9537 species8.setRooted( true );
9538 gene8.setRooted( true );
9539 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9540 if ( sdi_unrooted.getCount() != 1 ) {
9543 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9546 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9549 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9552 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9555 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9558 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9561 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9564 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9567 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9570 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9573 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9576 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9581 catch ( final Exception e ) {
9582 e.printStackTrace( System.out );
9588 private static boolean testSequenceIdParsing() {
9590 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
9591 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9592 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9594 System.out.println( "value =" + id.getValue() );
9595 System.out.println( "provider=" + id.getProvider() );
9600 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
9601 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9602 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9604 System.out.println( "value =" + id.getValue() );
9605 System.out.println( "provider=" + id.getProvider() );
9610 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
9611 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9612 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9614 System.out.println( "value =" + id.getValue() );
9615 System.out.println( "provider=" + id.getProvider() );
9620 id = SequenceIdParser.parse( "gb_AAA96518_1" );
9621 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9622 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
9624 System.out.println( "value =" + id.getValue() );
9625 System.out.println( "provider=" + id.getProvider() );
9630 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
9631 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9632 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
9634 System.out.println( "value =" + id.getValue() );
9635 System.out.println( "provider=" + id.getProvider() );
9640 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
9641 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9642 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
9644 System.out.println( "value =" + id.getValue() );
9645 System.out.println( "provider=" + id.getProvider() );
9650 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
9651 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9652 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
9654 System.out.println( "value =" + id.getValue() );
9655 System.out.println( "provider=" + id.getProvider() );
9660 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
9661 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9662 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9664 System.out.println( "value =" + id.getValue() );
9665 System.out.println( "provider=" + id.getProvider() );
9670 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
9671 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9672 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9674 System.out.println( "value =" + id.getValue() );
9675 System.out.println( "provider=" + id.getProvider() );
9680 id = SequenceIdParser.parse( "P4A123" );
9681 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9682 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9684 System.out.println( "value =" + id.getValue() );
9685 System.out.println( "provider=" + id.getProvider() );
9690 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
9691 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9692 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9694 System.out.println( "value =" + id.getValue() );
9695 System.out.println( "provider=" + id.getProvider() );
9700 id = SequenceIdParser.parse( "XP_12345" );
9702 System.out.println( "value =" + id.getValue() );
9703 System.out.println( "provider=" + id.getProvider() );
9706 // lcl_91970_unknown_
9708 catch ( final Exception e ) {
9709 e.printStackTrace( System.out );
9715 private static boolean testSequenceWriter() {
9717 final String n = ForesterUtil.LINE_SEPARATOR;
9718 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9721 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9724 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9727 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9730 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9731 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9734 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9735 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9739 catch ( final Exception e ) {
9740 e.printStackTrace();
9746 private static boolean testSpecies() {
9748 final Species s1 = new BasicSpecies( "a" );
9749 final Species s2 = new BasicSpecies( "a" );
9750 final Species s3 = new BasicSpecies( "A" );
9751 final Species s4 = new BasicSpecies( "b" );
9752 if ( !s1.equals( s1 ) ) {
9755 if ( s1.getSpeciesId().equals( "x" ) ) {
9758 if ( s1.getSpeciesId().equals( null ) ) {
9761 if ( !s1.equals( s2 ) ) {
9764 if ( s1.equals( s3 ) ) {
9767 if ( s1.hashCode() != s1.hashCode() ) {
9770 if ( s1.hashCode() != s2.hashCode() ) {
9773 if ( s1.hashCode() == s3.hashCode() ) {
9776 if ( s1.compareTo( s1 ) != 0 ) {
9779 if ( s1.compareTo( s2 ) != 0 ) {
9782 if ( s1.compareTo( s3 ) != 0 ) {
9785 if ( s1.compareTo( s4 ) >= 0 ) {
9788 if ( s4.compareTo( s1 ) <= 0 ) {
9791 if ( !s4.getSpeciesId().equals( "b" ) ) {
9794 final Species s5 = new BasicSpecies( " C " );
9795 if ( !s5.getSpeciesId().equals( "C" ) ) {
9798 if ( s5.equals( s1 ) ) {
9802 catch ( final Exception e ) {
9803 e.printStackTrace( System.out );
9809 private static boolean testSplit() {
9811 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9812 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9813 //Archaeopteryx.createApplication( p0 );
9814 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9815 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9816 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9817 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9818 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9819 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9820 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9821 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9822 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9823 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9824 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9825 // System.out.println( s0.toString() );
9827 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9830 if ( s0.match( query_nodes ) ) {
9833 query_nodes = new HashSet<PhylogenyNode>();
9834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9836 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9837 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9841 if ( !s0.match( query_nodes ) ) {
9845 query_nodes = new HashSet<PhylogenyNode>();
9846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9849 if ( !s0.match( query_nodes ) ) {
9853 query_nodes = new HashSet<PhylogenyNode>();
9854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9855 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9858 if ( !s0.match( query_nodes ) ) {
9862 query_nodes = new HashSet<PhylogenyNode>();
9863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9867 if ( !s0.match( query_nodes ) ) {
9871 query_nodes = new HashSet<PhylogenyNode>();
9872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9875 if ( !s0.match( query_nodes ) ) {
9879 query_nodes = new HashSet<PhylogenyNode>();
9880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9882 if ( !s0.match( query_nodes ) ) {
9886 query_nodes = new HashSet<PhylogenyNode>();
9887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9892 if ( !s0.match( query_nodes ) ) {
9896 query_nodes = new HashSet<PhylogenyNode>();
9897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9900 if ( !s0.match( query_nodes ) ) {
9904 query_nodes = new HashSet<PhylogenyNode>();
9905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9909 if ( !s0.match( query_nodes ) ) {
9913 query_nodes = new HashSet<PhylogenyNode>();
9914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9916 if ( s0.match( query_nodes ) ) {
9920 query_nodes = new HashSet<PhylogenyNode>();
9921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9925 if ( s0.match( query_nodes ) ) {
9929 query_nodes = new HashSet<PhylogenyNode>();
9930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9935 if ( s0.match( query_nodes ) ) {
9939 query_nodes = new HashSet<PhylogenyNode>();
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9943 if ( s0.match( query_nodes ) ) {
9947 query_nodes = new HashSet<PhylogenyNode>();
9948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9950 if ( s0.match( query_nodes ) ) {
9954 query_nodes = new HashSet<PhylogenyNode>();
9955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9957 if ( s0.match( query_nodes ) ) {
9961 query_nodes = new HashSet<PhylogenyNode>();
9962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9964 if ( s0.match( query_nodes ) ) {
9968 query_nodes = new HashSet<PhylogenyNode>();
9969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9971 if ( s0.match( query_nodes ) ) {
9975 query_nodes = new HashSet<PhylogenyNode>();
9976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9978 if ( s0.match( query_nodes ) ) {
9982 query_nodes = new HashSet<PhylogenyNode>();
9983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9985 if ( s0.match( query_nodes ) ) {
9989 query_nodes = new HashSet<PhylogenyNode>();
9990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9993 if ( s0.match( query_nodes ) ) {
9997 query_nodes = new HashSet<PhylogenyNode>();
9998 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10001 if ( s0.match( query_nodes ) ) {
10005 query_nodes = new HashSet<PhylogenyNode>();
10006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10009 if ( s0.match( query_nodes ) ) {
10013 query_nodes = new HashSet<PhylogenyNode>();
10014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10018 if ( s0.match( query_nodes ) ) {
10022 // query_nodes = new HashSet<PhylogenyNode>();
10023 // query_nodes.add( new PhylogenyNode( "X" ) );
10024 // query_nodes.add( new PhylogenyNode( "Y" ) );
10025 // query_nodes.add( new PhylogenyNode( "A" ) );
10026 // query_nodes.add( new PhylogenyNode( "B" ) );
10027 // query_nodes.add( new PhylogenyNode( "C" ) );
10028 // query_nodes.add( new PhylogenyNode( "D" ) );
10029 // query_nodes.add( new PhylogenyNode( "E" ) );
10030 // query_nodes.add( new PhylogenyNode( "F" ) );
10031 // query_nodes.add( new PhylogenyNode( "G" ) );
10032 // if ( !s0.match( query_nodes ) ) {
10035 // query_nodes = new HashSet<PhylogenyNode>();
10036 // query_nodes.add( new PhylogenyNode( "X" ) );
10037 // query_nodes.add( new PhylogenyNode( "Y" ) );
10038 // query_nodes.add( new PhylogenyNode( "A" ) );
10039 // query_nodes.add( new PhylogenyNode( "B" ) );
10040 // query_nodes.add( new PhylogenyNode( "C" ) );
10041 // if ( !s0.match( query_nodes ) ) {
10045 // query_nodes = new HashSet<PhylogenyNode>();
10046 // query_nodes.add( new PhylogenyNode( "X" ) );
10047 // query_nodes.add( new PhylogenyNode( "Y" ) );
10048 // query_nodes.add( new PhylogenyNode( "D" ) );
10049 // query_nodes.add( new PhylogenyNode( "E" ) );
10050 // query_nodes.add( new PhylogenyNode( "F" ) );
10051 // query_nodes.add( new PhylogenyNode( "G" ) );
10052 // if ( !s0.match( query_nodes ) ) {
10056 // query_nodes = new HashSet<PhylogenyNode>();
10057 // query_nodes.add( new PhylogenyNode( "X" ) );
10058 // query_nodes.add( new PhylogenyNode( "Y" ) );
10059 // query_nodes.add( new PhylogenyNode( "A" ) );
10060 // query_nodes.add( new PhylogenyNode( "B" ) );
10061 // query_nodes.add( new PhylogenyNode( "C" ) );
10062 // query_nodes.add( new PhylogenyNode( "D" ) );
10063 // if ( !s0.match( query_nodes ) ) {
10067 // query_nodes = new HashSet<PhylogenyNode>();
10068 // query_nodes.add( new PhylogenyNode( "X" ) );
10069 // query_nodes.add( new PhylogenyNode( "Y" ) );
10070 // query_nodes.add( new PhylogenyNode( "E" ) );
10071 // query_nodes.add( new PhylogenyNode( "F" ) );
10072 // query_nodes.add( new PhylogenyNode( "G" ) );
10073 // if ( !s0.match( query_nodes ) ) {
10077 // query_nodes = new HashSet<PhylogenyNode>();
10078 // query_nodes.add( new PhylogenyNode( "X" ) );
10079 // query_nodes.add( new PhylogenyNode( "Y" ) );
10080 // query_nodes.add( new PhylogenyNode( "F" ) );
10081 // query_nodes.add( new PhylogenyNode( "G" ) );
10082 // if ( !s0.match( query_nodes ) ) {
10086 query_nodes = new HashSet<PhylogenyNode>();
10087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10088 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10089 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10091 if ( s0.match( query_nodes ) ) {
10095 query_nodes = new HashSet<PhylogenyNode>();
10096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10099 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10100 if ( s0.match( query_nodes ) ) {
10103 ///////////////////////////
10105 query_nodes = new HashSet<PhylogenyNode>();
10106 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10107 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10110 if ( s0.match( query_nodes ) ) {
10114 query_nodes = new HashSet<PhylogenyNode>();
10115 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10117 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10119 if ( s0.match( query_nodes ) ) {
10123 query_nodes = new HashSet<PhylogenyNode>();
10124 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10125 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10126 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10127 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10128 if ( s0.match( query_nodes ) ) {
10132 query_nodes = new HashSet<PhylogenyNode>();
10133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10134 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10135 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10136 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10137 if ( s0.match( query_nodes ) ) {
10141 query_nodes = new HashSet<PhylogenyNode>();
10142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10144 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10146 if ( s0.match( query_nodes ) ) {
10150 query_nodes = new HashSet<PhylogenyNode>();
10151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10153 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10154 if ( s0.match( query_nodes ) ) {
10158 query_nodes = new HashSet<PhylogenyNode>();
10159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10161 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10162 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10163 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10164 if ( s0.match( query_nodes ) ) {
10168 query_nodes = new HashSet<PhylogenyNode>();
10169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10171 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10172 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10173 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10174 if ( s0.match( query_nodes ) ) {
10178 query_nodes = new HashSet<PhylogenyNode>();
10179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10180 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10181 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10182 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10184 if ( s0.match( query_nodes ) ) {
10188 query_nodes = new HashSet<PhylogenyNode>();
10189 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10190 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10193 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10195 if ( s0.match( query_nodes ) ) {
10199 catch ( final Exception e ) {
10200 e.printStackTrace();
10206 private static boolean testSplitStrict() {
10208 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10209 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10210 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10211 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10212 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10213 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10214 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10215 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10216 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10217 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10218 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10219 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10222 if ( s0.match( query_nodes ) ) {
10225 query_nodes = new HashSet<PhylogenyNode>();
10226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10227 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10228 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10233 if ( !s0.match( query_nodes ) ) {
10237 query_nodes = new HashSet<PhylogenyNode>();
10238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10241 if ( !s0.match( query_nodes ) ) {
10245 query_nodes = new HashSet<PhylogenyNode>();
10246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10247 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10250 if ( !s0.match( query_nodes ) ) {
10254 query_nodes = new HashSet<PhylogenyNode>();
10255 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10256 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10257 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10258 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10259 if ( !s0.match( query_nodes ) ) {
10263 query_nodes = new HashSet<PhylogenyNode>();
10264 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10265 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10267 if ( !s0.match( query_nodes ) ) {
10271 query_nodes = new HashSet<PhylogenyNode>();
10272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10274 if ( !s0.match( query_nodes ) ) {
10278 query_nodes = new HashSet<PhylogenyNode>();
10279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10284 if ( !s0.match( query_nodes ) ) {
10288 query_nodes = new HashSet<PhylogenyNode>();
10289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10292 if ( !s0.match( query_nodes ) ) {
10296 query_nodes = new HashSet<PhylogenyNode>();
10297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10301 if ( !s0.match( query_nodes ) ) {
10305 query_nodes = new HashSet<PhylogenyNode>();
10306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10307 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10308 if ( s0.match( query_nodes ) ) {
10312 query_nodes = new HashSet<PhylogenyNode>();
10313 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10314 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10317 if ( s0.match( query_nodes ) ) {
10321 query_nodes = new HashSet<PhylogenyNode>();
10322 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10327 if ( s0.match( query_nodes ) ) {
10331 query_nodes = new HashSet<PhylogenyNode>();
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10335 if ( s0.match( query_nodes ) ) {
10339 query_nodes = new HashSet<PhylogenyNode>();
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10342 if ( s0.match( query_nodes ) ) {
10346 query_nodes = new HashSet<PhylogenyNode>();
10347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10349 if ( s0.match( query_nodes ) ) {
10353 query_nodes = new HashSet<PhylogenyNode>();
10354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10356 if ( s0.match( query_nodes ) ) {
10360 query_nodes = new HashSet<PhylogenyNode>();
10361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10362 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10363 if ( s0.match( query_nodes ) ) {
10367 query_nodes = new HashSet<PhylogenyNode>();
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10370 if ( s0.match( query_nodes ) ) {
10374 query_nodes = new HashSet<PhylogenyNode>();
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10377 if ( s0.match( query_nodes ) ) {
10381 query_nodes = new HashSet<PhylogenyNode>();
10382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10385 if ( s0.match( query_nodes ) ) {
10389 query_nodes = new HashSet<PhylogenyNode>();
10390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10393 if ( s0.match( query_nodes ) ) {
10397 query_nodes = new HashSet<PhylogenyNode>();
10398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10401 if ( s0.match( query_nodes ) ) {
10405 query_nodes = new HashSet<PhylogenyNode>();
10406 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10407 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10409 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10410 if ( s0.match( query_nodes ) ) {
10414 catch ( final Exception e ) {
10415 e.printStackTrace();
10421 private static boolean testSubtreeDeletion() {
10423 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10424 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10425 t1.deleteSubtree( t1.getNode( "A" ), false );
10426 if ( t1.getNumberOfExternalNodes() != 5 ) {
10429 t1.toNewHampshireX();
10430 t1.deleteSubtree( t1.getNode( "E" ), false );
10431 if ( t1.getNumberOfExternalNodes() != 4 ) {
10434 t1.toNewHampshireX();
10435 t1.deleteSubtree( t1.getNode( "F" ), false );
10436 if ( t1.getNumberOfExternalNodes() != 3 ) {
10439 t1.toNewHampshireX();
10440 t1.deleteSubtree( t1.getNode( "D" ), false );
10441 t1.toNewHampshireX();
10442 if ( t1.getNumberOfExternalNodes() != 3 ) {
10445 t1.deleteSubtree( t1.getNode( "def" ), false );
10446 t1.toNewHampshireX();
10447 if ( t1.getNumberOfExternalNodes() != 2 ) {
10450 t1.deleteSubtree( t1.getNode( "B" ), false );
10451 t1.toNewHampshireX();
10452 if ( t1.getNumberOfExternalNodes() != 1 ) {
10455 t1.deleteSubtree( t1.getNode( "C" ), false );
10456 t1.toNewHampshireX();
10457 if ( t1.getNumberOfExternalNodes() != 1 ) {
10460 t1.deleteSubtree( t1.getNode( "abc" ), false );
10461 t1.toNewHampshireX();
10462 if ( t1.getNumberOfExternalNodes() != 1 ) {
10465 t1.deleteSubtree( t1.getNode( "r" ), false );
10466 if ( t1.getNumberOfExternalNodes() != 0 ) {
10469 if ( !t1.isEmpty() ) {
10472 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10473 t2.deleteSubtree( t2.getNode( "A" ), false );
10474 t2.toNewHampshireX();
10475 if ( t2.getNumberOfExternalNodes() != 5 ) {
10478 t2.deleteSubtree( t2.getNode( "abc" ), false );
10479 t2.toNewHampshireX();
10480 if ( t2.getNumberOfExternalNodes() != 3 ) {
10483 t2.deleteSubtree( t2.getNode( "def" ), false );
10484 t2.toNewHampshireX();
10485 if ( t2.getNumberOfExternalNodes() != 1 ) {
10489 catch ( final Exception e ) {
10490 e.printStackTrace( System.out );
10496 private static boolean testSupportCount() {
10498 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10499 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10500 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10501 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10502 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10503 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10504 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10506 SupportCount.count( t0_1, phylogenies_1, true, false );
10507 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10508 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10509 + "(((((A,B),C),D),E),((F,G),X))"
10510 + "(((((A,Y),B),C),D),((F,G),E))"
10511 + "(((((A,B),C),D),E),(F,G))"
10512 + "(((((A,B),C),D),E),(F,G))"
10513 + "(((((A,B),C),D),E),(F,G))"
10514 + "(((((A,B),C),D),E),(F,G),Z)"
10515 + "(((((A,B),C),D),E),(F,G))"
10516 + "((((((A,B),C),D),E),F),G)"
10517 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10519 SupportCount.count( t0_2, phylogenies_2, true, false );
10520 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10521 while ( it.hasNext() ) {
10522 final PhylogenyNode n = it.next();
10523 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10527 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10528 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10529 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10530 SupportCount.count( t0_3, phylogenies_3, true, false );
10531 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10532 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10535 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10538 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10541 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10544 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10547 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10550 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10553 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10556 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10559 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10562 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10563 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10564 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10565 SupportCount.count( t0_4, phylogenies_4, true, false );
10566 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10567 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10570 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10573 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10576 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10579 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10582 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10585 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10588 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10591 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10594 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10597 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10598 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10599 double d = SupportCount.compare( b1, a, true, true, true );
10600 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10603 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10604 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10605 d = SupportCount.compare( b2, a, true, true, true );
10606 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10609 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10610 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10611 d = SupportCount.compare( b3, a, true, true, true );
10612 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10615 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10616 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10617 d = SupportCount.compare( b4, a, true, true, false );
10618 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10622 catch ( final Exception e ) {
10623 e.printStackTrace( System.out );
10629 private static boolean testSupportTransfer() {
10631 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10632 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)",
10633 new NHXParser() )[ 0 ];
10634 final Phylogeny p2 = factory
10635 .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 ];
10636 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10639 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10642 support_transfer.moveBranchLengthsToBootstrap( p1 );
10643 support_transfer.transferSupportValues( p1, p2 );
10644 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10647 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10650 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10653 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10656 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10659 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10662 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10665 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10669 catch ( final Exception e ) {
10670 e.printStackTrace( System.out );
10676 private static boolean testTaxonomyExtraction() {
10678 final PhylogenyNode n0 = PhylogenyNode
10679 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10680 if ( n0.getNodeData().isHasTaxonomy() ) {
10683 final PhylogenyNode n1 = PhylogenyNode
10684 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10685 if ( n1.getNodeData().isHasTaxonomy() ) {
10686 System.out.println( n1.toString() );
10689 final PhylogenyNode n2x = PhylogenyNode
10690 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10691 if ( n2x.getNodeData().isHasTaxonomy() ) {
10694 final PhylogenyNode n3 = PhylogenyNode
10695 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10696 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10697 System.out.println( n3.toString() );
10700 final PhylogenyNode n4 = PhylogenyNode
10701 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10702 if ( n4.getNodeData().isHasTaxonomy() ) {
10703 System.out.println( n4.toString() );
10706 final PhylogenyNode n5 = PhylogenyNode
10707 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10708 if ( n5.getNodeData().isHasTaxonomy() ) {
10709 System.out.println( n5.toString() );
10712 final PhylogenyNode n6 = PhylogenyNode
10713 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10714 if ( n6.getNodeData().isHasTaxonomy() ) {
10715 System.out.println( n6.toString() );
10718 final PhylogenyNode n7 = PhylogenyNode
10719 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10720 if ( n7.getNodeData().isHasTaxonomy() ) {
10721 System.out.println( n7.toString() );
10724 final PhylogenyNode n8 = PhylogenyNode
10725 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10726 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10727 System.out.println( n8.toString() );
10730 final PhylogenyNode n9 = PhylogenyNode
10731 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10732 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10733 System.out.println( n9.toString() );
10736 final PhylogenyNode n10x = PhylogenyNode
10737 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10738 if ( n10x.getNodeData().isHasTaxonomy() ) {
10739 System.out.println( n10x.toString() );
10742 final PhylogenyNode n10xx = PhylogenyNode
10743 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10744 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10745 System.out.println( n10xx.toString() );
10748 final PhylogenyNode n10 = PhylogenyNode
10749 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10750 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10751 System.out.println( n10.toString() );
10754 final PhylogenyNode n11 = PhylogenyNode
10755 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10756 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10757 System.out.println( n11.toString() );
10760 final PhylogenyNode n12 = PhylogenyNode
10761 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10762 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10763 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10764 System.out.println( n12.toString() );
10767 final PhylogenyNode n13 = PhylogenyNode
10768 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10769 if ( n13.getNodeData().isHasTaxonomy() ) {
10770 System.out.println( n13.toString() );
10774 catch ( final Exception e ) {
10775 e.printStackTrace( System.out );
10781 private static boolean testTreeMethods() {
10783 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10784 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10785 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10786 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10787 System.out.println( t0.toNewHampshireX() );
10790 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10791 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10792 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10795 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10798 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10802 catch ( final Exception e ) {
10803 e.printStackTrace( System.out );
10809 private static boolean testUniprotEntryRetrieval() {
10811 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
10812 if ( !entry.getAccession().equals( "P12345" ) ) {
10815 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
10818 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
10821 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
10825 catch ( final IOException e ) {
10826 System.out.println();
10827 System.out.println( "the following might be due to absence internet connection:" );
10828 e.printStackTrace( System.out );
10831 catch ( final Exception e ) {
10837 private static boolean testUniprotTaxonomySearch() {
10839 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
10841 if ( results.size() != 1 ) {
10844 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10847 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10850 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10853 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10856 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10860 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
10861 if ( results.size() != 1 ) {
10864 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10867 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10870 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10873 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10876 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10880 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
10881 if ( results.size() != 1 ) {
10884 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10887 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10890 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10893 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10896 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10900 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
10901 if ( results.size() != 1 ) {
10904 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10907 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10910 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10913 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10916 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10919 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
10922 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
10925 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10926 .equals( "Nematostella vectensis" ) ) {
10927 System.out.println( results.get( 0 ).getLineage() );
10932 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
10933 if ( results.size() != 1 ) {
10936 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
10939 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
10942 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
10945 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10948 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
10951 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10952 .equals( "Xenopus tropicalis" ) ) {
10953 System.out.println( results.get( 0 ).getLineage() );
10958 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
10959 if ( results.size() != 1 ) {
10962 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
10965 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
10968 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
10971 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10974 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
10977 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10978 .equals( "Xenopus tropicalis" ) ) {
10979 System.out.println( results.get( 0 ).getLineage() );
10984 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
10985 if ( results.size() != 1 ) {
10988 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
10991 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
10994 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
10997 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11000 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11003 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11004 .equals( "Xenopus tropicalis" ) ) {
11005 System.out.println( results.get( 0 ).getLineage() );
11009 catch ( final IOException e ) {
11010 System.out.println();
11011 System.out.println( "the following might be due to absence internet connection:" );
11012 e.printStackTrace( System.out );
11015 catch ( final Exception e ) {
11021 private static boolean testWabiTxSearch() {
11023 String result = "";
11024 result = TxSearch.searchSimple( "nematostella" );
11025 result = TxSearch.getTxId( "nematostella" );
11026 if ( !result.equals( "45350" ) ) {
11029 result = TxSearch.getTxName( "45350" );
11030 if ( !result.equals( "Nematostella" ) ) {
11033 result = TxSearch.getTxId( "nematostella vectensis" );
11034 if ( !result.equals( "45351" ) ) {
11037 result = TxSearch.getTxName( "45351" );
11038 if ( !result.equals( "Nematostella vectensis" ) ) {
11041 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11042 if ( !result.equals( "536089" ) ) {
11045 result = TxSearch.getTxName( "536089" );
11046 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11049 final List<String> queries = new ArrayList<String>();
11050 queries.add( "Campylobacter coli" );
11051 queries.add( "Escherichia coli" );
11052 queries.add( "Arabidopsis" );
11053 queries.add( "Trichoplax" );
11054 queries.add( "Samanea saman" );
11055 queries.add( "Kluyveromyces marxianus" );
11056 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11057 queries.add( "Bornavirus parrot/PDD/2008" );
11058 final List<RANKS> ranks = new ArrayList<RANKS>();
11059 ranks.add( RANKS.SUPERKINGDOM );
11060 ranks.add( RANKS.KINGDOM );
11061 ranks.add( RANKS.FAMILY );
11062 ranks.add( RANKS.GENUS );
11063 ranks.add( RANKS.TRIBE );
11064 result = TxSearch.searchLineage( queries, ranks );
11065 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11066 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11068 catch ( final Exception e ) {
11069 System.out.println();
11070 System.out.println( "the following might be due to absence internet connection:" );
11071 e.printStackTrace( System.out );