2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
40 import org.forester.application.support_transfer;
41 import org.forester.archaeopteryx.AptxUtil;
42 import org.forester.development.DevelopmentTools;
43 import org.forester.evoinference.TestPhylogenyReconstruction;
44 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
46 import org.forester.go.TestGo;
47 import org.forester.io.parsers.FastaParser;
48 import org.forester.io.parsers.GeneralMsaParser;
49 import org.forester.io.parsers.HmmscanPerDomainTableParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
51 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
52 import org.forester.io.parsers.nexus.NexusCharactersParser;
53 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
54 import org.forester.io.parsers.nhx.NHXParser;
55 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
56 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
57 import org.forester.io.parsers.tol.TolParser;
58 import org.forester.io.parsers.util.ParserUtils;
59 import org.forester.io.writers.PhylogenyWriter;
60 import org.forester.io.writers.SequenceWriter;
61 import org.forester.msa.BasicMsa;
62 import org.forester.msa.Mafft;
63 import org.forester.msa.Msa;
64 import org.forester.msa.MsaInferrer;
65 import org.forester.msa.MsaMethods;
66 import org.forester.pccx.TestPccx;
67 import org.forester.phylogeny.Phylogeny;
68 import org.forester.phylogeny.PhylogenyBranch;
69 import org.forester.phylogeny.PhylogenyMethods;
70 import org.forester.phylogeny.PhylogenyNode;
71 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
72 import org.forester.phylogeny.data.Accession;
73 import org.forester.phylogeny.data.BinaryCharacters;
74 import org.forester.phylogeny.data.BranchWidth;
75 import org.forester.phylogeny.data.Confidence;
76 import org.forester.phylogeny.data.Distribution;
77 import org.forester.phylogeny.data.DomainArchitecture;
78 import org.forester.phylogeny.data.Event;
79 import org.forester.phylogeny.data.Identifier;
80 import org.forester.phylogeny.data.PhylogenyData;
81 import org.forester.phylogeny.data.PhylogenyDataUtil;
82 import org.forester.phylogeny.data.Polygon;
83 import org.forester.phylogeny.data.PropertiesMap;
84 import org.forester.phylogeny.data.Property;
85 import org.forester.phylogeny.data.Property.AppliesTo;
86 import org.forester.phylogeny.data.ProteinDomain;
87 import org.forester.phylogeny.data.Taxonomy;
88 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
89 import org.forester.phylogeny.factories.PhylogenyFactory;
90 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
91 import org.forester.protein.BasicDomain;
92 import org.forester.protein.BasicProtein;
93 import org.forester.protein.Domain;
94 import org.forester.protein.DomainId;
95 import org.forester.protein.Protein;
96 import org.forester.protein.ProteinId;
97 import org.forester.rio.TestRIO;
98 import org.forester.sdi.SDI;
99 import org.forester.sdi.SDIR;
100 import org.forester.sdi.TestGSDI;
101 import org.forester.sequence.BasicSequence;
102 import org.forester.sequence.Sequence;
103 import org.forester.species.BasicSpecies;
104 import org.forester.species.Species;
105 import org.forester.surfacing.TestSurfacing;
106 import org.forester.tools.ConfidenceAssessor;
107 import org.forester.tools.SupportCount;
108 import org.forester.tools.TreeSplitMatrix;
109 import org.forester.util.AsciiHistogram;
110 import org.forester.util.BasicDescriptiveStatistics;
111 import org.forester.util.BasicTable;
112 import org.forester.util.BasicTableParser;
113 import org.forester.util.DescriptiveStatistics;
114 import org.forester.util.ForesterConstants;
115 import org.forester.util.ForesterUtil;
116 import org.forester.util.GeneralTable;
117 import org.forester.util.SequenceIdParser;
118 import org.forester.ws.seqdb.SequenceDatabaseEntry;
119 import org.forester.ws.seqdb.SequenceDbWsTools;
120 import org.forester.ws.seqdb.UniProtTaxonomy;
121 import org.forester.ws.wabi.TxSearch;
122 import org.forester.ws.wabi.TxSearch.RANKS;
123 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
124 import org.forester.ws.wabi.TxSearch.TAX_RANK;
126 @SuppressWarnings( "unused")
127 public final class Test {
129 private final static double ZERO_DIFF = 1.0E-9;
130 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
131 + ForesterUtil.getFileSeparator() + "test_data"
132 + ForesterUtil.getFileSeparator();
133 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
134 + ForesterUtil.getFileSeparator() + "resources"
135 + ForesterUtil.getFileSeparator();
136 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
137 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
138 + ForesterConstants.PHYLO_XML_VERSION + "/"
139 + ForesterConstants.PHYLO_XML_XSD;
140 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/"
142 + ForesterConstants.PHYLO_XML_XSD;
144 public static boolean isEqual( final double a, final double b ) {
145 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
148 public static void main( final String[] args ) {
149 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
150 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
152 Locale.setDefault( Locale.US );
153 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
156 System.out.print( "[Test if directory with files for testing exists/is readable: " );
157 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
158 System.out.println( "OK.]" );
161 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
162 System.out.println( "Testing aborted." );
165 System.out.print( "[Test if resources directory exists/is readable: " );
166 if ( testDir( PATH_TO_RESOURCES ) ) {
167 System.out.println( "OK.]" );
170 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
171 System.out.println( "Testing aborted." );
174 final long start_time = new Date().getTime();
175 System.out.print( "Domain id: " );
176 if ( !testDomainId() ) {
177 System.out.println( "failed." );
183 System.out.println( "OK." );
184 System.out.print( "Protein id: " );
185 if ( !testProteinId() ) {
186 System.out.println( "failed." );
192 System.out.println( "OK." );
193 System.out.print( "Species: " );
194 if ( !testSpecies() ) {
195 System.out.println( "failed." );
201 System.out.println( "OK." );
202 System.out.print( "Basic domain: " );
203 if ( !testBasicDomain() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Basic protein: " );
212 if ( !testBasicProtein() ) {
213 System.out.println( "failed." );
219 System.out.println( "OK." );
220 System.out.print( "Sequence writer: " );
221 if ( testSequenceWriter() ) {
222 System.out.println( "OK." );
226 System.out.println( "failed." );
229 System.out.print( "Sequence id parsing: " );
230 if ( testSequenceIdParsing() ) {
231 System.out.println( "OK." );
235 System.out.println( "failed." );
238 System.out.print( "Hmmscan output parser: " );
239 if ( testHmmscanOutputParser() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "Basic node methods: " );
248 if ( Test.testBasicNodeMethods() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "Taxonomy code extraction: " );
257 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "SN extraction: " );
266 if ( Test.testExtractSNFromNodeName() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "Taxonomy extraction (general): " );
275 if ( Test.testTaxonomyExtraction() ) {
276 System.out.println( "OK." );
280 System.out.println( "failed." );
283 System.out.print( "UniProtKB id extraction: " );
284 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
285 System.out.println( "OK." );
289 System.out.println( "failed." );
292 System.out.print( "Uri for Aptx web sequence accession: " );
293 if ( Test.testCreateUriForSeqWeb() ) {
294 System.out.println( "OK." );
298 System.out.println( "failed." );
301 System.out.print( "Basic node construction and parsing of NHX (node level): " );
302 if ( Test.testNHXNodeParsing() ) {
303 System.out.println( "OK." );
307 System.out.println( "failed." );
310 System.out.print( "NHX parsing iterating: " );
311 if ( Test.testNHParsingIter() ) {
312 System.out.println( "OK." );
316 System.out.println( "failed." );
319 System.out.print( "NH parsing: " );
320 if ( Test.testNHParsing() ) {
321 System.out.println( "OK." );
325 System.out.println( "failed." );
328 System.out.print( "Conversion to NHX (node level): " );
329 if ( Test.testNHXconversion() ) {
330 System.out.println( "OK." );
334 System.out.println( "failed." );
337 System.out.print( "NHX parsing: " );
338 if ( Test.testNHXParsing() ) {
339 System.out.println( "OK." );
343 System.out.println( "failed." );
346 System.out.print( "NHX parsing with quotes: " );
347 if ( Test.testNHXParsingQuotes() ) {
348 System.out.println( "OK." );
352 System.out.println( "failed." );
355 System.out.print( "NHX parsing (MrBayes): " );
356 if ( Test.testNHXParsingMB() ) {
357 System.out.println( "OK." );
361 System.out.println( "failed." );
364 System.out.print( "Nexus characters parsing: " );
365 if ( Test.testNexusCharactersParsing() ) {
366 System.out.println( "OK." );
370 System.out.println( "failed." );
373 System.out.print( "Nexus tree parsing iterating: " );
374 if ( Test.testNexusTreeParsingIterating() ) {
375 System.out.println( "OK." );
379 System.out.println( "failed." );
382 System.out.print( "Nexus tree parsing: " );
383 if ( Test.testNexusTreeParsing() ) {
384 System.out.println( "OK." );
388 System.out.println( "failed." );
391 System.out.print( "Nexus tree parsing (translating): " );
392 if ( Test.testNexusTreeParsingTranslating() ) {
393 System.out.println( "OK." );
397 System.out.println( "failed." );
400 System.out.print( "Nexus matrix parsing: " );
401 if ( Test.testNexusMatrixParsing() ) {
402 System.out.println( "OK." );
406 System.out.println( "failed." );
409 System.out.print( "Basic phyloXML parsing: " );
410 if ( Test.testBasicPhyloXMLparsing() ) {
411 System.out.println( "OK." );
415 System.out.println( "failed." );
418 System.out.print( "Basic phyloXML parsing (validating against schema): " );
419 if ( testBasicPhyloXMLparsingValidating() ) {
420 System.out.println( "OK." );
424 System.out.println( "failed." );
427 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
428 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
429 System.out.println( "OK." );
433 System.out.println( "failed." );
436 System.out.print( "phyloXML Distribution Element: " );
437 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
438 System.out.println( "OK." );
442 System.out.println( "failed." );
445 System.out.print( "Tol XML parsing: " );
446 if ( Test.testBasicTolXMLparsing() ) {
447 System.out.println( "OK." );
451 System.out.println( "failed." );
454 System.out.print( "Copying of node data: " );
455 if ( Test.testCopyOfNodeData() ) {
456 System.out.println( "OK." );
460 System.out.println( "failed." );
463 System.out.print( "Basic tree methods: " );
464 if ( Test.testBasicTreeMethods() ) {
465 System.out.println( "OK." );
469 System.out.println( "failed." );
472 System.out.print( "Tree methods: " );
473 if ( Test.testTreeMethods() ) {
474 System.out.println( "OK." );
478 System.out.println( "failed." );
481 System.out.print( "Postorder Iterator: " );
482 if ( Test.testPostOrderIterator() ) {
483 System.out.println( "OK." );
487 System.out.println( "failed." );
490 System.out.print( "Preorder Iterator: " );
491 if ( Test.testPreOrderIterator() ) {
492 System.out.println( "OK." );
496 System.out.println( "failed." );
499 System.out.print( "Levelorder Iterator: " );
500 if ( Test.testLevelOrderIterator() ) {
501 System.out.println( "OK." );
505 System.out.println( "failed." );
508 System.out.print( "Re-id methods: " );
509 if ( Test.testReIdMethods() ) {
510 System.out.println( "OK." );
514 System.out.println( "failed." );
517 System.out.print( "Methods on last external nodes: " );
518 if ( Test.testLastExternalNodeMethods() ) {
519 System.out.println( "OK." );
523 System.out.println( "failed." );
526 System.out.print( "Methods on external nodes: " );
527 if ( Test.testExternalNodeRelatedMethods() ) {
528 System.out.println( "OK." );
532 System.out.println( "failed." );
535 System.out.print( "Deletion of external nodes: " );
536 if ( Test.testDeletionOfExternalNodes() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
544 System.out.print( "Subtree deletion: " );
545 if ( Test.testSubtreeDeletion() ) {
546 System.out.println( "OK." );
550 System.out.println( "failed." );
553 System.out.print( "Phylogeny branch: " );
554 if ( Test.testPhylogenyBranch() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
562 System.out.print( "Rerooting: " );
563 if ( Test.testRerooting() ) {
564 System.out.println( "OK." );
568 System.out.println( "failed." );
571 System.out.print( "Mipoint rooting: " );
572 if ( Test.testMidpointrooting() ) {
573 System.out.println( "OK." );
577 System.out.println( "failed." );
580 System.out.print( "Node removal: " );
581 if ( Test.testNodeRemoval() ) {
582 System.out.println( "OK." );
586 System.out.println( "failed." );
589 System.out.print( "Support count: " );
590 if ( Test.testSupportCount() ) {
591 System.out.println( "OK." );
595 System.out.println( "failed." );
598 System.out.print( "Support transfer: " );
599 if ( Test.testSupportTransfer() ) {
600 System.out.println( "OK." );
604 System.out.println( "failed." );
607 System.out.print( "Finding of LCA: " );
608 if ( Test.testGetLCA() ) {
609 System.out.println( "OK." );
613 System.out.println( "failed." );
616 System.out.print( "Finding of LCA 2: " );
617 if ( Test.testGetLCA2() ) {
618 System.out.println( "OK." );
622 System.out.println( "failed." );
625 System.out.print( "Calculation of distance between nodes: " );
626 if ( Test.testGetDistance() ) {
627 System.out.println( "OK." );
631 System.out.println( "failed." );
634 System.out.print( "Descriptive statistics: " );
635 if ( Test.testDescriptiveStatistics() ) {
636 System.out.println( "OK." );
640 System.out.println( "failed." );
643 System.out.print( "Data objects and methods: " );
644 if ( Test.testDataObjects() ) {
645 System.out.println( "OK." );
649 System.out.println( "failed." );
652 System.out.print( "Properties map: " );
653 if ( Test.testPropertiesMap() ) {
654 System.out.println( "OK." );
658 System.out.println( "failed." );
661 System.out.print( "SDIse: " );
662 if ( Test.testSDIse() ) {
663 System.out.println( "OK." );
667 System.out.println( "failed." );
670 System.out.print( "SDIunrooted: " );
671 if ( Test.testSDIunrooted() ) {
672 System.out.println( "OK." );
676 System.out.println( "failed." );
679 System.out.print( "GSDI: " );
680 if ( TestGSDI.test() ) {
681 System.out.println( "OK." );
685 System.out.println( "failed." );
688 System.out.print( "RIO: " );
689 if ( TestRIO.test() ) {
690 System.out.println( "OK." );
694 System.out.println( "failed." );
697 System.out.print( "Phylogeny reconstruction:" );
698 System.out.println();
699 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "Analysis of domain architectures: " );
708 System.out.println();
709 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
710 System.out.println( "OK." );
714 System.out.println( "failed." );
717 System.out.print( "GO: " );
718 System.out.println();
719 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
720 System.out.println( "OK." );
724 System.out.println( "failed." );
727 System.out.print( "Modeling tools: " );
728 if ( TestPccx.test() ) {
729 System.out.println( "OK." );
733 System.out.println( "failed." );
736 System.out.print( "Split Matrix strict: " );
737 if ( Test.testSplitStrict() ) {
738 System.out.println( "OK." );
742 System.out.println( "failed." );
745 System.out.print( "Split Matrix: " );
746 if ( Test.testSplit() ) {
747 System.out.println( "OK." );
751 System.out.println( "failed." );
754 System.out.print( "Confidence Assessor: " );
755 if ( Test.testConfidenceAssessor() ) {
756 System.out.println( "OK." );
760 System.out.println( "failed." );
763 System.out.print( "Basic table: " );
764 if ( Test.testBasicTable() ) {
765 System.out.println( "OK." );
769 System.out.println( "failed." );
772 System.out.print( "General table: " );
773 if ( Test.testGeneralTable() ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "Amino acid sequence: " );
782 if ( Test.testAminoAcidSequence() ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "General MSA parser: " );
791 if ( Test.testGeneralMsaParser() ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "Fasta parser for msa: " );
800 if ( Test.testFastaParser() ) {
801 System.out.println( "OK." );
805 System.out.println( "failed." );
808 System.out.print( "Creation of balanced phylogeny: " );
809 if ( Test.testCreateBalancedPhylogeny() ) {
810 System.out.println( "OK." );
814 System.out.println( "failed." );
817 System.out.print( "EMBL Entry Retrieval: " );
818 if ( Test.testEmblEntryRetrieval() ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Uniprot Entry Retrieval: " );
827 if ( Test.testUniprotEntryRetrieval() ) {
828 System.out.println( "OK." );
832 System.out.println( "failed." );
835 System.out.print( "Uniprot Taxonomy Search: " );
836 if ( Test.testUniprotTaxonomySearch() ) {
837 System.out.println( "OK." );
841 System.out.println( "failed." );
846 final String os = ForesterUtil.OS_NAME.toLowerCase();
847 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
848 path = "/usr/local/bin/mafft";
850 else if ( os.indexOf( "win" ) >= 0 ) {
851 path = "C:\\Program Files\\mafft-win\\mafft.bat";
854 path = "/home/czmasek/bin/mafft";
856 if ( !MsaInferrer.isInstalled( path ) ) {
859 if ( !MsaInferrer.isInstalled( path ) ) {
860 path = "/usr/local/bin/mafft";
862 if ( MsaInferrer.isInstalled( path ) ) {
863 System.out.print( "MAFFT (external program): " );
864 if ( Test.testMafft( path ) ) {
865 System.out.println( "OK." );
869 System.out.println( "failed [will not count towards failed tests]" );
873 System.out.print( "Next nodes with collapsed: " );
874 if ( Test.testNextNodeWithCollapsing() ) {
875 System.out.println( "OK." );
879 System.out.println( "failed." );
882 System.out.print( "Simple MSA quality: " );
883 if ( Test.testMsaQualityMethod() ) {
884 System.out.println( "OK." );
888 System.out.println( "failed." );
891 System.out.println();
892 final Runtime rt = java.lang.Runtime.getRuntime();
893 final long free_memory = rt.freeMemory() / 1000000;
894 final long total_memory = rt.totalMemory() / 1000000;
895 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
896 + free_memory + "MB, total memory: " + total_memory + "MB)" );
897 System.out.println();
898 System.out.println( "Successful tests: " + succeeded );
899 System.out.println( "Failed tests: " + failed );
900 System.out.println();
902 System.out.println( "OK." );
905 System.out.println( "Not OK." );
909 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
910 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
914 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
915 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
918 private static boolean testAminoAcidSequence() {
920 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
921 if ( aa1.getLength() != 13 ) {
924 if ( aa1.getResidueAt( 0 ) != 'A' ) {
927 if ( aa1.getResidueAt( 2 ) != 'K' ) {
930 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
933 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
934 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
937 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
938 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
941 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
942 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
946 catch ( final Exception e ) {
953 private static boolean testBasicDomain() {
955 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
956 if ( !pd.getDomainId().getId().equals( "id" ) ) {
959 if ( pd.getNumber() != 1 ) {
962 if ( pd.getTotalCount() != 4 ) {
965 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
968 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
969 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
970 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
971 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
972 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
973 if ( !a1.equals( a1 ) ) {
976 if ( !a1.equals( a1_copy ) ) {
979 if ( !a1.equals( a1_equal ) ) {
982 if ( !a1.equals( a2 ) ) {
985 if ( a1.equals( a3 ) ) {
988 if ( a1.compareTo( a1 ) != 0 ) {
991 if ( a1.compareTo( a1_copy ) != 0 ) {
994 if ( a1.compareTo( a1_equal ) != 0 ) {
997 if ( a1.compareTo( a2 ) != 0 ) {
1000 if ( a1.compareTo( a3 ) != 0 ) {
1004 catch ( final Exception e ) {
1005 e.printStackTrace( System.out );
1011 private static boolean testBasicNodeMethods() {
1013 if ( PhylogenyNode.getNodeCount() != 0 ) {
1016 final PhylogenyNode n1 = new PhylogenyNode();
1017 final PhylogenyNode n2 = PhylogenyNode
1018 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1019 final PhylogenyNode n3 = PhylogenyNode
1020 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1021 final PhylogenyNode n4 = PhylogenyNode
1022 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1023 if ( n1.isHasAssignedEvent() ) {
1026 if ( PhylogenyNode.getNodeCount() != 4 ) {
1029 if ( n3.getIndicator() != 0 ) {
1032 if ( n3.getNumberOfExternalNodes() != 1 ) {
1035 if ( !n3.isExternal() ) {
1038 if ( !n3.isRoot() ) {
1041 if ( !n4.getName().equals( "n4" ) ) {
1045 catch ( final Exception e ) {
1046 e.printStackTrace( System.out );
1052 private static boolean testBasicPhyloXMLparsing() {
1054 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1055 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1056 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1058 if ( xml_parser.getErrorCount() > 0 ) {
1059 System.out.println( xml_parser.getErrorMessages().toString() );
1062 if ( phylogenies_0.length != 4 ) {
1065 final Phylogeny t1 = phylogenies_0[ 0 ];
1066 final Phylogeny t2 = phylogenies_0[ 1 ];
1067 final Phylogeny t3 = phylogenies_0[ 2 ];
1068 final Phylogeny t4 = phylogenies_0[ 3 ];
1069 if ( t1.getNumberOfExternalNodes() != 1 ) {
1072 if ( !t1.isRooted() ) {
1075 if ( t1.isRerootable() ) {
1078 if ( !t1.getType().equals( "gene_tree" ) ) {
1081 if ( t2.getNumberOfExternalNodes() != 2 ) {
1084 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1087 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1090 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1093 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1096 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1099 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1102 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1103 .startsWith( "actgtgggggt" ) ) {
1106 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1107 .startsWith( "ctgtgatgcat" ) ) {
1110 if ( t3.getNumberOfExternalNodes() != 4 ) {
1113 if ( !t1.getName().equals( "t1" ) ) {
1116 if ( !t2.getName().equals( "t2" ) ) {
1119 if ( !t3.getName().equals( "t3" ) ) {
1122 if ( !t4.getName().equals( "t4" ) ) {
1125 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1128 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1131 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1134 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1135 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1138 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1141 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1144 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1147 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1148 .equals( "apoptosis" ) ) {
1151 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1152 .equals( "GO:0006915" ) ) {
1155 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1156 .equals( "UniProtKB" ) ) {
1159 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1160 .equals( "experimental" ) ) {
1163 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1164 .equals( "function" ) ) {
1167 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1168 .getValue() != 1 ) {
1171 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1172 .getType().equals( "ml" ) ) {
1175 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1176 .equals( "apoptosis" ) ) {
1179 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1180 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1183 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1184 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1187 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1188 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1191 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1192 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1195 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1196 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1199 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1200 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1203 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1204 .equals( "GO:0005829" ) ) {
1207 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1208 .equals( "intracellular organelle" ) ) {
1211 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1214 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1215 .equals( "UniProt link" ) ) ) {
1218 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1222 catch ( final Exception e ) {
1223 e.printStackTrace( System.out );
1229 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1231 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1232 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1233 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1234 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1237 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1239 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1241 if ( xml_parser.getErrorCount() > 0 ) {
1242 System.out.println( xml_parser.getErrorMessages().toString() );
1245 if ( phylogenies_0.length != 4 ) {
1248 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1249 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1250 if ( phylogenies_t1.length != 1 ) {
1253 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1254 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1257 if ( !t1_rt.isRooted() ) {
1260 if ( t1_rt.isRerootable() ) {
1263 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1266 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1267 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1268 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1269 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1272 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1275 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1278 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1281 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1282 .startsWith( "actgtgggggt" ) ) {
1285 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1286 .startsWith( "ctgtgatgcat" ) ) {
1289 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1290 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1291 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1292 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1293 if ( phylogenies_1.length != 1 ) {
1296 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1297 if ( !t3_rt.getName().equals( "t3" ) ) {
1300 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1303 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1306 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1309 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1312 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1313 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1316 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1319 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1322 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1323 .equals( "UniProtKB" ) ) {
1326 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1327 .equals( "apoptosis" ) ) {
1330 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1331 .equals( "GO:0006915" ) ) {
1334 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1335 .equals( "UniProtKB" ) ) {
1338 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1339 .equals( "experimental" ) ) {
1342 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1343 .equals( "function" ) ) {
1346 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1347 .getValue() != 1 ) {
1350 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1351 .getType().equals( "ml" ) ) {
1354 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1355 .equals( "apoptosis" ) ) {
1358 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1359 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1362 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1363 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1366 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1367 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1370 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1371 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1374 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1375 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1378 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1379 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1382 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1383 .equals( "GO:0005829" ) ) {
1386 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1387 .equals( "intracellular organelle" ) ) {
1390 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1393 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1394 .equals( "UniProt link" ) ) ) {
1397 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1400 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1403 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1404 .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." ) ) ) {
1407 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1410 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1413 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1416 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1419 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1420 .equals( "ncbi" ) ) {
1423 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1426 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1427 .getName().equals( "B" ) ) {
1430 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1431 .getFrom() != 21 ) {
1434 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1437 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1438 .getLength() != 24 ) {
1441 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1442 .getConfidence() != 2144 ) {
1445 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1446 .equals( "pfam" ) ) {
1449 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1452 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1455 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1458 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1461 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1462 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1465 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1468 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1471 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1474 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1477 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1480 if ( taxbb.getSynonyms().size() != 2 ) {
1483 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1486 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1489 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1492 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1495 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1498 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1499 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1503 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1506 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1509 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1512 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1515 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1518 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1521 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1525 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1528 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1529 .equalsIgnoreCase( "435" ) ) {
1532 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1535 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1536 .equalsIgnoreCase( "443.7" ) ) {
1539 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1542 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1545 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1546 .equalsIgnoreCase( "433" ) ) {
1550 catch ( final Exception e ) {
1551 e.printStackTrace( System.out );
1557 private static boolean testBasicPhyloXMLparsingValidating() {
1559 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1560 PhyloXmlParser xml_parser = null;
1562 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1564 catch ( final Exception e ) {
1565 // Do nothing -- means were not running from jar.
1567 if ( xml_parser == null ) {
1568 xml_parser = new PhyloXmlParser();
1569 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1570 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1573 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1576 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1578 if ( xml_parser.getErrorCount() > 0 ) {
1579 System.out.println( xml_parser.getErrorMessages().toString() );
1582 if ( phylogenies_0.length != 4 ) {
1585 final Phylogeny t1 = phylogenies_0[ 0 ];
1586 final Phylogeny t2 = phylogenies_0[ 1 ];
1587 final Phylogeny t3 = phylogenies_0[ 2 ];
1588 final Phylogeny t4 = phylogenies_0[ 3 ];
1589 if ( !t1.getName().equals( "t1" ) ) {
1592 if ( !t2.getName().equals( "t2" ) ) {
1595 if ( !t3.getName().equals( "t3" ) ) {
1598 if ( !t4.getName().equals( "t4" ) ) {
1601 if ( t1.getNumberOfExternalNodes() != 1 ) {
1604 if ( t2.getNumberOfExternalNodes() != 2 ) {
1607 if ( t3.getNumberOfExternalNodes() != 4 ) {
1610 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1611 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1612 if ( xml_parser.getErrorCount() > 0 ) {
1613 System.out.println( "errors:" );
1614 System.out.println( xml_parser.getErrorMessages().toString() );
1617 if ( phylogenies_1.length != 4 ) {
1620 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1622 if ( xml_parser.getErrorCount() > 0 ) {
1623 System.out.println( "errors:" );
1624 System.out.println( xml_parser.getErrorMessages().toString() );
1627 if ( phylogenies_2.length != 1 ) {
1630 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1633 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1635 if ( xml_parser.getErrorCount() > 0 ) {
1636 System.out.println( xml_parser.getErrorMessages().toString() );
1639 if ( phylogenies_3.length != 2 ) {
1642 final Phylogeny a = phylogenies_3[ 0 ];
1643 if ( !a.getName().equals( "tree 4" ) ) {
1646 if ( a.getNumberOfExternalNodes() != 3 ) {
1649 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1652 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1655 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1657 if ( xml_parser.getErrorCount() > 0 ) {
1658 System.out.println( xml_parser.getErrorMessages().toString() );
1661 if ( phylogenies_4.length != 1 ) {
1664 final Phylogeny s = phylogenies_4[ 0 ];
1665 if ( s.getNumberOfExternalNodes() != 6 ) {
1668 s.getNode( "first" );
1670 s.getNode( "\"<a'b&c'd\">\"" );
1671 s.getNode( "'''\"" );
1672 s.getNode( "\"\"\"" );
1673 s.getNode( "dick & doof" );
1675 catch ( final Exception e ) {
1676 e.printStackTrace( System.out );
1682 private static boolean testBasicProtein() {
1684 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1685 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1686 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1687 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1688 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1689 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1690 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1691 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1692 p0.addProteinDomain( y );
1693 p0.addProteinDomain( e );
1694 p0.addProteinDomain( b );
1695 p0.addProteinDomain( c );
1696 p0.addProteinDomain( d );
1697 p0.addProteinDomain( a );
1698 p0.addProteinDomain( x );
1699 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1702 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1703 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1704 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1705 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1706 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1707 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1708 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1709 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1710 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1711 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1712 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1713 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1714 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1715 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1716 p.addProteinDomain( B15 );
1717 p.addProteinDomain( C50 );
1718 p.addProteinDomain( A60 );
1719 p.addProteinDomain( A30 );
1720 p.addProteinDomain( C70 );
1721 p.addProteinDomain( B35 );
1722 p.addProteinDomain( B40 );
1723 p.addProteinDomain( A0 );
1724 p.addProteinDomain( A10 );
1725 p.addProteinDomain( A20 );
1726 p.addProteinDomain( B25 );
1727 p.addProteinDomain( D80 );
1728 List<DomainId> domains_ids = new ArrayList<DomainId>();
1729 domains_ids.add( new DomainId( "A" ) );
1730 domains_ids.add( new DomainId( "B" ) );
1731 domains_ids.add( new DomainId( "C" ) );
1732 if ( !p.contains( domains_ids, false ) ) {
1735 if ( !p.contains( domains_ids, true ) ) {
1738 domains_ids.add( new DomainId( "X" ) );
1739 if ( p.contains( domains_ids, false ) ) {
1742 if ( p.contains( domains_ids, true ) ) {
1745 domains_ids = new ArrayList<DomainId>();
1746 domains_ids.add( new DomainId( "A" ) );
1747 domains_ids.add( new DomainId( "C" ) );
1748 domains_ids.add( new DomainId( "D" ) );
1749 if ( !p.contains( domains_ids, false ) ) {
1752 if ( !p.contains( domains_ids, true ) ) {
1755 domains_ids = new ArrayList<DomainId>();
1756 domains_ids.add( new DomainId( "A" ) );
1757 domains_ids.add( new DomainId( "D" ) );
1758 domains_ids.add( new DomainId( "C" ) );
1759 if ( !p.contains( domains_ids, false ) ) {
1762 if ( p.contains( domains_ids, true ) ) {
1765 domains_ids = new ArrayList<DomainId>();
1766 domains_ids.add( new DomainId( "A" ) );
1767 domains_ids.add( new DomainId( "A" ) );
1768 domains_ids.add( new DomainId( "B" ) );
1769 if ( !p.contains( domains_ids, false ) ) {
1772 if ( !p.contains( domains_ids, true ) ) {
1775 domains_ids = new ArrayList<DomainId>();
1776 domains_ids.add( new DomainId( "A" ) );
1777 domains_ids.add( new DomainId( "A" ) );
1778 domains_ids.add( new DomainId( "A" ) );
1779 domains_ids.add( new DomainId( "B" ) );
1780 domains_ids.add( new DomainId( "B" ) );
1781 if ( !p.contains( domains_ids, false ) ) {
1784 if ( !p.contains( domains_ids, true ) ) {
1787 domains_ids = new ArrayList<DomainId>();
1788 domains_ids.add( new DomainId( "A" ) );
1789 domains_ids.add( new DomainId( "A" ) );
1790 domains_ids.add( new DomainId( "A" ) );
1791 domains_ids.add( new DomainId( "A" ) );
1792 domains_ids.add( new DomainId( "B" ) );
1793 domains_ids.add( new DomainId( "B" ) );
1794 if ( !p.contains( domains_ids, false ) ) {
1797 if ( !p.contains( domains_ids, true ) ) {
1800 domains_ids = new ArrayList<DomainId>();
1801 domains_ids.add( new DomainId( "A" ) );
1802 domains_ids.add( new DomainId( "A" ) );
1803 domains_ids.add( new DomainId( "A" ) );
1804 domains_ids.add( new DomainId( "A" ) );
1805 domains_ids.add( new DomainId( "A" ) );
1806 domains_ids.add( new DomainId( "B" ) );
1807 domains_ids.add( new DomainId( "B" ) );
1808 if ( !p.contains( domains_ids, false ) ) {
1811 if ( p.contains( domains_ids, true ) ) {
1814 domains_ids = new ArrayList<DomainId>();
1815 domains_ids.add( new DomainId( "A" ) );
1816 domains_ids.add( new DomainId( "A" ) );
1817 domains_ids.add( new DomainId( "B" ) );
1818 domains_ids.add( new DomainId( "A" ) );
1819 domains_ids.add( new DomainId( "B" ) );
1820 domains_ids.add( new DomainId( "A" ) );
1821 domains_ids.add( new DomainId( "B" ) );
1822 domains_ids.add( new DomainId( "B" ) );
1823 domains_ids.add( new DomainId( "C" ) );
1824 domains_ids.add( new DomainId( "A" ) );
1825 domains_ids.add( new DomainId( "C" ) );
1826 domains_ids.add( new DomainId( "D" ) );
1827 if ( !p.contains( domains_ids, false ) ) {
1830 if ( !p.contains( domains_ids, true ) ) {
1833 domains_ids = new ArrayList<DomainId>();
1834 domains_ids.add( new DomainId( "A" ) );
1835 domains_ids.add( new DomainId( "B" ) );
1836 domains_ids.add( new DomainId( "A" ) );
1837 domains_ids.add( new DomainId( "B" ) );
1838 domains_ids.add( new DomainId( "A" ) );
1839 domains_ids.add( new DomainId( "B" ) );
1840 domains_ids.add( new DomainId( "B" ) );
1841 domains_ids.add( new DomainId( "A" ) );
1842 domains_ids.add( new DomainId( "C" ) );
1843 domains_ids.add( new DomainId( "D" ) );
1844 if ( !p.contains( domains_ids, false ) ) {
1847 if ( !p.contains( domains_ids, true ) ) {
1850 domains_ids = new ArrayList<DomainId>();
1851 domains_ids.add( new DomainId( "A" ) );
1852 domains_ids.add( new DomainId( "A" ) );
1853 domains_ids.add( new DomainId( "B" ) );
1854 domains_ids.add( new DomainId( "A" ) );
1855 domains_ids.add( new DomainId( "B" ) );
1856 domains_ids.add( new DomainId( "A" ) );
1857 domains_ids.add( new DomainId( "B" ) );
1858 domains_ids.add( new DomainId( "B" ) );
1859 domains_ids.add( new DomainId( "C" ) );
1860 domains_ids.add( new DomainId( "C" ) );
1861 domains_ids.add( new DomainId( "A" ) );
1862 domains_ids.add( new DomainId( "C" ) );
1863 domains_ids.add( new DomainId( "D" ) );
1864 if ( !p.contains( domains_ids, false ) ) {
1867 if ( p.contains( domains_ids, true ) ) {
1870 domains_ids = new ArrayList<DomainId>();
1871 domains_ids.add( new DomainId( "A" ) );
1872 domains_ids.add( new DomainId( "A" ) );
1873 domains_ids.add( new DomainId( "A" ) );
1874 domains_ids.add( new DomainId( "B" ) );
1875 domains_ids.add( new DomainId( "A" ) );
1876 domains_ids.add( new DomainId( "B" ) );
1877 domains_ids.add( new DomainId( "A" ) );
1878 domains_ids.add( new DomainId( "B" ) );
1879 domains_ids.add( new DomainId( "B" ) );
1880 domains_ids.add( new DomainId( "C" ) );
1881 domains_ids.add( new DomainId( "A" ) );
1882 domains_ids.add( new DomainId( "C" ) );
1883 domains_ids.add( new DomainId( "D" ) );
1884 if ( !p.contains( domains_ids, false ) ) {
1887 if ( p.contains( domains_ids, true ) ) {
1890 domains_ids = new ArrayList<DomainId>();
1891 domains_ids.add( new DomainId( "A" ) );
1892 domains_ids.add( new DomainId( "A" ) );
1893 domains_ids.add( new DomainId( "B" ) );
1894 domains_ids.add( new DomainId( "A" ) );
1895 domains_ids.add( new DomainId( "B" ) );
1896 domains_ids.add( new DomainId( "A" ) );
1897 domains_ids.add( new DomainId( "B" ) );
1898 domains_ids.add( new DomainId( "B" ) );
1899 domains_ids.add( new DomainId( "A" ) );
1900 domains_ids.add( new DomainId( "D" ) );
1901 if ( !p.contains( domains_ids, false ) ) {
1904 if ( !p.contains( domains_ids, true ) ) {
1907 domains_ids = new ArrayList<DomainId>();
1908 domains_ids.add( new DomainId( "A" ) );
1909 domains_ids.add( new DomainId( "A" ) );
1910 domains_ids.add( new DomainId( "B" ) );
1911 domains_ids.add( new DomainId( "A" ) );
1912 domains_ids.add( new DomainId( "B" ) );
1913 domains_ids.add( new DomainId( "A" ) );
1914 domains_ids.add( new DomainId( "B" ) );
1915 domains_ids.add( new DomainId( "B" ) );
1916 domains_ids.add( new DomainId( "C" ) );
1917 domains_ids.add( new DomainId( "A" ) );
1918 domains_ids.add( new DomainId( "C" ) );
1919 domains_ids.add( new DomainId( "D" ) );
1920 domains_ids.add( new DomainId( "X" ) );
1921 if ( p.contains( domains_ids, false ) ) {
1924 if ( p.contains( domains_ids, true ) ) {
1927 domains_ids = new ArrayList<DomainId>();
1928 domains_ids.add( new DomainId( "X" ) );
1929 domains_ids.add( new DomainId( "A" ) );
1930 domains_ids.add( new DomainId( "A" ) );
1931 domains_ids.add( new DomainId( "B" ) );
1932 domains_ids.add( new DomainId( "A" ) );
1933 domains_ids.add( new DomainId( "B" ) );
1934 domains_ids.add( new DomainId( "A" ) );
1935 domains_ids.add( new DomainId( "B" ) );
1936 domains_ids.add( new DomainId( "B" ) );
1937 domains_ids.add( new DomainId( "C" ) );
1938 domains_ids.add( new DomainId( "A" ) );
1939 domains_ids.add( new DomainId( "C" ) );
1940 domains_ids.add( new DomainId( "D" ) );
1941 if ( p.contains( domains_ids, false ) ) {
1944 if ( p.contains( domains_ids, true ) ) {
1947 domains_ids = new ArrayList<DomainId>();
1948 domains_ids.add( new DomainId( "A" ) );
1949 domains_ids.add( new DomainId( "A" ) );
1950 domains_ids.add( new DomainId( "B" ) );
1951 domains_ids.add( new DomainId( "A" ) );
1952 domains_ids.add( new DomainId( "B" ) );
1953 domains_ids.add( new DomainId( "B" ) );
1954 domains_ids.add( new DomainId( "A" ) );
1955 domains_ids.add( new DomainId( "B" ) );
1956 domains_ids.add( new DomainId( "C" ) );
1957 domains_ids.add( new DomainId( "A" ) );
1958 domains_ids.add( new DomainId( "C" ) );
1959 domains_ids.add( new DomainId( "D" ) );
1960 if ( !p.contains( domains_ids, false ) ) {
1963 if ( p.contains( domains_ids, true ) ) {
1967 catch ( final Exception e ) {
1968 e.printStackTrace( System.out );
1974 private static boolean testBasicTable() {
1976 final BasicTable<String> t0 = new BasicTable<String>();
1977 if ( t0.getNumberOfColumns() != 0 ) {
1980 if ( t0.getNumberOfRows() != 0 ) {
1983 t0.setValue( 3, 2, "23" );
1984 t0.setValue( 10, 1, "error" );
1985 t0.setValue( 10, 1, "110" );
1986 t0.setValue( 9, 1, "19" );
1987 t0.setValue( 1, 10, "101" );
1988 t0.setValue( 10, 10, "1010" );
1989 t0.setValue( 100, 10, "10100" );
1990 t0.setValue( 0, 0, "00" );
1991 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1994 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1997 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2000 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2003 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2006 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2009 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2012 if ( t0.getNumberOfColumns() != 101 ) {
2015 if ( t0.getNumberOfRows() != 11 ) {
2018 if ( t0.getValueAsString( 49, 4 ) != null ) {
2021 final String l = ForesterUtil.getLineSeparator();
2022 final StringBuffer source = new StringBuffer();
2023 source.append( "" + l );
2024 source.append( "# 1 1 1 1 1 1 1 1" + l );
2025 source.append( " 00 01 02 03" + l );
2026 source.append( " 10 11 12 13 " + l );
2027 source.append( "20 21 22 23 " + l );
2028 source.append( " 30 31 32 33" + l );
2029 source.append( "40 41 42 43" + l );
2030 source.append( " # 1 1 1 1 1 " + l );
2031 source.append( "50 51 52 53 54" + l );
2032 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2033 if ( t1.getNumberOfColumns() != 5 ) {
2036 if ( t1.getNumberOfRows() != 6 ) {
2039 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2042 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2045 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2048 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2051 final StringBuffer source1 = new StringBuffer();
2052 source1.append( "" + l );
2053 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2054 source1.append( " 00; 01 ;02;03" + l );
2055 source1.append( " 10; 11; 12; 13 " + l );
2056 source1.append( "20; 21; 22; 23 " + l );
2057 source1.append( " 30; 31; 32; 33" + l );
2058 source1.append( "40;41;42;43" + l );
2059 source1.append( " # 1 1 1 1 1 " + l );
2060 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2061 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2062 if ( t2.getNumberOfColumns() != 5 ) {
2065 if ( t2.getNumberOfRows() != 6 ) {
2068 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2071 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2074 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2077 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2080 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2083 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2086 final StringBuffer source2 = new StringBuffer();
2087 source2.append( "" + l );
2088 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2089 source2.append( " 00; 01 ;02;03" + l );
2090 source2.append( " 10; 11; 12; 13 " + l );
2091 source2.append( "20; 21; 22; 23 " + l );
2092 source2.append( " " + l );
2093 source2.append( " 30; 31; 32; 33" + l );
2094 source2.append( "40;41;42;43" + l );
2095 source2.append( " comment: 1 1 1 1 1 " + l );
2096 source2.append( ";;;50 ; 52; 53;;54 " + l );
2097 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2103 if ( tl.size() != 2 ) {
2106 final BasicTable<String> t3 = tl.get( 0 );
2107 final BasicTable<String> t4 = tl.get( 1 );
2108 if ( t3.getNumberOfColumns() != 4 ) {
2111 if ( t3.getNumberOfRows() != 3 ) {
2114 if ( t4.getNumberOfColumns() != 4 ) {
2117 if ( t4.getNumberOfRows() != 3 ) {
2120 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2123 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2127 catch ( final Exception e ) {
2128 e.printStackTrace( System.out );
2134 private static boolean testBasicTolXMLparsing() {
2136 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2137 final TolParser parser = new TolParser();
2138 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2139 if ( parser.getErrorCount() > 0 ) {
2140 System.out.println( parser.getErrorMessages().toString() );
2143 if ( phylogenies_0.length != 1 ) {
2146 final Phylogeny t1 = phylogenies_0[ 0 ];
2147 if ( t1.getNumberOfExternalNodes() != 5 ) {
2150 if ( !t1.isRooted() ) {
2153 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2156 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2159 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2162 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2165 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2166 if ( parser.getErrorCount() > 0 ) {
2167 System.out.println( parser.getErrorMessages().toString() );
2170 if ( phylogenies_1.length != 1 ) {
2173 final Phylogeny t2 = phylogenies_1[ 0 ];
2174 if ( t2.getNumberOfExternalNodes() != 664 ) {
2177 if ( !t2.isRooted() ) {
2180 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2183 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2186 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2189 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2192 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2195 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2196 .equals( "Aquifex" ) ) {
2199 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2200 if ( parser.getErrorCount() > 0 ) {
2201 System.out.println( parser.getErrorMessages().toString() );
2204 if ( phylogenies_2.length != 1 ) {
2207 final Phylogeny t3 = phylogenies_2[ 0 ];
2208 if ( t3.getNumberOfExternalNodes() != 184 ) {
2211 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2214 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2217 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2220 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2221 if ( parser.getErrorCount() > 0 ) {
2222 System.out.println( parser.getErrorMessages().toString() );
2225 if ( phylogenies_3.length != 1 ) {
2228 final Phylogeny t4 = phylogenies_3[ 0 ];
2229 if ( t4.getNumberOfExternalNodes() != 1 ) {
2232 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2235 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2238 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2241 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2242 if ( parser.getErrorCount() > 0 ) {
2243 System.out.println( parser.getErrorMessages().toString() );
2246 if ( phylogenies_4.length != 1 ) {
2249 final Phylogeny t5 = phylogenies_4[ 0 ];
2250 if ( t5.getNumberOfExternalNodes() != 13 ) {
2253 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2256 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2259 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2263 catch ( final Exception e ) {
2264 e.printStackTrace( System.out );
2270 private static boolean testBasicTreeMethods() {
2272 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2273 final Phylogeny t1 = factory.create();
2274 if ( !t1.isEmpty() ) {
2277 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2278 if ( t2.getNumberOfExternalNodes() != 4 ) {
2281 if ( t2.getHeight() != 8.5 ) {
2284 if ( !t2.isCompletelyBinary() ) {
2287 if ( t2.isEmpty() ) {
2290 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2291 if ( t3.getNumberOfExternalNodes() != 5 ) {
2294 if ( t3.getHeight() != 11 ) {
2297 if ( t3.isCompletelyBinary() ) {
2300 final PhylogenyNode n = t3.getNode( "ABC" );
2301 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 ];
2302 if ( t4.getNumberOfExternalNodes() != 9 ) {
2305 if ( t4.getHeight() != 11 ) {
2308 if ( t4.isCompletelyBinary() ) {
2311 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)" );
2312 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2313 if ( t5.getNumberOfExternalNodes() != 8 ) {
2316 if ( t5.getHeight() != 15 ) {
2319 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)" );
2320 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2321 if ( t6.getHeight() != 15 ) {
2324 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)" );
2325 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2326 if ( t7.getHeight() != 15 ) {
2329 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)" );
2330 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2331 if ( t8.getNumberOfExternalNodes() != 10 ) {
2334 if ( t8.getHeight() != 15 ) {
2337 final char[] a9 = new char[] { 'a' };
2338 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2339 if ( t9.getHeight() != 0 ) {
2342 final char[] a10 = new char[] { 'a', ':', '6' };
2343 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2344 if ( t10.getHeight() != 6 ) {
2348 catch ( final Exception e ) {
2349 e.printStackTrace( System.out );
2355 private static boolean testConfidenceAssessor() {
2357 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2358 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2359 final Phylogeny[] ev0 = factory
2360 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2362 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2363 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2366 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2369 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2370 final Phylogeny[] ev1 = factory
2371 .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)));",
2373 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2374 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2377 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2380 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2381 final Phylogeny[] ev_b = factory
2382 .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",
2384 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2385 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2388 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2392 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2393 final Phylogeny[] ev1x = factory
2394 .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)));",
2396 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2397 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2400 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2403 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2404 final Phylogeny[] ev_bx = factory
2405 .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",
2407 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2408 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2411 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2415 final Phylogeny[] t2 = factory
2416 .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);",
2418 final Phylogeny[] ev2 = factory
2419 .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);",
2421 for( final Phylogeny target : t2 ) {
2422 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2425 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2426 new NHXParser() )[ 0 ];
2427 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2428 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2429 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2432 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2435 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2439 catch ( final Exception e ) {
2440 e.printStackTrace();
2446 private static boolean testCopyOfNodeData() {
2448 final PhylogenyNode n1 = PhylogenyNode
2449 .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]" );
2450 final PhylogenyNode n2 = n1.copyNodeData();
2451 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2455 catch ( final Exception e ) {
2456 e.printStackTrace();
2462 private static boolean testCreateBalancedPhylogeny() {
2464 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2465 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2468 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2471 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2472 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2475 if ( p1.getNumberOfExternalNodes() != 100 ) {
2479 catch ( final Exception e ) {
2480 e.printStackTrace();
2486 private static boolean testCreateUriForSeqWeb() {
2488 final PhylogenyNode n = new PhylogenyNode();
2489 n.setName( "tr|B3RJ64" );
2490 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2493 n.setName( "B0LM41_HUMAN" );
2494 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2497 n.setName( "NP_001025424" );
2498 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2501 n.setName( "_NM_001030253-" );
2502 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2505 n.setName( "XM_002122186" );
2506 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2509 n.setName( "dgh_AAA34956_gdg" );
2510 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2513 n.setName( "j40f4_Q06891.1_fndn2 fnr3" );
2514 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "Q06891.1" ) ) {
2517 n.setName( "GI:394892" );
2518 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2519 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2522 n.setName( "gi_394892" );
2523 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2524 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2527 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2528 if ( !AptxUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2529 System.out.println( AptxUtil.createUriForSeqWeb( n, null, null ) );
2533 catch ( final Exception e ) {
2534 e.printStackTrace( System.out );
2540 private static boolean testDataObjects() {
2542 final Confidence s0 = new Confidence();
2543 final Confidence s1 = new Confidence();
2544 if ( !s0.isEqual( s1 ) ) {
2547 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2548 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2549 if ( s2.isEqual( s1 ) ) {
2552 if ( !s2.isEqual( s3 ) ) {
2555 final Confidence s4 = ( Confidence ) s3.copy();
2556 if ( !s4.isEqual( s3 ) ) {
2563 final Taxonomy t1 = new Taxonomy();
2564 final Taxonomy t2 = new Taxonomy();
2565 final Taxonomy t3 = new Taxonomy();
2566 final Taxonomy t4 = new Taxonomy();
2567 final Taxonomy t5 = new Taxonomy();
2568 t1.setIdentifier( new Identifier( "ecoli" ) );
2569 t1.setTaxonomyCode( "ECOLI" );
2570 t1.setScientificName( "E. coli" );
2571 t1.setCommonName( "coli" );
2572 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2573 if ( !t1.isEqual( t0 ) ) {
2576 t2.setIdentifier( new Identifier( "ecoli" ) );
2577 t2.setTaxonomyCode( "OTHER" );
2578 t2.setScientificName( "what" );
2579 t2.setCommonName( "something" );
2580 if ( !t1.isEqual( t2 ) ) {
2583 t2.setIdentifier( new Identifier( "nemve" ) );
2584 if ( t1.isEqual( t2 ) ) {
2587 t1.setIdentifier( null );
2588 t3.setTaxonomyCode( "ECOLI" );
2589 t3.setScientificName( "what" );
2590 t3.setCommonName( "something" );
2591 if ( !t1.isEqual( t3 ) ) {
2594 t1.setIdentifier( null );
2595 t1.setTaxonomyCode( "" );
2596 t4.setScientificName( "E. ColI" );
2597 t4.setCommonName( "something" );
2598 if ( !t1.isEqual( t4 ) ) {
2601 t4.setScientificName( "B. subtilis" );
2602 t4.setCommonName( "something" );
2603 if ( t1.isEqual( t4 ) ) {
2606 t1.setIdentifier( null );
2607 t1.setTaxonomyCode( "" );
2608 t1.setScientificName( "" );
2609 t5.setCommonName( "COLI" );
2610 if ( !t1.isEqual( t5 ) ) {
2613 t5.setCommonName( "vibrio" );
2614 if ( t1.isEqual( t5 ) ) {
2619 final Identifier id0 = new Identifier( "123", "pfam" );
2620 final Identifier id1 = ( Identifier ) id0.copy();
2621 if ( !id1.isEqual( id1 ) ) {
2624 if ( !id1.isEqual( id0 ) ) {
2627 if ( !id0.isEqual( id1 ) ) {
2634 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2635 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2636 if ( !pd1.isEqual( pd1 ) ) {
2639 if ( !pd1.isEqual( pd0 ) ) {
2644 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2645 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2646 if ( !pd3.isEqual( pd3 ) ) {
2649 if ( !pd2.isEqual( pd3 ) ) {
2652 if ( !pd0.isEqual( pd3 ) ) {
2657 // DomainArchitecture
2658 // ------------------
2659 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2660 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2661 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2662 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2663 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2664 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2669 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2670 if ( ds0.getNumberOfDomains() != 4 ) {
2673 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2674 if ( !ds0.isEqual( ds0 ) ) {
2677 if ( !ds0.isEqual( ds1 ) ) {
2680 if ( ds1.getNumberOfDomains() != 4 ) {
2683 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2688 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2689 if ( ds0.isEqual( ds2 ) ) {
2695 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2696 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2697 System.out.println( ds3.toNHX() );
2700 if ( ds3.getNumberOfDomains() != 3 ) {
2705 final Event e1 = new Event( Event.EventType.fusion );
2706 if ( e1.isDuplication() ) {
2709 if ( !e1.isFusion() ) {
2712 if ( !e1.asText().toString().equals( "fusion" ) ) {
2715 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2718 final Event e11 = new Event( Event.EventType.fusion );
2719 if ( !e11.isEqual( e1 ) ) {
2722 if ( !e11.toNHX().toString().equals( "" ) ) {
2725 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2726 if ( e2.isDuplication() ) {
2729 if ( !e2.isSpeciationOrDuplication() ) {
2732 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2735 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2738 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2741 if ( e11.isEqual( e2 ) ) {
2744 final Event e2c = ( Event ) e2.copy();
2745 if ( !e2c.isEqual( e2 ) ) {
2748 Event e3 = new Event( 1, 2, 3 );
2749 if ( e3.isDuplication() ) {
2752 if ( e3.isSpeciation() ) {
2755 if ( e3.isGeneLoss() ) {
2758 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2761 final Event e3c = ( Event ) e3.copy();
2762 final Event e3cc = ( Event ) e3c.copy();
2763 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2767 if ( !e3c.isEqual( e3cc ) ) {
2770 Event e4 = new Event( 1, 2, 3 );
2771 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2774 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2777 final Event e4c = ( Event ) e4.copy();
2779 final Event e4cc = ( Event ) e4c.copy();
2780 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2783 if ( !e4c.isEqual( e4cc ) ) {
2786 final Event e5 = new Event();
2787 if ( !e5.isUnassigned() ) {
2790 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2793 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2796 final Event e6 = new Event( 1, 0, 0 );
2797 if ( !e6.asText().toString().equals( "duplication" ) ) {
2800 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2803 final Event e7 = new Event( 0, 1, 0 );
2804 if ( !e7.asText().toString().equals( "speciation" ) ) {
2807 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2810 final Event e8 = new Event( 0, 0, 1 );
2811 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2814 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2818 catch ( final Exception e ) {
2819 e.printStackTrace( System.out );
2825 private static boolean testDeletionOfExternalNodes() {
2827 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2828 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2829 final PhylogenyWriter w = new PhylogenyWriter();
2830 if ( t0.isEmpty() ) {
2833 if ( t0.getNumberOfExternalNodes() != 1 ) {
2836 t0.deleteSubtree( t0.getNode( "A" ), false );
2837 if ( t0.getNumberOfExternalNodes() != 0 ) {
2840 if ( !t0.isEmpty() ) {
2843 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2844 if ( t1.getNumberOfExternalNodes() != 2 ) {
2847 t1.deleteSubtree( t1.getNode( "A" ), false );
2848 if ( t1.getNumberOfExternalNodes() != 1 ) {
2851 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2854 t1.deleteSubtree( t1.getNode( "B" ), false );
2855 if ( t1.getNumberOfExternalNodes() != 1 ) {
2858 t1.deleteSubtree( t1.getNode( "r" ), false );
2859 if ( !t1.isEmpty() ) {
2862 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2863 if ( t2.getNumberOfExternalNodes() != 3 ) {
2866 t2.deleteSubtree( t2.getNode( "B" ), false );
2867 if ( t2.getNumberOfExternalNodes() != 2 ) {
2870 t2.toNewHampshireX();
2871 PhylogenyNode n = t2.getNode( "A" );
2872 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2875 t2.deleteSubtree( t2.getNode( "A" ), false );
2876 if ( t2.getNumberOfExternalNodes() != 2 ) {
2879 t2.deleteSubtree( t2.getNode( "C" ), true );
2880 if ( t2.getNumberOfExternalNodes() != 1 ) {
2883 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2884 if ( t3.getNumberOfExternalNodes() != 4 ) {
2887 t3.deleteSubtree( t3.getNode( "B" ), true );
2888 if ( t3.getNumberOfExternalNodes() != 3 ) {
2891 n = t3.getNode( "A" );
2892 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2895 n = n.getNextExternalNode();
2896 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2899 t3.deleteSubtree( t3.getNode( "A" ), true );
2900 if ( t3.getNumberOfExternalNodes() != 2 ) {
2903 n = t3.getNode( "C" );
2904 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2907 t3.deleteSubtree( t3.getNode( "C" ), true );
2908 if ( t3.getNumberOfExternalNodes() != 1 ) {
2911 t3.deleteSubtree( t3.getNode( "D" ), true );
2912 if ( t3.getNumberOfExternalNodes() != 0 ) {
2915 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2916 if ( t4.getNumberOfExternalNodes() != 6 ) {
2919 t4.deleteSubtree( t4.getNode( "B2" ), true );
2920 if ( t4.getNumberOfExternalNodes() != 5 ) {
2923 String s = w.toNewHampshire( t4, false, true ).toString();
2924 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2927 t4.deleteSubtree( t4.getNode( "B11" ), true );
2928 if ( t4.getNumberOfExternalNodes() != 4 ) {
2931 t4.deleteSubtree( t4.getNode( "C" ), true );
2932 if ( t4.getNumberOfExternalNodes() != 3 ) {
2935 n = t4.getNode( "A" );
2936 n = n.getNextExternalNode();
2937 if ( !n.getName().equals( "B12" ) ) {
2940 n = n.getNextExternalNode();
2941 if ( !n.getName().equals( "D" ) ) {
2944 s = w.toNewHampshire( t4, false, true ).toString();
2945 if ( !s.equals( "((A,B12),D);" ) ) {
2948 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2949 t5.deleteSubtree( t5.getNode( "A" ), true );
2950 if ( t5.getNumberOfExternalNodes() != 5 ) {
2953 s = w.toNewHampshire( t5, false, true ).toString();
2954 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2957 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2958 t6.deleteSubtree( t6.getNode( "B11" ), true );
2959 if ( t6.getNumberOfExternalNodes() != 5 ) {
2962 s = w.toNewHampshire( t6, false, false ).toString();
2963 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2966 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2967 t7.deleteSubtree( t7.getNode( "B12" ), true );
2968 if ( t7.getNumberOfExternalNodes() != 5 ) {
2971 s = w.toNewHampshire( t7, false, true ).toString();
2972 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2975 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2976 t8.deleteSubtree( t8.getNode( "B2" ), true );
2977 if ( t8.getNumberOfExternalNodes() != 5 ) {
2980 s = w.toNewHampshire( t8, false, false ).toString();
2981 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2984 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2985 t9.deleteSubtree( t9.getNode( "C" ), true );
2986 if ( t9.getNumberOfExternalNodes() != 5 ) {
2989 s = w.toNewHampshire( t9, false, true ).toString();
2990 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2993 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2994 t10.deleteSubtree( t10.getNode( "D" ), true );
2995 if ( t10.getNumberOfExternalNodes() != 5 ) {
2998 s = w.toNewHampshire( t10, false, true ).toString();
2999 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3002 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3003 t11.deleteSubtree( t11.getNode( "A" ), true );
3004 if ( t11.getNumberOfExternalNodes() != 2 ) {
3007 s = w.toNewHampshire( t11, false, true ).toString();
3008 if ( !s.equals( "(B,C);" ) ) {
3011 t11.deleteSubtree( t11.getNode( "C" ), true );
3012 if ( t11.getNumberOfExternalNodes() != 1 ) {
3015 s = w.toNewHampshire( t11, false, false ).toString();
3016 if ( !s.equals( "B;" ) ) {
3019 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3020 t12.deleteSubtree( t12.getNode( "B2" ), true );
3021 if ( t12.getNumberOfExternalNodes() != 8 ) {
3024 s = w.toNewHampshire( t12, false, true ).toString();
3025 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3028 t12.deleteSubtree( t12.getNode( "B3" ), true );
3029 if ( t12.getNumberOfExternalNodes() != 7 ) {
3032 s = w.toNewHampshire( t12, false, true ).toString();
3033 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3036 t12.deleteSubtree( t12.getNode( "C3" ), true );
3037 if ( t12.getNumberOfExternalNodes() != 6 ) {
3040 s = w.toNewHampshire( t12, false, true ).toString();
3041 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3044 t12.deleteSubtree( t12.getNode( "A1" ), true );
3045 if ( t12.getNumberOfExternalNodes() != 5 ) {
3048 s = w.toNewHampshire( t12, false, true ).toString();
3049 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3052 t12.deleteSubtree( t12.getNode( "B1" ), true );
3053 if ( t12.getNumberOfExternalNodes() != 4 ) {
3056 s = w.toNewHampshire( t12, false, true ).toString();
3057 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3060 t12.deleteSubtree( t12.getNode( "A3" ), true );
3061 if ( t12.getNumberOfExternalNodes() != 3 ) {
3064 s = w.toNewHampshire( t12, false, true ).toString();
3065 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3068 t12.deleteSubtree( t12.getNode( "A2" ), true );
3069 if ( t12.getNumberOfExternalNodes() != 2 ) {
3072 s = w.toNewHampshire( t12, false, true ).toString();
3073 if ( !s.equals( "(C1,C2);" ) ) {
3076 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3077 t13.deleteSubtree( t13.getNode( "D" ), true );
3078 if ( t13.getNumberOfExternalNodes() != 4 ) {
3081 s = w.toNewHampshire( t13, false, true ).toString();
3082 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3085 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3086 t14.deleteSubtree( t14.getNode( "E" ), true );
3087 if ( t14.getNumberOfExternalNodes() != 5 ) {
3090 s = w.toNewHampshire( t14, false, true ).toString();
3091 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3094 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3095 t15.deleteSubtree( t15.getNode( "B2" ), true );
3096 if ( t15.getNumberOfExternalNodes() != 11 ) {
3099 t15.deleteSubtree( t15.getNode( "B1" ), true );
3100 if ( t15.getNumberOfExternalNodes() != 10 ) {
3103 t15.deleteSubtree( t15.getNode( "B3" ), true );
3104 if ( t15.getNumberOfExternalNodes() != 9 ) {
3107 t15.deleteSubtree( t15.getNode( "B4" ), true );
3108 if ( t15.getNumberOfExternalNodes() != 8 ) {
3111 t15.deleteSubtree( t15.getNode( "A1" ), true );
3112 if ( t15.getNumberOfExternalNodes() != 7 ) {
3115 t15.deleteSubtree( t15.getNode( "C4" ), true );
3116 if ( t15.getNumberOfExternalNodes() != 6 ) {
3120 catch ( final Exception e ) {
3121 e.printStackTrace( System.out );
3127 private static boolean testDescriptiveStatistics() {
3129 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3130 dss1.addValue( 82 );
3131 dss1.addValue( 78 );
3132 dss1.addValue( 70 );
3133 dss1.addValue( 58 );
3134 dss1.addValue( 42 );
3135 if ( dss1.getN() != 5 ) {
3138 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3141 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3144 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3147 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3150 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3153 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3156 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3159 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3162 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3165 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3168 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3171 dss1.addValue( 123 );
3172 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3175 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3178 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3181 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3182 dss2.addValue( -1.85 );
3183 dss2.addValue( 57.5 );
3184 dss2.addValue( 92.78 );
3185 dss2.addValue( 57.78 );
3186 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3189 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3192 final double[] a = dss2.getDataAsDoubleArray();
3193 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3196 dss2.addValue( -100 );
3197 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3200 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3203 final double[] ds = new double[ 14 ];
3218 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3219 if ( bins.length != 4 ) {
3222 if ( bins[ 0 ] != 2 ) {
3225 if ( bins[ 1 ] != 3 ) {
3228 if ( bins[ 2 ] != 4 ) {
3231 if ( bins[ 3 ] != 5 ) {
3234 final double[] ds1 = new double[ 9 ];
3244 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3245 if ( bins1.length != 4 ) {
3248 if ( bins1[ 0 ] != 2 ) {
3251 if ( bins1[ 1 ] != 3 ) {
3254 if ( bins1[ 2 ] != 0 ) {
3257 if ( bins1[ 3 ] != 4 ) {
3260 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3261 if ( bins1_1.length != 3 ) {
3264 if ( bins1_1[ 0 ] != 3 ) {
3267 if ( bins1_1[ 1 ] != 2 ) {
3270 if ( bins1_1[ 2 ] != 4 ) {
3273 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3274 if ( bins1_2.length != 3 ) {
3277 if ( bins1_2[ 0 ] != 2 ) {
3280 if ( bins1_2[ 1 ] != 2 ) {
3283 if ( bins1_2[ 2 ] != 2 ) {
3286 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3300 dss3.addValue( 10 );
3301 dss3.addValue( 10 );
3302 dss3.addValue( 10 );
3303 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3304 histo.toStringBuffer( 10, '=', 40, 5 );
3305 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3307 catch ( final Exception e ) {
3308 e.printStackTrace( System.out );
3314 private static boolean testDir( final String file ) {
3316 final File f = new File( file );
3317 if ( !f.exists() ) {
3320 if ( !f.isDirectory() ) {
3323 if ( !f.canRead() ) {
3327 catch ( final Exception e ) {
3333 private static boolean testDomainId() {
3335 final DomainId id1 = new DomainId( "a" );
3336 final DomainId id2 = new DomainId( "a" );
3337 final DomainId id3 = new DomainId( "A" );
3338 final DomainId id4 = new DomainId( "b" );
3339 if ( !id1.equals( id1 ) ) {
3342 if ( id1.getId().equals( "x" ) ) {
3345 if ( id1.getId().equals( null ) ) {
3348 if ( !id1.equals( id2 ) ) {
3351 if ( id1.equals( id3 ) ) {
3354 if ( id1.hashCode() != id1.hashCode() ) {
3357 if ( id1.hashCode() != id2.hashCode() ) {
3360 if ( id1.hashCode() == id3.hashCode() ) {
3363 if ( id1.compareTo( id1 ) != 0 ) {
3366 if ( id1.compareTo( id2 ) != 0 ) {
3369 if ( id1.compareTo( id3 ) != 0 ) {
3372 if ( id1.compareTo( id4 ) >= 0 ) {
3375 if ( id4.compareTo( id1 ) <= 0 ) {
3378 if ( !id4.getId().equals( "b" ) ) {
3381 final DomainId id5 = new DomainId( " C " );
3382 if ( !id5.getId().equals( "C" ) ) {
3385 if ( id5.equals( id1 ) ) {
3389 catch ( final Exception e ) {
3390 e.printStackTrace( System.out );
3396 private static boolean testEmblEntryRetrieval() {
3397 //The format for GenBank Accession numbers are:
3398 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3399 //Protein: 3 letters + 5 numerals
3400 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3401 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
3404 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3407 if ( !SequenceIdParser.parseGenbankAccessor( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3410 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
3413 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
3416 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
3419 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
3422 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
3425 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
3428 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
3431 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
3434 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
3437 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
3440 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
3446 private static boolean testExternalNodeRelatedMethods() {
3448 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3449 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3450 PhylogenyNode n = t1.getNode( "A" );
3451 n = n.getNextExternalNode();
3452 if ( !n.getName().equals( "B" ) ) {
3455 n = n.getNextExternalNode();
3456 if ( !n.getName().equals( "C" ) ) {
3459 n = n.getNextExternalNode();
3460 if ( !n.getName().equals( "D" ) ) {
3463 n = t1.getNode( "B" );
3464 while ( !n.isLastExternalNode() ) {
3465 n = n.getNextExternalNode();
3467 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3468 n = t2.getNode( "A" );
3469 n = n.getNextExternalNode();
3470 if ( !n.getName().equals( "B" ) ) {
3473 n = n.getNextExternalNode();
3474 if ( !n.getName().equals( "C" ) ) {
3477 n = n.getNextExternalNode();
3478 if ( !n.getName().equals( "D" ) ) {
3481 n = t2.getNode( "B" );
3482 while ( !n.isLastExternalNode() ) {
3483 n = n.getNextExternalNode();
3485 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3486 n = t3.getNode( "A" );
3487 n = n.getNextExternalNode();
3488 if ( !n.getName().equals( "B" ) ) {
3491 n = n.getNextExternalNode();
3492 if ( !n.getName().equals( "C" ) ) {
3495 n = n.getNextExternalNode();
3496 if ( !n.getName().equals( "D" ) ) {
3499 n = n.getNextExternalNode();
3500 if ( !n.getName().equals( "E" ) ) {
3503 n = n.getNextExternalNode();
3504 if ( !n.getName().equals( "F" ) ) {
3507 n = n.getNextExternalNode();
3508 if ( !n.getName().equals( "G" ) ) {
3511 n = n.getNextExternalNode();
3512 if ( !n.getName().equals( "H" ) ) {
3515 n = t3.getNode( "B" );
3516 while ( !n.isLastExternalNode() ) {
3517 n = n.getNextExternalNode();
3519 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3520 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3521 final PhylogenyNode node = iter.next();
3523 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3524 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3525 final PhylogenyNode node = iter.next();
3527 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3528 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3529 if ( !iter.next().getName().equals( "A" ) ) {
3532 if ( !iter.next().getName().equals( "B" ) ) {
3535 if ( !iter.next().getName().equals( "C" ) ) {
3538 if ( !iter.next().getName().equals( "D" ) ) {
3541 if ( !iter.next().getName().equals( "E" ) ) {
3544 if ( !iter.next().getName().equals( "F" ) ) {
3547 if ( iter.hasNext() ) {
3551 catch ( final Exception e ) {
3552 e.printStackTrace( System.out );
3558 private static boolean testExtractSNFromNodeName() {
3560 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3563 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3564 .equals( "Mus musculus musculus" ) ) {
3567 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3568 .equals( "Mus musculus musculus" ) ) {
3571 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3574 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3575 .equals( "Mus musculus" ) ) {
3579 catch ( final Exception e ) {
3580 e.printStackTrace( System.out );
3586 private static boolean testExtractTaxonomyCodeFromNodeName() {
3588 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3591 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3592 .equals( "SOYBN" ) ) {
3595 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3596 .equals( "ARATH" ) ) {
3599 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3600 .equals( "ARATH" ) ) {
3603 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3606 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3609 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3612 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3613 .equals( "SOYBN" ) ) {
3616 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3617 .equals( "SOYBN" ) ) {
3620 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3621 .equals( "SOYBN" ) ) {
3624 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3625 .equals( "SOYBN" ) ) {
3628 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3629 .equals( "SOYBN" ) ) {
3632 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3633 .equals( "SOYBN" ) ) {
3636 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3637 .equals( "SOYBN" ) ) {
3640 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3641 .equals( "SOYBN" ) ) {
3644 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3647 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3648 .equals( "SOYBN" ) ) {
3651 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3652 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3655 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3656 .equals( "9YX45" ) ) {
3659 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3660 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3661 .equals( "MOUSE" ) ) {
3664 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3665 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3666 .equals( "MOUSE" ) ) {
3669 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3670 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3671 .equals( "MOUSE" ) ) {
3674 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3675 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3678 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3679 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3682 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3683 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3686 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3687 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3690 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3691 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3694 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3695 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3698 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3699 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3702 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3703 .equals( "RAT" ) ) {
3706 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3707 .equals( "PIG" ) ) {
3711 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3712 .equals( "MOUSE" ) ) {
3715 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3716 .equals( "MOUSE" ) ) {
3719 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3723 catch ( final Exception e ) {
3724 e.printStackTrace( System.out );
3730 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3732 PhylogenyNode n = new PhylogenyNode();
3733 n.setName( "tr|B3RJ64" );
3734 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3737 n.setName( "tr.B3RJ64" );
3738 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3741 n.setName( "tr=B3RJ64" );
3742 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3745 n.setName( "tr-B3RJ64" );
3746 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3749 n.setName( "tr/B3RJ64" );
3750 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3753 n.setName( "tr\\B3RJ64" );
3754 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3757 n.setName( "tr_B3RJ64" );
3758 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3761 n.setName( " tr|B3RJ64 " );
3762 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3765 n.setName( "-tr|B3RJ64-" );
3766 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3769 n.setName( "-tr=B3RJ64-" );
3770 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3773 n.setName( "_tr=B3RJ64_" );
3774 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3777 n.setName( " tr_tr|B3RJ64_sp|123 " );
3778 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3781 n.setName( "sp|B3RJ64" );
3782 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3785 n.setName( "ssp|B3RJ64" );
3786 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3789 n.setName( "sp|B3RJ64C" );
3790 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3793 n.setName( "sp B3RJ64" );
3794 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3797 n.setName( "sp|B3RJ6X" );
3798 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3801 n.setName( "sp|B3RJ6" );
3802 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3805 n.setName( "K1PYK7_CRAGI" );
3806 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3809 n.setName( "K1PYK7_PEA" );
3810 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PEA" ) ) {
3813 n.setName( "K1PYK7_RAT" );
3814 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_RAT" ) ) {
3817 n.setName( "K1PYK7_PIG" );
3818 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3821 n.setName( "~K1PYK7_PIG~" );
3822 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3825 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3826 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3829 n.setName( "K1PYKX_CRAGI" );
3830 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3833 n.setName( "XXXXX_CRAGI" );
3834 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "XXXXX_CRAGI" ) ) {
3837 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3838 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "H3IB65" ) ) {
3841 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3842 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3845 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3846 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "Q86U06" ) ) {
3849 n = new PhylogenyNode();
3850 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3851 seq.setSymbol( "K1PYK7_CRAGI" );
3852 n.getNodeData().addSequence( seq );
3853 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3856 seq.setSymbol( "tr|B3RJ64" );
3857 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3860 n = new PhylogenyNode();
3861 seq = new org.forester.phylogeny.data.Sequence();
3862 seq.setName( "K1PYK7_CRAGI" );
3863 n.getNodeData().addSequence( seq );
3864 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3867 seq.setName( "tr|B3RJ64" );
3868 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3871 n = new PhylogenyNode();
3872 seq = new org.forester.phylogeny.data.Sequence();
3873 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3874 n.getNodeData().addSequence( seq );
3875 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK8_CRAGI" ) ) {
3878 n = new PhylogenyNode();
3879 seq = new org.forester.phylogeny.data.Sequence();
3880 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3881 n.getNodeData().addSequence( seq );
3882 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3886 n = new PhylogenyNode();
3887 n.setName( "ACP19736" );
3888 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3891 n = new PhylogenyNode();
3892 n.setName( "_ACP19736_" );
3893 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3897 catch ( final Exception e ) {
3898 e.printStackTrace( System.out );
3904 private static boolean testFastaParser() {
3906 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3909 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3912 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3913 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3916 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3919 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3922 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3925 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3928 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3932 catch ( final Exception e ) {
3933 e.printStackTrace();
3939 private static boolean testGeneralMsaParser() {
3941 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3942 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3943 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3944 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3945 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3946 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3947 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3948 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3949 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3952 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3955 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3958 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3961 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3964 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3967 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3970 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3973 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3976 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3979 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3982 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3985 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3986 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3989 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3992 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3995 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3996 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3999 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4002 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4005 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4006 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4009 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4012 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4016 catch ( final Exception e ) {
4017 e.printStackTrace();
4023 private static boolean testGeneralTable() {
4025 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4026 t0.setValue( 3, 2, "23" );
4027 t0.setValue( 10, 1, "error" );
4028 t0.setValue( 10, 1, "110" );
4029 t0.setValue( 9, 1, "19" );
4030 t0.setValue( 1, 10, "101" );
4031 t0.setValue( 10, 10, "1010" );
4032 t0.setValue( 100, 10, "10100" );
4033 t0.setValue( 0, 0, "00" );
4034 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4037 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4040 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4043 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4046 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4049 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4052 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4055 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4058 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4061 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4062 t1.setValue( "3", "2", "23" );
4063 t1.setValue( "10", "1", "error" );
4064 t1.setValue( "10", "1", "110" );
4065 t1.setValue( "9", "1", "19" );
4066 t1.setValue( "1", "10", "101" );
4067 t1.setValue( "10", "10", "1010" );
4068 t1.setValue( "100", "10", "10100" );
4069 t1.setValue( "0", "0", "00" );
4070 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4071 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4074 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4077 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4080 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4083 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4086 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4089 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4092 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4095 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4098 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4102 catch ( final Exception e ) {
4103 e.printStackTrace( System.out );
4109 private static boolean testGetDistance() {
4111 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4112 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",
4113 new NHXParser() )[ 0 ];
4114 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4117 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4120 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4123 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4126 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4129 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4132 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4135 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4138 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4141 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4144 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4147 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4150 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4153 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4156 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4159 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4162 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4165 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4168 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4171 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4174 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4177 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4180 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4183 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4186 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4189 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4192 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4195 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4198 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4201 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4204 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4207 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",
4208 new NHXParser() )[ 0 ];
4209 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4212 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4215 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4218 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4221 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4224 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4227 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4230 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4233 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4236 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4239 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4243 catch ( final Exception e ) {
4244 e.printStackTrace( System.out );
4250 private static boolean testGetLCA() {
4252 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4253 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4254 new NHXParser() )[ 0 ];
4255 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4256 if ( !A.getName().equals( "A" ) ) {
4259 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4260 if ( !gh.getName().equals( "gh" ) ) {
4263 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4264 if ( !ab.getName().equals( "ab" ) ) {
4267 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4268 if ( !ab2.getName().equals( "ab" ) ) {
4271 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4272 if ( !gh2.getName().equals( "gh" ) ) {
4275 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4276 if ( !gh3.getName().equals( "gh" ) ) {
4279 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4280 if ( !abc.getName().equals( "abc" ) ) {
4283 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4284 if ( !abc2.getName().equals( "abc" ) ) {
4287 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4288 if ( !abcd.getName().equals( "abcd" ) ) {
4291 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4292 if ( !abcd2.getName().equals( "abcd" ) ) {
4295 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4296 if ( !abcdef.getName().equals( "abcdef" ) ) {
4299 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4300 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4303 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4304 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4307 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4308 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4311 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4312 if ( !abcde.getName().equals( "abcde" ) ) {
4315 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4316 if ( !abcde2.getName().equals( "abcde" ) ) {
4319 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4320 if ( !r.getName().equals( "abcdefgh" ) ) {
4323 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4324 if ( !r2.getName().equals( "abcdefgh" ) ) {
4327 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4328 if ( !r3.getName().equals( "abcdefgh" ) ) {
4331 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4332 if ( !abcde3.getName().equals( "abcde" ) ) {
4335 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4336 if ( !abcde4.getName().equals( "abcde" ) ) {
4339 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4340 if ( !ab3.getName().equals( "ab" ) ) {
4343 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4344 if ( !ab4.getName().equals( "ab" ) ) {
4347 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4348 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4349 if ( !cd.getName().equals( "cd" ) ) {
4352 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4353 if ( !cd2.getName().equals( "cd" ) ) {
4356 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4357 if ( !cde.getName().equals( "cde" ) ) {
4360 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4361 if ( !cde2.getName().equals( "cde" ) ) {
4364 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4365 if ( !cdef.getName().equals( "cdef" ) ) {
4368 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4369 if ( !cdef2.getName().equals( "cdef" ) ) {
4372 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4373 if ( !cdef3.getName().equals( "cdef" ) ) {
4376 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4377 if ( !rt.getName().equals( "r" ) ) {
4380 final Phylogeny p3 = factory
4381 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4382 new NHXParser() )[ 0 ];
4383 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4384 if ( !bc_3.getName().equals( "bc" ) ) {
4387 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4388 if ( !ac_3.getName().equals( "abc" ) ) {
4391 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4392 if ( !ad_3.getName().equals( "abcde" ) ) {
4395 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4396 if ( !af_3.getName().equals( "abcdef" ) ) {
4399 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4400 if ( !ag_3.getName().equals( "" ) ) {
4403 if ( !ag_3.isRoot() ) {
4406 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4407 if ( !al_3.getName().equals( "" ) ) {
4410 if ( !al_3.isRoot() ) {
4413 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4414 if ( !kl_3.getName().equals( "" ) ) {
4417 if ( !kl_3.isRoot() ) {
4420 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4421 if ( !fl_3.getName().equals( "" ) ) {
4424 if ( !fl_3.isRoot() ) {
4427 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4428 if ( !gk_3.getName().equals( "ghijk" ) ) {
4431 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4432 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4433 if ( !r_4.getName().equals( "r" ) ) {
4436 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4437 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4438 if ( !r_5.getName().equals( "root" ) ) {
4441 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4442 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4443 if ( !r_6.getName().equals( "rot" ) ) {
4446 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4447 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4448 if ( !r_7.getName().equals( "rott" ) ) {
4452 catch ( final Exception e ) {
4453 e.printStackTrace( System.out );
4459 private static boolean testGetLCA2() {
4461 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4462 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4463 PhylogenyMethods.preOrderReId( p_a );
4464 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4465 p_a.getNode( "a" ) );
4466 if ( !p_a_1.getName().equals( "a" ) ) {
4469 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4470 PhylogenyMethods.preOrderReId( p_b );
4471 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4472 p_b.getNode( "a" ) );
4473 if ( !p_b_1.getName().equals( "b" ) ) {
4476 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4477 p_b.getNode( "b" ) );
4478 if ( !p_b_2.getName().equals( "b" ) ) {
4481 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4482 PhylogenyMethods.preOrderReId( p_c );
4483 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4484 p_c.getNode( "a" ) );
4485 if ( !p_c_1.getName().equals( "b" ) ) {
4488 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4489 p_c.getNode( "c" ) );
4490 if ( !p_c_2.getName().equals( "c" ) ) {
4491 System.out.println( p_c_2.getName() );
4495 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4496 p_c.getNode( "b" ) );
4497 if ( !p_c_3.getName().equals( "b" ) ) {
4500 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4501 p_c.getNode( "a" ) );
4502 if ( !p_c_4.getName().equals( "c" ) ) {
4505 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4506 new NHXParser() )[ 0 ];
4507 PhylogenyMethods.preOrderReId( p1 );
4508 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4509 p1.getNode( "A" ) );
4510 if ( !A.getName().equals( "A" ) ) {
4513 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4514 p1.getNode( "gh" ) );
4515 if ( !gh.getName().equals( "gh" ) ) {
4518 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4519 p1.getNode( "B" ) );
4520 if ( !ab.getName().equals( "ab" ) ) {
4523 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4524 p1.getNode( "A" ) );
4525 if ( !ab2.getName().equals( "ab" ) ) {
4528 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4529 p1.getNode( "G" ) );
4530 if ( !gh2.getName().equals( "gh" ) ) {
4533 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4534 p1.getNode( "H" ) );
4535 if ( !gh3.getName().equals( "gh" ) ) {
4538 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4539 p1.getNode( "A" ) );
4540 if ( !abc.getName().equals( "abc" ) ) {
4543 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4544 p1.getNode( "C" ) );
4545 if ( !abc2.getName().equals( "abc" ) ) {
4548 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4549 p1.getNode( "D" ) );
4550 if ( !abcd.getName().equals( "abcd" ) ) {
4553 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4554 p1.getNode( "A" ) );
4555 if ( !abcd2.getName().equals( "abcd" ) ) {
4558 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4559 p1.getNode( "F" ) );
4560 if ( !abcdef.getName().equals( "abcdef" ) ) {
4563 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4564 p1.getNode( "A" ) );
4565 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4568 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4569 p1.getNode( "F" ) );
4570 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4573 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4574 p1.getNode( "ab" ) );
4575 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4578 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4579 p1.getNode( "E" ) );
4580 if ( !abcde.getName().equals( "abcde" ) ) {
4583 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4584 p1.getNode( "A" ) );
4585 if ( !abcde2.getName().equals( "abcde" ) ) {
4588 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4589 p1.getNode( "abcdefgh" ) );
4590 if ( !r.getName().equals( "abcdefgh" ) ) {
4593 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4594 p1.getNode( "H" ) );
4595 if ( !r2.getName().equals( "abcdefgh" ) ) {
4598 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4599 p1.getNode( "A" ) );
4600 if ( !r3.getName().equals( "abcdefgh" ) ) {
4603 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4604 p1.getNode( "abcde" ) );
4605 if ( !abcde3.getName().equals( "abcde" ) ) {
4608 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4609 p1.getNode( "E" ) );
4610 if ( !abcde4.getName().equals( "abcde" ) ) {
4613 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4614 p1.getNode( "B" ) );
4615 if ( !ab3.getName().equals( "ab" ) ) {
4618 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4619 p1.getNode( "ab" ) );
4620 if ( !ab4.getName().equals( "ab" ) ) {
4623 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4624 PhylogenyMethods.preOrderReId( p2 );
4625 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4626 p2.getNode( "d" ) );
4627 if ( !cd.getName().equals( "cd" ) ) {
4630 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4631 p2.getNode( "c" ) );
4632 if ( !cd2.getName().equals( "cd" ) ) {
4635 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4636 p2.getNode( "e" ) );
4637 if ( !cde.getName().equals( "cde" ) ) {
4640 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4641 p2.getNode( "c" ) );
4642 if ( !cde2.getName().equals( "cde" ) ) {
4645 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4646 p2.getNode( "f" ) );
4647 if ( !cdef.getName().equals( "cdef" ) ) {
4650 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4651 p2.getNode( "f" ) );
4652 if ( !cdef2.getName().equals( "cdef" ) ) {
4655 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4656 p2.getNode( "d" ) );
4657 if ( !cdef3.getName().equals( "cdef" ) ) {
4660 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4661 p2.getNode( "a" ) );
4662 if ( !rt.getName().equals( "r" ) ) {
4665 final Phylogeny p3 = factory
4666 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4667 new NHXParser() )[ 0 ];
4668 PhylogenyMethods.preOrderReId( p3 );
4669 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4670 p3.getNode( "c" ) );
4671 if ( !bc_3.getName().equals( "bc" ) ) {
4674 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4675 p3.getNode( "c" ) );
4676 if ( !ac_3.getName().equals( "abc" ) ) {
4679 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4680 p3.getNode( "d" ) );
4681 if ( !ad_3.getName().equals( "abcde" ) ) {
4684 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4685 p3.getNode( "f" ) );
4686 if ( !af_3.getName().equals( "abcdef" ) ) {
4689 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4690 p3.getNode( "g" ) );
4691 if ( !ag_3.getName().equals( "" ) ) {
4694 if ( !ag_3.isRoot() ) {
4697 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4698 p3.getNode( "l" ) );
4699 if ( !al_3.getName().equals( "" ) ) {
4702 if ( !al_3.isRoot() ) {
4705 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4706 p3.getNode( "l" ) );
4707 if ( !kl_3.getName().equals( "" ) ) {
4710 if ( !kl_3.isRoot() ) {
4713 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4714 p3.getNode( "l" ) );
4715 if ( !fl_3.getName().equals( "" ) ) {
4718 if ( !fl_3.isRoot() ) {
4721 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4722 p3.getNode( "k" ) );
4723 if ( !gk_3.getName().equals( "ghijk" ) ) {
4726 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4727 PhylogenyMethods.preOrderReId( p4 );
4728 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4729 p4.getNode( "c" ) );
4730 if ( !r_4.getName().equals( "r" ) ) {
4733 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4734 PhylogenyMethods.preOrderReId( p5 );
4735 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4736 p5.getNode( "c" ) );
4737 if ( !r_5.getName().equals( "root" ) ) {
4740 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4741 PhylogenyMethods.preOrderReId( p6 );
4742 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4743 p6.getNode( "a" ) );
4744 if ( !r_6.getName().equals( "rot" ) ) {
4747 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4748 PhylogenyMethods.preOrderReId( p7 );
4749 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4750 p7.getNode( "e" ) );
4751 if ( !r_7.getName().equals( "rott" ) ) {
4754 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4755 p7.getNode( "a" ) );
4756 if ( !r_71.getName().equals( "rott" ) ) {
4759 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4760 p7.getNode( "rott" ) );
4761 if ( !r_72.getName().equals( "rott" ) ) {
4764 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4765 p7.getNode( "a" ) );
4766 if ( !r_73.getName().equals( "rott" ) ) {
4769 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4770 p7.getNode( "rott" ) );
4771 if ( !r_74.getName().equals( "rott" ) ) {
4774 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4775 p7.getNode( "e" ) );
4776 if ( !r_75.getName().equals( "e" ) ) {
4780 catch ( final Exception e ) {
4781 e.printStackTrace( System.out );
4787 private static boolean testHmmscanOutputParser() {
4788 final String test_dir = Test.PATH_TO_TEST_DATA;
4790 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4791 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4793 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4794 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4795 final List<Protein> proteins = parser2.parse();
4796 if ( parser2.getProteinsEncountered() != 4 ) {
4799 if ( proteins.size() != 4 ) {
4802 if ( parser2.getDomainsEncountered() != 69 ) {
4805 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4808 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4811 final Protein p1 = proteins.get( 0 );
4812 if ( p1.getNumberOfProteinDomains() != 15 ) {
4815 if ( p1.getLength() != 850 ) {
4818 final Protein p2 = proteins.get( 1 );
4819 if ( p2.getNumberOfProteinDomains() != 51 ) {
4822 if ( p2.getLength() != 1291 ) {
4825 final Protein p3 = proteins.get( 2 );
4826 if ( p3.getNumberOfProteinDomains() != 2 ) {
4829 final Protein p4 = proteins.get( 3 );
4830 if ( p4.getNumberOfProteinDomains() != 1 ) {
4833 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4836 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4839 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4842 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4845 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4848 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4851 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4854 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4857 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4861 catch ( final Exception e ) {
4862 e.printStackTrace( System.out );
4868 private static boolean testLastExternalNodeMethods() {
4870 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4871 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4872 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4873 final PhylogenyNode n1 = t0.getNode( "A" );
4874 if ( n1.isLastExternalNode() ) {
4877 final PhylogenyNode n2 = t0.getNode( "B" );
4878 if ( n2.isLastExternalNode() ) {
4881 final PhylogenyNode n3 = t0.getNode( "C" );
4882 if ( n3.isLastExternalNode() ) {
4885 final PhylogenyNode n4 = t0.getNode( "D" );
4886 if ( !n4.isLastExternalNode() ) {
4890 catch ( final Exception e ) {
4891 e.printStackTrace( System.out );
4897 private static boolean testLevelOrderIterator() {
4899 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4900 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4901 PhylogenyNodeIterator it0;
4902 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4905 for( it0.reset(); it0.hasNext(); ) {
4908 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4909 if ( !it.next().getName().equals( "r" ) ) {
4912 if ( !it.next().getName().equals( "ab" ) ) {
4915 if ( !it.next().getName().equals( "cd" ) ) {
4918 if ( !it.next().getName().equals( "A" ) ) {
4921 if ( !it.next().getName().equals( "B" ) ) {
4924 if ( !it.next().getName().equals( "C" ) ) {
4927 if ( !it.next().getName().equals( "D" ) ) {
4930 if ( it.hasNext() ) {
4933 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",
4934 new NHXParser() )[ 0 ];
4935 PhylogenyNodeIterator it2;
4936 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4939 for( it2.reset(); it2.hasNext(); ) {
4942 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4943 if ( !it3.next().getName().equals( "r" ) ) {
4946 if ( !it3.next().getName().equals( "abc" ) ) {
4949 if ( !it3.next().getName().equals( "defg" ) ) {
4952 if ( !it3.next().getName().equals( "A" ) ) {
4955 if ( !it3.next().getName().equals( "B" ) ) {
4958 if ( !it3.next().getName().equals( "C" ) ) {
4961 if ( !it3.next().getName().equals( "D" ) ) {
4964 if ( !it3.next().getName().equals( "E" ) ) {
4967 if ( !it3.next().getName().equals( "F" ) ) {
4970 if ( !it3.next().getName().equals( "G" ) ) {
4973 if ( !it3.next().getName().equals( "1" ) ) {
4976 if ( !it3.next().getName().equals( "2" ) ) {
4979 if ( !it3.next().getName().equals( "3" ) ) {
4982 if ( !it3.next().getName().equals( "4" ) ) {
4985 if ( !it3.next().getName().equals( "5" ) ) {
4988 if ( !it3.next().getName().equals( "6" ) ) {
4991 if ( !it3.next().getName().equals( "f1" ) ) {
4994 if ( !it3.next().getName().equals( "f2" ) ) {
4997 if ( !it3.next().getName().equals( "f3" ) ) {
5000 if ( !it3.next().getName().equals( "a" ) ) {
5003 if ( !it3.next().getName().equals( "b" ) ) {
5006 if ( !it3.next().getName().equals( "f21" ) ) {
5009 if ( !it3.next().getName().equals( "X" ) ) {
5012 if ( !it3.next().getName().equals( "Y" ) ) {
5015 if ( !it3.next().getName().equals( "Z" ) ) {
5018 if ( it3.hasNext() ) {
5021 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5022 PhylogenyNodeIterator it4;
5023 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5026 for( it4.reset(); it4.hasNext(); ) {
5029 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5030 if ( !it5.next().getName().equals( "r" ) ) {
5033 if ( !it5.next().getName().equals( "A" ) ) {
5036 if ( !it5.next().getName().equals( "B" ) ) {
5039 if ( !it5.next().getName().equals( "C" ) ) {
5042 if ( !it5.next().getName().equals( "D" ) ) {
5045 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5046 PhylogenyNodeIterator it6;
5047 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5050 for( it6.reset(); it6.hasNext(); ) {
5053 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5054 if ( !it7.next().getName().equals( "A" ) ) {
5057 if ( it.hasNext() ) {
5061 catch ( final Exception e ) {
5062 e.printStackTrace( System.out );
5068 private static boolean testMafft( final String path ) {
5070 final List<String> opts = new ArrayList<String>();
5071 opts.add( "--maxiterate" );
5073 opts.add( "--localpair" );
5074 opts.add( "--quiet" );
5076 final MsaInferrer mafft = Mafft.createInstance( path );
5077 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5078 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5081 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5085 catch ( final Exception e ) {
5086 e.printStackTrace( System.out );
5092 private static boolean testMidpointrooting() {
5094 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5095 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5096 PhylogenyMethods.midpointRoot( t0 );
5097 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5100 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5103 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5107 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",
5108 new NHXParser() )[ 0 ];
5109 if ( !t1.isRooted() ) {
5112 PhylogenyMethods.midpointRoot( t1 );
5113 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5116 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5119 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5122 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5125 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5128 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5131 t1.reRoot( t1.getNode( "A" ) );
5132 PhylogenyMethods.midpointRoot( t1 );
5133 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5136 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5139 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5142 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5145 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5149 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5153 catch ( final Exception e ) {
5154 e.printStackTrace( System.out );
5160 private static boolean testMsaQualityMethod() {
5162 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5163 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5164 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5165 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5166 final List<Sequence> l = new ArrayList<Sequence>();
5171 final Msa msa = BasicMsa.createInstance( l );
5172 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5175 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5178 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5181 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5185 catch ( final Exception e ) {
5186 e.printStackTrace( System.out );
5192 private static boolean testNextNodeWithCollapsing() {
5194 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5196 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5197 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5198 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5199 t0.getNode( "cd" ).setCollapse( true );
5200 t0.getNode( "cde" ).setCollapse( true );
5201 n = t0.getFirstExternalNode();
5202 while ( n != null ) {
5204 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5206 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5209 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5212 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5215 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5218 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5221 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5225 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5226 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5227 t1.getNode( "ab" ).setCollapse( true );
5228 t1.getNode( "cd" ).setCollapse( true );
5229 t1.getNode( "cde" ).setCollapse( true );
5230 n = t1.getNode( "ab" );
5231 ext = new ArrayList<PhylogenyNode>();
5232 while ( n != null ) {
5234 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5236 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5239 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5242 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5245 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5248 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5254 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5255 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5256 t2.getNode( "ab" ).setCollapse( true );
5257 t2.getNode( "cd" ).setCollapse( true );
5258 t2.getNode( "cde" ).setCollapse( true );
5259 t2.getNode( "c" ).setCollapse( true );
5260 t2.getNode( "d" ).setCollapse( true );
5261 t2.getNode( "e" ).setCollapse( true );
5262 t2.getNode( "gh" ).setCollapse( true );
5263 n = t2.getNode( "ab" );
5264 ext = new ArrayList<PhylogenyNode>();
5265 while ( n != null ) {
5267 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5269 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5272 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5275 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5278 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5284 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5285 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5286 t3.getNode( "ab" ).setCollapse( true );
5287 t3.getNode( "cd" ).setCollapse( true );
5288 t3.getNode( "cde" ).setCollapse( true );
5289 t3.getNode( "c" ).setCollapse( true );
5290 t3.getNode( "d" ).setCollapse( true );
5291 t3.getNode( "e" ).setCollapse( true );
5292 t3.getNode( "gh" ).setCollapse( true );
5293 t3.getNode( "fgh" ).setCollapse( true );
5294 n = t3.getNode( "ab" );
5295 ext = new ArrayList<PhylogenyNode>();
5296 while ( n != null ) {
5298 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5300 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5303 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5306 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5312 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5313 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5314 t4.getNode( "ab" ).setCollapse( true );
5315 t4.getNode( "cd" ).setCollapse( true );
5316 t4.getNode( "cde" ).setCollapse( true );
5317 t4.getNode( "c" ).setCollapse( true );
5318 t4.getNode( "d" ).setCollapse( true );
5319 t4.getNode( "e" ).setCollapse( true );
5320 t4.getNode( "gh" ).setCollapse( true );
5321 t4.getNode( "fgh" ).setCollapse( true );
5322 t4.getNode( "abcdefgh" ).setCollapse( true );
5323 n = t4.getNode( "abcdefgh" );
5324 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5329 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5330 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5332 n = t5.getFirstExternalNode();
5333 while ( n != null ) {
5335 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5337 if ( ext.size() != 8 ) {
5340 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5343 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5346 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5349 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5352 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5355 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5358 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5361 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5366 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5367 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5369 t6.getNode( "ab" ).setCollapse( true );
5370 n = t6.getNode( "ab" );
5371 while ( n != null ) {
5373 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5375 if ( ext.size() != 7 ) {
5378 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5381 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5384 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5387 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5390 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5393 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5396 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5401 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5402 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5404 t7.getNode( "cd" ).setCollapse( true );
5405 n = t7.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" ) ) {
5422 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5425 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5428 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5431 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5436 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5437 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5439 t8.getNode( "cd" ).setCollapse( true );
5440 t8.getNode( "c" ).setCollapse( true );
5441 t8.getNode( "d" ).setCollapse( true );
5442 n = t8.getNode( "a" );
5443 while ( n != null ) {
5445 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5447 if ( ext.size() != 7 ) {
5450 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5453 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5456 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5457 System.out.println( "2 fail" );
5460 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5463 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5466 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5469 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5474 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5475 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5477 t9.getNode( "gh" ).setCollapse( true );
5478 n = t9.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 sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5510 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5512 t10.getNode( "gh" ).setCollapse( true );
5513 t10.getNode( "g" ).setCollapse( true );
5514 t10.getNode( "h" ).setCollapse( true );
5515 n = t10.getNode( "a" );
5516 while ( n != null ) {
5518 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5520 if ( ext.size() != 7 ) {
5523 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5526 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5529 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5532 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5535 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5538 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5541 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5546 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5547 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5549 t11.getNode( "gh" ).setCollapse( true );
5550 t11.getNode( "fgh" ).setCollapse( true );
5551 n = t11.getNode( "a" );
5552 while ( n != null ) {
5554 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5556 if ( ext.size() != 6 ) {
5559 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5562 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5565 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5568 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5571 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5574 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5579 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5580 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5582 t12.getNode( "gh" ).setCollapse( true );
5583 t12.getNode( "fgh" ).setCollapse( true );
5584 t12.getNode( "g" ).setCollapse( true );
5585 t12.getNode( "h" ).setCollapse( true );
5586 t12.getNode( "f" ).setCollapse( true );
5587 n = t12.getNode( "a" );
5588 while ( n != null ) {
5590 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5592 if ( ext.size() != 6 ) {
5595 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5598 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5601 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5604 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5607 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5610 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5615 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5616 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5618 t13.getNode( "ab" ).setCollapse( true );
5619 t13.getNode( "b" ).setCollapse( true );
5620 t13.getNode( "fgh" ).setCollapse( true );
5621 t13.getNode( "gh" ).setCollapse( true );
5622 n = t13.getNode( "ab" );
5623 while ( n != null ) {
5625 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5627 if ( ext.size() != 5 ) {
5630 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5633 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5636 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5639 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5642 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5647 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5648 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5650 t14.getNode( "ab" ).setCollapse( true );
5651 t14.getNode( "a" ).setCollapse( true );
5652 t14.getNode( "fgh" ).setCollapse( true );
5653 t14.getNode( "gh" ).setCollapse( true );
5654 n = t14.getNode( "ab" );
5655 while ( n != null ) {
5657 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5659 if ( ext.size() != 5 ) {
5662 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5665 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5668 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5671 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5674 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5679 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" );
5680 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5682 t15.getNode( "ab" ).setCollapse( true );
5683 t15.getNode( "a" ).setCollapse( true );
5684 t15.getNode( "fgh" ).setCollapse( true );
5685 t15.getNode( "gh" ).setCollapse( true );
5686 n = t15.getNode( "ab" );
5687 while ( n != null ) {
5689 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5691 if ( ext.size() != 6 ) {
5694 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5697 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5700 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5703 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5706 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5709 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5714 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" );
5715 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5717 t16.getNode( "ab" ).setCollapse( true );
5718 t16.getNode( "a" ).setCollapse( true );
5719 t16.getNode( "fgh" ).setCollapse( true );
5720 t16.getNode( "gh" ).setCollapse( true );
5721 t16.getNode( "cd" ).setCollapse( true );
5722 t16.getNode( "cde" ).setCollapse( true );
5723 t16.getNode( "d" ).setCollapse( true );
5724 t16.getNode( "x" ).setCollapse( true );
5725 n = t16.getNode( "ab" );
5726 while ( n != null ) {
5728 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5730 if ( ext.size() != 4 ) {
5733 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5736 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5739 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5742 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5746 catch ( final Exception e ) {
5747 e.printStackTrace( System.out );
5753 private static boolean testNexusCharactersParsing() {
5755 final NexusCharactersParser parser = new NexusCharactersParser();
5756 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5758 String[] labels = parser.getCharStateLabels();
5759 if ( labels.length != 7 ) {
5762 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5765 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5768 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5771 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5774 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5777 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5780 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5783 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5785 labels = parser.getCharStateLabels();
5786 if ( labels.length != 7 ) {
5789 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5792 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5795 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5798 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5801 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5804 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5807 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5811 catch ( final Exception e ) {
5812 e.printStackTrace( System.out );
5818 private static boolean testNexusMatrixParsing() {
5820 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5821 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5823 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5824 if ( m.getNumberOfCharacters() != 9 ) {
5827 if ( m.getNumberOfIdentifiers() != 5 ) {
5830 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5833 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5836 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5839 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5842 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5845 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5848 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5851 // if ( labels.length != 7 ) {
5854 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5857 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5860 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5863 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5866 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5869 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5872 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5875 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5877 // labels = parser.getCharStateLabels();
5878 // if ( labels.length != 7 ) {
5881 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5884 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5887 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5890 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5893 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5896 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5899 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5903 catch ( final Exception e ) {
5904 e.printStackTrace( System.out );
5910 private static boolean testNexusTreeParsing() {
5912 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5913 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5914 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5915 if ( phylogenies.length != 1 ) {
5918 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5921 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5925 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5926 if ( phylogenies.length != 1 ) {
5929 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5932 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5936 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5937 if ( phylogenies.length != 1 ) {
5940 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5943 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5946 if ( phylogenies[ 0 ].isRooted() ) {
5950 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5951 if ( phylogenies.length != 18 ) {
5954 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5957 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5960 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5963 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5966 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5969 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5972 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5975 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5978 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5981 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5984 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5987 if ( phylogenies[ 8 ].isRooted() ) {
5990 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5993 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5996 if ( !phylogenies[ 9 ].isRooted() ) {
5999 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
6002 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
6005 if ( !phylogenies[ 10 ].isRooted() ) {
6008 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
6011 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
6014 if ( phylogenies[ 11 ].isRooted() ) {
6017 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
6020 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
6023 if ( !phylogenies[ 12 ].isRooted() ) {
6026 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
6029 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
6032 if ( !phylogenies[ 13 ].isRooted() ) {
6035 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
6038 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
6041 if ( !phylogenies[ 14 ].isRooted() ) {
6044 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
6047 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
6050 if ( phylogenies[ 15 ].isRooted() ) {
6053 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
6056 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6059 if ( !phylogenies[ 16 ].isRooted() ) {
6062 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6065 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6068 if ( phylogenies[ 17 ].isRooted() ) {
6071 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6075 catch ( final Exception e ) {
6076 e.printStackTrace( System.out );
6082 private static boolean testNexusTreeParsingIterating() {
6084 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6085 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6086 if ( !p.hasNext() ) {
6089 Phylogeny phy = p.next();
6090 if ( phy == null ) {
6093 if ( phy.getNumberOfExternalNodes() != 25 ) {
6096 if ( !phy.getName().equals( "" ) ) {
6099 if ( p.hasNext() ) {
6103 if ( phy != null ) {
6108 if ( !p.hasNext() ) {
6112 if ( phy == null ) {
6115 if ( phy.getNumberOfExternalNodes() != 25 ) {
6118 if ( !phy.getName().equals( "" ) ) {
6121 if ( p.hasNext() ) {
6125 if ( phy != null ) {
6129 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6130 if ( !p.hasNext() ) {
6134 if ( phy == null ) {
6137 if ( phy.getNumberOfExternalNodes() != 10 ) {
6140 if ( !phy.getName().equals( "name" ) ) {
6143 if ( p.hasNext() ) {
6147 if ( phy != null ) {
6152 if ( !p.hasNext() ) {
6156 if ( phy == null ) {
6159 if ( phy.getNumberOfExternalNodes() != 10 ) {
6162 if ( !phy.getName().equals( "name" ) ) {
6165 if ( p.hasNext() ) {
6169 if ( phy != null ) {
6173 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6174 if ( !p.hasNext() ) {
6178 if ( phy == null ) {
6181 if ( phy.getNumberOfExternalNodes() != 3 ) {
6184 if ( !phy.getName().equals( "" ) ) {
6187 if ( phy.isRooted() ) {
6190 if ( p.hasNext() ) {
6194 if ( phy != null ) {
6199 if ( !p.hasNext() ) {
6203 if ( phy == null ) {
6206 if ( phy.getNumberOfExternalNodes() != 3 ) {
6209 if ( !phy.getName().equals( "" ) ) {
6212 if ( p.hasNext() ) {
6216 if ( phy != null ) {
6220 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6221 // if ( phylogenies.length != 18 ) {
6225 if ( !p.hasNext() ) {
6229 if ( phy == null ) {
6232 if ( phy.getNumberOfExternalNodes() != 10 ) {
6235 if ( !phy.getName().equals( "tree 0" ) ) {
6239 if ( !p.hasNext() ) {
6243 if ( phy == null ) {
6246 if ( phy.getNumberOfExternalNodes() != 10 ) {
6249 if ( !phy.getName().equals( "tree 1" ) ) {
6253 if ( !p.hasNext() ) {
6257 if ( phy == null ) {
6260 if ( phy.getNumberOfExternalNodes() != 3 ) {
6263 if ( !phy.getName().equals( "" ) ) {
6266 if ( phy.isRooted() ) {
6270 if ( !p.hasNext() ) {
6274 if ( phy == null ) {
6277 if ( phy.getNumberOfExternalNodes() != 4 ) {
6280 if ( !phy.getName().equals( "" ) ) {
6283 if ( !phy.isRooted() ) {
6287 if ( !p.hasNext() ) {
6291 if ( phy == null ) {
6294 if ( phy.getNumberOfExternalNodes() != 5 ) {
6295 System.out.println( phy.getNumberOfExternalNodes() );
6298 if ( !phy.getName().equals( "" ) ) {
6301 if ( !phy.isRooted() ) {
6305 if ( !p.hasNext() ) {
6309 if ( phy == null ) {
6312 if ( phy.getNumberOfExternalNodes() != 3 ) {
6315 if ( !phy.getName().equals( "" ) ) {
6318 if ( phy.isRooted() ) {
6322 if ( !p.hasNext() ) {
6326 if ( phy == null ) {
6329 if ( phy.getNumberOfExternalNodes() != 2 ) {
6332 if ( !phy.getName().equals( "" ) ) {
6335 if ( !phy.isRooted() ) {
6339 if ( !p.hasNext() ) {
6343 if ( phy.getNumberOfExternalNodes() != 3 ) {
6346 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6349 if ( !phy.isRooted() ) {
6353 if ( !p.hasNext() ) {
6357 if ( phy.getNumberOfExternalNodes() != 3 ) {
6360 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6363 if ( !phy.getName().equals( "tree 8" ) ) {
6367 if ( !p.hasNext() ) {
6371 if ( phy.getNumberOfExternalNodes() != 3 ) {
6374 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6377 if ( !phy.getName().equals( "tree 9" ) ) {
6381 if ( !p.hasNext() ) {
6385 if ( phy.getNumberOfExternalNodes() != 3 ) {
6388 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6391 if ( !phy.getName().equals( "tree 10" ) ) {
6394 if ( !phy.isRooted() ) {
6398 if ( !p.hasNext() ) {
6402 if ( phy.getNumberOfExternalNodes() != 3 ) {
6405 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6408 if ( !phy.getName().equals( "tree 11" ) ) {
6411 if ( phy.isRooted() ) {
6415 if ( !p.hasNext() ) {
6419 if ( phy.getNumberOfExternalNodes() != 3 ) {
6422 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6425 if ( !phy.getName().equals( "tree 12" ) ) {
6428 if ( !phy.isRooted() ) {
6432 if ( !p.hasNext() ) {
6436 if ( phy.getNumberOfExternalNodes() != 3 ) {
6439 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6442 if ( !phy.getName().equals( "tree 13" ) ) {
6445 if ( !phy.isRooted() ) {
6449 if ( !p.hasNext() ) {
6453 if ( phy.getNumberOfExternalNodes() != 10 ) {
6454 System.out.println( phy.getNumberOfExternalNodes() );
6459 .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;" ) ) {
6460 System.out.println( phy.toNewHampshire() );
6463 if ( !phy.getName().equals( "tree 14" ) ) {
6466 if ( !phy.isRooted() ) {
6470 if ( !p.hasNext() ) {
6474 if ( phy.getNumberOfExternalNodes() != 10 ) {
6475 System.out.println( phy.getNumberOfExternalNodes() );
6480 .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;" ) ) {
6481 System.out.println( phy.toNewHampshire() );
6484 if ( !phy.getName().equals( "tree 15" ) ) {
6487 if ( phy.isRooted() ) {
6491 if ( !p.hasNext() ) {
6495 if ( phy.getNumberOfExternalNodes() != 10 ) {
6496 System.out.println( phy.getNumberOfExternalNodes() );
6501 .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;" ) ) {
6502 System.out.println( phy.toNewHampshire() );
6505 if ( !phy.getName().equals( "tree 16" ) ) {
6508 if ( !phy.isRooted() ) {
6512 if ( !p.hasNext() ) {
6516 if ( phy.getNumberOfExternalNodes() != 10 ) {
6517 System.out.println( phy.getNumberOfExternalNodes() );
6522 .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;" ) ) {
6523 System.out.println( phy.toNewHampshire() );
6526 if ( !phy.getName().equals( "tree 17" ) ) {
6529 if ( phy.isRooted() ) {
6533 if ( p.hasNext() ) {
6537 if ( phy != null ) {
6542 if ( !p.hasNext() ) {
6546 if ( phy == null ) {
6549 if ( phy.getNumberOfExternalNodes() != 10 ) {
6552 if ( !phy.getName().equals( "tree 0" ) ) {
6556 if ( !p.hasNext() ) {
6560 if ( phy == null ) {
6563 if ( phy.getNumberOfExternalNodes() != 10 ) {
6566 if ( !phy.getName().equals( "tree 1" ) ) {
6570 if ( !p.hasNext() ) {
6574 if ( phy == null ) {
6577 if ( phy.getNumberOfExternalNodes() != 3 ) {
6580 if ( !phy.getName().equals( "" ) ) {
6583 if ( phy.isRooted() ) {
6587 if ( !p.hasNext() ) {
6591 if ( phy == null ) {
6594 if ( phy.getNumberOfExternalNodes() != 4 ) {
6597 if ( !phy.getName().equals( "" ) ) {
6600 if ( !phy.isRooted() ) {
6604 if ( !p.hasNext() ) {
6608 if ( phy == null ) {
6611 if ( phy.getNumberOfExternalNodes() != 5 ) {
6612 System.out.println( phy.getNumberOfExternalNodes() );
6615 if ( !phy.getName().equals( "" ) ) {
6618 if ( !phy.isRooted() ) {
6622 if ( !p.hasNext() ) {
6626 if ( phy == null ) {
6629 if ( phy.getNumberOfExternalNodes() != 3 ) {
6632 if ( !phy.getName().equals( "" ) ) {
6635 if ( phy.isRooted() ) {
6639 catch ( final Exception e ) {
6640 e.printStackTrace( System.out );
6646 private static boolean testNexusTreeParsingTranslating() {
6648 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6649 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6650 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6651 if ( phylogenies.length != 1 ) {
6654 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6657 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6660 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6663 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6666 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6667 .equals( "Aranaeus" ) ) {
6671 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6672 if ( phylogenies.length != 3 ) {
6675 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6678 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6681 if ( phylogenies[ 0 ].isRooted() ) {
6684 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6687 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6690 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6691 .equals( "Aranaeus" ) ) {
6694 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6697 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6700 if ( phylogenies[ 1 ].isRooted() ) {
6703 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6706 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6709 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6710 .equals( "Aranaeus" ) ) {
6713 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6716 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6719 if ( !phylogenies[ 2 ].isRooted() ) {
6722 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6725 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6728 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6729 .equals( "Aranaeus" ) ) {
6733 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6734 if ( phylogenies.length != 3 ) {
6737 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6740 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6743 if ( phylogenies[ 0 ].isRooted() ) {
6746 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6749 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6752 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6753 .equals( "Aranaeus" ) ) {
6756 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6759 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6762 if ( phylogenies[ 1 ].isRooted() ) {
6765 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6768 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6771 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6772 .equals( "Aranaeus" ) ) {
6775 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6778 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6781 if ( !phylogenies[ 2 ].isRooted() ) {
6784 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6787 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6790 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6791 .equals( "Aranaeus" ) ) {
6795 catch ( final Exception e ) {
6796 e.printStackTrace( System.out );
6802 private static boolean testNHParsing() {
6804 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6805 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6806 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6809 final NHXParser nhxp = new NHXParser();
6810 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6811 nhxp.setReplaceUnderscores( true );
6812 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6813 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6816 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6819 final Phylogeny p1b = factory
6820 .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 ",
6821 new NHXParser() )[ 0 ];
6822 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6825 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6828 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6829 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6830 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6831 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6832 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6833 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6834 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6835 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6836 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6837 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6838 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6839 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6840 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6842 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6845 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6848 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6851 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6854 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6855 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6856 final String p16_S = "((A,B),C)";
6857 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6858 if ( p16.length != 1 ) {
6861 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6864 final String p17_S = "(C,(A,B))";
6865 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6866 if ( p17.length != 1 ) {
6869 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6872 final String p18_S = "((A,B),(C,D))";
6873 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6874 if ( p18.length != 1 ) {
6877 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6880 final String p19_S = "(((A,B),C),D)";
6881 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6882 if ( p19.length != 1 ) {
6885 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6888 final String p20_S = "(A,(B,(C,D)))";
6889 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6890 if ( p20.length != 1 ) {
6893 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6896 final String p21_S = "(A,(B,(C,(D,E))))";
6897 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6898 if ( p21.length != 1 ) {
6901 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6904 final String p22_S = "((((A,B),C),D),E)";
6905 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6906 if ( p22.length != 1 ) {
6909 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6912 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6913 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6914 if ( p23.length != 1 ) {
6915 System.out.println( "xl=" + p23.length );
6919 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6922 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6923 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6924 if ( p24.length != 1 ) {
6927 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6930 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6931 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6932 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6933 if ( p241.length != 2 ) {
6936 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6939 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6942 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6943 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6944 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6945 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6946 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6947 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6948 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6949 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6950 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6951 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6954 final String p26_S = "(A,B)ab";
6955 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6956 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6959 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6960 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6961 if ( p27s.length != 1 ) {
6962 System.out.println( "xxl=" + p27s.length );
6966 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6967 System.out.println( p27s[ 0 ].toNewHampshireX() );
6971 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6973 if ( p27.length != 1 ) {
6974 System.out.println( "yl=" + p27.length );
6978 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6979 System.out.println( p27[ 0 ].toNewHampshireX() );
6983 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6984 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6985 final String p28_S3 = "(A,B)ab";
6986 final String p28_S4 = "((((A,B),C),D),;E;)";
6987 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6989 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6992 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6995 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6998 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
7001 if ( p28.length != 4 ) {
7004 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";
7005 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
7006 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
7009 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";
7010 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
7011 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
7014 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
7015 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
7016 if ( ( p32.length != 0 ) ) {
7019 final String p33_S = "A";
7020 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
7021 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
7024 final String p34_S = "B;";
7025 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
7026 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
7029 final String p35_S = "B:0.2";
7030 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
7031 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
7034 final String p36_S = "(A)";
7035 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
7036 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
7039 final String p37_S = "((A))";
7040 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
7041 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
7044 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7045 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
7046 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
7049 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
7050 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
7051 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
7054 final String p40_S = "(A,B,C)";
7055 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
7056 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7059 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7060 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7061 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7064 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7065 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7066 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7069 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)";
7070 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7071 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7074 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)))";
7075 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7076 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7079 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7080 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7081 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7084 final String p46_S = "";
7085 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7086 if ( p46.length != 0 ) {
7089 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7090 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7093 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7094 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7097 final Phylogeny p49 = factory
7098 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7099 new NHXParser() )[ 0 ];
7100 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7103 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7104 if ( p50.getNode( "A" ) == null ) {
7107 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7108 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7111 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7114 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7115 .equals( "((A,B)88:2.0,C);" ) ) {
7118 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7119 if ( p51.getNode( "A(A" ) == null ) {
7122 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7123 if ( p52.getNode( "A(A" ) == null ) {
7126 final Phylogeny p53 = factory
7127 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7128 new NHXParser() )[ 0 ];
7129 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7133 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7134 if ( p54.getNode( "A" ) == null ) {
7137 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7138 .equals( "((A,B)[88],C);" ) ) {
7142 catch ( final Exception e ) {
7143 e.printStackTrace( System.out );
7149 private static boolean testNHParsingIter() {
7151 final String p0_str = "(A,B);";
7152 final NHXParser p = new NHXParser();
7153 p.setSource( p0_str );
7154 if ( !p.hasNext() ) {
7157 final Phylogeny p0 = p.next();
7158 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7159 System.out.println( p0.toNewHampshire() );
7162 if ( p.hasNext() ) {
7165 if ( p.next() != null ) {
7169 final String p00_str = "(A,B)root;";
7170 p.setSource( p00_str );
7171 final Phylogeny p00 = p.next();
7172 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7173 System.out.println( p00.toNewHampshire() );
7177 final String p000_str = "A;";
7178 p.setSource( p000_str );
7179 final Phylogeny p000 = p.next();
7180 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7181 System.out.println( p000.toNewHampshire() );
7185 final String p0000_str = "A";
7186 p.setSource( p0000_str );
7187 final Phylogeny p0000 = p.next();
7188 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7189 System.out.println( p0000.toNewHampshire() );
7193 p.setSource( "(A)" );
7194 final Phylogeny p00000 = p.next();
7195 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7196 System.out.println( p00000.toNewHampshire() );
7200 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7201 p.setSource( p1_str );
7202 if ( !p.hasNext() ) {
7205 final Phylogeny p1_0 = p.next();
7206 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7207 System.out.println( p1_0.toNewHampshire() );
7210 if ( !p.hasNext() ) {
7213 final Phylogeny p1_1 = p.next();
7214 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7215 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7218 if ( !p.hasNext() ) {
7221 final Phylogeny p1_2 = p.next();
7222 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7223 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7226 if ( !p.hasNext() ) {
7229 final Phylogeny p1_3 = p.next();
7230 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7231 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7234 if ( p.hasNext() ) {
7237 if ( p.next() != null ) {
7241 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7242 p.setSource( p2_str );
7243 if ( !p.hasNext() ) {
7246 Phylogeny p2_0 = p.next();
7247 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7248 System.out.println( p2_0.toNewHampshire() );
7251 if ( !p.hasNext() ) {
7254 Phylogeny p2_1 = p.next();
7255 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7256 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7259 if ( !p.hasNext() ) {
7262 Phylogeny p2_2 = p.next();
7263 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7264 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7267 if ( !p.hasNext() ) {
7270 Phylogeny p2_3 = p.next();
7271 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7272 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7275 if ( !p.hasNext() ) {
7278 Phylogeny p2_4 = p.next();
7279 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7280 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7283 if ( p.hasNext() ) {
7286 if ( p.next() != null ) {
7291 if ( !p.hasNext() ) {
7295 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7296 System.out.println( p2_0.toNewHampshire() );
7299 if ( !p.hasNext() ) {
7303 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7304 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7307 if ( !p.hasNext() ) {
7311 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7312 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7315 if ( !p.hasNext() ) {
7319 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7320 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7323 if ( !p.hasNext() ) {
7327 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7328 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7331 if ( p.hasNext() ) {
7334 if ( p.next() != null ) {
7338 final String p3_str = "((A,B),C)abc";
7339 p.setSource( p3_str );
7340 if ( !p.hasNext() ) {
7343 final Phylogeny p3_0 = p.next();
7344 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7347 if ( p.hasNext() ) {
7350 if ( p.next() != null ) {
7354 final String p4_str = "((A,B)ab,C)abc";
7355 p.setSource( p4_str );
7356 if ( !p.hasNext() ) {
7359 final Phylogeny p4_0 = p.next();
7360 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7363 if ( p.hasNext() ) {
7366 if ( p.next() != null ) {
7370 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7371 p.setSource( p5_str );
7372 if ( !p.hasNext() ) {
7375 final Phylogeny p5_0 = p.next();
7376 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7379 if ( p.hasNext() ) {
7382 if ( p.next() != null ) {
7386 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7387 p.setSource( p6_str );
7388 if ( !p.hasNext() ) {
7391 Phylogeny p6_0 = p.next();
7392 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7395 if ( p.hasNext() ) {
7398 if ( p.next() != null ) {
7402 if ( !p.hasNext() ) {
7406 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7409 if ( p.hasNext() ) {
7412 if ( p.next() != null ) {
7416 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7417 p.setSource( p7_str );
7418 if ( !p.hasNext() ) {
7421 Phylogeny p7_0 = p.next();
7422 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7425 if ( p.hasNext() ) {
7428 if ( p.next() != null ) {
7432 if ( !p.hasNext() ) {
7436 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7439 if ( p.hasNext() ) {
7442 if ( p.next() != null ) {
7446 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7447 p.setSource( p8_str );
7448 if ( !p.hasNext() ) {
7451 Phylogeny p8_0 = p.next();
7452 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7455 if ( !p.hasNext() ) {
7458 if ( !p.hasNext() ) {
7461 Phylogeny p8_1 = p.next();
7462 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7465 if ( p.hasNext() ) {
7468 if ( p.next() != null ) {
7472 if ( !p.hasNext() ) {
7476 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7479 if ( !p.hasNext() ) {
7483 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7486 if ( p.hasNext() ) {
7489 if ( p.next() != null ) {
7495 if ( p.hasNext() ) {
7499 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7500 if ( !p.hasNext() ) {
7503 Phylogeny p_27 = p.next();
7504 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7505 System.out.println( p_27.toNewHampshireX() );
7509 if ( p.hasNext() ) {
7512 if ( p.next() != null ) {
7516 if ( !p.hasNext() ) {
7520 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7521 System.out.println( p_27.toNewHampshireX() );
7525 if ( p.hasNext() ) {
7528 if ( p.next() != null ) {
7532 catch ( final Exception e ) {
7533 e.printStackTrace( System.out );
7539 private static boolean testNHXconversion() {
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:Co=Y:B=56:T=1]" );
7547 final PhylogenyNode n6 = PhylogenyNode
7548 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7549 if ( !n1.toNewHampshireX().equals( "" ) ) {
7552 if ( !n2.toNewHampshireX().equals( "" ) ) {
7555 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7558 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7561 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7564 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7565 System.out.println( n6.toNewHampshireX() );
7569 catch ( final Exception e ) {
7570 e.printStackTrace( System.out );
7576 private static boolean testNHXNodeParsing() {
7578 final PhylogenyNode n1 = new PhylogenyNode();
7579 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7580 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7581 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7582 final PhylogenyNode n5 = PhylogenyNode
7583 .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]" );
7584 if ( !n3.getName().equals( "n3" ) ) {
7587 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7590 if ( n3.isDuplication() ) {
7593 if ( n3.isHasAssignedEvent() ) {
7596 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7599 if ( !n4.getName().equals( "n4" ) ) {
7602 if ( n4.getDistanceToParent() != 0.01 ) {
7605 if ( !n5.getName().equals( "n5" ) ) {
7608 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7611 if ( n5.getDistanceToParent() != 0.1 ) {
7614 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7617 if ( !n5.isDuplication() ) {
7620 if ( !n5.isHasAssignedEvent() ) {
7623 final PhylogenyNode n8 = PhylogenyNode
7624 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7625 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7626 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7629 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7632 final PhylogenyNode n9 = PhylogenyNode
7633 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7634 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7635 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7638 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7641 final PhylogenyNode n10 = PhylogenyNode
7642 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7643 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7646 final PhylogenyNode n20 = PhylogenyNode
7647 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7648 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7651 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7654 final PhylogenyNode n20x = PhylogenyNode
7655 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7656 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7659 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7662 final PhylogenyNode n20xx = PhylogenyNode
7663 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7664 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7667 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7670 final PhylogenyNode n20xxx = PhylogenyNode
7671 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7672 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7675 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7678 final PhylogenyNode n20xxxx = PhylogenyNode
7679 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7680 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7683 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7686 final PhylogenyNode n21 = PhylogenyNode
7687 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7688 if ( !n21.getName().equals( "N21_PIG" ) ) {
7691 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7694 final PhylogenyNode n21x = PhylogenyNode
7695 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7696 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7699 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7702 final PhylogenyNode n22 = PhylogenyNode
7703 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7704 if ( !n22.getName().equals( "n22/PIG" ) ) {
7707 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7710 final PhylogenyNode n23 = PhylogenyNode
7711 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7712 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7715 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7718 final PhylogenyNode a = PhylogenyNode
7719 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7720 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7723 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7726 final PhylogenyNode c1 = PhylogenyNode
7727 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7728 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7729 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7732 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7735 final PhylogenyNode c2 = PhylogenyNode
7736 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7737 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7738 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7741 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7744 final PhylogenyNode e3 = PhylogenyNode
7745 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7746 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7749 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7752 final PhylogenyNode n11 = PhylogenyNode
7753 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7754 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7755 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7758 if ( n11.getDistanceToParent() != 0.4 ) {
7761 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7764 final PhylogenyNode n12 = PhylogenyNode
7765 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7766 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7767 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7770 if ( n12.getDistanceToParent() != 0.4 ) {
7773 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7776 final PhylogenyNode o = PhylogenyNode
7777 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7778 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7781 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7784 if ( n1.getName().compareTo( "" ) != 0 ) {
7787 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7790 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7793 if ( n2.getName().compareTo( "" ) != 0 ) {
7796 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7799 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7802 final PhylogenyNode n00 = PhylogenyNode
7803 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7804 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7807 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7810 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7811 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7814 final PhylogenyNode n13 = PhylogenyNode
7815 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7816 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7819 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7822 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7825 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7828 final PhylogenyNode n14 = PhylogenyNode
7829 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7830 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7833 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7836 final PhylogenyNode n15 = PhylogenyNode
7837 .createInstanceFromNhxString( "something_wicked[123]",
7838 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7839 if ( !n15.getName().equals( "something_wicked" ) ) {
7842 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7845 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7848 final PhylogenyNode n16 = PhylogenyNode
7849 .createInstanceFromNhxString( "something_wicked2[9]",
7850 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7851 if ( !n16.getName().equals( "something_wicked2" ) ) {
7854 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7857 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7860 final PhylogenyNode n17 = PhylogenyNode
7861 .createInstanceFromNhxString( "something_wicked3[a]",
7862 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7863 if ( !n17.getName().equals( "something_wicked3" ) ) {
7866 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7869 final PhylogenyNode n18 = PhylogenyNode
7870 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7871 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7874 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7877 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7880 final PhylogenyNode n19 = PhylogenyNode
7881 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7882 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7885 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7888 final PhylogenyNode n30 = PhylogenyNode
7889 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7890 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7891 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7894 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7897 final PhylogenyNode n31 = PhylogenyNode
7898 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7899 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7900 if ( n31.getNodeData().isHasTaxonomy() ) {
7903 final PhylogenyNode n32 = PhylogenyNode
7904 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7905 if ( n32.getNodeData().isHasTaxonomy() ) {
7908 final PhylogenyNode n40 = PhylogenyNode
7909 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7910 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7913 final PhylogenyNode n41 = PhylogenyNode
7914 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7915 if ( n41.getNodeData().isHasTaxonomy() ) {
7918 final PhylogenyNode n42 = PhylogenyNode
7919 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7920 if ( n42.getNodeData().isHasTaxonomy() ) {
7923 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7924 NHXParser.TAXONOMY_EXTRACTION.NO );
7925 if ( n43.getNodeData().isHasTaxonomy() ) {
7928 final PhylogenyNode n44 = PhylogenyNode
7929 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7930 if ( n44.getNodeData().isHasTaxonomy() ) {
7934 catch ( final Exception e ) {
7935 e.printStackTrace( System.out );
7941 private static boolean testNHXParsing() {
7943 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7944 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7945 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7948 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]";
7949 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7950 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7953 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]";
7954 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7955 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7958 final Phylogeny[] p3 = factory
7959 .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]",
7961 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7964 final Phylogeny[] p4 = factory
7965 .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(]",
7967 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7970 final Phylogeny[] p5 = factory
7971 .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(((]",
7973 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7976 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)";
7977 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)";
7978 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7979 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7982 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)))";
7983 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)))";
7984 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7985 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7988 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]) ))[,,, ])))))))";
7989 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7990 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7991 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7994 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7995 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7998 final Phylogeny p10 = factory
7999 .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]",
8000 new NHXParser() )[ 0 ];
8001 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
8005 catch ( final Exception e ) {
8006 e.printStackTrace( System.out );
8012 private static boolean testNHXParsingMB() {
8014 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8015 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
8016 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8017 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8018 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8019 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8020 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8021 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8022 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8023 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
8024 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
8027 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
8030 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
8031 0.1100000000000000e+00 ) ) {
8034 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
8037 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
8040 final Phylogeny p2 = factory
8041 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
8042 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8043 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
8044 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
8045 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
8046 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
8047 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
8048 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
8049 + "7.369400000000000e-02}])",
8050 new NHXParser() )[ 0 ];
8051 if ( p2.getNode( "1" ) == null ) {
8054 if ( p2.getNode( "2" ) == null ) {
8058 catch ( final Exception e ) {
8059 e.printStackTrace( System.out );
8066 private static boolean testNHXParsingQuotes() {
8068 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8069 final NHXParser p = new NHXParser();
8070 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8071 if ( phylogenies_0.length != 5 ) {
8074 final Phylogeny phy = phylogenies_0[ 4 ];
8075 if ( phy.getNumberOfExternalNodes() != 7 ) {
8078 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8081 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8084 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8085 .getScientificName().equals( "hsapiens" ) ) {
8088 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8091 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8094 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8097 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8100 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8103 final NHXParser p1p = new NHXParser();
8104 p1p.setIgnoreQuotes( true );
8105 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8106 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8109 final NHXParser p2p = new NHXParser();
8110 p1p.setIgnoreQuotes( false );
8111 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8112 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8115 final NHXParser p3p = new NHXParser();
8116 p3p.setIgnoreQuotes( false );
8117 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8118 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8121 final NHXParser p4p = new NHXParser();
8122 p4p.setIgnoreQuotes( false );
8123 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8124 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8127 final Phylogeny p10 = factory
8128 .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]",
8129 new NHXParser() )[ 0 ];
8130 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]";
8131 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8134 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8135 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8139 final Phylogeny p12 = factory
8140 .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]",
8141 new NHXParser() )[ 0 ];
8142 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]";
8143 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8146 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8147 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8150 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;";
8151 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8154 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8155 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8159 catch ( final Exception e ) {
8160 e.printStackTrace( System.out );
8166 private static boolean testNodeRemoval() {
8168 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8169 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8170 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8171 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8174 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8175 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8176 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8179 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8180 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8181 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8185 catch ( final Exception e ) {
8186 e.printStackTrace( System.out );
8192 private static boolean testPhylogenyBranch() {
8194 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8195 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8196 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8197 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8198 if ( !a1b1.equals( a1b1 ) ) {
8201 if ( !a1b1.equals( b1a1 ) ) {
8204 if ( !b1a1.equals( a1b1 ) ) {
8207 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8208 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8209 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8210 if ( a1_b1.equals( b1_a1 ) ) {
8213 if ( a1_b1.equals( a1_b1_ ) ) {
8216 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8217 if ( !a1_b1.equals( b1_a1_ ) ) {
8220 if ( a1_b1_.equals( b1_a1_ ) ) {
8223 if ( !a1_b1_.equals( b1_a1 ) ) {
8227 catch ( final Exception e ) {
8228 e.printStackTrace( System.out );
8234 private static boolean testPhyloXMLparsingOfDistributionElement() {
8236 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8237 PhyloXmlParser xml_parser = null;
8239 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8241 catch ( final Exception e ) {
8242 // Do nothing -- means were not running from jar.
8244 if ( xml_parser == null ) {
8245 xml_parser = new PhyloXmlParser();
8246 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8247 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8250 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8253 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8255 if ( xml_parser.getErrorCount() > 0 ) {
8256 System.out.println( xml_parser.getErrorMessages().toString() );
8259 if ( phylogenies_0.length != 1 ) {
8262 final Phylogeny t1 = phylogenies_0[ 0 ];
8263 PhylogenyNode n = null;
8264 Distribution d = null;
8265 n = t1.getNode( "root node" );
8266 if ( !n.getNodeData().isHasDistribution() ) {
8269 if ( n.getNodeData().getDistributions().size() != 1 ) {
8272 d = n.getNodeData().getDistribution();
8273 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8276 if ( d.getPoints().size() != 1 ) {
8279 if ( d.getPolygons() != null ) {
8282 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8285 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8288 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8291 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8294 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8297 n = t1.getNode( "node a" );
8298 if ( !n.getNodeData().isHasDistribution() ) {
8301 if ( n.getNodeData().getDistributions().size() != 2 ) {
8304 d = n.getNodeData().getDistribution( 1 );
8305 if ( !d.getDesc().equals( "San Diego" ) ) {
8308 if ( d.getPoints().size() != 1 ) {
8311 if ( d.getPolygons() != null ) {
8314 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8317 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8320 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8323 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8326 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8329 n = t1.getNode( "node bb" );
8330 if ( !n.getNodeData().isHasDistribution() ) {
8333 if ( n.getNodeData().getDistributions().size() != 1 ) {
8336 d = n.getNodeData().getDistribution( 0 );
8337 if ( d.getPoints().size() != 3 ) {
8340 if ( d.getPolygons().size() != 2 ) {
8343 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8346 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8349 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8352 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8355 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8358 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8361 Polygon p = d.getPolygons().get( 0 );
8362 if ( p.getPoints().size() != 3 ) {
8365 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8368 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8371 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8374 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8377 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8380 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8383 p = d.getPolygons().get( 1 );
8384 if ( p.getPoints().size() != 3 ) {
8387 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8390 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8393 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8397 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8398 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8399 if ( rt.length != 1 ) {
8402 final Phylogeny t1_rt = rt[ 0 ];
8403 n = t1_rt.getNode( "root node" );
8404 if ( !n.getNodeData().isHasDistribution() ) {
8407 if ( n.getNodeData().getDistributions().size() != 1 ) {
8410 d = n.getNodeData().getDistribution();
8411 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8414 if ( d.getPoints().size() != 1 ) {
8417 if ( d.getPolygons() != null ) {
8420 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8423 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8426 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8429 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8432 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8435 n = t1_rt.getNode( "node a" );
8436 if ( !n.getNodeData().isHasDistribution() ) {
8439 if ( n.getNodeData().getDistributions().size() != 2 ) {
8442 d = n.getNodeData().getDistribution( 1 );
8443 if ( !d.getDesc().equals( "San Diego" ) ) {
8446 if ( d.getPoints().size() != 1 ) {
8449 if ( d.getPolygons() != null ) {
8452 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8455 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8458 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8461 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8464 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8467 n = t1_rt.getNode( "node bb" );
8468 if ( !n.getNodeData().isHasDistribution() ) {
8471 if ( n.getNodeData().getDistributions().size() != 1 ) {
8474 d = n.getNodeData().getDistribution( 0 );
8475 if ( d.getPoints().size() != 3 ) {
8478 if ( d.getPolygons().size() != 2 ) {
8481 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8484 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8487 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8490 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8493 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8496 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8499 p = d.getPolygons().get( 0 );
8500 if ( p.getPoints().size() != 3 ) {
8503 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8506 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8509 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8512 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8515 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8518 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8521 p = d.getPolygons().get( 1 );
8522 if ( p.getPoints().size() != 3 ) {
8525 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8528 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8531 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8535 catch ( final Exception e ) {
8536 e.printStackTrace( System.out );
8542 private static boolean testPostOrderIterator() {
8544 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8545 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8546 PhylogenyNodeIterator it0;
8547 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8550 for( it0.reset(); it0.hasNext(); ) {
8553 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8554 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8555 if ( !it.next().getName().equals( "A" ) ) {
8558 if ( !it.next().getName().equals( "B" ) ) {
8561 if ( !it.next().getName().equals( "ab" ) ) {
8564 if ( !it.next().getName().equals( "C" ) ) {
8567 if ( !it.next().getName().equals( "D" ) ) {
8570 if ( !it.next().getName().equals( "cd" ) ) {
8573 if ( !it.next().getName().equals( "abcd" ) ) {
8576 if ( !it.next().getName().equals( "E" ) ) {
8579 if ( !it.next().getName().equals( "F" ) ) {
8582 if ( !it.next().getName().equals( "ef" ) ) {
8585 if ( !it.next().getName().equals( "G" ) ) {
8588 if ( !it.next().getName().equals( "H" ) ) {
8591 if ( !it.next().getName().equals( "gh" ) ) {
8594 if ( !it.next().getName().equals( "efgh" ) ) {
8597 if ( !it.next().getName().equals( "r" ) ) {
8600 if ( it.hasNext() ) {
8604 catch ( final Exception e ) {
8605 e.printStackTrace( System.out );
8611 private static boolean testPreOrderIterator() {
8613 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8614 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8615 PhylogenyNodeIterator it0;
8616 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8619 for( it0.reset(); it0.hasNext(); ) {
8622 PhylogenyNodeIterator it = t0.iteratorPreorder();
8623 if ( !it.next().getName().equals( "r" ) ) {
8626 if ( !it.next().getName().equals( "ab" ) ) {
8629 if ( !it.next().getName().equals( "A" ) ) {
8632 if ( !it.next().getName().equals( "B" ) ) {
8635 if ( !it.next().getName().equals( "cd" ) ) {
8638 if ( !it.next().getName().equals( "C" ) ) {
8641 if ( !it.next().getName().equals( "D" ) ) {
8644 if ( it.hasNext() ) {
8647 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8648 it = t1.iteratorPreorder();
8649 if ( !it.next().getName().equals( "r" ) ) {
8652 if ( !it.next().getName().equals( "abcd" ) ) {
8655 if ( !it.next().getName().equals( "ab" ) ) {
8658 if ( !it.next().getName().equals( "A" ) ) {
8661 if ( !it.next().getName().equals( "B" ) ) {
8664 if ( !it.next().getName().equals( "cd" ) ) {
8667 if ( !it.next().getName().equals( "C" ) ) {
8670 if ( !it.next().getName().equals( "D" ) ) {
8673 if ( !it.next().getName().equals( "efgh" ) ) {
8676 if ( !it.next().getName().equals( "ef" ) ) {
8679 if ( !it.next().getName().equals( "E" ) ) {
8682 if ( !it.next().getName().equals( "F" ) ) {
8685 if ( !it.next().getName().equals( "gh" ) ) {
8688 if ( !it.next().getName().equals( "G" ) ) {
8691 if ( !it.next().getName().equals( "H" ) ) {
8694 if ( it.hasNext() ) {
8698 catch ( final Exception e ) {
8699 e.printStackTrace( System.out );
8705 private static boolean testPropertiesMap() {
8707 final PropertiesMap pm = new PropertiesMap();
8708 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8709 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8710 final Property p2 = new Property( "something:else",
8712 "improbable:research",
8715 pm.addProperty( p0 );
8716 pm.addProperty( p1 );
8717 pm.addProperty( p2 );
8718 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8721 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8724 if ( pm.getProperties().size() != 3 ) {
8727 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8730 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8733 if ( pm.getProperties().size() != 3 ) {
8736 pm.removeProperty( "dimensions:diameter" );
8737 if ( pm.getProperties().size() != 2 ) {
8740 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8743 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8747 catch ( final Exception e ) {
8748 e.printStackTrace( System.out );
8754 private static boolean testProteinId() {
8756 final ProteinId id1 = new ProteinId( "a" );
8757 final ProteinId id2 = new ProteinId( "a" );
8758 final ProteinId id3 = new ProteinId( "A" );
8759 final ProteinId id4 = new ProteinId( "b" );
8760 if ( !id1.equals( id1 ) ) {
8763 if ( id1.getId().equals( "x" ) ) {
8766 if ( id1.getId().equals( null ) ) {
8769 if ( !id1.equals( id2 ) ) {
8772 if ( id1.equals( id3 ) ) {
8775 if ( id1.hashCode() != id1.hashCode() ) {
8778 if ( id1.hashCode() != id2.hashCode() ) {
8781 if ( id1.hashCode() == id3.hashCode() ) {
8784 if ( id1.compareTo( id1 ) != 0 ) {
8787 if ( id1.compareTo( id2 ) != 0 ) {
8790 if ( id1.compareTo( id3 ) != 0 ) {
8793 if ( id1.compareTo( id4 ) >= 0 ) {
8796 if ( id4.compareTo( id1 ) <= 0 ) {
8799 if ( !id4.getId().equals( "b" ) ) {
8802 final ProteinId id5 = new ProteinId( " C " );
8803 if ( !id5.getId().equals( "C" ) ) {
8806 if ( id5.equals( id1 ) ) {
8810 catch ( final Exception e ) {
8811 e.printStackTrace( System.out );
8817 private static boolean testReIdMethods() {
8819 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8820 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8821 final long count = PhylogenyNode.getNodeCount();
8823 if ( p.getNode( "r" ).getId() != count ) {
8826 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8829 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8832 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8835 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8838 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8841 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8844 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8847 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8850 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8853 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8856 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8859 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8862 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8865 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8869 catch ( final Exception e ) {
8870 e.printStackTrace( System.out );
8876 private static boolean testRerooting() {
8878 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8879 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",
8880 new NHXParser() )[ 0 ];
8881 if ( !t1.isRooted() ) {
8884 t1.reRoot( t1.getNode( "D" ) );
8885 t1.reRoot( t1.getNode( "CD" ) );
8886 t1.reRoot( t1.getNode( "A" ) );
8887 t1.reRoot( t1.getNode( "B" ) );
8888 t1.reRoot( t1.getNode( "AB" ) );
8889 t1.reRoot( t1.getNode( "D" ) );
8890 t1.reRoot( t1.getNode( "C" ) );
8891 t1.reRoot( t1.getNode( "CD" ) );
8892 t1.reRoot( t1.getNode( "A" ) );
8893 t1.reRoot( t1.getNode( "B" ) );
8894 t1.reRoot( t1.getNode( "AB" ) );
8895 t1.reRoot( t1.getNode( "D" ) );
8896 t1.reRoot( t1.getNode( "D" ) );
8897 t1.reRoot( t1.getNode( "C" ) );
8898 t1.reRoot( t1.getNode( "A" ) );
8899 t1.reRoot( t1.getNode( "B" ) );
8900 t1.reRoot( t1.getNode( "AB" ) );
8901 t1.reRoot( t1.getNode( "C" ) );
8902 t1.reRoot( t1.getNode( "D" ) );
8903 t1.reRoot( t1.getNode( "CD" ) );
8904 t1.reRoot( t1.getNode( "D" ) );
8905 t1.reRoot( t1.getNode( "A" ) );
8906 t1.reRoot( t1.getNode( "B" ) );
8907 t1.reRoot( t1.getNode( "AB" ) );
8908 t1.reRoot( t1.getNode( "C" ) );
8909 t1.reRoot( t1.getNode( "D" ) );
8910 t1.reRoot( t1.getNode( "CD" ) );
8911 t1.reRoot( t1.getNode( "D" ) );
8912 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8915 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8918 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8921 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8924 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8927 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8930 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",
8931 new NHXParser() )[ 0 ];
8932 t2.reRoot( t2.getNode( "A" ) );
8933 t2.reRoot( t2.getNode( "D" ) );
8934 t2.reRoot( t2.getNode( "ABC" ) );
8935 t2.reRoot( t2.getNode( "A" ) );
8936 t2.reRoot( t2.getNode( "B" ) );
8937 t2.reRoot( t2.getNode( "D" ) );
8938 t2.reRoot( t2.getNode( "C" ) );
8939 t2.reRoot( t2.getNode( "ABC" ) );
8940 t2.reRoot( t2.getNode( "A" ) );
8941 t2.reRoot( t2.getNode( "B" ) );
8942 t2.reRoot( t2.getNode( "AB" ) );
8943 t2.reRoot( t2.getNode( "AB" ) );
8944 t2.reRoot( t2.getNode( "D" ) );
8945 t2.reRoot( t2.getNode( "C" ) );
8946 t2.reRoot( t2.getNode( "B" ) );
8947 t2.reRoot( t2.getNode( "AB" ) );
8948 t2.reRoot( t2.getNode( "D" ) );
8949 t2.reRoot( t2.getNode( "D" ) );
8950 t2.reRoot( t2.getNode( "ABC" ) );
8951 t2.reRoot( t2.getNode( "A" ) );
8952 t2.reRoot( t2.getNode( "B" ) );
8953 t2.reRoot( t2.getNode( "AB" ) );
8954 t2.reRoot( t2.getNode( "D" ) );
8955 t2.reRoot( t2.getNode( "C" ) );
8956 t2.reRoot( t2.getNode( "ABC" ) );
8957 t2.reRoot( t2.getNode( "A" ) );
8958 t2.reRoot( t2.getNode( "B" ) );
8959 t2.reRoot( t2.getNode( "AB" ) );
8960 t2.reRoot( t2.getNode( "D" ) );
8961 t2.reRoot( t2.getNode( "D" ) );
8962 t2.reRoot( t2.getNode( "C" ) );
8963 t2.reRoot( t2.getNode( "A" ) );
8964 t2.reRoot( t2.getNode( "B" ) );
8965 t2.reRoot( t2.getNode( "AB" ) );
8966 t2.reRoot( t2.getNode( "C" ) );
8967 t2.reRoot( t2.getNode( "D" ) );
8968 t2.reRoot( t2.getNode( "ABC" ) );
8969 t2.reRoot( t2.getNode( "D" ) );
8970 t2.reRoot( t2.getNode( "A" ) );
8971 t2.reRoot( t2.getNode( "B" ) );
8972 t2.reRoot( t2.getNode( "AB" ) );
8973 t2.reRoot( t2.getNode( "C" ) );
8974 t2.reRoot( t2.getNode( "D" ) );
8975 t2.reRoot( t2.getNode( "ABC" ) );
8976 t2.reRoot( t2.getNode( "D" ) );
8977 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8980 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8983 t2.reRoot( t2.getNode( "ABC" ) );
8984 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8987 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8990 t2.reRoot( t2.getNode( "AB" ) );
8991 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8994 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8997 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9000 t2.reRoot( t2.getNode( "AB" ) );
9001 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9004 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9007 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9010 t2.reRoot( t2.getNode( "D" ) );
9011 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9014 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9017 t2.reRoot( t2.getNode( "ABC" ) );
9018 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
9021 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
9024 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
9025 new NHXParser() )[ 0 ];
9026 t3.reRoot( t3.getNode( "B" ) );
9027 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9030 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9033 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9036 t3.reRoot( t3.getNode( "B" ) );
9037 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9040 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9043 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9046 t3.reRoot( t3.getRoot() );
9047 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9050 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
9053 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
9057 catch ( final Exception e ) {
9058 e.printStackTrace( System.out );
9064 private static boolean testSDIse() {
9066 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9067 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9068 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9069 gene1.setRooted( true );
9070 species1.setRooted( true );
9071 final SDI sdi = new SDI( gene1, species1 );
9072 if ( !gene1.getRoot().isDuplication() ) {
9075 final Phylogeny species2 = factory
9076 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9077 new NHXParser() )[ 0 ];
9078 final Phylogeny gene2 = factory
9079 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9080 new NHXParser() )[ 0 ];
9081 species2.setRooted( true );
9082 gene2.setRooted( true );
9083 final SDI sdi2 = new SDI( gene2, species2 );
9084 if ( sdi2.getDuplicationsSum() != 0 ) {
9087 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9090 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9093 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9096 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9099 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9102 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9105 final Phylogeny species3 = factory
9106 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9107 new NHXParser() )[ 0 ];
9108 final Phylogeny gene3 = factory
9109 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9110 new NHXParser() )[ 0 ];
9111 species3.setRooted( true );
9112 gene3.setRooted( true );
9113 final SDI sdi3 = new SDI( gene3, species3 );
9114 if ( sdi3.getDuplicationsSum() != 1 ) {
9117 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9120 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9123 final Phylogeny species4 = factory
9124 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9125 new NHXParser() )[ 0 ];
9126 final Phylogeny gene4 = factory
9127 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9128 new NHXParser() )[ 0 ];
9129 species4.setRooted( true );
9130 gene4.setRooted( true );
9131 final SDI sdi4 = new SDI( gene4, species4 );
9132 if ( sdi4.getDuplicationsSum() != 1 ) {
9135 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9138 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9141 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9144 if ( species4.getNumberOfExternalNodes() != 6 ) {
9147 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9150 final Phylogeny species5 = factory
9151 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9152 new NHXParser() )[ 0 ];
9153 final Phylogeny gene5 = factory
9154 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9155 new NHXParser() )[ 0 ];
9156 species5.setRooted( true );
9157 gene5.setRooted( true );
9158 final SDI sdi5 = new SDI( gene5, species5 );
9159 if ( sdi5.getDuplicationsSum() != 2 ) {
9162 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9165 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9168 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9171 if ( species5.getNumberOfExternalNodes() != 6 ) {
9174 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9177 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9178 // Conjecture for Comparing Molecular Phylogenies"
9179 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9180 final Phylogeny species6 = factory
9181 .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,"
9182 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9183 new NHXParser() )[ 0 ];
9184 final Phylogeny gene6 = factory
9185 .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,"
9186 + "((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,"
9187 + "(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;",
9188 new NHXParser() )[ 0 ];
9189 species6.setRooted( true );
9190 gene6.setRooted( true );
9191 final SDI sdi6 = new SDI( gene6, species6 );
9192 if ( sdi6.getDuplicationsSum() != 3 ) {
9195 if ( !gene6.getNode( "r" ).isDuplication() ) {
9198 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9201 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9204 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9207 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9210 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9213 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9216 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9219 sdi6.computeMappingCostL();
9220 if ( sdi6.computeMappingCostL() != 17 ) {
9223 if ( species6.getNumberOfExternalNodes() != 9 ) {
9226 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9229 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9230 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9231 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9232 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9233 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9234 species7.setRooted( true );
9235 final Phylogeny gene7_1 = Test
9236 .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])" );
9237 gene7_1.setRooted( true );
9238 final SDI sdi7 = new SDI( gene7_1, species7 );
9239 if ( sdi7.getDuplicationsSum() != 0 ) {
9242 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9245 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9248 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9251 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9254 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9257 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9260 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9263 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9266 final Phylogeny gene7_2 = Test
9267 .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])" );
9268 gene7_2.setRooted( true );
9269 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9270 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9273 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9276 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9279 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9282 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9285 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9288 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9291 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9294 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9297 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9301 catch ( final Exception e ) {
9307 private static boolean testSDIunrooted() {
9309 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9310 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9311 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9312 final Iterator<PhylogenyBranch> iter = l.iterator();
9313 PhylogenyBranch br = iter.next();
9314 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9317 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9321 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9324 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9328 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9331 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9335 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9338 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9342 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9345 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9349 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9352 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9356 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9359 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9363 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9366 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9370 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9373 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9377 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9380 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9384 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9387 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9391 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9394 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9398 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9401 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9405 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9408 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9412 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9415 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9418 if ( iter.hasNext() ) {
9421 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9422 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9423 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9425 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9428 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9432 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9435 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9439 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9442 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9445 if ( iter1.hasNext() ) {
9448 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9449 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9450 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9452 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9455 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9459 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9462 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9466 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9469 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9472 if ( iter2.hasNext() ) {
9475 final Phylogeny species0 = factory
9476 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9477 new NHXParser() )[ 0 ];
9478 final Phylogeny gene1 = factory
9479 .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])",
9480 new NHXParser() )[ 0 ];
9481 species0.setRooted( true );
9482 gene1.setRooted( true );
9483 final SDIR sdi_unrooted = new SDIR();
9484 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9485 if ( sdi_unrooted.getCount() != 1 ) {
9488 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9491 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9494 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9497 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9500 final Phylogeny gene2 = factory
9501 .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])",
9502 new NHXParser() )[ 0 ];
9503 gene2.setRooted( true );
9504 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9505 if ( sdi_unrooted.getCount() != 1 ) {
9508 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9511 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9514 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9517 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9520 final Phylogeny species6 = factory
9521 .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,"
9522 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9523 new NHXParser() )[ 0 ];
9524 final Phylogeny gene6 = factory
9525 .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],"
9526 + "(((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],"
9527 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9528 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9529 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9530 new NHXParser() )[ 0 ];
9531 species6.setRooted( true );
9532 gene6.setRooted( true );
9533 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9534 if ( sdi_unrooted.getCount() != 1 ) {
9537 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9540 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9543 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9546 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9549 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9552 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9555 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9558 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9561 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9564 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9567 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9570 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9574 final Phylogeny species7 = factory
9575 .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,"
9576 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9577 new NHXParser() )[ 0 ];
9578 final Phylogeny gene7 = factory
9579 .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],"
9580 + "(((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],"
9581 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9582 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9583 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9584 new NHXParser() )[ 0 ];
9585 species7.setRooted( true );
9586 gene7.setRooted( true );
9587 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9588 if ( sdi_unrooted.getCount() != 1 ) {
9591 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9594 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9597 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9600 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9603 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9606 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9609 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9612 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9615 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9618 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9621 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9624 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9628 final Phylogeny species8 = factory
9629 .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,"
9630 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9631 new NHXParser() )[ 0 ];
9632 final Phylogeny gene8 = factory
9633 .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],"
9634 + "(((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],"
9635 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9636 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9637 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9638 new NHXParser() )[ 0 ];
9639 species8.setRooted( true );
9640 gene8.setRooted( true );
9641 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9642 if ( sdi_unrooted.getCount() != 1 ) {
9645 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9648 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9651 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9654 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9657 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9660 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9663 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9666 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9669 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9672 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9675 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9678 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9683 catch ( final Exception e ) {
9684 e.printStackTrace( System.out );
9690 private static boolean testSequenceIdParsing() {
9692 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
9693 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9694 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9696 System.out.println( "value =" + id.getValue() );
9697 System.out.println( "provider=" + id.getProvider() );
9702 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
9703 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9704 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9706 System.out.println( "value =" + id.getValue() );
9707 System.out.println( "provider=" + id.getProvider() );
9712 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
9713 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9714 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9716 System.out.println( "value =" + id.getValue() );
9717 System.out.println( "provider=" + id.getProvider() );
9722 id = SequenceIdParser.parse( "gb_AAA96518_1" );
9723 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9724 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
9726 System.out.println( "value =" + id.getValue() );
9727 System.out.println( "provider=" + id.getProvider() );
9732 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
9733 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9734 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
9736 System.out.println( "value =" + id.getValue() );
9737 System.out.println( "provider=" + id.getProvider() );
9742 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
9743 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9744 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
9746 System.out.println( "value =" + id.getValue() );
9747 System.out.println( "provider=" + id.getProvider() );
9752 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
9753 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9754 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
9756 System.out.println( "value =" + id.getValue() );
9757 System.out.println( "provider=" + id.getProvider() );
9762 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
9763 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9764 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9766 System.out.println( "value =" + id.getValue() );
9767 System.out.println( "provider=" + id.getProvider() );
9772 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
9773 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9774 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9776 System.out.println( "value =" + id.getValue() );
9777 System.out.println( "provider=" + id.getProvider() );
9782 id = SequenceIdParser.parse( "P4A123" );
9783 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9784 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9786 System.out.println( "value =" + id.getValue() );
9787 System.out.println( "provider=" + id.getProvider() );
9792 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
9793 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9794 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9796 System.out.println( "value =" + id.getValue() );
9797 System.out.println( "provider=" + id.getProvider() );
9802 id = SequenceIdParser.parse( "XP_12345" );
9804 System.out.println( "value =" + id.getValue() );
9805 System.out.println( "provider=" + id.getProvider() );
9808 // lcl_91970_unknown_
9810 catch ( final Exception e ) {
9811 e.printStackTrace( System.out );
9817 private static boolean testSequenceWriter() {
9819 final String n = ForesterUtil.LINE_SEPARATOR;
9820 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9823 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9826 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9829 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9832 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9833 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9836 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9837 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9841 catch ( final Exception e ) {
9842 e.printStackTrace();
9848 private static boolean testSpecies() {
9850 final Species s1 = new BasicSpecies( "a" );
9851 final Species s2 = new BasicSpecies( "a" );
9852 final Species s3 = new BasicSpecies( "A" );
9853 final Species s4 = new BasicSpecies( "b" );
9854 if ( !s1.equals( s1 ) ) {
9857 if ( s1.getSpeciesId().equals( "x" ) ) {
9860 if ( s1.getSpeciesId().equals( null ) ) {
9863 if ( !s1.equals( s2 ) ) {
9866 if ( s1.equals( s3 ) ) {
9869 if ( s1.hashCode() != s1.hashCode() ) {
9872 if ( s1.hashCode() != s2.hashCode() ) {
9875 if ( s1.hashCode() == s3.hashCode() ) {
9878 if ( s1.compareTo( s1 ) != 0 ) {
9881 if ( s1.compareTo( s2 ) != 0 ) {
9884 if ( s1.compareTo( s3 ) != 0 ) {
9887 if ( s1.compareTo( s4 ) >= 0 ) {
9890 if ( s4.compareTo( s1 ) <= 0 ) {
9893 if ( !s4.getSpeciesId().equals( "b" ) ) {
9896 final Species s5 = new BasicSpecies( " C " );
9897 if ( !s5.getSpeciesId().equals( "C" ) ) {
9900 if ( s5.equals( s1 ) ) {
9904 catch ( final Exception e ) {
9905 e.printStackTrace( System.out );
9911 private static boolean testSplit() {
9913 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9914 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9915 //Archaeopteryx.createApplication( p0 );
9916 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9917 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9918 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9919 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9920 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9921 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9922 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9923 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9924 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9925 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9926 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9927 // System.out.println( s0.toString() );
9929 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9932 if ( s0.match( query_nodes ) ) {
9935 query_nodes = new HashSet<PhylogenyNode>();
9936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9937 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9943 if ( !s0.match( query_nodes ) ) {
9947 query_nodes = new HashSet<PhylogenyNode>();
9948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9951 if ( !s0.match( query_nodes ) ) {
9955 query_nodes = new HashSet<PhylogenyNode>();
9956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9960 if ( !s0.match( query_nodes ) ) {
9964 query_nodes = new HashSet<PhylogenyNode>();
9965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9969 if ( !s0.match( query_nodes ) ) {
9973 query_nodes = new HashSet<PhylogenyNode>();
9974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9977 if ( !s0.match( query_nodes ) ) {
9981 query_nodes = new HashSet<PhylogenyNode>();
9982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9984 if ( !s0.match( query_nodes ) ) {
9988 query_nodes = new HashSet<PhylogenyNode>();
9989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9990 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9994 if ( !s0.match( query_nodes ) ) {
9998 query_nodes = new HashSet<PhylogenyNode>();
9999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10002 if ( !s0.match( query_nodes ) ) {
10006 query_nodes = new HashSet<PhylogenyNode>();
10007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10011 if ( !s0.match( query_nodes ) ) {
10015 query_nodes = new HashSet<PhylogenyNode>();
10016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10018 if ( s0.match( query_nodes ) ) {
10022 query_nodes = new HashSet<PhylogenyNode>();
10023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10024 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10027 if ( s0.match( query_nodes ) ) {
10031 query_nodes = new HashSet<PhylogenyNode>();
10032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10034 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10037 if ( s0.match( query_nodes ) ) {
10041 query_nodes = new HashSet<PhylogenyNode>();
10042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10044 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10045 if ( s0.match( query_nodes ) ) {
10049 query_nodes = new HashSet<PhylogenyNode>();
10050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10052 if ( s0.match( query_nodes ) ) {
10056 query_nodes = new HashSet<PhylogenyNode>();
10057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10059 if ( s0.match( query_nodes ) ) {
10063 query_nodes = new HashSet<PhylogenyNode>();
10064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10066 if ( s0.match( query_nodes ) ) {
10070 query_nodes = new HashSet<PhylogenyNode>();
10071 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10073 if ( s0.match( query_nodes ) ) {
10077 query_nodes = new HashSet<PhylogenyNode>();
10078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10079 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10080 if ( s0.match( query_nodes ) ) {
10084 query_nodes = new HashSet<PhylogenyNode>();
10085 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10087 if ( s0.match( query_nodes ) ) {
10091 query_nodes = new HashSet<PhylogenyNode>();
10092 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10093 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10094 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10095 if ( s0.match( query_nodes ) ) {
10099 query_nodes = new HashSet<PhylogenyNode>();
10100 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10101 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10102 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10103 if ( s0.match( query_nodes ) ) {
10107 query_nodes = new HashSet<PhylogenyNode>();
10108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10111 if ( s0.match( query_nodes ) ) {
10115 query_nodes = new HashSet<PhylogenyNode>();
10116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10117 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10119 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10120 if ( s0.match( query_nodes ) ) {
10124 // query_nodes = new HashSet<PhylogenyNode>();
10125 // query_nodes.add( new PhylogenyNode( "X" ) );
10126 // query_nodes.add( new PhylogenyNode( "Y" ) );
10127 // query_nodes.add( new PhylogenyNode( "A" ) );
10128 // query_nodes.add( new PhylogenyNode( "B" ) );
10129 // query_nodes.add( new PhylogenyNode( "C" ) );
10130 // query_nodes.add( new PhylogenyNode( "D" ) );
10131 // query_nodes.add( new PhylogenyNode( "E" ) );
10132 // query_nodes.add( new PhylogenyNode( "F" ) );
10133 // query_nodes.add( new PhylogenyNode( "G" ) );
10134 // if ( !s0.match( query_nodes ) ) {
10137 // query_nodes = new HashSet<PhylogenyNode>();
10138 // query_nodes.add( new PhylogenyNode( "X" ) );
10139 // query_nodes.add( new PhylogenyNode( "Y" ) );
10140 // query_nodes.add( new PhylogenyNode( "A" ) );
10141 // query_nodes.add( new PhylogenyNode( "B" ) );
10142 // query_nodes.add( new PhylogenyNode( "C" ) );
10143 // if ( !s0.match( query_nodes ) ) {
10147 // query_nodes = new HashSet<PhylogenyNode>();
10148 // query_nodes.add( new PhylogenyNode( "X" ) );
10149 // query_nodes.add( new PhylogenyNode( "Y" ) );
10150 // query_nodes.add( new PhylogenyNode( "D" ) );
10151 // query_nodes.add( new PhylogenyNode( "E" ) );
10152 // query_nodes.add( new PhylogenyNode( "F" ) );
10153 // query_nodes.add( new PhylogenyNode( "G" ) );
10154 // if ( !s0.match( query_nodes ) ) {
10158 // query_nodes = new HashSet<PhylogenyNode>();
10159 // query_nodes.add( new PhylogenyNode( "X" ) );
10160 // query_nodes.add( new PhylogenyNode( "Y" ) );
10161 // query_nodes.add( new PhylogenyNode( "A" ) );
10162 // query_nodes.add( new PhylogenyNode( "B" ) );
10163 // query_nodes.add( new PhylogenyNode( "C" ) );
10164 // query_nodes.add( new PhylogenyNode( "D" ) );
10165 // if ( !s0.match( query_nodes ) ) {
10169 // query_nodes = new HashSet<PhylogenyNode>();
10170 // query_nodes.add( new PhylogenyNode( "X" ) );
10171 // query_nodes.add( new PhylogenyNode( "Y" ) );
10172 // query_nodes.add( new PhylogenyNode( "E" ) );
10173 // query_nodes.add( new PhylogenyNode( "F" ) );
10174 // query_nodes.add( new PhylogenyNode( "G" ) );
10175 // if ( !s0.match( query_nodes ) ) {
10179 // query_nodes = new HashSet<PhylogenyNode>();
10180 // query_nodes.add( new PhylogenyNode( "X" ) );
10181 // query_nodes.add( new PhylogenyNode( "Y" ) );
10182 // query_nodes.add( new PhylogenyNode( "F" ) );
10183 // query_nodes.add( new PhylogenyNode( "G" ) );
10184 // if ( !s0.match( query_nodes ) ) {
10188 query_nodes = new HashSet<PhylogenyNode>();
10189 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10190 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10193 if ( s0.match( query_nodes ) ) {
10197 query_nodes = new HashSet<PhylogenyNode>();
10198 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10199 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10200 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10201 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10202 if ( s0.match( query_nodes ) ) {
10205 ///////////////////////////
10207 query_nodes = new HashSet<PhylogenyNode>();
10208 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10209 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10212 if ( s0.match( query_nodes ) ) {
10216 query_nodes = new HashSet<PhylogenyNode>();
10217 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10219 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10221 if ( s0.match( query_nodes ) ) {
10225 query_nodes = new HashSet<PhylogenyNode>();
10226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10227 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10228 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10230 if ( s0.match( query_nodes ) ) {
10234 query_nodes = new HashSet<PhylogenyNode>();
10235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10239 if ( s0.match( query_nodes ) ) {
10243 query_nodes = new HashSet<PhylogenyNode>();
10244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10247 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10248 if ( s0.match( query_nodes ) ) {
10252 query_nodes = new HashSet<PhylogenyNode>();
10253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10254 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10255 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10256 if ( s0.match( query_nodes ) ) {
10260 query_nodes = new HashSet<PhylogenyNode>();
10261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10264 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10265 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10266 if ( s0.match( query_nodes ) ) {
10270 query_nodes = new HashSet<PhylogenyNode>();
10271 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10276 if ( s0.match( query_nodes ) ) {
10280 query_nodes = new HashSet<PhylogenyNode>();
10281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10285 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10286 if ( s0.match( query_nodes ) ) {
10290 query_nodes = new HashSet<PhylogenyNode>();
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10293 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10294 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10295 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10296 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10297 if ( s0.match( query_nodes ) ) {
10301 catch ( final Exception e ) {
10302 e.printStackTrace();
10308 private static boolean testSplitStrict() {
10310 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10311 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10312 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10313 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10314 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10315 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10316 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10317 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10318 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10319 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10320 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10321 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10322 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10324 if ( s0.match( query_nodes ) ) {
10327 query_nodes = new HashSet<PhylogenyNode>();
10328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10331 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10335 if ( !s0.match( query_nodes ) ) {
10339 query_nodes = new HashSet<PhylogenyNode>();
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10343 if ( !s0.match( query_nodes ) ) {
10347 query_nodes = new HashSet<PhylogenyNode>();
10348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10351 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10352 if ( !s0.match( query_nodes ) ) {
10356 query_nodes = new HashSet<PhylogenyNode>();
10357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10361 if ( !s0.match( query_nodes ) ) {
10365 query_nodes = new HashSet<PhylogenyNode>();
10366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10369 if ( !s0.match( query_nodes ) ) {
10373 query_nodes = new HashSet<PhylogenyNode>();
10374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10376 if ( !s0.match( query_nodes ) ) {
10380 query_nodes = new HashSet<PhylogenyNode>();
10381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10386 if ( !s0.match( query_nodes ) ) {
10390 query_nodes = new HashSet<PhylogenyNode>();
10391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10394 if ( !s0.match( query_nodes ) ) {
10398 query_nodes = new HashSet<PhylogenyNode>();
10399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10403 if ( !s0.match( query_nodes ) ) {
10407 query_nodes = new HashSet<PhylogenyNode>();
10408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10409 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10410 if ( s0.match( query_nodes ) ) {
10414 query_nodes = new HashSet<PhylogenyNode>();
10415 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10416 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10417 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10418 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10419 if ( s0.match( query_nodes ) ) {
10423 query_nodes = new HashSet<PhylogenyNode>();
10424 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10425 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10429 if ( s0.match( query_nodes ) ) {
10433 query_nodes = new HashSet<PhylogenyNode>();
10434 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10437 if ( s0.match( query_nodes ) ) {
10441 query_nodes = new HashSet<PhylogenyNode>();
10442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10444 if ( s0.match( query_nodes ) ) {
10448 query_nodes = new HashSet<PhylogenyNode>();
10449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10451 if ( s0.match( query_nodes ) ) {
10455 query_nodes = new HashSet<PhylogenyNode>();
10456 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10458 if ( s0.match( query_nodes ) ) {
10462 query_nodes = new HashSet<PhylogenyNode>();
10463 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10465 if ( s0.match( query_nodes ) ) {
10469 query_nodes = new HashSet<PhylogenyNode>();
10470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10472 if ( s0.match( query_nodes ) ) {
10476 query_nodes = new HashSet<PhylogenyNode>();
10477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10479 if ( s0.match( query_nodes ) ) {
10483 query_nodes = new HashSet<PhylogenyNode>();
10484 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10487 if ( s0.match( query_nodes ) ) {
10491 query_nodes = new HashSet<PhylogenyNode>();
10492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10495 if ( s0.match( query_nodes ) ) {
10499 query_nodes = new HashSet<PhylogenyNode>();
10500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10503 if ( s0.match( query_nodes ) ) {
10507 query_nodes = new HashSet<PhylogenyNode>();
10508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10512 if ( s0.match( query_nodes ) ) {
10516 catch ( final Exception e ) {
10517 e.printStackTrace();
10523 private static boolean testSubtreeDeletion() {
10525 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10526 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10527 t1.deleteSubtree( t1.getNode( "A" ), false );
10528 if ( t1.getNumberOfExternalNodes() != 5 ) {
10531 t1.toNewHampshireX();
10532 t1.deleteSubtree( t1.getNode( "E" ), false );
10533 if ( t1.getNumberOfExternalNodes() != 4 ) {
10536 t1.toNewHampshireX();
10537 t1.deleteSubtree( t1.getNode( "F" ), false );
10538 if ( t1.getNumberOfExternalNodes() != 3 ) {
10541 t1.toNewHampshireX();
10542 t1.deleteSubtree( t1.getNode( "D" ), false );
10543 t1.toNewHampshireX();
10544 if ( t1.getNumberOfExternalNodes() != 3 ) {
10547 t1.deleteSubtree( t1.getNode( "def" ), false );
10548 t1.toNewHampshireX();
10549 if ( t1.getNumberOfExternalNodes() != 2 ) {
10552 t1.deleteSubtree( t1.getNode( "B" ), false );
10553 t1.toNewHampshireX();
10554 if ( t1.getNumberOfExternalNodes() != 1 ) {
10557 t1.deleteSubtree( t1.getNode( "C" ), false );
10558 t1.toNewHampshireX();
10559 if ( t1.getNumberOfExternalNodes() != 1 ) {
10562 t1.deleteSubtree( t1.getNode( "abc" ), false );
10563 t1.toNewHampshireX();
10564 if ( t1.getNumberOfExternalNodes() != 1 ) {
10567 t1.deleteSubtree( t1.getNode( "r" ), false );
10568 if ( t1.getNumberOfExternalNodes() != 0 ) {
10571 if ( !t1.isEmpty() ) {
10574 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10575 t2.deleteSubtree( t2.getNode( "A" ), false );
10576 t2.toNewHampshireX();
10577 if ( t2.getNumberOfExternalNodes() != 5 ) {
10580 t2.deleteSubtree( t2.getNode( "abc" ), false );
10581 t2.toNewHampshireX();
10582 if ( t2.getNumberOfExternalNodes() != 3 ) {
10585 t2.deleteSubtree( t2.getNode( "def" ), false );
10586 t2.toNewHampshireX();
10587 if ( t2.getNumberOfExternalNodes() != 1 ) {
10591 catch ( final Exception e ) {
10592 e.printStackTrace( System.out );
10598 private static boolean testSupportCount() {
10600 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10601 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10602 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10603 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10604 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10605 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10606 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10608 SupportCount.count( t0_1, phylogenies_1, true, false );
10609 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10610 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10611 + "(((((A,B),C),D),E),((F,G),X))"
10612 + "(((((A,Y),B),C),D),((F,G),E))"
10613 + "(((((A,B),C),D),E),(F,G))"
10614 + "(((((A,B),C),D),E),(F,G))"
10615 + "(((((A,B),C),D),E),(F,G))"
10616 + "(((((A,B),C),D),E),(F,G),Z)"
10617 + "(((((A,B),C),D),E),(F,G))"
10618 + "((((((A,B),C),D),E),F),G)"
10619 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10621 SupportCount.count( t0_2, phylogenies_2, true, false );
10622 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10623 while ( it.hasNext() ) {
10624 final PhylogenyNode n = it.next();
10625 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10629 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10630 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10631 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10632 SupportCount.count( t0_3, phylogenies_3, true, false );
10633 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10634 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10637 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10640 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10643 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10646 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10649 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10652 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10655 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10658 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10661 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10664 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10665 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10666 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10667 SupportCount.count( t0_4, phylogenies_4, true, false );
10668 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10669 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10672 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10675 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10678 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10681 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10684 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10687 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10690 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10693 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10696 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10699 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10700 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10701 double d = SupportCount.compare( b1, a, true, true, true );
10702 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10705 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10706 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10707 d = SupportCount.compare( b2, a, true, true, true );
10708 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10711 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10712 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10713 d = SupportCount.compare( b3, a, true, true, true );
10714 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10717 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10718 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10719 d = SupportCount.compare( b4, a, true, true, false );
10720 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10724 catch ( final Exception e ) {
10725 e.printStackTrace( System.out );
10731 private static boolean testSupportTransfer() {
10733 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10734 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)",
10735 new NHXParser() )[ 0 ];
10736 final Phylogeny p2 = factory
10737 .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 ];
10738 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10741 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10744 support_transfer.moveBranchLengthsToBootstrap( p1 );
10745 support_transfer.transferSupportValues( p1, p2 );
10746 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10749 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10752 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10755 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10758 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10761 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10764 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10767 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10771 catch ( final Exception e ) {
10772 e.printStackTrace( System.out );
10778 private static boolean testTaxonomyExtraction() {
10780 final PhylogenyNode n0 = PhylogenyNode
10781 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10782 if ( n0.getNodeData().isHasTaxonomy() ) {
10785 final PhylogenyNode n1 = PhylogenyNode
10786 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10787 if ( n1.getNodeData().isHasTaxonomy() ) {
10788 System.out.println( n1.toString() );
10791 final PhylogenyNode n2x = PhylogenyNode
10792 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10793 if ( n2x.getNodeData().isHasTaxonomy() ) {
10796 final PhylogenyNode n3 = PhylogenyNode
10797 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10798 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10799 System.out.println( n3.toString() );
10802 final PhylogenyNode n4 = PhylogenyNode
10803 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10804 if ( n4.getNodeData().isHasTaxonomy() ) {
10805 System.out.println( n4.toString() );
10808 final PhylogenyNode n5 = PhylogenyNode
10809 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10810 if ( n5.getNodeData().isHasTaxonomy() ) {
10811 System.out.println( n5.toString() );
10814 final PhylogenyNode n6 = PhylogenyNode
10815 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10816 if ( n6.getNodeData().isHasTaxonomy() ) {
10817 System.out.println( n6.toString() );
10820 final PhylogenyNode n7 = PhylogenyNode
10821 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10822 if ( n7.getNodeData().isHasTaxonomy() ) {
10823 System.out.println( n7.toString() );
10826 final PhylogenyNode n8 = PhylogenyNode
10827 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10828 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10829 System.out.println( n8.toString() );
10832 final PhylogenyNode n9 = PhylogenyNode
10833 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10834 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10835 System.out.println( n9.toString() );
10838 final PhylogenyNode n10x = PhylogenyNode
10839 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10840 if ( n10x.getNodeData().isHasTaxonomy() ) {
10841 System.out.println( n10x.toString() );
10844 final PhylogenyNode n10xx = PhylogenyNode
10845 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10846 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10847 System.out.println( n10xx.toString() );
10850 final PhylogenyNode n10 = PhylogenyNode
10851 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10852 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10853 System.out.println( n10.toString() );
10856 final PhylogenyNode n11 = PhylogenyNode
10857 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10858 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10859 System.out.println( n11.toString() );
10862 final PhylogenyNode n12 = PhylogenyNode
10863 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10864 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10865 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10866 System.out.println( n12.toString() );
10869 final PhylogenyNode n13 = PhylogenyNode
10870 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10871 if ( n13.getNodeData().isHasTaxonomy() ) {
10872 System.out.println( n13.toString() );
10876 catch ( final Exception e ) {
10877 e.printStackTrace( System.out );
10883 private static boolean testTreeMethods() {
10885 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10886 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10887 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10888 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10889 System.out.println( t0.toNewHampshireX() );
10892 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10893 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10894 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10897 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10900 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10904 catch ( final Exception e ) {
10905 e.printStackTrace( System.out );
10911 private static boolean testUniprotEntryRetrieval() {
10913 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
10914 if ( !entry.getAccession().equals( "P12345" ) ) {
10917 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
10920 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
10923 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
10927 catch ( final IOException e ) {
10928 System.out.println();
10929 System.out.println( "the following might be due to absence internet connection:" );
10930 e.printStackTrace( System.out );
10933 catch ( final Exception e ) {
10939 private static boolean testUniprotTaxonomySearch() {
10941 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
10943 if ( results.size() != 1 ) {
10946 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10949 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10952 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10955 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10958 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10962 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
10963 if ( results.size() != 1 ) {
10966 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10969 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10972 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10975 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10978 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10982 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
10983 if ( results.size() != 1 ) {
10986 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10989 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10992 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10995 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10998 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11002 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
11003 if ( results.size() != 1 ) {
11006 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
11009 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
11012 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
11015 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11018 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
11021 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
11024 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
11027 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11028 .equals( "Nematostella vectensis" ) ) {
11029 System.out.println( results.get( 0 ).getLineage() );
11033 catch ( final IOException e ) {
11034 System.out.println();
11035 System.out.println( "the following might be due to absence internet connection:" );
11036 e.printStackTrace( System.out );
11039 catch ( final Exception e ) {
11045 private static boolean testWabiTxSearch() {
11047 String result = "";
11048 result = TxSearch.searchSimple( "nematostella" );
11049 result = TxSearch.getTxId( "nematostella" );
11050 if ( !result.equals( "45350" ) ) {
11053 result = TxSearch.getTxName( "45350" );
11054 if ( !result.equals( "Nematostella" ) ) {
11057 result = TxSearch.getTxId( "nematostella vectensis" );
11058 if ( !result.equals( "45351" ) ) {
11061 result = TxSearch.getTxName( "45351" );
11062 if ( !result.equals( "Nematostella vectensis" ) ) {
11065 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11066 if ( !result.equals( "536089" ) ) {
11069 result = TxSearch.getTxName( "536089" );
11070 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11073 final List<String> queries = new ArrayList<String>();
11074 queries.add( "Campylobacter coli" );
11075 queries.add( "Escherichia coli" );
11076 queries.add( "Arabidopsis" );
11077 queries.add( "Trichoplax" );
11078 queries.add( "Samanea saman" );
11079 queries.add( "Kluyveromyces marxianus" );
11080 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11081 queries.add( "Bornavirus parrot/PDD/2008" );
11082 final List<RANKS> ranks = new ArrayList<RANKS>();
11083 ranks.add( RANKS.SUPERKINGDOM );
11084 ranks.add( RANKS.KINGDOM );
11085 ranks.add( RANKS.FAMILY );
11086 ranks.add( RANKS.GENUS );
11087 ranks.add( RANKS.TRIBE );
11088 result = TxSearch.searchLineage( queries, ranks );
11089 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11090 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11092 catch ( final Exception e ) {
11093 System.out.println();
11094 System.out.println( "the following might be due to absence internet connection:" );
11095 e.printStackTrace( System.out );