2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.test;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.HashSet;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Locale;
39 import java.util.SortedSet;
41 import org.forester.application.support_transfer;
42 import org.forester.archaeopteryx.TreePanelUtil;
43 import org.forester.development.DevelopmentTools;
44 import org.forester.evoinference.TestPhylogenyReconstruction;
45 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
46 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
47 import org.forester.go.TestGo;
48 import org.forester.io.parsers.FastaParser;
49 import org.forester.io.parsers.GeneralMsaParser;
50 import org.forester.io.parsers.HmmscanPerDomainTableParser;
51 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
52 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
53 import org.forester.io.parsers.nexus.NexusCharactersParser;
54 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
55 import org.forester.io.parsers.nhx.NHXParser;
56 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
57 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
58 import org.forester.io.parsers.tol.TolParser;
59 import org.forester.io.parsers.util.ParserUtils;
60 import org.forester.io.writers.PhylogenyWriter;
61 import org.forester.io.writers.SequenceWriter;
62 import org.forester.msa.BasicMsa;
63 import org.forester.msa.Mafft;
64 import org.forester.msa.Msa;
65 import org.forester.msa.MsaInferrer;
66 import org.forester.msa.MsaMethods;
67 import org.forester.pccx.TestPccx;
68 import org.forester.phylogeny.Phylogeny;
69 import org.forester.phylogeny.PhylogenyBranch;
70 import org.forester.phylogeny.PhylogenyMethods;
71 import org.forester.phylogeny.PhylogenyNode;
72 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
73 import org.forester.phylogeny.data.Accession;
74 import org.forester.phylogeny.data.BinaryCharacters;
75 import org.forester.phylogeny.data.BranchWidth;
76 import org.forester.phylogeny.data.Confidence;
77 import org.forester.phylogeny.data.Distribution;
78 import org.forester.phylogeny.data.DomainArchitecture;
79 import org.forester.phylogeny.data.Event;
80 import org.forester.phylogeny.data.Identifier;
81 import org.forester.phylogeny.data.PhylogenyData;
82 import org.forester.phylogeny.data.PhylogenyDataUtil;
83 import org.forester.phylogeny.data.Polygon;
84 import org.forester.phylogeny.data.PropertiesMap;
85 import org.forester.phylogeny.data.Property;
86 import org.forester.phylogeny.data.Property.AppliesTo;
87 import org.forester.phylogeny.data.ProteinDomain;
88 import org.forester.phylogeny.data.Taxonomy;
89 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
90 import org.forester.phylogeny.factories.PhylogenyFactory;
91 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
92 import org.forester.protein.BasicDomain;
93 import org.forester.protein.BasicProtein;
94 import org.forester.protein.Domain;
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( "Protein id: " );
176 if ( !testProteinId() ) {
177 System.out.println( "failed." );
183 System.out.println( "OK." );
184 System.out.print( "Species: " );
185 if ( !testSpecies() ) {
186 System.out.println( "failed." );
192 System.out.println( "OK." );
193 System.out.print( "Basic domain: " );
194 if ( !testBasicDomain() ) {
195 System.out.println( "failed." );
201 System.out.println( "OK." );
202 System.out.print( "Basic protein: " );
203 if ( !testBasicProtein() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Sequence writer: " );
212 if ( testSequenceWriter() ) {
213 System.out.println( "OK." );
217 System.out.println( "failed." );
220 System.out.print( "Sequence id parsing: " );
221 if ( testSequenceIdParsing() ) {
222 System.out.println( "OK." );
226 System.out.println( "failed." );
229 System.out.print( "Hmmscan output parser: " );
230 if ( testHmmscanOutputParser() ) {
231 System.out.println( "OK." );
235 System.out.println( "failed." );
238 System.out.print( "Basic node methods: " );
239 if ( Test.testBasicNodeMethods() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "Taxonomy code extraction: " );
248 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "SN extraction: " );
257 if ( Test.testExtractSNFromNodeName() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "Taxonomy extraction (general): " );
266 if ( Test.testTaxonomyExtraction() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "UniProtKB id extraction: " );
275 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
276 System.out.println( "OK." );
280 System.out.println( "failed." );
283 System.out.print( "Uri for Aptx web sequence accession: " );
284 if ( Test.testCreateUriForSeqWeb() ) {
285 System.out.println( "OK." );
289 System.out.println( "failed." );
292 System.out.print( "Basic node construction and parsing of NHX (node level): " );
293 if ( Test.testNHXNodeParsing() ) {
294 System.out.println( "OK." );
298 System.out.println( "failed." );
301 System.out.print( "NHX parsing iterating: " );
302 if ( Test.testNHParsingIter() ) {
303 System.out.println( "OK." );
307 System.out.println( "failed." );
310 System.out.print( "NH parsing: " );
311 if ( Test.testNHParsing() ) {
312 System.out.println( "OK." );
316 System.out.println( "failed." );
319 System.out.print( "Conversion to NHX (node level): " );
320 if ( Test.testNHXconversion() ) {
321 System.out.println( "OK." );
325 System.out.println( "failed." );
328 System.out.print( "NHX parsing: " );
329 if ( Test.testNHXParsing() ) {
330 System.out.println( "OK." );
334 System.out.println( "failed." );
337 System.out.print( "NHX parsing with quotes: " );
338 if ( Test.testNHXParsingQuotes() ) {
339 System.out.println( "OK." );
343 System.out.println( "failed." );
346 System.out.print( "NHX parsing (MrBayes): " );
347 if ( Test.testNHXParsingMB() ) {
348 System.out.println( "OK." );
352 System.out.println( "failed." );
355 System.out.print( "Nexus characters parsing: " );
356 if ( Test.testNexusCharactersParsing() ) {
357 System.out.println( "OK." );
361 System.out.println( "failed." );
364 System.out.print( "Nexus tree parsing iterating: " );
365 if ( Test.testNexusTreeParsingIterating() ) {
366 System.out.println( "OK." );
370 System.out.println( "failed." );
373 System.out.print( "Nexus tree parsing: " );
374 if ( Test.testNexusTreeParsing() ) {
375 System.out.println( "OK." );
379 System.out.println( "failed." );
382 System.out.print( "Nexus tree parsing (translating): " );
383 if ( Test.testNexusTreeParsingTranslating() ) {
384 System.out.println( "OK." );
388 System.out.println( "failed." );
391 System.out.print( "Nexus matrix parsing: " );
392 if ( Test.testNexusMatrixParsing() ) {
393 System.out.println( "OK." );
397 System.out.println( "failed." );
400 System.out.print( "Basic phyloXML parsing: " );
401 if ( Test.testBasicPhyloXMLparsing() ) {
402 System.out.println( "OK." );
406 System.out.println( "failed." );
409 System.out.print( "Basic phyloXML parsing (validating against schema): " );
410 if ( testBasicPhyloXMLparsingValidating() ) {
411 System.out.println( "OK." );
415 System.out.println( "failed." );
418 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
419 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
420 System.out.println( "OK." );
424 System.out.println( "failed." );
427 System.out.print( "phyloXML Distribution Element: " );
428 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
429 System.out.println( "OK." );
433 System.out.println( "failed." );
436 System.out.print( "Tol XML parsing: " );
437 if ( Test.testBasicTolXMLparsing() ) {
438 System.out.println( "OK." );
442 System.out.println( "failed." );
445 System.out.print( "Copying of node data: " );
446 if ( Test.testCopyOfNodeData() ) {
447 System.out.println( "OK." );
451 System.out.println( "failed." );
454 System.out.print( "Basic tree methods: " );
455 if ( Test.testBasicTreeMethods() ) {
456 System.out.println( "OK." );
460 System.out.println( "failed." );
463 System.out.print( "Tree methods: " );
464 if ( Test.testTreeMethods() ) {
465 System.out.println( "OK." );
469 System.out.println( "failed." );
472 System.out.print( "Postorder Iterator: " );
473 if ( Test.testPostOrderIterator() ) {
474 System.out.println( "OK." );
478 System.out.println( "failed." );
481 System.out.print( "Preorder Iterator: " );
482 if ( Test.testPreOrderIterator() ) {
483 System.out.println( "OK." );
487 System.out.println( "failed." );
490 System.out.print( "Levelorder Iterator: " );
491 if ( Test.testLevelOrderIterator() ) {
492 System.out.println( "OK." );
496 System.out.println( "failed." );
499 System.out.print( "Re-id methods: " );
500 if ( Test.testReIdMethods() ) {
501 System.out.println( "OK." );
505 System.out.println( "failed." );
508 System.out.print( "Methods on last external nodes: " );
509 if ( Test.testLastExternalNodeMethods() ) {
510 System.out.println( "OK." );
514 System.out.println( "failed." );
517 System.out.print( "Methods on external nodes: " );
518 if ( Test.testExternalNodeRelatedMethods() ) {
519 System.out.println( "OK." );
523 System.out.println( "failed." );
526 System.out.print( "Deletion of external nodes: " );
527 if ( Test.testDeletionOfExternalNodes() ) {
528 System.out.println( "OK." );
532 System.out.println( "failed." );
535 System.out.print( "Subtree deletion: " );
536 if ( Test.testSubtreeDeletion() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
544 System.out.print( "Phylogeny branch: " );
545 if ( Test.testPhylogenyBranch() ) {
546 System.out.println( "OK." );
550 System.out.println( "failed." );
553 System.out.print( "Rerooting: " );
554 if ( Test.testRerooting() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
562 System.out.print( "Mipoint rooting: " );
563 if ( Test.testMidpointrooting() ) {
564 System.out.println( "OK." );
568 System.out.println( "failed." );
571 System.out.print( "Node removal: " );
572 if ( Test.testNodeRemoval() ) {
573 System.out.println( "OK." );
577 System.out.println( "failed." );
580 System.out.print( "Support count: " );
581 if ( Test.testSupportCount() ) {
582 System.out.println( "OK." );
586 System.out.println( "failed." );
589 System.out.print( "Support transfer: " );
590 if ( Test.testSupportTransfer() ) {
591 System.out.println( "OK." );
595 System.out.println( "failed." );
598 System.out.print( "Finding of LCA: " );
599 if ( Test.testGetLCA() ) {
600 System.out.println( "OK." );
604 System.out.println( "failed." );
607 System.out.print( "Finding of LCA 2: " );
608 if ( Test.testGetLCA2() ) {
609 System.out.println( "OK." );
613 System.out.println( "failed." );
616 System.out.print( "Calculation of distance between nodes: " );
617 if ( Test.testGetDistance() ) {
618 System.out.println( "OK." );
622 System.out.println( "failed." );
625 System.out.print( "Descriptive statistics: " );
626 if ( Test.testDescriptiveStatistics() ) {
627 System.out.println( "OK." );
631 System.out.println( "failed." );
634 System.out.print( "Data objects and methods: " );
635 if ( Test.testDataObjects() ) {
636 System.out.println( "OK." );
640 System.out.println( "failed." );
643 System.out.print( "Properties map: " );
644 if ( Test.testPropertiesMap() ) {
645 System.out.println( "OK." );
649 System.out.println( "failed." );
652 System.out.print( "SDIse: " );
653 if ( Test.testSDIse() ) {
654 System.out.println( "OK." );
658 System.out.println( "failed." );
661 System.out.print( "SDIunrooted: " );
662 if ( Test.testSDIunrooted() ) {
663 System.out.println( "OK." );
667 System.out.println( "failed." );
670 System.out.print( "GSDI: " );
671 if ( TestGSDI.test() ) {
672 System.out.println( "OK." );
676 System.out.println( "failed." );
679 System.out.print( "RIO: " );
680 if ( TestRIO.test() ) {
681 System.out.println( "OK." );
685 System.out.println( "failed." );
688 System.out.print( "Phylogeny reconstruction:" );
689 System.out.println();
690 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
691 System.out.println( "OK." );
695 System.out.println( "failed." );
698 System.out.print( "Analysis of domain architectures: " );
699 System.out.println();
700 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
701 System.out.println( "OK." );
705 System.out.println( "failed." );
708 System.out.print( "GO: " );
709 System.out.println();
710 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
711 System.out.println( "OK." );
715 System.out.println( "failed." );
718 System.out.print( "Modeling tools: " );
719 if ( TestPccx.test() ) {
720 System.out.println( "OK." );
724 System.out.println( "failed." );
727 System.out.print( "Split Matrix strict: " );
728 if ( Test.testSplitStrict() ) {
729 System.out.println( "OK." );
733 System.out.println( "failed." );
736 System.out.print( "Split Matrix: " );
737 if ( Test.testSplit() ) {
738 System.out.println( "OK." );
742 System.out.println( "failed." );
745 System.out.print( "Confidence Assessor: " );
746 if ( Test.testConfidenceAssessor() ) {
747 System.out.println( "OK." );
751 System.out.println( "failed." );
754 System.out.print( "Basic table: " );
755 if ( Test.testBasicTable() ) {
756 System.out.println( "OK." );
760 System.out.println( "failed." );
763 System.out.print( "General table: " );
764 if ( Test.testGeneralTable() ) {
765 System.out.println( "OK." );
769 System.out.println( "failed." );
772 System.out.print( "Amino acid sequence: " );
773 if ( Test.testAminoAcidSequence() ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "General MSA parser: " );
782 if ( Test.testGeneralMsaParser() ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "Fasta parser for msa: " );
791 if ( Test.testFastaParser() ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "Creation of balanced phylogeny: " );
800 if ( Test.testCreateBalancedPhylogeny() ) {
801 System.out.println( "OK." );
805 System.out.println( "failed." );
808 System.out.print( "EMBL Entry Retrieval: " );
809 if ( Test.testEmblEntryRetrieval() ) {
810 System.out.println( "OK." );
814 System.out.println( "failed." );
817 System.out.print( "Uniprot Entry Retrieval: " );
818 if ( Test.testUniprotEntryRetrieval() ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Uniprot Taxonomy Search: " );
827 if ( Test.testUniprotTaxonomySearch() ) {
828 System.out.println( "OK." );
832 System.out.println( "failed." );
837 final String os = ForesterUtil.OS_NAME.toLowerCase();
838 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
839 path = "/usr/local/bin/mafft";
841 else if ( os.indexOf( "win" ) >= 0 ) {
842 path = "C:\\Program Files\\mafft-win\\mafft.bat";
845 path = "/home/czmasek/bin/mafft";
847 if ( !MsaInferrer.isInstalled( path ) ) {
850 if ( !MsaInferrer.isInstalled( path ) ) {
851 path = "/usr/local/bin/mafft";
853 if ( MsaInferrer.isInstalled( path ) ) {
854 System.out.print( "MAFFT (external program): " );
855 if ( Test.testMafft( path ) ) {
856 System.out.println( "OK." );
860 System.out.println( "failed [will not count towards failed tests]" );
864 System.out.print( "Next nodes with collapsed: " );
865 if ( Test.testNextNodeWithCollapsing() ) {
866 System.out.println( "OK." );
870 System.out.println( "failed." );
873 System.out.print( "Simple MSA quality: " );
874 if ( Test.testMsaQualityMethod() ) {
875 System.out.println( "OK." );
879 System.out.println( "failed." );
882 System.out.println();
883 final Runtime rt = java.lang.Runtime.getRuntime();
884 final long free_memory = rt.freeMemory() / 1000000;
885 final long total_memory = rt.totalMemory() / 1000000;
886 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
887 + free_memory + "MB, total memory: " + total_memory + "MB)" );
888 System.out.println();
889 System.out.println( "Successful tests: " + succeeded );
890 System.out.println( "Failed tests: " + failed );
891 System.out.println();
893 System.out.println( "OK." );
896 System.out.println( "Not OK." );
900 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
901 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
905 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
906 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
909 private static boolean testAminoAcidSequence() {
911 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
912 if ( aa1.getLength() != 13 ) {
915 if ( aa1.getResidueAt( 0 ) != 'A' ) {
918 if ( aa1.getResidueAt( 2 ) != 'K' ) {
921 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
924 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
925 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
928 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
929 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
932 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
933 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
937 catch ( final Exception e ) {
944 private static boolean testBasicDomain() {
946 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
947 if ( !pd.getDomainId().equals( "id" ) ) {
950 if ( pd.getNumber() != 1 ) {
953 if ( pd.getTotalCount() != 4 ) {
956 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
959 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
960 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
961 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
962 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
963 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
964 if ( !a1.equals( a1 ) ) {
967 if ( !a1.equals( a1_copy ) ) {
970 if ( !a1.equals( a1_equal ) ) {
973 if ( !a1.equals( a2 ) ) {
976 if ( a1.equals( a3 ) ) {
979 if ( a1.compareTo( a1 ) != 0 ) {
982 if ( a1.compareTo( a1_copy ) != 0 ) {
985 if ( a1.compareTo( a1_equal ) != 0 ) {
988 if ( a1.compareTo( a2 ) != 0 ) {
991 if ( a1.compareTo( a3 ) == 0 ) {
995 catch ( final Exception e ) {
996 e.printStackTrace( System.out );
1002 private static boolean testBasicNodeMethods() {
1004 if ( PhylogenyNode.getNodeCount() != 0 ) {
1007 final PhylogenyNode n1 = new PhylogenyNode();
1008 final PhylogenyNode n2 = PhylogenyNode
1009 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1010 final PhylogenyNode n3 = PhylogenyNode
1011 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1012 final PhylogenyNode n4 = PhylogenyNode
1013 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1014 if ( n1.isHasAssignedEvent() ) {
1017 if ( PhylogenyNode.getNodeCount() != 4 ) {
1020 if ( n3.getIndicator() != 0 ) {
1023 if ( n3.getNumberOfExternalNodes() != 1 ) {
1026 if ( !n3.isExternal() ) {
1029 if ( !n3.isRoot() ) {
1032 if ( !n4.getName().equals( "n4" ) ) {
1036 catch ( final Exception e ) {
1037 e.printStackTrace( System.out );
1043 private static boolean testBasicPhyloXMLparsing() {
1045 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1046 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1047 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1049 if ( xml_parser.getErrorCount() > 0 ) {
1050 System.out.println( xml_parser.getErrorMessages().toString() );
1053 if ( phylogenies_0.length != 4 ) {
1056 final Phylogeny t1 = phylogenies_0[ 0 ];
1057 final Phylogeny t2 = phylogenies_0[ 1 ];
1058 final Phylogeny t3 = phylogenies_0[ 2 ];
1059 final Phylogeny t4 = phylogenies_0[ 3 ];
1060 if ( t1.getNumberOfExternalNodes() != 1 ) {
1063 if ( !t1.isRooted() ) {
1066 if ( t1.isRerootable() ) {
1069 if ( !t1.getType().equals( "gene_tree" ) ) {
1072 if ( t2.getNumberOfExternalNodes() != 2 ) {
1075 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1078 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1081 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1084 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1087 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1090 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1093 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1094 .startsWith( "actgtgggggt" ) ) {
1097 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1098 .startsWith( "ctgtgatgcat" ) ) {
1101 if ( t3.getNumberOfExternalNodes() != 4 ) {
1104 if ( !t1.getName().equals( "t1" ) ) {
1107 if ( !t2.getName().equals( "t2" ) ) {
1110 if ( !t3.getName().equals( "t3" ) ) {
1113 if ( !t4.getName().equals( "t4" ) ) {
1116 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1119 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1122 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1125 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1126 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1129 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1132 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1135 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1138 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1139 .equals( "apoptosis" ) ) {
1142 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1143 .equals( "GO:0006915" ) ) {
1146 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1147 .equals( "UniProtKB" ) ) {
1150 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1151 .equals( "experimental" ) ) {
1154 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1155 .equals( "function" ) ) {
1158 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1159 .getValue() != 1 ) {
1162 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1163 .getType().equals( "ml" ) ) {
1166 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1167 .equals( "apoptosis" ) ) {
1170 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1171 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1174 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1175 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1178 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1179 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1182 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1183 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1186 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1187 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1190 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1191 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1194 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1195 .equals( "GO:0005829" ) ) {
1198 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1199 .equals( "intracellular organelle" ) ) {
1202 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1205 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1206 .equals( "UniProt link" ) ) ) {
1209 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1212 SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1213 if ( x.size() != 4 ) {
1217 for( Accession acc : x ) {
1219 if ( !acc.getSource().equals( "KEGG" ) ) {
1222 if ( !acc.getValue().equals( "hsa:596" ) ) {
1229 catch ( final Exception e ) {
1230 e.printStackTrace( System.out );
1236 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1238 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1239 final PhyloXmlParser xml_parser = new PhyloXmlParser();
1240 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1241 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1244 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1246 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1248 if ( xml_parser.getErrorCount() > 0 ) {
1249 System.out.println( xml_parser.getErrorMessages().toString() );
1252 if ( phylogenies_0.length != 4 ) {
1255 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1256 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1257 if ( phylogenies_t1.length != 1 ) {
1260 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1261 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1264 if ( !t1_rt.isRooted() ) {
1267 if ( t1_rt.isRerootable() ) {
1270 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1273 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1274 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1275 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1276 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1279 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1282 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1285 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1288 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1289 .startsWith( "actgtgggggt" ) ) {
1292 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1293 .startsWith( "ctgtgatgcat" ) ) {
1296 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1297 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1298 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1299 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1300 if ( phylogenies_1.length != 1 ) {
1303 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1304 if ( !t3_rt.getName().equals( "t3" ) ) {
1307 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1310 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1313 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1316 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1319 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1320 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1323 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1326 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1329 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1330 .equals( "UniProtKB" ) ) {
1333 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1334 .equals( "apoptosis" ) ) {
1337 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1338 .equals( "GO:0006915" ) ) {
1341 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1342 .equals( "UniProtKB" ) ) {
1345 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1346 .equals( "experimental" ) ) {
1349 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1350 .equals( "function" ) ) {
1353 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1354 .getValue() != 1 ) {
1357 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1358 .getType().equals( "ml" ) ) {
1361 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1362 .equals( "apoptosis" ) ) {
1365 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1366 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1369 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1370 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1373 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1374 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1377 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1378 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1381 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1382 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1385 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1386 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1389 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1390 .equals( "GO:0005829" ) ) {
1393 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1394 .equals( "intracellular organelle" ) ) {
1397 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1400 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1401 .equals( "UniProt link" ) ) ) {
1404 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1407 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1410 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1411 .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." ) ) ) {
1414 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1417 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1420 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1423 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1426 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1427 .equals( "ncbi" ) ) {
1430 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
1433 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1434 .getName().equals( "B" ) ) {
1437 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1438 .getFrom() != 21 ) {
1441 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
1444 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1445 .getLength() != 24 ) {
1448 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
1449 .getConfidence() != 2144 ) {
1452 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
1453 .equals( "pfam" ) ) {
1456 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
1459 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1462 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
1465 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
1468 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
1469 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
1472 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
1475 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
1478 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
1481 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
1484 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
1487 if ( taxbb.getSynonyms().size() != 2 ) {
1490 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
1493 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
1496 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
1499 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
1502 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
1505 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
1506 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
1510 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1513 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1516 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1519 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1522 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1525 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1528 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1532 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1535 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1536 .equalsIgnoreCase( "435" ) ) {
1539 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1542 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1543 .equalsIgnoreCase( "443.7" ) ) {
1546 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1549 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1552 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1553 .equalsIgnoreCase( "433" ) ) {
1556 SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1557 if ( x.size() != 4 ) {
1561 for( Accession acc : x ) {
1563 if ( !acc.getSource().equals( "KEGG" ) ) {
1566 if ( !acc.getValue().equals( "hsa:596" ) ) {
1573 catch ( final Exception e ) {
1574 e.printStackTrace( System.out );
1580 private static boolean testBasicPhyloXMLparsingValidating() {
1582 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1583 PhyloXmlParser xml_parser = null;
1585 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
1587 catch ( final Exception e ) {
1588 // Do nothing -- means were not running from jar.
1590 if ( xml_parser == null ) {
1591 xml_parser = new PhyloXmlParser();
1592 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1593 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1596 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1599 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1601 if ( xml_parser.getErrorCount() > 0 ) {
1602 System.out.println( xml_parser.getErrorMessages().toString() );
1605 if ( phylogenies_0.length != 4 ) {
1608 final Phylogeny t1 = phylogenies_0[ 0 ];
1609 final Phylogeny t2 = phylogenies_0[ 1 ];
1610 final Phylogeny t3 = phylogenies_0[ 2 ];
1611 final Phylogeny t4 = phylogenies_0[ 3 ];
1612 if ( !t1.getName().equals( "t1" ) ) {
1615 if ( !t2.getName().equals( "t2" ) ) {
1618 if ( !t3.getName().equals( "t3" ) ) {
1621 if ( !t4.getName().equals( "t4" ) ) {
1624 if ( t1.getNumberOfExternalNodes() != 1 ) {
1627 if ( t2.getNumberOfExternalNodes() != 2 ) {
1630 if ( t3.getNumberOfExternalNodes() != 4 ) {
1633 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
1634 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
1635 if ( xml_parser.getErrorCount() > 0 ) {
1636 System.out.println( "errors:" );
1637 System.out.println( xml_parser.getErrorMessages().toString() );
1640 if ( phylogenies_1.length != 4 ) {
1643 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
1645 if ( xml_parser.getErrorCount() > 0 ) {
1646 System.out.println( "errors:" );
1647 System.out.println( xml_parser.getErrorMessages().toString() );
1650 if ( phylogenies_2.length != 1 ) {
1653 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
1656 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
1658 if ( xml_parser.getErrorCount() > 0 ) {
1659 System.out.println( xml_parser.getErrorMessages().toString() );
1662 if ( phylogenies_3.length != 2 ) {
1665 final Phylogeny a = phylogenies_3[ 0 ];
1666 if ( !a.getName().equals( "tree 4" ) ) {
1669 if ( a.getNumberOfExternalNodes() != 3 ) {
1672 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
1675 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
1678 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
1680 if ( xml_parser.getErrorCount() > 0 ) {
1681 System.out.println( xml_parser.getErrorMessages().toString() );
1684 if ( phylogenies_4.length != 1 ) {
1687 final Phylogeny s = phylogenies_4[ 0 ];
1688 if ( s.getNumberOfExternalNodes() != 6 ) {
1691 s.getNode( "first" );
1693 s.getNode( "\"<a'b&c'd\">\"" );
1694 s.getNode( "'''\"" );
1695 s.getNode( "\"\"\"" );
1696 s.getNode( "dick & doof" );
1698 catch ( final Exception e ) {
1699 e.printStackTrace( System.out );
1705 private static boolean testBasicProtein() {
1707 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
1708 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1709 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1710 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1711 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1712 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1713 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1714 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1715 p0.addProteinDomain( y );
1716 p0.addProteinDomain( e );
1717 p0.addProteinDomain( b );
1718 p0.addProteinDomain( c );
1719 p0.addProteinDomain( d );
1720 p0.addProteinDomain( a );
1721 p0.addProteinDomain( x );
1722 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
1725 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
1729 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
1730 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1731 aa0.addProteinDomain( a1 );
1732 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
1735 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
1739 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
1740 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1741 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1742 aa1.addProteinDomain( a11 );
1743 aa1.addProteinDomain( a12 );
1744 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
1747 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
1750 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1751 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
1754 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1757 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
1760 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1761 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
1764 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
1767 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
1770 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
1773 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1774 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
1777 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
1780 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
1783 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
1786 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
1787 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
1790 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
1793 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
1796 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
1800 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
1801 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
1802 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
1803 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
1804 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
1805 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
1806 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
1807 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
1808 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
1809 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
1810 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
1811 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1812 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
1813 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
1814 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
1815 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
1816 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
1817 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
1818 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
1819 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
1820 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
1821 p00.addProteinDomain( y0 );
1822 p00.addProteinDomain( e0 );
1823 p00.addProteinDomain( b0 );
1824 p00.addProteinDomain( c0 );
1825 p00.addProteinDomain( d0 );
1826 p00.addProteinDomain( a0 );
1827 p00.addProteinDomain( x0 );
1828 p00.addProteinDomain( y1 );
1829 p00.addProteinDomain( y2 );
1830 p00.addProteinDomain( y3 );
1831 p00.addProteinDomain( e1 );
1832 p00.addProteinDomain( e2 );
1833 p00.addProteinDomain( e3 );
1834 p00.addProteinDomain( e4 );
1835 p00.addProteinDomain( e5 );
1836 p00.addProteinDomain( z0 );
1837 p00.addProteinDomain( z1 );
1838 p00.addProteinDomain( z2 );
1839 p00.addProteinDomain( zz0 );
1840 p00.addProteinDomain( zz1 );
1841 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
1844 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
1847 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1850 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1853 if ( !p00.toDomainArchitectureString( "~", 7, "" ).equals( "a~b~c~d~e~e~e~e~e~e~x~y~y~y~y~z~z~z~Z~Z" ) ) {
1856 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1857 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1858 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1859 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1860 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1861 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1862 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1863 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1864 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1865 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1866 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1867 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1868 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1869 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1870 p.addProteinDomain( B15 );
1871 p.addProteinDomain( C50 );
1872 p.addProteinDomain( A60 );
1873 p.addProteinDomain( A30 );
1874 p.addProteinDomain( C70 );
1875 p.addProteinDomain( B35 );
1876 p.addProteinDomain( B40 );
1877 p.addProteinDomain( A0 );
1878 p.addProteinDomain( A10 );
1879 p.addProteinDomain( A20 );
1880 p.addProteinDomain( B25 );
1881 p.addProteinDomain( D80 );
1882 List<String> domains_ids = new ArrayList<String>();
1883 domains_ids.add( "A" );
1884 domains_ids.add( "B" );
1885 domains_ids.add( "C" );
1886 if ( !p.contains( domains_ids, false ) ) {
1889 if ( !p.contains( domains_ids, true ) ) {
1892 domains_ids.add( "X" );
1893 if ( p.contains( domains_ids, false ) ) {
1896 if ( p.contains( domains_ids, true ) ) {
1899 domains_ids = new ArrayList<String>();
1900 domains_ids.add( "A" );
1901 domains_ids.add( "C" );
1902 domains_ids.add( "D" );
1903 if ( !p.contains( domains_ids, false ) ) {
1906 if ( !p.contains( domains_ids, true ) ) {
1909 domains_ids = new ArrayList<String>();
1910 domains_ids.add( "A" );
1911 domains_ids.add( "D" );
1912 domains_ids.add( "C" );
1913 if ( !p.contains( domains_ids, false ) ) {
1916 if ( p.contains( domains_ids, true ) ) {
1919 domains_ids = new ArrayList<String>();
1920 domains_ids.add( "A" );
1921 domains_ids.add( "A" );
1922 domains_ids.add( "B" );
1923 if ( !p.contains( domains_ids, false ) ) {
1926 if ( !p.contains( domains_ids, true ) ) {
1929 domains_ids = new ArrayList<String>();
1930 domains_ids.add( "A" );
1931 domains_ids.add( "A" );
1932 domains_ids.add( "A" );
1933 domains_ids.add( "B" );
1934 domains_ids.add( "B" );
1935 if ( !p.contains( domains_ids, false ) ) {
1938 if ( !p.contains( domains_ids, true ) ) {
1941 domains_ids = new ArrayList<String>();
1942 domains_ids.add( "A" );
1943 domains_ids.add( "A" );
1944 domains_ids.add( "B" );
1945 domains_ids.add( "A" );
1946 domains_ids.add( "B" );
1947 domains_ids.add( "B" );
1948 domains_ids.add( "A" );
1949 domains_ids.add( "B" );
1950 domains_ids.add( "C" );
1951 domains_ids.add( "A" );
1952 domains_ids.add( "C" );
1953 domains_ids.add( "D" );
1954 if ( !p.contains( domains_ids, false ) ) {
1957 if ( p.contains( domains_ids, true ) ) {
1961 catch ( final Exception e ) {
1962 e.printStackTrace( System.out );
1968 private static boolean testBasicTable() {
1970 final BasicTable<String> t0 = new BasicTable<String>();
1971 if ( t0.getNumberOfColumns() != 0 ) {
1974 if ( t0.getNumberOfRows() != 0 ) {
1977 t0.setValue( 3, 2, "23" );
1978 t0.setValue( 10, 1, "error" );
1979 t0.setValue( 10, 1, "110" );
1980 t0.setValue( 9, 1, "19" );
1981 t0.setValue( 1, 10, "101" );
1982 t0.setValue( 10, 10, "1010" );
1983 t0.setValue( 100, 10, "10100" );
1984 t0.setValue( 0, 0, "00" );
1985 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
1988 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
1991 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
1994 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
1997 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2000 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2003 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2006 if ( t0.getNumberOfColumns() != 101 ) {
2009 if ( t0.getNumberOfRows() != 11 ) {
2012 if ( t0.getValueAsString( 49, 4 ) != null ) {
2015 final String l = ForesterUtil.getLineSeparator();
2016 final StringBuffer source = new StringBuffer();
2017 source.append( "" + l );
2018 source.append( "# 1 1 1 1 1 1 1 1" + l );
2019 source.append( " 00 01 02 03" + l );
2020 source.append( " 10 11 12 13 " + l );
2021 source.append( "20 21 22 23 " + l );
2022 source.append( " 30 31 32 33" + l );
2023 source.append( "40 41 42 43" + l );
2024 source.append( " # 1 1 1 1 1 " + l );
2025 source.append( "50 51 52 53 54" + l );
2026 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2027 if ( t1.getNumberOfColumns() != 5 ) {
2030 if ( t1.getNumberOfRows() != 6 ) {
2033 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2036 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2039 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2042 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2045 final StringBuffer source1 = new StringBuffer();
2046 source1.append( "" + l );
2047 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2048 source1.append( " 00; 01 ;02;03" + l );
2049 source1.append( " 10; 11; 12; 13 " + l );
2050 source1.append( "20; 21; 22; 23 " + l );
2051 source1.append( " 30; 31; 32; 33" + l );
2052 source1.append( "40;41;42;43" + l );
2053 source1.append( " # 1 1 1 1 1 " + l );
2054 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2055 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2056 if ( t2.getNumberOfColumns() != 5 ) {
2059 if ( t2.getNumberOfRows() != 6 ) {
2062 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2065 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2068 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2071 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2074 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2077 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2080 final StringBuffer source2 = new StringBuffer();
2081 source2.append( "" + l );
2082 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2083 source2.append( " 00; 01 ;02;03" + l );
2084 source2.append( " 10; 11; 12; 13 " + l );
2085 source2.append( "20; 21; 22; 23 " + l );
2086 source2.append( " " + l );
2087 source2.append( " 30; 31; 32; 33" + l );
2088 source2.append( "40;41;42;43" + l );
2089 source2.append( " comment: 1 1 1 1 1 " + l );
2090 source2.append( ";;;50 ; 52; 53;;54 " + l );
2091 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2097 if ( tl.size() != 2 ) {
2100 final BasicTable<String> t3 = tl.get( 0 );
2101 final BasicTable<String> t4 = tl.get( 1 );
2102 if ( t3.getNumberOfColumns() != 4 ) {
2105 if ( t3.getNumberOfRows() != 3 ) {
2108 if ( t4.getNumberOfColumns() != 4 ) {
2111 if ( t4.getNumberOfRows() != 3 ) {
2114 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2117 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2121 catch ( final Exception e ) {
2122 e.printStackTrace( System.out );
2128 private static boolean testBasicTolXMLparsing() {
2130 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2131 final TolParser parser = new TolParser();
2132 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2133 if ( parser.getErrorCount() > 0 ) {
2134 System.out.println( parser.getErrorMessages().toString() );
2137 if ( phylogenies_0.length != 1 ) {
2140 final Phylogeny t1 = phylogenies_0[ 0 ];
2141 if ( t1.getNumberOfExternalNodes() != 5 ) {
2144 if ( !t1.isRooted() ) {
2147 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2150 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2153 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2156 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2159 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2160 if ( parser.getErrorCount() > 0 ) {
2161 System.out.println( parser.getErrorMessages().toString() );
2164 if ( phylogenies_1.length != 1 ) {
2167 final Phylogeny t2 = phylogenies_1[ 0 ];
2168 if ( t2.getNumberOfExternalNodes() != 664 ) {
2171 if ( !t2.isRooted() ) {
2174 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2177 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2180 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2183 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2186 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2189 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2190 .equals( "Aquifex" ) ) {
2193 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2194 if ( parser.getErrorCount() > 0 ) {
2195 System.out.println( parser.getErrorMessages().toString() );
2198 if ( phylogenies_2.length != 1 ) {
2201 final Phylogeny t3 = phylogenies_2[ 0 ];
2202 if ( t3.getNumberOfExternalNodes() != 184 ) {
2205 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2208 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2211 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2214 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2215 if ( parser.getErrorCount() > 0 ) {
2216 System.out.println( parser.getErrorMessages().toString() );
2219 if ( phylogenies_3.length != 1 ) {
2222 final Phylogeny t4 = phylogenies_3[ 0 ];
2223 if ( t4.getNumberOfExternalNodes() != 1 ) {
2226 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2229 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2232 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2235 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2236 if ( parser.getErrorCount() > 0 ) {
2237 System.out.println( parser.getErrorMessages().toString() );
2240 if ( phylogenies_4.length != 1 ) {
2243 final Phylogeny t5 = phylogenies_4[ 0 ];
2244 if ( t5.getNumberOfExternalNodes() != 13 ) {
2247 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2250 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2253 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2257 catch ( final Exception e ) {
2258 e.printStackTrace( System.out );
2264 private static boolean testBasicTreeMethods() {
2266 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2267 final Phylogeny t1 = factory.create();
2268 if ( !t1.isEmpty() ) {
2271 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2272 if ( t2.getNumberOfExternalNodes() != 4 ) {
2275 if ( t2.getHeight() != 8.5 ) {
2278 if ( !t2.isCompletelyBinary() ) {
2281 if ( t2.isEmpty() ) {
2284 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2285 if ( t3.getNumberOfExternalNodes() != 5 ) {
2288 if ( t3.getHeight() != 11 ) {
2291 if ( t3.isCompletelyBinary() ) {
2294 final PhylogenyNode n = t3.getNode( "ABC" );
2295 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 ];
2296 if ( t4.getNumberOfExternalNodes() != 9 ) {
2299 if ( t4.getHeight() != 11 ) {
2302 if ( t4.isCompletelyBinary() ) {
2305 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)" );
2306 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2307 if ( t5.getNumberOfExternalNodes() != 8 ) {
2310 if ( t5.getHeight() != 15 ) {
2313 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)" );
2314 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2315 if ( t6.getHeight() != 15 ) {
2318 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)" );
2319 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2320 if ( t7.getHeight() != 15 ) {
2323 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)" );
2324 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2325 if ( t8.getNumberOfExternalNodes() != 10 ) {
2328 if ( t8.getHeight() != 15 ) {
2331 final char[] a9 = new char[] { 'a' };
2332 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2333 if ( t9.getHeight() != 0 ) {
2336 final char[] a10 = new char[] { 'a', ':', '6' };
2337 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2338 if ( t10.getHeight() != 6 ) {
2342 catch ( final Exception e ) {
2343 e.printStackTrace( System.out );
2349 private static boolean testConfidenceAssessor() {
2351 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2352 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2353 final Phylogeny[] ev0 = factory
2354 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2356 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2357 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2360 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2363 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2364 final Phylogeny[] ev1 = factory
2365 .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)));",
2367 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2368 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2371 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2374 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2375 final Phylogeny[] ev_b = factory
2376 .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",
2378 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2379 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2382 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2386 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2387 final Phylogeny[] ev1x = factory
2388 .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)));",
2390 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2391 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2394 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2397 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2398 final Phylogeny[] ev_bx = factory
2399 .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",
2401 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2402 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2405 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2409 final Phylogeny[] t2 = factory
2410 .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);",
2412 final Phylogeny[] ev2 = factory
2413 .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);",
2415 for( final Phylogeny target : t2 ) {
2416 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2419 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2420 new NHXParser() )[ 0 ];
2421 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2422 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2423 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2426 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2429 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2433 catch ( final Exception e ) {
2434 e.printStackTrace();
2440 private static boolean testCopyOfNodeData() {
2442 final PhylogenyNode n1 = PhylogenyNode
2443 .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]" );
2444 final PhylogenyNode n2 = n1.copyNodeData();
2445 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
2449 catch ( final Exception e ) {
2450 e.printStackTrace();
2456 private static boolean testCreateBalancedPhylogeny() {
2458 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
2459 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
2462 if ( p0.getNumberOfExternalNodes() != 15625 ) {
2465 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
2466 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
2469 if ( p1.getNumberOfExternalNodes() != 100 ) {
2473 catch ( final Exception e ) {
2474 e.printStackTrace();
2480 private static boolean testCreateUriForSeqWeb() {
2482 final PhylogenyNode n = new PhylogenyNode();
2483 n.setName( "tr|B3RJ64" );
2484 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
2487 n.setName( "B0LM41_HUMAN" );
2488 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
2491 n.setName( "NP_001025424" );
2492 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
2495 n.setName( "_NM_001030253-" );
2496 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
2499 n.setName( "XM_002122186" );
2500 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
2503 n.setName( "dgh_AAA34956_gdg" );
2504 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
2507 n.setName( "j40f4_Q06891.1_fndn2 fnr3" );
2508 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "Q06891.1" ) ) {
2511 n.setName( "GI:394892" );
2512 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2513 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2516 n.setName( "gi_394892" );
2517 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2518 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2521 n.setName( "gi6335_gi_394892_56635_Gi_43" );
2522 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
2523 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2527 catch ( final Exception e ) {
2528 e.printStackTrace( System.out );
2534 private static boolean testDataObjects() {
2536 final Confidence s0 = new Confidence();
2537 final Confidence s1 = new Confidence();
2538 if ( !s0.isEqual( s1 ) ) {
2541 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2542 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2543 if ( s2.isEqual( s1 ) ) {
2546 if ( !s2.isEqual( s3 ) ) {
2549 final Confidence s4 = ( Confidence ) s3.copy();
2550 if ( !s4.isEqual( s3 ) ) {
2557 final Taxonomy t1 = new Taxonomy();
2558 final Taxonomy t2 = new Taxonomy();
2559 final Taxonomy t3 = new Taxonomy();
2560 final Taxonomy t4 = new Taxonomy();
2561 final Taxonomy t5 = new Taxonomy();
2562 t1.setIdentifier( new Identifier( "ecoli" ) );
2563 t1.setTaxonomyCode( "ECOLI" );
2564 t1.setScientificName( "E. coli" );
2565 t1.setCommonName( "coli" );
2566 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2567 if ( !t1.isEqual( t0 ) ) {
2570 t2.setIdentifier( new Identifier( "ecoli" ) );
2571 t2.setTaxonomyCode( "OTHER" );
2572 t2.setScientificName( "what" );
2573 t2.setCommonName( "something" );
2574 if ( !t1.isEqual( t2 ) ) {
2577 t2.setIdentifier( new Identifier( "nemve" ) );
2578 if ( t1.isEqual( t2 ) ) {
2581 t1.setIdentifier( null );
2582 t3.setTaxonomyCode( "ECOLI" );
2583 t3.setScientificName( "what" );
2584 t3.setCommonName( "something" );
2585 if ( !t1.isEqual( t3 ) ) {
2588 t1.setIdentifier( null );
2589 t1.setTaxonomyCode( "" );
2590 t4.setScientificName( "E. ColI" );
2591 t4.setCommonName( "something" );
2592 if ( !t1.isEqual( t4 ) ) {
2595 t4.setScientificName( "B. subtilis" );
2596 t4.setCommonName( "something" );
2597 if ( t1.isEqual( t4 ) ) {
2600 t1.setIdentifier( null );
2601 t1.setTaxonomyCode( "" );
2602 t1.setScientificName( "" );
2603 t5.setCommonName( "COLI" );
2604 if ( !t1.isEqual( t5 ) ) {
2607 t5.setCommonName( "vibrio" );
2608 if ( t1.isEqual( t5 ) ) {
2613 final Identifier id0 = new Identifier( "123", "pfam" );
2614 final Identifier id1 = ( Identifier ) id0.copy();
2615 if ( !id1.isEqual( id1 ) ) {
2618 if ( !id1.isEqual( id0 ) ) {
2621 if ( !id0.isEqual( id1 ) ) {
2628 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2629 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2630 if ( !pd1.isEqual( pd1 ) ) {
2633 if ( !pd1.isEqual( pd0 ) ) {
2638 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2639 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2640 if ( !pd3.isEqual( pd3 ) ) {
2643 if ( !pd2.isEqual( pd3 ) ) {
2646 if ( !pd0.isEqual( pd3 ) ) {
2651 // DomainArchitecture
2652 // ------------------
2653 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2654 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2655 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2656 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2657 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2658 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2663 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2664 if ( ds0.getNumberOfDomains() != 4 ) {
2667 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2668 if ( !ds0.isEqual( ds0 ) ) {
2671 if ( !ds0.isEqual( ds1 ) ) {
2674 if ( ds1.getNumberOfDomains() != 4 ) {
2677 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2682 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2683 if ( ds0.isEqual( ds2 ) ) {
2689 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2690 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2691 System.out.println( ds3.toNHX() );
2694 if ( ds3.getNumberOfDomains() != 3 ) {
2699 final Event e1 = new Event( Event.EventType.fusion );
2700 if ( e1.isDuplication() ) {
2703 if ( !e1.isFusion() ) {
2706 if ( !e1.asText().toString().equals( "fusion" ) ) {
2709 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2712 final Event e11 = new Event( Event.EventType.fusion );
2713 if ( !e11.isEqual( e1 ) ) {
2716 if ( !e11.toNHX().toString().equals( "" ) ) {
2719 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2720 if ( e2.isDuplication() ) {
2723 if ( !e2.isSpeciationOrDuplication() ) {
2726 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2729 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2732 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2735 if ( e11.isEqual( e2 ) ) {
2738 final Event e2c = ( Event ) e2.copy();
2739 if ( !e2c.isEqual( e2 ) ) {
2742 Event e3 = new Event( 1, 2, 3 );
2743 if ( e3.isDuplication() ) {
2746 if ( e3.isSpeciation() ) {
2749 if ( e3.isGeneLoss() ) {
2752 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2755 final Event e3c = ( Event ) e3.copy();
2756 final Event e3cc = ( Event ) e3c.copy();
2757 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2761 if ( !e3c.isEqual( e3cc ) ) {
2764 Event e4 = new Event( 1, 2, 3 );
2765 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2768 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2771 final Event e4c = ( Event ) e4.copy();
2773 final Event e4cc = ( Event ) e4c.copy();
2774 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2777 if ( !e4c.isEqual( e4cc ) ) {
2780 final Event e5 = new Event();
2781 if ( !e5.isUnassigned() ) {
2784 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2787 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2790 final Event e6 = new Event( 1, 0, 0 );
2791 if ( !e6.asText().toString().equals( "duplication" ) ) {
2794 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2797 final Event e7 = new Event( 0, 1, 0 );
2798 if ( !e7.asText().toString().equals( "speciation" ) ) {
2801 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2804 final Event e8 = new Event( 0, 0, 1 );
2805 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2808 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2812 catch ( final Exception e ) {
2813 e.printStackTrace( System.out );
2819 private static boolean testDeletionOfExternalNodes() {
2821 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2822 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2823 final PhylogenyWriter w = new PhylogenyWriter();
2824 if ( t0.isEmpty() ) {
2827 if ( t0.getNumberOfExternalNodes() != 1 ) {
2830 t0.deleteSubtree( t0.getNode( "A" ), false );
2831 if ( t0.getNumberOfExternalNodes() != 0 ) {
2834 if ( !t0.isEmpty() ) {
2837 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2838 if ( t1.getNumberOfExternalNodes() != 2 ) {
2841 t1.deleteSubtree( t1.getNode( "A" ), false );
2842 if ( t1.getNumberOfExternalNodes() != 1 ) {
2845 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2848 t1.deleteSubtree( t1.getNode( "B" ), false );
2849 if ( t1.getNumberOfExternalNodes() != 1 ) {
2852 t1.deleteSubtree( t1.getNode( "r" ), false );
2853 if ( !t1.isEmpty() ) {
2856 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2857 if ( t2.getNumberOfExternalNodes() != 3 ) {
2860 t2.deleteSubtree( t2.getNode( "B" ), false );
2861 if ( t2.getNumberOfExternalNodes() != 2 ) {
2864 t2.toNewHampshireX();
2865 PhylogenyNode n = t2.getNode( "A" );
2866 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2869 t2.deleteSubtree( t2.getNode( "A" ), false );
2870 if ( t2.getNumberOfExternalNodes() != 2 ) {
2873 t2.deleteSubtree( t2.getNode( "C" ), true );
2874 if ( t2.getNumberOfExternalNodes() != 1 ) {
2877 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2878 if ( t3.getNumberOfExternalNodes() != 4 ) {
2881 t3.deleteSubtree( t3.getNode( "B" ), true );
2882 if ( t3.getNumberOfExternalNodes() != 3 ) {
2885 n = t3.getNode( "A" );
2886 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2889 n = n.getNextExternalNode();
2890 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2893 t3.deleteSubtree( t3.getNode( "A" ), true );
2894 if ( t3.getNumberOfExternalNodes() != 2 ) {
2897 n = t3.getNode( "C" );
2898 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2901 t3.deleteSubtree( t3.getNode( "C" ), true );
2902 if ( t3.getNumberOfExternalNodes() != 1 ) {
2905 t3.deleteSubtree( t3.getNode( "D" ), true );
2906 if ( t3.getNumberOfExternalNodes() != 0 ) {
2909 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2910 if ( t4.getNumberOfExternalNodes() != 6 ) {
2913 t4.deleteSubtree( t4.getNode( "B2" ), true );
2914 if ( t4.getNumberOfExternalNodes() != 5 ) {
2917 String s = w.toNewHampshire( t4, false, true ).toString();
2918 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2921 t4.deleteSubtree( t4.getNode( "B11" ), true );
2922 if ( t4.getNumberOfExternalNodes() != 4 ) {
2925 t4.deleteSubtree( t4.getNode( "C" ), true );
2926 if ( t4.getNumberOfExternalNodes() != 3 ) {
2929 n = t4.getNode( "A" );
2930 n = n.getNextExternalNode();
2931 if ( !n.getName().equals( "B12" ) ) {
2934 n = n.getNextExternalNode();
2935 if ( !n.getName().equals( "D" ) ) {
2938 s = w.toNewHampshire( t4, false, true ).toString();
2939 if ( !s.equals( "((A,B12),D);" ) ) {
2942 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2943 t5.deleteSubtree( t5.getNode( "A" ), true );
2944 if ( t5.getNumberOfExternalNodes() != 5 ) {
2947 s = w.toNewHampshire( t5, false, true ).toString();
2948 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2951 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2952 t6.deleteSubtree( t6.getNode( "B11" ), true );
2953 if ( t6.getNumberOfExternalNodes() != 5 ) {
2956 s = w.toNewHampshire( t6, false, false ).toString();
2957 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2960 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2961 t7.deleteSubtree( t7.getNode( "B12" ), true );
2962 if ( t7.getNumberOfExternalNodes() != 5 ) {
2965 s = w.toNewHampshire( t7, false, true ).toString();
2966 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2969 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2970 t8.deleteSubtree( t8.getNode( "B2" ), true );
2971 if ( t8.getNumberOfExternalNodes() != 5 ) {
2974 s = w.toNewHampshire( t8, false, false ).toString();
2975 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2978 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2979 t9.deleteSubtree( t9.getNode( "C" ), true );
2980 if ( t9.getNumberOfExternalNodes() != 5 ) {
2983 s = w.toNewHampshire( t9, false, true ).toString();
2984 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2987 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2988 t10.deleteSubtree( t10.getNode( "D" ), true );
2989 if ( t10.getNumberOfExternalNodes() != 5 ) {
2992 s = w.toNewHampshire( t10, false, true ).toString();
2993 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
2996 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
2997 t11.deleteSubtree( t11.getNode( "A" ), true );
2998 if ( t11.getNumberOfExternalNodes() != 2 ) {
3001 s = w.toNewHampshire( t11, false, true ).toString();
3002 if ( !s.equals( "(B,C);" ) ) {
3005 t11.deleteSubtree( t11.getNode( "C" ), true );
3006 if ( t11.getNumberOfExternalNodes() != 1 ) {
3009 s = w.toNewHampshire( t11, false, false ).toString();
3010 if ( !s.equals( "B;" ) ) {
3013 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3014 t12.deleteSubtree( t12.getNode( "B2" ), true );
3015 if ( t12.getNumberOfExternalNodes() != 8 ) {
3018 s = w.toNewHampshire( t12, false, true ).toString();
3019 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3022 t12.deleteSubtree( t12.getNode( "B3" ), true );
3023 if ( t12.getNumberOfExternalNodes() != 7 ) {
3026 s = w.toNewHampshire( t12, false, true ).toString();
3027 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3030 t12.deleteSubtree( t12.getNode( "C3" ), true );
3031 if ( t12.getNumberOfExternalNodes() != 6 ) {
3034 s = w.toNewHampshire( t12, false, true ).toString();
3035 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3038 t12.deleteSubtree( t12.getNode( "A1" ), true );
3039 if ( t12.getNumberOfExternalNodes() != 5 ) {
3042 s = w.toNewHampshire( t12, false, true ).toString();
3043 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3046 t12.deleteSubtree( t12.getNode( "B1" ), true );
3047 if ( t12.getNumberOfExternalNodes() != 4 ) {
3050 s = w.toNewHampshire( t12, false, true ).toString();
3051 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3054 t12.deleteSubtree( t12.getNode( "A3" ), true );
3055 if ( t12.getNumberOfExternalNodes() != 3 ) {
3058 s = w.toNewHampshire( t12, false, true ).toString();
3059 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3062 t12.deleteSubtree( t12.getNode( "A2" ), true );
3063 if ( t12.getNumberOfExternalNodes() != 2 ) {
3066 s = w.toNewHampshire( t12, false, true ).toString();
3067 if ( !s.equals( "(C1,C2);" ) ) {
3070 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3071 t13.deleteSubtree( t13.getNode( "D" ), true );
3072 if ( t13.getNumberOfExternalNodes() != 4 ) {
3075 s = w.toNewHampshire( t13, false, true ).toString();
3076 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3079 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3080 t14.deleteSubtree( t14.getNode( "E" ), true );
3081 if ( t14.getNumberOfExternalNodes() != 5 ) {
3084 s = w.toNewHampshire( t14, false, true ).toString();
3085 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3088 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3089 t15.deleteSubtree( t15.getNode( "B2" ), true );
3090 if ( t15.getNumberOfExternalNodes() != 11 ) {
3093 t15.deleteSubtree( t15.getNode( "B1" ), true );
3094 if ( t15.getNumberOfExternalNodes() != 10 ) {
3097 t15.deleteSubtree( t15.getNode( "B3" ), true );
3098 if ( t15.getNumberOfExternalNodes() != 9 ) {
3101 t15.deleteSubtree( t15.getNode( "B4" ), true );
3102 if ( t15.getNumberOfExternalNodes() != 8 ) {
3105 t15.deleteSubtree( t15.getNode( "A1" ), true );
3106 if ( t15.getNumberOfExternalNodes() != 7 ) {
3109 t15.deleteSubtree( t15.getNode( "C4" ), true );
3110 if ( t15.getNumberOfExternalNodes() != 6 ) {
3114 catch ( final Exception e ) {
3115 e.printStackTrace( System.out );
3121 private static boolean testDescriptiveStatistics() {
3123 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3124 dss1.addValue( 82 );
3125 dss1.addValue( 78 );
3126 dss1.addValue( 70 );
3127 dss1.addValue( 58 );
3128 dss1.addValue( 42 );
3129 if ( dss1.getN() != 5 ) {
3132 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3135 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3138 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3141 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3144 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3147 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3150 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3153 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3156 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3159 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3162 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3165 dss1.addValue( 123 );
3166 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3169 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3172 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3175 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3176 dss2.addValue( -1.85 );
3177 dss2.addValue( 57.5 );
3178 dss2.addValue( 92.78 );
3179 dss2.addValue( 57.78 );
3180 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3183 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3186 final double[] a = dss2.getDataAsDoubleArray();
3187 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3190 dss2.addValue( -100 );
3191 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3194 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3197 final double[] ds = new double[ 14 ];
3212 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3213 if ( bins.length != 4 ) {
3216 if ( bins[ 0 ] != 2 ) {
3219 if ( bins[ 1 ] != 3 ) {
3222 if ( bins[ 2 ] != 4 ) {
3225 if ( bins[ 3 ] != 5 ) {
3228 final double[] ds1 = new double[ 9 ];
3238 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3239 if ( bins1.length != 4 ) {
3242 if ( bins1[ 0 ] != 2 ) {
3245 if ( bins1[ 1 ] != 3 ) {
3248 if ( bins1[ 2 ] != 0 ) {
3251 if ( bins1[ 3 ] != 4 ) {
3254 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3255 if ( bins1_1.length != 3 ) {
3258 if ( bins1_1[ 0 ] != 3 ) {
3261 if ( bins1_1[ 1 ] != 2 ) {
3264 if ( bins1_1[ 2 ] != 4 ) {
3267 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3268 if ( bins1_2.length != 3 ) {
3271 if ( bins1_2[ 0 ] != 2 ) {
3274 if ( bins1_2[ 1 ] != 2 ) {
3277 if ( bins1_2[ 2 ] != 2 ) {
3280 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3294 dss3.addValue( 10 );
3295 dss3.addValue( 10 );
3296 dss3.addValue( 10 );
3297 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3298 histo.toStringBuffer( 10, '=', 40, 5 );
3299 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3301 catch ( final Exception e ) {
3302 e.printStackTrace( System.out );
3308 private static boolean testDir( final String file ) {
3310 final File f = new File( file );
3311 if ( !f.exists() ) {
3314 if ( !f.isDirectory() ) {
3317 if ( !f.canRead() ) {
3321 catch ( final Exception e ) {
3327 private static boolean testEmblEntryRetrieval() {
3328 //The format for GenBank Accession numbers are:
3329 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3330 //Protein: 3 letters + 5 numerals
3331 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3332 if ( !SequenceIdParser.parseGenbankAccessor( "AY423861" ).equals( "AY423861" ) ) {
3335 if ( !SequenceIdParser.parseGenbankAccessor( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3338 if ( !SequenceIdParser.parseGenbankAccessor( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3341 if ( SequenceIdParser.parseGenbankAccessor( "AAY423861" ) != null ) {
3344 if ( SequenceIdParser.parseGenbankAccessor( "AY4238612" ) != null ) {
3347 if ( SequenceIdParser.parseGenbankAccessor( "AAY4238612" ) != null ) {
3350 if ( SequenceIdParser.parseGenbankAccessor( "Y423861" ) != null ) {
3353 if ( !SequenceIdParser.parseGenbankAccessor( "S12345" ).equals( "S12345" ) ) {
3356 if ( !SequenceIdParser.parseGenbankAccessor( "|S12345|" ).equals( "S12345" ) ) {
3359 if ( SequenceIdParser.parseGenbankAccessor( "|S123456" ) != null ) {
3362 if ( SequenceIdParser.parseGenbankAccessor( "ABC123456" ) != null ) {
3365 if ( !SequenceIdParser.parseGenbankAccessor( "ABC12345" ).equals( "ABC12345" ) ) {
3368 if ( !SequenceIdParser.parseGenbankAccessor( "&ABC12345&" ).equals( "ABC12345" ) ) {
3371 if ( SequenceIdParser.parseGenbankAccessor( "ABCD12345" ) != null ) {
3377 private static boolean testExternalNodeRelatedMethods() {
3379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3380 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3381 PhylogenyNode n = t1.getNode( "A" );
3382 n = n.getNextExternalNode();
3383 if ( !n.getName().equals( "B" ) ) {
3386 n = n.getNextExternalNode();
3387 if ( !n.getName().equals( "C" ) ) {
3390 n = n.getNextExternalNode();
3391 if ( !n.getName().equals( "D" ) ) {
3394 n = t1.getNode( "B" );
3395 while ( !n.isLastExternalNode() ) {
3396 n = n.getNextExternalNode();
3398 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3399 n = t2.getNode( "A" );
3400 n = n.getNextExternalNode();
3401 if ( !n.getName().equals( "B" ) ) {
3404 n = n.getNextExternalNode();
3405 if ( !n.getName().equals( "C" ) ) {
3408 n = n.getNextExternalNode();
3409 if ( !n.getName().equals( "D" ) ) {
3412 n = t2.getNode( "B" );
3413 while ( !n.isLastExternalNode() ) {
3414 n = n.getNextExternalNode();
3416 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3417 n = t3.getNode( "A" );
3418 n = n.getNextExternalNode();
3419 if ( !n.getName().equals( "B" ) ) {
3422 n = n.getNextExternalNode();
3423 if ( !n.getName().equals( "C" ) ) {
3426 n = n.getNextExternalNode();
3427 if ( !n.getName().equals( "D" ) ) {
3430 n = n.getNextExternalNode();
3431 if ( !n.getName().equals( "E" ) ) {
3434 n = n.getNextExternalNode();
3435 if ( !n.getName().equals( "F" ) ) {
3438 n = n.getNextExternalNode();
3439 if ( !n.getName().equals( "G" ) ) {
3442 n = n.getNextExternalNode();
3443 if ( !n.getName().equals( "H" ) ) {
3446 n = t3.getNode( "B" );
3447 while ( !n.isLastExternalNode() ) {
3448 n = n.getNextExternalNode();
3450 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3451 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3452 final PhylogenyNode node = iter.next();
3454 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3455 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3456 final PhylogenyNode node = iter.next();
3458 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3459 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3460 if ( !iter.next().getName().equals( "A" ) ) {
3463 if ( !iter.next().getName().equals( "B" ) ) {
3466 if ( !iter.next().getName().equals( "C" ) ) {
3469 if ( !iter.next().getName().equals( "D" ) ) {
3472 if ( !iter.next().getName().equals( "E" ) ) {
3475 if ( !iter.next().getName().equals( "F" ) ) {
3478 if ( iter.hasNext() ) {
3482 catch ( final Exception e ) {
3483 e.printStackTrace( System.out );
3489 private static boolean testExtractSNFromNodeName() {
3491 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3494 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3495 .equals( "Mus musculus musculus" ) ) {
3498 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3499 .equals( "Mus musculus musculus" ) ) {
3502 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3505 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3506 .equals( "Mus musculus" ) ) {
3510 catch ( final Exception e ) {
3511 e.printStackTrace( System.out );
3517 private static boolean testExtractTaxonomyCodeFromNodeName() {
3519 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3522 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3523 .equals( "SOYBN" ) ) {
3526 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3527 .equals( "ARATH" ) ) {
3530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3531 .equals( "ARATH" ) ) {
3534 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3537 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3540 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3543 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3544 .equals( "SOYBN" ) ) {
3547 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3548 .equals( "SOYBN" ) ) {
3551 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3552 .equals( "SOYBN" ) ) {
3555 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3556 .equals( "SOYBN" ) ) {
3559 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3560 .equals( "SOYBN" ) ) {
3563 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3564 .equals( "SOYBN" ) ) {
3567 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3568 .equals( "SOYBN" ) ) {
3571 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3572 .equals( "SOYBN" ) ) {
3575 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3578 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3579 .equals( "SOYBN" ) ) {
3582 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3583 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3586 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3587 .equals( "9YX45" ) ) {
3590 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3591 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3592 .equals( "MOUSE" ) ) {
3595 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3596 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3597 .equals( "MOUSE" ) ) {
3600 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3601 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3602 .equals( "MOUSE" ) ) {
3605 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3606 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3609 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3610 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3613 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3614 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3617 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3618 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3621 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3622 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3625 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3626 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3629 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3630 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3633 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3634 .equals( "RAT" ) ) {
3637 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3638 .equals( "PIG" ) ) {
3642 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3643 .equals( "MOUSE" ) ) {
3646 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3647 .equals( "MOUSE" ) ) {
3650 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3654 catch ( final Exception e ) {
3655 e.printStackTrace( System.out );
3661 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3663 PhylogenyNode n = new PhylogenyNode();
3664 n.setName( "tr|B3RJ64" );
3665 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3668 n.setName( "tr.B3RJ64" );
3669 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3672 n.setName( "tr=B3RJ64" );
3673 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3676 n.setName( "tr-B3RJ64" );
3677 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3680 n.setName( "tr/B3RJ64" );
3681 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3684 n.setName( "tr\\B3RJ64" );
3685 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3688 n.setName( "tr_B3RJ64" );
3689 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3692 n.setName( " tr|B3RJ64 " );
3693 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3696 n.setName( "-tr|B3RJ64-" );
3697 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3700 n.setName( "-tr=B3RJ64-" );
3701 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3704 n.setName( "_tr=B3RJ64_" );
3705 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3708 n.setName( " tr_tr|B3RJ64_sp|123 " );
3709 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3712 n.setName( "sp|B3RJ64" );
3713 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3716 n.setName( "ssp|B3RJ64" );
3717 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3720 n.setName( "sp|B3RJ64C" );
3721 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3724 n.setName( "sp B3RJ64" );
3725 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3728 n.setName( "sp|B3RJ6X" );
3729 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3732 n.setName( "sp|B3RJ6" );
3733 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3736 n.setName( "K1PYK7_CRAGI" );
3737 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3740 n.setName( "K1PYK7_PEA" );
3741 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PEA" ) ) {
3744 n.setName( "K1PYK7_RAT" );
3745 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_RAT" ) ) {
3748 n.setName( "K1PYK7_PIG" );
3749 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3752 n.setName( "~K1PYK7_PIG~" );
3753 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_PIG" ) ) {
3756 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3757 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3760 n.setName( "K1PYKX_CRAGI" );
3761 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3764 n.setName( "XXXXX_CRAGI" );
3765 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "XXXXX_CRAGI" ) ) {
3768 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3769 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "H3IB65" ) ) {
3772 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3773 if ( ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ) != null ) {
3776 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3777 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "Q86U06" ) ) {
3780 n = new PhylogenyNode();
3781 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3782 seq.setSymbol( "K1PYK7_CRAGI" );
3783 n.getNodeData().addSequence( seq );
3784 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3787 seq.setSymbol( "tr|B3RJ64" );
3788 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3791 n = new PhylogenyNode();
3792 seq = new org.forester.phylogeny.data.Sequence();
3793 seq.setName( "K1PYK7_CRAGI" );
3794 n.getNodeData().addSequence( seq );
3795 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK7_CRAGI" ) ) {
3798 seq.setName( "tr|B3RJ64" );
3799 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3802 n = new PhylogenyNode();
3803 seq = new org.forester.phylogeny.data.Sequence();
3804 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3805 n.getNodeData().addSequence( seq );
3806 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "K1PYK8_CRAGI" ) ) {
3809 n = new PhylogenyNode();
3810 seq = new org.forester.phylogeny.data.Sequence();
3811 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3812 n.getNodeData().addSequence( seq );
3813 if ( !ForesterUtil.extractUniProtKbProteinSeqIdentifier( n ).equals( "B3RJ64" ) ) {
3817 n = new PhylogenyNode();
3818 n.setName( "ACP19736" );
3819 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3822 n = new PhylogenyNode();
3823 n.setName( "_ACP19736_" );
3824 if ( !ForesterUtil.extractGenbankAccessor( n ).equals( "ACP19736" ) ) {
3828 catch ( final Exception e ) {
3829 e.printStackTrace( System.out );
3835 private static boolean testFastaParser() {
3837 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3840 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3843 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3844 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3847 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3850 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3853 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3856 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3859 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3863 catch ( final Exception e ) {
3864 e.printStackTrace();
3870 private static boolean testGeneralMsaParser() {
3872 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3873 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3874 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3875 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3876 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3877 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3878 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3879 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3880 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3883 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3886 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3889 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3892 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3895 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3898 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3901 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3904 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3907 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3910 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3913 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3916 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3917 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3920 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3923 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3926 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3927 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3930 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3933 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3936 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3937 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3940 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3943 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3947 catch ( final Exception e ) {
3948 e.printStackTrace();
3954 private static boolean testGeneralTable() {
3956 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3957 t0.setValue( 3, 2, "23" );
3958 t0.setValue( 10, 1, "error" );
3959 t0.setValue( 10, 1, "110" );
3960 t0.setValue( 9, 1, "19" );
3961 t0.setValue( 1, 10, "101" );
3962 t0.setValue( 10, 10, "1010" );
3963 t0.setValue( 100, 10, "10100" );
3964 t0.setValue( 0, 0, "00" );
3965 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3968 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3971 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3974 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3977 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3980 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3983 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3986 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
3989 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
3992 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
3993 t1.setValue( "3", "2", "23" );
3994 t1.setValue( "10", "1", "error" );
3995 t1.setValue( "10", "1", "110" );
3996 t1.setValue( "9", "1", "19" );
3997 t1.setValue( "1", "10", "101" );
3998 t1.setValue( "10", "10", "1010" );
3999 t1.setValue( "100", "10", "10100" );
4000 t1.setValue( "0", "0", "00" );
4001 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4002 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4005 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4008 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4011 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4014 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4017 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4020 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4023 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4026 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4029 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4033 catch ( final Exception e ) {
4034 e.printStackTrace( System.out );
4040 private static boolean testGetDistance() {
4042 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4043 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",
4044 new NHXParser() )[ 0 ];
4045 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4048 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4051 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4054 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4057 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4060 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4063 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4066 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4069 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4072 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4075 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4078 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4081 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4084 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4087 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4090 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4093 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4096 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4099 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4102 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4105 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4108 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4111 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4114 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4117 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4120 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4123 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4126 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4129 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4132 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4135 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4138 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",
4139 new NHXParser() )[ 0 ];
4140 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4143 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4146 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4149 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4152 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4155 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4158 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4161 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4164 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4167 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4170 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4174 catch ( final Exception e ) {
4175 e.printStackTrace( System.out );
4181 private static boolean testGetLCA() {
4183 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4184 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4185 new NHXParser() )[ 0 ];
4186 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4187 if ( !A.getName().equals( "A" ) ) {
4190 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4191 if ( !gh.getName().equals( "gh" ) ) {
4194 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4195 if ( !ab.getName().equals( "ab" ) ) {
4198 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4199 if ( !ab2.getName().equals( "ab" ) ) {
4202 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4203 if ( !gh2.getName().equals( "gh" ) ) {
4206 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4207 if ( !gh3.getName().equals( "gh" ) ) {
4210 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4211 if ( !abc.getName().equals( "abc" ) ) {
4214 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4215 if ( !abc2.getName().equals( "abc" ) ) {
4218 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4219 if ( !abcd.getName().equals( "abcd" ) ) {
4222 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4223 if ( !abcd2.getName().equals( "abcd" ) ) {
4226 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4227 if ( !abcdef.getName().equals( "abcdef" ) ) {
4230 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4231 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4234 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4235 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4238 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4239 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4242 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4243 if ( !abcde.getName().equals( "abcde" ) ) {
4246 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4247 if ( !abcde2.getName().equals( "abcde" ) ) {
4250 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4251 if ( !r.getName().equals( "abcdefgh" ) ) {
4254 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4255 if ( !r2.getName().equals( "abcdefgh" ) ) {
4258 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4259 if ( !r3.getName().equals( "abcdefgh" ) ) {
4262 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4263 if ( !abcde3.getName().equals( "abcde" ) ) {
4266 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4267 if ( !abcde4.getName().equals( "abcde" ) ) {
4270 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4271 if ( !ab3.getName().equals( "ab" ) ) {
4274 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4275 if ( !ab4.getName().equals( "ab" ) ) {
4278 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4279 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4280 if ( !cd.getName().equals( "cd" ) ) {
4283 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4284 if ( !cd2.getName().equals( "cd" ) ) {
4287 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4288 if ( !cde.getName().equals( "cde" ) ) {
4291 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4292 if ( !cde2.getName().equals( "cde" ) ) {
4295 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4296 if ( !cdef.getName().equals( "cdef" ) ) {
4299 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4300 if ( !cdef2.getName().equals( "cdef" ) ) {
4303 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4304 if ( !cdef3.getName().equals( "cdef" ) ) {
4307 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4308 if ( !rt.getName().equals( "r" ) ) {
4311 final Phylogeny p3 = factory
4312 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4313 new NHXParser() )[ 0 ];
4314 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4315 if ( !bc_3.getName().equals( "bc" ) ) {
4318 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4319 if ( !ac_3.getName().equals( "abc" ) ) {
4322 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4323 if ( !ad_3.getName().equals( "abcde" ) ) {
4326 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4327 if ( !af_3.getName().equals( "abcdef" ) ) {
4330 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4331 if ( !ag_3.getName().equals( "" ) ) {
4334 if ( !ag_3.isRoot() ) {
4337 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4338 if ( !al_3.getName().equals( "" ) ) {
4341 if ( !al_3.isRoot() ) {
4344 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4345 if ( !kl_3.getName().equals( "" ) ) {
4348 if ( !kl_3.isRoot() ) {
4351 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4352 if ( !fl_3.getName().equals( "" ) ) {
4355 if ( !fl_3.isRoot() ) {
4358 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4359 if ( !gk_3.getName().equals( "ghijk" ) ) {
4362 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4363 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4364 if ( !r_4.getName().equals( "r" ) ) {
4367 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4368 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4369 if ( !r_5.getName().equals( "root" ) ) {
4372 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4373 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4374 if ( !r_6.getName().equals( "rot" ) ) {
4377 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4378 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4379 if ( !r_7.getName().equals( "rott" ) ) {
4383 catch ( final Exception e ) {
4384 e.printStackTrace( System.out );
4390 private static boolean testGetLCA2() {
4392 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4393 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4394 PhylogenyMethods.preOrderReId( p_a );
4395 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4396 p_a.getNode( "a" ) );
4397 if ( !p_a_1.getName().equals( "a" ) ) {
4400 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4401 PhylogenyMethods.preOrderReId( p_b );
4402 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4403 p_b.getNode( "a" ) );
4404 if ( !p_b_1.getName().equals( "b" ) ) {
4407 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4408 p_b.getNode( "b" ) );
4409 if ( !p_b_2.getName().equals( "b" ) ) {
4412 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4413 PhylogenyMethods.preOrderReId( p_c );
4414 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4415 p_c.getNode( "a" ) );
4416 if ( !p_c_1.getName().equals( "b" ) ) {
4419 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4420 p_c.getNode( "c" ) );
4421 if ( !p_c_2.getName().equals( "c" ) ) {
4422 System.out.println( p_c_2.getName() );
4426 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4427 p_c.getNode( "b" ) );
4428 if ( !p_c_3.getName().equals( "b" ) ) {
4431 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4432 p_c.getNode( "a" ) );
4433 if ( !p_c_4.getName().equals( "c" ) ) {
4436 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4437 new NHXParser() )[ 0 ];
4438 PhylogenyMethods.preOrderReId( p1 );
4439 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4440 p1.getNode( "A" ) );
4441 if ( !A.getName().equals( "A" ) ) {
4444 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4445 p1.getNode( "gh" ) );
4446 if ( !gh.getName().equals( "gh" ) ) {
4449 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4450 p1.getNode( "B" ) );
4451 if ( !ab.getName().equals( "ab" ) ) {
4454 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4455 p1.getNode( "A" ) );
4456 if ( !ab2.getName().equals( "ab" ) ) {
4459 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4460 p1.getNode( "G" ) );
4461 if ( !gh2.getName().equals( "gh" ) ) {
4464 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4465 p1.getNode( "H" ) );
4466 if ( !gh3.getName().equals( "gh" ) ) {
4469 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4470 p1.getNode( "A" ) );
4471 if ( !abc.getName().equals( "abc" ) ) {
4474 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4475 p1.getNode( "C" ) );
4476 if ( !abc2.getName().equals( "abc" ) ) {
4479 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4480 p1.getNode( "D" ) );
4481 if ( !abcd.getName().equals( "abcd" ) ) {
4484 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4485 p1.getNode( "A" ) );
4486 if ( !abcd2.getName().equals( "abcd" ) ) {
4489 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4490 p1.getNode( "F" ) );
4491 if ( !abcdef.getName().equals( "abcdef" ) ) {
4494 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4495 p1.getNode( "A" ) );
4496 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4499 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4500 p1.getNode( "F" ) );
4501 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4504 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4505 p1.getNode( "ab" ) );
4506 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4509 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4510 p1.getNode( "E" ) );
4511 if ( !abcde.getName().equals( "abcde" ) ) {
4514 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4515 p1.getNode( "A" ) );
4516 if ( !abcde2.getName().equals( "abcde" ) ) {
4519 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4520 p1.getNode( "abcdefgh" ) );
4521 if ( !r.getName().equals( "abcdefgh" ) ) {
4524 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4525 p1.getNode( "H" ) );
4526 if ( !r2.getName().equals( "abcdefgh" ) ) {
4529 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4530 p1.getNode( "A" ) );
4531 if ( !r3.getName().equals( "abcdefgh" ) ) {
4534 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4535 p1.getNode( "abcde" ) );
4536 if ( !abcde3.getName().equals( "abcde" ) ) {
4539 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4540 p1.getNode( "E" ) );
4541 if ( !abcde4.getName().equals( "abcde" ) ) {
4544 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4545 p1.getNode( "B" ) );
4546 if ( !ab3.getName().equals( "ab" ) ) {
4549 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4550 p1.getNode( "ab" ) );
4551 if ( !ab4.getName().equals( "ab" ) ) {
4554 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4555 PhylogenyMethods.preOrderReId( p2 );
4556 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4557 p2.getNode( "d" ) );
4558 if ( !cd.getName().equals( "cd" ) ) {
4561 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4562 p2.getNode( "c" ) );
4563 if ( !cd2.getName().equals( "cd" ) ) {
4566 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4567 p2.getNode( "e" ) );
4568 if ( !cde.getName().equals( "cde" ) ) {
4571 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4572 p2.getNode( "c" ) );
4573 if ( !cde2.getName().equals( "cde" ) ) {
4576 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4577 p2.getNode( "f" ) );
4578 if ( !cdef.getName().equals( "cdef" ) ) {
4581 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4582 p2.getNode( "f" ) );
4583 if ( !cdef2.getName().equals( "cdef" ) ) {
4586 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4587 p2.getNode( "d" ) );
4588 if ( !cdef3.getName().equals( "cdef" ) ) {
4591 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4592 p2.getNode( "a" ) );
4593 if ( !rt.getName().equals( "r" ) ) {
4596 final Phylogeny p3 = factory
4597 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4598 new NHXParser() )[ 0 ];
4599 PhylogenyMethods.preOrderReId( p3 );
4600 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4601 p3.getNode( "c" ) );
4602 if ( !bc_3.getName().equals( "bc" ) ) {
4605 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4606 p3.getNode( "c" ) );
4607 if ( !ac_3.getName().equals( "abc" ) ) {
4610 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4611 p3.getNode( "d" ) );
4612 if ( !ad_3.getName().equals( "abcde" ) ) {
4615 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4616 p3.getNode( "f" ) );
4617 if ( !af_3.getName().equals( "abcdef" ) ) {
4620 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4621 p3.getNode( "g" ) );
4622 if ( !ag_3.getName().equals( "" ) ) {
4625 if ( !ag_3.isRoot() ) {
4628 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4629 p3.getNode( "l" ) );
4630 if ( !al_3.getName().equals( "" ) ) {
4633 if ( !al_3.isRoot() ) {
4636 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4637 p3.getNode( "l" ) );
4638 if ( !kl_3.getName().equals( "" ) ) {
4641 if ( !kl_3.isRoot() ) {
4644 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4645 p3.getNode( "l" ) );
4646 if ( !fl_3.getName().equals( "" ) ) {
4649 if ( !fl_3.isRoot() ) {
4652 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4653 p3.getNode( "k" ) );
4654 if ( !gk_3.getName().equals( "ghijk" ) ) {
4657 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4658 PhylogenyMethods.preOrderReId( p4 );
4659 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4660 p4.getNode( "c" ) );
4661 if ( !r_4.getName().equals( "r" ) ) {
4664 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4665 PhylogenyMethods.preOrderReId( p5 );
4666 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4667 p5.getNode( "c" ) );
4668 if ( !r_5.getName().equals( "root" ) ) {
4671 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4672 PhylogenyMethods.preOrderReId( p6 );
4673 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4674 p6.getNode( "a" ) );
4675 if ( !r_6.getName().equals( "rot" ) ) {
4678 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4679 PhylogenyMethods.preOrderReId( p7 );
4680 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4681 p7.getNode( "e" ) );
4682 if ( !r_7.getName().equals( "rott" ) ) {
4685 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4686 p7.getNode( "a" ) );
4687 if ( !r_71.getName().equals( "rott" ) ) {
4690 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4691 p7.getNode( "rott" ) );
4692 if ( !r_72.getName().equals( "rott" ) ) {
4695 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4696 p7.getNode( "a" ) );
4697 if ( !r_73.getName().equals( "rott" ) ) {
4700 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4701 p7.getNode( "rott" ) );
4702 if ( !r_74.getName().equals( "rott" ) ) {
4705 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4706 p7.getNode( "e" ) );
4707 if ( !r_75.getName().equals( "e" ) ) {
4711 catch ( final Exception e ) {
4712 e.printStackTrace( System.out );
4718 private static boolean testHmmscanOutputParser() {
4719 final String test_dir = Test.PATH_TO_TEST_DATA;
4721 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4722 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4724 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4725 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4726 final List<Protein> proteins = parser2.parse();
4727 if ( parser2.getProteinsEncountered() != 4 ) {
4730 if ( proteins.size() != 4 ) {
4733 if ( parser2.getDomainsEncountered() != 69 ) {
4736 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4739 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4742 final Protein p1 = proteins.get( 0 );
4743 if ( p1.getNumberOfProteinDomains() != 15 ) {
4746 if ( p1.getLength() != 850 ) {
4749 final Protein p2 = proteins.get( 1 );
4750 if ( p2.getNumberOfProteinDomains() != 51 ) {
4753 if ( p2.getLength() != 1291 ) {
4756 final Protein p3 = proteins.get( 2 );
4757 if ( p3.getNumberOfProteinDomains() != 2 ) {
4760 final Protein p4 = proteins.get( 3 );
4761 if ( p4.getNumberOfProteinDomains() != 1 ) {
4764 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4767 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4770 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4773 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4776 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4779 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4782 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4785 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4788 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4792 catch ( final Exception e ) {
4793 e.printStackTrace( System.out );
4799 private static boolean testLastExternalNodeMethods() {
4801 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4802 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4803 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4804 final PhylogenyNode n1 = t0.getNode( "A" );
4805 if ( n1.isLastExternalNode() ) {
4808 final PhylogenyNode n2 = t0.getNode( "B" );
4809 if ( n2.isLastExternalNode() ) {
4812 final PhylogenyNode n3 = t0.getNode( "C" );
4813 if ( n3.isLastExternalNode() ) {
4816 final PhylogenyNode n4 = t0.getNode( "D" );
4817 if ( !n4.isLastExternalNode() ) {
4821 catch ( final Exception e ) {
4822 e.printStackTrace( System.out );
4828 private static boolean testLevelOrderIterator() {
4830 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4831 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4832 PhylogenyNodeIterator it0;
4833 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4836 for( it0.reset(); it0.hasNext(); ) {
4839 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4840 if ( !it.next().getName().equals( "r" ) ) {
4843 if ( !it.next().getName().equals( "ab" ) ) {
4846 if ( !it.next().getName().equals( "cd" ) ) {
4849 if ( !it.next().getName().equals( "A" ) ) {
4852 if ( !it.next().getName().equals( "B" ) ) {
4855 if ( !it.next().getName().equals( "C" ) ) {
4858 if ( !it.next().getName().equals( "D" ) ) {
4861 if ( it.hasNext() ) {
4864 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",
4865 new NHXParser() )[ 0 ];
4866 PhylogenyNodeIterator it2;
4867 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4870 for( it2.reset(); it2.hasNext(); ) {
4873 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4874 if ( !it3.next().getName().equals( "r" ) ) {
4877 if ( !it3.next().getName().equals( "abc" ) ) {
4880 if ( !it3.next().getName().equals( "defg" ) ) {
4883 if ( !it3.next().getName().equals( "A" ) ) {
4886 if ( !it3.next().getName().equals( "B" ) ) {
4889 if ( !it3.next().getName().equals( "C" ) ) {
4892 if ( !it3.next().getName().equals( "D" ) ) {
4895 if ( !it3.next().getName().equals( "E" ) ) {
4898 if ( !it3.next().getName().equals( "F" ) ) {
4901 if ( !it3.next().getName().equals( "G" ) ) {
4904 if ( !it3.next().getName().equals( "1" ) ) {
4907 if ( !it3.next().getName().equals( "2" ) ) {
4910 if ( !it3.next().getName().equals( "3" ) ) {
4913 if ( !it3.next().getName().equals( "4" ) ) {
4916 if ( !it3.next().getName().equals( "5" ) ) {
4919 if ( !it3.next().getName().equals( "6" ) ) {
4922 if ( !it3.next().getName().equals( "f1" ) ) {
4925 if ( !it3.next().getName().equals( "f2" ) ) {
4928 if ( !it3.next().getName().equals( "f3" ) ) {
4931 if ( !it3.next().getName().equals( "a" ) ) {
4934 if ( !it3.next().getName().equals( "b" ) ) {
4937 if ( !it3.next().getName().equals( "f21" ) ) {
4940 if ( !it3.next().getName().equals( "X" ) ) {
4943 if ( !it3.next().getName().equals( "Y" ) ) {
4946 if ( !it3.next().getName().equals( "Z" ) ) {
4949 if ( it3.hasNext() ) {
4952 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4953 PhylogenyNodeIterator it4;
4954 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4957 for( it4.reset(); it4.hasNext(); ) {
4960 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4961 if ( !it5.next().getName().equals( "r" ) ) {
4964 if ( !it5.next().getName().equals( "A" ) ) {
4967 if ( !it5.next().getName().equals( "B" ) ) {
4970 if ( !it5.next().getName().equals( "C" ) ) {
4973 if ( !it5.next().getName().equals( "D" ) ) {
4976 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
4977 PhylogenyNodeIterator it6;
4978 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
4981 for( it6.reset(); it6.hasNext(); ) {
4984 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
4985 if ( !it7.next().getName().equals( "A" ) ) {
4988 if ( it.hasNext() ) {
4992 catch ( final Exception e ) {
4993 e.printStackTrace( System.out );
4999 private static boolean testMafft( final String path ) {
5001 final List<String> opts = new ArrayList<String>();
5002 opts.add( "--maxiterate" );
5004 opts.add( "--localpair" );
5005 opts.add( "--quiet" );
5007 final MsaInferrer mafft = Mafft.createInstance( path );
5008 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5009 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5012 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5016 catch ( final Exception e ) {
5017 e.printStackTrace( System.out );
5023 private static boolean testMidpointrooting() {
5025 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5026 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5027 PhylogenyMethods.midpointRoot( t0 );
5028 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5031 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5034 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5038 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",
5039 new NHXParser() )[ 0 ];
5040 if ( !t1.isRooted() ) {
5043 PhylogenyMethods.midpointRoot( t1 );
5044 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5047 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5050 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5053 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5056 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5059 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5062 t1.reRoot( t1.getNode( "A" ) );
5063 PhylogenyMethods.midpointRoot( t1 );
5064 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5067 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5070 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5073 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5076 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5080 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5084 catch ( final Exception e ) {
5085 e.printStackTrace( System.out );
5091 private static boolean testMsaQualityMethod() {
5093 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5094 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5095 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5096 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5097 final List<Sequence> l = new ArrayList<Sequence>();
5102 final Msa msa = BasicMsa.createInstance( l );
5103 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5106 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5109 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5112 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5116 catch ( final Exception e ) {
5117 e.printStackTrace( System.out );
5123 private static boolean testNextNodeWithCollapsing() {
5125 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5127 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5128 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5129 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5130 t0.getNode( "cd" ).setCollapse( true );
5131 t0.getNode( "cde" ).setCollapse( true );
5132 n = t0.getFirstExternalNode();
5133 while ( n != null ) {
5135 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5137 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5140 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5143 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5146 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5149 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5152 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5156 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5157 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5158 t1.getNode( "ab" ).setCollapse( true );
5159 t1.getNode( "cd" ).setCollapse( true );
5160 t1.getNode( "cde" ).setCollapse( true );
5161 n = t1.getNode( "ab" );
5162 ext = new ArrayList<PhylogenyNode>();
5163 while ( n != null ) {
5165 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5167 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5170 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5173 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5176 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5179 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5185 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5186 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5187 t2.getNode( "ab" ).setCollapse( true );
5188 t2.getNode( "cd" ).setCollapse( true );
5189 t2.getNode( "cde" ).setCollapse( true );
5190 t2.getNode( "c" ).setCollapse( true );
5191 t2.getNode( "d" ).setCollapse( true );
5192 t2.getNode( "e" ).setCollapse( true );
5193 t2.getNode( "gh" ).setCollapse( true );
5194 n = t2.getNode( "ab" );
5195 ext = new ArrayList<PhylogenyNode>();
5196 while ( n != null ) {
5198 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5200 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5203 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5206 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5209 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5215 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5216 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5217 t3.getNode( "ab" ).setCollapse( true );
5218 t3.getNode( "cd" ).setCollapse( true );
5219 t3.getNode( "cde" ).setCollapse( true );
5220 t3.getNode( "c" ).setCollapse( true );
5221 t3.getNode( "d" ).setCollapse( true );
5222 t3.getNode( "e" ).setCollapse( true );
5223 t3.getNode( "gh" ).setCollapse( true );
5224 t3.getNode( "fgh" ).setCollapse( true );
5225 n = t3.getNode( "ab" );
5226 ext = new ArrayList<PhylogenyNode>();
5227 while ( n != null ) {
5229 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5231 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5234 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5237 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5243 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5244 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5245 t4.getNode( "ab" ).setCollapse( true );
5246 t4.getNode( "cd" ).setCollapse( true );
5247 t4.getNode( "cde" ).setCollapse( true );
5248 t4.getNode( "c" ).setCollapse( true );
5249 t4.getNode( "d" ).setCollapse( true );
5250 t4.getNode( "e" ).setCollapse( true );
5251 t4.getNode( "gh" ).setCollapse( true );
5252 t4.getNode( "fgh" ).setCollapse( true );
5253 t4.getNode( "abcdefgh" ).setCollapse( true );
5254 n = t4.getNode( "abcdefgh" );
5255 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5260 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5261 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5263 n = t5.getFirstExternalNode();
5264 while ( n != null ) {
5266 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5268 if ( ext.size() != 8 ) {
5271 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5274 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5277 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5280 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5283 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5286 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5289 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5292 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5297 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5298 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5300 t6.getNode( "ab" ).setCollapse( true );
5301 n = t6.getNode( "ab" );
5302 while ( n != null ) {
5304 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5306 if ( ext.size() != 7 ) {
5309 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5312 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5315 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5318 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5321 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5324 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5327 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5332 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5333 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5335 t7.getNode( "cd" ).setCollapse( true );
5336 n = t7.getNode( "a" );
5337 while ( n != null ) {
5339 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5341 if ( ext.size() != 7 ) {
5344 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5347 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5350 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5353 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5356 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5359 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5362 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5367 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5368 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5370 t8.getNode( "cd" ).setCollapse( true );
5371 t8.getNode( "c" ).setCollapse( true );
5372 t8.getNode( "d" ).setCollapse( true );
5373 n = t8.getNode( "a" );
5374 while ( n != null ) {
5376 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5378 if ( ext.size() != 7 ) {
5381 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5384 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5387 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5388 System.out.println( "2 fail" );
5391 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5394 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5397 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5400 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5405 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5406 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5408 t9.getNode( "gh" ).setCollapse( true );
5409 n = t9.getNode( "a" );
5410 while ( n != null ) {
5412 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5414 if ( ext.size() != 7 ) {
5417 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5420 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5423 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5426 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5429 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5432 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5435 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5440 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5441 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5443 t10.getNode( "gh" ).setCollapse( true );
5444 t10.getNode( "g" ).setCollapse( true );
5445 t10.getNode( "h" ).setCollapse( true );
5446 n = t10.getNode( "a" );
5447 while ( n != null ) {
5449 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5451 if ( ext.size() != 7 ) {
5454 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5457 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5460 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5463 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5466 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5469 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5472 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5477 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5478 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5480 t11.getNode( "gh" ).setCollapse( true );
5481 t11.getNode( "fgh" ).setCollapse( true );
5482 n = t11.getNode( "a" );
5483 while ( n != null ) {
5485 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5487 if ( ext.size() != 6 ) {
5490 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5493 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5496 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5499 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5502 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5505 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5510 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5511 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5513 t12.getNode( "gh" ).setCollapse( true );
5514 t12.getNode( "fgh" ).setCollapse( true );
5515 t12.getNode( "g" ).setCollapse( true );
5516 t12.getNode( "h" ).setCollapse( true );
5517 t12.getNode( "f" ).setCollapse( true );
5518 n = t12.getNode( "a" );
5519 while ( n != null ) {
5521 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5523 if ( ext.size() != 6 ) {
5526 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5529 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5532 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5535 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5538 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5541 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5546 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5547 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5549 t13.getNode( "ab" ).setCollapse( true );
5550 t13.getNode( "b" ).setCollapse( true );
5551 t13.getNode( "fgh" ).setCollapse( true );
5552 t13.getNode( "gh" ).setCollapse( true );
5553 n = t13.getNode( "ab" );
5554 while ( n != null ) {
5556 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5558 if ( ext.size() != 5 ) {
5561 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5564 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5567 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5570 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5573 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5578 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5579 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5581 t14.getNode( "ab" ).setCollapse( true );
5582 t14.getNode( "a" ).setCollapse( true );
5583 t14.getNode( "fgh" ).setCollapse( true );
5584 t14.getNode( "gh" ).setCollapse( true );
5585 n = t14.getNode( "ab" );
5586 while ( n != null ) {
5588 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5590 if ( ext.size() != 5 ) {
5593 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5596 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5599 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5602 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5605 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5610 final StringBuffer sb15 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,x,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5611 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5613 t15.getNode( "ab" ).setCollapse( true );
5614 t15.getNode( "a" ).setCollapse( true );
5615 t15.getNode( "fgh" ).setCollapse( true );
5616 t15.getNode( "gh" ).setCollapse( true );
5617 n = t15.getNode( "ab" );
5618 while ( n != null ) {
5620 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5622 if ( ext.size() != 6 ) {
5625 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5628 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5631 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5634 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5637 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5640 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5645 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" );
5646 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5648 t16.getNode( "ab" ).setCollapse( true );
5649 t16.getNode( "a" ).setCollapse( true );
5650 t16.getNode( "fgh" ).setCollapse( true );
5651 t16.getNode( "gh" ).setCollapse( true );
5652 t16.getNode( "cd" ).setCollapse( true );
5653 t16.getNode( "cde" ).setCollapse( true );
5654 t16.getNode( "d" ).setCollapse( true );
5655 t16.getNode( "x" ).setCollapse( true );
5656 n = t16.getNode( "ab" );
5657 while ( n != null ) {
5659 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5661 if ( ext.size() != 4 ) {
5664 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5667 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5670 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5673 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5677 catch ( final Exception e ) {
5678 e.printStackTrace( System.out );
5684 private static boolean testNexusCharactersParsing() {
5686 final NexusCharactersParser parser = new NexusCharactersParser();
5687 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5689 String[] labels = parser.getCharStateLabels();
5690 if ( labels.length != 7 ) {
5693 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5696 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5699 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5702 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5705 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5708 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5711 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5714 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5716 labels = parser.getCharStateLabels();
5717 if ( labels.length != 7 ) {
5720 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5723 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5726 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5729 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5732 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5735 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5738 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5742 catch ( final Exception e ) {
5743 e.printStackTrace( System.out );
5749 private static boolean testNexusMatrixParsing() {
5751 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5752 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5754 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5755 if ( m.getNumberOfCharacters() != 9 ) {
5758 if ( m.getNumberOfIdentifiers() != 5 ) {
5761 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5764 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5767 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5770 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5773 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5776 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5779 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5782 // if ( labels.length != 7 ) {
5785 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5788 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5791 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5794 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5797 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5800 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5803 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5806 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5808 // labels = parser.getCharStateLabels();
5809 // if ( labels.length != 7 ) {
5812 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5815 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5818 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5821 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5824 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5827 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5830 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5834 catch ( final Exception e ) {
5835 e.printStackTrace( System.out );
5841 private static boolean testNexusTreeParsing() {
5843 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5844 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5845 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5846 if ( phylogenies.length != 1 ) {
5849 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5852 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5856 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5857 if ( phylogenies.length != 1 ) {
5860 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5863 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5867 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5868 if ( phylogenies.length != 1 ) {
5871 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5874 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5877 if ( phylogenies[ 0 ].isRooted() ) {
5881 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5882 if ( phylogenies.length != 18 ) {
5885 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5888 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5891 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5894 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5897 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5900 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5903 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5906 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5909 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5912 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5915 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5918 if ( phylogenies[ 8 ].isRooted() ) {
5921 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5924 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5927 if ( !phylogenies[ 9 ].isRooted() ) {
5930 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5933 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5936 if ( !phylogenies[ 10 ].isRooted() ) {
5939 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5942 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5945 if ( phylogenies[ 11 ].isRooted() ) {
5948 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
5951 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
5954 if ( !phylogenies[ 12 ].isRooted() ) {
5957 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
5960 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
5963 if ( !phylogenies[ 13 ].isRooted() ) {
5966 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
5969 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
5972 if ( !phylogenies[ 14 ].isRooted() ) {
5975 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
5978 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
5981 if ( phylogenies[ 15 ].isRooted() ) {
5984 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
5987 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
5990 if ( !phylogenies[ 16 ].isRooted() ) {
5993 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
5996 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
5999 if ( phylogenies[ 17 ].isRooted() ) {
6002 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6006 catch ( final Exception e ) {
6007 e.printStackTrace( System.out );
6013 private static boolean testNexusTreeParsingIterating() {
6015 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6016 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6017 if ( !p.hasNext() ) {
6020 Phylogeny phy = p.next();
6021 if ( phy == null ) {
6024 if ( phy.getNumberOfExternalNodes() != 25 ) {
6027 if ( !phy.getName().equals( "" ) ) {
6030 if ( p.hasNext() ) {
6034 if ( phy != null ) {
6039 if ( !p.hasNext() ) {
6043 if ( phy == null ) {
6046 if ( phy.getNumberOfExternalNodes() != 25 ) {
6049 if ( !phy.getName().equals( "" ) ) {
6052 if ( p.hasNext() ) {
6056 if ( phy != null ) {
6060 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6061 if ( !p.hasNext() ) {
6065 if ( phy == null ) {
6068 if ( phy.getNumberOfExternalNodes() != 10 ) {
6071 if ( !phy.getName().equals( "name" ) ) {
6074 if ( p.hasNext() ) {
6078 if ( phy != null ) {
6083 if ( !p.hasNext() ) {
6087 if ( phy == null ) {
6090 if ( phy.getNumberOfExternalNodes() != 10 ) {
6093 if ( !phy.getName().equals( "name" ) ) {
6096 if ( p.hasNext() ) {
6100 if ( phy != null ) {
6104 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6105 if ( !p.hasNext() ) {
6109 if ( phy == null ) {
6112 if ( phy.getNumberOfExternalNodes() != 3 ) {
6115 if ( !phy.getName().equals( "" ) ) {
6118 if ( phy.isRooted() ) {
6121 if ( p.hasNext() ) {
6125 if ( phy != null ) {
6130 if ( !p.hasNext() ) {
6134 if ( phy == null ) {
6137 if ( phy.getNumberOfExternalNodes() != 3 ) {
6140 if ( !phy.getName().equals( "" ) ) {
6143 if ( p.hasNext() ) {
6147 if ( phy != null ) {
6151 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6152 // if ( phylogenies.length != 18 ) {
6156 if ( !p.hasNext() ) {
6160 if ( phy == null ) {
6163 if ( phy.getNumberOfExternalNodes() != 10 ) {
6166 if ( !phy.getName().equals( "tree 0" ) ) {
6170 if ( !p.hasNext() ) {
6174 if ( phy == null ) {
6177 if ( phy.getNumberOfExternalNodes() != 10 ) {
6180 if ( !phy.getName().equals( "tree 1" ) ) {
6184 if ( !p.hasNext() ) {
6188 if ( phy == null ) {
6191 if ( phy.getNumberOfExternalNodes() != 3 ) {
6194 if ( !phy.getName().equals( "" ) ) {
6197 if ( phy.isRooted() ) {
6201 if ( !p.hasNext() ) {
6205 if ( phy == null ) {
6208 if ( phy.getNumberOfExternalNodes() != 4 ) {
6211 if ( !phy.getName().equals( "" ) ) {
6214 if ( !phy.isRooted() ) {
6218 if ( !p.hasNext() ) {
6222 if ( phy == null ) {
6225 if ( phy.getNumberOfExternalNodes() != 5 ) {
6226 System.out.println( phy.getNumberOfExternalNodes() );
6229 if ( !phy.getName().equals( "" ) ) {
6232 if ( !phy.isRooted() ) {
6236 if ( !p.hasNext() ) {
6240 if ( phy == null ) {
6243 if ( phy.getNumberOfExternalNodes() != 3 ) {
6246 if ( !phy.getName().equals( "" ) ) {
6249 if ( phy.isRooted() ) {
6253 if ( !p.hasNext() ) {
6257 if ( phy == null ) {
6260 if ( phy.getNumberOfExternalNodes() != 2 ) {
6263 if ( !phy.getName().equals( "" ) ) {
6266 if ( !phy.isRooted() ) {
6270 if ( !p.hasNext() ) {
6274 if ( phy.getNumberOfExternalNodes() != 3 ) {
6277 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6280 if ( !phy.isRooted() ) {
6284 if ( !p.hasNext() ) {
6288 if ( phy.getNumberOfExternalNodes() != 3 ) {
6291 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6294 if ( !phy.getName().equals( "tree 8" ) ) {
6298 if ( !p.hasNext() ) {
6302 if ( phy.getNumberOfExternalNodes() != 3 ) {
6305 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6308 if ( !phy.getName().equals( "tree 9" ) ) {
6312 if ( !p.hasNext() ) {
6316 if ( phy.getNumberOfExternalNodes() != 3 ) {
6319 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6322 if ( !phy.getName().equals( "tree 10" ) ) {
6325 if ( !phy.isRooted() ) {
6329 if ( !p.hasNext() ) {
6333 if ( phy.getNumberOfExternalNodes() != 3 ) {
6336 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6339 if ( !phy.getName().equals( "tree 11" ) ) {
6342 if ( phy.isRooted() ) {
6346 if ( !p.hasNext() ) {
6350 if ( phy.getNumberOfExternalNodes() != 3 ) {
6353 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6356 if ( !phy.getName().equals( "tree 12" ) ) {
6359 if ( !phy.isRooted() ) {
6363 if ( !p.hasNext() ) {
6367 if ( phy.getNumberOfExternalNodes() != 3 ) {
6370 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6373 if ( !phy.getName().equals( "tree 13" ) ) {
6376 if ( !phy.isRooted() ) {
6380 if ( !p.hasNext() ) {
6384 if ( phy.getNumberOfExternalNodes() != 10 ) {
6385 System.out.println( phy.getNumberOfExternalNodes() );
6390 .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;" ) ) {
6391 System.out.println( phy.toNewHampshire() );
6394 if ( !phy.getName().equals( "tree 14" ) ) {
6397 if ( !phy.isRooted() ) {
6401 if ( !p.hasNext() ) {
6405 if ( phy.getNumberOfExternalNodes() != 10 ) {
6406 System.out.println( phy.getNumberOfExternalNodes() );
6411 .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;" ) ) {
6412 System.out.println( phy.toNewHampshire() );
6415 if ( !phy.getName().equals( "tree 15" ) ) {
6418 if ( phy.isRooted() ) {
6422 if ( !p.hasNext() ) {
6426 if ( phy.getNumberOfExternalNodes() != 10 ) {
6427 System.out.println( phy.getNumberOfExternalNodes() );
6432 .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;" ) ) {
6433 System.out.println( phy.toNewHampshire() );
6436 if ( !phy.getName().equals( "tree 16" ) ) {
6439 if ( !phy.isRooted() ) {
6443 if ( !p.hasNext() ) {
6447 if ( phy.getNumberOfExternalNodes() != 10 ) {
6448 System.out.println( phy.getNumberOfExternalNodes() );
6453 .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;" ) ) {
6454 System.out.println( phy.toNewHampshire() );
6457 if ( !phy.getName().equals( "tree 17" ) ) {
6460 if ( phy.isRooted() ) {
6464 if ( p.hasNext() ) {
6468 if ( phy != null ) {
6473 if ( !p.hasNext() ) {
6477 if ( phy == null ) {
6480 if ( phy.getNumberOfExternalNodes() != 10 ) {
6483 if ( !phy.getName().equals( "tree 0" ) ) {
6487 if ( !p.hasNext() ) {
6491 if ( phy == null ) {
6494 if ( phy.getNumberOfExternalNodes() != 10 ) {
6497 if ( !phy.getName().equals( "tree 1" ) ) {
6501 if ( !p.hasNext() ) {
6505 if ( phy == null ) {
6508 if ( phy.getNumberOfExternalNodes() != 3 ) {
6511 if ( !phy.getName().equals( "" ) ) {
6514 if ( phy.isRooted() ) {
6518 if ( !p.hasNext() ) {
6522 if ( phy == null ) {
6525 if ( phy.getNumberOfExternalNodes() != 4 ) {
6528 if ( !phy.getName().equals( "" ) ) {
6531 if ( !phy.isRooted() ) {
6535 if ( !p.hasNext() ) {
6539 if ( phy == null ) {
6542 if ( phy.getNumberOfExternalNodes() != 5 ) {
6543 System.out.println( phy.getNumberOfExternalNodes() );
6546 if ( !phy.getName().equals( "" ) ) {
6549 if ( !phy.isRooted() ) {
6553 if ( !p.hasNext() ) {
6557 if ( phy == null ) {
6560 if ( phy.getNumberOfExternalNodes() != 3 ) {
6563 if ( !phy.getName().equals( "" ) ) {
6566 if ( phy.isRooted() ) {
6570 catch ( final Exception e ) {
6571 e.printStackTrace( System.out );
6577 private static boolean testNexusTreeParsingTranslating() {
6579 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6580 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6581 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6582 if ( phylogenies.length != 1 ) {
6585 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6588 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6591 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6594 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6597 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6598 .equals( "Aranaeus" ) ) {
6602 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6603 if ( phylogenies.length != 3 ) {
6606 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6609 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6612 if ( phylogenies[ 0 ].isRooted() ) {
6615 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6618 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6621 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6622 .equals( "Aranaeus" ) ) {
6625 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6628 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6631 if ( phylogenies[ 1 ].isRooted() ) {
6634 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6637 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6640 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6641 .equals( "Aranaeus" ) ) {
6644 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6647 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6650 if ( !phylogenies[ 2 ].isRooted() ) {
6653 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6656 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6659 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6660 .equals( "Aranaeus" ) ) {
6664 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6665 if ( phylogenies.length != 3 ) {
6668 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6671 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6674 if ( phylogenies[ 0 ].isRooted() ) {
6677 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6680 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6683 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6684 .equals( "Aranaeus" ) ) {
6687 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6690 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6693 if ( phylogenies[ 1 ].isRooted() ) {
6696 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6699 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6702 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6703 .equals( "Aranaeus" ) ) {
6706 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6709 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6712 if ( !phylogenies[ 2 ].isRooted() ) {
6715 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6718 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6721 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6722 .equals( "Aranaeus" ) ) {
6726 catch ( final Exception e ) {
6727 e.printStackTrace( System.out );
6733 private static boolean testNHParsing() {
6735 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6736 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6737 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6740 final NHXParser nhxp = new NHXParser();
6741 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6742 nhxp.setReplaceUnderscores( true );
6743 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6744 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6747 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6750 final Phylogeny p1b = factory
6751 .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 ",
6752 new NHXParser() )[ 0 ];
6753 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6756 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6759 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6760 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6761 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6762 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6763 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6764 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6765 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6766 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6767 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6768 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6769 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6770 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6771 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6773 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6776 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6779 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6782 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6785 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6786 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6787 final String p16_S = "((A,B),C)";
6788 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6789 if ( p16.length != 1 ) {
6792 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6795 final String p17_S = "(C,(A,B))";
6796 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6797 if ( p17.length != 1 ) {
6800 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6803 final String p18_S = "((A,B),(C,D))";
6804 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6805 if ( p18.length != 1 ) {
6808 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6811 final String p19_S = "(((A,B),C),D)";
6812 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6813 if ( p19.length != 1 ) {
6816 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6819 final String p20_S = "(A,(B,(C,D)))";
6820 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6821 if ( p20.length != 1 ) {
6824 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6827 final String p21_S = "(A,(B,(C,(D,E))))";
6828 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6829 if ( p21.length != 1 ) {
6832 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6835 final String p22_S = "((((A,B),C),D),E)";
6836 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6837 if ( p22.length != 1 ) {
6840 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6843 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6844 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6845 if ( p23.length != 1 ) {
6846 System.out.println( "xl=" + p23.length );
6850 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6853 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6854 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6855 if ( p24.length != 1 ) {
6858 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6861 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6862 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6863 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6864 if ( p241.length != 2 ) {
6867 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6870 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6873 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6874 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6875 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6876 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6877 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6878 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6879 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6880 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6881 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6882 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6885 final String p26_S = "(A,B)ab";
6886 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6887 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6890 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6891 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6892 if ( p27s.length != 1 ) {
6893 System.out.println( "xxl=" + p27s.length );
6897 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6898 System.out.println( p27s[ 0 ].toNewHampshireX() );
6902 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6904 if ( p27.length != 1 ) {
6905 System.out.println( "yl=" + p27.length );
6909 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6910 System.out.println( p27[ 0 ].toNewHampshireX() );
6914 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6915 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6916 final String p28_S3 = "(A,B)ab";
6917 final String p28_S4 = "((((A,B),C),D),;E;)";
6918 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6920 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6923 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6926 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6929 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6932 if ( p28.length != 4 ) {
6935 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";
6936 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6937 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6940 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";
6941 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6942 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6945 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6946 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6947 if ( ( p32.length != 0 ) ) {
6950 final String p33_S = "A";
6951 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
6952 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
6955 final String p34_S = "B;";
6956 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
6957 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
6960 final String p35_S = "B:0.2";
6961 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
6962 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
6965 final String p36_S = "(A)";
6966 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
6967 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
6970 final String p37_S = "((A))";
6971 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
6972 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
6975 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6976 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
6977 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
6980 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6981 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
6982 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
6985 final String p40_S = "(A,B,C)";
6986 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
6987 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
6990 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
6991 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
6992 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
6995 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
6996 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
6997 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7000 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)";
7001 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7002 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7005 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)))";
7006 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7007 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7010 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7011 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7012 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7015 final String p46_S = "";
7016 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7017 if ( p46.length != 0 ) {
7020 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7021 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7024 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7025 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7028 final Phylogeny p49 = factory
7029 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7030 new NHXParser() )[ 0 ];
7031 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7034 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7035 if ( p50.getNode( "A" ) == null ) {
7038 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7039 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7042 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7045 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7046 .equals( "((A,B)88:2.0,C);" ) ) {
7049 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7050 if ( p51.getNode( "A(A" ) == null ) {
7053 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7054 if ( p52.getNode( "A(A" ) == null ) {
7057 final Phylogeny p53 = factory
7058 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7059 new NHXParser() )[ 0 ];
7060 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7064 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7065 if ( p54.getNode( "A" ) == null ) {
7068 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7069 .equals( "((A,B)[88],C);" ) ) {
7073 catch ( final Exception e ) {
7074 e.printStackTrace( System.out );
7080 private static boolean testNHParsingIter() {
7082 final String p0_str = "(A,B);";
7083 final NHXParser p = new NHXParser();
7084 p.setSource( p0_str );
7085 if ( !p.hasNext() ) {
7088 final Phylogeny p0 = p.next();
7089 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7090 System.out.println( p0.toNewHampshire() );
7093 if ( p.hasNext() ) {
7096 if ( p.next() != null ) {
7100 final String p00_str = "(A,B)root;";
7101 p.setSource( p00_str );
7102 final Phylogeny p00 = p.next();
7103 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7104 System.out.println( p00.toNewHampshire() );
7108 final String p000_str = "A;";
7109 p.setSource( p000_str );
7110 final Phylogeny p000 = p.next();
7111 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7112 System.out.println( p000.toNewHampshire() );
7116 final String p0000_str = "A";
7117 p.setSource( p0000_str );
7118 final Phylogeny p0000 = p.next();
7119 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7120 System.out.println( p0000.toNewHampshire() );
7124 p.setSource( "(A)" );
7125 final Phylogeny p00000 = p.next();
7126 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7127 System.out.println( p00000.toNewHampshire() );
7131 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7132 p.setSource( p1_str );
7133 if ( !p.hasNext() ) {
7136 final Phylogeny p1_0 = p.next();
7137 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7138 System.out.println( p1_0.toNewHampshire() );
7141 if ( !p.hasNext() ) {
7144 final Phylogeny p1_1 = p.next();
7145 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7146 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7149 if ( !p.hasNext() ) {
7152 final Phylogeny p1_2 = p.next();
7153 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7154 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7157 if ( !p.hasNext() ) {
7160 final Phylogeny p1_3 = p.next();
7161 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7162 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7165 if ( p.hasNext() ) {
7168 if ( p.next() != null ) {
7172 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7173 p.setSource( p2_str );
7174 if ( !p.hasNext() ) {
7177 Phylogeny p2_0 = p.next();
7178 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7179 System.out.println( p2_0.toNewHampshire() );
7182 if ( !p.hasNext() ) {
7185 Phylogeny p2_1 = p.next();
7186 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7187 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7190 if ( !p.hasNext() ) {
7193 Phylogeny p2_2 = p.next();
7194 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7195 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7198 if ( !p.hasNext() ) {
7201 Phylogeny p2_3 = p.next();
7202 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7203 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7206 if ( !p.hasNext() ) {
7209 Phylogeny p2_4 = p.next();
7210 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7211 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7214 if ( p.hasNext() ) {
7217 if ( p.next() != null ) {
7222 if ( !p.hasNext() ) {
7226 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7227 System.out.println( p2_0.toNewHampshire() );
7230 if ( !p.hasNext() ) {
7234 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7235 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7238 if ( !p.hasNext() ) {
7242 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7243 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7246 if ( !p.hasNext() ) {
7250 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7251 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7254 if ( !p.hasNext() ) {
7258 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7259 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7262 if ( p.hasNext() ) {
7265 if ( p.next() != null ) {
7269 final String p3_str = "((A,B),C)abc";
7270 p.setSource( p3_str );
7271 if ( !p.hasNext() ) {
7274 final Phylogeny p3_0 = p.next();
7275 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7278 if ( p.hasNext() ) {
7281 if ( p.next() != null ) {
7285 final String p4_str = "((A,B)ab,C)abc";
7286 p.setSource( p4_str );
7287 if ( !p.hasNext() ) {
7290 final Phylogeny p4_0 = p.next();
7291 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7294 if ( p.hasNext() ) {
7297 if ( p.next() != null ) {
7301 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7302 p.setSource( p5_str );
7303 if ( !p.hasNext() ) {
7306 final Phylogeny p5_0 = p.next();
7307 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7310 if ( p.hasNext() ) {
7313 if ( p.next() != null ) {
7317 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7318 p.setSource( p6_str );
7319 if ( !p.hasNext() ) {
7322 Phylogeny p6_0 = p.next();
7323 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7326 if ( p.hasNext() ) {
7329 if ( p.next() != null ) {
7333 if ( !p.hasNext() ) {
7337 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7340 if ( p.hasNext() ) {
7343 if ( p.next() != null ) {
7347 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7348 p.setSource( p7_str );
7349 if ( !p.hasNext() ) {
7352 Phylogeny p7_0 = p.next();
7353 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7356 if ( p.hasNext() ) {
7359 if ( p.next() != null ) {
7363 if ( !p.hasNext() ) {
7367 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7370 if ( p.hasNext() ) {
7373 if ( p.next() != null ) {
7377 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7378 p.setSource( p8_str );
7379 if ( !p.hasNext() ) {
7382 Phylogeny p8_0 = p.next();
7383 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7386 if ( !p.hasNext() ) {
7389 if ( !p.hasNext() ) {
7392 Phylogeny p8_1 = p.next();
7393 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7396 if ( p.hasNext() ) {
7399 if ( p.next() != null ) {
7403 if ( !p.hasNext() ) {
7407 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7410 if ( !p.hasNext() ) {
7414 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7417 if ( p.hasNext() ) {
7420 if ( p.next() != null ) {
7426 if ( p.hasNext() ) {
7430 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7431 if ( !p.hasNext() ) {
7434 Phylogeny p_27 = p.next();
7435 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7436 System.out.println( p_27.toNewHampshireX() );
7440 if ( p.hasNext() ) {
7443 if ( p.next() != null ) {
7447 if ( !p.hasNext() ) {
7451 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7452 System.out.println( p_27.toNewHampshireX() );
7456 if ( p.hasNext() ) {
7459 if ( p.next() != null ) {
7463 catch ( final Exception e ) {
7464 e.printStackTrace( System.out );
7470 private static boolean testNHXconversion() {
7472 final PhylogenyNode n1 = new PhylogenyNode();
7473 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7474 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7475 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7476 final PhylogenyNode n5 = PhylogenyNode
7477 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7478 final PhylogenyNode n6 = PhylogenyNode
7479 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7480 if ( !n1.toNewHampshireX().equals( "" ) ) {
7483 if ( !n2.toNewHampshireX().equals( "" ) ) {
7486 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7489 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7492 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7495 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7496 System.out.println( n6.toNewHampshireX() );
7500 catch ( final Exception e ) {
7501 e.printStackTrace( System.out );
7507 private static boolean testNHXNodeParsing() {
7509 final PhylogenyNode n1 = new PhylogenyNode();
7510 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7511 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7512 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7513 final PhylogenyNode n5 = PhylogenyNode
7514 .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]" );
7515 if ( !n3.getName().equals( "n3" ) ) {
7518 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7521 if ( n3.isDuplication() ) {
7524 if ( n3.isHasAssignedEvent() ) {
7527 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7530 if ( !n4.getName().equals( "n4" ) ) {
7533 if ( n4.getDistanceToParent() != 0.01 ) {
7536 if ( !n5.getName().equals( "n5" ) ) {
7539 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7542 if ( n5.getDistanceToParent() != 0.1 ) {
7545 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7548 if ( !n5.isDuplication() ) {
7551 if ( !n5.isHasAssignedEvent() ) {
7554 final PhylogenyNode n8 = PhylogenyNode
7555 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7556 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7557 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7560 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7563 final PhylogenyNode n9 = PhylogenyNode
7564 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7565 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7566 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7569 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7572 final PhylogenyNode n10 = PhylogenyNode
7573 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7574 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7577 final PhylogenyNode n20 = PhylogenyNode
7578 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7579 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7582 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7585 final PhylogenyNode n20x = PhylogenyNode
7586 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7587 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7590 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7593 final PhylogenyNode n20xx = PhylogenyNode
7594 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7595 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7598 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7601 final PhylogenyNode n20xxx = PhylogenyNode
7602 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7603 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7606 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7609 final PhylogenyNode n20xxxx = PhylogenyNode
7610 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7611 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7614 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7617 final PhylogenyNode n21 = PhylogenyNode
7618 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7619 if ( !n21.getName().equals( "N21_PIG" ) ) {
7622 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7625 final PhylogenyNode n21x = PhylogenyNode
7626 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7627 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7630 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7633 final PhylogenyNode n22 = PhylogenyNode
7634 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7635 if ( !n22.getName().equals( "n22/PIG" ) ) {
7638 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7641 final PhylogenyNode n23 = PhylogenyNode
7642 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7643 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7646 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7649 final PhylogenyNode a = PhylogenyNode
7650 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7651 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7654 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7657 final PhylogenyNode c1 = PhylogenyNode
7658 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7659 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7660 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7663 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7666 final PhylogenyNode c2 = PhylogenyNode
7667 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7668 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7669 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7672 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7675 final PhylogenyNode e3 = PhylogenyNode
7676 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7677 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7680 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7683 final PhylogenyNode n11 = PhylogenyNode
7684 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7685 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7686 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7689 if ( n11.getDistanceToParent() != 0.4 ) {
7692 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7695 final PhylogenyNode n12 = PhylogenyNode
7696 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7697 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7698 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7701 if ( n12.getDistanceToParent() != 0.4 ) {
7704 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7707 final PhylogenyNode o = PhylogenyNode
7708 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7709 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7712 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7715 if ( n1.getName().compareTo( "" ) != 0 ) {
7718 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7721 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7724 if ( n2.getName().compareTo( "" ) != 0 ) {
7727 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7730 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7733 final PhylogenyNode n00 = PhylogenyNode
7734 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7735 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7738 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7741 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7742 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7745 final PhylogenyNode n13 = PhylogenyNode
7746 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7747 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7750 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7753 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7756 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7759 final PhylogenyNode n14 = PhylogenyNode
7760 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7761 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7764 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7767 final PhylogenyNode n15 = PhylogenyNode
7768 .createInstanceFromNhxString( "something_wicked[123]",
7769 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7770 if ( !n15.getName().equals( "something_wicked" ) ) {
7773 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7776 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7779 final PhylogenyNode n16 = PhylogenyNode
7780 .createInstanceFromNhxString( "something_wicked2[9]",
7781 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7782 if ( !n16.getName().equals( "something_wicked2" ) ) {
7785 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7788 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7791 final PhylogenyNode n17 = PhylogenyNode
7792 .createInstanceFromNhxString( "something_wicked3[a]",
7793 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7794 if ( !n17.getName().equals( "something_wicked3" ) ) {
7797 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7800 final PhylogenyNode n18 = PhylogenyNode
7801 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7802 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7805 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7808 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7811 final PhylogenyNode n19 = PhylogenyNode
7812 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7813 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7816 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7819 final PhylogenyNode n30 = PhylogenyNode
7820 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7821 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7822 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7825 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7828 final PhylogenyNode n31 = PhylogenyNode
7829 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7830 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7831 if ( n31.getNodeData().isHasTaxonomy() ) {
7834 final PhylogenyNode n32 = PhylogenyNode
7835 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7836 if ( n32.getNodeData().isHasTaxonomy() ) {
7839 final PhylogenyNode n40 = PhylogenyNode
7840 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7841 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7844 final PhylogenyNode n41 = PhylogenyNode
7845 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7846 if ( n41.getNodeData().isHasTaxonomy() ) {
7849 final PhylogenyNode n42 = PhylogenyNode
7850 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7851 if ( n42.getNodeData().isHasTaxonomy() ) {
7854 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7855 NHXParser.TAXONOMY_EXTRACTION.NO );
7856 if ( n43.getNodeData().isHasTaxonomy() ) {
7859 final PhylogenyNode n44 = PhylogenyNode
7860 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7861 if ( n44.getNodeData().isHasTaxonomy() ) {
7865 catch ( final Exception e ) {
7866 e.printStackTrace( System.out );
7872 private static boolean testNHXParsing() {
7874 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7875 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7876 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7879 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]";
7880 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7881 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7884 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]";
7885 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7886 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7889 final Phylogeny[] p3 = factory
7890 .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]",
7892 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7895 final Phylogeny[] p4 = factory
7896 .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(]",
7898 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7901 final Phylogeny[] p5 = factory
7902 .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(((]",
7904 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7907 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)";
7908 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)";
7909 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7910 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7913 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)))";
7914 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)))";
7915 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7916 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7919 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]) ))[,,, ])))))))";
7920 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7921 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7922 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7925 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7926 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7929 final Phylogeny p10 = factory
7930 .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]",
7931 new NHXParser() )[ 0 ];
7932 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7936 catch ( final Exception e ) {
7937 e.printStackTrace( System.out );
7943 private static boolean testNHXParsingMB() {
7945 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7946 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7947 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7948 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7949 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7950 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7951 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7952 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7953 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7954 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7955 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7958 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7961 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
7962 0.1100000000000000e+00 ) ) {
7965 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
7968 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
7971 final Phylogeny p2 = factory
7972 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
7973 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7974 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7975 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7976 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7977 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7978 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7979 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7980 + "7.369400000000000e-02}])",
7981 new NHXParser() )[ 0 ];
7982 if ( p2.getNode( "1" ) == null ) {
7985 if ( p2.getNode( "2" ) == null ) {
7989 catch ( final Exception e ) {
7990 e.printStackTrace( System.out );
7997 private static boolean testNHXParsingQuotes() {
7999 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8000 final NHXParser p = new NHXParser();
8001 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8002 if ( phylogenies_0.length != 5 ) {
8005 final Phylogeny phy = phylogenies_0[ 4 ];
8006 if ( phy.getNumberOfExternalNodes() != 7 ) {
8009 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8012 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8015 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8016 .getScientificName().equals( "hsapiens" ) ) {
8019 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8022 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8025 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8028 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8031 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8034 final NHXParser p1p = new NHXParser();
8035 p1p.setIgnoreQuotes( true );
8036 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8037 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8040 final NHXParser p2p = new NHXParser();
8041 p1p.setIgnoreQuotes( false );
8042 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8043 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8046 final NHXParser p3p = new NHXParser();
8047 p3p.setIgnoreQuotes( false );
8048 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8049 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8052 final NHXParser p4p = new NHXParser();
8053 p4p.setIgnoreQuotes( false );
8054 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8055 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8058 final Phylogeny p10 = factory
8059 .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]",
8060 new NHXParser() )[ 0 ];
8061 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]";
8062 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8065 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8066 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8070 final Phylogeny p12 = factory
8071 .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]",
8072 new NHXParser() )[ 0 ];
8073 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]";
8074 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8077 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8078 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8081 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;";
8082 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8085 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8086 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8090 catch ( final Exception e ) {
8091 e.printStackTrace( System.out );
8097 private static boolean testNodeRemoval() {
8099 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8100 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8101 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8102 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8105 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8106 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8107 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8110 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8111 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8112 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8116 catch ( final Exception e ) {
8117 e.printStackTrace( System.out );
8123 private static boolean testPhylogenyBranch() {
8125 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8126 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8127 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8128 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8129 if ( !a1b1.equals( a1b1 ) ) {
8132 if ( !a1b1.equals( b1a1 ) ) {
8135 if ( !b1a1.equals( a1b1 ) ) {
8138 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8139 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8140 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8141 if ( a1_b1.equals( b1_a1 ) ) {
8144 if ( a1_b1.equals( a1_b1_ ) ) {
8147 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8148 if ( !a1_b1.equals( b1_a1_ ) ) {
8151 if ( a1_b1_.equals( b1_a1_ ) ) {
8154 if ( !a1_b1_.equals( b1_a1 ) ) {
8158 catch ( final Exception e ) {
8159 e.printStackTrace( System.out );
8165 private static boolean testPhyloXMLparsingOfDistributionElement() {
8167 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8168 PhyloXmlParser xml_parser = null;
8170 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8172 catch ( final Exception e ) {
8173 // Do nothing -- means were not running from jar.
8175 if ( xml_parser == null ) {
8176 xml_parser = new PhyloXmlParser();
8177 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8178 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8181 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8184 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8186 if ( xml_parser.getErrorCount() > 0 ) {
8187 System.out.println( xml_parser.getErrorMessages().toString() );
8190 if ( phylogenies_0.length != 1 ) {
8193 final Phylogeny t1 = phylogenies_0[ 0 ];
8194 PhylogenyNode n = null;
8195 Distribution d = null;
8196 n = t1.getNode( "root node" );
8197 if ( !n.getNodeData().isHasDistribution() ) {
8200 if ( n.getNodeData().getDistributions().size() != 1 ) {
8203 d = n.getNodeData().getDistribution();
8204 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8207 if ( d.getPoints().size() != 1 ) {
8210 if ( d.getPolygons() != null ) {
8213 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8216 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8219 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8222 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8225 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8228 n = t1.getNode( "node a" );
8229 if ( !n.getNodeData().isHasDistribution() ) {
8232 if ( n.getNodeData().getDistributions().size() != 2 ) {
8235 d = n.getNodeData().getDistribution( 1 );
8236 if ( !d.getDesc().equals( "San Diego" ) ) {
8239 if ( d.getPoints().size() != 1 ) {
8242 if ( d.getPolygons() != null ) {
8245 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8248 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8251 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8254 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8257 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8260 n = t1.getNode( "node bb" );
8261 if ( !n.getNodeData().isHasDistribution() ) {
8264 if ( n.getNodeData().getDistributions().size() != 1 ) {
8267 d = n.getNodeData().getDistribution( 0 );
8268 if ( d.getPoints().size() != 3 ) {
8271 if ( d.getPolygons().size() != 2 ) {
8274 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8277 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8280 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8283 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8286 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8289 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8292 Polygon p = d.getPolygons().get( 0 );
8293 if ( p.getPoints().size() != 3 ) {
8296 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8299 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8302 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8305 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8308 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8311 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8314 p = d.getPolygons().get( 1 );
8315 if ( p.getPoints().size() != 3 ) {
8318 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8321 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8324 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8328 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8329 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8330 if ( rt.length != 1 ) {
8333 final Phylogeny t1_rt = rt[ 0 ];
8334 n = t1_rt.getNode( "root node" );
8335 if ( !n.getNodeData().isHasDistribution() ) {
8338 if ( n.getNodeData().getDistributions().size() != 1 ) {
8341 d = n.getNodeData().getDistribution();
8342 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8345 if ( d.getPoints().size() != 1 ) {
8348 if ( d.getPolygons() != null ) {
8351 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8354 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8357 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8360 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8363 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8366 n = t1_rt.getNode( "node a" );
8367 if ( !n.getNodeData().isHasDistribution() ) {
8370 if ( n.getNodeData().getDistributions().size() != 2 ) {
8373 d = n.getNodeData().getDistribution( 1 );
8374 if ( !d.getDesc().equals( "San Diego" ) ) {
8377 if ( d.getPoints().size() != 1 ) {
8380 if ( d.getPolygons() != null ) {
8383 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8386 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8389 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8392 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8395 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8398 n = t1_rt.getNode( "node bb" );
8399 if ( !n.getNodeData().isHasDistribution() ) {
8402 if ( n.getNodeData().getDistributions().size() != 1 ) {
8405 d = n.getNodeData().getDistribution( 0 );
8406 if ( d.getPoints().size() != 3 ) {
8409 if ( d.getPolygons().size() != 2 ) {
8412 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8415 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8418 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8421 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8424 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8427 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8430 p = d.getPolygons().get( 0 );
8431 if ( p.getPoints().size() != 3 ) {
8434 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8437 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8440 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8443 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8446 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8449 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8452 p = d.getPolygons().get( 1 );
8453 if ( p.getPoints().size() != 3 ) {
8456 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8459 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8462 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8466 catch ( final Exception e ) {
8467 e.printStackTrace( System.out );
8473 private static boolean testPostOrderIterator() {
8475 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8476 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8477 PhylogenyNodeIterator it0;
8478 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8481 for( it0.reset(); it0.hasNext(); ) {
8484 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8485 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8486 if ( !it.next().getName().equals( "A" ) ) {
8489 if ( !it.next().getName().equals( "B" ) ) {
8492 if ( !it.next().getName().equals( "ab" ) ) {
8495 if ( !it.next().getName().equals( "C" ) ) {
8498 if ( !it.next().getName().equals( "D" ) ) {
8501 if ( !it.next().getName().equals( "cd" ) ) {
8504 if ( !it.next().getName().equals( "abcd" ) ) {
8507 if ( !it.next().getName().equals( "E" ) ) {
8510 if ( !it.next().getName().equals( "F" ) ) {
8513 if ( !it.next().getName().equals( "ef" ) ) {
8516 if ( !it.next().getName().equals( "G" ) ) {
8519 if ( !it.next().getName().equals( "H" ) ) {
8522 if ( !it.next().getName().equals( "gh" ) ) {
8525 if ( !it.next().getName().equals( "efgh" ) ) {
8528 if ( !it.next().getName().equals( "r" ) ) {
8531 if ( it.hasNext() ) {
8535 catch ( final Exception e ) {
8536 e.printStackTrace( System.out );
8542 private static boolean testPreOrderIterator() {
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.iteratorPreorder(); it0.hasNext(); ) {
8550 for( it0.reset(); it0.hasNext(); ) {
8553 PhylogenyNodeIterator it = t0.iteratorPreorder();
8554 if ( !it.next().getName().equals( "r" ) ) {
8557 if ( !it.next().getName().equals( "ab" ) ) {
8560 if ( !it.next().getName().equals( "A" ) ) {
8563 if ( !it.next().getName().equals( "B" ) ) {
8566 if ( !it.next().getName().equals( "cd" ) ) {
8569 if ( !it.next().getName().equals( "C" ) ) {
8572 if ( !it.next().getName().equals( "D" ) ) {
8575 if ( it.hasNext() ) {
8578 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8579 it = t1.iteratorPreorder();
8580 if ( !it.next().getName().equals( "r" ) ) {
8583 if ( !it.next().getName().equals( "abcd" ) ) {
8586 if ( !it.next().getName().equals( "ab" ) ) {
8589 if ( !it.next().getName().equals( "A" ) ) {
8592 if ( !it.next().getName().equals( "B" ) ) {
8595 if ( !it.next().getName().equals( "cd" ) ) {
8598 if ( !it.next().getName().equals( "C" ) ) {
8601 if ( !it.next().getName().equals( "D" ) ) {
8604 if ( !it.next().getName().equals( "efgh" ) ) {
8607 if ( !it.next().getName().equals( "ef" ) ) {
8610 if ( !it.next().getName().equals( "E" ) ) {
8613 if ( !it.next().getName().equals( "F" ) ) {
8616 if ( !it.next().getName().equals( "gh" ) ) {
8619 if ( !it.next().getName().equals( "G" ) ) {
8622 if ( !it.next().getName().equals( "H" ) ) {
8625 if ( it.hasNext() ) {
8629 catch ( final Exception e ) {
8630 e.printStackTrace( System.out );
8636 private static boolean testPropertiesMap() {
8638 final PropertiesMap pm = new PropertiesMap();
8639 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8640 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8641 final Property p2 = new Property( "something:else",
8643 "improbable:research",
8646 pm.addProperty( p0 );
8647 pm.addProperty( p1 );
8648 pm.addProperty( p2 );
8649 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8652 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8655 if ( pm.getProperties().size() != 3 ) {
8658 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8661 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8664 if ( pm.getProperties().size() != 3 ) {
8667 pm.removeProperty( "dimensions:diameter" );
8668 if ( pm.getProperties().size() != 2 ) {
8671 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8674 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8678 catch ( final Exception e ) {
8679 e.printStackTrace( System.out );
8685 private static boolean testProteinId() {
8687 final ProteinId id1 = new ProteinId( "a" );
8688 final ProteinId id2 = new ProteinId( "a" );
8689 final ProteinId id3 = new ProteinId( "A" );
8690 final ProteinId id4 = new ProteinId( "b" );
8691 if ( !id1.equals( id1 ) ) {
8694 if ( id1.getId().equals( "x" ) ) {
8697 if ( id1.getId().equals( null ) ) {
8700 if ( !id1.equals( id2 ) ) {
8703 if ( id1.equals( id3 ) ) {
8706 if ( id1.hashCode() != id1.hashCode() ) {
8709 if ( id1.hashCode() != id2.hashCode() ) {
8712 if ( id1.hashCode() == id3.hashCode() ) {
8715 if ( id1.compareTo( id1 ) != 0 ) {
8718 if ( id1.compareTo( id2 ) != 0 ) {
8721 if ( id1.compareTo( id3 ) != 0 ) {
8724 if ( id1.compareTo( id4 ) >= 0 ) {
8727 if ( id4.compareTo( id1 ) <= 0 ) {
8730 if ( !id4.getId().equals( "b" ) ) {
8733 final ProteinId id5 = new ProteinId( " C " );
8734 if ( !id5.getId().equals( "C" ) ) {
8737 if ( id5.equals( id1 ) ) {
8741 catch ( final Exception e ) {
8742 e.printStackTrace( System.out );
8748 private static boolean testReIdMethods() {
8750 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8751 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8752 final long count = PhylogenyNode.getNodeCount();
8754 if ( p.getNode( "r" ).getId() != count ) {
8757 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8760 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8763 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8766 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8769 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8772 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8775 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8778 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8781 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8784 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8787 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8790 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8793 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8796 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8800 catch ( final Exception e ) {
8801 e.printStackTrace( System.out );
8807 private static boolean testRerooting() {
8809 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8810 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",
8811 new NHXParser() )[ 0 ];
8812 if ( !t1.isRooted() ) {
8815 t1.reRoot( t1.getNode( "D" ) );
8816 t1.reRoot( t1.getNode( "CD" ) );
8817 t1.reRoot( t1.getNode( "A" ) );
8818 t1.reRoot( t1.getNode( "B" ) );
8819 t1.reRoot( t1.getNode( "AB" ) );
8820 t1.reRoot( t1.getNode( "D" ) );
8821 t1.reRoot( t1.getNode( "C" ) );
8822 t1.reRoot( t1.getNode( "CD" ) );
8823 t1.reRoot( t1.getNode( "A" ) );
8824 t1.reRoot( t1.getNode( "B" ) );
8825 t1.reRoot( t1.getNode( "AB" ) );
8826 t1.reRoot( t1.getNode( "D" ) );
8827 t1.reRoot( t1.getNode( "D" ) );
8828 t1.reRoot( t1.getNode( "C" ) );
8829 t1.reRoot( t1.getNode( "A" ) );
8830 t1.reRoot( t1.getNode( "B" ) );
8831 t1.reRoot( t1.getNode( "AB" ) );
8832 t1.reRoot( t1.getNode( "C" ) );
8833 t1.reRoot( t1.getNode( "D" ) );
8834 t1.reRoot( t1.getNode( "CD" ) );
8835 t1.reRoot( t1.getNode( "D" ) );
8836 t1.reRoot( t1.getNode( "A" ) );
8837 t1.reRoot( t1.getNode( "B" ) );
8838 t1.reRoot( t1.getNode( "AB" ) );
8839 t1.reRoot( t1.getNode( "C" ) );
8840 t1.reRoot( t1.getNode( "D" ) );
8841 t1.reRoot( t1.getNode( "CD" ) );
8842 t1.reRoot( t1.getNode( "D" ) );
8843 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8846 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8849 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8852 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8855 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8858 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8861 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",
8862 new NHXParser() )[ 0 ];
8863 t2.reRoot( t2.getNode( "A" ) );
8864 t2.reRoot( t2.getNode( "D" ) );
8865 t2.reRoot( t2.getNode( "ABC" ) );
8866 t2.reRoot( t2.getNode( "A" ) );
8867 t2.reRoot( t2.getNode( "B" ) );
8868 t2.reRoot( t2.getNode( "D" ) );
8869 t2.reRoot( t2.getNode( "C" ) );
8870 t2.reRoot( t2.getNode( "ABC" ) );
8871 t2.reRoot( t2.getNode( "A" ) );
8872 t2.reRoot( t2.getNode( "B" ) );
8873 t2.reRoot( t2.getNode( "AB" ) );
8874 t2.reRoot( t2.getNode( "AB" ) );
8875 t2.reRoot( t2.getNode( "D" ) );
8876 t2.reRoot( t2.getNode( "C" ) );
8877 t2.reRoot( t2.getNode( "B" ) );
8878 t2.reRoot( t2.getNode( "AB" ) );
8879 t2.reRoot( t2.getNode( "D" ) );
8880 t2.reRoot( t2.getNode( "D" ) );
8881 t2.reRoot( t2.getNode( "ABC" ) );
8882 t2.reRoot( t2.getNode( "A" ) );
8883 t2.reRoot( t2.getNode( "B" ) );
8884 t2.reRoot( t2.getNode( "AB" ) );
8885 t2.reRoot( t2.getNode( "D" ) );
8886 t2.reRoot( t2.getNode( "C" ) );
8887 t2.reRoot( t2.getNode( "ABC" ) );
8888 t2.reRoot( t2.getNode( "A" ) );
8889 t2.reRoot( t2.getNode( "B" ) );
8890 t2.reRoot( t2.getNode( "AB" ) );
8891 t2.reRoot( t2.getNode( "D" ) );
8892 t2.reRoot( t2.getNode( "D" ) );
8893 t2.reRoot( t2.getNode( "C" ) );
8894 t2.reRoot( t2.getNode( "A" ) );
8895 t2.reRoot( t2.getNode( "B" ) );
8896 t2.reRoot( t2.getNode( "AB" ) );
8897 t2.reRoot( t2.getNode( "C" ) );
8898 t2.reRoot( t2.getNode( "D" ) );
8899 t2.reRoot( t2.getNode( "ABC" ) );
8900 t2.reRoot( t2.getNode( "D" ) );
8901 t2.reRoot( t2.getNode( "A" ) );
8902 t2.reRoot( t2.getNode( "B" ) );
8903 t2.reRoot( t2.getNode( "AB" ) );
8904 t2.reRoot( t2.getNode( "C" ) );
8905 t2.reRoot( t2.getNode( "D" ) );
8906 t2.reRoot( t2.getNode( "ABC" ) );
8907 t2.reRoot( t2.getNode( "D" ) );
8908 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8911 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8914 t2.reRoot( t2.getNode( "ABC" ) );
8915 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8918 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8921 t2.reRoot( t2.getNode( "AB" ) );
8922 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8925 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8928 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8931 t2.reRoot( t2.getNode( "AB" ) );
8932 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8935 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8938 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8941 t2.reRoot( t2.getNode( "D" ) );
8942 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8945 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8948 t2.reRoot( t2.getNode( "ABC" ) );
8949 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8952 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8955 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
8956 new NHXParser() )[ 0 ];
8957 t3.reRoot( t3.getNode( "B" ) );
8958 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8961 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8964 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8967 t3.reRoot( t3.getNode( "B" ) );
8968 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8971 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8974 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8977 t3.reRoot( t3.getRoot() );
8978 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8981 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8984 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8988 catch ( final Exception e ) {
8989 e.printStackTrace( System.out );
8995 private static boolean testSDIse() {
8997 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8998 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
8999 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9000 gene1.setRooted( true );
9001 species1.setRooted( true );
9002 final SDI sdi = new SDI( gene1, species1 );
9003 if ( !gene1.getRoot().isDuplication() ) {
9006 final Phylogeny species2 = factory
9007 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9008 new NHXParser() )[ 0 ];
9009 final Phylogeny gene2 = factory
9010 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9011 new NHXParser() )[ 0 ];
9012 species2.setRooted( true );
9013 gene2.setRooted( true );
9014 final SDI sdi2 = new SDI( gene2, species2 );
9015 if ( sdi2.getDuplicationsSum() != 0 ) {
9018 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9021 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9024 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9027 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9030 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9033 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9036 final Phylogeny species3 = factory
9037 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9038 new NHXParser() )[ 0 ];
9039 final Phylogeny gene3 = factory
9040 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9041 new NHXParser() )[ 0 ];
9042 species3.setRooted( true );
9043 gene3.setRooted( true );
9044 final SDI sdi3 = new SDI( gene3, species3 );
9045 if ( sdi3.getDuplicationsSum() != 1 ) {
9048 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9051 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9054 final Phylogeny species4 = factory
9055 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9056 new NHXParser() )[ 0 ];
9057 final Phylogeny gene4 = factory
9058 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9059 new NHXParser() )[ 0 ];
9060 species4.setRooted( true );
9061 gene4.setRooted( true );
9062 final SDI sdi4 = new SDI( gene4, species4 );
9063 if ( sdi4.getDuplicationsSum() != 1 ) {
9066 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9069 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9072 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9075 if ( species4.getNumberOfExternalNodes() != 6 ) {
9078 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9081 final Phylogeny species5 = factory
9082 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9083 new NHXParser() )[ 0 ];
9084 final Phylogeny gene5 = factory
9085 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9086 new NHXParser() )[ 0 ];
9087 species5.setRooted( true );
9088 gene5.setRooted( true );
9089 final SDI sdi5 = new SDI( gene5, species5 );
9090 if ( sdi5.getDuplicationsSum() != 2 ) {
9093 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9096 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9099 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9102 if ( species5.getNumberOfExternalNodes() != 6 ) {
9105 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9108 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9109 // Conjecture for Comparing Molecular Phylogenies"
9110 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9111 final Phylogeny species6 = factory
9112 .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,"
9113 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9114 new NHXParser() )[ 0 ];
9115 final Phylogeny gene6 = factory
9116 .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,"
9117 + "((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,"
9118 + "(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;",
9119 new NHXParser() )[ 0 ];
9120 species6.setRooted( true );
9121 gene6.setRooted( true );
9122 final SDI sdi6 = new SDI( gene6, species6 );
9123 if ( sdi6.getDuplicationsSum() != 3 ) {
9126 if ( !gene6.getNode( "r" ).isDuplication() ) {
9129 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9132 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9135 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9138 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9141 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9144 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9147 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9150 sdi6.computeMappingCostL();
9151 if ( sdi6.computeMappingCostL() != 17 ) {
9154 if ( species6.getNumberOfExternalNodes() != 9 ) {
9157 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9160 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9161 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9162 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9163 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9164 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9165 species7.setRooted( true );
9166 final Phylogeny gene7_1 = Test
9167 .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])" );
9168 gene7_1.setRooted( true );
9169 final SDI sdi7 = new SDI( gene7_1, species7 );
9170 if ( sdi7.getDuplicationsSum() != 0 ) {
9173 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9176 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9179 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9182 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9185 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9188 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9191 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9194 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9197 final Phylogeny gene7_2 = Test
9198 .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])" );
9199 gene7_2.setRooted( true );
9200 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9201 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9204 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9207 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9210 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9213 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9216 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9219 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9222 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9225 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9228 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9232 catch ( final Exception e ) {
9238 private static boolean testSDIunrooted() {
9240 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9241 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9242 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9243 final Iterator<PhylogenyBranch> iter = l.iterator();
9244 PhylogenyBranch br = iter.next();
9245 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9248 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9252 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9255 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9259 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9262 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9266 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9269 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9273 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9276 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9280 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9283 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9287 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9290 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9294 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9297 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9301 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9304 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9308 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9311 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9315 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9318 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9322 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9325 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9329 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9332 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9336 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9339 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9343 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9346 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9349 if ( iter.hasNext() ) {
9352 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9353 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9354 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9356 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9359 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9363 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9366 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9370 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9373 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9376 if ( iter1.hasNext() ) {
9379 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9380 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9381 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9383 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9386 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9390 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9393 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9397 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9400 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9403 if ( iter2.hasNext() ) {
9406 final Phylogeny species0 = factory
9407 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9408 new NHXParser() )[ 0 ];
9409 final Phylogeny gene1 = factory
9410 .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])",
9411 new NHXParser() )[ 0 ];
9412 species0.setRooted( true );
9413 gene1.setRooted( true );
9414 final SDIR sdi_unrooted = new SDIR();
9415 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9416 if ( sdi_unrooted.getCount() != 1 ) {
9419 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9422 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9425 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9428 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9431 final Phylogeny gene2 = factory
9432 .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])",
9433 new NHXParser() )[ 0 ];
9434 gene2.setRooted( true );
9435 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9436 if ( sdi_unrooted.getCount() != 1 ) {
9439 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9442 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9445 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9448 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9451 final Phylogeny species6 = factory
9452 .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,"
9453 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9454 new NHXParser() )[ 0 ];
9455 final Phylogeny gene6 = factory
9456 .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],"
9457 + "(((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],"
9458 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9459 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9460 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9461 new NHXParser() )[ 0 ];
9462 species6.setRooted( true );
9463 gene6.setRooted( true );
9464 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9465 if ( sdi_unrooted.getCount() != 1 ) {
9468 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9471 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9474 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9477 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9480 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9483 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9486 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9489 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9492 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9495 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9498 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9501 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9505 final Phylogeny species7 = factory
9506 .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,"
9507 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9508 new NHXParser() )[ 0 ];
9509 final Phylogeny gene7 = factory
9510 .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],"
9511 + "(((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],"
9512 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9513 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9514 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9515 new NHXParser() )[ 0 ];
9516 species7.setRooted( true );
9517 gene7.setRooted( true );
9518 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9519 if ( sdi_unrooted.getCount() != 1 ) {
9522 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9525 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9528 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9531 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9534 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9537 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9540 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9543 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9546 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9549 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9552 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9555 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9559 final Phylogeny species8 = factory
9560 .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,"
9561 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9562 new NHXParser() )[ 0 ];
9563 final Phylogeny gene8 = factory
9564 .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],"
9565 + "(((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],"
9566 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9567 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9568 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9569 new NHXParser() )[ 0 ];
9570 species8.setRooted( true );
9571 gene8.setRooted( true );
9572 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9573 if ( sdi_unrooted.getCount() != 1 ) {
9576 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9579 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9582 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9585 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9588 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9591 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9594 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9597 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9600 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9603 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9606 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9609 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9614 catch ( final Exception e ) {
9615 e.printStackTrace( System.out );
9621 private static boolean testSequenceIdParsing() {
9623 Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" );
9624 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9625 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9627 System.out.println( "value =" + id.getValue() );
9628 System.out.println( "provider=" + id.getProvider() );
9633 id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" );
9634 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9635 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9637 System.out.println( "value =" + id.getValue() );
9638 System.out.println( "provider=" + id.getProvider() );
9643 id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" );
9644 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9645 || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) {
9647 System.out.println( "value =" + id.getValue() );
9648 System.out.println( "provider=" + id.getProvider() );
9653 id = SequenceIdParser.parse( "gb_AAA96518_1" );
9654 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9655 || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) {
9657 System.out.println( "value =" + id.getValue() );
9658 System.out.println( "provider=" + id.getProvider() );
9663 id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" );
9664 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9665 || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) {
9667 System.out.println( "value =" + id.getValue() );
9668 System.out.println( "provider=" + id.getProvider() );
9673 id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" );
9674 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9675 || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) {
9677 System.out.println( "value =" + id.getValue() );
9678 System.out.println( "provider=" + id.getProvider() );
9683 id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" );
9684 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9685 || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) {
9687 System.out.println( "value =" + id.getValue() );
9688 System.out.println( "provider=" + id.getProvider() );
9693 id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" );
9694 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9695 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9697 System.out.println( "value =" + id.getValue() );
9698 System.out.println( "provider=" + id.getProvider() );
9703 id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" );
9704 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9705 || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) {
9707 System.out.println( "value =" + id.getValue() );
9708 System.out.println( "provider=" + id.getProvider() );
9713 id = SequenceIdParser.parse( "P4A123" );
9714 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9715 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9717 System.out.println( "value =" + id.getValue() );
9718 System.out.println( "provider=" + id.getProvider() );
9723 id = SequenceIdParser.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
9724 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() )
9725 || !id.getValue().equals( "P4A123" ) || !id.getProvider().equals( "sp" ) ) {
9727 System.out.println( "value =" + id.getValue() );
9728 System.out.println( "provider=" + id.getProvider() );
9733 id = SequenceIdParser.parse( "XP_12345" );
9735 System.out.println( "value =" + id.getValue() );
9736 System.out.println( "provider=" + id.getProvider() );
9739 // lcl_91970_unknown_
9741 catch ( final Exception e ) {
9742 e.printStackTrace( System.out );
9748 private static boolean testSequenceWriter() {
9750 final String n = ForesterUtil.LINE_SEPARATOR;
9751 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9754 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9757 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9760 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9763 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9764 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9767 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9768 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9772 catch ( final Exception e ) {
9773 e.printStackTrace();
9779 private static boolean testSpecies() {
9781 final Species s1 = new BasicSpecies( "a" );
9782 final Species s2 = new BasicSpecies( "a" );
9783 final Species s3 = new BasicSpecies( "A" );
9784 final Species s4 = new BasicSpecies( "b" );
9785 if ( !s1.equals( s1 ) ) {
9788 if ( s1.getSpeciesId().equals( "x" ) ) {
9791 if ( s1.getSpeciesId().equals( null ) ) {
9794 if ( !s1.equals( s2 ) ) {
9797 if ( s1.equals( s3 ) ) {
9800 if ( s1.hashCode() != s1.hashCode() ) {
9803 if ( s1.hashCode() != s2.hashCode() ) {
9806 if ( s1.hashCode() == s3.hashCode() ) {
9809 if ( s1.compareTo( s1 ) != 0 ) {
9812 if ( s1.compareTo( s2 ) != 0 ) {
9815 if ( s1.compareTo( s3 ) != 0 ) {
9818 if ( s1.compareTo( s4 ) >= 0 ) {
9821 if ( s4.compareTo( s1 ) <= 0 ) {
9824 if ( !s4.getSpeciesId().equals( "b" ) ) {
9827 final Species s5 = new BasicSpecies( " C " );
9828 if ( !s5.getSpeciesId().equals( "C" ) ) {
9831 if ( s5.equals( s1 ) ) {
9835 catch ( final Exception e ) {
9836 e.printStackTrace( System.out );
9842 private static boolean testSplit() {
9844 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9845 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9846 //Archaeopteryx.createApplication( p0 );
9847 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9848 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9849 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9850 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9851 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9852 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9853 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9854 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9855 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9856 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9857 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9858 // System.out.println( s0.toString() );
9860 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9863 if ( s0.match( query_nodes ) ) {
9866 query_nodes = new HashSet<PhylogenyNode>();
9867 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9874 if ( !s0.match( query_nodes ) ) {
9878 query_nodes = new HashSet<PhylogenyNode>();
9879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9882 if ( !s0.match( query_nodes ) ) {
9886 query_nodes = new HashSet<PhylogenyNode>();
9887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9891 if ( !s0.match( query_nodes ) ) {
9895 query_nodes = new HashSet<PhylogenyNode>();
9896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9900 if ( !s0.match( query_nodes ) ) {
9904 query_nodes = new HashSet<PhylogenyNode>();
9905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9908 if ( !s0.match( query_nodes ) ) {
9912 query_nodes = new HashSet<PhylogenyNode>();
9913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9915 if ( !s0.match( query_nodes ) ) {
9919 query_nodes = new HashSet<PhylogenyNode>();
9920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9925 if ( !s0.match( query_nodes ) ) {
9929 query_nodes = new HashSet<PhylogenyNode>();
9930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9933 if ( !s0.match( query_nodes ) ) {
9937 query_nodes = new HashSet<PhylogenyNode>();
9938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9942 if ( !s0.match( query_nodes ) ) {
9946 query_nodes = new HashSet<PhylogenyNode>();
9947 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9949 if ( s0.match( query_nodes ) ) {
9953 query_nodes = new HashSet<PhylogenyNode>();
9954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9958 if ( s0.match( query_nodes ) ) {
9962 query_nodes = new HashSet<PhylogenyNode>();
9963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9968 if ( s0.match( query_nodes ) ) {
9972 query_nodes = new HashSet<PhylogenyNode>();
9973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9976 if ( s0.match( query_nodes ) ) {
9980 query_nodes = new HashSet<PhylogenyNode>();
9981 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9983 if ( s0.match( query_nodes ) ) {
9987 query_nodes = new HashSet<PhylogenyNode>();
9988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9989 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9990 if ( s0.match( query_nodes ) ) {
9994 query_nodes = new HashSet<PhylogenyNode>();
9995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9997 if ( s0.match( query_nodes ) ) {
10001 query_nodes = new HashSet<PhylogenyNode>();
10002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10004 if ( s0.match( query_nodes ) ) {
10008 query_nodes = new HashSet<PhylogenyNode>();
10009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10011 if ( s0.match( query_nodes ) ) {
10015 query_nodes = new HashSet<PhylogenyNode>();
10016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10018 if ( s0.match( query_nodes ) ) {
10022 query_nodes = new HashSet<PhylogenyNode>();
10023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10024 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10026 if ( s0.match( query_nodes ) ) {
10030 query_nodes = new HashSet<PhylogenyNode>();
10031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10034 if ( s0.match( query_nodes ) ) {
10038 query_nodes = new HashSet<PhylogenyNode>();
10039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10042 if ( s0.match( query_nodes ) ) {
10046 query_nodes = new HashSet<PhylogenyNode>();
10047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10048 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10051 if ( s0.match( query_nodes ) ) {
10055 // query_nodes = new HashSet<PhylogenyNode>();
10056 // query_nodes.add( new PhylogenyNode( "X" ) );
10057 // query_nodes.add( new PhylogenyNode( "Y" ) );
10058 // query_nodes.add( new PhylogenyNode( "A" ) );
10059 // query_nodes.add( new PhylogenyNode( "B" ) );
10060 // query_nodes.add( new PhylogenyNode( "C" ) );
10061 // query_nodes.add( new PhylogenyNode( "D" ) );
10062 // query_nodes.add( new PhylogenyNode( "E" ) );
10063 // query_nodes.add( new PhylogenyNode( "F" ) );
10064 // query_nodes.add( new PhylogenyNode( "G" ) );
10065 // if ( !s0.match( query_nodes ) ) {
10068 // query_nodes = new HashSet<PhylogenyNode>();
10069 // query_nodes.add( new PhylogenyNode( "X" ) );
10070 // query_nodes.add( new PhylogenyNode( "Y" ) );
10071 // query_nodes.add( new PhylogenyNode( "A" ) );
10072 // query_nodes.add( new PhylogenyNode( "B" ) );
10073 // query_nodes.add( new PhylogenyNode( "C" ) );
10074 // if ( !s0.match( query_nodes ) ) {
10078 // query_nodes = new HashSet<PhylogenyNode>();
10079 // query_nodes.add( new PhylogenyNode( "X" ) );
10080 // query_nodes.add( new PhylogenyNode( "Y" ) );
10081 // query_nodes.add( new PhylogenyNode( "D" ) );
10082 // query_nodes.add( new PhylogenyNode( "E" ) );
10083 // query_nodes.add( new PhylogenyNode( "F" ) );
10084 // query_nodes.add( new PhylogenyNode( "G" ) );
10085 // if ( !s0.match( query_nodes ) ) {
10089 // query_nodes = new HashSet<PhylogenyNode>();
10090 // query_nodes.add( new PhylogenyNode( "X" ) );
10091 // query_nodes.add( new PhylogenyNode( "Y" ) );
10092 // query_nodes.add( new PhylogenyNode( "A" ) );
10093 // query_nodes.add( new PhylogenyNode( "B" ) );
10094 // query_nodes.add( new PhylogenyNode( "C" ) );
10095 // query_nodes.add( new PhylogenyNode( "D" ) );
10096 // if ( !s0.match( query_nodes ) ) {
10100 // query_nodes = new HashSet<PhylogenyNode>();
10101 // query_nodes.add( new PhylogenyNode( "X" ) );
10102 // query_nodes.add( new PhylogenyNode( "Y" ) );
10103 // query_nodes.add( new PhylogenyNode( "E" ) );
10104 // query_nodes.add( new PhylogenyNode( "F" ) );
10105 // query_nodes.add( new PhylogenyNode( "G" ) );
10106 // if ( !s0.match( query_nodes ) ) {
10110 // query_nodes = new HashSet<PhylogenyNode>();
10111 // query_nodes.add( new PhylogenyNode( "X" ) );
10112 // query_nodes.add( new PhylogenyNode( "Y" ) );
10113 // query_nodes.add( new PhylogenyNode( "F" ) );
10114 // query_nodes.add( new PhylogenyNode( "G" ) );
10115 // if ( !s0.match( query_nodes ) ) {
10119 query_nodes = new HashSet<PhylogenyNode>();
10120 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10121 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10122 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10123 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10124 if ( s0.match( query_nodes ) ) {
10128 query_nodes = new HashSet<PhylogenyNode>();
10129 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10130 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10132 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10133 if ( s0.match( query_nodes ) ) {
10136 ///////////////////////////
10138 query_nodes = new HashSet<PhylogenyNode>();
10139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10141 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10143 if ( s0.match( query_nodes ) ) {
10147 query_nodes = new HashSet<PhylogenyNode>();
10148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10152 if ( s0.match( query_nodes ) ) {
10156 query_nodes = new HashSet<PhylogenyNode>();
10157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10161 if ( s0.match( query_nodes ) ) {
10165 query_nodes = new HashSet<PhylogenyNode>();
10166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10170 if ( s0.match( query_nodes ) ) {
10174 query_nodes = new HashSet<PhylogenyNode>();
10175 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10179 if ( s0.match( query_nodes ) ) {
10183 query_nodes = new HashSet<PhylogenyNode>();
10184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10187 if ( s0.match( query_nodes ) ) {
10191 query_nodes = new HashSet<PhylogenyNode>();
10192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10193 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10197 if ( s0.match( query_nodes ) ) {
10201 query_nodes = new HashSet<PhylogenyNode>();
10202 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10203 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10207 if ( s0.match( query_nodes ) ) {
10211 query_nodes = new HashSet<PhylogenyNode>();
10212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10215 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10217 if ( s0.match( query_nodes ) ) {
10221 query_nodes = new HashSet<PhylogenyNode>();
10222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10226 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10227 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10228 if ( s0.match( query_nodes ) ) {
10232 catch ( final Exception e ) {
10233 e.printStackTrace();
10239 private static boolean testSplitStrict() {
10241 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10242 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10243 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10244 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10245 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10246 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10247 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10248 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10249 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10250 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10251 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10252 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10254 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10255 if ( s0.match( query_nodes ) ) {
10258 query_nodes = new HashSet<PhylogenyNode>();
10259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
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( "A" ) );
10272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10274 if ( !s0.match( query_nodes ) ) {
10278 query_nodes = new HashSet<PhylogenyNode>();
10279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10283 if ( !s0.match( query_nodes ) ) {
10287 query_nodes = new HashSet<PhylogenyNode>();
10288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10292 if ( !s0.match( query_nodes ) ) {
10296 query_nodes = new HashSet<PhylogenyNode>();
10297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10300 if ( !s0.match( query_nodes ) ) {
10304 query_nodes = new HashSet<PhylogenyNode>();
10305 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10307 if ( !s0.match( query_nodes ) ) {
10311 query_nodes = new HashSet<PhylogenyNode>();
10312 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10313 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10314 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10317 if ( !s0.match( query_nodes ) ) {
10321 query_nodes = new HashSet<PhylogenyNode>();
10322 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10325 if ( !s0.match( query_nodes ) ) {
10329 query_nodes = new HashSet<PhylogenyNode>();
10330 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10331 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10334 if ( !s0.match( query_nodes ) ) {
10338 query_nodes = new HashSet<PhylogenyNode>();
10339 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10341 if ( s0.match( query_nodes ) ) {
10345 query_nodes = new HashSet<PhylogenyNode>();
10346 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10350 if ( s0.match( query_nodes ) ) {
10354 query_nodes = new HashSet<PhylogenyNode>();
10355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10360 if ( s0.match( query_nodes ) ) {
10364 query_nodes = new HashSet<PhylogenyNode>();
10365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10368 if ( s0.match( query_nodes ) ) {
10372 query_nodes = new HashSet<PhylogenyNode>();
10373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10375 if ( s0.match( query_nodes ) ) {
10379 query_nodes = new HashSet<PhylogenyNode>();
10380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10382 if ( s0.match( query_nodes ) ) {
10386 query_nodes = new HashSet<PhylogenyNode>();
10387 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10389 if ( s0.match( query_nodes ) ) {
10393 query_nodes = new HashSet<PhylogenyNode>();
10394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10396 if ( s0.match( query_nodes ) ) {
10400 query_nodes = new HashSet<PhylogenyNode>();
10401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10403 if ( s0.match( query_nodes ) ) {
10407 query_nodes = new HashSet<PhylogenyNode>();
10408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10409 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
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( "F" ) );
10417 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10418 if ( s0.match( query_nodes ) ) {
10422 query_nodes = new HashSet<PhylogenyNode>();
10423 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10424 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10425 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10426 if ( s0.match( query_nodes ) ) {
10430 query_nodes = new HashSet<PhylogenyNode>();
10431 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10432 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10433 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10434 if ( s0.match( query_nodes ) ) {
10438 query_nodes = new HashSet<PhylogenyNode>();
10439 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10440 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10441 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10443 if ( s0.match( query_nodes ) ) {
10447 catch ( final Exception e ) {
10448 e.printStackTrace();
10454 private static boolean testSubtreeDeletion() {
10456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10457 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10458 t1.deleteSubtree( t1.getNode( "A" ), false );
10459 if ( t1.getNumberOfExternalNodes() != 5 ) {
10462 t1.toNewHampshireX();
10463 t1.deleteSubtree( t1.getNode( "E" ), false );
10464 if ( t1.getNumberOfExternalNodes() != 4 ) {
10467 t1.toNewHampshireX();
10468 t1.deleteSubtree( t1.getNode( "F" ), false );
10469 if ( t1.getNumberOfExternalNodes() != 3 ) {
10472 t1.toNewHampshireX();
10473 t1.deleteSubtree( t1.getNode( "D" ), false );
10474 t1.toNewHampshireX();
10475 if ( t1.getNumberOfExternalNodes() != 3 ) {
10478 t1.deleteSubtree( t1.getNode( "def" ), false );
10479 t1.toNewHampshireX();
10480 if ( t1.getNumberOfExternalNodes() != 2 ) {
10483 t1.deleteSubtree( t1.getNode( "B" ), false );
10484 t1.toNewHampshireX();
10485 if ( t1.getNumberOfExternalNodes() != 1 ) {
10488 t1.deleteSubtree( t1.getNode( "C" ), false );
10489 t1.toNewHampshireX();
10490 if ( t1.getNumberOfExternalNodes() != 1 ) {
10493 t1.deleteSubtree( t1.getNode( "abc" ), false );
10494 t1.toNewHampshireX();
10495 if ( t1.getNumberOfExternalNodes() != 1 ) {
10498 t1.deleteSubtree( t1.getNode( "r" ), false );
10499 if ( t1.getNumberOfExternalNodes() != 0 ) {
10502 if ( !t1.isEmpty() ) {
10505 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10506 t2.deleteSubtree( t2.getNode( "A" ), false );
10507 t2.toNewHampshireX();
10508 if ( t2.getNumberOfExternalNodes() != 5 ) {
10511 t2.deleteSubtree( t2.getNode( "abc" ), false );
10512 t2.toNewHampshireX();
10513 if ( t2.getNumberOfExternalNodes() != 3 ) {
10516 t2.deleteSubtree( t2.getNode( "def" ), false );
10517 t2.toNewHampshireX();
10518 if ( t2.getNumberOfExternalNodes() != 1 ) {
10522 catch ( final Exception e ) {
10523 e.printStackTrace( System.out );
10529 private static boolean testSupportCount() {
10531 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10532 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10533 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10534 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10535 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10536 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10537 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10539 SupportCount.count( t0_1, phylogenies_1, true, false );
10540 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10541 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10542 + "(((((A,B),C),D),E),((F,G),X))"
10543 + "(((((A,Y),B),C),D),((F,G),E))"
10544 + "(((((A,B),C),D),E),(F,G))"
10545 + "(((((A,B),C),D),E),(F,G))"
10546 + "(((((A,B),C),D),E),(F,G))"
10547 + "(((((A,B),C),D),E),(F,G),Z)"
10548 + "(((((A,B),C),D),E),(F,G))"
10549 + "((((((A,B),C),D),E),F),G)"
10550 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10552 SupportCount.count( t0_2, phylogenies_2, true, false );
10553 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10554 while ( it.hasNext() ) {
10555 final PhylogenyNode n = it.next();
10556 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10560 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10561 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10562 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10563 SupportCount.count( t0_3, phylogenies_3, true, false );
10564 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10565 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10568 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10571 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10574 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10577 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10580 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10583 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10586 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10589 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10592 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10595 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10596 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10597 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10598 SupportCount.count( t0_4, phylogenies_4, true, false );
10599 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10600 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10603 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10606 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10609 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10612 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10615 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10618 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10621 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10624 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10627 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10630 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10631 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10632 double d = SupportCount.compare( b1, a, true, true, true );
10633 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10636 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10637 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10638 d = SupportCount.compare( b2, a, true, true, true );
10639 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10642 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10643 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10644 d = SupportCount.compare( b3, a, true, true, true );
10645 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10648 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10649 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10650 d = SupportCount.compare( b4, a, true, true, false );
10651 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10655 catch ( final Exception e ) {
10656 e.printStackTrace( System.out );
10662 private static boolean testSupportTransfer() {
10664 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10665 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)",
10666 new NHXParser() )[ 0 ];
10667 final Phylogeny p2 = factory
10668 .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 ];
10669 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10672 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10675 support_transfer.moveBranchLengthsToBootstrap( p1 );
10676 support_transfer.transferSupportValues( p1, p2 );
10677 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10680 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10683 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10686 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10689 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10692 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10695 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10698 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10702 catch ( final Exception e ) {
10703 e.printStackTrace( System.out );
10709 private static boolean testTaxonomyExtraction() {
10711 final PhylogenyNode n0 = PhylogenyNode
10712 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10713 if ( n0.getNodeData().isHasTaxonomy() ) {
10716 final PhylogenyNode n1 = PhylogenyNode
10717 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10718 if ( n1.getNodeData().isHasTaxonomy() ) {
10719 System.out.println( n1.toString() );
10722 final PhylogenyNode n2x = PhylogenyNode
10723 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10724 if ( n2x.getNodeData().isHasTaxonomy() ) {
10727 final PhylogenyNode n3 = PhylogenyNode
10728 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10729 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10730 System.out.println( n3.toString() );
10733 final PhylogenyNode n4 = PhylogenyNode
10734 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10735 if ( n4.getNodeData().isHasTaxonomy() ) {
10736 System.out.println( n4.toString() );
10739 final PhylogenyNode n5 = PhylogenyNode
10740 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10741 if ( n5.getNodeData().isHasTaxonomy() ) {
10742 System.out.println( n5.toString() );
10745 final PhylogenyNode n6 = PhylogenyNode
10746 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10747 if ( n6.getNodeData().isHasTaxonomy() ) {
10748 System.out.println( n6.toString() );
10751 final PhylogenyNode n7 = PhylogenyNode
10752 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10753 if ( n7.getNodeData().isHasTaxonomy() ) {
10754 System.out.println( n7.toString() );
10757 final PhylogenyNode n8 = PhylogenyNode
10758 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10759 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10760 System.out.println( n8.toString() );
10763 final PhylogenyNode n9 = PhylogenyNode
10764 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10765 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10766 System.out.println( n9.toString() );
10769 final PhylogenyNode n10x = PhylogenyNode
10770 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10771 if ( n10x.getNodeData().isHasTaxonomy() ) {
10772 System.out.println( n10x.toString() );
10775 final PhylogenyNode n10xx = PhylogenyNode
10776 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10777 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10778 System.out.println( n10xx.toString() );
10781 final PhylogenyNode n10 = PhylogenyNode
10782 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10783 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10784 System.out.println( n10.toString() );
10787 final PhylogenyNode n11 = PhylogenyNode
10788 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10789 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10790 System.out.println( n11.toString() );
10793 final PhylogenyNode n12 = PhylogenyNode
10794 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10795 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10796 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10797 System.out.println( n12.toString() );
10800 final PhylogenyNode n13 = PhylogenyNode
10801 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10802 if ( n13.getNodeData().isHasTaxonomy() ) {
10803 System.out.println( n13.toString() );
10807 catch ( final Exception e ) {
10808 e.printStackTrace( System.out );
10814 private static boolean testTreeMethods() {
10816 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10817 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10818 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10819 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10820 System.out.println( t0.toNewHampshireX() );
10823 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10824 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10825 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10828 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10831 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10835 catch ( final Exception e ) {
10836 e.printStackTrace( System.out );
10842 private static boolean testUniprotEntryRetrieval() {
10844 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
10845 if ( !entry.getAccession().equals( "P12345" ) ) {
10848 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
10851 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
10854 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
10857 if ( !entry.getGeneName().equals( "GOT2" ) ) {
10860 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
10864 catch ( final IOException e ) {
10865 System.out.println();
10866 System.out.println( "the following might be due to absence internet connection:" );
10867 e.printStackTrace( System.out );
10870 catch ( final Exception e ) {
10876 private static boolean testUniprotTaxonomySearch() {
10878 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
10880 if ( results.size() != 1 ) {
10883 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10886 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10889 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10892 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10895 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10899 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
10900 if ( results.size() != 1 ) {
10903 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10906 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10909 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10912 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10915 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10919 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
10920 if ( results.size() != 1 ) {
10923 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10926 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10929 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10932 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10935 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10939 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
10940 if ( results.size() != 1 ) {
10943 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10946 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10949 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10952 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10955 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10958 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
10961 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
10964 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10965 .equals( "Nematostella vectensis" ) ) {
10966 System.out.println( results.get( 0 ).getLineage() );
10971 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
10972 if ( results.size() != 1 ) {
10975 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
10978 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
10981 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
10984 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10987 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
10990 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10991 .equals( "Xenopus tropicalis" ) ) {
10992 System.out.println( results.get( 0 ).getLineage() );
10997 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
10998 if ( results.size() != 1 ) {
11001 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11004 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11007 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11010 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11013 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11016 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11017 .equals( "Xenopus tropicalis" ) ) {
11018 System.out.println( results.get( 0 ).getLineage() );
11023 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11024 if ( results.size() != 1 ) {
11027 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11030 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11033 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11036 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11039 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11042 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11043 .equals( "Xenopus tropicalis" ) ) {
11044 System.out.println( results.get( 0 ).getLineage() );
11048 catch ( final IOException e ) {
11049 System.out.println();
11050 System.out.println( "the following might be due to absence internet connection:" );
11051 e.printStackTrace( System.out );
11054 catch ( final Exception e ) {
11060 private static boolean testWabiTxSearch() {
11062 String result = "";
11063 result = TxSearch.searchSimple( "nematostella" );
11064 result = TxSearch.getTxId( "nematostella" );
11065 if ( !result.equals( "45350" ) ) {
11068 result = TxSearch.getTxName( "45350" );
11069 if ( !result.equals( "Nematostella" ) ) {
11072 result = TxSearch.getTxId( "nematostella vectensis" );
11073 if ( !result.equals( "45351" ) ) {
11076 result = TxSearch.getTxName( "45351" );
11077 if ( !result.equals( "Nematostella vectensis" ) ) {
11080 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11081 if ( !result.equals( "536089" ) ) {
11084 result = TxSearch.getTxName( "536089" );
11085 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11088 final List<String> queries = new ArrayList<String>();
11089 queries.add( "Campylobacter coli" );
11090 queries.add( "Escherichia coli" );
11091 queries.add( "Arabidopsis" );
11092 queries.add( "Trichoplax" );
11093 queries.add( "Samanea saman" );
11094 queries.add( "Kluyveromyces marxianus" );
11095 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11096 queries.add( "Bornavirus parrot/PDD/2008" );
11097 final List<RANKS> ranks = new ArrayList<RANKS>();
11098 ranks.add( RANKS.SUPERKINGDOM );
11099 ranks.add( RANKS.KINGDOM );
11100 ranks.add( RANKS.FAMILY );
11101 ranks.add( RANKS.GENUS );
11102 ranks.add( RANKS.TRIBE );
11103 result = TxSearch.searchLineage( queries, ranks );
11104 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11105 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11107 catch ( final Exception e ) {
11108 System.out.println();
11109 System.out.println( "the following might be due to absence internet connection:" );
11110 e.printStackTrace( System.out );