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.SequenceAccessionTools;
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 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1213 if ( x.size() != 4 ) {
1217 for( final 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 ) {
1509 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
1512 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
1515 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
1518 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
1521 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
1524 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
1527 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
1531 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
1534 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
1535 .equalsIgnoreCase( "435" ) ) {
1538 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
1541 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
1542 .equalsIgnoreCase( "443.7" ) ) {
1545 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
1548 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
1551 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
1552 .equalsIgnoreCase( "433" ) ) {
1555 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
1556 .getCrossReferences();
1557 if ( x.size() != 4 ) {
1561 for( final 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( "AAA34956" );
2508 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
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 ) );
2526 n.setName( "P12345" );
2527 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2528 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2531 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
2532 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
2533 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
2537 catch ( final Exception e ) {
2538 e.printStackTrace( System.out );
2544 private static boolean testDataObjects() {
2546 final Confidence s0 = new Confidence();
2547 final Confidence s1 = new Confidence();
2548 if ( !s0.isEqual( s1 ) ) {
2551 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
2552 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
2553 if ( s2.isEqual( s1 ) ) {
2556 if ( !s2.isEqual( s3 ) ) {
2559 final Confidence s4 = ( Confidence ) s3.copy();
2560 if ( !s4.isEqual( s3 ) ) {
2567 final Taxonomy t1 = new Taxonomy();
2568 final Taxonomy t2 = new Taxonomy();
2569 final Taxonomy t3 = new Taxonomy();
2570 final Taxonomy t4 = new Taxonomy();
2571 final Taxonomy t5 = new Taxonomy();
2572 t1.setIdentifier( new Identifier( "ecoli" ) );
2573 t1.setTaxonomyCode( "ECOLI" );
2574 t1.setScientificName( "E. coli" );
2575 t1.setCommonName( "coli" );
2576 final Taxonomy t0 = ( Taxonomy ) t1.copy();
2577 if ( !t1.isEqual( t0 ) ) {
2580 t2.setIdentifier( new Identifier( "ecoli" ) );
2581 t2.setTaxonomyCode( "OTHER" );
2582 t2.setScientificName( "what" );
2583 t2.setCommonName( "something" );
2584 if ( !t1.isEqual( t2 ) ) {
2587 t2.setIdentifier( new Identifier( "nemve" ) );
2588 if ( t1.isEqual( t2 ) ) {
2591 t1.setIdentifier( null );
2592 t3.setTaxonomyCode( "ECOLI" );
2593 t3.setScientificName( "what" );
2594 t3.setCommonName( "something" );
2595 if ( !t1.isEqual( t3 ) ) {
2598 t1.setIdentifier( null );
2599 t1.setTaxonomyCode( "" );
2600 t4.setScientificName( "E. ColI" );
2601 t4.setCommonName( "something" );
2602 if ( !t1.isEqual( t4 ) ) {
2605 t4.setScientificName( "B. subtilis" );
2606 t4.setCommonName( "something" );
2607 if ( t1.isEqual( t4 ) ) {
2610 t1.setIdentifier( null );
2611 t1.setTaxonomyCode( "" );
2612 t1.setScientificName( "" );
2613 t5.setCommonName( "COLI" );
2614 if ( !t1.isEqual( t5 ) ) {
2617 t5.setCommonName( "vibrio" );
2618 if ( t1.isEqual( t5 ) ) {
2623 final Identifier id0 = new Identifier( "123", "pfam" );
2624 final Identifier id1 = ( Identifier ) id0.copy();
2625 if ( !id1.isEqual( id1 ) ) {
2628 if ( !id1.isEqual( id0 ) ) {
2631 if ( !id0.isEqual( id1 ) ) {
2638 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
2639 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
2640 if ( !pd1.isEqual( pd1 ) ) {
2643 if ( !pd1.isEqual( pd0 ) ) {
2648 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
2649 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
2650 if ( !pd3.isEqual( pd3 ) ) {
2653 if ( !pd2.isEqual( pd3 ) ) {
2656 if ( !pd0.isEqual( pd3 ) ) {
2661 // DomainArchitecture
2662 // ------------------
2663 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
2664 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
2665 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
2666 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
2667 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
2668 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
2673 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
2674 if ( ds0.getNumberOfDomains() != 4 ) {
2677 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
2678 if ( !ds0.isEqual( ds0 ) ) {
2681 if ( !ds0.isEqual( ds1 ) ) {
2684 if ( ds1.getNumberOfDomains() != 4 ) {
2687 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
2692 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
2693 if ( ds0.isEqual( ds2 ) ) {
2699 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
2700 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
2701 System.out.println( ds3.toNHX() );
2704 if ( ds3.getNumberOfDomains() != 3 ) {
2709 final Event e1 = new Event( Event.EventType.fusion );
2710 if ( e1.isDuplication() ) {
2713 if ( !e1.isFusion() ) {
2716 if ( !e1.asText().toString().equals( "fusion" ) ) {
2719 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
2722 final Event e11 = new Event( Event.EventType.fusion );
2723 if ( !e11.isEqual( e1 ) ) {
2726 if ( !e11.toNHX().toString().equals( "" ) ) {
2729 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
2730 if ( e2.isDuplication() ) {
2733 if ( !e2.isSpeciationOrDuplication() ) {
2736 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
2739 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
2742 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
2745 if ( e11.isEqual( e2 ) ) {
2748 final Event e2c = ( Event ) e2.copy();
2749 if ( !e2c.isEqual( e2 ) ) {
2752 Event e3 = new Event( 1, 2, 3 );
2753 if ( e3.isDuplication() ) {
2756 if ( e3.isSpeciation() ) {
2759 if ( e3.isGeneLoss() ) {
2762 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2765 final Event e3c = ( Event ) e3.copy();
2766 final Event e3cc = ( Event ) e3c.copy();
2767 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
2771 if ( !e3c.isEqual( e3cc ) ) {
2774 Event e4 = new Event( 1, 2, 3 );
2775 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2778 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
2781 final Event e4c = ( Event ) e4.copy();
2783 final Event e4cc = ( Event ) e4c.copy();
2784 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
2787 if ( !e4c.isEqual( e4cc ) ) {
2790 final Event e5 = new Event();
2791 if ( !e5.isUnassigned() ) {
2794 if ( !e5.asText().toString().equals( "unassigned" ) ) {
2797 if ( !e5.asSimpleText().toString().equals( "" ) ) {
2800 final Event e6 = new Event( 1, 0, 0 );
2801 if ( !e6.asText().toString().equals( "duplication" ) ) {
2804 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
2807 final Event e7 = new Event( 0, 1, 0 );
2808 if ( !e7.asText().toString().equals( "speciation" ) ) {
2811 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
2814 final Event e8 = new Event( 0, 0, 1 );
2815 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
2818 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
2822 catch ( final Exception e ) {
2823 e.printStackTrace( System.out );
2829 private static boolean testDeletionOfExternalNodes() {
2831 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2832 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
2833 final PhylogenyWriter w = new PhylogenyWriter();
2834 if ( t0.isEmpty() ) {
2837 if ( t0.getNumberOfExternalNodes() != 1 ) {
2840 t0.deleteSubtree( t0.getNode( "A" ), false );
2841 if ( t0.getNumberOfExternalNodes() != 0 ) {
2844 if ( !t0.isEmpty() ) {
2847 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
2848 if ( t1.getNumberOfExternalNodes() != 2 ) {
2851 t1.deleteSubtree( t1.getNode( "A" ), false );
2852 if ( t1.getNumberOfExternalNodes() != 1 ) {
2855 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
2858 t1.deleteSubtree( t1.getNode( "B" ), false );
2859 if ( t1.getNumberOfExternalNodes() != 1 ) {
2862 t1.deleteSubtree( t1.getNode( "r" ), false );
2863 if ( !t1.isEmpty() ) {
2866 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
2867 if ( t2.getNumberOfExternalNodes() != 3 ) {
2870 t2.deleteSubtree( t2.getNode( "B" ), false );
2871 if ( t2.getNumberOfExternalNodes() != 2 ) {
2874 t2.toNewHampshireX();
2875 PhylogenyNode n = t2.getNode( "A" );
2876 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2879 t2.deleteSubtree( t2.getNode( "A" ), false );
2880 if ( t2.getNumberOfExternalNodes() != 2 ) {
2883 t2.deleteSubtree( t2.getNode( "C" ), true );
2884 if ( t2.getNumberOfExternalNodes() != 1 ) {
2887 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
2888 if ( t3.getNumberOfExternalNodes() != 4 ) {
2891 t3.deleteSubtree( t3.getNode( "B" ), true );
2892 if ( t3.getNumberOfExternalNodes() != 3 ) {
2895 n = t3.getNode( "A" );
2896 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
2899 n = n.getNextExternalNode();
2900 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2903 t3.deleteSubtree( t3.getNode( "A" ), true );
2904 if ( t3.getNumberOfExternalNodes() != 2 ) {
2907 n = t3.getNode( "C" );
2908 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
2911 t3.deleteSubtree( t3.getNode( "C" ), true );
2912 if ( t3.getNumberOfExternalNodes() != 1 ) {
2915 t3.deleteSubtree( t3.getNode( "D" ), true );
2916 if ( t3.getNumberOfExternalNodes() != 0 ) {
2919 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2920 if ( t4.getNumberOfExternalNodes() != 6 ) {
2923 t4.deleteSubtree( t4.getNode( "B2" ), true );
2924 if ( t4.getNumberOfExternalNodes() != 5 ) {
2927 String s = w.toNewHampshire( t4, false, true ).toString();
2928 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2931 t4.deleteSubtree( t4.getNode( "B11" ), true );
2932 if ( t4.getNumberOfExternalNodes() != 4 ) {
2935 t4.deleteSubtree( t4.getNode( "C" ), true );
2936 if ( t4.getNumberOfExternalNodes() != 3 ) {
2939 n = t4.getNode( "A" );
2940 n = n.getNextExternalNode();
2941 if ( !n.getName().equals( "B12" ) ) {
2944 n = n.getNextExternalNode();
2945 if ( !n.getName().equals( "D" ) ) {
2948 s = w.toNewHampshire( t4, false, true ).toString();
2949 if ( !s.equals( "((A,B12),D);" ) ) {
2952 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2953 t5.deleteSubtree( t5.getNode( "A" ), true );
2954 if ( t5.getNumberOfExternalNodes() != 5 ) {
2957 s = w.toNewHampshire( t5, false, true ).toString();
2958 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
2961 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2962 t6.deleteSubtree( t6.getNode( "B11" ), true );
2963 if ( t6.getNumberOfExternalNodes() != 5 ) {
2966 s = w.toNewHampshire( t6, false, false ).toString();
2967 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
2970 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2971 t7.deleteSubtree( t7.getNode( "B12" ), true );
2972 if ( t7.getNumberOfExternalNodes() != 5 ) {
2975 s = w.toNewHampshire( t7, false, true ).toString();
2976 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
2979 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2980 t8.deleteSubtree( t8.getNode( "B2" ), true );
2981 if ( t8.getNumberOfExternalNodes() != 5 ) {
2984 s = w.toNewHampshire( t8, false, false ).toString();
2985 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
2988 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2989 t9.deleteSubtree( t9.getNode( "C" ), true );
2990 if ( t9.getNumberOfExternalNodes() != 5 ) {
2993 s = w.toNewHampshire( t9, false, true ).toString();
2994 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
2997 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
2998 t10.deleteSubtree( t10.getNode( "D" ), true );
2999 if ( t10.getNumberOfExternalNodes() != 5 ) {
3002 s = w.toNewHampshire( t10, false, true ).toString();
3003 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3006 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3007 t11.deleteSubtree( t11.getNode( "A" ), true );
3008 if ( t11.getNumberOfExternalNodes() != 2 ) {
3011 s = w.toNewHampshire( t11, false, true ).toString();
3012 if ( !s.equals( "(B,C);" ) ) {
3015 t11.deleteSubtree( t11.getNode( "C" ), true );
3016 if ( t11.getNumberOfExternalNodes() != 1 ) {
3019 s = w.toNewHampshire( t11, false, false ).toString();
3020 if ( !s.equals( "B;" ) ) {
3023 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3024 t12.deleteSubtree( t12.getNode( "B2" ), true );
3025 if ( t12.getNumberOfExternalNodes() != 8 ) {
3028 s = w.toNewHampshire( t12, false, true ).toString();
3029 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3032 t12.deleteSubtree( t12.getNode( "B3" ), true );
3033 if ( t12.getNumberOfExternalNodes() != 7 ) {
3036 s = w.toNewHampshire( t12, false, true ).toString();
3037 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3040 t12.deleteSubtree( t12.getNode( "C3" ), true );
3041 if ( t12.getNumberOfExternalNodes() != 6 ) {
3044 s = w.toNewHampshire( t12, false, true ).toString();
3045 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3048 t12.deleteSubtree( t12.getNode( "A1" ), true );
3049 if ( t12.getNumberOfExternalNodes() != 5 ) {
3052 s = w.toNewHampshire( t12, false, true ).toString();
3053 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3056 t12.deleteSubtree( t12.getNode( "B1" ), true );
3057 if ( t12.getNumberOfExternalNodes() != 4 ) {
3060 s = w.toNewHampshire( t12, false, true ).toString();
3061 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3064 t12.deleteSubtree( t12.getNode( "A3" ), true );
3065 if ( t12.getNumberOfExternalNodes() != 3 ) {
3068 s = w.toNewHampshire( t12, false, true ).toString();
3069 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3072 t12.deleteSubtree( t12.getNode( "A2" ), true );
3073 if ( t12.getNumberOfExternalNodes() != 2 ) {
3076 s = w.toNewHampshire( t12, false, true ).toString();
3077 if ( !s.equals( "(C1,C2);" ) ) {
3080 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3081 t13.deleteSubtree( t13.getNode( "D" ), true );
3082 if ( t13.getNumberOfExternalNodes() != 4 ) {
3085 s = w.toNewHampshire( t13, false, true ).toString();
3086 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3089 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3090 t14.deleteSubtree( t14.getNode( "E" ), true );
3091 if ( t14.getNumberOfExternalNodes() != 5 ) {
3094 s = w.toNewHampshire( t14, false, true ).toString();
3095 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3098 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3099 t15.deleteSubtree( t15.getNode( "B2" ), true );
3100 if ( t15.getNumberOfExternalNodes() != 11 ) {
3103 t15.deleteSubtree( t15.getNode( "B1" ), true );
3104 if ( t15.getNumberOfExternalNodes() != 10 ) {
3107 t15.deleteSubtree( t15.getNode( "B3" ), true );
3108 if ( t15.getNumberOfExternalNodes() != 9 ) {
3111 t15.deleteSubtree( t15.getNode( "B4" ), true );
3112 if ( t15.getNumberOfExternalNodes() != 8 ) {
3115 t15.deleteSubtree( t15.getNode( "A1" ), true );
3116 if ( t15.getNumberOfExternalNodes() != 7 ) {
3119 t15.deleteSubtree( t15.getNode( "C4" ), true );
3120 if ( t15.getNumberOfExternalNodes() != 6 ) {
3124 catch ( final Exception e ) {
3125 e.printStackTrace( System.out );
3131 private static boolean testDescriptiveStatistics() {
3133 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3134 dss1.addValue( 82 );
3135 dss1.addValue( 78 );
3136 dss1.addValue( 70 );
3137 dss1.addValue( 58 );
3138 dss1.addValue( 42 );
3139 if ( dss1.getN() != 5 ) {
3142 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3145 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3148 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3151 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3154 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3157 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3160 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3163 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3166 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3169 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3172 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3175 dss1.addValue( 123 );
3176 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3179 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3182 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3185 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3186 dss2.addValue( -1.85 );
3187 dss2.addValue( 57.5 );
3188 dss2.addValue( 92.78 );
3189 dss2.addValue( 57.78 );
3190 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3193 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3196 final double[] a = dss2.getDataAsDoubleArray();
3197 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3200 dss2.addValue( -100 );
3201 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3204 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3207 final double[] ds = new double[ 14 ];
3222 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3223 if ( bins.length != 4 ) {
3226 if ( bins[ 0 ] != 2 ) {
3229 if ( bins[ 1 ] != 3 ) {
3232 if ( bins[ 2 ] != 4 ) {
3235 if ( bins[ 3 ] != 5 ) {
3238 final double[] ds1 = new double[ 9 ];
3248 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3249 if ( bins1.length != 4 ) {
3252 if ( bins1[ 0 ] != 2 ) {
3255 if ( bins1[ 1 ] != 3 ) {
3258 if ( bins1[ 2 ] != 0 ) {
3261 if ( bins1[ 3 ] != 4 ) {
3264 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3265 if ( bins1_1.length != 3 ) {
3268 if ( bins1_1[ 0 ] != 3 ) {
3271 if ( bins1_1[ 1 ] != 2 ) {
3274 if ( bins1_1[ 2 ] != 4 ) {
3277 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3278 if ( bins1_2.length != 3 ) {
3281 if ( bins1_2[ 0 ] != 2 ) {
3284 if ( bins1_2[ 1 ] != 2 ) {
3287 if ( bins1_2[ 2 ] != 2 ) {
3290 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3304 dss3.addValue( 10 );
3305 dss3.addValue( 10 );
3306 dss3.addValue( 10 );
3307 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3308 histo.toStringBuffer( 10, '=', 40, 5 );
3309 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3311 catch ( final Exception e ) {
3312 e.printStackTrace( System.out );
3318 private static boolean testDir( final String file ) {
3320 final File f = new File( file );
3321 if ( !f.exists() ) {
3324 if ( !f.isDirectory() ) {
3327 if ( !f.canRead() ) {
3331 catch ( final Exception e ) {
3337 private static boolean testEmblEntryRetrieval() {
3338 //The format for GenBank Accession numbers are:
3339 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
3340 //Protein: 3 letters + 5 numerals
3341 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
3342 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
3345 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
3348 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
3351 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
3354 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
3357 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
3360 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
3363 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
3366 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
3369 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
3372 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
3375 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
3378 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
3381 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
3387 private static boolean testExternalNodeRelatedMethods() {
3389 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3390 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3391 PhylogenyNode n = t1.getNode( "A" );
3392 n = n.getNextExternalNode();
3393 if ( !n.getName().equals( "B" ) ) {
3396 n = n.getNextExternalNode();
3397 if ( !n.getName().equals( "C" ) ) {
3400 n = n.getNextExternalNode();
3401 if ( !n.getName().equals( "D" ) ) {
3404 n = t1.getNode( "B" );
3405 while ( !n.isLastExternalNode() ) {
3406 n = n.getNextExternalNode();
3408 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
3409 n = t2.getNode( "A" );
3410 n = n.getNextExternalNode();
3411 if ( !n.getName().equals( "B" ) ) {
3414 n = n.getNextExternalNode();
3415 if ( !n.getName().equals( "C" ) ) {
3418 n = n.getNextExternalNode();
3419 if ( !n.getName().equals( "D" ) ) {
3422 n = t2.getNode( "B" );
3423 while ( !n.isLastExternalNode() ) {
3424 n = n.getNextExternalNode();
3426 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3427 n = t3.getNode( "A" );
3428 n = n.getNextExternalNode();
3429 if ( !n.getName().equals( "B" ) ) {
3432 n = n.getNextExternalNode();
3433 if ( !n.getName().equals( "C" ) ) {
3436 n = n.getNextExternalNode();
3437 if ( !n.getName().equals( "D" ) ) {
3440 n = n.getNextExternalNode();
3441 if ( !n.getName().equals( "E" ) ) {
3444 n = n.getNextExternalNode();
3445 if ( !n.getName().equals( "F" ) ) {
3448 n = n.getNextExternalNode();
3449 if ( !n.getName().equals( "G" ) ) {
3452 n = n.getNextExternalNode();
3453 if ( !n.getName().equals( "H" ) ) {
3456 n = t3.getNode( "B" );
3457 while ( !n.isLastExternalNode() ) {
3458 n = n.getNextExternalNode();
3460 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3461 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
3462 final PhylogenyNode node = iter.next();
3464 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
3465 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
3466 final PhylogenyNode node = iter.next();
3468 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
3469 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
3470 if ( !iter.next().getName().equals( "A" ) ) {
3473 if ( !iter.next().getName().equals( "B" ) ) {
3476 if ( !iter.next().getName().equals( "C" ) ) {
3479 if ( !iter.next().getName().equals( "D" ) ) {
3482 if ( !iter.next().getName().equals( "E" ) ) {
3485 if ( !iter.next().getName().equals( "F" ) ) {
3488 if ( iter.hasNext() ) {
3492 catch ( final Exception e ) {
3493 e.printStackTrace( System.out );
3499 private static boolean testExtractSNFromNodeName() {
3501 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
3504 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus" )
3505 .equals( "Mus musculus musculus" ) ) {
3508 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus_musculus-12" )
3509 .equals( "Mus musculus musculus" ) ) {
3512 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus-12" ).equals( "Mus musculus" ) ) {
3515 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus-12 affrre e" )
3516 .equals( "Mus musculus" ) ) {
3520 catch ( final Exception e ) {
3521 e.printStackTrace( System.out );
3527 private static boolean testExtractTaxonomyCodeFromNodeName() {
3529 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3532 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3533 .equals( "SOYBN" ) ) {
3536 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3537 .equals( "ARATH" ) ) {
3540 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
3541 .equals( "ARATH" ) ) {
3544 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3547 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
3550 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3553 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3554 .equals( "SOYBN" ) ) {
3557 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3558 .equals( "SOYBN" ) ) {
3561 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3562 .equals( "SOYBN" ) ) {
3565 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3566 .equals( "SOYBN" ) ) {
3569 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3570 .equals( "SOYBN" ) ) {
3573 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
3574 .equals( "SOYBN" ) ) {
3577 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
3578 .equals( "SOYBN" ) ) {
3581 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
3582 .equals( "SOYBN" ) ) {
3585 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
3588 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
3589 .equals( "SOYBN" ) ) {
3592 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
3593 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
3596 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
3597 .equals( "9YX45" ) ) {
3600 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
3601 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3602 .equals( "MOUSE" ) ) {
3605 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
3606 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3607 .equals( "MOUSE" ) ) {
3610 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
3611 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3612 .equals( "MOUSE" ) ) {
3615 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
3616 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3619 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
3620 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3623 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3624 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3627 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
3628 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3631 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
3632 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
3635 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
3636 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3639 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
3640 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3643 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3644 .equals( "RAT" ) ) {
3647 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3648 .equals( "PIG" ) ) {
3652 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
3653 .equals( "MOUSE" ) ) {
3656 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
3657 .equals( "MOUSE" ) ) {
3660 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
3664 catch ( final Exception e ) {
3665 e.printStackTrace( System.out );
3671 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
3673 PhylogenyNode n = new PhylogenyNode();
3674 n.setName( "tr|B3RJ64" );
3675 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3678 n.setName( "tr.B3RJ64" );
3679 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3682 n.setName( "tr=B3RJ64" );
3683 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3686 n.setName( "tr-B3RJ64" );
3687 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3690 n.setName( "tr/B3RJ64" );
3691 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3694 n.setName( "tr\\B3RJ64" );
3695 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3698 n.setName( "tr_B3RJ64" );
3699 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3702 n.setName( " tr|B3RJ64 " );
3703 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3706 n.setName( "-tr|B3RJ64-" );
3707 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3710 n.setName( "-tr=B3RJ64-" );
3711 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3714 n.setName( "_tr=B3RJ64_" );
3715 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3718 n.setName( " tr_tr|B3RJ64_sp|123 " );
3719 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3722 n.setName( "B3RJ64" );
3723 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3726 n.setName( "sp|B3RJ64" );
3727 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3730 n.setName( "sp|B3RJ64C" );
3731 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3734 n.setName( "sp B3RJ64" );
3735 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3738 n.setName( "sp|B3RJ6X" );
3739 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3742 n.setName( "sp|B3RJ6" );
3743 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3746 n.setName( "K1PYK7_CRAGI" );
3747 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3750 n.setName( "K1PYK7_PEA" );
3751 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
3754 n.setName( "K1PYK7_RAT" );
3755 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
3758 n.setName( "K1PYK7_PIG" );
3759 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3762 n.setName( "~K1PYK7_PIG~" );
3763 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
3766 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
3767 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3770 n.setName( "K1PYKX_CRAGI" );
3771 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3774 n.setName( "XXXXX_CRAGI" );
3775 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
3778 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
3779 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
3782 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
3783 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
3786 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
3787 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
3790 n = new PhylogenyNode();
3791 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
3792 seq.setSymbol( "K1PYK7_CRAGI" );
3793 n.getNodeData().addSequence( seq );
3794 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3797 seq.setSymbol( "tr|B3RJ64" );
3798 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3801 n = new PhylogenyNode();
3802 seq = new org.forester.phylogeny.data.Sequence();
3803 seq.setName( "K1PYK7_CRAGI" );
3804 n.getNodeData().addSequence( seq );
3805 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
3808 seq.setName( "tr|B3RJ64" );
3809 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3812 n = new PhylogenyNode();
3813 seq = new org.forester.phylogeny.data.Sequence();
3814 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
3815 n.getNodeData().addSequence( seq );
3816 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
3819 n = new PhylogenyNode();
3820 seq = new org.forester.phylogeny.data.Sequence();
3821 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
3822 n.getNodeData().addSequence( seq );
3823 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
3827 n = new PhylogenyNode();
3828 n.setName( "ACP19736" );
3829 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3832 n = new PhylogenyNode();
3833 n.setName( "_ACP19736_" );
3834 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
3838 catch ( final Exception e ) {
3839 e.printStackTrace( System.out );
3845 private static boolean testFastaParser() {
3847 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
3850 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
3853 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
3854 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
3857 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
3860 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
3863 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
3866 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
3869 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
3873 catch ( final Exception e ) {
3874 e.printStackTrace();
3880 private static boolean testGeneralMsaParser() {
3882 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
3883 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
3884 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
3885 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
3886 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
3887 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
3888 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
3889 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
3890 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3893 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3896 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3899 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3902 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3905 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3908 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3911 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3914 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
3917 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
3920 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
3923 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
3926 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
3927 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3930 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3933 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3936 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
3937 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
3940 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
3943 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
3946 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
3947 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
3950 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
3953 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
3957 catch ( final Exception e ) {
3958 e.printStackTrace();
3964 private static boolean testGeneralTable() {
3966 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
3967 t0.setValue( 3, 2, "23" );
3968 t0.setValue( 10, 1, "error" );
3969 t0.setValue( 10, 1, "110" );
3970 t0.setValue( 9, 1, "19" );
3971 t0.setValue( 1, 10, "101" );
3972 t0.setValue( 10, 10, "1010" );
3973 t0.setValue( 100, 10, "10100" );
3974 t0.setValue( 0, 0, "00" );
3975 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3978 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3981 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3984 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3987 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3990 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3993 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3996 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
3999 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4002 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4003 t1.setValue( "3", "2", "23" );
4004 t1.setValue( "10", "1", "error" );
4005 t1.setValue( "10", "1", "110" );
4006 t1.setValue( "9", "1", "19" );
4007 t1.setValue( "1", "10", "101" );
4008 t1.setValue( "10", "10", "1010" );
4009 t1.setValue( "100", "10", "10100" );
4010 t1.setValue( "0", "0", "00" );
4011 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4012 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4015 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4018 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4021 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4024 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4027 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4030 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4033 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4036 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
4039 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
4043 catch ( final Exception e ) {
4044 e.printStackTrace( System.out );
4050 private static boolean testGetDistance() {
4052 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4053 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",
4054 new NHXParser() )[ 0 ];
4055 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
4058 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
4061 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
4064 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
4067 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
4070 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
4073 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
4076 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
4079 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
4082 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
4085 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
4088 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
4091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
4094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
4097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
4100 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
4103 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
4106 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
4109 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
4112 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
4115 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
4118 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
4121 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
4124 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
4127 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
4130 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
4133 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
4136 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
4139 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
4142 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
4145 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
4148 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",
4149 new NHXParser() )[ 0 ];
4150 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
4153 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
4156 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
4159 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
4162 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
4165 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
4168 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
4171 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
4174 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
4177 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
4180 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
4184 catch ( final Exception e ) {
4185 e.printStackTrace( System.out );
4191 private static boolean testGetLCA() {
4193 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4194 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4195 new NHXParser() )[ 0 ];
4196 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
4197 if ( !A.getName().equals( "A" ) ) {
4200 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
4201 if ( !gh.getName().equals( "gh" ) ) {
4204 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
4205 if ( !ab.getName().equals( "ab" ) ) {
4208 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
4209 if ( !ab2.getName().equals( "ab" ) ) {
4212 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
4213 if ( !gh2.getName().equals( "gh" ) ) {
4216 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
4217 if ( !gh3.getName().equals( "gh" ) ) {
4220 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
4221 if ( !abc.getName().equals( "abc" ) ) {
4224 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
4225 if ( !abc2.getName().equals( "abc" ) ) {
4228 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
4229 if ( !abcd.getName().equals( "abcd" ) ) {
4232 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
4233 if ( !abcd2.getName().equals( "abcd" ) ) {
4236 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
4237 if ( !abcdef.getName().equals( "abcdef" ) ) {
4240 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
4241 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4244 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
4245 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4248 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
4249 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4252 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
4253 if ( !abcde.getName().equals( "abcde" ) ) {
4256 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
4257 if ( !abcde2.getName().equals( "abcde" ) ) {
4260 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
4261 if ( !r.getName().equals( "abcdefgh" ) ) {
4264 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
4265 if ( !r2.getName().equals( "abcdefgh" ) ) {
4268 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
4269 if ( !r3.getName().equals( "abcdefgh" ) ) {
4272 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
4273 if ( !abcde3.getName().equals( "abcde" ) ) {
4276 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
4277 if ( !abcde4.getName().equals( "abcde" ) ) {
4280 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
4281 if ( !ab3.getName().equals( "ab" ) ) {
4284 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
4285 if ( !ab4.getName().equals( "ab" ) ) {
4288 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4289 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
4290 if ( !cd.getName().equals( "cd" ) ) {
4293 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
4294 if ( !cd2.getName().equals( "cd" ) ) {
4297 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
4298 if ( !cde.getName().equals( "cde" ) ) {
4301 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
4302 if ( !cde2.getName().equals( "cde" ) ) {
4305 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
4306 if ( !cdef.getName().equals( "cdef" ) ) {
4309 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
4310 if ( !cdef2.getName().equals( "cdef" ) ) {
4313 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
4314 if ( !cdef3.getName().equals( "cdef" ) ) {
4317 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
4318 if ( !rt.getName().equals( "r" ) ) {
4321 final Phylogeny p3 = factory
4322 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4323 new NHXParser() )[ 0 ];
4324 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
4325 if ( !bc_3.getName().equals( "bc" ) ) {
4328 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
4329 if ( !ac_3.getName().equals( "abc" ) ) {
4332 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
4333 if ( !ad_3.getName().equals( "abcde" ) ) {
4336 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
4337 if ( !af_3.getName().equals( "abcdef" ) ) {
4340 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
4341 if ( !ag_3.getName().equals( "" ) ) {
4344 if ( !ag_3.isRoot() ) {
4347 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
4348 if ( !al_3.getName().equals( "" ) ) {
4351 if ( !al_3.isRoot() ) {
4354 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
4355 if ( !kl_3.getName().equals( "" ) ) {
4358 if ( !kl_3.isRoot() ) {
4361 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
4362 if ( !fl_3.getName().equals( "" ) ) {
4365 if ( !fl_3.isRoot() ) {
4368 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
4369 if ( !gk_3.getName().equals( "ghijk" ) ) {
4372 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4373 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
4374 if ( !r_4.getName().equals( "r" ) ) {
4377 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4378 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
4379 if ( !r_5.getName().equals( "root" ) ) {
4382 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4383 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
4384 if ( !r_6.getName().equals( "rot" ) ) {
4387 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4388 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
4389 if ( !r_7.getName().equals( "rott" ) ) {
4393 catch ( final Exception e ) {
4394 e.printStackTrace( System.out );
4400 private static boolean testGetLCA2() {
4402 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4403 final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
4404 PhylogenyMethods.preOrderReId( p_a );
4405 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
4406 p_a.getNode( "a" ) );
4407 if ( !p_a_1.getName().equals( "a" ) ) {
4410 final Phylogeny p_b = factory.create( "((a)b)", new NHXParser() )[ 0 ];
4411 PhylogenyMethods.preOrderReId( p_b );
4412 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
4413 p_b.getNode( "a" ) );
4414 if ( !p_b_1.getName().equals( "b" ) ) {
4417 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
4418 p_b.getNode( "b" ) );
4419 if ( !p_b_2.getName().equals( "b" ) ) {
4422 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
4423 PhylogenyMethods.preOrderReId( p_c );
4424 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
4425 p_c.getNode( "a" ) );
4426 if ( !p_c_1.getName().equals( "b" ) ) {
4429 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4430 p_c.getNode( "c" ) );
4431 if ( !p_c_2.getName().equals( "c" ) ) {
4432 System.out.println( p_c_2.getName() );
4436 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
4437 p_c.getNode( "b" ) );
4438 if ( !p_c_3.getName().equals( "b" ) ) {
4441 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
4442 p_c.getNode( "a" ) );
4443 if ( !p_c_4.getName().equals( "c" ) ) {
4446 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
4447 new NHXParser() )[ 0 ];
4448 PhylogenyMethods.preOrderReId( p1 );
4449 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4450 p1.getNode( "A" ) );
4451 if ( !A.getName().equals( "A" ) ) {
4454 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
4455 p1.getNode( "gh" ) );
4456 if ( !gh.getName().equals( "gh" ) ) {
4459 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4460 p1.getNode( "B" ) );
4461 if ( !ab.getName().equals( "ab" ) ) {
4464 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4465 p1.getNode( "A" ) );
4466 if ( !ab2.getName().equals( "ab" ) ) {
4469 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4470 p1.getNode( "G" ) );
4471 if ( !gh2.getName().equals( "gh" ) ) {
4474 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
4475 p1.getNode( "H" ) );
4476 if ( !gh3.getName().equals( "gh" ) ) {
4479 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
4480 p1.getNode( "A" ) );
4481 if ( !abc.getName().equals( "abc" ) ) {
4484 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4485 p1.getNode( "C" ) );
4486 if ( !abc2.getName().equals( "abc" ) ) {
4489 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4490 p1.getNode( "D" ) );
4491 if ( !abcd.getName().equals( "abcd" ) ) {
4494 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
4495 p1.getNode( "A" ) );
4496 if ( !abcd2.getName().equals( "abcd" ) ) {
4499 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4500 p1.getNode( "F" ) );
4501 if ( !abcdef.getName().equals( "abcdef" ) ) {
4504 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4505 p1.getNode( "A" ) );
4506 if ( !abcdef2.getName().equals( "abcdef" ) ) {
4509 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4510 p1.getNode( "F" ) );
4511 if ( !abcdef3.getName().equals( "abcdef" ) ) {
4514 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
4515 p1.getNode( "ab" ) );
4516 if ( !abcdef4.getName().equals( "abcdef" ) ) {
4519 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4520 p1.getNode( "E" ) );
4521 if ( !abcde.getName().equals( "abcde" ) ) {
4524 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4525 p1.getNode( "A" ) );
4526 if ( !abcde2.getName().equals( "abcde" ) ) {
4529 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
4530 p1.getNode( "abcdefgh" ) );
4531 if ( !r.getName().equals( "abcdefgh" ) ) {
4534 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
4535 p1.getNode( "H" ) );
4536 if ( !r2.getName().equals( "abcdefgh" ) ) {
4539 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
4540 p1.getNode( "A" ) );
4541 if ( !r3.getName().equals( "abcdefgh" ) ) {
4544 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
4545 p1.getNode( "abcde" ) );
4546 if ( !abcde3.getName().equals( "abcde" ) ) {
4549 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
4550 p1.getNode( "E" ) );
4551 if ( !abcde4.getName().equals( "abcde" ) ) {
4554 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
4555 p1.getNode( "B" ) );
4556 if ( !ab3.getName().equals( "ab" ) ) {
4559 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
4560 p1.getNode( "ab" ) );
4561 if ( !ab4.getName().equals( "ab" ) ) {
4564 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
4565 PhylogenyMethods.preOrderReId( p2 );
4566 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4567 p2.getNode( "d" ) );
4568 if ( !cd.getName().equals( "cd" ) ) {
4571 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4572 p2.getNode( "c" ) );
4573 if ( !cd2.getName().equals( "cd" ) ) {
4576 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4577 p2.getNode( "e" ) );
4578 if ( !cde.getName().equals( "cde" ) ) {
4581 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
4582 p2.getNode( "c" ) );
4583 if ( !cde2.getName().equals( "cde" ) ) {
4586 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4587 p2.getNode( "f" ) );
4588 if ( !cdef.getName().equals( "cdef" ) ) {
4591 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
4592 p2.getNode( "f" ) );
4593 if ( !cdef2.getName().equals( "cdef" ) ) {
4596 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
4597 p2.getNode( "d" ) );
4598 if ( !cdef3.getName().equals( "cdef" ) ) {
4601 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
4602 p2.getNode( "a" ) );
4603 if ( !rt.getName().equals( "r" ) ) {
4606 final Phylogeny p3 = factory
4607 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
4608 new NHXParser() )[ 0 ];
4609 PhylogenyMethods.preOrderReId( p3 );
4610 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
4611 p3.getNode( "c" ) );
4612 if ( !bc_3.getName().equals( "bc" ) ) {
4615 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4616 p3.getNode( "c" ) );
4617 if ( !ac_3.getName().equals( "abc" ) ) {
4620 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4621 p3.getNode( "d" ) );
4622 if ( !ad_3.getName().equals( "abcde" ) ) {
4625 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4626 p3.getNode( "f" ) );
4627 if ( !af_3.getName().equals( "abcdef" ) ) {
4630 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4631 p3.getNode( "g" ) );
4632 if ( !ag_3.getName().equals( "" ) ) {
4635 if ( !ag_3.isRoot() ) {
4638 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
4639 p3.getNode( "l" ) );
4640 if ( !al_3.getName().equals( "" ) ) {
4643 if ( !al_3.isRoot() ) {
4646 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
4647 p3.getNode( "l" ) );
4648 if ( !kl_3.getName().equals( "" ) ) {
4651 if ( !kl_3.isRoot() ) {
4654 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
4655 p3.getNode( "l" ) );
4656 if ( !fl_3.getName().equals( "" ) ) {
4659 if ( !fl_3.isRoot() ) {
4662 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
4663 p3.getNode( "k" ) );
4664 if ( !gk_3.getName().equals( "ghijk" ) ) {
4667 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
4668 PhylogenyMethods.preOrderReId( p4 );
4669 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
4670 p4.getNode( "c" ) );
4671 if ( !r_4.getName().equals( "r" ) ) {
4674 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
4675 PhylogenyMethods.preOrderReId( p5 );
4676 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
4677 p5.getNode( "c" ) );
4678 if ( !r_5.getName().equals( "root" ) ) {
4681 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
4682 PhylogenyMethods.preOrderReId( p6 );
4683 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
4684 p6.getNode( "a" ) );
4685 if ( !r_6.getName().equals( "rot" ) ) {
4688 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
4689 PhylogenyMethods.preOrderReId( p7 );
4690 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
4691 p7.getNode( "e" ) );
4692 if ( !r_7.getName().equals( "rott" ) ) {
4695 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4696 p7.getNode( "a" ) );
4697 if ( !r_71.getName().equals( "rott" ) ) {
4700 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4701 p7.getNode( "rott" ) );
4702 if ( !r_72.getName().equals( "rott" ) ) {
4705 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4706 p7.getNode( "a" ) );
4707 if ( !r_73.getName().equals( "rott" ) ) {
4710 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
4711 p7.getNode( "rott" ) );
4712 if ( !r_74.getName().equals( "rott" ) ) {
4715 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
4716 p7.getNode( "e" ) );
4717 if ( !r_75.getName().equals( "e" ) ) {
4721 catch ( final Exception e ) {
4722 e.printStackTrace( System.out );
4728 private static boolean testHmmscanOutputParser() {
4729 final String test_dir = Test.PATH_TO_TEST_DATA;
4731 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
4732 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4734 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
4735 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
4736 final List<Protein> proteins = parser2.parse();
4737 if ( parser2.getProteinsEncountered() != 4 ) {
4740 if ( proteins.size() != 4 ) {
4743 if ( parser2.getDomainsEncountered() != 69 ) {
4746 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
4749 if ( parser2.getDomainsIgnoredDueToEval() != 0 ) {
4752 final Protein p1 = proteins.get( 0 );
4753 if ( p1.getNumberOfProteinDomains() != 15 ) {
4756 if ( p1.getLength() != 850 ) {
4759 final Protein p2 = proteins.get( 1 );
4760 if ( p2.getNumberOfProteinDomains() != 51 ) {
4763 if ( p2.getLength() != 1291 ) {
4766 final Protein p3 = proteins.get( 2 );
4767 if ( p3.getNumberOfProteinDomains() != 2 ) {
4770 final Protein p4 = proteins.get( 3 );
4771 if ( p4.getNumberOfProteinDomains() != 1 ) {
4774 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
4777 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
4780 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
4783 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
4786 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
4789 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceEvalue(), 8.3e-40 ) ) {
4792 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerSequenceScore(), 136.3 ) ) {
4795 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
4798 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
4802 catch ( final Exception e ) {
4803 e.printStackTrace( System.out );
4809 private static boolean testLastExternalNodeMethods() {
4811 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4812 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
4813 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
4814 final PhylogenyNode n1 = t0.getNode( "A" );
4815 if ( n1.isLastExternalNode() ) {
4818 final PhylogenyNode n2 = t0.getNode( "B" );
4819 if ( n2.isLastExternalNode() ) {
4822 final PhylogenyNode n3 = t0.getNode( "C" );
4823 if ( n3.isLastExternalNode() ) {
4826 final PhylogenyNode n4 = t0.getNode( "D" );
4827 if ( !n4.isLastExternalNode() ) {
4831 catch ( final Exception e ) {
4832 e.printStackTrace( System.out );
4838 private static boolean testLevelOrderIterator() {
4840 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4841 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
4842 PhylogenyNodeIterator it0;
4843 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
4846 for( it0.reset(); it0.hasNext(); ) {
4849 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
4850 if ( !it.next().getName().equals( "r" ) ) {
4853 if ( !it.next().getName().equals( "ab" ) ) {
4856 if ( !it.next().getName().equals( "cd" ) ) {
4859 if ( !it.next().getName().equals( "A" ) ) {
4862 if ( !it.next().getName().equals( "B" ) ) {
4865 if ( !it.next().getName().equals( "C" ) ) {
4868 if ( !it.next().getName().equals( "D" ) ) {
4871 if ( it.hasNext() ) {
4874 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",
4875 new NHXParser() )[ 0 ];
4876 PhylogenyNodeIterator it2;
4877 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
4880 for( it2.reset(); it2.hasNext(); ) {
4883 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
4884 if ( !it3.next().getName().equals( "r" ) ) {
4887 if ( !it3.next().getName().equals( "abc" ) ) {
4890 if ( !it3.next().getName().equals( "defg" ) ) {
4893 if ( !it3.next().getName().equals( "A" ) ) {
4896 if ( !it3.next().getName().equals( "B" ) ) {
4899 if ( !it3.next().getName().equals( "C" ) ) {
4902 if ( !it3.next().getName().equals( "D" ) ) {
4905 if ( !it3.next().getName().equals( "E" ) ) {
4908 if ( !it3.next().getName().equals( "F" ) ) {
4911 if ( !it3.next().getName().equals( "G" ) ) {
4914 if ( !it3.next().getName().equals( "1" ) ) {
4917 if ( !it3.next().getName().equals( "2" ) ) {
4920 if ( !it3.next().getName().equals( "3" ) ) {
4923 if ( !it3.next().getName().equals( "4" ) ) {
4926 if ( !it3.next().getName().equals( "5" ) ) {
4929 if ( !it3.next().getName().equals( "6" ) ) {
4932 if ( !it3.next().getName().equals( "f1" ) ) {
4935 if ( !it3.next().getName().equals( "f2" ) ) {
4938 if ( !it3.next().getName().equals( "f3" ) ) {
4941 if ( !it3.next().getName().equals( "a" ) ) {
4944 if ( !it3.next().getName().equals( "b" ) ) {
4947 if ( !it3.next().getName().equals( "f21" ) ) {
4950 if ( !it3.next().getName().equals( "X" ) ) {
4953 if ( !it3.next().getName().equals( "Y" ) ) {
4956 if ( !it3.next().getName().equals( "Z" ) ) {
4959 if ( it3.hasNext() ) {
4962 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
4963 PhylogenyNodeIterator it4;
4964 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
4967 for( it4.reset(); it4.hasNext(); ) {
4970 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
4971 if ( !it5.next().getName().equals( "r" ) ) {
4974 if ( !it5.next().getName().equals( "A" ) ) {
4977 if ( !it5.next().getName().equals( "B" ) ) {
4980 if ( !it5.next().getName().equals( "C" ) ) {
4983 if ( !it5.next().getName().equals( "D" ) ) {
4986 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
4987 PhylogenyNodeIterator it6;
4988 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
4991 for( it6.reset(); it6.hasNext(); ) {
4994 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
4995 if ( !it7.next().getName().equals( "A" ) ) {
4998 if ( it.hasNext() ) {
5002 catch ( final Exception e ) {
5003 e.printStackTrace( System.out );
5009 private static boolean testMafft( final String path ) {
5011 final List<String> opts = new ArrayList<String>();
5012 opts.add( "--maxiterate" );
5014 opts.add( "--localpair" );
5015 opts.add( "--quiet" );
5017 final MsaInferrer mafft = Mafft.createInstance( path );
5018 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5019 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5022 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5026 catch ( final Exception e ) {
5027 e.printStackTrace( System.out );
5033 private static boolean testMidpointrooting() {
5035 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5036 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5037 PhylogenyMethods.midpointRoot( t0 );
5038 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
5041 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
5044 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
5048 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",
5049 new NHXParser() )[ 0 ];
5050 if ( !t1.isRooted() ) {
5053 PhylogenyMethods.midpointRoot( t1 );
5054 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5057 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5060 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5063 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5066 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5069 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5072 t1.reRoot( t1.getNode( "A" ) );
5073 PhylogenyMethods.midpointRoot( t1 );
5074 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
5077 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
5080 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
5083 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
5086 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
5090 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
5094 catch ( final Exception e ) {
5095 e.printStackTrace( System.out );
5101 private static boolean testMsaQualityMethod() {
5103 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJ" );
5104 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJ" );
5105 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJ" );
5106 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ" );
5107 final List<Sequence> l = new ArrayList<Sequence>();
5112 final Msa msa = BasicMsa.createInstance( l );
5113 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
5116 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
5119 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
5122 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
5126 catch ( final Exception e ) {
5127 e.printStackTrace( System.out );
5133 private static boolean testNextNodeWithCollapsing() {
5135 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5137 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
5138 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5139 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
5140 t0.getNode( "cd" ).setCollapse( true );
5141 t0.getNode( "cde" ).setCollapse( true );
5142 n = t0.getFirstExternalNode();
5143 while ( n != null ) {
5145 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5147 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5150 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5153 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
5156 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
5159 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
5162 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
5166 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5167 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
5168 t1.getNode( "ab" ).setCollapse( true );
5169 t1.getNode( "cd" ).setCollapse( true );
5170 t1.getNode( "cde" ).setCollapse( true );
5171 n = t1.getNode( "ab" );
5172 ext = new ArrayList<PhylogenyNode>();
5173 while ( n != null ) {
5175 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5177 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5180 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5183 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5186 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
5189 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
5195 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5196 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
5197 t2.getNode( "ab" ).setCollapse( true );
5198 t2.getNode( "cd" ).setCollapse( true );
5199 t2.getNode( "cde" ).setCollapse( true );
5200 t2.getNode( "c" ).setCollapse( true );
5201 t2.getNode( "d" ).setCollapse( true );
5202 t2.getNode( "e" ).setCollapse( true );
5203 t2.getNode( "gh" ).setCollapse( true );
5204 n = t2.getNode( "ab" );
5205 ext = new ArrayList<PhylogenyNode>();
5206 while ( n != null ) {
5208 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5210 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5213 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5216 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
5219 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
5225 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5226 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
5227 t3.getNode( "ab" ).setCollapse( true );
5228 t3.getNode( "cd" ).setCollapse( true );
5229 t3.getNode( "cde" ).setCollapse( true );
5230 t3.getNode( "c" ).setCollapse( true );
5231 t3.getNode( "d" ).setCollapse( true );
5232 t3.getNode( "e" ).setCollapse( true );
5233 t3.getNode( "gh" ).setCollapse( true );
5234 t3.getNode( "fgh" ).setCollapse( true );
5235 n = t3.getNode( "ab" );
5236 ext = new ArrayList<PhylogenyNode>();
5237 while ( n != null ) {
5239 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5241 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5244 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5247 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
5253 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5254 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
5255 t4.getNode( "ab" ).setCollapse( true );
5256 t4.getNode( "cd" ).setCollapse( true );
5257 t4.getNode( "cde" ).setCollapse( true );
5258 t4.getNode( "c" ).setCollapse( true );
5259 t4.getNode( "d" ).setCollapse( true );
5260 t4.getNode( "e" ).setCollapse( true );
5261 t4.getNode( "gh" ).setCollapse( true );
5262 t4.getNode( "fgh" ).setCollapse( true );
5263 t4.getNode( "abcdefgh" ).setCollapse( true );
5264 n = t4.getNode( "abcdefgh" );
5265 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
5270 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5271 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
5273 n = t5.getFirstExternalNode();
5274 while ( n != null ) {
5276 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5278 if ( ext.size() != 8 ) {
5281 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5284 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5287 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5290 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5293 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5296 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5299 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
5302 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
5307 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5308 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
5310 t6.getNode( "ab" ).setCollapse( true );
5311 n = t6.getNode( "ab" );
5312 while ( n != null ) {
5314 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5316 if ( ext.size() != 7 ) {
5319 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5322 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5325 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5328 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5331 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5334 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5337 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5342 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5343 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
5345 t7.getNode( "cd" ).setCollapse( true );
5346 n = t7.getNode( "a" );
5347 while ( n != null ) {
5349 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5351 if ( ext.size() != 7 ) {
5354 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5357 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5360 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5363 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5366 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5369 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5372 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5377 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
5378 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
5380 t8.getNode( "cd" ).setCollapse( true );
5381 t8.getNode( "c" ).setCollapse( true );
5382 t8.getNode( "d" ).setCollapse( true );
5383 n = t8.getNode( "a" );
5384 while ( n != null ) {
5386 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5388 if ( ext.size() != 7 ) {
5391 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5394 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5397 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
5398 System.out.println( "2 fail" );
5401 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5404 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
5407 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
5410 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
5415 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5416 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
5418 t9.getNode( "gh" ).setCollapse( true );
5419 n = t9.getNode( "a" );
5420 while ( n != null ) {
5422 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5424 if ( ext.size() != 7 ) {
5427 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5430 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5433 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5436 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5439 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5442 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5445 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5450 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5451 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
5453 t10.getNode( "gh" ).setCollapse( true );
5454 t10.getNode( "g" ).setCollapse( true );
5455 t10.getNode( "h" ).setCollapse( true );
5456 n = t10.getNode( "a" );
5457 while ( n != null ) {
5459 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5461 if ( ext.size() != 7 ) {
5464 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5467 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5470 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5473 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5476 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5479 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
5482 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
5487 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5488 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
5490 t11.getNode( "gh" ).setCollapse( true );
5491 t11.getNode( "fgh" ).setCollapse( true );
5492 n = t11.getNode( "a" );
5493 while ( n != null ) {
5495 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5497 if ( ext.size() != 6 ) {
5500 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5503 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5506 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5509 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5512 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5515 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5520 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5521 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
5523 t12.getNode( "gh" ).setCollapse( true );
5524 t12.getNode( "fgh" ).setCollapse( true );
5525 t12.getNode( "g" ).setCollapse( true );
5526 t12.getNode( "h" ).setCollapse( true );
5527 t12.getNode( "f" ).setCollapse( true );
5528 n = t12.getNode( "a" );
5529 while ( n != null ) {
5531 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5533 if ( ext.size() != 6 ) {
5536 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
5539 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
5542 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
5545 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
5548 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
5551 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5556 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
5557 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
5559 t13.getNode( "ab" ).setCollapse( true );
5560 t13.getNode( "b" ).setCollapse( true );
5561 t13.getNode( "fgh" ).setCollapse( true );
5562 t13.getNode( "gh" ).setCollapse( true );
5563 n = t13.getNode( "ab" );
5564 while ( n != null ) {
5566 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5568 if ( ext.size() != 5 ) {
5571 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5574 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5577 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5580 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5583 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5588 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
5589 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
5591 t14.getNode( "ab" ).setCollapse( true );
5592 t14.getNode( "a" ).setCollapse( true );
5593 t14.getNode( "fgh" ).setCollapse( true );
5594 t14.getNode( "gh" ).setCollapse( true );
5595 n = t14.getNode( "ab" );
5596 while ( n != null ) {
5598 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5600 if ( ext.size() != 5 ) {
5603 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5606 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5609 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5612 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5615 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
5620 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" );
5621 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
5623 t15.getNode( "ab" ).setCollapse( true );
5624 t15.getNode( "a" ).setCollapse( true );
5625 t15.getNode( "fgh" ).setCollapse( true );
5626 t15.getNode( "gh" ).setCollapse( true );
5627 n = t15.getNode( "ab" );
5628 while ( n != null ) {
5630 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5632 if ( ext.size() != 6 ) {
5635 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5638 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
5641 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
5644 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
5647 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
5650 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
5655 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" );
5656 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
5658 t16.getNode( "ab" ).setCollapse( true );
5659 t16.getNode( "a" ).setCollapse( true );
5660 t16.getNode( "fgh" ).setCollapse( true );
5661 t16.getNode( "gh" ).setCollapse( true );
5662 t16.getNode( "cd" ).setCollapse( true );
5663 t16.getNode( "cde" ).setCollapse( true );
5664 t16.getNode( "d" ).setCollapse( true );
5665 t16.getNode( "x" ).setCollapse( true );
5666 n = t16.getNode( "ab" );
5667 while ( n != null ) {
5669 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
5671 if ( ext.size() != 4 ) {
5674 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
5677 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
5680 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
5683 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
5687 catch ( final Exception e ) {
5688 e.printStackTrace( System.out );
5694 private static boolean testNexusCharactersParsing() {
5696 final NexusCharactersParser parser = new NexusCharactersParser();
5697 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
5699 String[] labels = parser.getCharStateLabels();
5700 if ( labels.length != 7 ) {
5703 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5706 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5709 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5712 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5715 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5718 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5721 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5724 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5726 labels = parser.getCharStateLabels();
5727 if ( labels.length != 7 ) {
5730 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5733 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5736 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5739 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5742 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5745 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5748 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5752 catch ( final Exception e ) {
5753 e.printStackTrace( System.out );
5759 private static boolean testNexusMatrixParsing() {
5761 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
5762 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
5764 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
5765 if ( m.getNumberOfCharacters() != 9 ) {
5768 if ( m.getNumberOfIdentifiers() != 5 ) {
5771 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
5774 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
5777 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
5780 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
5783 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
5786 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5789 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
5792 // if ( labels.length != 7 ) {
5795 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5798 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5801 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5804 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5807 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5810 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5813 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5816 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
5818 // labels = parser.getCharStateLabels();
5819 // if ( labels.length != 7 ) {
5822 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
5825 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
5828 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
5831 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
5834 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
5837 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
5840 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
5844 catch ( final Exception e ) {
5845 e.printStackTrace( System.out );
5851 private static boolean testNexusTreeParsing() {
5853 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5854 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
5855 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
5856 if ( phylogenies.length != 1 ) {
5859 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
5862 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5866 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
5867 if ( phylogenies.length != 1 ) {
5870 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5873 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
5877 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
5878 if ( phylogenies.length != 1 ) {
5881 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
5884 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
5887 if ( phylogenies[ 0 ].isRooted() ) {
5891 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
5892 if ( phylogenies.length != 18 ) {
5895 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
5898 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
5901 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
5904 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
5907 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
5910 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
5913 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
5916 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
5919 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
5922 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
5925 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
5928 if ( phylogenies[ 8 ].isRooted() ) {
5931 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
5934 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
5937 if ( !phylogenies[ 9 ].isRooted() ) {
5940 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
5943 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
5946 if ( !phylogenies[ 10 ].isRooted() ) {
5949 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
5952 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
5955 if ( phylogenies[ 11 ].isRooted() ) {
5958 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
5961 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
5964 if ( !phylogenies[ 12 ].isRooted() ) {
5967 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
5970 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
5973 if ( !phylogenies[ 13 ].isRooted() ) {
5976 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
5979 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
5982 if ( !phylogenies[ 14 ].isRooted() ) {
5985 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
5988 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
5991 if ( phylogenies[ 15 ].isRooted() ) {
5994 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
5997 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
6000 if ( !phylogenies[ 16 ].isRooted() ) {
6003 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
6006 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
6009 if ( phylogenies[ 17 ].isRooted() ) {
6012 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
6016 catch ( final Exception e ) {
6017 e.printStackTrace( System.out );
6023 private static boolean testNexusTreeParsingIterating() {
6025 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
6026 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
6027 if ( !p.hasNext() ) {
6030 Phylogeny phy = p.next();
6031 if ( phy == null ) {
6034 if ( phy.getNumberOfExternalNodes() != 25 ) {
6037 if ( !phy.getName().equals( "" ) ) {
6040 if ( p.hasNext() ) {
6044 if ( phy != null ) {
6049 if ( !p.hasNext() ) {
6053 if ( phy == null ) {
6056 if ( phy.getNumberOfExternalNodes() != 25 ) {
6059 if ( !phy.getName().equals( "" ) ) {
6062 if ( p.hasNext() ) {
6066 if ( phy != null ) {
6070 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
6071 if ( !p.hasNext() ) {
6075 if ( phy == null ) {
6078 if ( phy.getNumberOfExternalNodes() != 10 ) {
6081 if ( !phy.getName().equals( "name" ) ) {
6084 if ( p.hasNext() ) {
6088 if ( phy != null ) {
6093 if ( !p.hasNext() ) {
6097 if ( phy == null ) {
6100 if ( phy.getNumberOfExternalNodes() != 10 ) {
6103 if ( !phy.getName().equals( "name" ) ) {
6106 if ( p.hasNext() ) {
6110 if ( phy != null ) {
6114 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
6115 if ( !p.hasNext() ) {
6119 if ( phy == null ) {
6122 if ( phy.getNumberOfExternalNodes() != 3 ) {
6125 if ( !phy.getName().equals( "" ) ) {
6128 if ( phy.isRooted() ) {
6131 if ( p.hasNext() ) {
6135 if ( phy != null ) {
6140 if ( !p.hasNext() ) {
6144 if ( phy == null ) {
6147 if ( phy.getNumberOfExternalNodes() != 3 ) {
6150 if ( !phy.getName().equals( "" ) ) {
6153 if ( p.hasNext() ) {
6157 if ( phy != null ) {
6161 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
6162 // if ( phylogenies.length != 18 ) {
6166 if ( !p.hasNext() ) {
6170 if ( phy == null ) {
6173 if ( phy.getNumberOfExternalNodes() != 10 ) {
6176 if ( !phy.getName().equals( "tree 0" ) ) {
6180 if ( !p.hasNext() ) {
6184 if ( phy == null ) {
6187 if ( phy.getNumberOfExternalNodes() != 10 ) {
6190 if ( !phy.getName().equals( "tree 1" ) ) {
6194 if ( !p.hasNext() ) {
6198 if ( phy == null ) {
6201 if ( phy.getNumberOfExternalNodes() != 3 ) {
6204 if ( !phy.getName().equals( "" ) ) {
6207 if ( phy.isRooted() ) {
6211 if ( !p.hasNext() ) {
6215 if ( phy == null ) {
6218 if ( phy.getNumberOfExternalNodes() != 4 ) {
6221 if ( !phy.getName().equals( "" ) ) {
6224 if ( !phy.isRooted() ) {
6228 if ( !p.hasNext() ) {
6232 if ( phy == null ) {
6235 if ( phy.getNumberOfExternalNodes() != 5 ) {
6236 System.out.println( phy.getNumberOfExternalNodes() );
6239 if ( !phy.getName().equals( "" ) ) {
6242 if ( !phy.isRooted() ) {
6246 if ( !p.hasNext() ) {
6250 if ( phy == null ) {
6253 if ( phy.getNumberOfExternalNodes() != 3 ) {
6256 if ( !phy.getName().equals( "" ) ) {
6259 if ( phy.isRooted() ) {
6263 if ( !p.hasNext() ) {
6267 if ( phy == null ) {
6270 if ( phy.getNumberOfExternalNodes() != 2 ) {
6273 if ( !phy.getName().equals( "" ) ) {
6276 if ( !phy.isRooted() ) {
6280 if ( !p.hasNext() ) {
6284 if ( phy.getNumberOfExternalNodes() != 3 ) {
6287 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6290 if ( !phy.isRooted() ) {
6294 if ( !p.hasNext() ) {
6298 if ( phy.getNumberOfExternalNodes() != 3 ) {
6301 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
6304 if ( !phy.getName().equals( "tree 8" ) ) {
6308 if ( !p.hasNext() ) {
6312 if ( phy.getNumberOfExternalNodes() != 3 ) {
6315 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
6318 if ( !phy.getName().equals( "tree 9" ) ) {
6322 if ( !p.hasNext() ) {
6326 if ( phy.getNumberOfExternalNodes() != 3 ) {
6329 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6332 if ( !phy.getName().equals( "tree 10" ) ) {
6335 if ( !phy.isRooted() ) {
6339 if ( !p.hasNext() ) {
6343 if ( phy.getNumberOfExternalNodes() != 3 ) {
6346 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
6349 if ( !phy.getName().equals( "tree 11" ) ) {
6352 if ( phy.isRooted() ) {
6356 if ( !p.hasNext() ) {
6360 if ( phy.getNumberOfExternalNodes() != 3 ) {
6363 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
6366 if ( !phy.getName().equals( "tree 12" ) ) {
6369 if ( !phy.isRooted() ) {
6373 if ( !p.hasNext() ) {
6377 if ( phy.getNumberOfExternalNodes() != 3 ) {
6380 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
6383 if ( !phy.getName().equals( "tree 13" ) ) {
6386 if ( !phy.isRooted() ) {
6390 if ( !p.hasNext() ) {
6394 if ( phy.getNumberOfExternalNodes() != 10 ) {
6395 System.out.println( phy.getNumberOfExternalNodes() );
6400 .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;" ) ) {
6401 System.out.println( phy.toNewHampshire() );
6404 if ( !phy.getName().equals( "tree 14" ) ) {
6407 if ( !phy.isRooted() ) {
6411 if ( !p.hasNext() ) {
6415 if ( phy.getNumberOfExternalNodes() != 10 ) {
6416 System.out.println( phy.getNumberOfExternalNodes() );
6421 .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;" ) ) {
6422 System.out.println( phy.toNewHampshire() );
6425 if ( !phy.getName().equals( "tree 15" ) ) {
6428 if ( phy.isRooted() ) {
6432 if ( !p.hasNext() ) {
6436 if ( phy.getNumberOfExternalNodes() != 10 ) {
6437 System.out.println( phy.getNumberOfExternalNodes() );
6442 .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;" ) ) {
6443 System.out.println( phy.toNewHampshire() );
6446 if ( !phy.getName().equals( "tree 16" ) ) {
6449 if ( !phy.isRooted() ) {
6453 if ( !p.hasNext() ) {
6457 if ( phy.getNumberOfExternalNodes() != 10 ) {
6458 System.out.println( phy.getNumberOfExternalNodes() );
6463 .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;" ) ) {
6464 System.out.println( phy.toNewHampshire() );
6467 if ( !phy.getName().equals( "tree 17" ) ) {
6470 if ( phy.isRooted() ) {
6474 if ( p.hasNext() ) {
6478 if ( phy != null ) {
6483 if ( !p.hasNext() ) {
6487 if ( phy == null ) {
6490 if ( phy.getNumberOfExternalNodes() != 10 ) {
6493 if ( !phy.getName().equals( "tree 0" ) ) {
6497 if ( !p.hasNext() ) {
6501 if ( phy == null ) {
6504 if ( phy.getNumberOfExternalNodes() != 10 ) {
6507 if ( !phy.getName().equals( "tree 1" ) ) {
6511 if ( !p.hasNext() ) {
6515 if ( phy == null ) {
6518 if ( phy.getNumberOfExternalNodes() != 3 ) {
6521 if ( !phy.getName().equals( "" ) ) {
6524 if ( phy.isRooted() ) {
6528 if ( !p.hasNext() ) {
6532 if ( phy == null ) {
6535 if ( phy.getNumberOfExternalNodes() != 4 ) {
6538 if ( !phy.getName().equals( "" ) ) {
6541 if ( !phy.isRooted() ) {
6545 if ( !p.hasNext() ) {
6549 if ( phy == null ) {
6552 if ( phy.getNumberOfExternalNodes() != 5 ) {
6553 System.out.println( phy.getNumberOfExternalNodes() );
6556 if ( !phy.getName().equals( "" ) ) {
6559 if ( !phy.isRooted() ) {
6563 if ( !p.hasNext() ) {
6567 if ( phy == null ) {
6570 if ( phy.getNumberOfExternalNodes() != 3 ) {
6573 if ( !phy.getName().equals( "" ) ) {
6576 if ( phy.isRooted() ) {
6580 catch ( final Exception e ) {
6581 e.printStackTrace( System.out );
6587 private static boolean testNexusTreeParsingTranslating() {
6589 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6590 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
6591 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
6592 if ( phylogenies.length != 1 ) {
6595 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6598 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6601 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6604 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6607 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6608 .equals( "Aranaeus" ) ) {
6612 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
6613 if ( phylogenies.length != 3 ) {
6616 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6619 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6622 if ( phylogenies[ 0 ].isRooted() ) {
6625 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6628 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6631 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6632 .equals( "Aranaeus" ) ) {
6635 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6638 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6641 if ( phylogenies[ 1 ].isRooted() ) {
6644 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6647 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6650 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6651 .equals( "Aranaeus" ) ) {
6654 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6657 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6660 if ( !phylogenies[ 2 ].isRooted() ) {
6663 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6666 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6669 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6670 .equals( "Aranaeus" ) ) {
6674 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
6675 if ( phylogenies.length != 3 ) {
6678 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
6681 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
6684 if ( phylogenies[ 0 ].isRooted() ) {
6687 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6690 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6693 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6694 .equals( "Aranaeus" ) ) {
6697 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
6700 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
6703 if ( phylogenies[ 1 ].isRooted() ) {
6706 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6709 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6712 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6713 .equals( "Aranaeus" ) ) {
6716 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
6719 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
6722 if ( !phylogenies[ 2 ].isRooted() ) {
6725 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
6728 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
6731 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
6732 .equals( "Aranaeus" ) ) {
6736 catch ( final Exception e ) {
6737 e.printStackTrace( System.out );
6743 private static boolean testNHParsing() {
6745 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6746 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
6747 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
6750 final NHXParser nhxp = new NHXParser();
6751 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
6752 nhxp.setReplaceUnderscores( true );
6753 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
6754 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A " ) ) {
6757 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( " B B" ) ) {
6760 final Phylogeny p1b = factory
6761 .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 ",
6762 new NHXParser() )[ 0 ];
6763 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
6766 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
6769 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
6770 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
6771 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
6772 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
6773 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
6774 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
6775 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
6776 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
6777 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
6778 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
6779 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
6780 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
6781 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
6783 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
6786 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
6789 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
6792 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
6795 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
6796 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
6797 final String p16_S = "((A,B),C)";
6798 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
6799 if ( p16.length != 1 ) {
6802 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
6805 final String p17_S = "(C,(A,B))";
6806 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
6807 if ( p17.length != 1 ) {
6810 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
6813 final String p18_S = "((A,B),(C,D))";
6814 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
6815 if ( p18.length != 1 ) {
6818 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
6821 final String p19_S = "(((A,B),C),D)";
6822 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
6823 if ( p19.length != 1 ) {
6826 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
6829 final String p20_S = "(A,(B,(C,D)))";
6830 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
6831 if ( p20.length != 1 ) {
6834 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
6837 final String p21_S = "(A,(B,(C,(D,E))))";
6838 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
6839 if ( p21.length != 1 ) {
6842 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
6845 final String p22_S = "((((A,B),C),D),E)";
6846 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
6847 if ( p22.length != 1 ) {
6850 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
6853 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6854 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
6855 if ( p23.length != 1 ) {
6856 System.out.println( "xl=" + p23.length );
6860 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
6863 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6864 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
6865 if ( p24.length != 1 ) {
6868 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
6871 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6872 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6873 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
6874 if ( p241.length != 2 ) {
6877 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
6880 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
6883 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
6884 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
6885 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
6886 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
6887 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
6888 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
6889 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
6890 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
6891 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
6892 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
6895 final String p26_S = "(A,B)ab";
6896 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
6897 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
6900 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6901 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
6902 if ( p27s.length != 1 ) {
6903 System.out.println( "xxl=" + p27s.length );
6907 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6908 System.out.println( p27s[ 0 ].toNewHampshireX() );
6912 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
6914 if ( p27.length != 1 ) {
6915 System.out.println( "yl=" + p27.length );
6919 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
6920 System.out.println( p27[ 0 ].toNewHampshireX() );
6924 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
6925 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
6926 final String p28_S3 = "(A,B)ab";
6927 final String p28_S4 = "((((A,B),C),D),;E;)";
6928 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
6930 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
6933 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
6936 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
6939 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
6942 if ( p28.length != 4 ) {
6945 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";
6946 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
6947 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
6950 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";
6951 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
6952 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
6955 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
6956 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
6957 if ( ( p32.length != 0 ) ) {
6960 final String p33_S = "A";
6961 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
6962 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
6965 final String p34_S = "B;";
6966 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
6967 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
6970 final String p35_S = "B:0.2";
6971 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
6972 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
6975 final String p36_S = "(A)";
6976 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
6977 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
6980 final String p37_S = "((A))";
6981 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
6982 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
6985 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6986 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
6987 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
6990 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
6991 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
6992 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
6995 final String p40_S = "(A,B,C)";
6996 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
6997 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
7000 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
7001 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
7002 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
7005 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
7006 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
7007 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
7010 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)";
7011 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
7012 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
7015 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)))";
7016 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
7017 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
7020 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
7021 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
7022 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
7025 final String p46_S = "";
7026 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
7027 if ( p46.length != 0 ) {
7030 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
7031 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7034 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7035 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7038 final Phylogeny p49 = factory
7039 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
7040 new NHXParser() )[ 0 ];
7041 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
7044 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7045 if ( p50.getNode( "A" ) == null ) {
7048 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7049 .equals( "((A,B)ab:2.0[88],C);" ) ) {
7052 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
7055 if ( !p50.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
7056 .equals( "((A,B)88:2.0,C);" ) ) {
7059 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7060 if ( p51.getNode( "A(A" ) == null ) {
7063 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
7064 if ( p52.getNode( "A(A" ) == null ) {
7067 final Phylogeny p53 = factory
7068 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
7069 new NHXParser() )[ 0 ];
7070 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
7074 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
7075 if ( p54.getNode( "A" ) == null ) {
7078 if ( !p54.toNewHampshire( false, NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
7079 .equals( "((A,B)[88],C);" ) ) {
7083 catch ( final Exception e ) {
7084 e.printStackTrace( System.out );
7090 private static boolean testNHParsingIter() {
7092 final String p0_str = "(A,B);";
7093 final NHXParser p = new NHXParser();
7094 p.setSource( p0_str );
7095 if ( !p.hasNext() ) {
7098 final Phylogeny p0 = p.next();
7099 if ( !p0.toNewHampshire().equals( p0_str ) ) {
7100 System.out.println( p0.toNewHampshire() );
7103 if ( p.hasNext() ) {
7106 if ( p.next() != null ) {
7110 final String p00_str = "(A,B)root;";
7111 p.setSource( p00_str );
7112 final Phylogeny p00 = p.next();
7113 if ( !p00.toNewHampshire().equals( p00_str ) ) {
7114 System.out.println( p00.toNewHampshire() );
7118 final String p000_str = "A;";
7119 p.setSource( p000_str );
7120 final Phylogeny p000 = p.next();
7121 if ( !p000.toNewHampshire().equals( p000_str ) ) {
7122 System.out.println( p000.toNewHampshire() );
7126 final String p0000_str = "A";
7127 p.setSource( p0000_str );
7128 final Phylogeny p0000 = p.next();
7129 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
7130 System.out.println( p0000.toNewHampshire() );
7134 p.setSource( "(A)" );
7135 final Phylogeny p00000 = p.next();
7136 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
7137 System.out.println( p00000.toNewHampshire() );
7141 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
7142 p.setSource( p1_str );
7143 if ( !p.hasNext() ) {
7146 final Phylogeny p1_0 = p.next();
7147 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
7148 System.out.println( p1_0.toNewHampshire() );
7151 if ( !p.hasNext() ) {
7154 final Phylogeny p1_1 = p.next();
7155 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
7156 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
7159 if ( !p.hasNext() ) {
7162 final Phylogeny p1_2 = p.next();
7163 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
7164 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
7167 if ( !p.hasNext() ) {
7170 final Phylogeny p1_3 = p.next();
7171 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
7172 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
7175 if ( p.hasNext() ) {
7178 if ( p.next() != null ) {
7182 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
7183 p.setSource( p2_str );
7184 if ( !p.hasNext() ) {
7187 Phylogeny p2_0 = p.next();
7188 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7189 System.out.println( p2_0.toNewHampshire() );
7192 if ( !p.hasNext() ) {
7195 Phylogeny p2_1 = p.next();
7196 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7197 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7200 if ( !p.hasNext() ) {
7203 Phylogeny p2_2 = p.next();
7204 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7205 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7208 if ( !p.hasNext() ) {
7211 Phylogeny p2_3 = p.next();
7212 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7213 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7216 if ( !p.hasNext() ) {
7219 Phylogeny p2_4 = p.next();
7220 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7221 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7224 if ( p.hasNext() ) {
7227 if ( p.next() != null ) {
7232 if ( !p.hasNext() ) {
7236 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
7237 System.out.println( p2_0.toNewHampshire() );
7240 if ( !p.hasNext() ) {
7244 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
7245 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
7248 if ( !p.hasNext() ) {
7252 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
7253 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
7256 if ( !p.hasNext() ) {
7260 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
7261 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
7264 if ( !p.hasNext() ) {
7268 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
7269 System.out.println( "(X) != " + p2_4.toNewHampshire() );
7272 if ( p.hasNext() ) {
7275 if ( p.next() != null ) {
7279 final String p3_str = "((A,B),C)abc";
7280 p.setSource( p3_str );
7281 if ( !p.hasNext() ) {
7284 final Phylogeny p3_0 = p.next();
7285 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
7288 if ( p.hasNext() ) {
7291 if ( p.next() != null ) {
7295 final String p4_str = "((A,B)ab,C)abc";
7296 p.setSource( p4_str );
7297 if ( !p.hasNext() ) {
7300 final Phylogeny p4_0 = p.next();
7301 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
7304 if ( p.hasNext() ) {
7307 if ( p.next() != null ) {
7311 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
7312 p.setSource( p5_str );
7313 if ( !p.hasNext() ) {
7316 final Phylogeny p5_0 = p.next();
7317 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
7320 if ( p.hasNext() ) {
7323 if ( p.next() != null ) {
7327 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
7328 p.setSource( p6_str );
7329 if ( !p.hasNext() ) {
7332 Phylogeny p6_0 = p.next();
7333 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7336 if ( p.hasNext() ) {
7339 if ( p.next() != null ) {
7343 if ( !p.hasNext() ) {
7347 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
7350 if ( p.hasNext() ) {
7353 if ( p.next() != null ) {
7357 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
7358 p.setSource( p7_str );
7359 if ( !p.hasNext() ) {
7362 Phylogeny p7_0 = p.next();
7363 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7366 if ( p.hasNext() ) {
7369 if ( p.next() != null ) {
7373 if ( !p.hasNext() ) {
7377 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7380 if ( p.hasNext() ) {
7383 if ( p.next() != null ) {
7387 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
7388 p.setSource( p8_str );
7389 if ( !p.hasNext() ) {
7392 Phylogeny p8_0 = p.next();
7393 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7396 if ( !p.hasNext() ) {
7399 if ( !p.hasNext() ) {
7402 Phylogeny p8_1 = p.next();
7403 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7406 if ( p.hasNext() ) {
7409 if ( p.next() != null ) {
7413 if ( !p.hasNext() ) {
7417 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
7420 if ( !p.hasNext() ) {
7424 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
7427 if ( p.hasNext() ) {
7430 if ( p.next() != null ) {
7436 if ( p.hasNext() ) {
7440 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
7441 if ( !p.hasNext() ) {
7444 Phylogeny p_27 = p.next();
7445 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7446 System.out.println( p_27.toNewHampshireX() );
7450 if ( p.hasNext() ) {
7453 if ( p.next() != null ) {
7457 if ( !p.hasNext() ) {
7461 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
7462 System.out.println( p_27.toNewHampshireX() );
7466 if ( p.hasNext() ) {
7469 if ( p.next() != null ) {
7473 catch ( final Exception e ) {
7474 e.printStackTrace( System.out );
7480 private static boolean testNHXconversion() {
7482 final PhylogenyNode n1 = new PhylogenyNode();
7483 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7484 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7485 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7486 final PhylogenyNode n5 = PhylogenyNode
7487 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
7488 final PhylogenyNode n6 = PhylogenyNode
7489 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
7490 if ( !n1.toNewHampshireX().equals( "" ) ) {
7493 if ( !n2.toNewHampshireX().equals( "" ) ) {
7496 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
7499 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
7502 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
7505 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
7506 System.out.println( n6.toNewHampshireX() );
7510 catch ( final Exception e ) {
7511 e.printStackTrace( System.out );
7517 private static boolean testNHXNodeParsing() {
7519 final PhylogenyNode n1 = new PhylogenyNode();
7520 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
7521 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
7522 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
7523 final PhylogenyNode n5 = PhylogenyNode
7524 .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]" );
7525 if ( !n3.getName().equals( "n3" ) ) {
7528 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7531 if ( n3.isDuplication() ) {
7534 if ( n3.isHasAssignedEvent() ) {
7537 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
7540 if ( !n4.getName().equals( "n4" ) ) {
7543 if ( n4.getDistanceToParent() != 0.01 ) {
7546 if ( !n5.getName().equals( "n5" ) ) {
7549 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
7552 if ( n5.getDistanceToParent() != 0.1 ) {
7555 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
7558 if ( !n5.isDuplication() ) {
7561 if ( !n5.isHasAssignedEvent() ) {
7564 final PhylogenyNode n8 = PhylogenyNode
7565 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
7566 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7567 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7570 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
7573 final PhylogenyNode n9 = PhylogenyNode
7574 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
7575 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7576 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
7579 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
7582 final PhylogenyNode n10 = PhylogenyNode
7583 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7584 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
7587 final PhylogenyNode n20 = PhylogenyNode
7588 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7589 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7592 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
7595 final PhylogenyNode n20x = PhylogenyNode
7596 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7597 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
7600 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
7603 final PhylogenyNode n20xx = PhylogenyNode
7604 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7605 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
7608 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
7611 final PhylogenyNode n20xxx = PhylogenyNode
7612 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7613 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
7616 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
7619 final PhylogenyNode n20xxxx = PhylogenyNode
7620 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7621 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
7624 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
7627 final PhylogenyNode n21 = PhylogenyNode
7628 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7629 if ( !n21.getName().equals( "N21_PIG" ) ) {
7632 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
7635 final PhylogenyNode n21x = PhylogenyNode
7636 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7637 if ( !n21x.getName().equals( "n21_PIG" ) ) {
7640 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
7643 final PhylogenyNode n22 = PhylogenyNode
7644 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7645 if ( !n22.getName().equals( "n22/PIG" ) ) {
7648 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
7651 final PhylogenyNode n23 = PhylogenyNode
7652 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7653 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
7656 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
7659 final PhylogenyNode a = PhylogenyNode
7660 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7661 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
7664 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
7667 final PhylogenyNode c1 = PhylogenyNode
7668 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
7669 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7670 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
7673 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
7676 final PhylogenyNode c2 = PhylogenyNode
7677 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
7678 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7679 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
7682 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
7685 final PhylogenyNode e3 = PhylogenyNode
7686 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7687 if ( !e3.getName().equals( "n10_RAT~" ) ) {
7690 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
7693 final PhylogenyNode n11 = PhylogenyNode
7694 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
7695 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7696 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
7699 if ( n11.getDistanceToParent() != 0.4 ) {
7702 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
7705 final PhylogenyNode n12 = PhylogenyNode
7706 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
7707 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7708 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
7711 if ( n12.getDistanceToParent() != 0.4 ) {
7714 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
7717 final PhylogenyNode o = PhylogenyNode
7718 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7719 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
7722 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
7725 if ( n1.getName().compareTo( "" ) != 0 ) {
7728 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7731 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7734 if ( n2.getName().compareTo( "" ) != 0 ) {
7737 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
7740 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
7743 final PhylogenyNode n00 = PhylogenyNode
7744 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
7745 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
7748 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
7751 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
7752 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
7755 final PhylogenyNode n13 = PhylogenyNode
7756 .createInstanceFromNhxString( "blah_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7757 if ( !n13.getName().equals( "blah_12345/1-2" ) ) {
7760 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
7763 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7766 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7769 final PhylogenyNode n14 = PhylogenyNode
7770 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7771 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
7774 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
7777 final PhylogenyNode n15 = PhylogenyNode
7778 .createInstanceFromNhxString( "something_wicked[123]",
7779 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7780 if ( !n15.getName().equals( "something_wicked" ) ) {
7783 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
7786 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
7789 final PhylogenyNode n16 = PhylogenyNode
7790 .createInstanceFromNhxString( "something_wicked2[9]",
7791 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7792 if ( !n16.getName().equals( "something_wicked2" ) ) {
7795 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
7798 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
7801 final PhylogenyNode n17 = PhylogenyNode
7802 .createInstanceFromNhxString( "something_wicked3[a]",
7803 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7804 if ( !n17.getName().equals( "something_wicked3" ) ) {
7807 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
7810 final PhylogenyNode n18 = PhylogenyNode
7811 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7812 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
7815 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
7818 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
7821 final PhylogenyNode n19 = PhylogenyNode
7822 .createInstanceFromNhxString( "blah_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7823 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
7826 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7829 final PhylogenyNode n30 = PhylogenyNode
7830 .createInstanceFromNhxString( "blah_1234567-roejojoej",
7831 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7832 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
7835 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
7838 final PhylogenyNode n31 = PhylogenyNode
7839 .createInstanceFromNhxString( "blah_12345678-roejojoej",
7840 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7841 if ( n31.getNodeData().isHasTaxonomy() ) {
7844 final PhylogenyNode n32 = PhylogenyNode
7845 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7846 if ( n32.getNodeData().isHasTaxonomy() ) {
7849 final PhylogenyNode n40 = PhylogenyNode
7850 .createInstanceFromNhxString( "bcl2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7851 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
7854 final PhylogenyNode n41 = PhylogenyNode
7855 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7856 if ( n41.getNodeData().isHasTaxonomy() ) {
7859 final PhylogenyNode n42 = PhylogenyNode
7860 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
7861 if ( n42.getNodeData().isHasTaxonomy() ) {
7864 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
7865 NHXParser.TAXONOMY_EXTRACTION.NO );
7866 if ( n43.getNodeData().isHasTaxonomy() ) {
7869 final PhylogenyNode n44 = PhylogenyNode
7870 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
7871 if ( n44.getNodeData().isHasTaxonomy() ) {
7875 catch ( final Exception e ) {
7876 e.printStackTrace( System.out );
7882 private static boolean testNHXParsing() {
7884 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7885 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
7886 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
7889 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]";
7890 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
7891 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7894 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]";
7895 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
7896 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
7899 final Phylogeny[] p3 = factory
7900 .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]",
7902 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7905 final Phylogeny[] p4 = factory
7906 .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(]",
7908 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7911 final Phylogeny[] p5 = factory
7912 .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(((]",
7914 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
7917 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)";
7918 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)";
7919 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
7920 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
7923 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)))";
7924 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)))";
7925 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
7926 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
7929 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]) ))[,,, ])))))))";
7930 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
7931 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
7932 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
7935 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
7936 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7939 final Phylogeny p10 = factory
7940 .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]",
7941 new NHXParser() )[ 0 ];
7942 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
7946 catch ( final Exception e ) {
7947 e.printStackTrace( System.out );
7953 private static boolean testNHXParsingMB() {
7955 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7956 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
7957 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7958 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7959 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7960 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7961 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7962 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7963 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7964 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
7965 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
7968 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
7971 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
7972 0.1100000000000000e+00 ) ) {
7975 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
7978 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
7981 final Phylogeny p2 = factory
7982 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
7983 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7984 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
7985 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
7986 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
7987 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
7988 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
7989 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
7990 + "7.369400000000000e-02}])",
7991 new NHXParser() )[ 0 ];
7992 if ( p2.getNode( "1" ) == null ) {
7995 if ( p2.getNode( "2" ) == null ) {
7999 catch ( final Exception e ) {
8000 e.printStackTrace( System.out );
8007 private static boolean testNHXParsingQuotes() {
8009 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8010 final NHXParser p = new NHXParser();
8011 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
8012 if ( phylogenies_0.length != 5 ) {
8015 final Phylogeny phy = phylogenies_0[ 4 ];
8016 if ( phy.getNumberOfExternalNodes() != 7 ) {
8019 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
8022 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
8025 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
8026 .getScientificName().equals( "hsapiens" ) ) {
8029 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
8032 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
8035 if ( phy.getNodes( "double quotes inside single quotes" ).size() != 1 ) {
8038 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
8041 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
8044 final NHXParser p1p = new NHXParser();
8045 p1p.setIgnoreQuotes( true );
8046 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
8047 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
8050 final NHXParser p2p = new NHXParser();
8051 p1p.setIgnoreQuotes( false );
8052 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
8053 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
8056 final NHXParser p3p = new NHXParser();
8057 p3p.setIgnoreQuotes( false );
8058 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
8059 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
8062 final NHXParser p4p = new NHXParser();
8063 p4p.setIgnoreQuotes( false );
8064 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
8065 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
8068 final Phylogeny p10 = factory
8069 .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]",
8070 new NHXParser() )[ 0 ];
8071 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]";
8072 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
8075 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
8076 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
8080 final Phylogeny p12 = factory
8081 .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]",
8082 new NHXParser() )[ 0 ];
8083 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]";
8084 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
8087 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
8088 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
8091 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;";
8092 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
8095 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
8096 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
8100 catch ( final Exception e ) {
8101 e.printStackTrace( System.out );
8107 private static boolean testNodeRemoval() {
8109 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8110 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
8111 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
8112 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
8115 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
8116 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
8117 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
8120 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
8121 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
8122 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
8126 catch ( final Exception e ) {
8127 e.printStackTrace( System.out );
8133 private static boolean testPhylogenyBranch() {
8135 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
8136 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
8137 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
8138 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
8139 if ( !a1b1.equals( a1b1 ) ) {
8142 if ( !a1b1.equals( b1a1 ) ) {
8145 if ( !b1a1.equals( a1b1 ) ) {
8148 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
8149 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
8150 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
8151 if ( a1_b1.equals( b1_a1 ) ) {
8154 if ( a1_b1.equals( a1_b1_ ) ) {
8157 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
8158 if ( !a1_b1.equals( b1_a1_ ) ) {
8161 if ( a1_b1_.equals( b1_a1_ ) ) {
8164 if ( !a1_b1_.equals( b1_a1 ) ) {
8168 catch ( final Exception e ) {
8169 e.printStackTrace( System.out );
8175 private static boolean testPhyloXMLparsingOfDistributionElement() {
8177 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8178 PhyloXmlParser xml_parser = null;
8180 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
8182 catch ( final Exception e ) {
8183 // Do nothing -- means were not running from jar.
8185 if ( xml_parser == null ) {
8186 xml_parser = new PhyloXmlParser();
8187 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
8188 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
8191 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
8194 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
8196 if ( xml_parser.getErrorCount() > 0 ) {
8197 System.out.println( xml_parser.getErrorMessages().toString() );
8200 if ( phylogenies_0.length != 1 ) {
8203 final Phylogeny t1 = phylogenies_0[ 0 ];
8204 PhylogenyNode n = null;
8205 Distribution d = null;
8206 n = t1.getNode( "root node" );
8207 if ( !n.getNodeData().isHasDistribution() ) {
8210 if ( n.getNodeData().getDistributions().size() != 1 ) {
8213 d = n.getNodeData().getDistribution();
8214 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8217 if ( d.getPoints().size() != 1 ) {
8220 if ( d.getPolygons() != null ) {
8223 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8226 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8229 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8232 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8235 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8238 n = t1.getNode( "node a" );
8239 if ( !n.getNodeData().isHasDistribution() ) {
8242 if ( n.getNodeData().getDistributions().size() != 2 ) {
8245 d = n.getNodeData().getDistribution( 1 );
8246 if ( !d.getDesc().equals( "San Diego" ) ) {
8249 if ( d.getPoints().size() != 1 ) {
8252 if ( d.getPolygons() != null ) {
8255 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8258 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8261 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8264 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8267 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8270 n = t1.getNode( "node bb" );
8271 if ( !n.getNodeData().isHasDistribution() ) {
8274 if ( n.getNodeData().getDistributions().size() != 1 ) {
8277 d = n.getNodeData().getDistribution( 0 );
8278 if ( d.getPoints().size() != 3 ) {
8281 if ( d.getPolygons().size() != 2 ) {
8284 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8287 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8290 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8293 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8296 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8299 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8302 Polygon p = d.getPolygons().get( 0 );
8303 if ( p.getPoints().size() != 3 ) {
8306 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8309 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8312 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8315 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8318 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8321 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8324 p = d.getPolygons().get( 1 );
8325 if ( p.getPoints().size() != 3 ) {
8328 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8331 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8334 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8338 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
8339 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
8340 if ( rt.length != 1 ) {
8343 final Phylogeny t1_rt = rt[ 0 ];
8344 n = t1_rt.getNode( "root node" );
8345 if ( !n.getNodeData().isHasDistribution() ) {
8348 if ( n.getNodeData().getDistributions().size() != 1 ) {
8351 d = n.getNodeData().getDistribution();
8352 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
8355 if ( d.getPoints().size() != 1 ) {
8358 if ( d.getPolygons() != null ) {
8361 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
8364 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8367 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8370 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
8373 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
8376 n = t1_rt.getNode( "node a" );
8377 if ( !n.getNodeData().isHasDistribution() ) {
8380 if ( n.getNodeData().getDistributions().size() != 2 ) {
8383 d = n.getNodeData().getDistribution( 1 );
8384 if ( !d.getDesc().equals( "San Diego" ) ) {
8387 if ( d.getPoints().size() != 1 ) {
8390 if ( d.getPolygons() != null ) {
8393 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
8396 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
8399 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
8402 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
8405 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
8408 n = t1_rt.getNode( "node bb" );
8409 if ( !n.getNodeData().isHasDistribution() ) {
8412 if ( n.getNodeData().getDistributions().size() != 1 ) {
8415 d = n.getNodeData().getDistribution( 0 );
8416 if ( d.getPoints().size() != 3 ) {
8419 if ( d.getPolygons().size() != 2 ) {
8422 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
8425 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
8428 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
8431 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
8434 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
8437 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
8440 p = d.getPolygons().get( 0 );
8441 if ( p.getPoints().size() != 3 ) {
8444 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
8447 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
8450 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8453 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
8456 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
8459 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
8462 p = d.getPolygons().get( 1 );
8463 if ( p.getPoints().size() != 3 ) {
8466 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
8469 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
8472 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
8476 catch ( final Exception e ) {
8477 e.printStackTrace( System.out );
8483 private static boolean testPostOrderIterator() {
8485 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8486 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8487 PhylogenyNodeIterator it0;
8488 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
8491 for( it0.reset(); it0.hasNext(); ) {
8494 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8495 final PhylogenyNodeIterator it = t1.iteratorPostorder();
8496 if ( !it.next().getName().equals( "A" ) ) {
8499 if ( !it.next().getName().equals( "B" ) ) {
8502 if ( !it.next().getName().equals( "ab" ) ) {
8505 if ( !it.next().getName().equals( "C" ) ) {
8508 if ( !it.next().getName().equals( "D" ) ) {
8511 if ( !it.next().getName().equals( "cd" ) ) {
8514 if ( !it.next().getName().equals( "abcd" ) ) {
8517 if ( !it.next().getName().equals( "E" ) ) {
8520 if ( !it.next().getName().equals( "F" ) ) {
8523 if ( !it.next().getName().equals( "ef" ) ) {
8526 if ( !it.next().getName().equals( "G" ) ) {
8529 if ( !it.next().getName().equals( "H" ) ) {
8532 if ( !it.next().getName().equals( "gh" ) ) {
8535 if ( !it.next().getName().equals( "efgh" ) ) {
8538 if ( !it.next().getName().equals( "r" ) ) {
8541 if ( it.hasNext() ) {
8545 catch ( final Exception e ) {
8546 e.printStackTrace( System.out );
8552 private static boolean testPreOrderIterator() {
8554 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8555 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
8556 PhylogenyNodeIterator it0;
8557 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
8560 for( it0.reset(); it0.hasNext(); ) {
8563 PhylogenyNodeIterator it = t0.iteratorPreorder();
8564 if ( !it.next().getName().equals( "r" ) ) {
8567 if ( !it.next().getName().equals( "ab" ) ) {
8570 if ( !it.next().getName().equals( "A" ) ) {
8573 if ( !it.next().getName().equals( "B" ) ) {
8576 if ( !it.next().getName().equals( "cd" ) ) {
8579 if ( !it.next().getName().equals( "C" ) ) {
8582 if ( !it.next().getName().equals( "D" ) ) {
8585 if ( it.hasNext() ) {
8588 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
8589 it = t1.iteratorPreorder();
8590 if ( !it.next().getName().equals( "r" ) ) {
8593 if ( !it.next().getName().equals( "abcd" ) ) {
8596 if ( !it.next().getName().equals( "ab" ) ) {
8599 if ( !it.next().getName().equals( "A" ) ) {
8602 if ( !it.next().getName().equals( "B" ) ) {
8605 if ( !it.next().getName().equals( "cd" ) ) {
8608 if ( !it.next().getName().equals( "C" ) ) {
8611 if ( !it.next().getName().equals( "D" ) ) {
8614 if ( !it.next().getName().equals( "efgh" ) ) {
8617 if ( !it.next().getName().equals( "ef" ) ) {
8620 if ( !it.next().getName().equals( "E" ) ) {
8623 if ( !it.next().getName().equals( "F" ) ) {
8626 if ( !it.next().getName().equals( "gh" ) ) {
8629 if ( !it.next().getName().equals( "G" ) ) {
8632 if ( !it.next().getName().equals( "H" ) ) {
8635 if ( it.hasNext() ) {
8639 catch ( final Exception e ) {
8640 e.printStackTrace( System.out );
8646 private static boolean testPropertiesMap() {
8648 final PropertiesMap pm = new PropertiesMap();
8649 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8650 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
8651 final Property p2 = new Property( "something:else",
8653 "improbable:research",
8656 pm.addProperty( p0 );
8657 pm.addProperty( p1 );
8658 pm.addProperty( p2 );
8659 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
8662 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
8665 if ( pm.getProperties().size() != 3 ) {
8668 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
8671 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8674 if ( pm.getProperties().size() != 3 ) {
8677 pm.removeProperty( "dimensions:diameter" );
8678 if ( pm.getProperties().size() != 2 ) {
8681 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
8684 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
8688 catch ( final Exception e ) {
8689 e.printStackTrace( System.out );
8695 private static boolean testProteinId() {
8697 final ProteinId id1 = new ProteinId( "a" );
8698 final ProteinId id2 = new ProteinId( "a" );
8699 final ProteinId id3 = new ProteinId( "A" );
8700 final ProteinId id4 = new ProteinId( "b" );
8701 if ( !id1.equals( id1 ) ) {
8704 if ( id1.getId().equals( "x" ) ) {
8707 if ( id1.getId().equals( null ) ) {
8710 if ( !id1.equals( id2 ) ) {
8713 if ( id1.equals( id3 ) ) {
8716 if ( id1.hashCode() != id1.hashCode() ) {
8719 if ( id1.hashCode() != id2.hashCode() ) {
8722 if ( id1.hashCode() == id3.hashCode() ) {
8725 if ( id1.compareTo( id1 ) != 0 ) {
8728 if ( id1.compareTo( id2 ) != 0 ) {
8731 if ( id1.compareTo( id3 ) != 0 ) {
8734 if ( id1.compareTo( id4 ) >= 0 ) {
8737 if ( id4.compareTo( id1 ) <= 0 ) {
8740 if ( !id4.getId().equals( "b" ) ) {
8743 final ProteinId id5 = new ProteinId( " C " );
8744 if ( !id5.getId().equals( "C" ) ) {
8747 if ( id5.equals( id1 ) ) {
8751 catch ( final Exception e ) {
8752 e.printStackTrace( System.out );
8758 private static boolean testReIdMethods() {
8760 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8761 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
8762 final long count = PhylogenyNode.getNodeCount();
8764 if ( p.getNode( "r" ).getId() != count ) {
8767 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
8770 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
8773 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
8776 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
8779 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
8782 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
8785 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
8788 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
8791 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
8794 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
8797 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
8800 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
8803 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
8806 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
8810 catch ( final Exception e ) {
8811 e.printStackTrace( System.out );
8817 private static boolean testRerooting() {
8819 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8820 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",
8821 new NHXParser() )[ 0 ];
8822 if ( !t1.isRooted() ) {
8825 t1.reRoot( t1.getNode( "D" ) );
8826 t1.reRoot( t1.getNode( "CD" ) );
8827 t1.reRoot( t1.getNode( "A" ) );
8828 t1.reRoot( t1.getNode( "B" ) );
8829 t1.reRoot( t1.getNode( "AB" ) );
8830 t1.reRoot( t1.getNode( "D" ) );
8831 t1.reRoot( t1.getNode( "C" ) );
8832 t1.reRoot( t1.getNode( "CD" ) );
8833 t1.reRoot( t1.getNode( "A" ) );
8834 t1.reRoot( t1.getNode( "B" ) );
8835 t1.reRoot( t1.getNode( "AB" ) );
8836 t1.reRoot( t1.getNode( "D" ) );
8837 t1.reRoot( t1.getNode( "D" ) );
8838 t1.reRoot( t1.getNode( "C" ) );
8839 t1.reRoot( t1.getNode( "A" ) );
8840 t1.reRoot( t1.getNode( "B" ) );
8841 t1.reRoot( t1.getNode( "AB" ) );
8842 t1.reRoot( t1.getNode( "C" ) );
8843 t1.reRoot( t1.getNode( "D" ) );
8844 t1.reRoot( t1.getNode( "CD" ) );
8845 t1.reRoot( t1.getNode( "D" ) );
8846 t1.reRoot( t1.getNode( "A" ) );
8847 t1.reRoot( t1.getNode( "B" ) );
8848 t1.reRoot( t1.getNode( "AB" ) );
8849 t1.reRoot( t1.getNode( "C" ) );
8850 t1.reRoot( t1.getNode( "D" ) );
8851 t1.reRoot( t1.getNode( "CD" ) );
8852 t1.reRoot( t1.getNode( "D" ) );
8853 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
8856 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
8859 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
8862 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
8865 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
8868 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
8871 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",
8872 new NHXParser() )[ 0 ];
8873 t2.reRoot( t2.getNode( "A" ) );
8874 t2.reRoot( t2.getNode( "D" ) );
8875 t2.reRoot( t2.getNode( "ABC" ) );
8876 t2.reRoot( t2.getNode( "A" ) );
8877 t2.reRoot( t2.getNode( "B" ) );
8878 t2.reRoot( t2.getNode( "D" ) );
8879 t2.reRoot( t2.getNode( "C" ) );
8880 t2.reRoot( t2.getNode( "ABC" ) );
8881 t2.reRoot( t2.getNode( "A" ) );
8882 t2.reRoot( t2.getNode( "B" ) );
8883 t2.reRoot( t2.getNode( "AB" ) );
8884 t2.reRoot( t2.getNode( "AB" ) );
8885 t2.reRoot( t2.getNode( "D" ) );
8886 t2.reRoot( t2.getNode( "C" ) );
8887 t2.reRoot( t2.getNode( "B" ) );
8888 t2.reRoot( t2.getNode( "AB" ) );
8889 t2.reRoot( t2.getNode( "D" ) );
8890 t2.reRoot( t2.getNode( "D" ) );
8891 t2.reRoot( t2.getNode( "ABC" ) );
8892 t2.reRoot( t2.getNode( "A" ) );
8893 t2.reRoot( t2.getNode( "B" ) );
8894 t2.reRoot( t2.getNode( "AB" ) );
8895 t2.reRoot( t2.getNode( "D" ) );
8896 t2.reRoot( t2.getNode( "C" ) );
8897 t2.reRoot( t2.getNode( "ABC" ) );
8898 t2.reRoot( t2.getNode( "A" ) );
8899 t2.reRoot( t2.getNode( "B" ) );
8900 t2.reRoot( t2.getNode( "AB" ) );
8901 t2.reRoot( t2.getNode( "D" ) );
8902 t2.reRoot( t2.getNode( "D" ) );
8903 t2.reRoot( t2.getNode( "C" ) );
8904 t2.reRoot( t2.getNode( "A" ) );
8905 t2.reRoot( t2.getNode( "B" ) );
8906 t2.reRoot( t2.getNode( "AB" ) );
8907 t2.reRoot( t2.getNode( "C" ) );
8908 t2.reRoot( t2.getNode( "D" ) );
8909 t2.reRoot( t2.getNode( "ABC" ) );
8910 t2.reRoot( t2.getNode( "D" ) );
8911 t2.reRoot( t2.getNode( "A" ) );
8912 t2.reRoot( t2.getNode( "B" ) );
8913 t2.reRoot( t2.getNode( "AB" ) );
8914 t2.reRoot( t2.getNode( "C" ) );
8915 t2.reRoot( t2.getNode( "D" ) );
8916 t2.reRoot( t2.getNode( "ABC" ) );
8917 t2.reRoot( t2.getNode( "D" ) );
8918 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8921 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8924 t2.reRoot( t2.getNode( "ABC" ) );
8925 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8928 if ( !isEqual( t2.getNode( "ABC" ).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( "AB" ) );
8942 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8945 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8948 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8951 t2.reRoot( t2.getNode( "D" ) );
8952 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8955 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8958 t2.reRoot( t2.getNode( "ABC" ) );
8959 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
8962 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
8965 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
8966 new NHXParser() )[ 0 ];
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.getNode( "B" ) );
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 ) {
8987 t3.reRoot( t3.getRoot() );
8988 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8991 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
8994 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
8998 catch ( final Exception e ) {
8999 e.printStackTrace( System.out );
9005 private static boolean testSDIse() {
9007 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9008 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
9009 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
9010 gene1.setRooted( true );
9011 species1.setRooted( true );
9012 final SDI sdi = new SDI( gene1, species1 );
9013 if ( !gene1.getRoot().isDuplication() ) {
9016 final Phylogeny species2 = factory
9017 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9018 new NHXParser() )[ 0 ];
9019 final Phylogeny gene2 = factory
9020 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9021 new NHXParser() )[ 0 ];
9022 species2.setRooted( true );
9023 gene2.setRooted( true );
9024 final SDI sdi2 = new SDI( gene2, species2 );
9025 if ( sdi2.getDuplicationsSum() != 0 ) {
9028 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
9031 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
9034 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
9037 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
9040 if ( !gene2.getNode( "r" ).isSpeciation() ) {
9043 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
9046 final Phylogeny species3 = factory
9047 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9048 new NHXParser() )[ 0 ];
9049 final Phylogeny gene3 = factory
9050 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9051 new NHXParser() )[ 0 ];
9052 species3.setRooted( true );
9053 gene3.setRooted( true );
9054 final SDI sdi3 = new SDI( gene3, species3 );
9055 if ( sdi3.getDuplicationsSum() != 1 ) {
9058 if ( !gene3.getNode( "aa" ).isDuplication() ) {
9061 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
9064 final Phylogeny species4 = factory
9065 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9066 new NHXParser() )[ 0 ];
9067 final Phylogeny gene4 = factory
9068 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9069 new NHXParser() )[ 0 ];
9070 species4.setRooted( true );
9071 gene4.setRooted( true );
9072 final SDI sdi4 = new SDI( gene4, species4 );
9073 if ( sdi4.getDuplicationsSum() != 1 ) {
9076 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
9079 if ( !gene4.getNode( "abc" ).isDuplication() ) {
9082 if ( gene4.getNode( "abcd" ).isDuplication() ) {
9085 if ( species4.getNumberOfExternalNodes() != 6 ) {
9088 if ( gene4.getNumberOfExternalNodes() != 6 ) {
9091 final Phylogeny species5 = factory
9092 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9093 new NHXParser() )[ 0 ];
9094 final Phylogeny gene5 = factory
9095 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
9096 new NHXParser() )[ 0 ];
9097 species5.setRooted( true );
9098 gene5.setRooted( true );
9099 final SDI sdi5 = new SDI( gene5, species5 );
9100 if ( sdi5.getDuplicationsSum() != 2 ) {
9103 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
9106 if ( !gene5.getNode( "adc" ).isDuplication() ) {
9109 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
9112 if ( species5.getNumberOfExternalNodes() != 6 ) {
9115 if ( gene5.getNumberOfExternalNodes() != 6 ) {
9118 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
9119 // Conjecture for Comparing Molecular Phylogenies"
9120 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
9121 final Phylogeny species6 = factory
9122 .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,"
9123 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9124 new NHXParser() )[ 0 ];
9125 final Phylogeny gene6 = factory
9126 .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,"
9127 + "((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,"
9128 + "(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;",
9129 new NHXParser() )[ 0 ];
9130 species6.setRooted( true );
9131 gene6.setRooted( true );
9132 final SDI sdi6 = new SDI( gene6, species6 );
9133 if ( sdi6.getDuplicationsSum() != 3 ) {
9136 if ( !gene6.getNode( "r" ).isDuplication() ) {
9139 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
9142 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
9145 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
9148 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
9151 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
9154 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
9157 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
9160 sdi6.computeMappingCostL();
9161 if ( sdi6.computeMappingCostL() != 17 ) {
9164 if ( species6.getNumberOfExternalNodes() != 9 ) {
9167 if ( gene6.getNumberOfExternalNodes() != 9 ) {
9170 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
9171 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
9172 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
9173 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
9174 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
9175 species7.setRooted( true );
9176 final Phylogeny gene7_1 = Test
9177 .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])" );
9178 gene7_1.setRooted( true );
9179 final SDI sdi7 = new SDI( gene7_1, species7 );
9180 if ( sdi7.getDuplicationsSum() != 0 ) {
9183 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
9186 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
9189 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
9192 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
9195 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
9198 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
9201 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
9204 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
9207 final Phylogeny gene7_2 = Test
9208 .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])" );
9209 gene7_2.setRooted( true );
9210 final SDI sdi7_2 = new SDI( gene7_2, species7 );
9211 if ( sdi7_2.getDuplicationsSum() != 1 ) {
9214 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
9217 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
9220 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
9223 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
9226 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
9229 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
9232 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
9235 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
9238 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
9242 catch ( final Exception e ) {
9248 private static boolean testSDIunrooted() {
9250 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9251 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
9252 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
9253 final Iterator<PhylogenyBranch> iter = l.iterator();
9254 PhylogenyBranch br = iter.next();
9255 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
9258 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
9262 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9265 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9269 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
9272 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
9276 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9279 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9283 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9286 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9290 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
9293 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
9297 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9300 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9304 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9307 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9311 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9314 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9318 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
9321 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
9325 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9328 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9332 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
9335 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
9339 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
9342 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
9346 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
9349 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
9353 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
9356 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
9359 if ( iter.hasNext() ) {
9362 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
9363 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
9364 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
9366 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9369 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9373 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9376 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9380 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9383 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9386 if ( iter1.hasNext() ) {
9389 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
9390 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
9391 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
9393 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
9396 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
9400 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
9403 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
9407 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
9410 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
9413 if ( iter2.hasNext() ) {
9416 final Phylogeny species0 = factory
9417 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
9418 new NHXParser() )[ 0 ];
9419 final Phylogeny gene1 = factory
9420 .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])",
9421 new NHXParser() )[ 0 ];
9422 species0.setRooted( true );
9423 gene1.setRooted( true );
9424 final SDIR sdi_unrooted = new SDIR();
9425 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
9426 if ( sdi_unrooted.getCount() != 1 ) {
9429 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
9432 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
9435 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
9438 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9441 final Phylogeny gene2 = factory
9442 .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])",
9443 new NHXParser() )[ 0 ];
9444 gene2.setRooted( true );
9445 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
9446 if ( sdi_unrooted.getCount() != 1 ) {
9449 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9452 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9455 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
9458 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9461 final Phylogeny species6 = factory
9462 .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,"
9463 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9464 new NHXParser() )[ 0 ];
9465 final Phylogeny gene6 = factory
9466 .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],"
9467 + "(((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],"
9468 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9469 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9470 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9471 new NHXParser() )[ 0 ];
9472 species6.setRooted( true );
9473 gene6.setRooted( true );
9474 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
9475 if ( sdi_unrooted.getCount() != 1 ) {
9478 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9481 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9484 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9487 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9490 if ( !p6[ 0 ].getRoot().isDuplication() ) {
9493 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9496 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9499 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
9502 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9505 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
9508 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
9511 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9515 final Phylogeny species7 = factory
9516 .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,"
9517 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9518 new NHXParser() )[ 0 ];
9519 final Phylogeny gene7 = factory
9520 .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],"
9521 + "(((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],"
9522 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9523 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9524 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9525 new NHXParser() )[ 0 ];
9526 species7.setRooted( true );
9527 gene7.setRooted( true );
9528 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
9529 if ( sdi_unrooted.getCount() != 1 ) {
9532 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9535 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9538 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9541 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
9544 if ( !p7[ 0 ].getRoot().isDuplication() ) {
9547 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9550 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9553 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
9556 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9559 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
9562 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
9565 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9569 final Phylogeny species8 = factory
9570 .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,"
9571 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
9572 new NHXParser() )[ 0 ];
9573 final Phylogeny gene8 = factory
9574 .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],"
9575 + "(((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],"
9576 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
9577 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
9578 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
9579 new NHXParser() )[ 0 ];
9580 species8.setRooted( true );
9581 gene8.setRooted( true );
9582 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
9583 if ( sdi_unrooted.getCount() != 1 ) {
9586 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
9589 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
9592 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
9595 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
9598 if ( !p8[ 0 ].getRoot().isDuplication() ) {
9601 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
9604 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
9607 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
9610 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
9613 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
9616 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
9619 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
9624 catch ( final Exception e ) {
9625 e.printStackTrace( System.out );
9631 private static boolean testSequenceIdParsing() {
9633 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
9634 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9635 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9637 System.out.println( "value =" + id.getValue() );
9638 System.out.println( "provider=" + id.getSource() );
9643 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
9644 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9645 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9647 System.out.println( "value =" + id.getValue() );
9648 System.out.println( "provider=" + id.getSource() );
9653 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
9654 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9655 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
9657 System.out.println( "value =" + id.getValue() );
9658 System.out.println( "provider=" + id.getSource() );
9663 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
9664 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9665 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
9667 System.out.println( "value =" + id.getValue() );
9668 System.out.println( "provider=" + id.getSource() );
9673 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
9674 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9675 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
9677 System.out.println( "value =" + id.getValue() );
9678 System.out.println( "provider=" + id.getSource() );
9683 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
9684 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9685 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
9687 System.out.println( "value =" + id.getValue() );
9688 System.out.println( "provider=" + id.getSource() );
9693 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
9694 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9695 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
9697 System.out.println( "value =" + id.getValue() );
9698 System.out.println( "provider=" + id.getSource() );
9703 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
9704 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9705 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9707 System.out.println( "value =" + id.getValue() );
9708 System.out.println( "provider=" + id.getSource() );
9713 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
9714 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9715 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
9717 System.out.println( "value =" + id.getValue() );
9718 System.out.println( "provider=" + id.getSource() );
9723 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
9724 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9725 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
9727 System.out.println( "value =" + id.getValue() );
9728 System.out.println( "provider=" + id.getSource() );
9733 // id = SequenceAccessionTools.parse( "pllf[pok P4A123_osdjfosnqo035-9233332904i000490 vf tmv x45" );
9734 // if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
9735 // || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "sp" ) ) {
9736 // if ( id != null ) {
9737 // System.out.println( "value =" + id.getValue() );
9738 // System.out.println( "provider=" + id.getSource() );
9743 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
9745 System.out.println( "value =" + id.getValue() );
9746 System.out.println( "provider=" + id.getSource() );
9749 // lcl_91970_unknown_
9751 catch ( final Exception e ) {
9752 e.printStackTrace( System.out );
9758 private static boolean testSequenceWriter() {
9760 final String n = ForesterUtil.LINE_SEPARATOR;
9761 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
9764 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
9767 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
9770 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
9773 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
9774 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
9777 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
9778 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
9782 catch ( final Exception e ) {
9783 e.printStackTrace();
9789 private static boolean testSpecies() {
9791 final Species s1 = new BasicSpecies( "a" );
9792 final Species s2 = new BasicSpecies( "a" );
9793 final Species s3 = new BasicSpecies( "A" );
9794 final Species s4 = new BasicSpecies( "b" );
9795 if ( !s1.equals( s1 ) ) {
9798 if ( s1.getSpeciesId().equals( "x" ) ) {
9801 if ( s1.getSpeciesId().equals( null ) ) {
9804 if ( !s1.equals( s2 ) ) {
9807 if ( s1.equals( s3 ) ) {
9810 if ( s1.hashCode() != s1.hashCode() ) {
9813 if ( s1.hashCode() != s2.hashCode() ) {
9816 if ( s1.hashCode() == s3.hashCode() ) {
9819 if ( s1.compareTo( s1 ) != 0 ) {
9822 if ( s1.compareTo( s2 ) != 0 ) {
9825 if ( s1.compareTo( s3 ) != 0 ) {
9828 if ( s1.compareTo( s4 ) >= 0 ) {
9831 if ( s4.compareTo( s1 ) <= 0 ) {
9834 if ( !s4.getSpeciesId().equals( "b" ) ) {
9837 final Species s5 = new BasicSpecies( " C " );
9838 if ( !s5.getSpeciesId().equals( "C" ) ) {
9841 if ( s5.equals( s1 ) ) {
9845 catch ( final Exception e ) {
9846 e.printStackTrace( System.out );
9852 private static boolean testSplit() {
9854 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9855 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
9856 //Archaeopteryx.createApplication( p0 );
9857 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
9858 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9859 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9860 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9861 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9862 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9863 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9864 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9865 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
9866 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
9867 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
9868 // System.out.println( s0.toString() );
9870 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
9871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9873 if ( s0.match( query_nodes ) ) {
9876 query_nodes = new HashSet<PhylogenyNode>();
9877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9884 if ( !s0.match( query_nodes ) ) {
9888 query_nodes = new HashSet<PhylogenyNode>();
9889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9892 if ( !s0.match( query_nodes ) ) {
9896 query_nodes = new HashSet<PhylogenyNode>();
9897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9901 if ( !s0.match( query_nodes ) ) {
9905 query_nodes = new HashSet<PhylogenyNode>();
9906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9910 if ( !s0.match( query_nodes ) ) {
9914 query_nodes = new HashSet<PhylogenyNode>();
9915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9918 if ( !s0.match( query_nodes ) ) {
9922 query_nodes = new HashSet<PhylogenyNode>();
9923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9925 if ( !s0.match( query_nodes ) ) {
9929 query_nodes = new HashSet<PhylogenyNode>();
9930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9934 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9935 if ( !s0.match( query_nodes ) ) {
9939 query_nodes = new HashSet<PhylogenyNode>();
9940 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9941 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9942 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9943 if ( !s0.match( query_nodes ) ) {
9947 query_nodes = new HashSet<PhylogenyNode>();
9948 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9949 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9950 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9951 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9952 if ( !s0.match( query_nodes ) ) {
9956 query_nodes = new HashSet<PhylogenyNode>();
9957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
9958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9959 if ( s0.match( query_nodes ) ) {
9963 query_nodes = new HashSet<PhylogenyNode>();
9964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
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( "F" ) );
9974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
9975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
9976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
9978 if ( s0.match( query_nodes ) ) {
9982 query_nodes = new HashSet<PhylogenyNode>();
9983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
9985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9986 if ( s0.match( query_nodes ) ) {
9990 query_nodes = new HashSet<PhylogenyNode>();
9991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
9993 if ( s0.match( query_nodes ) ) {
9997 query_nodes = new HashSet<PhylogenyNode>();
9998 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
9999 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10000 if ( s0.match( query_nodes ) ) {
10004 query_nodes = new HashSet<PhylogenyNode>();
10005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10007 if ( s0.match( query_nodes ) ) {
10011 query_nodes = new HashSet<PhylogenyNode>();
10012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10013 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10014 if ( s0.match( query_nodes ) ) {
10018 query_nodes = new HashSet<PhylogenyNode>();
10019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10021 if ( s0.match( query_nodes ) ) {
10025 query_nodes = new HashSet<PhylogenyNode>();
10026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10027 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10028 if ( s0.match( query_nodes ) ) {
10032 query_nodes = new HashSet<PhylogenyNode>();
10033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10034 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10036 if ( s0.match( query_nodes ) ) {
10040 query_nodes = new HashSet<PhylogenyNode>();
10041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10044 if ( s0.match( query_nodes ) ) {
10048 query_nodes = new HashSet<PhylogenyNode>();
10049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10052 if ( s0.match( query_nodes ) ) {
10056 query_nodes = new HashSet<PhylogenyNode>();
10057 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10061 if ( s0.match( query_nodes ) ) {
10065 // query_nodes = new HashSet<PhylogenyNode>();
10066 // query_nodes.add( new PhylogenyNode( "X" ) );
10067 // query_nodes.add( new PhylogenyNode( "Y" ) );
10068 // query_nodes.add( new PhylogenyNode( "A" ) );
10069 // query_nodes.add( new PhylogenyNode( "B" ) );
10070 // query_nodes.add( new PhylogenyNode( "C" ) );
10071 // query_nodes.add( new PhylogenyNode( "D" ) );
10072 // query_nodes.add( new PhylogenyNode( "E" ) );
10073 // query_nodes.add( new PhylogenyNode( "F" ) );
10074 // query_nodes.add( new PhylogenyNode( "G" ) );
10075 // 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( "A" ) );
10082 // query_nodes.add( new PhylogenyNode( "B" ) );
10083 // query_nodes.add( new PhylogenyNode( "C" ) );
10084 // if ( !s0.match( query_nodes ) ) {
10088 // query_nodes = new HashSet<PhylogenyNode>();
10089 // query_nodes.add( new PhylogenyNode( "X" ) );
10090 // query_nodes.add( new PhylogenyNode( "Y" ) );
10091 // query_nodes.add( new PhylogenyNode( "D" ) );
10092 // query_nodes.add( new PhylogenyNode( "E" ) );
10093 // query_nodes.add( new PhylogenyNode( "F" ) );
10094 // query_nodes.add( new PhylogenyNode( "G" ) );
10095 // if ( !s0.match( query_nodes ) ) {
10099 // query_nodes = new HashSet<PhylogenyNode>();
10100 // query_nodes.add( new PhylogenyNode( "X" ) );
10101 // query_nodes.add( new PhylogenyNode( "Y" ) );
10102 // query_nodes.add( new PhylogenyNode( "A" ) );
10103 // query_nodes.add( new PhylogenyNode( "B" ) );
10104 // query_nodes.add( new PhylogenyNode( "C" ) );
10105 // query_nodes.add( new PhylogenyNode( "D" ) );
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( "E" ) );
10114 // query_nodes.add( new PhylogenyNode( "F" ) );
10115 // query_nodes.add( new PhylogenyNode( "G" ) );
10116 // if ( !s0.match( query_nodes ) ) {
10120 // query_nodes = new HashSet<PhylogenyNode>();
10121 // query_nodes.add( new PhylogenyNode( "X" ) );
10122 // query_nodes.add( new PhylogenyNode( "Y" ) );
10123 // query_nodes.add( new PhylogenyNode( "F" ) );
10124 // query_nodes.add( new PhylogenyNode( "G" ) );
10125 // if ( !s0.match( query_nodes ) ) {
10129 query_nodes = new HashSet<PhylogenyNode>();
10130 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10132 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10134 if ( s0.match( query_nodes ) ) {
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( "B" ) );
10143 if ( s0.match( query_nodes ) ) {
10146 ///////////////////////////
10148 query_nodes = new HashSet<PhylogenyNode>();
10149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10153 if ( s0.match( query_nodes ) ) {
10157 query_nodes = new HashSet<PhylogenyNode>();
10158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10161 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10162 if ( s0.match( query_nodes ) ) {
10166 query_nodes = new HashSet<PhylogenyNode>();
10167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10171 if ( s0.match( query_nodes ) ) {
10175 query_nodes = new HashSet<PhylogenyNode>();
10176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10180 if ( s0.match( query_nodes ) ) {
10184 query_nodes = new HashSet<PhylogenyNode>();
10185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10187 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10188 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10189 if ( s0.match( query_nodes ) ) {
10193 query_nodes = new HashSet<PhylogenyNode>();
10194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
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( "F" ) );
10206 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10207 if ( s0.match( query_nodes ) ) {
10211 query_nodes = new HashSet<PhylogenyNode>();
10212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10215 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10216 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
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 if ( s0.match( query_nodes ) ) {
10231 query_nodes = new HashSet<PhylogenyNode>();
10232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
10233 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
10234 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10235 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10238 if ( s0.match( query_nodes ) ) {
10242 catch ( final Exception e ) {
10243 e.printStackTrace();
10249 private static boolean testSplitStrict() {
10251 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10252 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
10253 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
10254 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10255 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10256 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10257 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10258 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10259 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10260 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10261 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
10262 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
10263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10264 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10265 if ( s0.match( query_nodes ) ) {
10268 query_nodes = new HashSet<PhylogenyNode>();
10269 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10270 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10271 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10276 if ( !s0.match( query_nodes ) ) {
10280 query_nodes = new HashSet<PhylogenyNode>();
10281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10284 if ( !s0.match( query_nodes ) ) {
10288 query_nodes = new HashSet<PhylogenyNode>();
10289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10292 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10293 if ( !s0.match( query_nodes ) ) {
10297 query_nodes = new HashSet<PhylogenyNode>();
10298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10301 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10302 if ( !s0.match( query_nodes ) ) {
10306 query_nodes = new HashSet<PhylogenyNode>();
10307 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10310 if ( !s0.match( query_nodes ) ) {
10314 query_nodes = new HashSet<PhylogenyNode>();
10315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10317 if ( !s0.match( query_nodes ) ) {
10321 query_nodes = new HashSet<PhylogenyNode>();
10322 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10327 if ( !s0.match( query_nodes ) ) {
10331 query_nodes = new HashSet<PhylogenyNode>();
10332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10335 if ( !s0.match( query_nodes ) ) {
10339 query_nodes = new HashSet<PhylogenyNode>();
10340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10344 if ( !s0.match( query_nodes ) ) {
10348 query_nodes = new HashSet<PhylogenyNode>();
10349 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10350 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10351 if ( s0.match( query_nodes ) ) {
10355 query_nodes = new HashSet<PhylogenyNode>();
10356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
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( "F" ) );
10366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10367 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10370 if ( s0.match( query_nodes ) ) {
10374 query_nodes = new HashSet<PhylogenyNode>();
10375 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10376 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10378 if ( s0.match( query_nodes ) ) {
10382 query_nodes = new HashSet<PhylogenyNode>();
10383 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10385 if ( s0.match( query_nodes ) ) {
10389 query_nodes = new HashSet<PhylogenyNode>();
10390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10392 if ( s0.match( query_nodes ) ) {
10396 query_nodes = new HashSet<PhylogenyNode>();
10397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
10399 if ( s0.match( query_nodes ) ) {
10403 query_nodes = new HashSet<PhylogenyNode>();
10404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10405 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10406 if ( s0.match( query_nodes ) ) {
10410 query_nodes = new HashSet<PhylogenyNode>();
10411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10413 if ( s0.match( query_nodes ) ) {
10417 query_nodes = new HashSet<PhylogenyNode>();
10418 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10420 if ( s0.match( query_nodes ) ) {
10424 query_nodes = new HashSet<PhylogenyNode>();
10425 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
10427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10428 if ( s0.match( query_nodes ) ) {
10432 query_nodes = new HashSet<PhylogenyNode>();
10433 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10434 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
10435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10436 if ( s0.match( query_nodes ) ) {
10440 query_nodes = new HashSet<PhylogenyNode>();
10441 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10444 if ( s0.match( query_nodes ) ) {
10448 query_nodes = new HashSet<PhylogenyNode>();
10449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
10450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
10451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
10452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
10453 if ( s0.match( query_nodes ) ) {
10457 catch ( final Exception e ) {
10458 e.printStackTrace();
10464 private static boolean testSubtreeDeletion() {
10466 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10467 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10468 t1.deleteSubtree( t1.getNode( "A" ), false );
10469 if ( t1.getNumberOfExternalNodes() != 5 ) {
10472 t1.toNewHampshireX();
10473 t1.deleteSubtree( t1.getNode( "E" ), false );
10474 if ( t1.getNumberOfExternalNodes() != 4 ) {
10477 t1.toNewHampshireX();
10478 t1.deleteSubtree( t1.getNode( "F" ), false );
10479 if ( t1.getNumberOfExternalNodes() != 3 ) {
10482 t1.toNewHampshireX();
10483 t1.deleteSubtree( t1.getNode( "D" ), false );
10484 t1.toNewHampshireX();
10485 if ( t1.getNumberOfExternalNodes() != 3 ) {
10488 t1.deleteSubtree( t1.getNode( "def" ), false );
10489 t1.toNewHampshireX();
10490 if ( t1.getNumberOfExternalNodes() != 2 ) {
10493 t1.deleteSubtree( t1.getNode( "B" ), false );
10494 t1.toNewHampshireX();
10495 if ( t1.getNumberOfExternalNodes() != 1 ) {
10498 t1.deleteSubtree( t1.getNode( "C" ), false );
10499 t1.toNewHampshireX();
10500 if ( t1.getNumberOfExternalNodes() != 1 ) {
10503 t1.deleteSubtree( t1.getNode( "abc" ), false );
10504 t1.toNewHampshireX();
10505 if ( t1.getNumberOfExternalNodes() != 1 ) {
10508 t1.deleteSubtree( t1.getNode( "r" ), false );
10509 if ( t1.getNumberOfExternalNodes() != 0 ) {
10512 if ( !t1.isEmpty() ) {
10515 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
10516 t2.deleteSubtree( t2.getNode( "A" ), false );
10517 t2.toNewHampshireX();
10518 if ( t2.getNumberOfExternalNodes() != 5 ) {
10521 t2.deleteSubtree( t2.getNode( "abc" ), false );
10522 t2.toNewHampshireX();
10523 if ( t2.getNumberOfExternalNodes() != 3 ) {
10526 t2.deleteSubtree( t2.getNode( "def" ), false );
10527 t2.toNewHampshireX();
10528 if ( t2.getNumberOfExternalNodes() != 1 ) {
10532 catch ( final Exception e ) {
10533 e.printStackTrace( System.out );
10539 private static boolean testSupportCount() {
10541 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10542 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
10543 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
10544 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
10545 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
10546 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
10547 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
10549 SupportCount.count( t0_1, phylogenies_1, true, false );
10550 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
10551 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
10552 + "(((((A,B),C),D),E),((F,G),X))"
10553 + "(((((A,Y),B),C),D),((F,G),E))"
10554 + "(((((A,B),C),D),E),(F,G))"
10555 + "(((((A,B),C),D),E),(F,G))"
10556 + "(((((A,B),C),D),E),(F,G))"
10557 + "(((((A,B),C),D),E),(F,G),Z)"
10558 + "(((((A,B),C),D),E),(F,G))"
10559 + "((((((A,B),C),D),E),F),G)"
10560 + "(((((X,Y),F,G),E),((A,B),C)),D)",
10562 SupportCount.count( t0_2, phylogenies_2, true, false );
10563 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
10564 while ( it.hasNext() ) {
10565 final PhylogenyNode n = it.next();
10566 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
10570 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
10571 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
10572 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
10573 SupportCount.count( t0_3, phylogenies_3, true, false );
10574 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
10575 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
10578 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
10581 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
10584 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
10587 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
10590 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
10593 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
10596 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
10599 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
10602 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
10605 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10606 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
10607 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
10608 SupportCount.count( t0_4, phylogenies_4, true, false );
10609 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
10610 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
10613 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
10616 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
10619 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
10622 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
10625 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
10628 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
10631 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
10634 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
10637 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
10640 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10641 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10642 double d = SupportCount.compare( b1, a, true, true, true );
10643 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
10646 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10647 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10648 d = SupportCount.compare( b2, a, true, true, true );
10649 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
10652 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
10653 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
10654 d = SupportCount.compare( b3, a, true, true, true );
10655 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
10658 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
10659 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
10660 d = SupportCount.compare( b4, a, true, true, false );
10661 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
10665 catch ( final Exception e ) {
10666 e.printStackTrace( System.out );
10672 private static boolean testSupportTransfer() {
10674 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10675 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)",
10676 new NHXParser() )[ 0 ];
10677 final Phylogeny p2 = factory
10678 .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 ];
10679 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
10682 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
10685 support_transfer.moveBranchLengthsToBootstrap( p1 );
10686 support_transfer.transferSupportValues( p1, p2 );
10687 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
10690 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
10693 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
10696 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
10699 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
10702 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
10705 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
10708 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
10712 catch ( final Exception e ) {
10713 e.printStackTrace( System.out );
10719 private static boolean testTaxonomyExtraction() {
10721 final PhylogenyNode n0 = PhylogenyNode
10722 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10723 if ( n0.getNodeData().isHasTaxonomy() ) {
10726 final PhylogenyNode n1 = PhylogenyNode
10727 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10728 if ( n1.getNodeData().isHasTaxonomy() ) {
10729 System.out.println( n1.toString() );
10732 final PhylogenyNode n2x = PhylogenyNode
10733 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10734 if ( n2x.getNodeData().isHasTaxonomy() ) {
10737 final PhylogenyNode n3 = PhylogenyNode
10738 .createInstanceFromNhxString( "blag_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10739 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10740 System.out.println( n3.toString() );
10743 final PhylogenyNode n4 = PhylogenyNode
10744 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10745 if ( n4.getNodeData().isHasTaxonomy() ) {
10746 System.out.println( n4.toString() );
10749 final PhylogenyNode n5 = PhylogenyNode
10750 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10751 if ( n5.getNodeData().isHasTaxonomy() ) {
10752 System.out.println( n5.toString() );
10755 final PhylogenyNode n6 = PhylogenyNode
10756 .createInstanceFromNhxString( "blag-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10757 if ( n6.getNodeData().isHasTaxonomy() ) {
10758 System.out.println( n6.toString() );
10761 final PhylogenyNode n7 = PhylogenyNode
10762 .createInstanceFromNhxString( "blag-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10763 if ( n7.getNodeData().isHasTaxonomy() ) {
10764 System.out.println( n7.toString() );
10767 final PhylogenyNode n8 = PhylogenyNode
10768 .createInstanceFromNhxString( "blag_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10769 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10770 System.out.println( n8.toString() );
10773 final PhylogenyNode n9 = PhylogenyNode
10774 .createInstanceFromNhxString( "blag_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10775 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10776 System.out.println( n9.toString() );
10779 final PhylogenyNode n10x = PhylogenyNode
10780 .createInstanceFromNhxString( "blag_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10781 if ( n10x.getNodeData().isHasTaxonomy() ) {
10782 System.out.println( n10x.toString() );
10785 final PhylogenyNode n10xx = PhylogenyNode
10786 .createInstanceFromNhxString( "blag_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10787 if ( n10xx.getNodeData().isHasTaxonomy() ) {
10788 System.out.println( n10xx.toString() );
10791 final PhylogenyNode n10 = PhylogenyNode
10792 .createInstanceFromNhxString( "blag_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10793 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
10794 System.out.println( n10.toString() );
10797 final PhylogenyNode n11 = PhylogenyNode
10798 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10799 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
10800 System.out.println( n11.toString() );
10803 final PhylogenyNode n12 = PhylogenyNode
10804 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
10805 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10806 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
10807 System.out.println( n12.toString() );
10810 final PhylogenyNode n13 = PhylogenyNode
10811 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
10812 if ( n13.getNodeData().isHasTaxonomy() ) {
10813 System.out.println( n13.toString() );
10817 catch ( final Exception e ) {
10818 e.printStackTrace( System.out );
10824 private static boolean testTreeMethods() {
10826 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10827 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
10828 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
10829 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
10830 System.out.println( t0.toNewHampshireX() );
10833 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
10834 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
10835 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
10838 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
10841 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
10845 catch ( final Exception e ) {
10846 e.printStackTrace( System.out );
10852 private static boolean testUniprotEntryRetrieval() {
10854 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
10855 if ( !entry.getAccession().equals( "P12345" ) ) {
10858 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
10861 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
10864 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
10867 if ( !entry.getGeneName().equals( "GOT2" ) ) {
10870 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
10874 catch ( final IOException e ) {
10875 System.out.println();
10876 System.out.println( "the following might be due to absence internet connection:" );
10877 e.printStackTrace( System.out );
10880 catch ( final Exception e ) {
10886 private static boolean testUniprotTaxonomySearch() {
10888 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
10890 if ( results.size() != 1 ) {
10893 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10896 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10899 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10902 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10905 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10909 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
10910 if ( results.size() != 1 ) {
10913 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10916 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10919 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10922 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10925 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10929 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
10930 if ( results.size() != 1 ) {
10933 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10936 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10939 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10942 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10945 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10949 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
10950 if ( results.size() != 1 ) {
10953 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
10956 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
10959 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
10962 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10965 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
10968 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
10971 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
10974 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
10975 .equals( "Nematostella vectensis" ) ) {
10976 System.out.println( results.get( 0 ).getLineage() );
10981 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
10982 if ( results.size() != 1 ) {
10985 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
10988 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
10991 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
10994 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
10997 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11000 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11001 .equals( "Xenopus tropicalis" ) ) {
11002 System.out.println( results.get( 0 ).getLineage() );
11007 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
11008 if ( results.size() != 1 ) {
11011 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11014 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11017 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11020 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11023 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11026 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11027 .equals( "Xenopus tropicalis" ) ) {
11028 System.out.println( results.get( 0 ).getLineage() );
11033 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
11034 if ( results.size() != 1 ) {
11037 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
11040 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
11043 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
11046 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
11049 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
11052 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
11053 .equals( "Xenopus tropicalis" ) ) {
11054 System.out.println( results.get( 0 ).getLineage() );
11058 catch ( final IOException e ) {
11059 System.out.println();
11060 System.out.println( "the following might be due to absence internet connection:" );
11061 e.printStackTrace( System.out );
11064 catch ( final Exception e ) {
11070 private static boolean testWabiTxSearch() {
11072 String result = "";
11073 result = TxSearch.searchSimple( "nematostella" );
11074 result = TxSearch.getTxId( "nematostella" );
11075 if ( !result.equals( "45350" ) ) {
11078 result = TxSearch.getTxName( "45350" );
11079 if ( !result.equals( "Nematostella" ) ) {
11082 result = TxSearch.getTxId( "nematostella vectensis" );
11083 if ( !result.equals( "45351" ) ) {
11086 result = TxSearch.getTxName( "45351" );
11087 if ( !result.equals( "Nematostella vectensis" ) ) {
11090 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
11091 if ( !result.equals( "536089" ) ) {
11094 result = TxSearch.getTxName( "536089" );
11095 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
11098 final List<String> queries = new ArrayList<String>();
11099 queries.add( "Campylobacter coli" );
11100 queries.add( "Escherichia coli" );
11101 queries.add( "Arabidopsis" );
11102 queries.add( "Trichoplax" );
11103 queries.add( "Samanea saman" );
11104 queries.add( "Kluyveromyces marxianus" );
11105 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
11106 queries.add( "Bornavirus parrot/PDD/2008" );
11107 final List<RANKS> ranks = new ArrayList<RANKS>();
11108 ranks.add( RANKS.SUPERKINGDOM );
11109 ranks.add( RANKS.KINGDOM );
11110 ranks.add( RANKS.FAMILY );
11111 ranks.add( RANKS.GENUS );
11112 ranks.add( RANKS.TRIBE );
11113 result = TxSearch.searchLineage( queries, ranks );
11114 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
11115 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
11117 catch ( final Exception e ) {
11118 System.out.println();
11119 System.out.println( "the following might be due to absence internet connection:" );
11120 e.printStackTrace( System.out );