2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
40 import java.util.TreeSet;
42 import org.forester.application.support_transfer;
43 import org.forester.archaeopteryx.TreePanelUtil;
44 import org.forester.development.DevelopmentTools;
45 import org.forester.evoinference.TestPhylogenyReconstruction;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
47 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
48 import org.forester.go.TestGo;
49 import org.forester.io.parsers.FastaParser;
50 import org.forester.io.parsers.GeneralMsaParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser;
52 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
53 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
54 import org.forester.io.parsers.nexus.NexusCharactersParser;
55 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
56 import org.forester.io.parsers.nhx.NHXParser;
57 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
58 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
59 import org.forester.io.parsers.tol.TolParser;
60 import org.forester.io.parsers.util.ParserUtils;
61 import org.forester.io.writers.PhylogenyWriter;
62 import org.forester.io.writers.SequenceWriter;
63 import org.forester.msa.BasicMsa;
64 import org.forester.msa.Mafft;
65 import org.forester.msa.Msa;
66 import org.forester.msa.MsaInferrer;
67 import org.forester.msa.MsaMethods;
68 import org.forester.pccx.TestPccx;
69 import org.forester.phylogeny.Phylogeny;
70 import org.forester.phylogeny.PhylogenyBranch;
71 import org.forester.phylogeny.PhylogenyMethods;
72 import org.forester.phylogeny.PhylogenyNode;
73 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
74 import org.forester.phylogeny.data.Accession;
75 import org.forester.phylogeny.data.Accession.Source;
76 import org.forester.phylogeny.data.BinaryCharacters;
77 import org.forester.phylogeny.data.BranchWidth;
78 import org.forester.phylogeny.data.Confidence;
79 import org.forester.phylogeny.data.Distribution;
80 import org.forester.phylogeny.data.DomainArchitecture;
81 import org.forester.phylogeny.data.Event;
82 import org.forester.phylogeny.data.Identifier;
83 import org.forester.phylogeny.data.PhylogenyData;
84 import org.forester.phylogeny.data.PhylogenyDataUtil;
85 import org.forester.phylogeny.data.Polygon;
86 import org.forester.phylogeny.data.PropertiesMap;
87 import org.forester.phylogeny.data.Property;
88 import org.forester.phylogeny.data.Property.AppliesTo;
89 import org.forester.phylogeny.data.ProteinDomain;
90 import org.forester.phylogeny.data.Taxonomy;
91 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
92 import org.forester.phylogeny.factories.PhylogenyFactory;
93 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
94 import org.forester.protein.BasicDomain;
95 import org.forester.protein.BasicProtein;
96 import org.forester.protein.Domain;
97 import org.forester.protein.Protein;
98 import org.forester.protein.ProteinId;
99 import org.forester.rio.TestRIO;
100 import org.forester.sdi.SDI;
101 import org.forester.sdi.SDIR;
102 import org.forester.sdi.TestGSDI;
103 import org.forester.sequence.BasicSequence;
104 import org.forester.sequence.Sequence;
105 import org.forester.species.BasicSpecies;
106 import org.forester.species.Species;
107 import org.forester.surfacing.TestSurfacing;
108 import org.forester.tools.ConfidenceAssessor;
109 import org.forester.tools.SupportCount;
110 import org.forester.tools.TreeSplitMatrix;
111 import org.forester.util.AsciiHistogram;
112 import org.forester.util.BasicDescriptiveStatistics;
113 import org.forester.util.BasicTable;
114 import org.forester.util.BasicTableParser;
115 import org.forester.util.DescriptiveStatistics;
116 import org.forester.util.ForesterConstants;
117 import org.forester.util.ForesterUtil;
118 import org.forester.util.GeneralTable;
119 import org.forester.util.SequenceAccessionTools;
120 import org.forester.ws.seqdb.SequenceDatabaseEntry;
121 import org.forester.ws.seqdb.SequenceDbWsTools;
122 import org.forester.ws.seqdb.UniProtTaxonomy;
123 import org.forester.ws.wabi.TxSearch;
124 import org.forester.ws.wabi.TxSearch.RANKS;
125 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
126 import org.forester.ws.wabi.TxSearch.TAX_RANK;
128 @SuppressWarnings( "unused")
129 public final class Test {
131 private final static double ZERO_DIFF = 1.0E-9;
132 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "test_data"
134 + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
139 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/"
141 + ForesterConstants.PHYLO_XML_XSD;
142 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
143 + ForesterConstants.PHYLO_XML_VERSION + "/"
144 + ForesterConstants.PHYLO_XML_XSD;
146 public static boolean isEqual( final double a, final double b ) {
147 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
150 public static void main( final String[] args ) {
151 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
152 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
154 Locale.setDefault( Locale.US );
155 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
158 System.out.print( "[Test if directory with files for testing exists/is readable: " );
159 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
160 System.out.println( "OK.]" );
163 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
164 System.out.println( "Testing aborted." );
167 System.out.print( "[Test if resources directory exists/is readable: " );
168 if ( testDir( PATH_TO_RESOURCES ) ) {
169 System.out.println( "OK.]" );
172 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
173 System.out.println( "Testing aborted." );
176 final long start_time = new Date().getTime();
177 System.out.print( "Basic node methods: " );
178 if ( Test.testBasicNodeMethods() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Protein id: " );
187 if ( !testProteinId() ) {
188 System.out.println( "failed." );
194 System.out.println( "OK." );
195 System.out.print( "Species: " );
196 if ( !testSpecies() ) {
197 System.out.println( "failed." );
203 System.out.println( "OK." );
204 System.out.print( "Basic domain: " );
205 if ( !testBasicDomain() ) {
206 System.out.println( "failed." );
212 System.out.println( "OK." );
213 System.out.print( "Basic protein: " );
214 if ( !testBasicProtein() ) {
215 System.out.println( "failed." );
221 System.out.println( "OK." );
222 System.out.print( "Sequence writer: " );
223 if ( testSequenceWriter() ) {
224 System.out.println( "OK." );
228 System.out.println( "failed." );
231 System.out.print( "Sequence id parsing: " );
232 if ( testSequenceIdParsing() ) {
233 System.out.println( "OK." );
237 System.out.println( "failed." );
240 System.out.print( "UniProtKB id extraction: " );
241 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
242 System.out.println( "OK." );
246 System.out.println( "failed." );
249 System.out.print( "Sequence DB tools 1: " );
250 if ( testSequenceDbWsTools1() ) {
251 System.out.println( "OK." );
255 System.out.println( "failed." );
258 System.out.print( "Sequence DB tools 2: " );
259 if ( testSequenceDbWsTools2() ) {
260 System.out.println( "OK." );
264 System.out.println( "failed." );
269 System.out.print( "Hmmscan output parser: " );
270 if ( testHmmscanOutputParser() ) {
271 System.out.println( "OK." );
275 System.out.println( "failed." );
278 System.out.print( "Taxonomy code extraction: " );
279 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
280 System.out.println( "OK." );
284 System.out.println( "failed." );
287 System.out.print( "SN extraction: " );
288 if ( Test.testExtractSNFromNodeName() ) {
289 System.out.println( "OK." );
293 System.out.println( "failed." );
296 System.out.print( "Taxonomy extraction (general): " );
297 if ( Test.testTaxonomyExtraction() ) {
298 System.out.println( "OK." );
302 System.out.println( "failed." );
305 System.out.print( "Uri for Aptx web sequence accession: " );
306 if ( Test.testCreateUriForSeqWeb() ) {
307 System.out.println( "OK." );
311 System.out.println( "failed." );
314 System.out.print( "Basic node construction and parsing of NHX (node level): " );
315 if ( Test.testNHXNodeParsing() ) {
316 System.out.println( "OK." );
320 System.out.println( "failed." );
323 System.out.print( "NHX parsing iterating: " );
324 if ( Test.testNHParsingIter() ) {
325 System.out.println( "OK." );
329 System.out.println( "failed." );
332 System.out.print( "NH parsing: " );
333 if ( Test.testNHParsing() ) {
334 System.out.println( "OK." );
338 System.out.println( "failed." );
341 System.out.print( "Conversion to NHX (node level): " );
342 if ( Test.testNHXconversion() ) {
343 System.out.println( "OK." );
347 System.out.println( "failed." );
350 System.out.print( "NHX parsing: " );
351 if ( Test.testNHXParsing() ) {
352 System.out.println( "OK." );
356 System.out.println( "failed." );
359 System.out.print( "NHX parsing with quotes: " );
360 if ( Test.testNHXParsingQuotes() ) {
361 System.out.println( "OK." );
365 System.out.println( "failed." );
368 System.out.print( "NHX parsing (MrBayes): " );
369 if ( Test.testNHXParsingMB() ) {
370 System.out.println( "OK." );
374 System.out.println( "failed." );
377 System.out.print( "Nexus characters parsing: " );
378 if ( Test.testNexusCharactersParsing() ) {
379 System.out.println( "OK." );
383 System.out.println( "failed." );
386 System.out.print( "Nexus tree parsing iterating: " );
387 if ( Test.testNexusTreeParsingIterating() ) {
388 System.out.println( "OK." );
392 System.out.println( "failed." );
395 System.out.print( "Nexus tree parsing: " );
396 if ( Test.testNexusTreeParsing() ) {
397 System.out.println( "OK." );
401 System.out.println( "failed." );
404 System.out.print( "Nexus tree parsing (translating): " );
405 if ( Test.testNexusTreeParsingTranslating() ) {
406 System.out.println( "OK." );
410 System.out.println( "failed." );
413 System.out.print( "Nexus matrix parsing: " );
414 if ( Test.testNexusMatrixParsing() ) {
415 System.out.println( "OK." );
419 System.out.println( "failed." );
422 System.out.print( "Basic phyloXML parsing: " );
423 if ( Test.testBasicPhyloXMLparsing() ) {
424 System.out.println( "OK." );
428 System.out.println( "failed." );
431 System.out.print( "Basic phyloXML parsing (validating against schema): " );
432 if ( testBasicPhyloXMLparsingValidating() ) {
433 System.out.println( "OK." );
437 System.out.println( "failed." );
440 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
441 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
442 System.out.println( "OK." );
446 System.out.println( "failed." );
449 System.out.print( "phyloXML Distribution Element: " );
450 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
451 System.out.println( "OK." );
455 System.out.println( "failed." );
458 System.out.print( "Tol XML parsing: " );
459 if ( Test.testBasicTolXMLparsing() ) {
460 System.out.println( "OK." );
464 System.out.println( "failed." );
467 System.out.print( "Copying of node data: " );
468 if ( Test.testCopyOfNodeData() ) {
469 System.out.println( "OK." );
473 System.out.println( "failed." );
476 System.out.print( "Basic tree methods: " );
477 if ( Test.testBasicTreeMethods() ) {
478 System.out.println( "OK." );
482 System.out.println( "failed." );
485 System.out.print( "Tree methods: " );
486 if ( Test.testTreeMethods() ) {
487 System.out.println( "OK." );
491 System.out.println( "failed." );
494 System.out.print( "Postorder Iterator: " );
495 if ( Test.testPostOrderIterator() ) {
496 System.out.println( "OK." );
500 System.out.println( "failed." );
503 System.out.print( "Preorder Iterator: " );
504 if ( Test.testPreOrderIterator() ) {
505 System.out.println( "OK." );
509 System.out.println( "failed." );
512 System.out.print( "Levelorder Iterator: " );
513 if ( Test.testLevelOrderIterator() ) {
514 System.out.println( "OK." );
518 System.out.println( "failed." );
521 System.out.print( "Re-id methods: " );
522 if ( Test.testReIdMethods() ) {
523 System.out.println( "OK." );
527 System.out.println( "failed." );
530 System.out.print( "Methods on last external nodes: " );
531 if ( Test.testLastExternalNodeMethods() ) {
532 System.out.println( "OK." );
536 System.out.println( "failed." );
539 System.out.print( "Methods on external nodes: " );
540 if ( Test.testExternalNodeRelatedMethods() ) {
541 System.out.println( "OK." );
545 System.out.println( "failed." );
548 System.out.print( "Deletion of external nodes: " );
549 if ( Test.testDeletionOfExternalNodes() ) {
550 System.out.println( "OK." );
554 System.out.println( "failed." );
557 System.out.print( "Subtree deletion: " );
558 if ( Test.testSubtreeDeletion() ) {
559 System.out.println( "OK." );
563 System.out.println( "failed." );
566 System.out.print( "Phylogeny branch: " );
567 if ( Test.testPhylogenyBranch() ) {
568 System.out.println( "OK." );
572 System.out.println( "failed." );
575 System.out.print( "Rerooting: " );
576 if ( Test.testRerooting() ) {
577 System.out.println( "OK." );
581 System.out.println( "failed." );
584 System.out.print( "Mipoint rooting: " );
585 if ( Test.testMidpointrooting() ) {
586 System.out.println( "OK." );
590 System.out.println( "failed." );
593 System.out.print( "Node removal: " );
594 if ( Test.testNodeRemoval() ) {
595 System.out.println( "OK." );
599 System.out.println( "failed." );
602 System.out.print( "Support count: " );
603 if ( Test.testSupportCount() ) {
604 System.out.println( "OK." );
608 System.out.println( "failed." );
611 System.out.print( "Support transfer: " );
612 if ( Test.testSupportTransfer() ) {
613 System.out.println( "OK." );
617 System.out.println( "failed." );
620 System.out.print( "Finding of LCA: " );
621 if ( Test.testGetLCA() ) {
622 System.out.println( "OK." );
626 System.out.println( "failed." );
629 System.out.print( "Finding of LCA 2: " );
630 if ( Test.testGetLCA2() ) {
631 System.out.println( "OK." );
635 System.out.println( "failed." );
638 System.out.print( "Calculation of distance between nodes: " );
639 if ( Test.testGetDistance() ) {
640 System.out.println( "OK." );
644 System.out.println( "failed." );
647 System.out.print( "Descriptive statistics: " );
648 if ( Test.testDescriptiveStatistics() ) {
649 System.out.println( "OK." );
653 System.out.println( "failed." );
656 System.out.print( "Data objects and methods: " );
657 if ( Test.testDataObjects() ) {
658 System.out.println( "OK." );
662 System.out.println( "failed." );
665 System.out.print( "Properties map: " );
666 if ( Test.testPropertiesMap() ) {
667 System.out.println( "OK." );
671 System.out.println( "failed." );
674 System.out.print( "SDIse: " );
675 if ( Test.testSDIse() ) {
676 System.out.println( "OK." );
680 System.out.println( "failed." );
683 System.out.print( "SDIunrooted: " );
684 if ( Test.testSDIunrooted() ) {
685 System.out.println( "OK." );
689 System.out.println( "failed." );
692 System.out.print( "GSDI: " );
693 if ( TestGSDI.test() ) {
694 System.out.println( "OK." );
698 System.out.println( "failed." );
701 System.out.print( "RIO: " );
702 if ( TestRIO.test() ) {
703 System.out.println( "OK." );
707 System.out.println( "failed." );
710 System.out.print( "Phylogeny reconstruction:" );
711 System.out.println();
712 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
713 System.out.println( "OK." );
717 System.out.println( "failed." );
720 System.out.print( "Analysis of domain architectures: " );
721 System.out.println();
722 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
723 System.out.println( "OK." );
727 System.out.println( "failed." );
730 System.out.print( "GO: " );
731 System.out.println();
732 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
733 System.out.println( "OK." );
737 System.out.println( "failed." );
740 System.out.print( "Modeling tools: " );
741 if ( TestPccx.test() ) {
742 System.out.println( "OK." );
746 System.out.println( "failed." );
749 System.out.print( "Split Matrix strict: " );
750 if ( Test.testSplitStrict() ) {
751 System.out.println( "OK." );
755 System.out.println( "failed." );
758 System.out.print( "Split Matrix: " );
759 if ( Test.testSplit() ) {
760 System.out.println( "OK." );
764 System.out.println( "failed." );
767 System.out.print( "Confidence Assessor: " );
768 if ( Test.testConfidenceAssessor() ) {
769 System.out.println( "OK." );
773 System.out.println( "failed." );
776 System.out.print( "Basic table: " );
777 if ( Test.testBasicTable() ) {
778 System.out.println( "OK." );
782 System.out.println( "failed." );
785 System.out.print( "General table: " );
786 if ( Test.testGeneralTable() ) {
787 System.out.println( "OK." );
791 System.out.println( "failed." );
794 System.out.print( "Amino acid sequence: " );
795 if ( Test.testAminoAcidSequence() ) {
796 System.out.println( "OK." );
800 System.out.println( "failed." );
803 System.out.print( "General MSA parser: " );
804 if ( Test.testGeneralMsaParser() ) {
805 System.out.println( "OK." );
809 System.out.println( "failed." );
812 System.out.print( "Fasta parser for msa: " );
813 if ( Test.testFastaParser() ) {
814 System.out.println( "OK." );
818 System.out.println( "failed." );
821 System.out.print( "Creation of balanced phylogeny: " );
822 if ( Test.testCreateBalancedPhylogeny() ) {
823 System.out.println( "OK." );
827 System.out.println( "failed." );
830 System.out.print( "EMBL Entry Retrieval: " );
831 if ( Test.testEmblEntryRetrieval() ) {
832 System.out.println( "OK." );
836 System.out.println( "failed." );
839 System.out.print( "Uniprot Entry Retrieval: " );
840 if ( Test.testUniprotEntryRetrieval() ) {
841 System.out.println( "OK." );
845 System.out.println( "failed." );
848 System.out.print( "Uniprot Taxonomy Search: " );
849 if ( Test.testUniprotTaxonomySearch() ) {
850 System.out.println( "OK." );
854 System.out.println( "failed." );
859 final String os = ForesterUtil.OS_NAME.toLowerCase();
860 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
861 path = "/usr/local/bin/mafft";
863 else if ( os.indexOf( "win" ) >= 0 ) {
864 path = "C:\\Program Files\\mafft-win\\mafft.bat";
867 path = "/home/czmasek/bin/mafft";
869 if ( !MsaInferrer.isInstalled( path ) ) {
872 if ( !MsaInferrer.isInstalled( path ) ) {
873 path = "/usr/local/bin/mafft";
875 if ( MsaInferrer.isInstalled( path ) ) {
876 System.out.print( "MAFFT (external program): " );
877 if ( Test.testMafft( path ) ) {
878 System.out.println( "OK." );
882 System.out.println( "failed [will not count towards failed tests]" );
886 System.out.print( "Next nodes with collapsed: " );
887 if ( Test.testNextNodeWithCollapsing() ) {
888 System.out.println( "OK." );
892 System.out.println( "failed." );
895 System.out.print( "Simple MSA quality: " );
896 if ( Test.testMsaQualityMethod() ) {
897 System.out.println( "OK." );
901 System.out.println( "failed." );
904 System.out.println();
905 final Runtime rt = java.lang.Runtime.getRuntime();
906 final long free_memory = rt.freeMemory() / 1000000;
907 final long total_memory = rt.totalMemory() / 1000000;
908 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
909 + free_memory + "MB, total memory: " + total_memory + "MB)" );
910 System.out.println();
911 System.out.println( "Successful tests: " + succeeded );
912 System.out.println( "Failed tests: " + failed );
913 System.out.println();
915 System.out.println( "OK." );
918 System.out.println( "Not OK." );
922 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
923 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
927 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
928 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
931 private static boolean testAminoAcidSequence() {
933 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
934 if ( aa1.getLength() != 13 ) {
937 if ( aa1.getResidueAt( 0 ) != 'A' ) {
940 if ( aa1.getResidueAt( 2 ) != 'K' ) {
943 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
946 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
947 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
950 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
951 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
954 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
955 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
959 catch ( final Exception e ) {
966 private static boolean testBasicDomain() {
968 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
969 if ( !pd.getDomainId().equals( "id" ) ) {
972 if ( pd.getNumber() != 1 ) {
975 if ( pd.getTotalCount() != 4 ) {
978 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
981 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
982 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
983 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
984 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
985 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
986 if ( !a1.equals( a1 ) ) {
989 if ( !a1.equals( a1_copy ) ) {
992 if ( !a1.equals( a1_equal ) ) {
995 if ( !a1.equals( a2 ) ) {
998 if ( a1.equals( a3 ) ) {
1001 if ( a1.compareTo( a1 ) != 0 ) {
1004 if ( a1.compareTo( a1_copy ) != 0 ) {
1007 if ( a1.compareTo( a1_equal ) != 0 ) {
1010 if ( a1.compareTo( a2 ) != 0 ) {
1013 if ( a1.compareTo( a3 ) == 0 ) {
1017 catch ( final Exception e ) {
1018 e.printStackTrace( System.out );
1024 private static boolean testBasicNodeMethods() {
1026 if ( PhylogenyNode.getNodeCount() != 0 ) {
1029 final PhylogenyNode n1 = new PhylogenyNode();
1030 final PhylogenyNode n2 = PhylogenyNode
1031 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1032 final PhylogenyNode n3 = PhylogenyNode
1033 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1034 final PhylogenyNode n4 = PhylogenyNode
1035 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1036 if ( n1.isHasAssignedEvent() ) {
1039 if ( PhylogenyNode.getNodeCount() != 4 ) {
1042 if ( n3.getIndicator() != 0 ) {
1045 if ( n3.getNumberOfExternalNodes() != 1 ) {
1048 if ( !n3.isExternal() ) {
1051 if ( !n3.isRoot() ) {
1054 if ( !n4.getName().equals( "n4" ) ) {
1058 catch ( final Exception e ) {
1059 e.printStackTrace( System.out );
1065 private static boolean testBasicPhyloXMLparsing() {
1067 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1068 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1069 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1071 if ( xml_parser.getErrorCount() > 0 ) {
1072 System.out.println( xml_parser.getErrorMessages().toString() );
1075 if ( phylogenies_0.length != 4 ) {
1078 final Phylogeny t1 = phylogenies_0[ 0 ];
1079 final Phylogeny t2 = phylogenies_0[ 1 ];
1080 final Phylogeny t3 = phylogenies_0[ 2 ];
1081 final Phylogeny t4 = phylogenies_0[ 3 ];
1082 if ( t1.getNumberOfExternalNodes() != 1 ) {
1085 if ( !t1.isRooted() ) {
1088 if ( t1.isRerootable() ) {
1091 if ( !t1.getType().equals( "gene_tree" ) ) {
1094 if ( t2.getNumberOfExternalNodes() != 2 ) {
1097 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1100 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1103 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1106 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1109 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1112 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1115 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1116 .startsWith( "actgtgggggt" ) ) {
1119 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1120 .startsWith( "ctgtgatgcat" ) ) {
1123 if ( t3.getNumberOfExternalNodes() != 4 ) {
1126 if ( !t1.getName().equals( "t1" ) ) {
1129 if ( !t2.getName().equals( "t2" ) ) {
1132 if ( !t3.getName().equals( "t3" ) ) {
1135 if ( !t4.getName().equals( "t4" ) ) {
1138 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1141 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1144 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1147 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1148 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1151 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1154 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1157 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1160 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1161 .equals( "apoptosis" ) ) {
1164 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1165 .equals( "GO:0006915" ) ) {
1168 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1169 .equals( "UniProtKB" ) ) {
1172 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1173 .equals( "experimental" ) ) {
1176 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1177 .equals( "function" ) ) {
1180 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1181 .getValue() != 1 ) {
1184 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1185 .getType().equals( "ml" ) ) {
1188 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1189 .equals( "apoptosis" ) ) {
1192 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1193 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1196 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1197 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1200 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1201 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1204 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1205 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1208 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1209 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1212 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1213 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1216 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1217 .equals( "GO:0005829" ) ) {
1220 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1221 .equals( "intracellular organelle" ) ) {
1224 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1227 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1228 .equals( "UniProt link" ) ) ) {
1231 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1234 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1235 if ( x.size() != 4 ) {
1239 for( final Accession acc : x ) {
1241 if ( !acc.getSource().equals( "KEGG" ) ) {
1244 if ( !acc.getValue().equals( "hsa:596" ) ) {
1251 catch ( final Exception e ) {
1252 e.printStackTrace( System.out );
1258 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1260 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1261 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1262 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1263 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1266 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1268 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1270 if ( xml_parser.getErrorCount() > 0 ) {
1271 System.out.println( xml_parser.getErrorMessages().toString() );
1274 if ( phylogenies_0.length != 4 ) {
1277 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1278 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1279 if ( phylogenies_t1.length != 1 ) {
1282 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1283 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1286 if ( !t1_rt.isRooted() ) {
1289 if ( t1_rt.isRerootable() ) {
1292 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1295 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1296 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1297 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1298 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1301 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1304 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1307 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1310 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1311 .startsWith( "actgtgggggt" ) ) {
1314 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1315 .startsWith( "ctgtgatgcat" ) ) {
1318 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1319 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1320 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1321 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1322 if ( phylogenies_1.length != 1 ) {
1325 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1326 if ( !t3_rt.getName().equals( "t3" ) ) {
1329 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1332 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1335 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1338 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1341 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1342 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1345 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1348 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1351 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1352 .equals( "UniProtKB" ) ) {
1355 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1356 .equals( "apoptosis" ) ) {
1359 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1360 .equals( "GO:0006915" ) ) {
1363 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1364 .equals( "UniProtKB" ) ) {
1367 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1368 .equals( "experimental" ) ) {
1371 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1372 .equals( "function" ) ) {
1375 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1376 .getValue() != 1 ) {
1379 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1380 .getType().equals( "ml" ) ) {
1383 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1384 .equals( "apoptosis" ) ) {
1387 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1388 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1391 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1392 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1395 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1396 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1399 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1400 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1403 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1404 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1407 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1408 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1411 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1412 .equals( "GO:0005829" ) ) {
1415 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1416 .equals( "intracellular organelle" ) ) {
1419 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1422 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1423 .equals( "UniProt link" ) ) ) {
1426 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1429 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1432 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1433 .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." ) ) ) {
1436 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1439 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1442 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1445 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1448 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1449 .equals( "ncbi" ) ) {
1452 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1455 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1456 .getName().equals( "B" ) ) {
1459 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1460 .getFrom() != 21 ) {
1463 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1466 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1467 .getLength() != 24 ) {
1470 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1471 .getConfidence() != 2144 ) {
1474 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1475 .equals( "pfam" ) ) {
1478 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1481 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1484 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1487 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1490 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1491 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1494 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1497 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1500 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1503 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1506 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1509 if ( taxbb.getSynonyms().size() != 2 ) {
1512 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1515 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1518 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1521 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1524 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1527 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1528 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1531 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1534 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1537 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1540 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1543 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1546 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1549 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1553 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1556 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1557 .equalsIgnoreCase( "435" ) ) {
1560 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1563 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1564 .equalsIgnoreCase( "443.7" ) ) {
1567 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1570 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1573 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1574 .equalsIgnoreCase( "433" ) ) {
1577 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1578 .getCrossReferences();
1579 if ( x.size() != 4 ) {
1583 for( final Accession acc : x ) {
1585 if ( !acc.getSource().equals( "KEGG" ) ) {
1588 if ( !acc.getValue().equals( "hsa:596" ) ) {
1595 catch ( final Exception e ) {
1596 e.printStackTrace( System.out );
1602 private static boolean testBasicPhyloXMLparsingValidating() {
1604 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1605 PhyloXmlParser xml_parser = null;
1607 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1609 catch ( final Exception e ) {
1610 // Do nothing -- means were not running from jar.
1612 if ( xml_parser == null ) {
1613 xml_parser = new PhyloXmlParser();
1614 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1615 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1618 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1621 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1623 if ( xml_parser.getErrorCount() > 0 ) {
1624 System.out.println( xml_parser.getErrorMessages().toString() );
1627 if ( phylogenies_0.length != 4 ) {
1630 final Phylogeny t1 = phylogenies_0[ 0 ];
1631 final Phylogeny t2 = phylogenies_0[ 1 ];
1632 final Phylogeny t3 = phylogenies_0[ 2 ];
1633 final Phylogeny t4 = phylogenies_0[ 3 ];
1634 if ( !t1.getName().equals( "t1" ) ) {
1637 if ( !t2.getName().equals( "t2" ) ) {
1640 if ( !t3.getName().equals( "t3" ) ) {
1643 if ( !t4.getName().equals( "t4" ) ) {
1646 if ( t1.getNumberOfExternalNodes() != 1 ) {
1649 if ( t2.getNumberOfExternalNodes() != 2 ) {
1652 if ( t3.getNumberOfExternalNodes() != 4 ) {
1655 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1656 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1657 if ( xml_parser.getErrorCount() > 0 ) {
1658 System.out.println( "errors:" );
1659 System.out.println( xml_parser.getErrorMessages().toString() );
1662 if ( phylogenies_1.length != 4 ) {
1665 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1667 if ( xml_parser.getErrorCount() > 0 ) {
1668 System.out.println( "errors:" );
1669 System.out.println( xml_parser.getErrorMessages().toString() );
1672 if ( phylogenies_2.length != 1 ) {
1675 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1678 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1680 if ( xml_parser.getErrorCount() > 0 ) {
1681 System.out.println( xml_parser.getErrorMessages().toString() );
1684 if ( phylogenies_3.length != 2 ) {
1687 final Phylogeny a = phylogenies_3[ 0 ];
1688 if ( !a.getName().equals( "tree 4" ) ) {
1691 if ( a.getNumberOfExternalNodes() != 3 ) {
1694 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1697 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1700 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1702 if ( xml_parser.getErrorCount() > 0 ) {
1703 System.out.println( xml_parser.getErrorMessages().toString() );
1706 if ( phylogenies_4.length != 1 ) {
1709 final Phylogeny s = phylogenies_4[ 0 ];
1710 if ( s.getNumberOfExternalNodes() != 6 ) {
1713 s.getNode( "first" );
1715 s.getNode( "\"<a'b&c'd\">\"" );
1716 s.getNode( "'''\"" );
1717 s.getNode( "\"\"\"" );
1718 s.getNode( "dick & doof" );
1720 catch ( final Exception e ) {
1721 e.printStackTrace( System.out );
1727 private static boolean testBasicProtein() {
1729 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1730 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1731 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1732 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1733 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1734 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1735 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1736 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1737 p0.addProteinDomain( y );
1738 p0.addProteinDomain( e );
1739 p0.addProteinDomain( b );
1740 p0.addProteinDomain( c );
1741 p0.addProteinDomain( d );
1742 p0.addProteinDomain( a );
1743 p0.addProteinDomain( x );
1744 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1747 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
1751 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
1752 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1753 aa0.addProteinDomain( a1 );
1754 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
1757 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
1761 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
1762 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1763 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1764 aa1.addProteinDomain( a11 );
1765 aa1.addProteinDomain( a12 );
1766 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
1769 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
1772 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1773 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
1776 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1779 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
1782 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1783 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
1786 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1789 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
1792 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
1795 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1796 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
1799 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
1802 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
1805 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
1808 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1809 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
1812 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
1815 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
1818 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
1822 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
1823 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1824 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1825 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1826 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1827 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1828 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
1829 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
1830 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
1831 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
1832 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
1833 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1834 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1835 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
1836 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
1837 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
1838 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
1839 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
1840 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
1841 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
1842 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
1843 p00.addProteinDomain( y0 );
1844 p00.addProteinDomain( e0 );
1845 p00.addProteinDomain( b0 );
1846 p00.addProteinDomain( c0 );
1847 p00.addProteinDomain( d0 );
1848 p00.addProteinDomain( a0 );
1849 p00.addProteinDomain( x0 );
1850 p00.addProteinDomain( y1 );
1851 p00.addProteinDomain( y2 );
1852 p00.addProteinDomain( y3 );
1853 p00.addProteinDomain( e1 );
1854 p00.addProteinDomain( e2 );
1855 p00.addProteinDomain( e3 );
1856 p00.addProteinDomain( e4 );
1857 p00.addProteinDomain( e5 );
1858 p00.addProteinDomain( z0 );
1859 p00.addProteinDomain( z1 );
1860 p00.addProteinDomain( z2 );
1861 p00.addProteinDomain( zz0 );
1862 p00.addProteinDomain( zz1 );
1863 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
1866 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
1869 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1872 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1875 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" ) ) {
1878 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1879 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1880 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1881 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1882 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1883 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1884 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1885 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1886 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1887 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1888 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1889 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1890 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1891 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1892 p.addProteinDomain( B15 );
1893 p.addProteinDomain( C50 );
1894 p.addProteinDomain( A60 );
1895 p.addProteinDomain( A30 );
1896 p.addProteinDomain( C70 );
1897 p.addProteinDomain( B35 );
1898 p.addProteinDomain( B40 );
1899 p.addProteinDomain( A0 );
1900 p.addProteinDomain( A10 );
1901 p.addProteinDomain( A20 );
1902 p.addProteinDomain( B25 );
1903 p.addProteinDomain( D80 );
1904 List<String> domains_ids = new ArrayList<String>();
1905 domains_ids.add( "A" );
1906 domains_ids.add( "B" );
1907 domains_ids.add( "C" );
1908 if ( !p.contains( domains_ids, false ) ) {
1911 if ( !p.contains( domains_ids, true ) ) {
1914 domains_ids.add( "X" );
1915 if ( p.contains( domains_ids, false ) ) {
1918 if ( p.contains( domains_ids, true ) ) {
1921 domains_ids = new ArrayList<String>();
1922 domains_ids.add( "A" );
1923 domains_ids.add( "C" );
1924 domains_ids.add( "D" );
1925 if ( !p.contains( domains_ids, false ) ) {
1928 if ( !p.contains( domains_ids, true ) ) {
1931 domains_ids = new ArrayList<String>();
1932 domains_ids.add( "A" );
1933 domains_ids.add( "D" );
1934 domains_ids.add( "C" );
1935 if ( !p.contains( domains_ids, false ) ) {
1938 if ( p.contains( domains_ids, true ) ) {
1941 domains_ids = new ArrayList<String>();
1942 domains_ids.add( "A" );
1943 domains_ids.add( "A" );
1944 domains_ids.add( "B" );
1945 if ( !p.contains( domains_ids, false ) ) {
1948 if ( !p.contains( domains_ids, true ) ) {
1951 domains_ids = new ArrayList<String>();
1952 domains_ids.add( "A" );
1953 domains_ids.add( "A" );
1954 domains_ids.add( "A" );
1955 domains_ids.add( "B" );
1956 domains_ids.add( "B" );
1957 if ( !p.contains( domains_ids, false ) ) {
1960 if ( !p.contains( domains_ids, true ) ) {
1963 domains_ids = new ArrayList<String>();
1964 domains_ids.add( "A" );
1965 domains_ids.add( "A" );
1966 domains_ids.add( "B" );
1967 domains_ids.add( "A" );
1968 domains_ids.add( "B" );
1969 domains_ids.add( "B" );
1970 domains_ids.add( "A" );
1971 domains_ids.add( "B" );
1972 domains_ids.add( "C" );
1973 domains_ids.add( "A" );
1974 domains_ids.add( "C" );
1975 domains_ids.add( "D" );
1976 if ( !p.contains( domains_ids, false ) ) {
1979 if ( p.contains( domains_ids, true ) ) {
1983 catch ( final Exception e ) {
1984 e.printStackTrace( System.out );
1990 private static boolean testBasicTable() {
1992 final BasicTable<String> t0 = new BasicTable<String>();
1993 if ( t0.getNumberOfColumns() != 0 ) {
1996 if ( t0.getNumberOfRows() != 0 ) {
1999 t0.setValue( 3, 2, "23" );
2000 t0.setValue( 10, 1, "error" );
2001 t0.setValue( 10, 1, "110" );
2002 t0.setValue( 9, 1, "19" );
2003 t0.setValue( 1, 10, "101" );
2004 t0.setValue( 10, 10, "1010" );
2005 t0.setValue( 100, 10, "10100" );
2006 t0.setValue( 0, 0, "00" );
2007 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2010 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2013 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2016 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2019 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2022 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2025 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2028 if ( t0.getNumberOfColumns() != 101 ) {
2031 if ( t0.getNumberOfRows() != 11 ) {
2034 if ( t0.getValueAsString( 49, 4 ) != null ) {
2037 final String l = ForesterUtil.getLineSeparator();
2038 final StringBuffer source = new StringBuffer();
2039 source.append( "" + l );
2040 source.append( "# 1 1 1 1 1 1 1 1" + l );
2041 source.append( " 00 01 02 03" + l );
2042 source.append( " 10 11 12 13 " + l );
2043 source.append( "20 21 22 23 " + l );
2044 source.append( " 30 31 32 33" + l );
2045 source.append( "40 41 42 43" + l );
2046 source.append( " # 1 1 1 1 1 " + l );
2047 source.append( "50 51 52 53 54" + l );
2048 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2049 if ( t1.getNumberOfColumns() != 5 ) {
2052 if ( t1.getNumberOfRows() != 6 ) {
2055 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2058 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2061 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2064 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2067 final StringBuffer source1 = new StringBuffer();
2068 source1.append( "" + l );
2069 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2070 source1.append( " 00; 01 ;02;03" + l );
2071 source1.append( " 10; 11; 12; 13 " + l );
2072 source1.append( "20; 21; 22; 23 " + l );
2073 source1.append( " 30; 31; 32; 33" + l );
2074 source1.append( "40;41;42;43" + l );
2075 source1.append( " # 1 1 1 1 1 " + l );
2076 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2077 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2078 if ( t2.getNumberOfColumns() != 5 ) {
2081 if ( t2.getNumberOfRows() != 6 ) {
2084 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2087 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2090 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2093 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2096 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2099 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2102 final StringBuffer source2 = new StringBuffer();
2103 source2.append( "" + l );
2104 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2105 source2.append( " 00; 01 ;02;03" + l );
2106 source2.append( " 10; 11; 12; 13 " + l );
2107 source2.append( "20; 21; 22; 23 " + l );
2108 source2.append( " " + l );
2109 source2.append( " 30; 31; 32; 33" + l );
2110 source2.append( "40;41;42;43" + l );
2111 source2.append( " comment: 1 1 1 1 1 " + l );
2112 source2.append( ";;;50 ; 52; 53;;54 " + l );
2113 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2119 if ( tl.size() != 2 ) {
2122 final BasicTable<String> t3 = tl.get( 0 );
2123 final BasicTable<String> t4 = tl.get( 1 );
2124 if ( t3.getNumberOfColumns() != 4 ) {
2127 if ( t3.getNumberOfRows() != 3 ) {
2130 if ( t4.getNumberOfColumns() != 4 ) {
2133 if ( t4.getNumberOfRows() != 3 ) {
2136 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2139 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2143 catch ( final Exception e ) {
2144 e.printStackTrace( System.out );
2150 private static boolean testBasicTolXMLparsing() {
2152 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2153 final TolParser parser = new TolParser();
2154 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2155 if ( parser.getErrorCount() > 0 ) {
2156 System.out.println( parser.getErrorMessages().toString() );
2159 if ( phylogenies_0.length != 1 ) {
2162 final Phylogeny t1 = phylogenies_0[ 0 ];
2163 if ( t1.getNumberOfExternalNodes() != 5 ) {
2166 if ( !t1.isRooted() ) {
2169 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2172 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2175 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2178 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2181 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2182 if ( parser.getErrorCount() > 0 ) {
2183 System.out.println( parser.getErrorMessages().toString() );
2186 if ( phylogenies_1.length != 1 ) {
2189 final Phylogeny t2 = phylogenies_1[ 0 ];
2190 if ( t2.getNumberOfExternalNodes() != 664 ) {
2193 if ( !t2.isRooted() ) {
2196 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2199 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2202 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2205 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2208 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2211 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2212 .equals( "Aquifex" ) ) {
2215 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2216 if ( parser.getErrorCount() > 0 ) {
2217 System.out.println( parser.getErrorMessages().toString() );
2220 if ( phylogenies_2.length != 1 ) {
2223 final Phylogeny t3 = phylogenies_2[ 0 ];
2224 if ( t3.getNumberOfExternalNodes() != 184 ) {
2227 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2230 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2233 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2236 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2237 if ( parser.getErrorCount() > 0 ) {
2238 System.out.println( parser.getErrorMessages().toString() );
2241 if ( phylogenies_3.length != 1 ) {
2244 final Phylogeny t4 = phylogenies_3[ 0 ];
2245 if ( t4.getNumberOfExternalNodes() != 1 ) {
2248 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2251 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2254 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2257 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2258 if ( parser.getErrorCount() > 0 ) {
2259 System.out.println( parser.getErrorMessages().toString() );
2262 if ( phylogenies_4.length != 1 ) {
2265 final Phylogeny t5 = phylogenies_4[ 0 ];
2266 if ( t5.getNumberOfExternalNodes() != 13 ) {
2269 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2272 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2275 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2279 catch ( final Exception e ) {
2280 e.printStackTrace( System.out );
2286 private static boolean testBasicTreeMethods() {
2288 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2289 final Phylogeny t1 = factory.create();
2290 if ( !t1.isEmpty() ) {
2293 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2294 if ( t2.getNumberOfExternalNodes() != 4 ) {
2297 if ( t2.getHeight() != 8.5 ) {
2300 if ( !t2.isCompletelyBinary() ) {
2303 if ( t2.isEmpty() ) {
2306 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2307 if ( t3.getNumberOfExternalNodes() != 5 ) {
2310 if ( t3.getHeight() != 11 ) {
2313 if ( t3.isCompletelyBinary() ) {
2316 final PhylogenyNode n = t3.getNode( "ABC" );
2317 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 ];
2318 if ( t4.getNumberOfExternalNodes() != 9 ) {
2321 if ( t4.getHeight() != 11 ) {
2324 if ( t4.isCompletelyBinary() ) {
2327 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)" );
2328 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2329 if ( t5.getNumberOfExternalNodes() != 8 ) {
2332 if ( t5.getHeight() != 15 ) {
2335 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)" );
2336 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2337 if ( t6.getHeight() != 15 ) {
2340 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)" );
2341 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2342 if ( t7.getHeight() != 15 ) {
2345 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)" );
2346 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2347 if ( t8.getNumberOfExternalNodes() != 10 ) {
2350 if ( t8.getHeight() != 15 ) {
2353 final char[] a9 = new char[] { 'a' };
2354 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2355 if ( t9.getHeight() != 0 ) {
2358 final char[] a10 = new char[] { 'a', ':', '6' };
2359 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2360 if ( t10.getHeight() != 6 ) {
2364 catch ( final Exception e ) {
2365 e.printStackTrace( System.out );
2371 private static boolean testConfidenceAssessor() {
2373 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2374 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2375 final Phylogeny[] ev0 = factory
2376 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2378 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2379 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2382 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2385 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2386 final Phylogeny[] ev1 = factory
2387 .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)));",
2389 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2390 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2393 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2396 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2397 final Phylogeny[] ev_b = factory
2398 .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",
2400 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2401 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2404 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2408 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2409 final Phylogeny[] ev1x = factory
2410 .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)));",
2412 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2413 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2416 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2419 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2420 final Phylogeny[] ev_bx = factory
2421 .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",
2423 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2424 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2427 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2431 final Phylogeny[] t2 = factory
2432 .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);",
2434 final Phylogeny[] ev2 = factory
2435 .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);",
2437 for( final Phylogeny target : t2 ) {
2438 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2441 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2442 new NHXParser() )[ 0 ];
2443 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2444 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2445 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2448 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2451 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2455 catch ( final Exception e ) {
2456 e.printStackTrace();
2462 private static boolean testCopyOfNodeData() {
2464 final PhylogenyNode n1 = PhylogenyNode
2465 .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]" );
2466 final PhylogenyNode n2 = n1.copyNodeData();
2467 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2471 catch ( final Exception e ) {
2472 e.printStackTrace();
2478 private static boolean testCreateBalancedPhylogeny() {
2480 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2481 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2484 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2487 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2488 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2491 if ( p1.getNumberOfExternalNodes() != 100 ) {
2495 catch ( final Exception e ) {
2496 e.printStackTrace();
2502 private static boolean testCreateUriForSeqWeb() {
2504 final PhylogenyNode n = new PhylogenyNode();
2505 n.setName( "tr|B3RJ64" );
2506 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2509 n.setName( "B0LM41_HUMAN" );
2510 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2513 n.setName( "NP_001025424" );
2514 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2517 n.setName( "_NM_001030253-" );
2518 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2521 n.setName( "XM_002122186" );
2522 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2525 n.setName( "dgh_AAA34956_gdg" );
2526 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2529 n.setName( "AAA34956" );
2530 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2533 n.setName( "GI:394892" );
2534 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2535 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2538 n.setName( "gi_394892" );
2539 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2540 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2543 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2544 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2545 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2548 n.setName( "P12345" );
2549 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2550 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2553 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2554 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2555 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2559 catch ( final Exception e ) {
2560 e.printStackTrace( System.out );
2566 private static boolean testDataObjects() {
2568 final Confidence s0 = new Confidence();
2569 final Confidence s1 = new Confidence();
2570 if ( !s0.isEqual( s1 ) ) {
2573 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2574 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2575 if ( s2.isEqual( s1 ) ) {
2578 if ( !s2.isEqual( s3 ) ) {
2581 final Confidence s4 = ( Confidence ) s3.copy();
2582 if ( !s4.isEqual( s3 ) ) {
2589 final Taxonomy t1 = new Taxonomy();
2590 final Taxonomy t2 = new Taxonomy();
2591 final Taxonomy t3 = new Taxonomy();
2592 final Taxonomy t4 = new Taxonomy();
2593 final Taxonomy t5 = new Taxonomy();
2594 t1.setIdentifier( new Identifier( "ecoli" ) );
2595 t1.setTaxonomyCode( "ECOLI" );
2596 t1.setScientificName( "E. coli" );
2597 t1.setCommonName( "coli" );
2598 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2599 if ( !t1.isEqual( t0 ) ) {
2602 t2.setIdentifier( new Identifier( "ecoli" ) );
2603 t2.setTaxonomyCode( "OTHER" );
2604 t2.setScientificName( "what" );
2605 t2.setCommonName( "something" );
2606 if ( !t1.isEqual( t2 ) ) {
2609 t2.setIdentifier( new Identifier( "nemve" ) );
2610 if ( t1.isEqual( t2 ) ) {
2613 t1.setIdentifier( null );
2614 t3.setTaxonomyCode( "ECOLI" );
2615 t3.setScientificName( "what" );
2616 t3.setCommonName( "something" );
2617 if ( !t1.isEqual( t3 ) ) {
2620 t1.setIdentifier( null );
2621 t1.setTaxonomyCode( "" );
2622 t4.setScientificName( "E. ColI" );
2623 t4.setCommonName( "something" );
2624 if ( !t1.isEqual( t4 ) ) {
2627 t4.setScientificName( "B. subtilis" );
2628 t4.setCommonName( "something" );
2629 if ( t1.isEqual( t4 ) ) {
2632 t1.setIdentifier( null );
2633 t1.setTaxonomyCode( "" );
2634 t1.setScientificName( "" );
2635 t5.setCommonName( "COLI" );
2636 if ( !t1.isEqual( t5 ) ) {
2639 t5.setCommonName( "vibrio" );
2640 if ( t1.isEqual( t5 ) ) {
2645 final Identifier id0 = new Identifier( "123", "pfam" );
2646 final Identifier id1 = ( Identifier ) id0.copy();
2647 if ( !id1.isEqual( id1 ) ) {
2650 if ( !id1.isEqual( id0 ) ) {
2653 if ( !id0.isEqual( id1 ) ) {
2660 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2661 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2662 if ( !pd1.isEqual( pd1 ) ) {
2665 if ( !pd1.isEqual( pd0 ) ) {
2670 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2671 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2672 if ( !pd3.isEqual( pd3 ) ) {
2675 if ( !pd2.isEqual( pd3 ) ) {
2678 if ( !pd0.isEqual( pd3 ) ) {
2683 // DomainArchitecture
2684 // ------------------
2685 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2686 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2687 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2688 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2689 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2690 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2695 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2696 if ( ds0.getNumberOfDomains() != 4 ) {
2699 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2700 if ( !ds0.isEqual( ds0 ) ) {
2703 if ( !ds0.isEqual( ds1 ) ) {
2706 if ( ds1.getNumberOfDomains() != 4 ) {
2709 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2714 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2715 if ( ds0.isEqual( ds2 ) ) {
2721 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2722 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2723 System.out.println( ds3.toNHX() );
2726 if ( ds3.getNumberOfDomains() != 3 ) {
2731 final Event e1 = new Event( Event.EventType.fusion );
2732 if ( e1.isDuplication() ) {
2735 if ( !e1.isFusion() ) {
2738 if ( !e1.asText().toString().equals( "fusion" ) ) {
2741 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2744 final Event e11 = new Event( Event.EventType.fusion );
2745 if ( !e11.isEqual( e1 ) ) {
2748 if ( !e11.toNHX().toString().equals( "" ) ) {
2751 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2752 if ( e2.isDuplication() ) {
2755 if ( !e2.isSpeciationOrDuplication() ) {
2758 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2761 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2764 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2767 if ( e11.isEqual( e2 ) ) {
2770 final Event e2c = ( Event ) e2.copy();
2771 if ( !e2c.isEqual( e2 ) ) {
2774 Event e3 = new Event( 1, 2, 3 );
2775 if ( e3.isDuplication() ) {
2778 if ( e3.isSpeciation() ) {
2781 if ( e3.isGeneLoss() ) {
2784 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2787 final Event e3c = ( Event ) e3.copy();
2788 final Event e3cc = ( Event ) e3c.copy();
2789 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2793 if ( !e3c.isEqual( e3cc ) ) {
2796 Event e4 = new Event( 1, 2, 3 );
2797 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2800 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2803 final Event e4c = ( Event ) e4.copy();
2805 final Event e4cc = ( Event ) e4c.copy();
2806 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2809 if ( !e4c.isEqual( e4cc ) ) {
2812 final Event e5 = new Event();
2813 if ( !e5.isUnassigned() ) {
2816 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2819 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2822 final Event e6 = new Event( 1, 0, 0 );
2823 if ( !e6.asText().toString().equals( "duplication" ) ) {
2826 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2829 final Event e7 = new Event( 0, 1, 0 );
2830 if ( !e7.asText().toString().equals( "speciation" ) ) {
2833 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2836 final Event e8 = new Event( 0, 0, 1 );
2837 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2840 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2844 catch ( final Exception e ) {
2845 e.printStackTrace( System.out );
2851 private static boolean testDeletionOfExternalNodes() {
2853 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2854 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2855 final PhylogenyWriter w = new PhylogenyWriter();
2856 if ( t0.isEmpty() ) {
2859 if ( t0.getNumberOfExternalNodes() != 1 ) {
2862 t0.deleteSubtree( t0.getNode( "A" ), false );
2863 if ( t0.getNumberOfExternalNodes() != 0 ) {
2866 if ( !t0.isEmpty() ) {
2869 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2870 if ( t1.getNumberOfExternalNodes() != 2 ) {
2873 t1.deleteSubtree( t1.getNode( "A" ), false );
2874 if ( t1.getNumberOfExternalNodes() != 1 ) {
2877 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2880 t1.deleteSubtree( t1.getNode( "B" ), false );
2881 if ( t1.getNumberOfExternalNodes() != 1 ) {
2884 t1.deleteSubtree( t1.getNode( "r" ), false );
2885 if ( !t1.isEmpty() ) {
2888 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2889 if ( t2.getNumberOfExternalNodes() != 3 ) {
2892 t2.deleteSubtree( t2.getNode( "B" ), false );
2893 if ( t2.getNumberOfExternalNodes() != 2 ) {
2896 t2.toNewHampshireX();
2897 PhylogenyNode n = t2.getNode( "A" );
2898 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2901 t2.deleteSubtree( t2.getNode( "A" ), false );
2902 if ( t2.getNumberOfExternalNodes() != 2 ) {
2905 t2.deleteSubtree( t2.getNode( "C" ), true );
2906 if ( t2.getNumberOfExternalNodes() != 1 ) {
2909 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2910 if ( t3.getNumberOfExternalNodes() != 4 ) {
2913 t3.deleteSubtree( t3.getNode( "B" ), true );
2914 if ( t3.getNumberOfExternalNodes() != 3 ) {
2917 n = t3.getNode( "A" );
2918 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2921 n = n.getNextExternalNode();
2922 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2925 t3.deleteSubtree( t3.getNode( "A" ), true );
2926 if ( t3.getNumberOfExternalNodes() != 2 ) {
2929 n = t3.getNode( "C" );
2930 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2933 t3.deleteSubtree( t3.getNode( "C" ), true );
2934 if ( t3.getNumberOfExternalNodes() != 1 ) {
2937 t3.deleteSubtree( t3.getNode( "D" ), true );
2938 if ( t3.getNumberOfExternalNodes() != 0 ) {
2941 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2942 if ( t4.getNumberOfExternalNodes() != 6 ) {
2945 t4.deleteSubtree( t4.getNode( "B2" ), true );
2946 if ( t4.getNumberOfExternalNodes() != 5 ) {
2949 String s = w.toNewHampshire( t4, false, true ).toString();
2950 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2953 t4.deleteSubtree( t4.getNode( "B11" ), true );
2954 if ( t4.getNumberOfExternalNodes() != 4 ) {
2957 t4.deleteSubtree( t4.getNode( "C" ), true );
2958 if ( t4.getNumberOfExternalNodes() != 3 ) {
2961 n = t4.getNode( "A" );
2962 n = n.getNextExternalNode();
2963 if ( !n.getName().equals( "B12" ) ) {
2966 n = n.getNextExternalNode();
2967 if ( !n.getName().equals( "D" ) ) {
2970 s = w.toNewHampshire( t4, false, true ).toString();
2971 if ( !s.equals( "((A,B12),D);" ) ) {
2974 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2975 t5.deleteSubtree( t5.getNode( "A" ), true );
2976 if ( t5.getNumberOfExternalNodes() != 5 ) {
2979 s = w.toNewHampshire( t5, false, true ).toString();
2980 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2983 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2984 t6.deleteSubtree( t6.getNode( "B11" ), true );
2985 if ( t6.getNumberOfExternalNodes() != 5 ) {
2988 s = w.toNewHampshire( t6, false, false ).toString();
2989 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2992 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2993 t7.deleteSubtree( t7.getNode( "B12" ), true );
2994 if ( t7.getNumberOfExternalNodes() != 5 ) {
2997 s = w.toNewHampshire( t7, false, true ).toString();
2998 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3001 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3002 t8.deleteSubtree( t8.getNode( "B2" ), true );
3003 if ( t8.getNumberOfExternalNodes() != 5 ) {
3006 s = w.toNewHampshire( t8, false, false ).toString();
3007 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3010 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3011 t9.deleteSubtree( t9.getNode( "C" ), true );
3012 if ( t9.getNumberOfExternalNodes() != 5 ) {
3015 s = w.toNewHampshire( t9, false, true ).toString();
3016 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3019 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3020 t10.deleteSubtree( t10.getNode( "D" ), true );
3021 if ( t10.getNumberOfExternalNodes() != 5 ) {
3024 s = w.toNewHampshire( t10, false, true ).toString();
3025 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3028 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3029 t11.deleteSubtree( t11.getNode( "A" ), true );
3030 if ( t11.getNumberOfExternalNodes() != 2 ) {
3033 s = w.toNewHampshire( t11, false, true ).toString();
3034 if ( !s.equals( "(B,C);" ) ) {
3037 t11.deleteSubtree( t11.getNode( "C" ), true );
3038 if ( t11.getNumberOfExternalNodes() != 1 ) {
3041 s = w.toNewHampshire( t11, false, false ).toString();
3042 if ( !s.equals( "B;" ) ) {
3045 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3046 t12.deleteSubtree( t12.getNode( "B2" ), true );
3047 if ( t12.getNumberOfExternalNodes() != 8 ) {
3050 s = w.toNewHampshire( t12, false, true ).toString();
3051 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3054 t12.deleteSubtree( t12.getNode( "B3" ), true );
3055 if ( t12.getNumberOfExternalNodes() != 7 ) {
3058 s = w.toNewHampshire( t12, false, true ).toString();
3059 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3062 t12.deleteSubtree( t12.getNode( "C3" ), true );
3063 if ( t12.getNumberOfExternalNodes() != 6 ) {
3066 s = w.toNewHampshire( t12, false, true ).toString();
3067 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3070 t12.deleteSubtree( t12.getNode( "A1" ), true );
3071 if ( t12.getNumberOfExternalNodes() != 5 ) {
3074 s = w.toNewHampshire( t12, false, true ).toString();
3075 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3078 t12.deleteSubtree( t12.getNode( "B1" ), true );
3079 if ( t12.getNumberOfExternalNodes() != 4 ) {
3082 s = w.toNewHampshire( t12, false, true ).toString();
3083 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3086 t12.deleteSubtree( t12.getNode( "A3" ), true );
3087 if ( t12.getNumberOfExternalNodes() != 3 ) {
3090 s = w.toNewHampshire( t12, false, true ).toString();
3091 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3094 t12.deleteSubtree( t12.getNode( "A2" ), true );
3095 if ( t12.getNumberOfExternalNodes() != 2 ) {
3098 s = w.toNewHampshire( t12, false, true ).toString();
3099 if ( !s.equals( "(C1,C2);" ) ) {
3102 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3103 t13.deleteSubtree( t13.getNode( "D" ), true );
3104 if ( t13.getNumberOfExternalNodes() != 4 ) {
3107 s = w.toNewHampshire( t13, false, true ).toString();
3108 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3111 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3112 t14.deleteSubtree( t14.getNode( "E" ), true );
3113 if ( t14.getNumberOfExternalNodes() != 5 ) {
3116 s = w.toNewHampshire( t14, false, true ).toString();
3117 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3120 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3121 t15.deleteSubtree( t15.getNode( "B2" ), true );
3122 if ( t15.getNumberOfExternalNodes() != 11 ) {
3125 t15.deleteSubtree( t15.getNode( "B1" ), true );
3126 if ( t15.getNumberOfExternalNodes() != 10 ) {
3129 t15.deleteSubtree( t15.getNode( "B3" ), true );
3130 if ( t15.getNumberOfExternalNodes() != 9 ) {
3133 t15.deleteSubtree( t15.getNode( "B4" ), true );
3134 if ( t15.getNumberOfExternalNodes() != 8 ) {
3137 t15.deleteSubtree( t15.getNode( "A1" ), true );
3138 if ( t15.getNumberOfExternalNodes() != 7 ) {
3141 t15.deleteSubtree( t15.getNode( "C4" ), true );
3142 if ( t15.getNumberOfExternalNodes() != 6 ) {
3146 catch ( final Exception e ) {
3147 e.printStackTrace( System.out );
3153 private static boolean testDescriptiveStatistics() {
3155 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3156 dss1.addValue( 82 );
3157 dss1.addValue( 78 );
3158 dss1.addValue( 70 );
3159 dss1.addValue( 58 );
3160 dss1.addValue( 42 );
3161 if ( dss1.getN() != 5 ) {
3164 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3167 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3170 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3173 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3176 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3179 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3182 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3185 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3188 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3191 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3194 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3197 dss1.addValue( 123 );
3198 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3201 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3204 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3207 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3208 dss2.addValue( -1.85 );
3209 dss2.addValue( 57.5 );
3210 dss2.addValue( 92.78 );
3211 dss2.addValue( 57.78 );
3212 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3215 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3218 final double[] a = dss2.getDataAsDoubleArray();
3219 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3222 dss2.addValue( -100 );
3223 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3226 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3229 final double[] ds = new double[ 14 ];
3244 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3245 if ( bins.length != 4 ) {
3248 if ( bins[ 0 ] != 2 ) {
3251 if ( bins[ 1 ] != 3 ) {
3254 if ( bins[ 2 ] != 4 ) {
3257 if ( bins[ 3 ] != 5 ) {
3260 final double[] ds1 = new double[ 9 ];
3270 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3271 if ( bins1.length != 4 ) {
3274 if ( bins1[ 0 ] != 2 ) {
3277 if ( bins1[ 1 ] != 3 ) {
3280 if ( bins1[ 2 ] != 0 ) {
3283 if ( bins1[ 3 ] != 4 ) {
3286 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3287 if ( bins1_1.length != 3 ) {
3290 if ( bins1_1[ 0 ] != 3 ) {
3293 if ( bins1_1[ 1 ] != 2 ) {
3296 if ( bins1_1[ 2 ] != 4 ) {
3299 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3300 if ( bins1_2.length != 3 ) {
3303 if ( bins1_2[ 0 ] != 2 ) {
3306 if ( bins1_2[ 1 ] != 2 ) {
3309 if ( bins1_2[ 2 ] != 2 ) {
3312 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3326 dss3.addValue( 10 );
3327 dss3.addValue( 10 );
3328 dss3.addValue( 10 );
3329 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3330 histo.toStringBuffer( 10, '=', 40, 5 );
3331 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3333 catch ( final Exception e ) {
3334 e.printStackTrace( System.out );
3340 private static boolean testDir( final String file ) {
3342 final File f = new File( file );
3343 if ( !f.exists() ) {
3346 if ( !f.isDirectory() ) {
3349 if ( !f.canRead() ) {
3353 catch ( final Exception e ) {
3359 private static boolean testEmblEntryRetrieval() {
3360 //The format for GenBank Accession numbers are:
3361 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3362 //Protein: 3 letters + 5 numerals
3363 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3364 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3367 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3370 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3373 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3376 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3379 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3382 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3385 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3388 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3391 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3394 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3397 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3400 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3403 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3409 private static boolean testExternalNodeRelatedMethods() {
3411 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3412 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3413 PhylogenyNode n = t1.getNode( "A" );
3414 n = n.getNextExternalNode();
3415 if ( !n.getName().equals( "B" ) ) {
3418 n = n.getNextExternalNode();
3419 if ( !n.getName().equals( "C" ) ) {
3422 n = n.getNextExternalNode();
3423 if ( !n.getName().equals( "D" ) ) {
3426 n = t1.getNode( "B" );
3427 while ( !n.isLastExternalNode() ) {
3428 n = n.getNextExternalNode();
3430 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3431 n = t2.getNode( "A" );
3432 n = n.getNextExternalNode();
3433 if ( !n.getName().equals( "B" ) ) {
3436 n = n.getNextExternalNode();
3437 if ( !n.getName().equals( "C" ) ) {
3440 n = n.getNextExternalNode();
3441 if ( !n.getName().equals( "D" ) ) {
3444 n = t2.getNode( "B" );
3445 while ( !n.isLastExternalNode() ) {
3446 n = n.getNextExternalNode();
3448 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3449 n = t3.getNode( "A" );
3450 n = n.getNextExternalNode();
3451 if ( !n.getName().equals( "B" ) ) {
3454 n = n.getNextExternalNode();
3455 if ( !n.getName().equals( "C" ) ) {
3458 n = n.getNextExternalNode();
3459 if ( !n.getName().equals( "D" ) ) {
3462 n = n.getNextExternalNode();
3463 if ( !n.getName().equals( "E" ) ) {
3466 n = n.getNextExternalNode();
3467 if ( !n.getName().equals( "F" ) ) {
3470 n = n.getNextExternalNode();
3471 if ( !n.getName().equals( "G" ) ) {
3474 n = n.getNextExternalNode();
3475 if ( !n.getName().equals( "H" ) ) {
3478 n = t3.getNode( "B" );
3479 while ( !n.isLastExternalNode() ) {
3480 n = n.getNextExternalNode();
3482 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3483 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3484 final PhylogenyNode node = iter.next();
3486 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3487 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3488 final PhylogenyNode node = iter.next();
3490 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3491 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3492 if ( !iter.next().getName().equals( "A" ) ) {
3495 if ( !iter.next().getName().equals( "B" ) ) {
3498 if ( !iter.next().getName().equals( "C" ) ) {
3501 if ( !iter.next().getName().equals( "D" ) ) {
3504 if ( !iter.next().getName().equals( "E" ) ) {
3507 if ( !iter.next().getName().equals( "F" ) ) {
3510 if ( iter.hasNext() ) {
3514 catch ( final Exception e ) {
3515 e.printStackTrace( System.out );
3521 private static boolean testExtractSNFromNodeName() {
3523 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3526 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3527 .equals( "Mus musculus musculus" ) ) {
3530 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3531 .equals( "Mus musculus musculus" ) ) {
3534 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3537 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3538 .equals( "Mus musculus" ) ) {
3542 catch ( final Exception e ) {
3543 e.printStackTrace( System.out );
3549 private static boolean testExtractTaxonomyCodeFromNodeName() {
3551 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3554 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3555 .equals( "SOYBN" ) ) {
3558 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3559 .equals( "ARATH" ) ) {
3562 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3563 .equals( "ARATH" ) ) {
3566 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3569 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3572 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3575 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3576 .equals( "SOYBN" ) ) {
3579 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3580 .equals( "SOYBN" ) ) {
3583 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3584 .equals( "SOYBN" ) ) {
3587 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3588 .equals( "SOYBN" ) ) {
3591 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3592 .equals( "SOYBN" ) ) {
3595 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3596 .equals( "SOYBN" ) ) {
3599 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3600 .equals( "SOYBN" ) ) {
3603 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3604 .equals( "SOYBN" ) ) {
3607 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3610 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3611 .equals( "SOYBN" ) ) {
3614 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3615 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3618 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3619 .equals( "9YX45" ) ) {
3622 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3623 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3624 .equals( "MOUSE" ) ) {
3627 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3628 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3629 .equals( "MOUSE" ) ) {
3632 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3633 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3634 .equals( "MOUSE" ) ) {
3637 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3638 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3641 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3642 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3645 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3646 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3649 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3650 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3653 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3654 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3657 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3658 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3661 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3662 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3665 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3666 .equals( "RAT" ) ) {
3669 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3670 .equals( "PIG" ) ) {
3674 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3675 .equals( "MOUSE" ) ) {
3678 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3679 .equals( "MOUSE" ) ) {
3682 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3686 catch ( final Exception e ) {
3687 e.printStackTrace( System.out );
3693 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3695 PhylogenyNode n = new PhylogenyNode();
3696 n.setName( "tr|B3RJ64" );
3697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3700 n.setName( "tr.B3RJ64" );
3701 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3704 n.setName( "tr=B3RJ64" );
3705 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3708 n.setName( "tr-B3RJ64" );
3709 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3712 n.setName( "tr/B3RJ64" );
3713 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3716 n.setName( "tr\\B3RJ64" );
3717 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3720 n.setName( "tr_B3RJ64" );
3721 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3724 n.setName( " tr|B3RJ64 " );
3725 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3728 n.setName( "-tr|B3RJ64-" );
3729 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3732 n.setName( "-tr=B3RJ64-" );
3733 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3736 n.setName( "_tr=B3RJ64_" );
3737 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3740 n.setName( " tr_tr|B3RJ64_sp|123 " );
3741 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3744 n.setName( "B3RJ64" );
3745 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3748 n.setName( "sp|B3RJ64" );
3749 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3752 n.setName( "sp|B3RJ64C" );
3753 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3756 n.setName( "sp B3RJ64" );
3757 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3760 n.setName( "sp|B3RJ6X" );
3761 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3764 n.setName( "sp|B3RJ6" );
3765 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3768 n.setName( "K1PYK7_CRAGI" );
3769 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3772 n.setName( "K1PYK7_PEA" );
3773 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
3776 n.setName( "K1PYK7_RAT" );
3777 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
3780 n.setName( "K1PYK7_PIG" );
3781 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3784 n.setName( "~K1PYK7_PIG~" );
3785 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3788 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3789 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3792 n.setName( "K1PYKX_CRAGI" );
3793 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3796 n.setName( "XXXXX_CRAGI" );
3797 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
3800 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3801 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
3804 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3805 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3808 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3809 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
3812 n = new PhylogenyNode();
3813 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3814 seq.setSymbol( "K1PYK7_CRAGI" );
3815 n.getNodeData().addSequence( seq );
3816 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3819 seq.setSymbol( "tr|B3RJ64" );
3820 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3823 n = new PhylogenyNode();
3824 seq = new org.forester.phylogeny.data.Sequence();
3825 seq.setName( "K1PYK7_CRAGI" );
3826 n.getNodeData().addSequence( seq );
3827 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3830 seq.setName( "tr|B3RJ64" );
3831 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3834 n = new PhylogenyNode();
3835 seq = new org.forester.phylogeny.data.Sequence();
3836 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3837 n.getNodeData().addSequence( seq );
3838 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
3841 n = new PhylogenyNode();
3842 seq = new org.forester.phylogeny.data.Sequence();
3843 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3844 n.getNodeData().addSequence( seq );
3845 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3849 n = new PhylogenyNode();
3850 n.setName( "ACP19736" );
3851 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3854 n = new PhylogenyNode();
3855 n.setName( "|ACP19736|" );
3856 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3860 catch ( final Exception e ) {
3861 e.printStackTrace( System.out );
3867 private static boolean testFastaParser() {
3869 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3872 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3875 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3876 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3879 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3882 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3885 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3888 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3891 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3895 catch ( final Exception e ) {
3896 e.printStackTrace();
3902 private static boolean testGeneralMsaParser() {
3904 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3905 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3906 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3907 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3908 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3909 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3910 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3911 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3912 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3915 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3918 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3921 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3924 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3927 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3930 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3933 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3936 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3939 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3942 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3945 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3948 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3949 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3952 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3955 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3958 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3959 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3962 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3965 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3968 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3969 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3972 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3975 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3979 catch ( final Exception e ) {
3980 e.printStackTrace();
3986 private static boolean testGeneralTable() {
3988 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3989 t0.setValue( 3, 2, "23" );
3990 t0.setValue( 10, 1, "error" );
3991 t0.setValue( 10, 1, "110" );
3992 t0.setValue( 9, 1, "19" );
3993 t0.setValue( 1, 10, "101" );
3994 t0.setValue( 10, 10, "1010" );
3995 t0.setValue( 100, 10, "10100" );
3996 t0.setValue( 0, 0, "00" );
3997 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4000 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4003 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4006 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4009 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4012 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4015 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4018 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4021 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4024 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4025 t1.setValue( "3", "2", "23" );
4026 t1.setValue( "10", "1", "error" );
4027 t1.setValue( "10", "1", "110" );
4028 t1.setValue( "9", "1", "19" );
4029 t1.setValue( "1", "10", "101" );
4030 t1.setValue( "10", "10", "1010" );
4031 t1.setValue( "100", "10", "10100" );
4032 t1.setValue( "0", "0", "00" );
4033 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4034 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4037 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4040 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4043 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4046 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4049 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4052 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4055 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4058 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4061 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4065 catch ( final Exception e ) {
4066 e.printStackTrace( System.out );
4072 private static boolean testGetDistance() {
4074 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4075 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",
4076 new NHXParser() )[ 0 ];
4077 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4080 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4083 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4086 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4089 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4092 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4095 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4098 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4101 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4104 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4107 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4110 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4113 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4116 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4119 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4122 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4125 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4128 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4131 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4134 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4137 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4140 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4143 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4146 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4149 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4152 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4155 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4158 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4161 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4164 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4167 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4170 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",
4171 new NHXParser() )[ 0 ];
4172 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4175 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4178 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4181 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4184 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4187 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4190 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4193 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4196 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4199 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4202 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4206 catch ( final Exception e ) {
4207 e.printStackTrace( System.out );
4213 private static boolean testGetLCA() {
4215 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4216 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4217 new NHXParser() )[ 0 ];
4218 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4219 if ( !A.getName().equals( "A" ) ) {
4222 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4223 if ( !gh.getName().equals( "gh" ) ) {
4226 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4227 if ( !ab.getName().equals( "ab" ) ) {
4230 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4231 if ( !ab2.getName().equals( "ab" ) ) {
4234 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4235 if ( !gh2.getName().equals( "gh" ) ) {
4238 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4239 if ( !gh3.getName().equals( "gh" ) ) {
4242 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4243 if ( !abc.getName().equals( "abc" ) ) {
4246 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4247 if ( !abc2.getName().equals( "abc" ) ) {
4250 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4251 if ( !abcd.getName().equals( "abcd" ) ) {
4254 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4255 if ( !abcd2.getName().equals( "abcd" ) ) {
4258 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4259 if ( !abcdef.getName().equals( "abcdef" ) ) {
4262 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4263 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4266 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4267 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4270 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4271 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4274 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4275 if ( !abcde.getName().equals( "abcde" ) ) {
4278 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4279 if ( !abcde2.getName().equals( "abcde" ) ) {
4282 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4283 if ( !r.getName().equals( "abcdefgh" ) ) {
4286 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4287 if ( !r2.getName().equals( "abcdefgh" ) ) {
4290 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4291 if ( !r3.getName().equals( "abcdefgh" ) ) {
4294 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4295 if ( !abcde3.getName().equals( "abcde" ) ) {
4298 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4299 if ( !abcde4.getName().equals( "abcde" ) ) {
4302 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4303 if ( !ab3.getName().equals( "ab" ) ) {
4306 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4307 if ( !ab4.getName().equals( "ab" ) ) {
4310 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4311 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4312 if ( !cd.getName().equals( "cd" ) ) {
4315 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4316 if ( !cd2.getName().equals( "cd" ) ) {
4319 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4320 if ( !cde.getName().equals( "cde" ) ) {
4323 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4324 if ( !cde2.getName().equals( "cde" ) ) {
4327 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4328 if ( !cdef.getName().equals( "cdef" ) ) {
4331 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4332 if ( !cdef2.getName().equals( "cdef" ) ) {
4335 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4336 if ( !cdef3.getName().equals( "cdef" ) ) {
4339 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4340 if ( !rt.getName().equals( "r" ) ) {
4343 final Phylogeny p3 = factory
4344 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4345 new NHXParser() )[ 0 ];
4346 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4347 if ( !bc_3.getName().equals( "bc" ) ) {
4350 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4351 if ( !ac_3.getName().equals( "abc" ) ) {
4354 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4355 if ( !ad_3.getName().equals( "abcde" ) ) {
4358 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4359 if ( !af_3.getName().equals( "abcdef" ) ) {
4362 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4363 if ( !ag_3.getName().equals( "" ) ) {
4366 if ( !ag_3.isRoot() ) {
4369 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4370 if ( !al_3.getName().equals( "" ) ) {
4373 if ( !al_3.isRoot() ) {
4376 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4377 if ( !kl_3.getName().equals( "" ) ) {
4380 if ( !kl_3.isRoot() ) {
4383 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4384 if ( !fl_3.getName().equals( "" ) ) {
4387 if ( !fl_3.isRoot() ) {
4390 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4391 if ( !gk_3.getName().equals( "ghijk" ) ) {
4394 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4395 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4396 if ( !r_4.getName().equals( "r" ) ) {
4399 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4400 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4401 if ( !r_5.getName().equals( "root" ) ) {
4404 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4405 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4406 if ( !r_6.getName().equals( "rot" ) ) {
4409 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4410 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4411 if ( !r_7.getName().equals( "rott" ) ) {
4415 catch ( final Exception e ) {
4416 e.printStackTrace( System.out );
4422 private static boolean testGetLCA2() {
4424 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4425 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4426 PhylogenyMethods.preOrderReId( p_a );
4427 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4428 p_a.getNode( "a" ) );
4429 if ( !p_a_1.getName().equals( "a" ) ) {
4432 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4433 PhylogenyMethods.preOrderReId( p_b );
4434 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4435 p_b.getNode( "a" ) );
4436 if ( !p_b_1.getName().equals( "b" ) ) {
4439 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4440 p_b.getNode( "b" ) );
4441 if ( !p_b_2.getName().equals( "b" ) ) {
4444 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4445 PhylogenyMethods.preOrderReId( p_c );
4446 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4447 p_c.getNode( "a" ) );
4448 if ( !p_c_1.getName().equals( "b" ) ) {
4451 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4452 p_c.getNode( "c" ) );
4453 if ( !p_c_2.getName().equals( "c" ) ) {
4454 System.out.println( p_c_2.getName() );
4458 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4459 p_c.getNode( "b" ) );
4460 if ( !p_c_3.getName().equals( "b" ) ) {
4463 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4464 p_c.getNode( "a" ) );
4465 if ( !p_c_4.getName().equals( "c" ) ) {
4468 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4469 new NHXParser() )[ 0 ];
4470 PhylogenyMethods.preOrderReId( p1 );
4471 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4472 p1.getNode( "A" ) );
4473 if ( !A.getName().equals( "A" ) ) {
4476 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4477 p1.getNode( "gh" ) );
4478 if ( !gh.getName().equals( "gh" ) ) {
4481 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4482 p1.getNode( "B" ) );
4483 if ( !ab.getName().equals( "ab" ) ) {
4486 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4487 p1.getNode( "A" ) );
4488 if ( !ab2.getName().equals( "ab" ) ) {
4491 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4492 p1.getNode( "G" ) );
4493 if ( !gh2.getName().equals( "gh" ) ) {
4496 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4497 p1.getNode( "H" ) );
4498 if ( !gh3.getName().equals( "gh" ) ) {
4501 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4502 p1.getNode( "A" ) );
4503 if ( !abc.getName().equals( "abc" ) ) {
4506 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4507 p1.getNode( "C" ) );
4508 if ( !abc2.getName().equals( "abc" ) ) {
4511 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4512 p1.getNode( "D" ) );
4513 if ( !abcd.getName().equals( "abcd" ) ) {
4516 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4517 p1.getNode( "A" ) );
4518 if ( !abcd2.getName().equals( "abcd" ) ) {
4521 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4522 p1.getNode( "F" ) );
4523 if ( !abcdef.getName().equals( "abcdef" ) ) {
4526 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4527 p1.getNode( "A" ) );
4528 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4531 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4532 p1.getNode( "F" ) );
4533 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4536 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4537 p1.getNode( "ab" ) );
4538 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4541 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4542 p1.getNode( "E" ) );
4543 if ( !abcde.getName().equals( "abcde" ) ) {
4546 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4547 p1.getNode( "A" ) );
4548 if ( !abcde2.getName().equals( "abcde" ) ) {
4551 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4552 p1.getNode( "abcdefgh" ) );
4553 if ( !r.getName().equals( "abcdefgh" ) ) {
4556 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4557 p1.getNode( "H" ) );
4558 if ( !r2.getName().equals( "abcdefgh" ) ) {
4561 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4562 p1.getNode( "A" ) );
4563 if ( !r3.getName().equals( "abcdefgh" ) ) {
4566 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4567 p1.getNode( "abcde" ) );
4568 if ( !abcde3.getName().equals( "abcde" ) ) {
4571 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4572 p1.getNode( "E" ) );
4573 if ( !abcde4.getName().equals( "abcde" ) ) {
4576 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4577 p1.getNode( "B" ) );
4578 if ( !ab3.getName().equals( "ab" ) ) {
4581 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4582 p1.getNode( "ab" ) );
4583 if ( !ab4.getName().equals( "ab" ) ) {
4586 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4587 PhylogenyMethods.preOrderReId( p2 );
4588 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4589 p2.getNode( "d" ) );
4590 if ( !cd.getName().equals( "cd" ) ) {
4593 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4594 p2.getNode( "c" ) );
4595 if ( !cd2.getName().equals( "cd" ) ) {
4598 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4599 p2.getNode( "e" ) );
4600 if ( !cde.getName().equals( "cde" ) ) {
4603 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4604 p2.getNode( "c" ) );
4605 if ( !cde2.getName().equals( "cde" ) ) {
4608 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4609 p2.getNode( "f" ) );
4610 if ( !cdef.getName().equals( "cdef" ) ) {
4613 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4614 p2.getNode( "f" ) );
4615 if ( !cdef2.getName().equals( "cdef" ) ) {
4618 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4619 p2.getNode( "d" ) );
4620 if ( !cdef3.getName().equals( "cdef" ) ) {
4623 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4624 p2.getNode( "a" ) );
4625 if ( !rt.getName().equals( "r" ) ) {
4628 final Phylogeny p3 = factory
4629 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4630 new NHXParser() )[ 0 ];
4631 PhylogenyMethods.preOrderReId( p3 );
4632 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4633 p3.getNode( "c" ) );
4634 if ( !bc_3.getName().equals( "bc" ) ) {
4637 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4638 p3.getNode( "c" ) );
4639 if ( !ac_3.getName().equals( "abc" ) ) {
4642 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4643 p3.getNode( "d" ) );
4644 if ( !ad_3.getName().equals( "abcde" ) ) {
4647 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4648 p3.getNode( "f" ) );
4649 if ( !af_3.getName().equals( "abcdef" ) ) {
4652 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4653 p3.getNode( "g" ) );
4654 if ( !ag_3.getName().equals( "" ) ) {
4657 if ( !ag_3.isRoot() ) {
4660 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4661 p3.getNode( "l" ) );
4662 if ( !al_3.getName().equals( "" ) ) {
4665 if ( !al_3.isRoot() ) {
4668 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4669 p3.getNode( "l" ) );
4670 if ( !kl_3.getName().equals( "" ) ) {
4673 if ( !kl_3.isRoot() ) {
4676 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4677 p3.getNode( "l" ) );
4678 if ( !fl_3.getName().equals( "" ) ) {
4681 if ( !fl_3.isRoot() ) {
4684 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4685 p3.getNode( "k" ) );
4686 if ( !gk_3.getName().equals( "ghijk" ) ) {
4689 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4690 PhylogenyMethods.preOrderReId( p4 );
4691 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4692 p4.getNode( "c" ) );
4693 if ( !r_4.getName().equals( "r" ) ) {
4696 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4697 PhylogenyMethods.preOrderReId( p5 );
4698 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4699 p5.getNode( "c" ) );
4700 if ( !r_5.getName().equals( "root" ) ) {
4703 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4704 PhylogenyMethods.preOrderReId( p6 );
4705 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4706 p6.getNode( "a" ) );
4707 if ( !r_6.getName().equals( "rot" ) ) {
4710 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4711 PhylogenyMethods.preOrderReId( p7 );
4712 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4713 p7.getNode( "e" ) );
4714 if ( !r_7.getName().equals( "rott" ) ) {
4717 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4718 p7.getNode( "a" ) );
4719 if ( !r_71.getName().equals( "rott" ) ) {
4722 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4723 p7.getNode( "rott" ) );
4724 if ( !r_72.getName().equals( "rott" ) ) {
4727 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4728 p7.getNode( "a" ) );
4729 if ( !r_73.getName().equals( "rott" ) ) {
4732 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4733 p7.getNode( "rott" ) );
4734 if ( !r_74.getName().equals( "rott" ) ) {
4737 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4738 p7.getNode( "e" ) );
4739 if ( !r_75.getName().equals( "e" ) ) {
4743 catch ( final Exception e ) {
4744 e.printStackTrace( System.out );
4750 private static boolean testHmmscanOutputParser() {
4751 final String test_dir = Test.PATH_TO_TEST_DATA;
4753 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4754 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4756 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4757 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4758 final List<Protein> proteins = parser2.parse();
4759 if ( parser2.getProteinsEncountered() != 4 ) {
4762 if ( proteins.size() != 4 ) {
4765 if ( parser2.getDomainsEncountered() != 69 ) {
4768 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4771 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4774 final Protein p1 = proteins.get( 0 );
4775 if ( p1.getNumberOfProteinDomains() != 15 ) {
4778 if ( p1.getLength() != 850 ) {
4781 final Protein p2 = proteins.get( 1 );
4782 if ( p2.getNumberOfProteinDomains() != 51 ) {
4785 if ( p2.getLength() != 1291 ) {
4788 final Protein p3 = proteins.get( 2 );
4789 if ( p3.getNumberOfProteinDomains() != 2 ) {
4792 final Protein p4 = proteins.get( 3 );
4793 if ( p4.getNumberOfProteinDomains() != 1 ) {
4796 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4799 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4802 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4805 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4808 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4811 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4814 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4817 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4820 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4824 catch ( final Exception e ) {
4825 e.printStackTrace( System.out );
4831 private static boolean testLastExternalNodeMethods() {
4833 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4834 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4835 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4836 final PhylogenyNode n1 = t0.getNode( "A" );
4837 if ( n1.isLastExternalNode() ) {
4840 final PhylogenyNode n2 = t0.getNode( "B" );
4841 if ( n2.isLastExternalNode() ) {
4844 final PhylogenyNode n3 = t0.getNode( "C" );
4845 if ( n3.isLastExternalNode() ) {
4848 final PhylogenyNode n4 = t0.getNode( "D" );
4849 if ( !n4.isLastExternalNode() ) {
4853 catch ( final Exception e ) {
4854 e.printStackTrace( System.out );
4860 private static boolean testLevelOrderIterator() {
4862 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4863 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4864 PhylogenyNodeIterator it0;
4865 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4868 for( it0.reset(); it0.hasNext(); ) {
4871 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4872 if ( !it.next().getName().equals( "r" ) ) {
4875 if ( !it.next().getName().equals( "ab" ) ) {
4878 if ( !it.next().getName().equals( "cd" ) ) {
4881 if ( !it.next().getName().equals( "A" ) ) {
4884 if ( !it.next().getName().equals( "B" ) ) {
4887 if ( !it.next().getName().equals( "C" ) ) {
4890 if ( !it.next().getName().equals( "D" ) ) {
4893 if ( it.hasNext() ) {
4896 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",
4897 new NHXParser() )[ 0 ];
4898 PhylogenyNodeIterator it2;
4899 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4902 for( it2.reset(); it2.hasNext(); ) {
4905 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4906 if ( !it3.next().getName().equals( "r" ) ) {
4909 if ( !it3.next().getName().equals( "abc" ) ) {
4912 if ( !it3.next().getName().equals( "defg" ) ) {
4915 if ( !it3.next().getName().equals( "A" ) ) {
4918 if ( !it3.next().getName().equals( "B" ) ) {
4921 if ( !it3.next().getName().equals( "C" ) ) {
4924 if ( !it3.next().getName().equals( "D" ) ) {
4927 if ( !it3.next().getName().equals( "E" ) ) {
4930 if ( !it3.next().getName().equals( "F" ) ) {
4933 if ( !it3.next().getName().equals( "G" ) ) {
4936 if ( !it3.next().getName().equals( "1" ) ) {
4939 if ( !it3.next().getName().equals( "2" ) ) {
4942 if ( !it3.next().getName().equals( "3" ) ) {
4945 if ( !it3.next().getName().equals( "4" ) ) {
4948 if ( !it3.next().getName().equals( "5" ) ) {
4951 if ( !it3.next().getName().equals( "6" ) ) {
4954 if ( !it3.next().getName().equals( "f1" ) ) {
4957 if ( !it3.next().getName().equals( "f2" ) ) {
4960 if ( !it3.next().getName().equals( "f3" ) ) {
4963 if ( !it3.next().getName().equals( "a" ) ) {
4966 if ( !it3.next().getName().equals( "b" ) ) {
4969 if ( !it3.next().getName().equals( "f21" ) ) {
4972 if ( !it3.next().getName().equals( "X" ) ) {
4975 if ( !it3.next().getName().equals( "Y" ) ) {
4978 if ( !it3.next().getName().equals( "Z" ) ) {
4981 if ( it3.hasNext() ) {
4984 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4985 PhylogenyNodeIterator it4;
4986 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4989 for( it4.reset(); it4.hasNext(); ) {
4992 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4993 if ( !it5.next().getName().equals( "r" ) ) {
4996 if ( !it5.next().getName().equals( "A" ) ) {
4999 if ( !it5.next().getName().equals( "B" ) ) {
5002 if ( !it5.next().getName().equals( "C" ) ) {
5005 if ( !it5.next().getName().equals( "D" ) ) {
5008 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5009 PhylogenyNodeIterator it6;
5010 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5013 for( it6.reset(); it6.hasNext(); ) {
5016 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5017 if ( !it7.next().getName().equals( "A" ) ) {
5020 if ( it.hasNext() ) {
5024 catch ( final Exception e ) {
5025 e.printStackTrace( System.out );
5031 private static boolean testMafft( final String path ) {
5033 final List<String> opts = new ArrayList<String>();
5034 opts.add( "--maxiterate" );
5036 opts.add( "--localpair" );
5037 opts.add( "--quiet" );
5039 final MsaInferrer mafft = Mafft.createInstance( path );
5040 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5041 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5044 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5048 catch ( final Exception e ) {
5049 e.printStackTrace( System.out );
5055 private static boolean testMidpointrooting() {
5057 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5058 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5059 PhylogenyMethods.midpointRoot( t0 );
5060 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5063 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5066 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5070 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",
5071 new NHXParser() )[ 0 ];
5072 if ( !t1.isRooted() ) {
5075 PhylogenyMethods.midpointRoot( t1 );
5076 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5079 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5082 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5085 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5088 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5091 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5094 t1.reRoot( t1.getNode( "A" ) );
5095 PhylogenyMethods.midpointRoot( t1 );
5096 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5099 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5102 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5105 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5108 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5112 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5116 catch ( final Exception e ) {
5117 e.printStackTrace( System.out );
5123 private static boolean testMsaQualityMethod() {
5125 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5126 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5127 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5128 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5129 final List<Sequence> l = new ArrayList<Sequence>();
5134 final Msa msa = BasicMsa.createInstance( l );
5135 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5138 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5141 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5144 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5148 catch ( final Exception e ) {
5149 e.printStackTrace( System.out );
5155 private static boolean testNextNodeWithCollapsing() {
5157 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5159 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5160 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5161 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5162 t0.getNode( "cd" ).setCollapse( true );
5163 t0.getNode( "cde" ).setCollapse( true );
5164 n = t0.getFirstExternalNode();
5165 while ( n != null ) {
5167 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5169 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5172 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5175 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5178 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5181 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5184 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5188 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5189 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5190 t1.getNode( "ab" ).setCollapse( true );
5191 t1.getNode( "cd" ).setCollapse( true );
5192 t1.getNode( "cde" ).setCollapse( true );
5193 n = t1.getNode( "ab" );
5194 ext = new ArrayList<PhylogenyNode>();
5195 while ( n != null ) {
5197 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5199 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5202 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5205 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5208 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5211 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5217 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5218 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5219 t2.getNode( "ab" ).setCollapse( true );
5220 t2.getNode( "cd" ).setCollapse( true );
5221 t2.getNode( "cde" ).setCollapse( true );
5222 t2.getNode( "c" ).setCollapse( true );
5223 t2.getNode( "d" ).setCollapse( true );
5224 t2.getNode( "e" ).setCollapse( true );
5225 t2.getNode( "gh" ).setCollapse( true );
5226 n = t2.getNode( "ab" );
5227 ext = new ArrayList<PhylogenyNode>();
5228 while ( n != null ) {
5230 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5232 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5235 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5238 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5241 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5247 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5248 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5249 t3.getNode( "ab" ).setCollapse( true );
5250 t3.getNode( "cd" ).setCollapse( true );
5251 t3.getNode( "cde" ).setCollapse( true );
5252 t3.getNode( "c" ).setCollapse( true );
5253 t3.getNode( "d" ).setCollapse( true );
5254 t3.getNode( "e" ).setCollapse( true );
5255 t3.getNode( "gh" ).setCollapse( true );
5256 t3.getNode( "fgh" ).setCollapse( true );
5257 n = t3.getNode( "ab" );
5258 ext = new ArrayList<PhylogenyNode>();
5259 while ( n != null ) {
5261 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5263 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5266 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5269 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5275 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5276 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5277 t4.getNode( "ab" ).setCollapse( true );
5278 t4.getNode( "cd" ).setCollapse( true );
5279 t4.getNode( "cde" ).setCollapse( true );
5280 t4.getNode( "c" ).setCollapse( true );
5281 t4.getNode( "d" ).setCollapse( true );
5282 t4.getNode( "e" ).setCollapse( true );
5283 t4.getNode( "gh" ).setCollapse( true );
5284 t4.getNode( "fgh" ).setCollapse( true );
5285 t4.getNode( "abcdefgh" ).setCollapse( true );
5286 n = t4.getNode( "abcdefgh" );
5287 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5292 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5293 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5295 n = t5.getFirstExternalNode();
5296 while ( n != null ) {
5298 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5300 if ( ext.size() != 8 ) {
5303 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5306 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5309 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5312 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5315 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5318 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5321 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5324 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5329 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5330 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5332 t6.getNode( "ab" ).setCollapse( true );
5333 n = t6.getNode( "ab" );
5334 while ( n != null ) {
5336 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5338 if ( ext.size() != 7 ) {
5341 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5344 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5347 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5350 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5353 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5356 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5359 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5364 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5365 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5367 t7.getNode( "cd" ).setCollapse( true );
5368 n = t7.getNode( "a" );
5369 while ( n != null ) {
5371 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5373 if ( ext.size() != 7 ) {
5376 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5379 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5382 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5385 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5388 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5391 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5394 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5399 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5400 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5402 t8.getNode( "cd" ).setCollapse( true );
5403 t8.getNode( "c" ).setCollapse( true );
5404 t8.getNode( "d" ).setCollapse( true );
5405 n = t8.getNode( "a" );
5406 while ( n != null ) {
5408 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5410 if ( ext.size() != 7 ) {
5413 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5416 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5419 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5420 System.out.println( "2 fail" );
5423 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5426 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5429 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5432 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5437 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5438 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5440 t9.getNode( "gh" ).setCollapse( true );
5441 n = t9.getNode( "a" );
5442 while ( n != null ) {
5444 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5446 if ( ext.size() != 7 ) {
5449 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5452 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5455 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5458 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5461 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5464 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5467 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5472 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5473 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5475 t10.getNode( "gh" ).setCollapse( true );
5476 t10.getNode( "g" ).setCollapse( true );
5477 t10.getNode( "h" ).setCollapse( true );
5478 n = t10.getNode( "a" );
5479 while ( n != null ) {
5481 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5483 if ( ext.size() != 7 ) {
5486 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5489 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5492 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5495 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5498 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5501 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5504 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5509 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5510 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5512 t11.getNode( "gh" ).setCollapse( true );
5513 t11.getNode( "fgh" ).setCollapse( true );
5514 n = t11.getNode( "a" );
5515 while ( n != null ) {
5517 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5519 if ( ext.size() != 6 ) {
5522 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5525 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5528 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5531 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5534 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5537 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5542 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5543 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5545 t12.getNode( "gh" ).setCollapse( true );
5546 t12.getNode( "fgh" ).setCollapse( true );
5547 t12.getNode( "g" ).setCollapse( true );
5548 t12.getNode( "h" ).setCollapse( true );
5549 t12.getNode( "f" ).setCollapse( true );
5550 n = t12.getNode( "a" );
5551 while ( n != null ) {
5553 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5555 if ( ext.size() != 6 ) {
5558 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5561 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5564 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5567 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5570 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5573 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5578 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5579 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5581 t13.getNode( "ab" ).setCollapse( true );
5582 t13.getNode( "b" ).setCollapse( true );
5583 t13.getNode( "fgh" ).setCollapse( true );
5584 t13.getNode( "gh" ).setCollapse( true );
5585 n = t13.getNode( "ab" );
5586 while ( n != null ) {
5588 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5590 if ( ext.size() != 5 ) {
5593 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5596 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5599 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5602 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5605 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5610 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5611 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5613 t14.getNode( "ab" ).setCollapse( true );
5614 t14.getNode( "a" ).setCollapse( true );
5615 t14.getNode( "fgh" ).setCollapse( true );
5616 t14.getNode( "gh" ).setCollapse( true );
5617 n = t14.getNode( "ab" );
5618 while ( n != null ) {
5620 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5622 if ( ext.size() != 5 ) {
5625 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5628 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5631 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5634 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5637 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5642 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" );
5643 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5645 t15.getNode( "ab" ).setCollapse( true );
5646 t15.getNode( "a" ).setCollapse( true );
5647 t15.getNode( "fgh" ).setCollapse( true );
5648 t15.getNode( "gh" ).setCollapse( true );
5649 n = t15.getNode( "ab" );
5650 while ( n != null ) {
5652 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5654 if ( ext.size() != 6 ) {
5657 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5660 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5663 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5666 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5669 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5672 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5677 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" );
5678 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5680 t16.getNode( "ab" ).setCollapse( true );
5681 t16.getNode( "a" ).setCollapse( true );
5682 t16.getNode( "fgh" ).setCollapse( true );
5683 t16.getNode( "gh" ).setCollapse( true );
5684 t16.getNode( "cd" ).setCollapse( true );
5685 t16.getNode( "cde" ).setCollapse( true );
5686 t16.getNode( "d" ).setCollapse( true );
5687 t16.getNode( "x" ).setCollapse( true );
5688 n = t16.getNode( "ab" );
5689 while ( n != null ) {
5691 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5693 if ( ext.size() != 4 ) {
5696 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5699 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5702 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5705 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5709 catch ( final Exception e ) {
5710 e.printStackTrace( System.out );
5716 private static boolean testNexusCharactersParsing() {
5718 final NexusCharactersParser parser = new NexusCharactersParser();
5719 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5721 String[] labels = parser.getCharStateLabels();
5722 if ( labels.length != 7 ) {
5725 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5728 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5731 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5734 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5737 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5740 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5743 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5746 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5748 labels = parser.getCharStateLabels();
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" ) ) {
5774 catch ( final Exception e ) {
5775 e.printStackTrace( System.out );
5781 private static boolean testNexusMatrixParsing() {
5783 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5784 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5786 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5787 if ( m.getNumberOfCharacters() != 9 ) {
5790 if ( m.getNumberOfIdentifiers() != 5 ) {
5793 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5796 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5799 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5802 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5805 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5808 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5811 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5814 // if ( labels.length != 7 ) {
5817 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5820 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5823 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5826 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5829 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5832 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5835 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5838 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5840 // labels = parser.getCharStateLabels();
5841 // if ( labels.length != 7 ) {
5844 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5847 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5850 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5853 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5856 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5859 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5862 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5866 catch ( final Exception e ) {
5867 e.printStackTrace( System.out );
5873 private static boolean testNexusTreeParsing() {
5875 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5876 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5877 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5878 if ( phylogenies.length != 1 ) {
5881 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5884 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5888 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5889 if ( phylogenies.length != 1 ) {
5892 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5895 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5899 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5900 if ( phylogenies.length != 1 ) {
5903 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5906 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5909 if ( phylogenies[ 0 ].isRooted() ) {
5913 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5914 if ( phylogenies.length != 18 ) {
5917 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5920 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5923 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5926 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5929 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5932 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5935 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5938 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5941 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5944 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5947 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5950 if ( phylogenies[ 8 ].isRooted() ) {
5953 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5956 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5959 if ( !phylogenies[ 9 ].isRooted() ) {
5962 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5965 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5968 if ( !phylogenies[ 10 ].isRooted() ) {
5971 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5974 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5977 if ( phylogenies[ 11 ].isRooted() ) {
5980 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
5983 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
5986 if ( !phylogenies[ 12 ].isRooted() ) {
5989 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
5992 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
5995 if ( !phylogenies[ 13 ].isRooted() ) {
5998 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6001 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6004 if ( !phylogenies[ 14 ].isRooted() ) {
6007 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6010 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6013 if ( phylogenies[ 15 ].isRooted() ) {
6016 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6019 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6022 if ( !phylogenies[ 16 ].isRooted() ) {
6025 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6028 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6031 if ( phylogenies[ 17 ].isRooted() ) {
6034 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6038 catch ( final Exception e ) {
6039 e.printStackTrace( System.out );
6045 private static boolean testNexusTreeParsingIterating() {
6047 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6048 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6049 if ( !p.hasNext() ) {
6052 Phylogeny phy = p.next();
6053 if ( phy == null ) {
6056 if ( phy.getNumberOfExternalNodes() != 25 ) {
6059 if ( !phy.getName().equals( "" ) ) {
6062 if ( p.hasNext() ) {
6066 if ( phy != null ) {
6071 if ( !p.hasNext() ) {
6075 if ( phy == null ) {
6078 if ( phy.getNumberOfExternalNodes() != 25 ) {
6081 if ( !phy.getName().equals( "" ) ) {
6084 if ( p.hasNext() ) {
6088 if ( phy != null ) {
6092 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6093 if ( !p.hasNext() ) {
6097 if ( phy == null ) {
6100 if ( phy.getNumberOfExternalNodes() != 10 ) {
6103 if ( !phy.getName().equals( "name" ) ) {
6106 if ( p.hasNext() ) {
6110 if ( phy != null ) {
6115 if ( !p.hasNext() ) {
6119 if ( phy == null ) {
6122 if ( phy.getNumberOfExternalNodes() != 10 ) {
6125 if ( !phy.getName().equals( "name" ) ) {
6128 if ( p.hasNext() ) {
6132 if ( phy != null ) {
6136 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6137 if ( !p.hasNext() ) {
6141 if ( phy == null ) {
6144 if ( phy.getNumberOfExternalNodes() != 3 ) {
6147 if ( !phy.getName().equals( "" ) ) {
6150 if ( phy.isRooted() ) {
6153 if ( p.hasNext() ) {
6157 if ( phy != null ) {
6162 if ( !p.hasNext() ) {
6166 if ( phy == null ) {
6169 if ( phy.getNumberOfExternalNodes() != 3 ) {
6172 if ( !phy.getName().equals( "" ) ) {
6175 if ( p.hasNext() ) {
6179 if ( phy != null ) {
6183 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6184 // if ( phylogenies.length != 18 ) {
6188 if ( !p.hasNext() ) {
6192 if ( phy == null ) {
6195 if ( phy.getNumberOfExternalNodes() != 10 ) {
6198 if ( !phy.getName().equals( "tree 0" ) ) {
6202 if ( !p.hasNext() ) {
6206 if ( phy == null ) {
6209 if ( phy.getNumberOfExternalNodes() != 10 ) {
6212 if ( !phy.getName().equals( "tree 1" ) ) {
6216 if ( !p.hasNext() ) {
6220 if ( phy == null ) {
6223 if ( phy.getNumberOfExternalNodes() != 3 ) {
6226 if ( !phy.getName().equals( "" ) ) {
6229 if ( phy.isRooted() ) {
6233 if ( !p.hasNext() ) {
6237 if ( phy == null ) {
6240 if ( phy.getNumberOfExternalNodes() != 4 ) {
6243 if ( !phy.getName().equals( "" ) ) {
6246 if ( !phy.isRooted() ) {
6250 if ( !p.hasNext() ) {
6254 if ( phy == null ) {
6257 if ( phy.getNumberOfExternalNodes() != 5 ) {
6258 System.out.println( phy.getNumberOfExternalNodes() );
6261 if ( !phy.getName().equals( "" ) ) {
6264 if ( !phy.isRooted() ) {
6268 if ( !p.hasNext() ) {
6272 if ( phy == null ) {
6275 if ( phy.getNumberOfExternalNodes() != 3 ) {
6278 if ( !phy.getName().equals( "" ) ) {
6281 if ( phy.isRooted() ) {
6285 if ( !p.hasNext() ) {
6289 if ( phy == null ) {
6292 if ( phy.getNumberOfExternalNodes() != 2 ) {
6295 if ( !phy.getName().equals( "" ) ) {
6298 if ( !phy.isRooted() ) {
6302 if ( !p.hasNext() ) {
6306 if ( phy.getNumberOfExternalNodes() != 3 ) {
6309 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6312 if ( !phy.isRooted() ) {
6316 if ( !p.hasNext() ) {
6320 if ( phy.getNumberOfExternalNodes() != 3 ) {
6323 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6326 if ( !phy.getName().equals( "tree 8" ) ) {
6330 if ( !p.hasNext() ) {
6334 if ( phy.getNumberOfExternalNodes() != 3 ) {
6337 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6340 if ( !phy.getName().equals( "tree 9" ) ) {
6344 if ( !p.hasNext() ) {
6348 if ( phy.getNumberOfExternalNodes() != 3 ) {
6351 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6354 if ( !phy.getName().equals( "tree 10" ) ) {
6357 if ( !phy.isRooted() ) {
6361 if ( !p.hasNext() ) {
6365 if ( phy.getNumberOfExternalNodes() != 3 ) {
6368 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6371 if ( !phy.getName().equals( "tree 11" ) ) {
6374 if ( phy.isRooted() ) {
6378 if ( !p.hasNext() ) {
6382 if ( phy.getNumberOfExternalNodes() != 3 ) {
6385 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6388 if ( !phy.getName().equals( "tree 12" ) ) {
6391 if ( !phy.isRooted() ) {
6395 if ( !p.hasNext() ) {
6399 if ( phy.getNumberOfExternalNodes() != 3 ) {
6402 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6405 if ( !phy.getName().equals( "tree 13" ) ) {
6408 if ( !phy.isRooted() ) {
6412 if ( !p.hasNext() ) {
6416 if ( phy.getNumberOfExternalNodes() != 10 ) {
6417 System.out.println( phy.getNumberOfExternalNodes() );
6422 .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;" ) ) {
6423 System.out.println( phy.toNewHampshire() );
6426 if ( !phy.getName().equals( "tree 14" ) ) {
6429 if ( !phy.isRooted() ) {
6433 if ( !p.hasNext() ) {
6437 if ( phy.getNumberOfExternalNodes() != 10 ) {
6438 System.out.println( phy.getNumberOfExternalNodes() );
6443 .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;" ) ) {
6444 System.out.println( phy.toNewHampshire() );
6447 if ( !phy.getName().equals( "tree 15" ) ) {
6450 if ( phy.isRooted() ) {
6454 if ( !p.hasNext() ) {
6458 if ( phy.getNumberOfExternalNodes() != 10 ) {
6459 System.out.println( phy.getNumberOfExternalNodes() );
6464 .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;" ) ) {
6465 System.out.println( phy.toNewHampshire() );
6468 if ( !phy.getName().equals( "tree 16" ) ) {
6471 if ( !phy.isRooted() ) {
6475 if ( !p.hasNext() ) {
6479 if ( phy.getNumberOfExternalNodes() != 10 ) {
6480 System.out.println( phy.getNumberOfExternalNodes() );
6485 .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;" ) ) {
6486 System.out.println( phy.toNewHampshire() );
6489 if ( !phy.getName().equals( "tree 17" ) ) {
6492 if ( phy.isRooted() ) {
6496 if ( p.hasNext() ) {
6500 if ( phy != null ) {
6505 if ( !p.hasNext() ) {
6509 if ( phy == null ) {
6512 if ( phy.getNumberOfExternalNodes() != 10 ) {
6515 if ( !phy.getName().equals( "tree 0" ) ) {
6519 if ( !p.hasNext() ) {
6523 if ( phy == null ) {
6526 if ( phy.getNumberOfExternalNodes() != 10 ) {
6529 if ( !phy.getName().equals( "tree 1" ) ) {
6533 if ( !p.hasNext() ) {
6537 if ( phy == null ) {
6540 if ( phy.getNumberOfExternalNodes() != 3 ) {
6543 if ( !phy.getName().equals( "" ) ) {
6546 if ( phy.isRooted() ) {
6550 if ( !p.hasNext() ) {
6554 if ( phy == null ) {
6557 if ( phy.getNumberOfExternalNodes() != 4 ) {
6560 if ( !phy.getName().equals( "" ) ) {
6563 if ( !phy.isRooted() ) {
6567 if ( !p.hasNext() ) {
6571 if ( phy == null ) {
6574 if ( phy.getNumberOfExternalNodes() != 5 ) {
6575 System.out.println( phy.getNumberOfExternalNodes() );
6578 if ( !phy.getName().equals( "" ) ) {
6581 if ( !phy.isRooted() ) {
6585 if ( !p.hasNext() ) {
6589 if ( phy == null ) {
6592 if ( phy.getNumberOfExternalNodes() != 3 ) {
6595 if ( !phy.getName().equals( "" ) ) {
6598 if ( phy.isRooted() ) {
6602 catch ( final Exception e ) {
6603 e.printStackTrace( System.out );
6609 private static boolean testNexusTreeParsingTranslating() {
6611 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6612 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6613 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6614 if ( phylogenies.length != 1 ) {
6617 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6620 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6623 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6626 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6629 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6630 .equals( "Aranaeus" ) ) {
6634 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6635 if ( phylogenies.length != 3 ) {
6638 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6641 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6644 if ( phylogenies[ 0 ].isRooted() ) {
6647 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6650 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6653 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6654 .equals( "Aranaeus" ) ) {
6657 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6660 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6663 if ( phylogenies[ 1 ].isRooted() ) {
6666 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6669 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6672 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6673 .equals( "Aranaeus" ) ) {
6676 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6679 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6682 if ( !phylogenies[ 2 ].isRooted() ) {
6685 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6688 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6691 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6692 .equals( "Aranaeus" ) ) {
6696 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6697 if ( phylogenies.length != 3 ) {
6700 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6703 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6706 if ( phylogenies[ 0 ].isRooted() ) {
6709 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6712 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6715 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6716 .equals( "Aranaeus" ) ) {
6719 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6722 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6725 if ( phylogenies[ 1 ].isRooted() ) {
6728 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6731 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6734 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6735 .equals( "Aranaeus" ) ) {
6738 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6741 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6744 if ( !phylogenies[ 2 ].isRooted() ) {
6747 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6750 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6753 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6754 .equals( "Aranaeus" ) ) {
6758 catch ( final Exception e ) {
6759 e.printStackTrace( System.out );
6765 private static boolean testNHParsing() {
6767 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6768 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6769 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6772 final NHXParser nhxp = new NHXParser();
6773 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6774 nhxp.setReplaceUnderscores( true );
6775 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6776 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6779 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6782 final Phylogeny p1b = factory
6783 .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 ",
6784 new NHXParser() )[ 0 ];
6785 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6788 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6791 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6792 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6793 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6794 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6795 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6796 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6797 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6798 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6799 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6800 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6801 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6802 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6803 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6805 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6808 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6811 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6814 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6817 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6818 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6819 final String p16_S = "((A,B),C)";
6820 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6821 if ( p16.length != 1 ) {
6824 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6827 final String p17_S = "(C,(A,B))";
6828 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6829 if ( p17.length != 1 ) {
6832 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6835 final String p18_S = "((A,B),(C,D))";
6836 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6837 if ( p18.length != 1 ) {
6840 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6843 final String p19_S = "(((A,B),C),D)";
6844 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6845 if ( p19.length != 1 ) {
6848 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6851 final String p20_S = "(A,(B,(C,D)))";
6852 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6853 if ( p20.length != 1 ) {
6856 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6859 final String p21_S = "(A,(B,(C,(D,E))))";
6860 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6861 if ( p21.length != 1 ) {
6864 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6867 final String p22_S = "((((A,B),C),D),E)";
6868 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6869 if ( p22.length != 1 ) {
6872 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6875 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6876 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6877 if ( p23.length != 1 ) {
6878 System.out.println( "xl=" + p23.length );
6882 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6885 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6886 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6887 if ( p24.length != 1 ) {
6890 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6893 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6894 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6895 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6896 if ( p241.length != 2 ) {
6899 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6902 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6905 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6906 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6907 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6908 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6909 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6910 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6911 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6912 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6913 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6914 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6917 final String p26_S = "(A,B)ab";
6918 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6919 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6922 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6923 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6924 if ( p27s.length != 1 ) {
6925 System.out.println( "xxl=" + p27s.length );
6929 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6930 System.out.println( p27s[ 0 ].toNewHampshireX() );
6934 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6936 if ( p27.length != 1 ) {
6937 System.out.println( "yl=" + p27.length );
6941 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6942 System.out.println( p27[ 0 ].toNewHampshireX() );
6946 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6947 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6948 final String p28_S3 = "(A,B)ab";
6949 final String p28_S4 = "((((A,B),C),D),;E;)";
6950 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6952 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6955 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6958 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6961 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6964 if ( p28.length != 4 ) {
6967 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";
6968 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6969 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6972 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";
6973 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6974 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6977 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6978 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6979 if ( ( p32.length != 0 ) ) {
6982 final String p33_S = "A";
6983 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
6984 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
6987 final String p34_S = "B;";
6988 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
6989 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
6992 final String p35_S = "B:0.2";
6993 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
6994 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
6997 final String p36_S = "(A)";
6998 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
6999 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7002 final String p37_S = "((A))";
7003 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7004 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7007 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7008 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7009 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7012 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7013 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7014 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7017 final String p40_S = "(A,B,C)";
7018 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7019 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7022 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7023 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7024 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7027 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7028 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7029 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7032 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)";
7033 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7034 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7037 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)))";
7038 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7039 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7042 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7043 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7044 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7047 final String p46_S = "";
7048 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7049 if ( p46.length != 0 ) {
7052 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7053 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7056 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7057 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7060 final Phylogeny p49 = factory
7061 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7062 new NHXParser() )[ 0 ];
7063 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7066 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7067 if ( p50.getNode( "A" ) == null ) {
7070 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7071 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7074 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7077 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7078 .equals( "((A,B)88:2.0,C);" ) ) {
7081 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7082 if ( p51.getNode( "A(A" ) == null ) {
7085 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7086 if ( p52.getNode( "A(A" ) == null ) {
7089 final Phylogeny p53 = factory
7090 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7091 new NHXParser() )[ 0 ];
7092 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7096 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7097 if ( p54.getNode( "A" ) == null ) {
7100 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7101 .equals( "((A,B)[88],C);" ) ) {
7105 catch ( final Exception e ) {
7106 e.printStackTrace( System.out );
7112 private static boolean testNHParsingIter() {
7114 final String p0_str = "(A,B);";
7115 final NHXParser p = new NHXParser();
7116 p.setSource( p0_str );
7117 if ( !p.hasNext() ) {
7120 final Phylogeny p0 = p.next();
7121 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7122 System.out.println( p0.toNewHampshire() );
7125 if ( p.hasNext() ) {
7128 if ( p.next() != null ) {
7132 final String p00_str = "(A,B)root;";
7133 p.setSource( p00_str );
7134 final Phylogeny p00 = p.next();
7135 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7136 System.out.println( p00.toNewHampshire() );
7140 final String p000_str = "A;";
7141 p.setSource( p000_str );
7142 final Phylogeny p000 = p.next();
7143 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7144 System.out.println( p000.toNewHampshire() );
7148 final String p0000_str = "A";
7149 p.setSource( p0000_str );
7150 final Phylogeny p0000 = p.next();
7151 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7152 System.out.println( p0000.toNewHampshire() );
7156 p.setSource( "(A)" );
7157 final Phylogeny p00000 = p.next();
7158 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7159 System.out.println( p00000.toNewHampshire() );
7163 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7164 p.setSource( p1_str );
7165 if ( !p.hasNext() ) {
7168 final Phylogeny p1_0 = p.next();
7169 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7170 System.out.println( p1_0.toNewHampshire() );
7173 if ( !p.hasNext() ) {
7176 final Phylogeny p1_1 = p.next();
7177 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7178 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7181 if ( !p.hasNext() ) {
7184 final Phylogeny p1_2 = p.next();
7185 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7186 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7189 if ( !p.hasNext() ) {
7192 final Phylogeny p1_3 = p.next();
7193 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7194 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7197 if ( p.hasNext() ) {
7200 if ( p.next() != null ) {
7204 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7205 p.setSource( p2_str );
7206 if ( !p.hasNext() ) {
7209 Phylogeny p2_0 = p.next();
7210 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7211 System.out.println( p2_0.toNewHampshire() );
7214 if ( !p.hasNext() ) {
7217 Phylogeny p2_1 = p.next();
7218 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7219 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7222 if ( !p.hasNext() ) {
7225 Phylogeny p2_2 = p.next();
7226 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7227 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7230 if ( !p.hasNext() ) {
7233 Phylogeny p2_3 = p.next();
7234 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7235 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7238 if ( !p.hasNext() ) {
7241 Phylogeny p2_4 = p.next();
7242 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7243 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7246 if ( p.hasNext() ) {
7249 if ( p.next() != null ) {
7254 if ( !p.hasNext() ) {
7258 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7259 System.out.println( p2_0.toNewHampshire() );
7262 if ( !p.hasNext() ) {
7266 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7267 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7270 if ( !p.hasNext() ) {
7274 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7275 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7278 if ( !p.hasNext() ) {
7282 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7283 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7286 if ( !p.hasNext() ) {
7290 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7291 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7294 if ( p.hasNext() ) {
7297 if ( p.next() != null ) {
7301 final String p3_str = "((A,B),C)abc";
7302 p.setSource( p3_str );
7303 if ( !p.hasNext() ) {
7306 final Phylogeny p3_0 = p.next();
7307 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7310 if ( p.hasNext() ) {
7313 if ( p.next() != null ) {
7317 final String p4_str = "((A,B)ab,C)abc";
7318 p.setSource( p4_str );
7319 if ( !p.hasNext() ) {
7322 final Phylogeny p4_0 = p.next();
7323 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7326 if ( p.hasNext() ) {
7329 if ( p.next() != null ) {
7333 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7334 p.setSource( p5_str );
7335 if ( !p.hasNext() ) {
7338 final Phylogeny p5_0 = p.next();
7339 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7342 if ( p.hasNext() ) {
7345 if ( p.next() != null ) {
7349 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7350 p.setSource( p6_str );
7351 if ( !p.hasNext() ) {
7354 Phylogeny p6_0 = p.next();
7355 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7358 if ( p.hasNext() ) {
7361 if ( p.next() != null ) {
7365 if ( !p.hasNext() ) {
7369 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7372 if ( p.hasNext() ) {
7375 if ( p.next() != null ) {
7379 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7380 p.setSource( p7_str );
7381 if ( !p.hasNext() ) {
7384 Phylogeny p7_0 = p.next();
7385 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7388 if ( p.hasNext() ) {
7391 if ( p.next() != null ) {
7395 if ( !p.hasNext() ) {
7399 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7402 if ( p.hasNext() ) {
7405 if ( p.next() != null ) {
7409 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7410 p.setSource( p8_str );
7411 if ( !p.hasNext() ) {
7414 Phylogeny p8_0 = p.next();
7415 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7418 if ( !p.hasNext() ) {
7421 if ( !p.hasNext() ) {
7424 Phylogeny p8_1 = p.next();
7425 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7428 if ( p.hasNext() ) {
7431 if ( p.next() != null ) {
7435 if ( !p.hasNext() ) {
7439 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7442 if ( !p.hasNext() ) {
7446 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7449 if ( p.hasNext() ) {
7452 if ( p.next() != null ) {
7458 if ( p.hasNext() ) {
7462 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7463 if ( !p.hasNext() ) {
7466 Phylogeny p_27 = p.next();
7467 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7468 System.out.println( p_27.toNewHampshireX() );
7472 if ( p.hasNext() ) {
7475 if ( p.next() != null ) {
7479 if ( !p.hasNext() ) {
7483 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7484 System.out.println( p_27.toNewHampshireX() );
7488 if ( p.hasNext() ) {
7491 if ( p.next() != null ) {
7495 catch ( final Exception e ) {
7496 e.printStackTrace( System.out );
7502 private static boolean testNHXconversion() {
7504 final PhylogenyNode n1 = new PhylogenyNode();
7505 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7506 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7507 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7508 final PhylogenyNode n5 = PhylogenyNode
7509 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7510 final PhylogenyNode n6 = PhylogenyNode
7511 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7512 if ( !n1.toNewHampshireX().equals( "" ) ) {
7515 if ( !n2.toNewHampshireX().equals( "" ) ) {
7518 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7521 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7524 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7527 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7528 System.out.println( n6.toNewHampshireX() );
7532 catch ( final Exception e ) {
7533 e.printStackTrace( System.out );
7539 private static boolean testNHXNodeParsing() {
7541 final PhylogenyNode n1 = new PhylogenyNode();
7542 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7543 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7544 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7545 final PhylogenyNode n5 = PhylogenyNode
7546 .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]" );
7547 if ( !n3.getName().equals( "n3" ) ) {
7550 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7553 if ( n3.isDuplication() ) {
7556 if ( n3.isHasAssignedEvent() ) {
7559 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7562 if ( !n4.getName().equals( "n4" ) ) {
7565 if ( n4.getDistanceToParent() != 0.01 ) {
7568 if ( !n5.getName().equals( "n5" ) ) {
7571 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7574 if ( n5.getDistanceToParent() != 0.1 ) {
7577 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7580 if ( !n5.isDuplication() ) {
7583 if ( !n5.isHasAssignedEvent() ) {
7586 final PhylogenyNode n8 = PhylogenyNode
7587 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7588 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7589 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7592 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7595 final PhylogenyNode n9 = PhylogenyNode
7596 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7597 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7598 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7601 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7604 final PhylogenyNode n10 = PhylogenyNode
7605 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7606 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7609 final PhylogenyNode n20 = PhylogenyNode
7610 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7611 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7614 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7617 final PhylogenyNode n20x = PhylogenyNode
7618 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7619 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7622 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7625 final PhylogenyNode n20xx = PhylogenyNode
7626 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7627 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7630 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7633 final PhylogenyNode n20xxx = PhylogenyNode
7634 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7635 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7638 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7641 final PhylogenyNode n20xxxx = PhylogenyNode
7642 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7643 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7646 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7649 final PhylogenyNode n21 = PhylogenyNode
7650 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7651 if ( !n21.getName().equals( "N21_PIG" ) ) {
7654 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7657 final PhylogenyNode n21x = PhylogenyNode
7658 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7659 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7662 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7665 final PhylogenyNode n22 = PhylogenyNode
7666 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7667 if ( !n22.getName().equals( "n22/PIG" ) ) {
7670 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7673 final PhylogenyNode n23 = PhylogenyNode
7674 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7675 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7678 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7681 final PhylogenyNode a = PhylogenyNode
7682 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7683 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7686 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7689 final PhylogenyNode c1 = PhylogenyNode
7690 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7691 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7692 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7695 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7698 final PhylogenyNode c2 = PhylogenyNode
7699 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7700 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7701 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7704 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7707 final PhylogenyNode e3 = PhylogenyNode
7708 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7709 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7712 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7715 final PhylogenyNode n11 = PhylogenyNode
7716 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7717 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7718 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7721 if ( n11.getDistanceToParent() != 0.4 ) {
7724 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7727 final PhylogenyNode n12 = PhylogenyNode
7728 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7729 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7730 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7733 if ( n12.getDistanceToParent() != 0.4 ) {
7736 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7739 final PhylogenyNode o = PhylogenyNode
7740 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7741 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7744 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7747 if ( n1.getName().compareTo( "" ) != 0 ) {
7750 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7753 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7756 if ( n2.getName().compareTo( "" ) != 0 ) {
7759 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7762 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7765 final PhylogenyNode n00 = PhylogenyNode
7766 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7767 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7770 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7773 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7774 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7777 final PhylogenyNode n13 = PhylogenyNode
7778 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7779 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7782 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7785 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7788 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7791 final PhylogenyNode n14 = PhylogenyNode
7792 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7793 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7796 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7799 final PhylogenyNode n15 = PhylogenyNode
7800 .createInstanceFromNhxString( "something_wicked[123]",
7801 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7802 if ( !n15.getName().equals( "something_wicked" ) ) {
7805 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7808 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7811 final PhylogenyNode n16 = PhylogenyNode
7812 .createInstanceFromNhxString( "something_wicked2[9]",
7813 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7814 if ( !n16.getName().equals( "something_wicked2" ) ) {
7817 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7820 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7823 final PhylogenyNode n17 = PhylogenyNode
7824 .createInstanceFromNhxString( "something_wicked3[a]",
7825 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7826 if ( !n17.getName().equals( "something_wicked3" ) ) {
7829 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7832 final PhylogenyNode n18 = PhylogenyNode
7833 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7834 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7837 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7840 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7843 final PhylogenyNode n19 = PhylogenyNode
7844 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7845 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7848 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7851 final PhylogenyNode n30 = PhylogenyNode
7852 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7853 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7854 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7857 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7860 final PhylogenyNode n31 = PhylogenyNode
7861 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7862 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7863 if ( n31.getNodeData().isHasTaxonomy() ) {
7866 final PhylogenyNode n32 = PhylogenyNode
7867 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7868 if ( n32.getNodeData().isHasTaxonomy() ) {
7871 final PhylogenyNode n40 = PhylogenyNode
7872 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7873 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7876 final PhylogenyNode n41 = PhylogenyNode
7877 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7878 if ( n41.getNodeData().isHasTaxonomy() ) {
7881 final PhylogenyNode n42 = PhylogenyNode
7882 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7883 if ( n42.getNodeData().isHasTaxonomy() ) {
7886 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7887 NHXParser.TAXONOMY_EXTRACTION.NO );
7888 if ( n43.getNodeData().isHasTaxonomy() ) {
7891 final PhylogenyNode n44 = PhylogenyNode
7892 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7893 if ( n44.getNodeData().isHasTaxonomy() ) {
7897 catch ( final Exception e ) {
7898 e.printStackTrace( System.out );
7904 private static boolean testNHXParsing() {
7906 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7907 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7908 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7911 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]";
7912 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7913 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7916 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]";
7917 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7918 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7921 final Phylogeny[] p3 = factory
7922 .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]",
7924 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7927 final Phylogeny[] p4 = factory
7928 .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(]",
7930 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7933 final Phylogeny[] p5 = factory
7934 .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(((]",
7936 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7939 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)";
7940 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)";
7941 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7942 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7945 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)))";
7946 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)))";
7947 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7948 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7951 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]) ))[,,, ])))))))";
7952 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7953 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7954 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7957 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7958 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7961 final Phylogeny p10 = factory
7962 .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]",
7963 new NHXParser() )[ 0 ];
7964 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7968 catch ( final Exception e ) {
7969 e.printStackTrace( System.out );
7975 private static boolean testNHXParsingMB() {
7977 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7978 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7979 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7980 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7981 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7982 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7983 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7984 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7985 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7986 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7987 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7990 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7993 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
7994 0.1100000000000000e+00 ) ) {
7997 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8000 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8003 final Phylogeny p2 = factory
8004 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8005 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8006 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8007 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8008 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8009 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8010 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8011 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8012 + "7.369400000000000e-02}])",
8013 new NHXParser() )[ 0 ];
8014 if ( p2.getNode( "1" ) == null ) {
8017 if ( p2.getNode( "2" ) == null ) {
8021 catch ( final Exception e ) {
8022 e.printStackTrace( System.out );
8029 private static boolean testNHXParsingQuotes() {
8031 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8032 final NHXParser p = new NHXParser();
8033 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8034 if ( phylogenies_0.length != 5 ) {
8037 final Phylogeny phy = phylogenies_0[ 4 ];
8038 if ( phy.getNumberOfExternalNodes() != 7 ) {
8041 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8044 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8047 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8048 .getScientificName().equals( "hsapiens" ) ) {
8051 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8054 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8057 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8060 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8063 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8066 final NHXParser p1p = new NHXParser();
8067 p1p.setIgnoreQuotes( true );
8068 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8069 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8072 final NHXParser p2p = new NHXParser();
8073 p1p.setIgnoreQuotes( false );
8074 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8075 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8078 final NHXParser p3p = new NHXParser();
8079 p3p.setIgnoreQuotes( false );
8080 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8081 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8084 final NHXParser p4p = new NHXParser();
8085 p4p.setIgnoreQuotes( false );
8086 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8087 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8090 final Phylogeny p10 = factory
8091 .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]",
8092 new NHXParser() )[ 0 ];
8093 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]";
8094 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8097 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8098 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8102 final Phylogeny p12 = factory
8103 .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]",
8104 new NHXParser() )[ 0 ];
8105 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]";
8106 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8109 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8110 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8113 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;";
8114 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8117 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8118 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8122 catch ( final Exception e ) {
8123 e.printStackTrace( System.out );
8129 private static boolean testNodeRemoval() {
8131 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8132 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8133 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8134 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8137 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8138 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8139 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8142 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8143 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8144 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8148 catch ( final Exception e ) {
8149 e.printStackTrace( System.out );
8155 private static boolean testPhylogenyBranch() {
8157 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8158 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8159 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8160 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8161 if ( !a1b1.equals( a1b1 ) ) {
8164 if ( !a1b1.equals( b1a1 ) ) {
8167 if ( !b1a1.equals( a1b1 ) ) {
8170 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8171 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8172 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8173 if ( a1_b1.equals( b1_a1 ) ) {
8176 if ( a1_b1.equals( a1_b1_ ) ) {
8179 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8180 if ( !a1_b1.equals( b1_a1_ ) ) {
8183 if ( a1_b1_.equals( b1_a1_ ) ) {
8186 if ( !a1_b1_.equals( b1_a1 ) ) {
8190 catch ( final Exception e ) {
8191 e.printStackTrace( System.out );
8197 private static boolean testPhyloXMLparsingOfDistributionElement() {
8199 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8200 PhyloXmlParser xml_parser = null;
8202 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8204 catch ( final Exception e ) {
8205 // Do nothing -- means were not running from jar.
8207 if ( xml_parser == null ) {
8208 xml_parser = new PhyloXmlParser();
8209 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8210 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8213 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8216 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8218 if ( xml_parser.getErrorCount() > 0 ) {
8219 System.out.println( xml_parser.getErrorMessages().toString() );
8222 if ( phylogenies_0.length != 1 ) {
8225 final Phylogeny t1 = phylogenies_0[ 0 ];
8226 PhylogenyNode n = null;
8227 Distribution d = null;
8228 n = t1.getNode( "root node" );
8229 if ( !n.getNodeData().isHasDistribution() ) {
8232 if ( n.getNodeData().getDistributions().size() != 1 ) {
8235 d = n.getNodeData().getDistribution();
8236 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8239 if ( d.getPoints().size() != 1 ) {
8242 if ( d.getPolygons() != null ) {
8245 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8248 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8251 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8254 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8257 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8260 n = t1.getNode( "node a" );
8261 if ( !n.getNodeData().isHasDistribution() ) {
8264 if ( n.getNodeData().getDistributions().size() != 2 ) {
8267 d = n.getNodeData().getDistribution( 1 );
8268 if ( !d.getDesc().equals( "San Diego" ) ) {
8271 if ( d.getPoints().size() != 1 ) {
8274 if ( d.getPolygons() != null ) {
8277 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8280 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8283 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8286 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8289 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8292 n = t1.getNode( "node bb" );
8293 if ( !n.getNodeData().isHasDistribution() ) {
8296 if ( n.getNodeData().getDistributions().size() != 1 ) {
8299 d = n.getNodeData().getDistribution( 0 );
8300 if ( d.getPoints().size() != 3 ) {
8303 if ( d.getPolygons().size() != 2 ) {
8306 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8309 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8312 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8315 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8318 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8321 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8324 Polygon p = d.getPolygons().get( 0 );
8325 if ( p.getPoints().size() != 3 ) {
8328 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8331 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8334 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8337 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8340 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8343 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8346 p = d.getPolygons().get( 1 );
8347 if ( p.getPoints().size() != 3 ) {
8350 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8353 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8356 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8360 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8361 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8362 if ( rt.length != 1 ) {
8365 final Phylogeny t1_rt = rt[ 0 ];
8366 n = t1_rt.getNode( "root node" );
8367 if ( !n.getNodeData().isHasDistribution() ) {
8370 if ( n.getNodeData().getDistributions().size() != 1 ) {
8373 d = n.getNodeData().getDistribution();
8374 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8377 if ( d.getPoints().size() != 1 ) {
8380 if ( d.getPolygons() != null ) {
8383 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8386 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8389 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8392 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8395 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8398 n = t1_rt.getNode( "node a" );
8399 if ( !n.getNodeData().isHasDistribution() ) {
8402 if ( n.getNodeData().getDistributions().size() != 2 ) {
8405 d = n.getNodeData().getDistribution( 1 );
8406 if ( !d.getDesc().equals( "San Diego" ) ) {
8409 if ( d.getPoints().size() != 1 ) {
8412 if ( d.getPolygons() != null ) {
8415 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8418 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8421 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8424 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8427 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8430 n = t1_rt.getNode( "node bb" );
8431 if ( !n.getNodeData().isHasDistribution() ) {
8434 if ( n.getNodeData().getDistributions().size() != 1 ) {
8437 d = n.getNodeData().getDistribution( 0 );
8438 if ( d.getPoints().size() != 3 ) {
8441 if ( d.getPolygons().size() != 2 ) {
8444 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8447 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8450 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8453 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8456 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8459 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8462 p = d.getPolygons().get( 0 );
8463 if ( p.getPoints().size() != 3 ) {
8466 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8469 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8472 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8475 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8478 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8481 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8484 p = d.getPolygons().get( 1 );
8485 if ( p.getPoints().size() != 3 ) {
8488 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8491 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8494 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8498 catch ( final Exception e ) {
8499 e.printStackTrace( System.out );
8505 private static boolean testPostOrderIterator() {
8507 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8508 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8509 PhylogenyNodeIterator it0;
8510 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8513 for( it0.reset(); it0.hasNext(); ) {
8516 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8517 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8518 if ( !it.next().getName().equals( "A" ) ) {
8521 if ( !it.next().getName().equals( "B" ) ) {
8524 if ( !it.next().getName().equals( "ab" ) ) {
8527 if ( !it.next().getName().equals( "C" ) ) {
8530 if ( !it.next().getName().equals( "D" ) ) {
8533 if ( !it.next().getName().equals( "cd" ) ) {
8536 if ( !it.next().getName().equals( "abcd" ) ) {
8539 if ( !it.next().getName().equals( "E" ) ) {
8542 if ( !it.next().getName().equals( "F" ) ) {
8545 if ( !it.next().getName().equals( "ef" ) ) {
8548 if ( !it.next().getName().equals( "G" ) ) {
8551 if ( !it.next().getName().equals( "H" ) ) {
8554 if ( !it.next().getName().equals( "gh" ) ) {
8557 if ( !it.next().getName().equals( "efgh" ) ) {
8560 if ( !it.next().getName().equals( "r" ) ) {
8563 if ( it.hasNext() ) {
8567 catch ( final Exception e ) {
8568 e.printStackTrace( System.out );
8574 private static boolean testPreOrderIterator() {
8576 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8577 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8578 PhylogenyNodeIterator it0;
8579 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8582 for( it0.reset(); it0.hasNext(); ) {
8585 PhylogenyNodeIterator it = t0.iteratorPreorder();
8586 if ( !it.next().getName().equals( "r" ) ) {
8589 if ( !it.next().getName().equals( "ab" ) ) {
8592 if ( !it.next().getName().equals( "A" ) ) {
8595 if ( !it.next().getName().equals( "B" ) ) {
8598 if ( !it.next().getName().equals( "cd" ) ) {
8601 if ( !it.next().getName().equals( "C" ) ) {
8604 if ( !it.next().getName().equals( "D" ) ) {
8607 if ( it.hasNext() ) {
8610 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8611 it = t1.iteratorPreorder();
8612 if ( !it.next().getName().equals( "r" ) ) {
8615 if ( !it.next().getName().equals( "abcd" ) ) {
8618 if ( !it.next().getName().equals( "ab" ) ) {
8621 if ( !it.next().getName().equals( "A" ) ) {
8624 if ( !it.next().getName().equals( "B" ) ) {
8627 if ( !it.next().getName().equals( "cd" ) ) {
8630 if ( !it.next().getName().equals( "C" ) ) {
8633 if ( !it.next().getName().equals( "D" ) ) {
8636 if ( !it.next().getName().equals( "efgh" ) ) {
8639 if ( !it.next().getName().equals( "ef" ) ) {
8642 if ( !it.next().getName().equals( "E" ) ) {
8645 if ( !it.next().getName().equals( "F" ) ) {
8648 if ( !it.next().getName().equals( "gh" ) ) {
8651 if ( !it.next().getName().equals( "G" ) ) {
8654 if ( !it.next().getName().equals( "H" ) ) {
8657 if ( it.hasNext() ) {
8661 catch ( final Exception e ) {
8662 e.printStackTrace( System.out );
8668 private static boolean testPropertiesMap() {
8670 final PropertiesMap pm = new PropertiesMap();
8671 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8672 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8673 final Property p2 = new Property( "something:else",
8675 "improbable:research",
8678 pm.addProperty( p0 );
8679 pm.addProperty( p1 );
8680 pm.addProperty( p2 );
8681 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8684 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8687 if ( pm.getProperties().size() != 3 ) {
8690 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8693 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8696 if ( pm.getProperties().size() != 3 ) {
8699 pm.removeProperty( "dimensions:diameter" );
8700 if ( pm.getProperties().size() != 2 ) {
8703 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8706 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8710 catch ( final Exception e ) {
8711 e.printStackTrace( System.out );
8717 private static boolean testProteinId() {
8719 final ProteinId id1 = new ProteinId( "a" );
8720 final ProteinId id2 = new ProteinId( "a" );
8721 final ProteinId id3 = new ProteinId( "A" );
8722 final ProteinId id4 = new ProteinId( "b" );
8723 if ( !id1.equals( id1 ) ) {
8726 if ( id1.getId().equals( "x" ) ) {
8729 if ( id1.getId().equals( null ) ) {
8732 if ( !id1.equals( id2 ) ) {
8735 if ( id1.equals( id3 ) ) {
8738 if ( id1.hashCode() != id1.hashCode() ) {
8741 if ( id1.hashCode() != id2.hashCode() ) {
8744 if ( id1.hashCode() == id3.hashCode() ) {
8747 if ( id1.compareTo( id1 ) != 0 ) {
8750 if ( id1.compareTo( id2 ) != 0 ) {
8753 if ( id1.compareTo( id3 ) != 0 ) {
8756 if ( id1.compareTo( id4 ) >= 0 ) {
8759 if ( id4.compareTo( id1 ) <= 0 ) {
8762 if ( !id4.getId().equals( "b" ) ) {
8765 final ProteinId id5 = new ProteinId( " C " );
8766 if ( !id5.getId().equals( "C" ) ) {
8769 if ( id5.equals( id1 ) ) {
8773 catch ( final Exception e ) {
8774 e.printStackTrace( System.out );
8780 private static boolean testReIdMethods() {
8782 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8783 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8784 final long count = PhylogenyNode.getNodeCount();
8786 if ( p.getNode( "r" ).getId() != count ) {
8789 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8792 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8795 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8798 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8801 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8804 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8807 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8810 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8813 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8816 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8819 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8822 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8825 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8828 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8832 catch ( final Exception e ) {
8833 e.printStackTrace( System.out );
8839 private static boolean testRerooting() {
8841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8842 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",
8843 new NHXParser() )[ 0 ];
8844 if ( !t1.isRooted() ) {
8847 t1.reRoot( t1.getNode( "D" ) );
8848 t1.reRoot( t1.getNode( "CD" ) );
8849 t1.reRoot( t1.getNode( "A" ) );
8850 t1.reRoot( t1.getNode( "B" ) );
8851 t1.reRoot( t1.getNode( "AB" ) );
8852 t1.reRoot( t1.getNode( "D" ) );
8853 t1.reRoot( t1.getNode( "C" ) );
8854 t1.reRoot( t1.getNode( "CD" ) );
8855 t1.reRoot( t1.getNode( "A" ) );
8856 t1.reRoot( t1.getNode( "B" ) );
8857 t1.reRoot( t1.getNode( "AB" ) );
8858 t1.reRoot( t1.getNode( "D" ) );
8859 t1.reRoot( t1.getNode( "D" ) );
8860 t1.reRoot( t1.getNode( "C" ) );
8861 t1.reRoot( t1.getNode( "A" ) );
8862 t1.reRoot( t1.getNode( "B" ) );
8863 t1.reRoot( t1.getNode( "AB" ) );
8864 t1.reRoot( t1.getNode( "C" ) );
8865 t1.reRoot( t1.getNode( "D" ) );
8866 t1.reRoot( t1.getNode( "CD" ) );
8867 t1.reRoot( t1.getNode( "D" ) );
8868 t1.reRoot( t1.getNode( "A" ) );
8869 t1.reRoot( t1.getNode( "B" ) );
8870 t1.reRoot( t1.getNode( "AB" ) );
8871 t1.reRoot( t1.getNode( "C" ) );
8872 t1.reRoot( t1.getNode( "D" ) );
8873 t1.reRoot( t1.getNode( "CD" ) );
8874 t1.reRoot( t1.getNode( "D" ) );
8875 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8878 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8881 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8884 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8887 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8890 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8893 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",
8894 new NHXParser() )[ 0 ];
8895 t2.reRoot( t2.getNode( "A" ) );
8896 t2.reRoot( t2.getNode( "D" ) );
8897 t2.reRoot( t2.getNode( "ABC" ) );
8898 t2.reRoot( t2.getNode( "A" ) );
8899 t2.reRoot( t2.getNode( "B" ) );
8900 t2.reRoot( t2.getNode( "D" ) );
8901 t2.reRoot( t2.getNode( "C" ) );
8902 t2.reRoot( t2.getNode( "ABC" ) );
8903 t2.reRoot( t2.getNode( "A" ) );
8904 t2.reRoot( t2.getNode( "B" ) );
8905 t2.reRoot( t2.getNode( "AB" ) );
8906 t2.reRoot( t2.getNode( "AB" ) );
8907 t2.reRoot( t2.getNode( "D" ) );
8908 t2.reRoot( t2.getNode( "C" ) );
8909 t2.reRoot( t2.getNode( "B" ) );
8910 t2.reRoot( t2.getNode( "AB" ) );
8911 t2.reRoot( t2.getNode( "D" ) );
8912 t2.reRoot( t2.getNode( "D" ) );
8913 t2.reRoot( t2.getNode( "ABC" ) );
8914 t2.reRoot( t2.getNode( "A" ) );
8915 t2.reRoot( t2.getNode( "B" ) );
8916 t2.reRoot( t2.getNode( "AB" ) );
8917 t2.reRoot( t2.getNode( "D" ) );
8918 t2.reRoot( t2.getNode( "C" ) );
8919 t2.reRoot( t2.getNode( "ABC" ) );
8920 t2.reRoot( t2.getNode( "A" ) );
8921 t2.reRoot( t2.getNode( "B" ) );
8922 t2.reRoot( t2.getNode( "AB" ) );
8923 t2.reRoot( t2.getNode( "D" ) );
8924 t2.reRoot( t2.getNode( "D" ) );
8925 t2.reRoot( t2.getNode( "C" ) );
8926 t2.reRoot( t2.getNode( "A" ) );
8927 t2.reRoot( t2.getNode( "B" ) );
8928 t2.reRoot( t2.getNode( "AB" ) );
8929 t2.reRoot( t2.getNode( "C" ) );
8930 t2.reRoot( t2.getNode( "D" ) );
8931 t2.reRoot( t2.getNode( "ABC" ) );
8932 t2.reRoot( t2.getNode( "D" ) );
8933 t2.reRoot( t2.getNode( "A" ) );
8934 t2.reRoot( t2.getNode( "B" ) );
8935 t2.reRoot( t2.getNode( "AB" ) );
8936 t2.reRoot( t2.getNode( "C" ) );
8937 t2.reRoot( t2.getNode( "D" ) );
8938 t2.reRoot( t2.getNode( "ABC" ) );
8939 t2.reRoot( t2.getNode( "D" ) );
8940 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8943 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8946 t2.reRoot( t2.getNode( "ABC" ) );
8947 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8950 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8953 t2.reRoot( t2.getNode( "AB" ) );
8954 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8957 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8960 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8963 t2.reRoot( t2.getNode( "AB" ) );
8964 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8967 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8970 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8973 t2.reRoot( t2.getNode( "D" ) );
8974 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8977 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8980 t2.reRoot( t2.getNode( "ABC" ) );
8981 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8984 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8987 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
8988 new NHXParser() )[ 0 ];
8989 t3.reRoot( t3.getNode( "B" ) );
8990 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8993 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8996 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8999 t3.reRoot( t3.getNode( "B" ) );
9000 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9003 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9006 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9009 t3.reRoot( t3.getRoot() );
9010 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9013 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9016 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9020 catch ( final Exception e ) {
9021 e.printStackTrace( System.out );
9027 private static boolean testSDIse() {
9029 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9030 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9031 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9032 gene1.setRooted( true );
9033 species1.setRooted( true );
9034 final SDI sdi = new SDI( gene1, species1 );
9035 if ( !gene1.getRoot().isDuplication() ) {
9038 final Phylogeny species2 = factory
9039 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9040 new NHXParser() )[ 0 ];
9041 final Phylogeny gene2 = factory
9042 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9043 new NHXParser() )[ 0 ];
9044 species2.setRooted( true );
9045 gene2.setRooted( true );
9046 final SDI sdi2 = new SDI( gene2, species2 );
9047 if ( sdi2.getDuplicationsSum() != 0 ) {
9050 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9053 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9056 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9059 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9062 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9065 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9068 final Phylogeny species3 = factory
9069 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9070 new NHXParser() )[ 0 ];
9071 final Phylogeny gene3 = factory
9072 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9073 new NHXParser() )[ 0 ];
9074 species3.setRooted( true );
9075 gene3.setRooted( true );
9076 final SDI sdi3 = new SDI( gene3, species3 );
9077 if ( sdi3.getDuplicationsSum() != 1 ) {
9080 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9083 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9086 final Phylogeny species4 = factory
9087 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9088 new NHXParser() )[ 0 ];
9089 final Phylogeny gene4 = factory
9090 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9091 new NHXParser() )[ 0 ];
9092 species4.setRooted( true );
9093 gene4.setRooted( true );
9094 final SDI sdi4 = new SDI( gene4, species4 );
9095 if ( sdi4.getDuplicationsSum() != 1 ) {
9098 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9101 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9104 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9107 if ( species4.getNumberOfExternalNodes() != 6 ) {
9110 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9113 final Phylogeny species5 = factory
9114 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9115 new NHXParser() )[ 0 ];
9116 final Phylogeny gene5 = factory
9117 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9118 new NHXParser() )[ 0 ];
9119 species5.setRooted( true );
9120 gene5.setRooted( true );
9121 final SDI sdi5 = new SDI( gene5, species5 );
9122 if ( sdi5.getDuplicationsSum() != 2 ) {
9125 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9128 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9131 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9134 if ( species5.getNumberOfExternalNodes() != 6 ) {
9137 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9140 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9141 // Conjecture for Comparing Molecular Phylogenies"
9142 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9143 final Phylogeny species6 = factory
9144 .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,"
9145 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9146 new NHXParser() )[ 0 ];
9147 final Phylogeny gene6 = factory
9148 .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,"
9149 + "((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,"
9150 + "(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;",
9151 new NHXParser() )[ 0 ];
9152 species6.setRooted( true );
9153 gene6.setRooted( true );
9154 final SDI sdi6 = new SDI( gene6, species6 );
9155 if ( sdi6.getDuplicationsSum() != 3 ) {
9158 if ( !gene6.getNode( "r" ).isDuplication() ) {
9161 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9164 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9167 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9170 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9173 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9176 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9179 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9182 sdi6.computeMappingCostL();
9183 if ( sdi6.computeMappingCostL() != 17 ) {
9186 if ( species6.getNumberOfExternalNodes() != 9 ) {
9189 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9192 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9193 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9194 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9195 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9196 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9197 species7.setRooted( true );
9198 final Phylogeny gene7_1 = Test
9199 .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])" );
9200 gene7_1.setRooted( true );
9201 final SDI sdi7 = new SDI( gene7_1, species7 );
9202 if ( sdi7.getDuplicationsSum() != 0 ) {
9205 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9208 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9211 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9214 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9217 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9220 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9223 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9226 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9229 final Phylogeny gene7_2 = Test
9230 .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])" );
9231 gene7_2.setRooted( true );
9232 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9233 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9236 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9239 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9242 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9245 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9248 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9251 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9254 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9257 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9260 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9264 catch ( final Exception e ) {
9270 private static boolean testSDIunrooted() {
9272 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9273 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9274 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9275 final Iterator<PhylogenyBranch> iter = l.iterator();
9276 PhylogenyBranch br = iter.next();
9277 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9280 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9284 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9287 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9291 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9294 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9298 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9301 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9305 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9308 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9312 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9315 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9319 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9322 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9326 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9329 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9333 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9336 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9340 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9343 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9347 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9350 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9354 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9357 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9361 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9364 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9368 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9371 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9375 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9378 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9381 if ( iter.hasNext() ) {
9384 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9385 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9386 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9388 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9391 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9395 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9398 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9402 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9405 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9408 if ( iter1.hasNext() ) {
9411 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9412 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9413 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9415 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9418 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9422 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9425 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9429 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9432 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9435 if ( iter2.hasNext() ) {
9438 final Phylogeny species0 = factory
9439 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9440 new NHXParser() )[ 0 ];
9441 final Phylogeny gene1 = factory
9442 .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])",
9443 new NHXParser() )[ 0 ];
9444 species0.setRooted( true );
9445 gene1.setRooted( true );
9446 final SDIR sdi_unrooted = new SDIR();
9447 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9448 if ( sdi_unrooted.getCount() != 1 ) {
9451 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9454 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9457 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9460 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9463 final Phylogeny gene2 = factory
9464 .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])",
9465 new NHXParser() )[ 0 ];
9466 gene2.setRooted( true );
9467 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9468 if ( sdi_unrooted.getCount() != 1 ) {
9471 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9474 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9477 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9480 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9483 final Phylogeny species6 = factory
9484 .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,"
9485 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9486 new NHXParser() )[ 0 ];
9487 final Phylogeny gene6 = factory
9488 .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],"
9489 + "(((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],"
9490 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9491 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9492 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9493 new NHXParser() )[ 0 ];
9494 species6.setRooted( true );
9495 gene6.setRooted( true );
9496 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9497 if ( sdi_unrooted.getCount() != 1 ) {
9500 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9503 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9506 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9509 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9512 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9515 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9518 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9521 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9524 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9527 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9530 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9533 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9537 final Phylogeny species7 = factory
9538 .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,"
9539 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9540 new NHXParser() )[ 0 ];
9541 final Phylogeny gene7 = factory
9542 .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],"
9543 + "(((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],"
9544 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9545 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9546 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9547 new NHXParser() )[ 0 ];
9548 species7.setRooted( true );
9549 gene7.setRooted( true );
9550 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9551 if ( sdi_unrooted.getCount() != 1 ) {
9554 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9557 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9560 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9563 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9566 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9569 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9572 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9575 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9578 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9581 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9584 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9587 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9591 final Phylogeny species8 = factory
9592 .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,"
9593 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9594 new NHXParser() )[ 0 ];
9595 final Phylogeny gene8 = factory
9596 .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],"
9597 + "(((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],"
9598 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9599 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9600 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9601 new NHXParser() )[ 0 ];
9602 species8.setRooted( true );
9603 gene8.setRooted( true );
9604 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9605 if ( sdi_unrooted.getCount() != 1 ) {
9608 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9611 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9614 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9617 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9620 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9623 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9626 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9629 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9632 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9635 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9638 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9641 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9646 catch ( final Exception e ) {
9647 e.printStackTrace( System.out );
9653 private static boolean testSequenceIdParsing() {
9655 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
9656 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9657 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9659 System.out.println( "value =" + id.getValue() );
9660 System.out.println( "provider=" + id.getSource() );
9665 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
9666 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9667 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9669 System.out.println( "value =" + id.getValue() );
9670 System.out.println( "provider=" + id.getSource() );
9675 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
9676 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9677 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9679 System.out.println( "value =" + id.getValue() );
9680 System.out.println( "provider=" + id.getSource() );
9685 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
9686 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9687 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
9689 System.out.println( "value =" + id.getValue() );
9690 System.out.println( "provider=" + id.getSource() );
9695 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
9696 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9697 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
9699 System.out.println( "value =" + id.getValue() );
9700 System.out.println( "provider=" + id.getSource() );
9705 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
9706 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9707 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
9709 System.out.println( "value =" + id.getValue() );
9710 System.out.println( "provider=" + id.getSource() );
9715 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
9716 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9717 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
9719 System.out.println( "value =" + id.getValue() );
9720 System.out.println( "provider=" + id.getSource() );
9725 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
9726 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9727 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9729 System.out.println( "value =" + id.getValue() );
9730 System.out.println( "provider=" + id.getSource() );
9735 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
9736 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9737 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9739 System.out.println( "value =" + id.getValue() );
9740 System.out.println( "provider=" + id.getSource() );
9745 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
9746 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9747 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
9749 System.out.println( "value =" + id.getValue() );
9750 System.out.println( "provider=" + id.getSource() );
9754 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
9756 System.out.println( "value =" + id.getValue() );
9757 System.out.println( "provider=" + id.getSource() );
9761 catch ( final Exception e ) {
9762 e.printStackTrace( System.out );
9768 private static boolean testSequenceWriter() {
9770 final String n = ForesterUtil.LINE_SEPARATOR;
9771 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9774 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9777 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9780 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9783 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9784 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9787 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9788 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9792 catch ( final Exception e ) {
9793 e.printStackTrace();
9799 private static boolean testSpecies() {
9801 final Species s1 = new BasicSpecies( "a" );
9802 final Species s2 = new BasicSpecies( "a" );
9803 final Species s3 = new BasicSpecies( "A" );
9804 final Species s4 = new BasicSpecies( "b" );
9805 if ( !s1.equals( s1 ) ) {
9808 if ( s1.getSpeciesId().equals( "x" ) ) {
9811 if ( s1.getSpeciesId().equals( null ) ) {
9814 if ( !s1.equals( s2 ) ) {
9817 if ( s1.equals( s3 ) ) {
9820 if ( s1.hashCode() != s1.hashCode() ) {
9823 if ( s1.hashCode() != s2.hashCode() ) {
9826 if ( s1.hashCode() == s3.hashCode() ) {
9829 if ( s1.compareTo( s1 ) != 0 ) {
9832 if ( s1.compareTo( s2 ) != 0 ) {
9835 if ( s1.compareTo( s3 ) != 0 ) {
9838 if ( s1.compareTo( s4 ) >= 0 ) {
9841 if ( s4.compareTo( s1 ) <= 0 ) {
9844 if ( !s4.getSpeciesId().equals( "b" ) ) {
9847 final Species s5 = new BasicSpecies( " C " );
9848 if ( !s5.getSpeciesId().equals( "C" ) ) {
9851 if ( s5.equals( s1 ) ) {
9855 catch ( final Exception e ) {
9856 e.printStackTrace( System.out );
9862 private static boolean testSplit() {
9864 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9865 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9866 //Archaeopteryx.createApplication( p0 );
9867 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9868 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9869 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9870 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9871 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9872 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9873 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9874 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9875 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9876 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9877 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9878 // System.out.println( s0.toString() );
9880 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9883 if ( s0.match( query_nodes ) ) {
9886 query_nodes = new HashSet<PhylogenyNode>();
9887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9893 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9894 if ( !s0.match( query_nodes ) ) {
9898 query_nodes = new HashSet<PhylogenyNode>();
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9902 if ( !s0.match( query_nodes ) ) {
9906 query_nodes = new HashSet<PhylogenyNode>();
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9911 if ( !s0.match( query_nodes ) ) {
9915 query_nodes = new HashSet<PhylogenyNode>();
9916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9920 if ( !s0.match( query_nodes ) ) {
9924 query_nodes = new HashSet<PhylogenyNode>();
9925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9928 if ( !s0.match( query_nodes ) ) {
9932 query_nodes = new HashSet<PhylogenyNode>();
9933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9935 if ( !s0.match( query_nodes ) ) {
9939 query_nodes = new HashSet<PhylogenyNode>();
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9943 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9944 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9945 if ( !s0.match( query_nodes ) ) {
9949 query_nodes = new HashSet<PhylogenyNode>();
9950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9951 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9952 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9953 if ( !s0.match( query_nodes ) ) {
9957 query_nodes = new HashSet<PhylogenyNode>();
9958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9960 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9962 if ( !s0.match( query_nodes ) ) {
9966 query_nodes = new HashSet<PhylogenyNode>();
9967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9969 if ( s0.match( query_nodes ) ) {
9973 query_nodes = new HashSet<PhylogenyNode>();
9974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9978 if ( s0.match( query_nodes ) ) {
9982 query_nodes = new HashSet<PhylogenyNode>();
9983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9988 if ( s0.match( query_nodes ) ) {
9992 query_nodes = new HashSet<PhylogenyNode>();
9993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9996 if ( s0.match( query_nodes ) ) {
10000 query_nodes = new HashSet<PhylogenyNode>();
10001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10003 if ( s0.match( query_nodes ) ) {
10007 query_nodes = new HashSet<PhylogenyNode>();
10008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10010 if ( s0.match( query_nodes ) ) {
10014 query_nodes = new HashSet<PhylogenyNode>();
10015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10017 if ( s0.match( query_nodes ) ) {
10021 query_nodes = new HashSet<PhylogenyNode>();
10022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10024 if ( s0.match( query_nodes ) ) {
10028 query_nodes = new HashSet<PhylogenyNode>();
10029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10031 if ( s0.match( query_nodes ) ) {
10035 query_nodes = new HashSet<PhylogenyNode>();
10036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10038 if ( s0.match( query_nodes ) ) {
10042 query_nodes = new HashSet<PhylogenyNode>();
10043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10046 if ( s0.match( query_nodes ) ) {
10050 query_nodes = new HashSet<PhylogenyNode>();
10051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10054 if ( s0.match( query_nodes ) ) {
10058 query_nodes = new HashSet<PhylogenyNode>();
10059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10062 if ( s0.match( query_nodes ) ) {
10066 query_nodes = new HashSet<PhylogenyNode>();
10067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10071 if ( s0.match( query_nodes ) ) {
10075 // query_nodes = new HashSet<PhylogenyNode>();
10076 // query_nodes.add( new PhylogenyNode( "X" ) );
10077 // query_nodes.add( new PhylogenyNode( "Y" ) );
10078 // query_nodes.add( new PhylogenyNode( "A" ) );
10079 // query_nodes.add( new PhylogenyNode( "B" ) );
10080 // query_nodes.add( new PhylogenyNode( "C" ) );
10081 // query_nodes.add( new PhylogenyNode( "D" ) );
10082 // query_nodes.add( new PhylogenyNode( "E" ) );
10083 // query_nodes.add( new PhylogenyNode( "F" ) );
10084 // query_nodes.add( new PhylogenyNode( "G" ) );
10085 // if ( !s0.match( query_nodes ) ) {
10088 // query_nodes = new HashSet<PhylogenyNode>();
10089 // query_nodes.add( new PhylogenyNode( "X" ) );
10090 // query_nodes.add( new PhylogenyNode( "Y" ) );
10091 // query_nodes.add( new PhylogenyNode( "A" ) );
10092 // query_nodes.add( new PhylogenyNode( "B" ) );
10093 // query_nodes.add( new PhylogenyNode( "C" ) );
10094 // if ( !s0.match( query_nodes ) ) {
10098 // query_nodes = new HashSet<PhylogenyNode>();
10099 // query_nodes.add( new PhylogenyNode( "X" ) );
10100 // query_nodes.add( new PhylogenyNode( "Y" ) );
10101 // query_nodes.add( new PhylogenyNode( "D" ) );
10102 // query_nodes.add( new PhylogenyNode( "E" ) );
10103 // query_nodes.add( new PhylogenyNode( "F" ) );
10104 // query_nodes.add( new PhylogenyNode( "G" ) );
10105 // if ( !s0.match( query_nodes ) ) {
10109 // query_nodes = new HashSet<PhylogenyNode>();
10110 // query_nodes.add( new PhylogenyNode( "X" ) );
10111 // query_nodes.add( new PhylogenyNode( "Y" ) );
10112 // query_nodes.add( new PhylogenyNode( "A" ) );
10113 // query_nodes.add( new PhylogenyNode( "B" ) );
10114 // query_nodes.add( new PhylogenyNode( "C" ) );
10115 // query_nodes.add( new PhylogenyNode( "D" ) );
10116 // if ( !s0.match( query_nodes ) ) {
10120 // query_nodes = new HashSet<PhylogenyNode>();
10121 // query_nodes.add( new PhylogenyNode( "X" ) );
10122 // query_nodes.add( new PhylogenyNode( "Y" ) );
10123 // query_nodes.add( new PhylogenyNode( "E" ) );
10124 // query_nodes.add( new PhylogenyNode( "F" ) );
10125 // query_nodes.add( new PhylogenyNode( "G" ) );
10126 // if ( !s0.match( query_nodes ) ) {
10130 // query_nodes = new HashSet<PhylogenyNode>();
10131 // query_nodes.add( new PhylogenyNode( "X" ) );
10132 // query_nodes.add( new PhylogenyNode( "Y" ) );
10133 // query_nodes.add( new PhylogenyNode( "F" ) );
10134 // query_nodes.add( new PhylogenyNode( "G" ) );
10135 // if ( !s0.match( query_nodes ) ) {
10139 query_nodes = new HashSet<PhylogenyNode>();
10140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10144 if ( s0.match( query_nodes ) ) {
10148 query_nodes = new HashSet<PhylogenyNode>();
10149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10153 if ( s0.match( query_nodes ) ) {
10156 ///////////////////////////
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( "D" ) );
10163 if ( s0.match( query_nodes ) ) {
10167 query_nodes = new HashSet<PhylogenyNode>();
10168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10171 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10172 if ( s0.match( query_nodes ) ) {
10176 query_nodes = new HashSet<PhylogenyNode>();
10177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10180 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10181 if ( s0.match( query_nodes ) ) {
10185 query_nodes = new HashSet<PhylogenyNode>();
10186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10187 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10188 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10189 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10190 if ( s0.match( query_nodes ) ) {
10194 query_nodes = new HashSet<PhylogenyNode>();
10195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10199 if ( s0.match( query_nodes ) ) {
10203 query_nodes = new HashSet<PhylogenyNode>();
10204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10207 if ( s0.match( query_nodes ) ) {
10211 query_nodes = new HashSet<PhylogenyNode>();
10212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10215 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10217 if ( s0.match( query_nodes ) ) {
10221 query_nodes = new HashSet<PhylogenyNode>();
10222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10227 if ( s0.match( query_nodes ) ) {
10231 query_nodes = new HashSet<PhylogenyNode>();
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10237 if ( s0.match( query_nodes ) ) {
10241 query_nodes = new HashSet<PhylogenyNode>();
10242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10247 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10248 if ( s0.match( query_nodes ) ) {
10252 catch ( final Exception e ) {
10253 e.printStackTrace();
10259 private static boolean testSplitStrict() {
10261 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10262 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10263 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10264 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10265 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10266 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10267 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10268 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10269 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10270 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10271 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10272 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10275 if ( s0.match( query_nodes ) ) {
10278 query_nodes = new HashSet<PhylogenyNode>();
10279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10285 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10286 if ( !s0.match( query_nodes ) ) {
10290 query_nodes = new HashSet<PhylogenyNode>();
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10294 if ( !s0.match( query_nodes ) ) {
10298 query_nodes = new HashSet<PhylogenyNode>();
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10303 if ( !s0.match( query_nodes ) ) {
10307 query_nodes = new HashSet<PhylogenyNode>();
10308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10310 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10312 if ( !s0.match( query_nodes ) ) {
10316 query_nodes = new HashSet<PhylogenyNode>();
10317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10320 if ( !s0.match( query_nodes ) ) {
10324 query_nodes = new HashSet<PhylogenyNode>();
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10327 if ( !s0.match( query_nodes ) ) {
10331 query_nodes = new HashSet<PhylogenyNode>();
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10337 if ( !s0.match( query_nodes ) ) {
10341 query_nodes = new HashSet<PhylogenyNode>();
10342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10345 if ( !s0.match( query_nodes ) ) {
10349 query_nodes = new HashSet<PhylogenyNode>();
10350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10352 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10354 if ( !s0.match( query_nodes ) ) {
10358 query_nodes = new HashSet<PhylogenyNode>();
10359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10361 if ( s0.match( query_nodes ) ) {
10365 query_nodes = new HashSet<PhylogenyNode>();
10366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10370 if ( s0.match( query_nodes ) ) {
10374 query_nodes = new HashSet<PhylogenyNode>();
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10378 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10380 if ( s0.match( query_nodes ) ) {
10384 query_nodes = new HashSet<PhylogenyNode>();
10385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10387 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10388 if ( s0.match( query_nodes ) ) {
10392 query_nodes = new HashSet<PhylogenyNode>();
10393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10395 if ( s0.match( query_nodes ) ) {
10399 query_nodes = new HashSet<PhylogenyNode>();
10400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10402 if ( s0.match( query_nodes ) ) {
10406 query_nodes = new HashSet<PhylogenyNode>();
10407 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10409 if ( s0.match( query_nodes ) ) {
10413 query_nodes = new HashSet<PhylogenyNode>();
10414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10415 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10416 if ( s0.match( query_nodes ) ) {
10420 query_nodes = new HashSet<PhylogenyNode>();
10421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10423 if ( s0.match( query_nodes ) ) {
10427 query_nodes = new HashSet<PhylogenyNode>();
10428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10430 if ( s0.match( query_nodes ) ) {
10434 query_nodes = new HashSet<PhylogenyNode>();
10435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10438 if ( s0.match( query_nodes ) ) {
10442 query_nodes = new HashSet<PhylogenyNode>();
10443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10446 if ( s0.match( query_nodes ) ) {
10450 query_nodes = new HashSet<PhylogenyNode>();
10451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10454 if ( s0.match( query_nodes ) ) {
10458 query_nodes = new HashSet<PhylogenyNode>();
10459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10463 if ( s0.match( query_nodes ) ) {
10467 catch ( final Exception e ) {
10468 e.printStackTrace();
10474 private static boolean testSubtreeDeletion() {
10476 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10477 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10478 t1.deleteSubtree( t1.getNode( "A" ), false );
10479 if ( t1.getNumberOfExternalNodes() != 5 ) {
10482 t1.toNewHampshireX();
10483 t1.deleteSubtree( t1.getNode( "E" ), false );
10484 if ( t1.getNumberOfExternalNodes() != 4 ) {
10487 t1.toNewHampshireX();
10488 t1.deleteSubtree( t1.getNode( "F" ), false );
10489 if ( t1.getNumberOfExternalNodes() != 3 ) {
10492 t1.toNewHampshireX();
10493 t1.deleteSubtree( t1.getNode( "D" ), false );
10494 t1.toNewHampshireX();
10495 if ( t1.getNumberOfExternalNodes() != 3 ) {
10498 t1.deleteSubtree( t1.getNode( "def" ), false );
10499 t1.toNewHampshireX();
10500 if ( t1.getNumberOfExternalNodes() != 2 ) {
10503 t1.deleteSubtree( t1.getNode( "B" ), false );
10504 t1.toNewHampshireX();
10505 if ( t1.getNumberOfExternalNodes() != 1 ) {
10508 t1.deleteSubtree( t1.getNode( "C" ), false );
10509 t1.toNewHampshireX();
10510 if ( t1.getNumberOfExternalNodes() != 1 ) {
10513 t1.deleteSubtree( t1.getNode( "abc" ), false );
10514 t1.toNewHampshireX();
10515 if ( t1.getNumberOfExternalNodes() != 1 ) {
10518 t1.deleteSubtree( t1.getNode( "r" ), false );
10519 if ( t1.getNumberOfExternalNodes() != 0 ) {
10522 if ( !t1.isEmpty() ) {
10525 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10526 t2.deleteSubtree( t2.getNode( "A" ), false );
10527 t2.toNewHampshireX();
10528 if ( t2.getNumberOfExternalNodes() != 5 ) {
10531 t2.deleteSubtree( t2.getNode( "abc" ), false );
10532 t2.toNewHampshireX();
10533 if ( t2.getNumberOfExternalNodes() != 3 ) {
10536 t2.deleteSubtree( t2.getNode( "def" ), false );
10537 t2.toNewHampshireX();
10538 if ( t2.getNumberOfExternalNodes() != 1 ) {
10542 catch ( final Exception e ) {
10543 e.printStackTrace( System.out );
10549 private static boolean testSupportCount() {
10551 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10552 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10553 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10554 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10555 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10556 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10557 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10559 SupportCount.count( t0_1, phylogenies_1, true, false );
10560 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10561 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10562 + "(((((A,B),C),D),E),((F,G),X))"
10563 + "(((((A,Y),B),C),D),((F,G),E))"
10564 + "(((((A,B),C),D),E),(F,G))"
10565 + "(((((A,B),C),D),E),(F,G))"
10566 + "(((((A,B),C),D),E),(F,G))"
10567 + "(((((A,B),C),D),E),(F,G),Z)"
10568 + "(((((A,B),C),D),E),(F,G))"
10569 + "((((((A,B),C),D),E),F),G)"
10570 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10572 SupportCount.count( t0_2, phylogenies_2, true, false );
10573 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10574 while ( it.hasNext() ) {
10575 final PhylogenyNode n = it.next();
10576 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10580 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10581 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10582 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10583 SupportCount.count( t0_3, phylogenies_3, true, false );
10584 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10585 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10588 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10591 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10594 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10597 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10600 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10603 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10606 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10609 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10612 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10615 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10616 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10617 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10618 SupportCount.count( t0_4, phylogenies_4, true, false );
10619 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10620 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10623 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10626 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10629 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10632 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10635 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10638 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10641 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10644 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10647 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10650 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10651 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10652 double d = SupportCount.compare( b1, a, true, true, true );
10653 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10656 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10657 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10658 d = SupportCount.compare( b2, a, true, true, true );
10659 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10662 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10663 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10664 d = SupportCount.compare( b3, a, true, true, true );
10665 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10668 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10669 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10670 d = SupportCount.compare( b4, a, true, true, false );
10671 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10675 catch ( final Exception e ) {
10676 e.printStackTrace( System.out );
10682 private static boolean testSupportTransfer() {
10684 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10685 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)",
10686 new NHXParser() )[ 0 ];
10687 final Phylogeny p2 = factory
10688 .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 ];
10689 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10692 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10695 support_transfer.moveBranchLengthsToBootstrap( p1 );
10696 support_transfer.transferSupportValues( p1, p2 );
10697 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10700 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10703 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10706 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10709 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10712 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10715 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10718 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10722 catch ( final Exception e ) {
10723 e.printStackTrace( System.out );
10729 private static boolean testTaxonomyExtraction() {
10731 final PhylogenyNode n0 = PhylogenyNode
10732 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10733 if ( n0.getNodeData().isHasTaxonomy() ) {
10736 final PhylogenyNode n1 = PhylogenyNode
10737 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10738 if ( n1.getNodeData().isHasTaxonomy() ) {
10739 System.out.println( n1.toString() );
10742 final PhylogenyNode n2x = PhylogenyNode
10743 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10744 if ( n2x.getNodeData().isHasTaxonomy() ) {
10747 final PhylogenyNode n3 = PhylogenyNode
10748 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10749 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10750 System.out.println( n3.toString() );
10753 final PhylogenyNode n4 = PhylogenyNode
10754 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10755 if ( n4.getNodeData().isHasTaxonomy() ) {
10756 System.out.println( n4.toString() );
10759 final PhylogenyNode n5 = PhylogenyNode
10760 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10761 if ( n5.getNodeData().isHasTaxonomy() ) {
10762 System.out.println( n5.toString() );
10765 final PhylogenyNode n6 = PhylogenyNode
10766 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10767 if ( n6.getNodeData().isHasTaxonomy() ) {
10768 System.out.println( n6.toString() );
10771 final PhylogenyNode n7 = PhylogenyNode
10772 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10773 if ( n7.getNodeData().isHasTaxonomy() ) {
10774 System.out.println( n7.toString() );
10777 final PhylogenyNode n8 = PhylogenyNode
10778 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10779 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10780 System.out.println( n8.toString() );
10783 final PhylogenyNode n9 = PhylogenyNode
10784 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10785 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10786 System.out.println( n9.toString() );
10789 final PhylogenyNode n10x = PhylogenyNode
10790 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10791 if ( n10x.getNodeData().isHasTaxonomy() ) {
10792 System.out.println( n10x.toString() );
10795 final PhylogenyNode n10xx = PhylogenyNode
10796 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10797 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10798 System.out.println( n10xx.toString() );
10801 final PhylogenyNode n10 = PhylogenyNode
10802 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10803 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10804 System.out.println( n10.toString() );
10807 final PhylogenyNode n11 = PhylogenyNode
10808 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10809 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10810 System.out.println( n11.toString() );
10813 final PhylogenyNode n12 = PhylogenyNode
10814 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10815 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10816 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10817 System.out.println( n12.toString() );
10820 final PhylogenyNode n13 = PhylogenyNode
10821 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10822 if ( n13.getNodeData().isHasTaxonomy() ) {
10823 System.out.println( n13.toString() );
10827 catch ( final Exception e ) {
10828 e.printStackTrace( System.out );
10834 private static boolean testTreeMethods() {
10836 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10837 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10838 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10839 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10840 System.out.println( t0.toNewHampshireX() );
10843 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10844 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10845 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10848 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10851 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10855 catch ( final Exception e ) {
10856 e.printStackTrace( System.out );
10862 private static boolean testSequenceDbWsTools1() {
10864 PhylogenyNode n = new PhylogenyNode();
10865 n.setName( "NP_001025424" );
10866 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
10867 if ( acc == null || !acc.getSource().equals( Source.REFSEQ.toString() )
10868 || !acc.getValue().equals( "NP_001025424" ) ) {
10871 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
10872 acc = SequenceDbWsTools.obtainSeqAccession( n );
10873 if ( acc == null || !acc.getSource().equals( Source.REFSEQ.toString() )
10874 || !acc.getValue().equals( "NP_001025424" ) ) {
10877 n.setName( "NP_001025424.1" );
10878 acc = SequenceDbWsTools.obtainSeqAccession( n );
10879 if ( acc == null || !acc.getSource().equals( Source.REFSEQ.toString() )
10880 || !acc.getValue().equals( "NP_001025424" ) ) {
10883 n.setName( "NM_001030253" );
10884 acc = SequenceDbWsTools.obtainSeqAccession( n );
10885 if ( acc == null || !acc.getSource().equals( Source.REFSEQ.toString() )
10886 || !acc.getValue().equals( "NM_001030253" ) ) {
10889 n.setName( "BCL2_HUMAN" );
10890 acc = SequenceDbWsTools.obtainSeqAccession( n );
10891 if ( acc == null || !acc.getSource().equals( Source.UNIPROT.toString() )
10892 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
10893 System.out.println( acc.toString() );
10896 n.setName( "P10415" );
10897 acc = SequenceDbWsTools.obtainSeqAccession( n );
10898 if ( acc == null || !acc.getSource().equals( Source.UNIPROT.toString() )
10899 || !acc.getValue().equals( "P10415" ) ) {
10900 System.out.println( acc.toString() );
10903 n.setName( " P10415 " );
10904 acc = SequenceDbWsTools.obtainSeqAccession( n );
10905 if ( acc == null || !acc.getSource().equals( Source.UNIPROT.toString() )
10906 || !acc.getValue().equals( "P10415" ) ) {
10907 System.out.println( acc.toString() );
10910 n.setName( "_P10415|" );
10911 acc = SequenceDbWsTools.obtainSeqAccession( n );
10912 if ( acc == null || !acc.getSource().equals( Source.UNIPROT.toString() )
10913 || !acc.getValue().equals( "P10415" ) ) {
10914 System.out.println( acc.toString() );
10917 n.setName( "AY695820" );
10918 acc = SequenceDbWsTools.obtainSeqAccession( n );
10919 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10920 || !acc.getValue().equals( "AY695820" ) ) {
10921 System.out.println( acc.toString() );
10924 n.setName( "_AY695820_" );
10925 acc = SequenceDbWsTools.obtainSeqAccession( n );
10926 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10927 || !acc.getValue().equals( "AY695820" ) ) {
10928 System.out.println( acc.toString() );
10931 n.setName( "AAA59452" );
10932 acc = SequenceDbWsTools.obtainSeqAccession( n );
10933 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10934 || !acc.getValue().equals( "AAA59452" ) ) {
10935 System.out.println( acc.toString() );
10938 n.setName( "_AAA59452_" );
10939 acc = SequenceDbWsTools.obtainSeqAccession( n );
10940 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10941 || !acc.getValue().equals( "AAA59452" ) ) {
10942 System.out.println( acc.toString() );
10945 n.setName( "AAA59452.1" );
10946 acc = SequenceDbWsTools.obtainSeqAccession( n );
10947 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10948 || !acc.getValue().equals( "AAA59452.1" ) ) {
10949 System.out.println( acc.toString() );
10952 n.setName( "_AAA59452.1_" );
10953 acc = SequenceDbWsTools.obtainSeqAccession( n );
10954 if ( acc == null || !acc.getSource().equals( Source.NCBI.toString() )
10955 || !acc.getValue().equals( "AAA59452.1" ) ) {
10956 System.out.println( acc.toString() );
10959 n.setName( "GI:94894583" );
10960 acc = SequenceDbWsTools.obtainSeqAccession( n );
10961 if ( acc == null || !acc.getSource().equals( Source.GI.toString() ) || !acc.getValue().equals( "94894583" ) ) {
10962 System.out.println( acc.toString() );
10966 catch ( final Exception e ) {
10972 private static boolean testSequenceDbWsTools2() {
10974 PhylogenyNode n1 = new PhylogenyNode();
10975 n1.setName( "NP_001025424" );
10976 SequenceDbWsTools.obtainSeqInformation( false, 4000, new TreeSet<String>(), n1 );
10977 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
10980 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10983 PhylogenyNode n2 = new PhylogenyNode();
10984 n2.setName( "NM_001030253" );
10985 SequenceDbWsTools.obtainSeqInformation( false, 4000, new TreeSet<String>(), n2 );
10986 System.out.println( n2.toString() );
10987 if ( !n2.getNodeData().getSequence().getName()
10988 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
10991 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
10995 catch ( final IOException e ) {
10996 System.out.println();
10997 System.out.println( "the following might be due to absence internet connection:" );
10998 e.printStackTrace( System.out );
11001 catch ( final Exception e ) {
11007 private static boolean testUniprotEntryRetrieval() {
11009 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
11010 if ( !entry.getAccession().equals( "P12345" ) ) {
11013 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
11016 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
11019 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
11022 if ( !entry.getGeneName().equals( "GOT2" ) ) {
11025 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
11029 catch ( final IOException e ) {
11030 System.out.println();
11031 System.out.println( "the following might be due to absence internet connection:" );
11032 e.printStackTrace( System.out );
11035 catch ( final Exception e ) {
11041 private static boolean testUniprotTaxonomySearch() {
11043 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
11045 if ( results.size() != 1 ) {
11048 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11051 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11054 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11057 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11060 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11064 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
11065 if ( results.size() != 1 ) {
11068 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11071 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11074 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11077 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11080 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11084 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
11085 if ( results.size() != 1 ) {
11088 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11091 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11094 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11097 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11100 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11104 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11105 if ( results.size() != 1 ) {
11108 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11111 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11114 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11117 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11120 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11123 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11126 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11129 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11130 .equals( "Nematostella vectensis" ) ) {
11131 System.out.println( results.get( 0 ).getLineage() );
11136 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
11137 if ( results.size() != 1 ) {
11140 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11143 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11146 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11149 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11152 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11155 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11156 .equals( "Xenopus tropicalis" ) ) {
11157 System.out.println( results.get( 0 ).getLineage() );
11162 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11163 if ( results.size() != 1 ) {
11166 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11169 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11172 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11175 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11178 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11181 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11182 .equals( "Xenopus tropicalis" ) ) {
11183 System.out.println( results.get( 0 ).getLineage() );
11188 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11189 if ( results.size() != 1 ) {
11192 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11195 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11198 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11201 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11204 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11207 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11208 .equals( "Xenopus tropicalis" ) ) {
11209 System.out.println( results.get( 0 ).getLineage() );
11213 catch ( final IOException e ) {
11214 System.out.println();
11215 System.out.println( "the following might be due to absence internet connection:" );
11216 e.printStackTrace( System.out );
11219 catch ( final Exception e ) {
11225 private static boolean testWabiTxSearch() {
11227 String result = "";
11228 result = TxSearch.searchSimple( "nematostella" );
11229 result = TxSearch.getTxId( "nematostella" );
11230 if ( !result.equals( "45350" ) ) {
11233 result = TxSearch.getTxName( "45350" );
11234 if ( !result.equals( "Nematostella" ) ) {
11237 result = TxSearch.getTxId( "nematostella vectensis" );
11238 if ( !result.equals( "45351" ) ) {
11241 result = TxSearch.getTxName( "45351" );
11242 if ( !result.equals( "Nematostella vectensis" ) ) {
11245 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11246 if ( !result.equals( "536089" ) ) {
11249 result = TxSearch.getTxName( "536089" );
11250 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11253 final List<String> queries = new ArrayList<String>();
11254 queries.add( "Campylobacter coli" );
11255 queries.add( "Escherichia coli" );
11256 queries.add( "Arabidopsis" );
11257 queries.add( "Trichoplax" );
11258 queries.add( "Samanea saman" );
11259 queries.add( "Kluyveromyces marxianus" );
11260 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11261 queries.add( "Bornavirus parrot/PDD/2008" );
11262 final List<RANKS> ranks = new ArrayList<RANKS>();
11263 ranks.add( RANKS.SUPERKINGDOM );
11264 ranks.add( RANKS.KINGDOM );
11265 ranks.add( RANKS.FAMILY );
11266 ranks.add( RANKS.GENUS );
11267 ranks.add( RANKS.TRIBE );
11268 result = TxSearch.searchLineage( queries, ranks );
11269 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11270 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11272 catch ( final Exception e ) {
11273 System.out.println();
11274 System.out.println( "the following might be due to absence internet connection:" );
11275 e.printStackTrace( System.out );