2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
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 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.TreePanelUtil;
45 import org.forester.archaeopteryx.webservices.WebserviceUtil;
46 import org.forester.development.DevelopmentTools;
47 import org.forester.evoinference.TestPhylogenyReconstruction;
48 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
49 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
50 import org.forester.go.TestGo;
51 import org.forester.io.parsers.FastaParser;
52 import org.forester.io.parsers.GeneralMsaParser;
53 import org.forester.io.parsers.HmmscanPerDomainTableParser;
54 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
55 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
56 import org.forester.io.parsers.nexus.NexusCharactersParser;
57 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
58 import org.forester.io.parsers.nhx.NHXParser;
59 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
60 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
61 import org.forester.io.parsers.tol.TolParser;
62 import org.forester.io.parsers.util.ParserUtils;
63 import org.forester.io.writers.PhylogenyWriter;
64 import org.forester.io.writers.SequenceWriter;
65 import org.forester.msa.BasicMsa;
66 import org.forester.msa.DeleteableMsa;
67 import org.forester.msa.Mafft;
68 import org.forester.msa.Msa;
69 import org.forester.msa.Msa.MSA_FORMAT;
70 import org.forester.msa.MsaInferrer;
71 import org.forester.msa.MsaMethods;
72 import org.forester.pccx.TestPccx;
73 import org.forester.phylogeny.Phylogeny;
74 import org.forester.phylogeny.PhylogenyBranch;
75 import org.forester.phylogeny.PhylogenyMethods;
76 import org.forester.phylogeny.PhylogenyNode;
77 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
78 import org.forester.phylogeny.data.Accession;
79 import org.forester.phylogeny.data.Accession.Source;
80 import org.forester.phylogeny.data.BinaryCharacters;
81 import org.forester.phylogeny.data.BranchWidth;
82 import org.forester.phylogeny.data.Confidence;
83 import org.forester.phylogeny.data.Distribution;
84 import org.forester.phylogeny.data.DomainArchitecture;
85 import org.forester.phylogeny.data.Event;
86 import org.forester.phylogeny.data.Identifier;
87 import org.forester.phylogeny.data.PhylogenyData;
88 import org.forester.phylogeny.data.PhylogenyDataUtil;
89 import org.forester.phylogeny.data.Polygon;
90 import org.forester.phylogeny.data.PropertiesMap;
91 import org.forester.phylogeny.data.Property;
92 import org.forester.phylogeny.data.Property.AppliesTo;
93 import org.forester.phylogeny.data.ProteinDomain;
94 import org.forester.phylogeny.data.Taxonomy;
95 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
96 import org.forester.phylogeny.factories.PhylogenyFactory;
97 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
98 import org.forester.protein.BasicDomain;
99 import org.forester.protein.BasicProtein;
100 import org.forester.protein.Domain;
101 import org.forester.protein.Protein;
102 import org.forester.protein.ProteinId;
103 import org.forester.rio.TestRIO;
104 import org.forester.sdi.SDI;
105 import org.forester.sdi.SDIR;
106 import org.forester.sdi.TestGSDI;
107 import org.forester.sequence.BasicSequence;
108 import org.forester.sequence.Sequence;
109 import org.forester.species.BasicSpecies;
110 import org.forester.species.Species;
111 import org.forester.surfacing.TestSurfacing;
112 import org.forester.tools.ConfidenceAssessor;
113 import org.forester.tools.SupportCount;
114 import org.forester.tools.TreeSplitMatrix;
115 import org.forester.util.AsciiHistogram;
116 import org.forester.util.BasicDescriptiveStatistics;
117 import org.forester.util.BasicTable;
118 import org.forester.util.BasicTableParser;
119 import org.forester.util.DescriptiveStatistics;
120 import org.forester.util.ForesterConstants;
121 import org.forester.util.ForesterUtil;
122 import org.forester.util.GeneralTable;
123 import org.forester.util.SequenceAccessionTools;
124 import org.forester.ws.seqdb.SequenceDatabaseEntry;
125 import org.forester.ws.seqdb.SequenceDbWsTools;
126 import org.forester.ws.seqdb.UniProtTaxonomy;
127 import org.forester.ws.wabi.TxSearch;
128 import org.forester.ws.wabi.TxSearch.RANKS;
129 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
130 import org.forester.ws.wabi.TxSearch.TAX_RANK;
132 @SuppressWarnings( "unused")
133 public final class Test {
135 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "resources"
137 + ForesterUtil.getFileSeparator();
138 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
139 + ForesterUtil.getFileSeparator() + "test_data"
140 + ForesterUtil.getFileSeparator();
141 private final static boolean PERFORM_DB_TESTS = false;
142 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
143 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
144 + ForesterConstants.PHYLO_XML_VERSION + "/"
145 + ForesterConstants.PHYLO_XML_XSD;
146 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
147 + ForesterConstants.PHYLO_XML_VERSION + "/"
148 + ForesterConstants.PHYLO_XML_XSD;
149 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
150 private final static double ZERO_DIFF = 1.0E-9;
152 public static boolean isEqual( final double a, final double b ) {
153 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
156 public static void main( final String[] args ) {
157 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
158 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
160 Locale.setDefault( Locale.US );
161 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
164 System.out.print( "[Test if directory with files for testing exists/is readable: " );
165 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
166 System.out.println( "OK.]" );
169 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
170 System.out.println( "Testing aborted." );
173 System.out.print( "[Test if resources directory exists/is readable: " );
174 if ( testDir( PATH_TO_RESOURCES ) ) {
175 System.out.println( "OK.]" );
178 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
179 System.out.println( "Testing aborted." );
182 final long start_time = new Date().getTime();
183 System.out.print( "MSA entropy: " );
184 if ( Test.testMsaEntropy() ) {
185 System.out.println( "OK." );
189 System.out.println( "failed." );
193 System.out.print( "Basic node methods: " );
194 if ( Test.testBasicNodeMethods() ) {
195 System.out.println( "OK." );
199 System.out.println( "failed." );
202 System.out.print( "Protein id: " );
203 if ( !testProteinId() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Species: " );
212 if ( !testSpecies() ) {
213 System.out.println( "failed." );
219 System.out.println( "OK." );
220 System.out.print( "Basic domain: " );
221 if ( !testBasicDomain() ) {
222 System.out.println( "failed." );
228 System.out.println( "OK." );
229 System.out.print( "Basic protein: " );
230 if ( !testBasicProtein() ) {
231 System.out.println( "failed." );
237 System.out.println( "OK." );
238 System.out.print( "Sequence writer: " );
239 if ( testSequenceWriter() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "Sequence id parsing: " );
248 if ( testSequenceIdParsing() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "UniProtKB id extraction: " );
257 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "Sequence DB tools 1: " );
266 if ( testSequenceDbWsTools1() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "Hmmscan output parser: " );
275 if ( testHmmscanOutputParser() ) {
276 System.out.println( "OK." );
280 System.out.println( "failed." );
283 System.out.print( "Overlap removal: " );
284 if ( !org.forester.test.Test.testOverlapRemoval() ) {
285 System.out.println( "failed." );
291 System.out.println( "OK." );
292 System.out.print( "Engulfing overlap removal: " );
293 if ( !Test.testEngulfingOverlapRemoval() ) {
294 System.out.println( "failed." );
300 System.out.println( "OK." );
301 System.out.print( "Taxonomy code extraction: " );
302 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
303 System.out.println( "OK." );
307 System.out.println( "failed." );
310 System.out.print( "SN extraction: " );
311 if ( Test.testExtractSNFromNodeName() ) {
312 System.out.println( "OK." );
316 System.out.println( "failed." );
319 System.out.print( "Taxonomy extraction (general): " );
320 if ( Test.testTaxonomyExtraction() ) {
321 System.out.println( "OK." );
325 System.out.println( "failed." );
328 System.out.print( "Uri for Aptx web sequence accession: " );
329 if ( Test.testCreateUriForSeqWeb() ) {
330 System.out.println( "OK." );
334 System.out.println( "failed." );
337 System.out.print( "Basic node construction and parsing of NHX (node level): " );
338 if ( Test.testNHXNodeParsing() ) {
339 System.out.println( "OK." );
343 System.out.println( "failed." );
346 System.out.print( "NHX parsing iterating: " );
347 if ( Test.testNHParsingIter() ) {
348 System.out.println( "OK." );
352 System.out.println( "failed." );
355 System.out.print( "NH parsing: " );
356 if ( Test.testNHParsing() ) {
357 System.out.println( "OK." );
361 System.out.println( "failed." );
364 System.out.print( "Conversion to NHX (node level): " );
365 if ( Test.testNHXconversion() ) {
366 System.out.println( "OK." );
370 System.out.println( "failed." );
373 System.out.print( "NHX parsing: " );
374 if ( Test.testNHXParsing() ) {
375 System.out.println( "OK." );
379 System.out.println( "failed." );
382 System.out.print( "NHX parsing with quotes: " );
383 if ( Test.testNHXParsingQuotes() ) {
384 System.out.println( "OK." );
388 System.out.println( "failed." );
391 System.out.print( "NHX parsing (MrBayes): " );
392 if ( Test.testNHXParsingMB() ) {
393 System.out.println( "OK." );
397 System.out.println( "failed." );
400 System.out.print( "Nexus characters parsing: " );
401 if ( Test.testNexusCharactersParsing() ) {
402 System.out.println( "OK." );
406 System.out.println( "failed." );
409 System.out.print( "Nexus tree parsing iterating: " );
410 if ( Test.testNexusTreeParsingIterating() ) {
411 System.out.println( "OK." );
415 System.out.println( "failed." );
418 System.out.print( "Nexus tree parsing: " );
419 if ( Test.testNexusTreeParsing() ) {
420 System.out.println( "OK." );
424 System.out.println( "failed." );
427 System.out.print( "Nexus tree parsing (translating): " );
428 if ( Test.testNexusTreeParsingTranslating() ) {
429 System.out.println( "OK." );
433 System.out.println( "failed." );
436 System.out.print( "Nexus matrix parsing: " );
437 if ( Test.testNexusMatrixParsing() ) {
438 System.out.println( "OK." );
442 System.out.println( "failed." );
445 System.out.print( "Basic phyloXML parsing: " );
446 if ( Test.testBasicPhyloXMLparsing() ) {
447 System.out.println( "OK." );
451 System.out.println( "failed." );
454 System.out.print( "Basic phyloXML parsing (validating against schema): " );
455 if ( testBasicPhyloXMLparsingValidating() ) {
456 System.out.println( "OK." );
460 System.out.println( "failed." );
463 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
464 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
465 System.out.println( "OK." );
469 System.out.println( "failed." );
472 System.out.print( "phyloXML Distribution Element: " );
473 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
474 System.out.println( "OK." );
478 System.out.println( "failed." );
481 System.out.print( "Tol XML parsing: " );
482 if ( Test.testBasicTolXMLparsing() ) {
483 System.out.println( "OK." );
487 System.out.println( "failed." );
490 System.out.print( "Copying of node data: " );
491 if ( Test.testCopyOfNodeData() ) {
492 System.out.println( "OK." );
496 System.out.println( "failed." );
499 System.out.print( "Tree copy: " );
500 if ( Test.testTreeCopy() ) {
501 System.out.println( "OK." );
505 System.out.println( "failed." );
508 System.out.print( "Basic tree methods: " );
509 if ( Test.testBasicTreeMethods() ) {
510 System.out.println( "OK." );
514 System.out.println( "failed." );
517 System.out.print( "Tree methods: " );
518 if ( Test.testTreeMethods() ) {
519 System.out.println( "OK." );
523 System.out.println( "failed." );
526 System.out.print( "Postorder Iterator: " );
527 if ( Test.testPostOrderIterator() ) {
528 System.out.println( "OK." );
532 System.out.println( "failed." );
535 System.out.print( "Preorder Iterator: " );
536 if ( Test.testPreOrderIterator() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
544 System.out.print( "Levelorder Iterator: " );
545 if ( Test.testLevelOrderIterator() ) {
546 System.out.println( "OK." );
550 System.out.println( "failed." );
553 System.out.print( "Re-id methods: " );
554 if ( Test.testReIdMethods() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
562 System.out.print( "Methods on last external nodes: " );
563 if ( Test.testLastExternalNodeMethods() ) {
564 System.out.println( "OK." );
568 System.out.println( "failed." );
571 System.out.print( "Methods on external nodes: " );
572 if ( Test.testExternalNodeRelatedMethods() ) {
573 System.out.println( "OK." );
577 System.out.println( "failed." );
580 System.out.print( "Deletion of external nodes: " );
581 if ( Test.testDeletionOfExternalNodes() ) {
582 System.out.println( "OK." );
586 System.out.println( "failed." );
589 System.out.print( "Subtree deletion: " );
590 if ( Test.testSubtreeDeletion() ) {
591 System.out.println( "OK." );
595 System.out.println( "failed." );
598 System.out.print( "Phylogeny branch: " );
599 if ( Test.testPhylogenyBranch() ) {
600 System.out.println( "OK." );
604 System.out.println( "failed." );
607 System.out.print( "Rerooting: " );
608 if ( Test.testRerooting() ) {
609 System.out.println( "OK." );
613 System.out.println( "failed." );
616 System.out.print( "Mipoint rooting: " );
617 if ( Test.testMidpointrooting() ) {
618 System.out.println( "OK." );
622 System.out.println( "failed." );
625 System.out.print( "Node removal: " );
626 if ( Test.testNodeRemoval() ) {
627 System.out.println( "OK." );
631 System.out.println( "failed." );
634 System.out.print( "Support count: " );
635 if ( Test.testSupportCount() ) {
636 System.out.println( "OK." );
640 System.out.println( "failed." );
643 System.out.print( "Support transfer: " );
644 if ( Test.testSupportTransfer() ) {
645 System.out.println( "OK." );
649 System.out.println( "failed." );
652 System.out.print( "Finding of LCA: " );
653 if ( Test.testGetLCA() ) {
654 System.out.println( "OK." );
658 System.out.println( "failed." );
661 System.out.print( "Finding of LCA 2: " );
662 if ( Test.testGetLCA2() ) {
663 System.out.println( "OK." );
667 System.out.println( "failed." );
670 System.out.print( "Calculation of distance between nodes: " );
671 if ( Test.testGetDistance() ) {
672 System.out.println( "OK." );
676 System.out.println( "failed." );
679 System.out.print( "Descriptive statistics: " );
680 if ( Test.testDescriptiveStatistics() ) {
681 System.out.println( "OK." );
685 System.out.println( "failed." );
688 System.out.print( "Data objects and methods: " );
689 if ( Test.testDataObjects() ) {
690 System.out.println( "OK." );
694 System.out.println( "failed." );
697 System.out.print( "Properties map: " );
698 if ( Test.testPropertiesMap() ) {
699 System.out.println( "OK." );
703 System.out.println( "failed." );
706 System.out.print( "SDIse: " );
707 if ( Test.testSDIse() ) {
708 System.out.println( "OK." );
712 System.out.println( "failed." );
715 System.out.print( "SDIunrooted: " );
716 if ( Test.testSDIunrooted() ) {
717 System.out.println( "OK." );
721 System.out.println( "failed." );
724 System.out.print( "GSDI: " );
725 if ( TestGSDI.test() ) {
726 System.out.println( "OK." );
730 System.out.println( "failed." );
733 System.out.print( "RIO: " );
734 if ( TestRIO.test() ) {
735 System.out.println( "OK." );
739 System.out.println( "failed." );
742 System.out.print( "Phylogeny reconstruction:" );
743 System.out.println();
744 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "Analysis of domain architectures: " );
753 System.out.println();
754 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "GO: " );
763 System.out.println();
764 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
765 System.out.println( "OK." );
769 System.out.println( "failed." );
772 System.out.print( "Modeling tools: " );
773 if ( TestPccx.test() ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "Split Matrix strict: " );
782 if ( Test.testSplitStrict() ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "Split Matrix: " );
791 if ( Test.testSplit() ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "Confidence Assessor: " );
800 if ( Test.testConfidenceAssessor() ) {
801 System.out.println( "OK." );
805 System.out.println( "failed." );
808 System.out.print( "Basic table: " );
809 if ( Test.testBasicTable() ) {
810 System.out.println( "OK." );
814 System.out.println( "failed." );
817 System.out.print( "General table: " );
818 if ( Test.testGeneralTable() ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Amino acid sequence: " );
827 if ( Test.testAminoAcidSequence() ) {
828 System.out.println( "OK." );
832 System.out.println( "failed." );
835 System.out.print( "General MSA parser: " );
836 if ( Test.testGeneralMsaParser() ) {
837 System.out.println( "OK." );
841 System.out.println( "failed." );
844 System.out.print( "Fasta parser for msa: " );
845 if ( Test.testFastaParser() ) {
846 System.out.println( "OK." );
850 System.out.println( "failed." );
853 System.out.print( "Creation of balanced phylogeny: " );
854 if ( Test.testCreateBalancedPhylogeny() ) {
855 System.out.println( "OK." );
859 System.out.println( "failed." );
862 System.out.print( "Genbank accessor parsing: " );
863 if ( Test.testGenbankAccessorParsing() ) {
864 System.out.println( "OK." );
868 System.out.println( "failed." );
872 final String os = ForesterUtil.OS_NAME.toLowerCase();
873 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
874 path = "/usr/local/bin/mafft";
876 else if ( os.indexOf( "win" ) >= 0 ) {
877 path = "C:\\Program Files\\mafft-win\\mafft.bat";
881 if ( !MsaInferrer.isInstalled( path ) ) {
882 path = "/usr/bin/mafft";
884 if ( !MsaInferrer.isInstalled( path ) ) {
885 path = "/usr/local/bin/mafft";
888 if ( MsaInferrer.isInstalled( path ) ) {
889 System.out.print( "MAFFT (external program): " );
890 if ( Test.testMafft( path ) ) {
891 System.out.println( "OK." );
895 System.out.println( "failed [will not count towards failed tests]" );
898 System.out.print( "Next nodes with collapsed: " );
899 if ( Test.testNextNodeWithCollapsing() ) {
900 System.out.println( "OK." );
904 System.out.println( "failed." );
907 System.out.print( "Simple MSA quality: " );
908 if ( Test.testMsaQualityMethod() ) {
909 System.out.println( "OK." );
913 System.out.println( "failed." );
916 System.out.print( "Deleteable MSA: " );
917 if ( Test.testDeleteableMsa() ) {
918 System.out.println( "OK." );
922 System.out.println( "failed." );
925 if ( PERFORM_DB_TESTS ) {
926 System.out.print( "Uniprot Entry Retrieval: " );
927 if ( Test.testUniprotEntryRetrieval() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Ebi Entry Retrieval: " );
936 if ( Test.testEbiEntryRetrieval() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Sequence DB tools 2: " );
945 if ( testSequenceDbWsTools2() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
954 System.out.print( "Uniprot Taxonomy Search: " );
955 if ( Test.testUniprotTaxonomySearch() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
964 if ( PERFORM_WEB_TREE_ACCESS ) {
965 System.out.print( "NHX parsing from URL: " );
966 if ( Test.testNHXparsingFromURL() ) {
967 System.out.println( "OK." );
971 System.out.println( "failed." );
974 System.out.print( "phyloXML parsing from URL: " );
975 if ( Test.testPhyloXMLparsingFromURL() ) {
976 System.out.println( "OK." );
980 System.out.println( "failed." );
983 System.out.print( "TreeBase acccess: " );
984 if ( Test.testTreeBaseReading() ) {
985 System.out.println( "OK." );
989 System.out.println( "failed." );
993 System.out.print( "ToL access: " );
994 if ( Test.testToLReading() ) {
995 System.out.println( "OK." );
999 System.out.println( "failed." );
1003 System.out.print( "TreeFam access: " );
1004 if ( Test.testTreeFamReading() ) {
1005 System.out.println( "OK." );
1009 System.out.println( "failed." );
1014 System.out.print( "Pfam tree access: " );
1015 if ( Test.testPfamTreeReading() ) {
1016 System.out.println( "OK." );
1020 System.out.println( "failed." );
1024 System.out.println();
1025 final Runtime rt = java.lang.Runtime.getRuntime();
1026 final long free_memory = rt.freeMemory() / 1000000;
1027 final long total_memory = rt.totalMemory() / 1000000;
1028 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1029 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1030 System.out.println();
1031 System.out.println( "Successful tests: " + succeeded );
1032 System.out.println( "Failed tests: " + failed );
1033 System.out.println();
1035 System.out.println( "OK." );
1038 System.out.println( "Not OK." );
1042 public static boolean testEngulfingOverlapRemoval() {
1044 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1045 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1046 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1047 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1048 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1049 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1050 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1051 final List<Boolean> covered = new ArrayList<Boolean>();
1052 covered.add( true ); // 0
1053 covered.add( false ); // 1
1054 covered.add( true ); // 2
1055 covered.add( false ); // 3
1056 covered.add( true ); // 4
1057 covered.add( true ); // 5
1058 covered.add( false ); // 6
1059 covered.add( true ); // 7
1060 covered.add( true ); // 8
1061 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1064 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1067 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1070 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1073 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1076 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1079 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1082 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1083 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1084 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1085 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1086 abc.addProteinDomain( a );
1087 abc.addProteinDomain( b );
1088 abc.addProteinDomain( c );
1089 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1090 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1091 if ( abc.getNumberOfProteinDomains() != 3 ) {
1094 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1097 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1100 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1103 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1106 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1107 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1108 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1109 final Protein def = new BasicProtein( "def", "nemve", 0 );
1110 def.addProteinDomain( d );
1111 def.addProteinDomain( e );
1112 def.addProteinDomain( f );
1113 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1114 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1115 if ( def.getNumberOfProteinDomains() != 3 ) {
1118 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1121 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1124 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1127 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1130 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1134 catch ( final Exception e ) {
1135 e.printStackTrace( System.out );
1141 public static final boolean testNHXparsingFromURL() {
1143 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1144 final URL u = new URL( s );
1145 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1146 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1147 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1150 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1151 System.out.println( phys[ 0 ].toNewHampshire() );
1154 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1155 System.out.println( phys[ 1 ].toNewHampshire() );
1158 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1159 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1162 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1163 System.out.println( phys2[ 0 ].toNewHampshire() );
1166 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1167 final NHXParser p = new NHXParser();
1168 final URL u2 = new URL( s );
1170 if ( !p.hasNext() ) {
1173 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1176 if ( !p.hasNext() ) {
1180 if ( !p.hasNext() ) {
1183 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1186 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1190 if ( !p.hasNext() ) {
1193 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1196 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1200 catch ( final Exception e ) {
1201 e.printStackTrace();
1206 public static boolean testOverlapRemoval() {
1208 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1209 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1210 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1211 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1212 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1213 final List<Boolean> covered = new ArrayList<Boolean>();
1214 covered.add( true ); // 0
1215 covered.add( false ); // 1
1216 covered.add( true ); // 2
1217 covered.add( false ); // 3
1218 covered.add( true ); // 4
1219 covered.add( true ); // 5
1220 covered.add( false ); // 6
1221 covered.add( true ); // 7
1222 covered.add( true ); // 8
1223 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1226 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1229 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1232 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1235 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1238 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1239 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1240 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1241 ab.addProteinDomain( a );
1242 ab.addProteinDomain( b );
1243 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1244 if ( ab.getNumberOfProteinDomains() != 2 ) {
1247 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1250 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1253 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1254 if ( ab.getNumberOfProteinDomains() != 2 ) {
1257 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1260 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1261 final Domain d = new BasicDomain( "d",
1268 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1269 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1270 cde.addProteinDomain( c );
1271 cde.addProteinDomain( d );
1272 cde.addProteinDomain( e );
1273 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1274 if ( cde.getNumberOfProteinDomains() != 3 ) {
1277 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1280 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1281 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1282 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1283 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1284 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1285 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1286 fghi.addProteinDomain( f );
1287 fghi.addProteinDomain( g );
1288 fghi.addProteinDomain( h );
1289 fghi.addProteinDomain( i );
1290 fghi.addProteinDomain( i );
1291 fghi.addProteinDomain( i );
1292 fghi.addProteinDomain( i2 );
1293 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1294 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1297 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1300 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1303 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1304 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1307 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1310 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1311 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1312 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1313 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1314 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1315 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1316 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1317 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1318 jklm.addProteinDomain( j );
1319 jklm.addProteinDomain( k );
1320 jklm.addProteinDomain( l );
1321 jklm.addProteinDomain( m );
1322 jklm.addProteinDomain( m0 );
1323 jklm.addProteinDomain( m1 );
1324 jklm.addProteinDomain( m2 );
1325 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1326 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1329 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1332 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1335 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1336 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1339 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1342 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1343 final Protein od = new BasicProtein( "od", "varanus", 0 );
1344 od.addProteinDomain( only );
1345 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1346 if ( od.getNumberOfProteinDomains() != 1 ) {
1349 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1353 catch ( final Exception e ) {
1354 e.printStackTrace( System.out );
1360 public static final boolean testPfamTreeReading() {
1362 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1363 final NHXParser parser = new NHXParser();
1364 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1365 parser.setReplaceUnderscores( false );
1366 parser.setGuessRootedness( true );
1367 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1368 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1369 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1372 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1376 catch ( final Exception e ) {
1377 e.printStackTrace();
1382 public static final boolean testPhyloXMLparsingFromURL() {
1384 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1385 final URL u = new URL( s );
1386 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1387 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1388 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1392 catch ( final Exception e ) {
1393 e.printStackTrace();
1398 public static final boolean testToLReading() {
1400 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1401 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1402 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1403 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1406 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1409 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1412 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1416 catch ( final Exception e ) {
1417 e.printStackTrace();
1422 public static final boolean testTreeBaseReading() {
1424 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1425 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1426 parser.setReplaceUnderscores( true );
1427 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1428 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1429 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1432 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1433 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1434 parser2.setReplaceUnderscores( true );
1435 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1436 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1437 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1441 catch ( final Exception e ) {
1442 e.printStackTrace();
1447 public static final boolean testTreeFamReading() {
1449 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1450 final NHXParser parser = new NHXParser();
1451 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1452 parser.setReplaceUnderscores( false );
1453 parser.setGuessRootedness( true );
1454 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1455 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1456 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1459 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1463 catch ( final Exception e ) {
1464 e.printStackTrace();
1469 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1470 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1474 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1475 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1478 private static boolean testAminoAcidSequence() {
1480 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1481 if ( aa1.getLength() != 13 ) {
1484 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1487 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1490 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1493 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1494 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1497 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1498 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1501 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1502 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1506 catch ( final Exception e ) {
1507 e.printStackTrace();
1513 private static boolean testBasicDomain() {
1515 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1516 if ( !pd.getDomainId().equals( "id" ) ) {
1519 if ( pd.getNumber() != 1 ) {
1522 if ( pd.getTotalCount() != 4 ) {
1525 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1528 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1529 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1530 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1531 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1532 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1533 if ( !a1.equals( a1 ) ) {
1536 if ( !a1.equals( a1_copy ) ) {
1539 if ( !a1.equals( a1_equal ) ) {
1542 if ( !a1.equals( a2 ) ) {
1545 if ( a1.equals( a3 ) ) {
1548 if ( a1.compareTo( a1 ) != 0 ) {
1551 if ( a1.compareTo( a1_copy ) != 0 ) {
1554 if ( a1.compareTo( a1_equal ) != 0 ) {
1557 if ( a1.compareTo( a2 ) != 0 ) {
1560 if ( a1.compareTo( a3 ) == 0 ) {
1564 catch ( final Exception e ) {
1565 e.printStackTrace( System.out );
1571 private static boolean testBasicNodeMethods() {
1573 if ( PhylogenyNode.getNodeCount() != 0 ) {
1576 final PhylogenyNode n1 = new PhylogenyNode();
1577 final PhylogenyNode n2 = PhylogenyNode
1578 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1579 final PhylogenyNode n3 = PhylogenyNode
1580 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1581 final PhylogenyNode n4 = PhylogenyNode
1582 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1583 if ( n1.isHasAssignedEvent() ) {
1586 if ( PhylogenyNode.getNodeCount() != 4 ) {
1589 if ( n3.getIndicator() != 0 ) {
1592 if ( n3.getNumberOfExternalNodes() != 1 ) {
1595 if ( !n3.isExternal() ) {
1598 if ( !n3.isRoot() ) {
1601 if ( !n4.getName().equals( "n4" ) ) {
1605 catch ( final Exception e ) {
1606 e.printStackTrace( System.out );
1612 private static boolean testBasicPhyloXMLparsing() {
1614 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1615 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1616 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1618 if ( xml_parser.getErrorCount() > 0 ) {
1619 System.out.println( xml_parser.getErrorMessages().toString() );
1622 if ( phylogenies_0.length != 4 ) {
1625 final Phylogeny t1 = phylogenies_0[ 0 ];
1626 final Phylogeny t2 = phylogenies_0[ 1 ];
1627 final Phylogeny t3 = phylogenies_0[ 2 ];
1628 final Phylogeny t4 = phylogenies_0[ 3 ];
1629 if ( t1.getNumberOfExternalNodes() != 1 ) {
1632 if ( !t1.isRooted() ) {
1635 if ( t1.isRerootable() ) {
1638 if ( !t1.getType().equals( "gene_tree" ) ) {
1641 if ( t2.getNumberOfExternalNodes() != 2 ) {
1644 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1647 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1650 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1653 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1656 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1659 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1662 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1663 .startsWith( "actgtgggggt" ) ) {
1666 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1667 .startsWith( "ctgtgatgcat" ) ) {
1670 if ( t3.getNumberOfExternalNodes() != 4 ) {
1673 if ( !t1.getName().equals( "t1" ) ) {
1676 if ( !t2.getName().equals( "t2" ) ) {
1679 if ( !t3.getName().equals( "t3" ) ) {
1682 if ( !t4.getName().equals( "t4" ) ) {
1685 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1688 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1691 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1694 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1695 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1698 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1701 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1704 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1707 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1708 .equals( "apoptosis" ) ) {
1711 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1712 .equals( "GO:0006915" ) ) {
1715 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1716 .equals( "UniProtKB" ) ) {
1719 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1720 .equals( "experimental" ) ) {
1723 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1724 .equals( "function" ) ) {
1727 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1728 .getValue() != 1 ) {
1731 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1732 .getType().equals( "ml" ) ) {
1735 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1736 .equals( "apoptosis" ) ) {
1739 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1740 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1743 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1744 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1747 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1748 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1751 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1752 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1755 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1756 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1759 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1760 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1763 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1764 .equals( "GO:0005829" ) ) {
1767 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1768 .equals( "intracellular organelle" ) ) {
1771 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1774 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1775 .equals( "UniProt link" ) ) ) {
1778 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1781 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1782 if ( x.size() != 4 ) {
1786 for( final Accession acc : x ) {
1788 if ( !acc.getSource().equals( "KEGG" ) ) {
1791 if ( !acc.getValue().equals( "hsa:596" ) ) {
1798 catch ( final Exception e ) {
1799 e.printStackTrace( System.out );
1805 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1807 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1808 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1809 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1810 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1813 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1815 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1817 if ( xml_parser.getErrorCount() > 0 ) {
1818 System.out.println( xml_parser.getErrorMessages().toString() );
1821 if ( phylogenies_0.length != 4 ) {
1824 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1825 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1826 if ( phylogenies_t1.length != 1 ) {
1829 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1830 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1833 if ( !t1_rt.isRooted() ) {
1836 if ( t1_rt.isRerootable() ) {
1839 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1842 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1843 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1844 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1845 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1848 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1851 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1854 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1857 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1858 .startsWith( "actgtgggggt" ) ) {
1861 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1862 .startsWith( "ctgtgatgcat" ) ) {
1865 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1866 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1867 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1868 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1869 if ( phylogenies_1.length != 1 ) {
1872 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1873 if ( !t3_rt.getName().equals( "t3" ) ) {
1876 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1879 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1882 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1885 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1888 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1889 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1892 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1895 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1898 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1899 .equals( "UniProtKB" ) ) {
1902 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1903 .equals( "apoptosis" ) ) {
1906 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1907 .equals( "GO:0006915" ) ) {
1910 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1911 .equals( "UniProtKB" ) ) {
1914 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1915 .equals( "experimental" ) ) {
1918 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1919 .equals( "function" ) ) {
1922 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1923 .getValue() != 1 ) {
1926 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1927 .getType().equals( "ml" ) ) {
1930 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1931 .equals( "apoptosis" ) ) {
1934 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1935 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1938 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1939 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1942 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1943 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1946 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1947 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1950 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1951 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1954 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1955 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1958 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1959 .equals( "GO:0005829" ) ) {
1962 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1963 .equals( "intracellular organelle" ) ) {
1966 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1969 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1970 .equals( "UniProt link" ) ) ) {
1973 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1976 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
1979 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
1980 .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." ) ) ) {
1983 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
1986 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
1989 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
1992 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
1995 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
1996 .equals( "ncbi" ) ) {
1999 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2002 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2003 .getName().equals( "B" ) ) {
2006 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2007 .getFrom() != 21 ) {
2010 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2013 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2014 .getLength() != 24 ) {
2017 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2018 .getConfidence() != 2144 ) {
2021 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2022 .equals( "pfam" ) ) {
2025 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2028 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2031 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2034 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2037 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2038 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2041 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2044 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2047 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2050 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2053 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2056 if ( taxbb.getSynonyms().size() != 2 ) {
2059 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2062 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2065 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2068 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2071 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2074 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2075 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2078 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2081 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2084 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2087 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2090 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2093 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2096 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2100 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2103 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2104 .equalsIgnoreCase( "435" ) ) {
2107 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2110 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2111 .equalsIgnoreCase( "443.7" ) ) {
2114 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2117 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2120 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2121 .equalsIgnoreCase( "433" ) ) {
2124 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2125 .getCrossReferences();
2126 if ( x.size() != 4 ) {
2130 for( final Accession acc : x ) {
2132 if ( !acc.getSource().equals( "KEGG" ) ) {
2135 if ( !acc.getValue().equals( "hsa:596" ) ) {
2142 catch ( final Exception e ) {
2143 e.printStackTrace( System.out );
2149 private static boolean testBasicPhyloXMLparsingValidating() {
2151 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2152 PhyloXmlParser xml_parser = null;
2154 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2156 catch ( final Exception e ) {
2157 // Do nothing -- means were not running from jar.
2159 if ( xml_parser == null ) {
2160 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2161 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2162 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2165 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2168 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2170 if ( xml_parser.getErrorCount() > 0 ) {
2171 System.out.println( xml_parser.getErrorMessages().toString() );
2174 if ( phylogenies_0.length != 4 ) {
2177 final Phylogeny t1 = phylogenies_0[ 0 ];
2178 final Phylogeny t2 = phylogenies_0[ 1 ];
2179 final Phylogeny t3 = phylogenies_0[ 2 ];
2180 final Phylogeny t4 = phylogenies_0[ 3 ];
2181 if ( !t1.getName().equals( "t1" ) ) {
2184 if ( !t2.getName().equals( "t2" ) ) {
2187 if ( !t3.getName().equals( "t3" ) ) {
2190 if ( !t4.getName().equals( "t4" ) ) {
2193 if ( t1.getNumberOfExternalNodes() != 1 ) {
2196 if ( t2.getNumberOfExternalNodes() != 2 ) {
2199 if ( t3.getNumberOfExternalNodes() != 4 ) {
2202 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2203 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2204 if ( xml_parser.getErrorCount() > 0 ) {
2205 System.out.println( "errors:" );
2206 System.out.println( xml_parser.getErrorMessages().toString() );
2209 if ( phylogenies_1.length != 4 ) {
2212 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2214 if ( xml_parser.getErrorCount() > 0 ) {
2215 System.out.println( "errors:" );
2216 System.out.println( xml_parser.getErrorMessages().toString() );
2219 if ( phylogenies_2.length != 1 ) {
2222 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2225 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2227 if ( xml_parser.getErrorCount() > 0 ) {
2228 System.out.println( xml_parser.getErrorMessages().toString() );
2231 if ( phylogenies_3.length != 2 ) {
2234 final Phylogeny a = phylogenies_3[ 0 ];
2235 if ( !a.getName().equals( "tree 4" ) ) {
2238 if ( a.getNumberOfExternalNodes() != 3 ) {
2241 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2244 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2247 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2249 if ( xml_parser.getErrorCount() > 0 ) {
2250 System.out.println( xml_parser.getErrorMessages().toString() );
2253 if ( phylogenies_4.length != 1 ) {
2256 final Phylogeny s = phylogenies_4[ 0 ];
2257 if ( s.getNumberOfExternalNodes() != 6 ) {
2260 s.getNode( "first" );
2262 s.getNode( "\"<a'b&c'd\">\"" );
2263 s.getNode( "'''\"" );
2264 s.getNode( "\"\"\"" );
2265 s.getNode( "dick & doof" );
2267 catch ( final Exception e ) {
2268 e.printStackTrace( System.out );
2274 private static boolean testBasicProtein() {
2276 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2277 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2278 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2279 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2280 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2281 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2282 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2283 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2284 p0.addProteinDomain( y );
2285 p0.addProteinDomain( e );
2286 p0.addProteinDomain( b );
2287 p0.addProteinDomain( c );
2288 p0.addProteinDomain( d );
2289 p0.addProteinDomain( a );
2290 p0.addProteinDomain( x );
2291 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2294 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2298 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2299 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2300 aa0.addProteinDomain( a1 );
2301 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2304 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2308 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2309 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2310 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2311 aa1.addProteinDomain( a11 );
2312 aa1.addProteinDomain( a12 );
2313 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2316 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2319 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2320 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2323 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2326 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2329 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2330 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2333 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2336 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2339 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2342 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2343 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2346 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2349 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2352 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2355 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2356 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2359 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2362 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2365 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2369 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2370 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2371 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2372 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2373 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2374 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2376 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2377 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2378 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2379 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2380 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2381 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2382 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2383 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2384 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2385 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2386 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2387 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2388 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2389 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2390 p00.addProteinDomain( y0 );
2391 p00.addProteinDomain( e0 );
2392 p00.addProteinDomain( b0 );
2393 p00.addProteinDomain( c0 );
2394 p00.addProteinDomain( d0 );
2395 p00.addProteinDomain( a0 );
2396 p00.addProteinDomain( x0 );
2397 p00.addProteinDomain( y1 );
2398 p00.addProteinDomain( y2 );
2399 p00.addProteinDomain( y3 );
2400 p00.addProteinDomain( e1 );
2401 p00.addProteinDomain( e2 );
2402 p00.addProteinDomain( e3 );
2403 p00.addProteinDomain( e4 );
2404 p00.addProteinDomain( e5 );
2405 p00.addProteinDomain( z0 );
2406 p00.addProteinDomain( z1 );
2407 p00.addProteinDomain( z2 );
2408 p00.addProteinDomain( zz0 );
2409 p00.addProteinDomain( zz1 );
2410 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2413 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2416 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2419 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2422 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" ) ) {
2425 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2426 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2427 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2428 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2429 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2430 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2431 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2432 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2433 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2434 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2435 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2436 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2437 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2438 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2439 p.addProteinDomain( B15 );
2440 p.addProteinDomain( C50 );
2441 p.addProteinDomain( A60 );
2442 p.addProteinDomain( A30 );
2443 p.addProteinDomain( C70 );
2444 p.addProteinDomain( B35 );
2445 p.addProteinDomain( B40 );
2446 p.addProteinDomain( A0 );
2447 p.addProteinDomain( A10 );
2448 p.addProteinDomain( A20 );
2449 p.addProteinDomain( B25 );
2450 p.addProteinDomain( D80 );
2451 List<String> domains_ids = new ArrayList<String>();
2452 domains_ids.add( "A" );
2453 domains_ids.add( "B" );
2454 domains_ids.add( "C" );
2455 if ( !p.contains( domains_ids, false ) ) {
2458 if ( !p.contains( domains_ids, true ) ) {
2461 domains_ids.add( "X" );
2462 if ( p.contains( domains_ids, false ) ) {
2465 if ( p.contains( domains_ids, true ) ) {
2468 domains_ids = new ArrayList<String>();
2469 domains_ids.add( "A" );
2470 domains_ids.add( "C" );
2471 domains_ids.add( "D" );
2472 if ( !p.contains( domains_ids, false ) ) {
2475 if ( !p.contains( domains_ids, true ) ) {
2478 domains_ids = new ArrayList<String>();
2479 domains_ids.add( "A" );
2480 domains_ids.add( "D" );
2481 domains_ids.add( "C" );
2482 if ( !p.contains( domains_ids, false ) ) {
2485 if ( p.contains( domains_ids, true ) ) {
2488 domains_ids = new ArrayList<String>();
2489 domains_ids.add( "A" );
2490 domains_ids.add( "A" );
2491 domains_ids.add( "B" );
2492 if ( !p.contains( domains_ids, false ) ) {
2495 if ( !p.contains( domains_ids, true ) ) {
2498 domains_ids = new ArrayList<String>();
2499 domains_ids.add( "A" );
2500 domains_ids.add( "A" );
2501 domains_ids.add( "A" );
2502 domains_ids.add( "B" );
2503 domains_ids.add( "B" );
2504 if ( !p.contains( domains_ids, false ) ) {
2507 if ( !p.contains( domains_ids, true ) ) {
2510 domains_ids = new ArrayList<String>();
2511 domains_ids.add( "A" );
2512 domains_ids.add( "A" );
2513 domains_ids.add( "B" );
2514 domains_ids.add( "A" );
2515 domains_ids.add( "B" );
2516 domains_ids.add( "B" );
2517 domains_ids.add( "A" );
2518 domains_ids.add( "B" );
2519 domains_ids.add( "C" );
2520 domains_ids.add( "A" );
2521 domains_ids.add( "C" );
2522 domains_ids.add( "D" );
2523 if ( !p.contains( domains_ids, false ) ) {
2526 if ( p.contains( domains_ids, true ) ) {
2530 catch ( final Exception e ) {
2531 e.printStackTrace( System.out );
2537 private static boolean testBasicTable() {
2539 final BasicTable<String> t0 = new BasicTable<String>();
2540 if ( t0.getNumberOfColumns() != 0 ) {
2543 if ( t0.getNumberOfRows() != 0 ) {
2546 t0.setValue( 3, 2, "23" );
2547 t0.setValue( 10, 1, "error" );
2548 t0.setValue( 10, 1, "110" );
2549 t0.setValue( 9, 1, "19" );
2550 t0.setValue( 1, 10, "101" );
2551 t0.setValue( 10, 10, "1010" );
2552 t0.setValue( 100, 10, "10100" );
2553 t0.setValue( 0, 0, "00" );
2554 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2557 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2560 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2563 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2566 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2569 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2572 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2575 if ( t0.getNumberOfColumns() != 101 ) {
2578 if ( t0.getNumberOfRows() != 11 ) {
2581 if ( t0.getValueAsString( 49, 4 ) != null ) {
2584 final String l = ForesterUtil.getLineSeparator();
2585 final StringBuffer source = new StringBuffer();
2586 source.append( "" + l );
2587 source.append( "# 1 1 1 1 1 1 1 1" + l );
2588 source.append( " 00 01 02 03" + l );
2589 source.append( " 10 11 12 13 " + l );
2590 source.append( "20 21 22 23 " + l );
2591 source.append( " 30 31 32 33" + l );
2592 source.append( "40 41 42 43" + l );
2593 source.append( " # 1 1 1 1 1 " + l );
2594 source.append( "50 51 52 53 54" + l );
2595 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2596 if ( t1.getNumberOfColumns() != 5 ) {
2599 if ( t1.getNumberOfRows() != 6 ) {
2602 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2605 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2608 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2611 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2614 final StringBuffer source1 = new StringBuffer();
2615 source1.append( "" + l );
2616 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2617 source1.append( " 00; 01 ;02;03" + l );
2618 source1.append( " 10; 11; 12; 13 " + l );
2619 source1.append( "20; 21; 22; 23 " + l );
2620 source1.append( " 30; 31; 32; 33" + l );
2621 source1.append( "40;41;42;43" + l );
2622 source1.append( " # 1 1 1 1 1 " + l );
2623 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2624 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2625 if ( t2.getNumberOfColumns() != 5 ) {
2628 if ( t2.getNumberOfRows() != 6 ) {
2631 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2634 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2637 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2640 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2643 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2646 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2649 final StringBuffer source2 = new StringBuffer();
2650 source2.append( "" + l );
2651 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2652 source2.append( " 00; 01 ;02;03" + l );
2653 source2.append( " 10; 11; 12; 13 " + l );
2654 source2.append( "20; 21; 22; 23 " + l );
2655 source2.append( " " + l );
2656 source2.append( " 30; 31; 32; 33" + l );
2657 source2.append( "40;41;42;43" + l );
2658 source2.append( " comment: 1 1 1 1 1 " + l );
2659 source2.append( ";;;50 ; 52; 53;;54 " + l );
2660 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2666 if ( tl.size() != 2 ) {
2669 final BasicTable<String> t3 = tl.get( 0 );
2670 final BasicTable<String> t4 = tl.get( 1 );
2671 if ( t3.getNumberOfColumns() != 4 ) {
2674 if ( t3.getNumberOfRows() != 3 ) {
2677 if ( t4.getNumberOfColumns() != 4 ) {
2680 if ( t4.getNumberOfRows() != 3 ) {
2683 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2686 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2690 catch ( final Exception e ) {
2691 e.printStackTrace( System.out );
2697 private static boolean testBasicTolXMLparsing() {
2699 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2700 final TolParser parser = new TolParser();
2701 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2702 if ( parser.getErrorCount() > 0 ) {
2703 System.out.println( parser.getErrorMessages().toString() );
2706 if ( phylogenies_0.length != 1 ) {
2709 final Phylogeny t1 = phylogenies_0[ 0 ];
2710 if ( t1.getNumberOfExternalNodes() != 5 ) {
2713 if ( !t1.isRooted() ) {
2716 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2719 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2722 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2725 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2728 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2729 if ( parser.getErrorCount() > 0 ) {
2730 System.out.println( parser.getErrorMessages().toString() );
2733 if ( phylogenies_1.length != 1 ) {
2736 final Phylogeny t2 = phylogenies_1[ 0 ];
2737 if ( t2.getNumberOfExternalNodes() != 664 ) {
2740 if ( !t2.isRooted() ) {
2743 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2746 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2749 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2752 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2755 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2758 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2759 .equals( "Aquifex" ) ) {
2762 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2763 if ( parser.getErrorCount() > 0 ) {
2764 System.out.println( parser.getErrorMessages().toString() );
2767 if ( phylogenies_2.length != 1 ) {
2770 final Phylogeny t3 = phylogenies_2[ 0 ];
2771 if ( t3.getNumberOfExternalNodes() != 184 ) {
2774 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2777 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2780 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2783 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2784 if ( parser.getErrorCount() > 0 ) {
2785 System.out.println( parser.getErrorMessages().toString() );
2788 if ( phylogenies_3.length != 1 ) {
2791 final Phylogeny t4 = phylogenies_3[ 0 ];
2792 if ( t4.getNumberOfExternalNodes() != 1 ) {
2795 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2798 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2801 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2804 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2805 if ( parser.getErrorCount() > 0 ) {
2806 System.out.println( parser.getErrorMessages().toString() );
2809 if ( phylogenies_4.length != 1 ) {
2812 final Phylogeny t5 = phylogenies_4[ 0 ];
2813 if ( t5.getNumberOfExternalNodes() != 13 ) {
2816 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2819 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2822 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2826 catch ( final Exception e ) {
2827 e.printStackTrace( System.out );
2833 private static boolean testBasicTreeMethods() {
2835 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2836 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2837 if ( t2.getNumberOfExternalNodes() != 4 ) {
2840 if ( t2.getHeight() != 8.5 ) {
2843 if ( !t2.isCompletelyBinary() ) {
2846 if ( t2.isEmpty() ) {
2849 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2850 if ( t3.getNumberOfExternalNodes() != 5 ) {
2853 if ( t3.getHeight() != 11 ) {
2856 if ( t3.isCompletelyBinary() ) {
2859 final PhylogenyNode n = t3.getNode( "ABC" );
2860 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 ];
2861 if ( t4.getNumberOfExternalNodes() != 9 ) {
2864 if ( t4.getHeight() != 11 ) {
2867 if ( t4.isCompletelyBinary() ) {
2870 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)" );
2871 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2872 if ( t5.getNumberOfExternalNodes() != 8 ) {
2875 if ( t5.getHeight() != 15 ) {
2878 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)" );
2879 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2880 if ( t6.getHeight() != 15 ) {
2883 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)" );
2884 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2885 if ( t7.getHeight() != 15 ) {
2888 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)" );
2889 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2890 if ( t8.getNumberOfExternalNodes() != 10 ) {
2893 if ( t8.getHeight() != 15 ) {
2896 final char[] a9 = new char[] { 'a' };
2897 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2898 if ( t9.getHeight() != 0 ) {
2901 final char[] a10 = new char[] { 'a', ':', '6' };
2902 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2903 if ( t10.getHeight() != 6 ) {
2907 catch ( final Exception e ) {
2908 e.printStackTrace( System.out );
2914 private static boolean testConfidenceAssessor() {
2916 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2917 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2918 final Phylogeny[] ev0 = factory
2919 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2921 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2922 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2925 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
2928 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2929 final Phylogeny[] ev1 = factory
2930 .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)));",
2932 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
2933 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
2936 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2939 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2940 final Phylogeny[] ev_b = factory
2941 .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",
2943 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
2944 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
2947 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2951 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2952 final Phylogeny[] ev1x = factory
2953 .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)));",
2955 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
2956 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2959 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
2962 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
2963 final Phylogeny[] ev_bx = factory
2964 .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",
2966 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
2967 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2970 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2974 final Phylogeny[] t2 = factory
2975 .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);",
2977 final Phylogeny[] ev2 = factory
2978 .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);",
2980 for( final Phylogeny target : t2 ) {
2981 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
2984 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
2985 new NHXParser() )[ 0 ];
2986 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
2987 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
2988 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2991 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
2994 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
2998 catch ( final Exception e ) {
2999 e.printStackTrace();
3005 private static boolean testCopyOfNodeData() {
3007 final PhylogenyNode n1 = PhylogenyNode
3008 .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]" );
3009 final PhylogenyNode n2 = n1.copyNodeData();
3010 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3014 catch ( final Exception e ) {
3015 e.printStackTrace();
3021 private static boolean testCreateBalancedPhylogeny() {
3023 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3024 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3027 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3030 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3031 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3034 if ( p1.getNumberOfExternalNodes() != 100 ) {
3038 catch ( final Exception e ) {
3039 e.printStackTrace();
3045 private static boolean testCreateUriForSeqWeb() {
3047 final PhylogenyNode n = new PhylogenyNode();
3048 n.setName( "tr|B3RJ64" );
3049 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3052 n.setName( "B0LM41_HUMAN" );
3053 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3056 n.setName( "NP_001025424" );
3057 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3060 n.setName( "_NM_001030253-" );
3061 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3064 n.setName( "XM_002122186" );
3065 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3068 n.setName( "dgh_AAA34956_gdg" );
3069 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3072 n.setName( "AAA34956" );
3073 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3076 n.setName( "GI:394892" );
3077 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3078 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3081 n.setName( "gi_394892" );
3082 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3083 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3086 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3087 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3088 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3091 n.setName( "P12345" );
3092 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3093 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3096 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3097 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3098 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3102 catch ( final Exception e ) {
3103 e.printStackTrace( System.out );
3109 private static boolean testDataObjects() {
3111 final Confidence s0 = new Confidence();
3112 final Confidence s1 = new Confidence();
3113 if ( !s0.isEqual( s1 ) ) {
3116 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3117 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3118 if ( s2.isEqual( s1 ) ) {
3121 if ( !s2.isEqual( s3 ) ) {
3124 final Confidence s4 = ( Confidence ) s3.copy();
3125 if ( !s4.isEqual( s3 ) ) {
3132 final Taxonomy t1 = new Taxonomy();
3133 final Taxonomy t2 = new Taxonomy();
3134 final Taxonomy t3 = new Taxonomy();
3135 final Taxonomy t4 = new Taxonomy();
3136 final Taxonomy t5 = new Taxonomy();
3137 t1.setIdentifier( new Identifier( "ecoli" ) );
3138 t1.setTaxonomyCode( "ECOLI" );
3139 t1.setScientificName( "E. coli" );
3140 t1.setCommonName( "coli" );
3141 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3142 if ( !t1.isEqual( t0 ) ) {
3145 t2.setIdentifier( new Identifier( "ecoli" ) );
3146 t2.setTaxonomyCode( "OTHER" );
3147 t2.setScientificName( "what" );
3148 t2.setCommonName( "something" );
3149 if ( !t1.isEqual( t2 ) ) {
3152 t2.setIdentifier( new Identifier( "nemve" ) );
3153 if ( t1.isEqual( t2 ) ) {
3156 t1.setIdentifier( null );
3157 t3.setTaxonomyCode( "ECOLI" );
3158 t3.setScientificName( "what" );
3159 t3.setCommonName( "something" );
3160 if ( !t1.isEqual( t3 ) ) {
3163 t1.setIdentifier( null );
3164 t1.setTaxonomyCode( "" );
3165 t4.setScientificName( "E. ColI" );
3166 t4.setCommonName( "something" );
3167 if ( !t1.isEqual( t4 ) ) {
3170 t4.setScientificName( "B. subtilis" );
3171 t4.setCommonName( "something" );
3172 if ( t1.isEqual( t4 ) ) {
3175 t1.setIdentifier( null );
3176 t1.setTaxonomyCode( "" );
3177 t1.setScientificName( "" );
3178 t5.setCommonName( "COLI" );
3179 if ( !t1.isEqual( t5 ) ) {
3182 t5.setCommonName( "vibrio" );
3183 if ( t1.isEqual( t5 ) ) {
3188 final Identifier id0 = new Identifier( "123", "pfam" );
3189 final Identifier id1 = ( Identifier ) id0.copy();
3190 if ( !id1.isEqual( id1 ) ) {
3193 if ( !id1.isEqual( id0 ) ) {
3196 if ( !id0.isEqual( id1 ) ) {
3203 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3204 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3205 if ( !pd1.isEqual( pd1 ) ) {
3208 if ( !pd1.isEqual( pd0 ) ) {
3213 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3214 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3215 if ( !pd3.isEqual( pd3 ) ) {
3218 if ( !pd2.isEqual( pd3 ) ) {
3221 if ( !pd0.isEqual( pd3 ) ) {
3226 // DomainArchitecture
3227 // ------------------
3228 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3229 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3230 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3231 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3232 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3233 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3238 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3239 if ( ds0.getNumberOfDomains() != 4 ) {
3242 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3243 if ( !ds0.isEqual( ds0 ) ) {
3246 if ( !ds0.isEqual( ds1 ) ) {
3249 if ( ds1.getNumberOfDomains() != 4 ) {
3252 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3257 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3258 if ( ds0.isEqual( ds2 ) ) {
3264 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3265 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3266 System.out.println( ds3.toNHX() );
3269 if ( ds3.getNumberOfDomains() != 3 ) {
3274 final Event e1 = new Event( Event.EventType.fusion );
3275 if ( e1.isDuplication() ) {
3278 if ( !e1.isFusion() ) {
3281 if ( !e1.asText().toString().equals( "fusion" ) ) {
3284 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3287 final Event e11 = new Event( Event.EventType.fusion );
3288 if ( !e11.isEqual( e1 ) ) {
3291 if ( !e11.toNHX().toString().equals( "" ) ) {
3294 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3295 if ( e2.isDuplication() ) {
3298 if ( !e2.isSpeciationOrDuplication() ) {
3301 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3304 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3307 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3310 if ( e11.isEqual( e2 ) ) {
3313 final Event e2c = ( Event ) e2.copy();
3314 if ( !e2c.isEqual( e2 ) ) {
3317 Event e3 = new Event( 1, 2, 3 );
3318 if ( e3.isDuplication() ) {
3321 if ( e3.isSpeciation() ) {
3324 if ( e3.isGeneLoss() ) {
3327 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3330 final Event e3c = ( Event ) e3.copy();
3331 final Event e3cc = ( Event ) e3c.copy();
3332 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3336 if ( !e3c.isEqual( e3cc ) ) {
3339 Event e4 = new Event( 1, 2, 3 );
3340 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3343 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3346 final Event e4c = ( Event ) e4.copy();
3348 final Event e4cc = ( Event ) e4c.copy();
3349 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3352 if ( !e4c.isEqual( e4cc ) ) {
3355 final Event e5 = new Event();
3356 if ( !e5.isUnassigned() ) {
3359 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3362 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3365 final Event e6 = new Event( 1, 0, 0 );
3366 if ( !e6.asText().toString().equals( "duplication" ) ) {
3369 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3372 final Event e7 = new Event( 0, 1, 0 );
3373 if ( !e7.asText().toString().equals( "speciation" ) ) {
3376 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3379 final Event e8 = new Event( 0, 0, 1 );
3380 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3383 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3387 catch ( final Exception e ) {
3388 e.printStackTrace( System.out );
3394 private static boolean testDeletionOfExternalNodes() {
3396 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3397 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3398 final PhylogenyWriter w = new PhylogenyWriter();
3399 if ( t0.isEmpty() ) {
3402 if ( t0.getNumberOfExternalNodes() != 1 ) {
3405 t0.deleteSubtree( t0.getNode( "A" ), false );
3406 if ( t0.getNumberOfExternalNodes() != 0 ) {
3409 if ( !t0.isEmpty() ) {
3412 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3413 if ( t1.getNumberOfExternalNodes() != 2 ) {
3416 t1.deleteSubtree( t1.getNode( "A" ), false );
3417 if ( t1.getNumberOfExternalNodes() != 1 ) {
3420 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3423 t1.deleteSubtree( t1.getNode( "B" ), false );
3424 if ( t1.getNumberOfExternalNodes() != 1 ) {
3427 t1.deleteSubtree( t1.getNode( "r" ), false );
3428 if ( !t1.isEmpty() ) {
3431 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3432 if ( t2.getNumberOfExternalNodes() != 3 ) {
3435 t2.deleteSubtree( t2.getNode( "B" ), false );
3436 if ( t2.getNumberOfExternalNodes() != 2 ) {
3439 t2.toNewHampshireX();
3440 PhylogenyNode n = t2.getNode( "A" );
3441 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3444 t2.deleteSubtree( t2.getNode( "A" ), false );
3445 if ( t2.getNumberOfExternalNodes() != 2 ) {
3448 t2.deleteSubtree( t2.getNode( "C" ), true );
3449 if ( t2.getNumberOfExternalNodes() != 1 ) {
3452 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3453 if ( t3.getNumberOfExternalNodes() != 4 ) {
3456 t3.deleteSubtree( t3.getNode( "B" ), true );
3457 if ( t3.getNumberOfExternalNodes() != 3 ) {
3460 n = t3.getNode( "A" );
3461 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3464 n = n.getNextExternalNode();
3465 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3468 t3.deleteSubtree( t3.getNode( "A" ), true );
3469 if ( t3.getNumberOfExternalNodes() != 2 ) {
3472 n = t3.getNode( "C" );
3473 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3476 t3.deleteSubtree( t3.getNode( "C" ), true );
3477 if ( t3.getNumberOfExternalNodes() != 1 ) {
3480 t3.deleteSubtree( t3.getNode( "D" ), true );
3481 if ( t3.getNumberOfExternalNodes() != 0 ) {
3484 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3485 if ( t4.getNumberOfExternalNodes() != 6 ) {
3488 t4.deleteSubtree( t4.getNode( "B2" ), true );
3489 if ( t4.getNumberOfExternalNodes() != 5 ) {
3492 String s = w.toNewHampshire( t4, true ).toString();
3493 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3496 t4.deleteSubtree( t4.getNode( "B11" ), true );
3497 if ( t4.getNumberOfExternalNodes() != 4 ) {
3500 t4.deleteSubtree( t4.getNode( "C" ), true );
3501 if ( t4.getNumberOfExternalNodes() != 3 ) {
3504 n = t4.getNode( "A" );
3505 n = n.getNextExternalNode();
3506 if ( !n.getName().equals( "B12" ) ) {
3509 n = n.getNextExternalNode();
3510 if ( !n.getName().equals( "D" ) ) {
3513 s = w.toNewHampshire( t4, true ).toString();
3514 if ( !s.equals( "((A,B12),D);" ) ) {
3517 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3518 t5.deleteSubtree( t5.getNode( "A" ), true );
3519 if ( t5.getNumberOfExternalNodes() != 5 ) {
3522 s = w.toNewHampshire( t5, true ).toString();
3523 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3526 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3527 t6.deleteSubtree( t6.getNode( "B11" ), true );
3528 if ( t6.getNumberOfExternalNodes() != 5 ) {
3531 s = w.toNewHampshire( t6, false ).toString();
3532 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3535 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3536 t7.deleteSubtree( t7.getNode( "B12" ), true );
3537 if ( t7.getNumberOfExternalNodes() != 5 ) {
3540 s = w.toNewHampshire( t7, true ).toString();
3541 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3544 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3545 t8.deleteSubtree( t8.getNode( "B2" ), true );
3546 if ( t8.getNumberOfExternalNodes() != 5 ) {
3549 s = w.toNewHampshire( t8, false ).toString();
3550 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3553 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3554 t9.deleteSubtree( t9.getNode( "C" ), true );
3555 if ( t9.getNumberOfExternalNodes() != 5 ) {
3558 s = w.toNewHampshire( t9, true ).toString();
3559 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3562 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3563 t10.deleteSubtree( t10.getNode( "D" ), true );
3564 if ( t10.getNumberOfExternalNodes() != 5 ) {
3567 s = w.toNewHampshire( t10, true ).toString();
3568 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3571 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3572 t11.deleteSubtree( t11.getNode( "A" ), true );
3573 if ( t11.getNumberOfExternalNodes() != 2 ) {
3576 s = w.toNewHampshire( t11, true ).toString();
3577 if ( !s.equals( "(B,C);" ) ) {
3580 t11.deleteSubtree( t11.getNode( "C" ), true );
3581 if ( t11.getNumberOfExternalNodes() != 1 ) {
3584 s = w.toNewHampshire( t11, false ).toString();
3585 if ( !s.equals( "B;" ) ) {
3588 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3589 t12.deleteSubtree( t12.getNode( "B2" ), true );
3590 if ( t12.getNumberOfExternalNodes() != 8 ) {
3593 s = w.toNewHampshire( t12, true ).toString();
3594 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3597 t12.deleteSubtree( t12.getNode( "B3" ), true );
3598 if ( t12.getNumberOfExternalNodes() != 7 ) {
3601 s = w.toNewHampshire( t12, true ).toString();
3602 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3605 t12.deleteSubtree( t12.getNode( "C3" ), true );
3606 if ( t12.getNumberOfExternalNodes() != 6 ) {
3609 s = w.toNewHampshire( t12, true ).toString();
3610 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3613 t12.deleteSubtree( t12.getNode( "A1" ), true );
3614 if ( t12.getNumberOfExternalNodes() != 5 ) {
3617 s = w.toNewHampshire( t12, true ).toString();
3618 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3621 t12.deleteSubtree( t12.getNode( "B1" ), true );
3622 if ( t12.getNumberOfExternalNodes() != 4 ) {
3625 s = w.toNewHampshire( t12, true ).toString();
3626 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3629 t12.deleteSubtree( t12.getNode( "A3" ), true );
3630 if ( t12.getNumberOfExternalNodes() != 3 ) {
3633 s = w.toNewHampshire( t12, true ).toString();
3634 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3637 t12.deleteSubtree( t12.getNode( "A2" ), true );
3638 if ( t12.getNumberOfExternalNodes() != 2 ) {
3641 s = w.toNewHampshire( t12, true ).toString();
3642 if ( !s.equals( "(C1,C2);" ) ) {
3645 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3646 t13.deleteSubtree( t13.getNode( "D" ), true );
3647 if ( t13.getNumberOfExternalNodes() != 4 ) {
3650 s = w.toNewHampshire( t13, true ).toString();
3651 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3654 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3655 t14.deleteSubtree( t14.getNode( "E" ), true );
3656 if ( t14.getNumberOfExternalNodes() != 5 ) {
3659 s = w.toNewHampshire( t14, true ).toString();
3660 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3663 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3664 t15.deleteSubtree( t15.getNode( "B2" ), true );
3665 if ( t15.getNumberOfExternalNodes() != 11 ) {
3668 t15.deleteSubtree( t15.getNode( "B1" ), true );
3669 if ( t15.getNumberOfExternalNodes() != 10 ) {
3672 t15.deleteSubtree( t15.getNode( "B3" ), true );
3673 if ( t15.getNumberOfExternalNodes() != 9 ) {
3676 t15.deleteSubtree( t15.getNode( "B4" ), true );
3677 if ( t15.getNumberOfExternalNodes() != 8 ) {
3680 t15.deleteSubtree( t15.getNode( "A1" ), true );
3681 if ( t15.getNumberOfExternalNodes() != 7 ) {
3684 t15.deleteSubtree( t15.getNode( "C4" ), true );
3685 if ( t15.getNumberOfExternalNodes() != 6 ) {
3689 catch ( final Exception e ) {
3690 e.printStackTrace( System.out );
3696 private static boolean testDescriptiveStatistics() {
3698 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3699 dss1.addValue( 82 );
3700 dss1.addValue( 78 );
3701 dss1.addValue( 70 );
3702 dss1.addValue( 58 );
3703 dss1.addValue( 42 );
3704 if ( dss1.getN() != 5 ) {
3707 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3710 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3713 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3716 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3719 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3722 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3725 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3728 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3731 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3734 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3737 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3740 dss1.addValue( 123 );
3741 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3744 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3747 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3750 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3751 dss2.addValue( -1.85 );
3752 dss2.addValue( 57.5 );
3753 dss2.addValue( 92.78 );
3754 dss2.addValue( 57.78 );
3755 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3758 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3761 final double[] a = dss2.getDataAsDoubleArray();
3762 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3765 dss2.addValue( -100 );
3766 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3769 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3772 final double[] ds = new double[ 14 ];
3787 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3788 if ( bins.length != 4 ) {
3791 if ( bins[ 0 ] != 2 ) {
3794 if ( bins[ 1 ] != 3 ) {
3797 if ( bins[ 2 ] != 4 ) {
3800 if ( bins[ 3 ] != 5 ) {
3803 final double[] ds1 = new double[ 9 ];
3813 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3814 if ( bins1.length != 4 ) {
3817 if ( bins1[ 0 ] != 2 ) {
3820 if ( bins1[ 1 ] != 3 ) {
3823 if ( bins1[ 2 ] != 0 ) {
3826 if ( bins1[ 3 ] != 4 ) {
3829 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3830 if ( bins1_1.length != 3 ) {
3833 if ( bins1_1[ 0 ] != 3 ) {
3836 if ( bins1_1[ 1 ] != 2 ) {
3839 if ( bins1_1[ 2 ] != 4 ) {
3842 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3843 if ( bins1_2.length != 3 ) {
3846 if ( bins1_2[ 0 ] != 2 ) {
3849 if ( bins1_2[ 1 ] != 2 ) {
3852 if ( bins1_2[ 2 ] != 2 ) {
3855 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3869 dss3.addValue( 10 );
3870 dss3.addValue( 10 );
3871 dss3.addValue( 10 );
3872 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3873 histo.toStringBuffer( 10, '=', 40, 5 );
3874 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3876 catch ( final Exception e ) {
3877 e.printStackTrace( System.out );
3883 private static boolean testDir( final String file ) {
3885 final File f = new File( file );
3886 if ( !f.exists() ) {
3889 if ( !f.isDirectory() ) {
3892 if ( !f.canRead() ) {
3896 catch ( final Exception e ) {
3902 private static boolean testEbiEntryRetrieval() {
3904 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3905 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3906 System.out.println( entry.getAccession() );
3909 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3910 System.out.println( entry.getTaxonomyScientificName() );
3913 if ( !entry.getSequenceName()
3914 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3915 System.out.println( entry.getSequenceName() );
3918 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3919 // System.out.println( entry.getSequenceSymbol() );
3922 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3923 System.out.println( entry.getGeneName() );
3926 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
3927 System.out.println( entry.getTaxonomyIdentifier() );
3930 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
3931 System.out.println( entry.getAnnotations().first().getRefValue() );
3934 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
3935 System.out.println( entry.getAnnotations().first().getRefSource() );
3938 if ( entry.getCrossReferences().size() != 5 ) {
3942 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
3943 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
3946 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
3947 System.out.println( entry1.getTaxonomyScientificName() );
3950 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
3951 System.out.println( entry1.getSequenceName() );
3954 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
3955 System.out.println( entry1.getTaxonomyIdentifier() );
3958 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
3959 System.out.println( entry1.getGeneName() );
3962 if ( entry1.getCrossReferences().size() != 6 ) {
3966 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
3967 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
3970 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
3971 System.out.println( entry2.getTaxonomyScientificName() );
3974 if ( !entry2.getSequenceName()
3975 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
3976 System.out.println( entry2.getSequenceName() );
3979 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
3980 System.out.println( entry2.getTaxonomyIdentifier() );
3983 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
3984 System.out.println( entry2.getGeneName() );
3987 if ( entry2.getCrossReferences().size() != 3 ) {
3991 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
3992 if ( !entry3.getAccession().equals( "HM043801" ) ) {
3995 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
3996 System.out.println( entry3.getTaxonomyScientificName() );
3999 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4000 System.out.println( entry3.getSequenceName() );
4003 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4004 System.out.println( entry3.getTaxonomyIdentifier() );
4007 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4008 System.out.println( entry3.getSequenceSymbol() );
4011 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4014 if ( entry3.getCrossReferences().size() != 8 ) {
4019 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4020 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4023 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4024 System.out.println( entry4.getTaxonomyScientificName() );
4027 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4028 System.out.println( entry4.getSequenceName() );
4031 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4032 System.out.println( entry4.getTaxonomyIdentifier() );
4035 if ( !entry4.getGeneName().equals( "ras" ) ) {
4036 System.out.println( entry4.getGeneName() );
4039 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4040 // System.out.println( entry4.getChromosome() );
4043 // if ( !entry4.getMap().equals( "ras" ) ) {
4044 // System.out.println( entry4.getMap() );
4050 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4051 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4054 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4055 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4058 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4059 System.out.println( entry5.getTaxonomyScientificName() );
4062 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4063 System.out.println( entry5.getSequenceName() );
4066 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4067 System.out.println( entry5.getTaxonomyIdentifier() );
4071 catch ( final IOException e ) {
4072 System.out.println();
4073 System.out.println( "the following might be due to absence internet connection:" );
4074 e.printStackTrace( System.out );
4077 catch ( final Exception e ) {
4078 e.printStackTrace();
4084 private static boolean testExternalNodeRelatedMethods() {
4086 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4087 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4088 PhylogenyNode n = t1.getNode( "A" );
4089 n = n.getNextExternalNode();
4090 if ( !n.getName().equals( "B" ) ) {
4093 n = n.getNextExternalNode();
4094 if ( !n.getName().equals( "C" ) ) {
4097 n = n.getNextExternalNode();
4098 if ( !n.getName().equals( "D" ) ) {
4101 n = t1.getNode( "B" );
4102 while ( !n.isLastExternalNode() ) {
4103 n = n.getNextExternalNode();
4105 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4106 n = t2.getNode( "A" );
4107 n = n.getNextExternalNode();
4108 if ( !n.getName().equals( "B" ) ) {
4111 n = n.getNextExternalNode();
4112 if ( !n.getName().equals( "C" ) ) {
4115 n = n.getNextExternalNode();
4116 if ( !n.getName().equals( "D" ) ) {
4119 n = t2.getNode( "B" );
4120 while ( !n.isLastExternalNode() ) {
4121 n = n.getNextExternalNode();
4123 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4124 n = t3.getNode( "A" );
4125 n = n.getNextExternalNode();
4126 if ( !n.getName().equals( "B" ) ) {
4129 n = n.getNextExternalNode();
4130 if ( !n.getName().equals( "C" ) ) {
4133 n = n.getNextExternalNode();
4134 if ( !n.getName().equals( "D" ) ) {
4137 n = n.getNextExternalNode();
4138 if ( !n.getName().equals( "E" ) ) {
4141 n = n.getNextExternalNode();
4142 if ( !n.getName().equals( "F" ) ) {
4145 n = n.getNextExternalNode();
4146 if ( !n.getName().equals( "G" ) ) {
4149 n = n.getNextExternalNode();
4150 if ( !n.getName().equals( "H" ) ) {
4153 n = t3.getNode( "B" );
4154 while ( !n.isLastExternalNode() ) {
4155 n = n.getNextExternalNode();
4157 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4158 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4159 final PhylogenyNode node = iter.next();
4161 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4162 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4163 final PhylogenyNode node = iter.next();
4165 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4166 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4167 if ( !iter.next().getName().equals( "A" ) ) {
4170 if ( !iter.next().getName().equals( "B" ) ) {
4173 if ( !iter.next().getName().equals( "C" ) ) {
4176 if ( !iter.next().getName().equals( "D" ) ) {
4179 if ( !iter.next().getName().equals( "E" ) ) {
4182 if ( !iter.next().getName().equals( "F" ) ) {
4185 if ( iter.hasNext() ) {
4189 catch ( final Exception e ) {
4190 e.printStackTrace( System.out );
4196 private static boolean testExtractSNFromNodeName() {
4198 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4201 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4204 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4207 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4208 .equals( "Mus musculus musculus" ) ) {
4211 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4212 .equals( "Mus musculus musculus" ) ) {
4215 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4216 .equals( "Mus musculus musculus" ) ) {
4219 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4220 .equals( "Mus musculus musculus" ) ) {
4223 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4226 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4227 .equals( "Mus musculus musculus" ) ) {
4230 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4231 .equals( "Mus musculus musculus" ) ) {
4234 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4237 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4240 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4243 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4246 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4247 .equals( "Mus musculus musculus" ) ) {
4250 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4253 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4256 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4259 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4262 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4265 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4268 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4271 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4274 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4275 .equals( "Mus musculus" ) ) {
4278 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4279 .equals( "Mus musculus" ) ) {
4282 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4285 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4286 .equals( "Mus musculus musculus" ) ) {
4289 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4290 .equals( "Mus musculus musculus" ) ) {
4293 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4294 .equals( "Mus musculus musculus" ) ) {
4297 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4300 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4301 .equals( "Pilostyles mexicana" ) ) {
4304 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4305 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4308 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4309 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4312 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4313 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4316 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4317 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4320 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4321 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4324 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4325 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4328 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4329 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4332 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4333 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4336 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4337 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4340 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4341 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4344 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4345 .equals( "Escherichia coli (strain K12)" ) ) {
4348 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4349 .equals( "Escherichia coli (strain K12)" ) ) {
4352 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4353 .equals( "Escherichia coli (str. K12)" ) ) {
4356 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4357 .equals( "Escherichia coli (str. K12)" ) ) {
4360 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4361 .equals( "Escherichia coli (str. K12)" ) ) {
4364 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4365 .equals( "Escherichia coli (var. K12)" ) ) {
4368 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4369 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4372 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4373 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4377 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4378 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4381 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4382 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4386 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4387 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4390 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4391 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4394 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4395 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4398 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4401 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4404 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4407 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4408 .equals( "Macrocera sp." ) ) {
4411 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4414 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4415 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4418 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4419 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4422 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4423 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4426 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4427 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4431 catch ( final Exception e ) {
4432 e.printStackTrace( System.out );
4438 private static boolean testExtractTaxonomyCodeFromNodeName() {
4440 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4443 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4444 .equals( "SOYBN" ) ) {
4447 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4448 .equals( "ARATH" ) ) {
4451 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4452 .equals( "ARATH" ) ) {
4455 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4458 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4461 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4464 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4465 .equals( "SOYBN" ) ) {
4468 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4469 .equals( "SOYBN" ) ) {
4472 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4473 .equals( "SOYBN" ) ) {
4476 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4477 .equals( "SOYBN" ) ) {
4480 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4481 .equals( "SOYBN" ) ) {
4484 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4485 .equals( "SOYBN" ) ) {
4488 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4489 .equals( "SOYBN" ) ) {
4492 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4493 .equals( "SOYBN" ) ) {
4496 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4499 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4500 .equals( "SOYBN" ) ) {
4503 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4504 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4507 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4508 .equals( "9YX45" ) ) {
4511 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4512 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4513 .equals( "MOUSE" ) ) {
4516 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4517 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4518 .equals( "MOUSE" ) ) {
4521 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4522 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4523 .equals( "MOUSE" ) ) {
4526 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4527 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4530 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4531 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4534 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4535 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4538 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4539 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4542 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4543 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4546 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4547 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4550 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4551 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4554 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4555 .equals( "RAT" ) ) {
4558 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4559 .equals( "PIG" ) ) {
4563 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4564 .equals( "MOUSE" ) ) {
4567 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4568 .equals( "MOUSE" ) ) {
4571 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4575 catch ( final Exception e ) {
4576 e.printStackTrace( System.out );
4582 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4584 PhylogenyNode n = new PhylogenyNode();
4585 n.setName( "tr|B3RJ64" );
4586 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4589 n.setName( "tr.B3RJ64" );
4590 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4593 n.setName( "tr=B3RJ64" );
4594 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4597 n.setName( "tr-B3RJ64" );
4598 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4601 n.setName( "tr/B3RJ64" );
4602 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4605 n.setName( "tr\\B3RJ64" );
4606 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4609 n.setName( "tr_B3RJ64" );
4610 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4613 n.setName( " tr|B3RJ64 " );
4614 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4617 n.setName( "-tr|B3RJ64-" );
4618 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4621 n.setName( "-tr=B3RJ64-" );
4622 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4625 n.setName( "_tr=B3RJ64_" );
4626 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4629 n.setName( " tr_tr|B3RJ64_sp|123 " );
4630 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4633 n.setName( "B3RJ64" );
4634 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4637 n.setName( "sp|B3RJ64" );
4638 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4641 n.setName( "sp|B3RJ64C" );
4642 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4645 n.setName( "sp B3RJ64" );
4646 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4649 n.setName( "sp|B3RJ6X" );
4650 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4653 n.setName( "sp|B3RJ6" );
4654 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4657 n.setName( "K1PYK7_CRAGI" );
4658 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4661 n.setName( "K1PYK7_PEA" );
4662 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4665 n.setName( "K1PYK7_RAT" );
4666 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4669 n.setName( "K1PYK7_PIG" );
4670 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4673 n.setName( "~K1PYK7_PIG~" );
4674 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4677 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4678 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4681 n.setName( "K1PYKX_CRAGI" );
4682 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4685 n.setName( "XXXXX_CRAGI" );
4686 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4689 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4690 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4693 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4694 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4697 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4698 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4701 n = new PhylogenyNode();
4702 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4703 seq.setSymbol( "K1PYK7_CRAGI" );
4704 n.getNodeData().addSequence( seq );
4705 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4708 seq.setSymbol( "tr|B3RJ64" );
4709 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4712 n = new PhylogenyNode();
4713 seq = new org.forester.phylogeny.data.Sequence();
4714 seq.setName( "K1PYK7_CRAGI" );
4715 n.getNodeData().addSequence( seq );
4716 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4719 seq.setName( "tr|B3RJ64" );
4720 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4723 n = new PhylogenyNode();
4724 seq = new org.forester.phylogeny.data.Sequence();
4725 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4726 n.getNodeData().addSequence( seq );
4727 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4730 n = new PhylogenyNode();
4731 seq = new org.forester.phylogeny.data.Sequence();
4732 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4733 n.getNodeData().addSequence( seq );
4734 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4738 n = new PhylogenyNode();
4739 n.setName( "ACP19736" );
4740 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4743 n = new PhylogenyNode();
4744 n.setName( "|ACP19736|" );
4745 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4749 catch ( final Exception e ) {
4750 e.printStackTrace( System.out );
4756 private static boolean testFastaParser() {
4758 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4761 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4764 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4765 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4768 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4771 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4774 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4777 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4780 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4784 catch ( final Exception e ) {
4785 e.printStackTrace();
4791 private static boolean testGenbankAccessorParsing() {
4792 //The format for GenBank Accession numbers are:
4793 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4794 //Protein: 3 letters + 5 numerals
4795 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4796 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4799 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4802 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4805 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4808 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4811 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4814 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4817 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4820 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4823 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4826 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4829 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4832 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4835 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4841 private static boolean testGeneralMsaParser() {
4843 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4844 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4845 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4846 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4847 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4848 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4849 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4850 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4851 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4854 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4857 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4860 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4863 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4866 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4869 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4872 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4875 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4878 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4881 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4884 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4887 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4888 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4891 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4894 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4897 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4898 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4901 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4904 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4907 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4908 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4911 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4914 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4918 catch ( final Exception e ) {
4919 e.printStackTrace();
4925 private static boolean testGeneralTable() {
4927 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
4928 t0.setValue( 3, 2, "23" );
4929 t0.setValue( 10, 1, "error" );
4930 t0.setValue( 10, 1, "110" );
4931 t0.setValue( 9, 1, "19" );
4932 t0.setValue( 1, 10, "101" );
4933 t0.setValue( 10, 10, "1010" );
4934 t0.setValue( 100, 10, "10100" );
4935 t0.setValue( 0, 0, "00" );
4936 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
4939 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
4942 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
4945 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
4948 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
4951 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
4954 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
4957 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
4960 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
4963 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
4964 t1.setValue( "3", "2", "23" );
4965 t1.setValue( "10", "1", "error" );
4966 t1.setValue( "10", "1", "110" );
4967 t1.setValue( "9", "1", "19" );
4968 t1.setValue( "1", "10", "101" );
4969 t1.setValue( "10", "10", "1010" );
4970 t1.setValue( "100", "10", "10100" );
4971 t1.setValue( "0", "0", "00" );
4972 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
4973 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
4976 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
4979 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
4982 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
4985 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
4988 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
4991 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
4994 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
4997 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5000 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5004 catch ( final Exception e ) {
5005 e.printStackTrace( System.out );
5011 private static boolean testGetDistance() {
5013 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5014 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",
5015 new NHXParser() )[ 0 ];
5016 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5019 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5022 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5025 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5028 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5031 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5034 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5037 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5040 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5043 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5046 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5049 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5052 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5055 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5058 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5061 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5064 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5067 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5070 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5073 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5076 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5079 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5082 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5085 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5088 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5100 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5103 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5106 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5109 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",
5110 new NHXParser() )[ 0 ];
5111 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5114 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5117 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5120 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5123 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5126 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5129 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5132 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5135 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5138 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5141 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5145 catch ( final Exception e ) {
5146 e.printStackTrace( System.out );
5152 private static boolean testGetLCA() {
5154 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5155 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5156 new NHXParser() )[ 0 ];
5157 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5158 if ( !A.getName().equals( "A" ) ) {
5161 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5162 if ( !gh.getName().equals( "gh" ) ) {
5165 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5166 if ( !ab.getName().equals( "ab" ) ) {
5169 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5170 if ( !ab2.getName().equals( "ab" ) ) {
5173 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5174 if ( !gh2.getName().equals( "gh" ) ) {
5177 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5178 if ( !gh3.getName().equals( "gh" ) ) {
5181 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5182 if ( !abc.getName().equals( "abc" ) ) {
5185 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5186 if ( !abc2.getName().equals( "abc" ) ) {
5189 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5190 if ( !abcd.getName().equals( "abcd" ) ) {
5193 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5194 if ( !abcd2.getName().equals( "abcd" ) ) {
5197 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5198 if ( !abcdef.getName().equals( "abcdef" ) ) {
5201 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5202 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5205 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5206 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5209 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5210 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5213 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5214 if ( !abcde.getName().equals( "abcde" ) ) {
5217 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5218 if ( !abcde2.getName().equals( "abcde" ) ) {
5221 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5222 if ( !r.getName().equals( "abcdefgh" ) ) {
5225 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5226 if ( !r2.getName().equals( "abcdefgh" ) ) {
5229 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5230 if ( !r3.getName().equals( "abcdefgh" ) ) {
5233 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5234 if ( !abcde3.getName().equals( "abcde" ) ) {
5237 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5238 if ( !abcde4.getName().equals( "abcde" ) ) {
5241 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5242 if ( !ab3.getName().equals( "ab" ) ) {
5245 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5246 if ( !ab4.getName().equals( "ab" ) ) {
5249 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5250 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5251 if ( !cd.getName().equals( "cd" ) ) {
5254 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5255 if ( !cd2.getName().equals( "cd" ) ) {
5258 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5259 if ( !cde.getName().equals( "cde" ) ) {
5262 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5263 if ( !cde2.getName().equals( "cde" ) ) {
5266 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5267 if ( !cdef.getName().equals( "cdef" ) ) {
5270 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5271 if ( !cdef2.getName().equals( "cdef" ) ) {
5274 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5275 if ( !cdef3.getName().equals( "cdef" ) ) {
5278 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5279 if ( !rt.getName().equals( "r" ) ) {
5282 final Phylogeny p3 = factory
5283 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5284 new NHXParser() )[ 0 ];
5285 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5286 if ( !bc_3.getName().equals( "bc" ) ) {
5289 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5290 if ( !ac_3.getName().equals( "abc" ) ) {
5293 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5294 if ( !ad_3.getName().equals( "abcde" ) ) {
5297 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5298 if ( !af_3.getName().equals( "abcdef" ) ) {
5301 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5302 if ( !ag_3.getName().equals( "" ) ) {
5305 if ( !ag_3.isRoot() ) {
5308 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5309 if ( !al_3.getName().equals( "" ) ) {
5312 if ( !al_3.isRoot() ) {
5315 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5316 if ( !kl_3.getName().equals( "" ) ) {
5319 if ( !kl_3.isRoot() ) {
5322 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5323 if ( !fl_3.getName().equals( "" ) ) {
5326 if ( !fl_3.isRoot() ) {
5329 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5330 if ( !gk_3.getName().equals( "ghijk" ) ) {
5333 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5334 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5335 if ( !r_4.getName().equals( "r" ) ) {
5338 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5339 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5340 if ( !r_5.getName().equals( "root" ) ) {
5343 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5344 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5345 if ( !r_6.getName().equals( "rot" ) ) {
5348 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5349 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5350 if ( !r_7.getName().equals( "rott" ) ) {
5354 catch ( final Exception e ) {
5355 e.printStackTrace( System.out );
5361 private static boolean testGetLCA2() {
5363 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5364 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5365 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5366 PhylogenyMethods.preOrderReId( p_a );
5367 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5368 p_a.getNode( "a" ) );
5369 if ( !p_a_1.getName().equals( "a" ) ) {
5372 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5373 PhylogenyMethods.preOrderReId( p_b );
5374 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5375 p_b.getNode( "a" ) );
5376 if ( !p_b_1.getName().equals( "b" ) ) {
5379 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5380 p_b.getNode( "b" ) );
5381 if ( !p_b_2.getName().equals( "b" ) ) {
5384 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5385 PhylogenyMethods.preOrderReId( p_c );
5386 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5387 p_c.getNode( "a" ) );
5388 if ( !p_c_1.getName().equals( "b" ) ) {
5391 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5392 p_c.getNode( "c" ) );
5393 if ( !p_c_2.getName().equals( "c" ) ) {
5394 System.out.println( p_c_2.getName() );
5398 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5399 p_c.getNode( "b" ) );
5400 if ( !p_c_3.getName().equals( "b" ) ) {
5403 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5404 p_c.getNode( "a" ) );
5405 if ( !p_c_4.getName().equals( "c" ) ) {
5408 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5409 new NHXParser() )[ 0 ];
5410 PhylogenyMethods.preOrderReId( p1 );
5411 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5412 p1.getNode( "A" ) );
5413 if ( !A.getName().equals( "A" ) ) {
5416 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5417 p1.getNode( "gh" ) );
5418 if ( !gh.getName().equals( "gh" ) ) {
5421 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5422 p1.getNode( "B" ) );
5423 if ( !ab.getName().equals( "ab" ) ) {
5426 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5427 p1.getNode( "A" ) );
5428 if ( !ab2.getName().equals( "ab" ) ) {
5431 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5432 p1.getNode( "G" ) );
5433 if ( !gh2.getName().equals( "gh" ) ) {
5436 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5437 p1.getNode( "H" ) );
5438 if ( !gh3.getName().equals( "gh" ) ) {
5441 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5442 p1.getNode( "A" ) );
5443 if ( !abc.getName().equals( "abc" ) ) {
5446 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5447 p1.getNode( "C" ) );
5448 if ( !abc2.getName().equals( "abc" ) ) {
5451 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5452 p1.getNode( "D" ) );
5453 if ( !abcd.getName().equals( "abcd" ) ) {
5456 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5457 p1.getNode( "A" ) );
5458 if ( !abcd2.getName().equals( "abcd" ) ) {
5461 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5462 p1.getNode( "F" ) );
5463 if ( !abcdef.getName().equals( "abcdef" ) ) {
5466 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5467 p1.getNode( "A" ) );
5468 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5471 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5472 p1.getNode( "F" ) );
5473 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5476 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5477 p1.getNode( "ab" ) );
5478 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5481 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5482 p1.getNode( "E" ) );
5483 if ( !abcde.getName().equals( "abcde" ) ) {
5486 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5487 p1.getNode( "A" ) );
5488 if ( !abcde2.getName().equals( "abcde" ) ) {
5491 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5492 p1.getNode( "abcdefgh" ) );
5493 if ( !r.getName().equals( "abcdefgh" ) ) {
5496 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5497 p1.getNode( "H" ) );
5498 if ( !r2.getName().equals( "abcdefgh" ) ) {
5501 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5502 p1.getNode( "A" ) );
5503 if ( !r3.getName().equals( "abcdefgh" ) ) {
5506 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5507 p1.getNode( "abcde" ) );
5508 if ( !abcde3.getName().equals( "abcde" ) ) {
5511 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5512 p1.getNode( "E" ) );
5513 if ( !abcde4.getName().equals( "abcde" ) ) {
5516 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5517 p1.getNode( "B" ) );
5518 if ( !ab3.getName().equals( "ab" ) ) {
5521 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5522 p1.getNode( "ab" ) );
5523 if ( !ab4.getName().equals( "ab" ) ) {
5526 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5527 PhylogenyMethods.preOrderReId( p2 );
5528 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5529 p2.getNode( "d" ) );
5530 if ( !cd.getName().equals( "cd" ) ) {
5533 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5534 p2.getNode( "c" ) );
5535 if ( !cd2.getName().equals( "cd" ) ) {
5538 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5539 p2.getNode( "e" ) );
5540 if ( !cde.getName().equals( "cde" ) ) {
5543 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5544 p2.getNode( "c" ) );
5545 if ( !cde2.getName().equals( "cde" ) ) {
5548 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5549 p2.getNode( "f" ) );
5550 if ( !cdef.getName().equals( "cdef" ) ) {
5553 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5554 p2.getNode( "f" ) );
5555 if ( !cdef2.getName().equals( "cdef" ) ) {
5558 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5559 p2.getNode( "d" ) );
5560 if ( !cdef3.getName().equals( "cdef" ) ) {
5563 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5564 p2.getNode( "a" ) );
5565 if ( !rt.getName().equals( "r" ) ) {
5568 final Phylogeny p3 = factory
5569 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5570 new NHXParser() )[ 0 ];
5571 PhylogenyMethods.preOrderReId( p3 );
5572 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5573 p3.getNode( "c" ) );
5574 if ( !bc_3.getName().equals( "bc" ) ) {
5577 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5578 p3.getNode( "c" ) );
5579 if ( !ac_3.getName().equals( "abc" ) ) {
5582 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5583 p3.getNode( "d" ) );
5584 if ( !ad_3.getName().equals( "abcde" ) ) {
5587 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5588 p3.getNode( "f" ) );
5589 if ( !af_3.getName().equals( "abcdef" ) ) {
5592 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5593 p3.getNode( "g" ) );
5594 if ( !ag_3.getName().equals( "" ) ) {
5597 if ( !ag_3.isRoot() ) {
5600 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5601 p3.getNode( "l" ) );
5602 if ( !al_3.getName().equals( "" ) ) {
5605 if ( !al_3.isRoot() ) {
5608 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5609 p3.getNode( "l" ) );
5610 if ( !kl_3.getName().equals( "" ) ) {
5613 if ( !kl_3.isRoot() ) {
5616 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5617 p3.getNode( "l" ) );
5618 if ( !fl_3.getName().equals( "" ) ) {
5621 if ( !fl_3.isRoot() ) {
5624 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5625 p3.getNode( "k" ) );
5626 if ( !gk_3.getName().equals( "ghijk" ) ) {
5629 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5630 PhylogenyMethods.preOrderReId( p4 );
5631 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5632 p4.getNode( "c" ) );
5633 if ( !r_4.getName().equals( "r" ) ) {
5636 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5637 PhylogenyMethods.preOrderReId( p5 );
5638 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5639 p5.getNode( "c" ) );
5640 if ( !r_5.getName().equals( "root" ) ) {
5643 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5644 PhylogenyMethods.preOrderReId( p6 );
5645 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5646 p6.getNode( "a" ) );
5647 if ( !r_6.getName().equals( "rot" ) ) {
5650 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5651 PhylogenyMethods.preOrderReId( p7 );
5652 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5653 p7.getNode( "e" ) );
5654 if ( !r_7.getName().equals( "rott" ) ) {
5657 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5658 p7.getNode( "a" ) );
5659 if ( !r_71.getName().equals( "rott" ) ) {
5662 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5663 p7.getNode( "rott" ) );
5664 if ( !r_72.getName().equals( "rott" ) ) {
5667 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5668 p7.getNode( "a" ) );
5669 if ( !r_73.getName().equals( "rott" ) ) {
5672 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5673 p7.getNode( "rott" ) );
5674 if ( !r_74.getName().equals( "rott" ) ) {
5677 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5678 p7.getNode( "e" ) );
5679 if ( !r_75.getName().equals( "e" ) ) {
5683 catch ( final Exception e ) {
5684 e.printStackTrace( System.out );
5690 private static boolean testHmmscanOutputParser() {
5691 final String test_dir = Test.PATH_TO_TEST_DATA;
5693 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5694 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5696 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5697 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5698 final List<Protein> proteins = parser2.parse();
5699 if ( parser2.getProteinsEncountered() != 4 ) {
5702 if ( proteins.size() != 4 ) {
5705 if ( parser2.getDomainsEncountered() != 69 ) {
5708 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5711 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5714 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5717 final Protein p1 = proteins.get( 0 );
5718 if ( p1.getNumberOfProteinDomains() != 15 ) {
5721 if ( p1.getLength() != 850 ) {
5724 final Protein p2 = proteins.get( 1 );
5725 if ( p2.getNumberOfProteinDomains() != 51 ) {
5728 if ( p2.getLength() != 1291 ) {
5731 final Protein p3 = proteins.get( 2 );
5732 if ( p3.getNumberOfProteinDomains() != 2 ) {
5735 final Protein p4 = proteins.get( 3 );
5736 if ( p4.getNumberOfProteinDomains() != 1 ) {
5739 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5742 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5745 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5748 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5751 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5754 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5757 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5761 catch ( final Exception e ) {
5762 e.printStackTrace( System.out );
5768 private static boolean testLastExternalNodeMethods() {
5770 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5771 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5772 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5773 final PhylogenyNode n1 = t0.getNode( "A" );
5774 if ( n1.isLastExternalNode() ) {
5777 final PhylogenyNode n2 = t0.getNode( "B" );
5778 if ( n2.isLastExternalNode() ) {
5781 final PhylogenyNode n3 = t0.getNode( "C" );
5782 if ( n3.isLastExternalNode() ) {
5785 final PhylogenyNode n4 = t0.getNode( "D" );
5786 if ( !n4.isLastExternalNode() ) {
5790 catch ( final Exception e ) {
5791 e.printStackTrace( System.out );
5797 private static boolean testLevelOrderIterator() {
5799 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5800 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5801 PhylogenyNodeIterator it0;
5802 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5805 for( it0.reset(); it0.hasNext(); ) {
5808 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5809 if ( !it.next().getName().equals( "r" ) ) {
5812 if ( !it.next().getName().equals( "ab" ) ) {
5815 if ( !it.next().getName().equals( "cd" ) ) {
5818 if ( !it.next().getName().equals( "A" ) ) {
5821 if ( !it.next().getName().equals( "B" ) ) {
5824 if ( !it.next().getName().equals( "C" ) ) {
5827 if ( !it.next().getName().equals( "D" ) ) {
5830 if ( it.hasNext() ) {
5833 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",
5834 new NHXParser() )[ 0 ];
5835 PhylogenyNodeIterator it2;
5836 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5839 for( it2.reset(); it2.hasNext(); ) {
5842 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5843 if ( !it3.next().getName().equals( "r" ) ) {
5846 if ( !it3.next().getName().equals( "abc" ) ) {
5849 if ( !it3.next().getName().equals( "defg" ) ) {
5852 if ( !it3.next().getName().equals( "A" ) ) {
5855 if ( !it3.next().getName().equals( "B" ) ) {
5858 if ( !it3.next().getName().equals( "C" ) ) {
5861 if ( !it3.next().getName().equals( "D" ) ) {
5864 if ( !it3.next().getName().equals( "E" ) ) {
5867 if ( !it3.next().getName().equals( "F" ) ) {
5870 if ( !it3.next().getName().equals( "G" ) ) {
5873 if ( !it3.next().getName().equals( "1" ) ) {
5876 if ( !it3.next().getName().equals( "2" ) ) {
5879 if ( !it3.next().getName().equals( "3" ) ) {
5882 if ( !it3.next().getName().equals( "4" ) ) {
5885 if ( !it3.next().getName().equals( "5" ) ) {
5888 if ( !it3.next().getName().equals( "6" ) ) {
5891 if ( !it3.next().getName().equals( "f1" ) ) {
5894 if ( !it3.next().getName().equals( "f2" ) ) {
5897 if ( !it3.next().getName().equals( "f3" ) ) {
5900 if ( !it3.next().getName().equals( "a" ) ) {
5903 if ( !it3.next().getName().equals( "b" ) ) {
5906 if ( !it3.next().getName().equals( "f21" ) ) {
5909 if ( !it3.next().getName().equals( "X" ) ) {
5912 if ( !it3.next().getName().equals( "Y" ) ) {
5915 if ( !it3.next().getName().equals( "Z" ) ) {
5918 if ( it3.hasNext() ) {
5921 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5922 PhylogenyNodeIterator it4;
5923 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
5926 for( it4.reset(); it4.hasNext(); ) {
5929 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
5930 if ( !it5.next().getName().equals( "r" ) ) {
5933 if ( !it5.next().getName().equals( "A" ) ) {
5936 if ( !it5.next().getName().equals( "B" ) ) {
5939 if ( !it5.next().getName().equals( "C" ) ) {
5942 if ( !it5.next().getName().equals( "D" ) ) {
5945 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
5946 PhylogenyNodeIterator it6;
5947 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
5950 for( it6.reset(); it6.hasNext(); ) {
5953 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
5954 if ( !it7.next().getName().equals( "A" ) ) {
5957 if ( it.hasNext() ) {
5961 catch ( final Exception e ) {
5962 e.printStackTrace( System.out );
5968 private static boolean testMafft( final String path ) {
5970 final List<String> opts = new ArrayList<String>();
5971 opts.add( "--maxiterate" );
5973 opts.add( "--localpair" );
5974 opts.add( "--quiet" );
5976 final MsaInferrer mafft = Mafft.createInstance( path );
5977 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
5978 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
5981 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
5985 catch ( final Exception e ) {
5986 e.printStackTrace( System.out );
5992 private static boolean testMidpointrooting() {
5994 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5995 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
5996 PhylogenyMethods.midpointRoot( t0 );
5997 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6000 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6003 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6007 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",
6008 new NHXParser() )[ 0 ];
6009 if ( !t1.isRooted() ) {
6012 PhylogenyMethods.midpointRoot( t1 );
6013 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6016 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6019 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6022 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6025 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6028 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6031 t1.reRoot( t1.getNode( "A" ) );
6032 PhylogenyMethods.midpointRoot( t1 );
6033 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6036 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6039 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6042 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6045 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6049 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6053 catch ( final Exception e ) {
6054 e.printStackTrace( System.out );
6060 private static boolean testMsaQualityMethod() {
6062 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6063 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6064 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6065 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6066 final List<Sequence> l = new ArrayList<Sequence>();
6071 final Msa msa = BasicMsa.createInstance( l );
6072 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6075 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6078 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6081 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6084 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6087 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6090 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6094 catch ( final Exception e ) {
6095 e.printStackTrace( System.out );
6101 private static boolean testMsaEntropy() {
6103 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6104 final Sequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6105 final Sequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6106 final Sequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6107 final List<Sequence> l = new ArrayList<Sequence>();
6112 final Msa msa = BasicMsa.createInstance( l );
6113 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6114 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6115 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6116 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6117 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6118 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6119 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6120 System.out.println();
6121 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6122 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6123 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6124 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6125 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6126 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6127 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6128 final List<Sequence> l2 = new ArrayList<Sequence>();
6129 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6130 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6131 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6132 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6133 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6134 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6135 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6136 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6137 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6138 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6139 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6140 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6141 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6142 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6143 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6144 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6145 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6146 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6147 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6148 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6149 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6150 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6151 final Msa msa2 = BasicMsa.createInstance( l2 );
6152 System.out.println();
6153 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6154 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6155 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6157 catch ( final Exception e ) {
6158 e.printStackTrace( System.out );
6164 private static boolean testDeleteableMsa() {
6166 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6167 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6168 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6169 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6170 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6171 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6172 final List<Sequence> l0 = new ArrayList<Sequence>();
6179 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6180 dmsa0.deleteRow( "b", false );
6181 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6184 dmsa0.deleteRow( "e", false );
6185 dmsa0.deleteRow( "a", false );
6186 dmsa0.deleteRow( "f", false );
6187 if ( dmsa0.getLength() != 4 ) {
6190 if ( dmsa0.getNumberOfSequences() != 2 ) {
6193 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6196 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6199 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6202 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6205 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6208 dmsa0.deleteRow( "c", false );
6209 dmsa0.deleteRow( "d", false );
6210 if ( dmsa0.getNumberOfSequences() != 0 ) {
6214 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6215 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6216 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6217 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6218 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6219 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6220 final List<Sequence> l1 = new ArrayList<Sequence>();
6227 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6228 dmsa1.deleteGapOnlyColumns();
6229 dmsa1.deleteRow( "a", false );
6230 dmsa1.deleteRow( "f", false );
6231 dmsa1.deleteRow( "d", false );
6232 dmsa1.deleteGapOnlyColumns();
6233 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6236 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6239 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6242 dmsa1.deleteRow( "c", false );
6243 dmsa1.deleteGapOnlyColumns();
6244 final Writer w0 = new StringWriter();
6245 dmsa1.write( w0, MSA_FORMAT.FASTA );
6246 final Writer w1 = new StringWriter();
6247 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6248 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6251 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6255 final Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6256 final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6257 final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6258 final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6259 final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6260 final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6261 final List<Sequence> l2 = new ArrayList<Sequence>();
6268 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6269 dmsa2.deleteGapColumns( 0.5 );
6270 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6273 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6276 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6279 dmsa2.deleteGapColumns( 0.2 );
6280 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6283 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6286 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6289 dmsa2.deleteGapColumns( 0 );
6290 dmsa2.deleteRow( "a", false );
6291 dmsa2.deleteRow( "b", false );
6292 dmsa2.deleteRow( "f", false );
6293 dmsa2.deleteRow( "e", false );
6294 dmsa2.setIdentifier( 0, "new_c" );
6295 dmsa2.setIdentifier( 1, "new_d" );
6296 dmsa2.setResidueAt( 0, 0, 'x' );
6297 final Sequence s = dmsa2.deleteRow( "new_d", true );
6298 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6301 final Writer w = new StringWriter();
6302 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6303 final String phylip = w.toString();
6304 if ( !phylip.equals( "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6307 final Writer w2 = new StringWriter();
6308 dmsa2.write( w2, MSA_FORMAT.FASTA );
6309 final String fasta = w2.toString();
6310 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6314 catch ( final Exception e ) {
6315 e.printStackTrace( System.out );
6321 private static boolean testNextNodeWithCollapsing() {
6323 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6325 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6326 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6327 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6328 t0.getNode( "cd" ).setCollapse( true );
6329 t0.getNode( "cde" ).setCollapse( true );
6330 n = t0.getFirstExternalNode();
6331 while ( n != null ) {
6333 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6335 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6338 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6341 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6344 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6347 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6350 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6354 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6355 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6356 t1.getNode( "ab" ).setCollapse( true );
6357 t1.getNode( "cd" ).setCollapse( true );
6358 t1.getNode( "cde" ).setCollapse( true );
6359 n = t1.getNode( "ab" );
6360 ext = new ArrayList<PhylogenyNode>();
6361 while ( n != null ) {
6363 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6365 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6368 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6371 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6374 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6377 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6383 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6384 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6385 t2.getNode( "ab" ).setCollapse( true );
6386 t2.getNode( "cd" ).setCollapse( true );
6387 t2.getNode( "cde" ).setCollapse( true );
6388 t2.getNode( "c" ).setCollapse( true );
6389 t2.getNode( "d" ).setCollapse( true );
6390 t2.getNode( "e" ).setCollapse( true );
6391 t2.getNode( "gh" ).setCollapse( true );
6392 n = t2.getNode( "ab" );
6393 ext = new ArrayList<PhylogenyNode>();
6394 while ( n != null ) {
6396 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6398 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6401 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6404 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6407 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6413 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6414 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6415 t3.getNode( "ab" ).setCollapse( true );
6416 t3.getNode( "cd" ).setCollapse( true );
6417 t3.getNode( "cde" ).setCollapse( true );
6418 t3.getNode( "c" ).setCollapse( true );
6419 t3.getNode( "d" ).setCollapse( true );
6420 t3.getNode( "e" ).setCollapse( true );
6421 t3.getNode( "gh" ).setCollapse( true );
6422 t3.getNode( "fgh" ).setCollapse( true );
6423 n = t3.getNode( "ab" );
6424 ext = new ArrayList<PhylogenyNode>();
6425 while ( n != null ) {
6427 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6429 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6432 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6435 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6441 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6442 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6443 t4.getNode( "ab" ).setCollapse( true );
6444 t4.getNode( "cd" ).setCollapse( true );
6445 t4.getNode( "cde" ).setCollapse( true );
6446 t4.getNode( "c" ).setCollapse( true );
6447 t4.getNode( "d" ).setCollapse( true );
6448 t4.getNode( "e" ).setCollapse( true );
6449 t4.getNode( "gh" ).setCollapse( true );
6450 t4.getNode( "fgh" ).setCollapse( true );
6451 t4.getNode( "abcdefgh" ).setCollapse( true );
6452 n = t4.getNode( "abcdefgh" );
6453 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6458 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6459 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6461 n = t5.getFirstExternalNode();
6462 while ( n != null ) {
6464 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6466 if ( ext.size() != 8 ) {
6469 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6472 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6475 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6478 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6481 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6484 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6487 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6490 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6495 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6496 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6498 t6.getNode( "ab" ).setCollapse( true );
6499 n = t6.getNode( "ab" );
6500 while ( n != null ) {
6502 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6504 if ( ext.size() != 7 ) {
6507 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6510 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6513 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6516 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6519 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6522 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6525 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6530 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6531 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6533 t7.getNode( "cd" ).setCollapse( true );
6534 n = t7.getNode( "a" );
6535 while ( n != null ) {
6537 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6539 if ( ext.size() != 7 ) {
6542 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6545 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6548 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6551 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6554 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6557 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6560 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6565 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6566 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6568 t8.getNode( "cd" ).setCollapse( true );
6569 t8.getNode( "c" ).setCollapse( true );
6570 t8.getNode( "d" ).setCollapse( true );
6571 n = t8.getNode( "a" );
6572 while ( n != null ) {
6574 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6576 if ( ext.size() != 7 ) {
6579 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6582 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6585 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6586 System.out.println( "2 fail" );
6589 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6592 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6595 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6598 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6603 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6604 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6606 t9.getNode( "gh" ).setCollapse( true );
6607 n = t9.getNode( "a" );
6608 while ( n != null ) {
6610 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6612 if ( ext.size() != 7 ) {
6615 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6618 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6621 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6624 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6627 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6630 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6633 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6638 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6639 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6641 t10.getNode( "gh" ).setCollapse( true );
6642 t10.getNode( "g" ).setCollapse( true );
6643 t10.getNode( "h" ).setCollapse( true );
6644 n = t10.getNode( "a" );
6645 while ( n != null ) {
6647 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6649 if ( ext.size() != 7 ) {
6652 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6655 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6658 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6661 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6664 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6667 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6670 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6675 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6676 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6678 t11.getNode( "gh" ).setCollapse( true );
6679 t11.getNode( "fgh" ).setCollapse( true );
6680 n = t11.getNode( "a" );
6681 while ( n != null ) {
6683 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6685 if ( ext.size() != 6 ) {
6688 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6691 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6694 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6697 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6700 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6703 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6708 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6709 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6711 t12.getNode( "gh" ).setCollapse( true );
6712 t12.getNode( "fgh" ).setCollapse( true );
6713 t12.getNode( "g" ).setCollapse( true );
6714 t12.getNode( "h" ).setCollapse( true );
6715 t12.getNode( "f" ).setCollapse( true );
6716 n = t12.getNode( "a" );
6717 while ( n != null ) {
6719 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6721 if ( ext.size() != 6 ) {
6724 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6727 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6730 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6733 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6736 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6739 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6744 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6745 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6747 t13.getNode( "ab" ).setCollapse( true );
6748 t13.getNode( "b" ).setCollapse( true );
6749 t13.getNode( "fgh" ).setCollapse( true );
6750 t13.getNode( "gh" ).setCollapse( true );
6751 n = t13.getNode( "ab" );
6752 while ( n != null ) {
6754 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6756 if ( ext.size() != 5 ) {
6759 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6762 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6765 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6768 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6771 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6776 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6777 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6779 t14.getNode( "ab" ).setCollapse( true );
6780 t14.getNode( "a" ).setCollapse( true );
6781 t14.getNode( "fgh" ).setCollapse( true );
6782 t14.getNode( "gh" ).setCollapse( true );
6783 n = t14.getNode( "ab" );
6784 while ( n != null ) {
6786 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6788 if ( ext.size() != 5 ) {
6791 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6794 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6797 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6800 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6803 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6808 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" );
6809 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6811 t15.getNode( "ab" ).setCollapse( true );
6812 t15.getNode( "a" ).setCollapse( true );
6813 t15.getNode( "fgh" ).setCollapse( true );
6814 t15.getNode( "gh" ).setCollapse( true );
6815 n = t15.getNode( "ab" );
6816 while ( n != null ) {
6818 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6820 if ( ext.size() != 6 ) {
6823 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6826 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6829 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6832 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6835 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6838 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6843 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" );
6844 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6846 t16.getNode( "ab" ).setCollapse( true );
6847 t16.getNode( "a" ).setCollapse( true );
6848 t16.getNode( "fgh" ).setCollapse( true );
6849 t16.getNode( "gh" ).setCollapse( true );
6850 t16.getNode( "cd" ).setCollapse( true );
6851 t16.getNode( "cde" ).setCollapse( true );
6852 t16.getNode( "d" ).setCollapse( true );
6853 t16.getNode( "x" ).setCollapse( true );
6854 n = t16.getNode( "ab" );
6855 while ( n != null ) {
6857 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6859 if ( ext.size() != 4 ) {
6862 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6865 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6868 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6871 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6875 catch ( final Exception e ) {
6876 e.printStackTrace( System.out );
6882 private static boolean testNexusCharactersParsing() {
6884 final NexusCharactersParser parser = new NexusCharactersParser();
6885 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6887 String[] labels = parser.getCharStateLabels();
6888 if ( labels.length != 7 ) {
6891 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6894 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6897 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6900 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6903 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6906 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6909 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6912 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6914 labels = parser.getCharStateLabels();
6915 if ( labels.length != 7 ) {
6918 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6921 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6924 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6927 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6930 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6933 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6936 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6940 catch ( final Exception e ) {
6941 e.printStackTrace( System.out );
6947 private static boolean testNexusMatrixParsing() {
6949 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
6950 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
6952 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
6953 if ( m.getNumberOfCharacters() != 9 ) {
6956 if ( m.getNumberOfIdentifiers() != 5 ) {
6959 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
6962 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
6965 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
6968 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
6971 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
6974 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6977 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
6980 // if ( labels.length != 7 ) {
6983 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6986 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6989 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6992 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6995 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6998 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7001 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7004 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7006 // labels = parser.getCharStateLabels();
7007 // if ( labels.length != 7 ) {
7010 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7013 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7016 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7019 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7022 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7025 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7028 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7032 catch ( final Exception e ) {
7033 e.printStackTrace( System.out );
7039 private static boolean testNexusTreeParsing() {
7041 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7042 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7043 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7044 if ( phylogenies.length != 1 ) {
7047 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7050 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7054 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7055 if ( phylogenies.length != 1 ) {
7058 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7061 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7065 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7066 if ( phylogenies.length != 1 ) {
7069 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7072 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7075 if ( phylogenies[ 0 ].isRooted() ) {
7079 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7080 if ( phylogenies.length != 18 ) {
7083 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7086 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7089 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7092 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7095 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7098 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7101 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7104 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7107 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7110 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7113 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7116 if ( phylogenies[ 8 ].isRooted() ) {
7119 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7122 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7125 if ( !phylogenies[ 9 ].isRooted() ) {
7128 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7131 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7134 if ( !phylogenies[ 10 ].isRooted() ) {
7137 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7140 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7143 if ( phylogenies[ 11 ].isRooted() ) {
7146 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7149 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7152 if ( !phylogenies[ 12 ].isRooted() ) {
7155 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7158 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7161 if ( !phylogenies[ 13 ].isRooted() ) {
7164 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7167 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7170 if ( !phylogenies[ 14 ].isRooted() ) {
7173 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7176 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7179 if ( phylogenies[ 15 ].isRooted() ) {
7182 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7185 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7188 if ( !phylogenies[ 16 ].isRooted() ) {
7191 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7194 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7197 if ( phylogenies[ 17 ].isRooted() ) {
7200 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7203 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7205 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7206 if ( phylogenies.length != 9 ) {
7209 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7210 .getDistanceToParent() ) ) {
7213 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7214 .getDistanceToParent() ) ) {
7217 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7220 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7223 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7226 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7229 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7233 catch ( final Exception e ) {
7234 e.printStackTrace( System.out );
7240 private static boolean testNexusTreeParsingIterating() {
7242 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7243 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7244 if ( !p.hasNext() ) {
7247 Phylogeny phy = p.next();
7248 if ( phy == null ) {
7251 if ( phy.getNumberOfExternalNodes() != 25 ) {
7254 if ( !phy.getName().equals( "" ) ) {
7257 if ( p.hasNext() ) {
7261 if ( phy != null ) {
7266 if ( !p.hasNext() ) {
7270 if ( phy == null ) {
7273 if ( phy.getNumberOfExternalNodes() != 25 ) {
7276 if ( !phy.getName().equals( "" ) ) {
7279 if ( p.hasNext() ) {
7283 if ( phy != null ) {
7287 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7288 if ( !p.hasNext() ) {
7292 if ( phy == null ) {
7295 if ( phy.getNumberOfExternalNodes() != 10 ) {
7298 if ( !phy.getName().equals( "name" ) ) {
7301 if ( p.hasNext() ) {
7305 if ( phy != null ) {
7310 if ( !p.hasNext() ) {
7314 if ( phy == null ) {
7317 if ( phy.getNumberOfExternalNodes() != 10 ) {
7320 if ( !phy.getName().equals( "name" ) ) {
7323 if ( p.hasNext() ) {
7327 if ( phy != null ) {
7331 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7332 if ( !p.hasNext() ) {
7336 if ( phy == null ) {
7339 if ( phy.getNumberOfExternalNodes() != 3 ) {
7342 if ( !phy.getName().equals( "" ) ) {
7345 if ( phy.isRooted() ) {
7348 if ( p.hasNext() ) {
7352 if ( phy != null ) {
7357 if ( !p.hasNext() ) {
7361 if ( phy == null ) {
7364 if ( phy.getNumberOfExternalNodes() != 3 ) {
7367 if ( !phy.getName().equals( "" ) ) {
7370 if ( p.hasNext() ) {
7374 if ( phy != null ) {
7378 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7379 if ( !p.hasNext() ) {
7384 if ( phy == null ) {
7387 if ( phy.getNumberOfExternalNodes() != 10 ) {
7390 if ( !phy.getName().equals( "tree 0" ) ) {
7394 if ( !p.hasNext() ) {
7398 if ( phy == null ) {
7401 if ( phy.getNumberOfExternalNodes() != 10 ) {
7404 if ( !phy.getName().equals( "tree 1" ) ) {
7408 if ( !p.hasNext() ) {
7412 if ( phy == null ) {
7415 if ( phy.getNumberOfExternalNodes() != 3 ) {
7416 System.out.println( phy.toString() );
7419 if ( !phy.getName().equals( "" ) ) {
7422 if ( phy.isRooted() ) {
7426 if ( !p.hasNext() ) {
7430 if ( phy == null ) {
7433 if ( phy.getNumberOfExternalNodes() != 4 ) {
7436 if ( !phy.getName().equals( "" ) ) {
7439 if ( !phy.isRooted() ) {
7443 if ( !p.hasNext() ) {
7447 if ( phy == null ) {
7450 if ( phy.getNumberOfExternalNodes() != 5 ) {
7451 System.out.println( phy.getNumberOfExternalNodes() );
7454 if ( !phy.getName().equals( "" ) ) {
7457 if ( !phy.isRooted() ) {
7461 if ( !p.hasNext() ) {
7465 if ( phy == null ) {
7468 if ( phy.getNumberOfExternalNodes() != 3 ) {
7471 if ( !phy.getName().equals( "" ) ) {
7474 if ( phy.isRooted() ) {
7478 if ( !p.hasNext() ) {
7482 if ( phy == null ) {
7485 if ( phy.getNumberOfExternalNodes() != 2 ) {
7488 if ( !phy.getName().equals( "" ) ) {
7491 if ( !phy.isRooted() ) {
7495 if ( !p.hasNext() ) {
7499 if ( phy.getNumberOfExternalNodes() != 3 ) {
7502 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7505 if ( !phy.isRooted() ) {
7509 if ( !p.hasNext() ) {
7513 if ( phy.getNumberOfExternalNodes() != 3 ) {
7516 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7519 if ( !phy.getName().equals( "tree 8" ) ) {
7523 if ( !p.hasNext() ) {
7527 if ( phy.getNumberOfExternalNodes() != 3 ) {
7530 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7533 if ( !phy.getName().equals( "tree 9" ) ) {
7537 if ( !p.hasNext() ) {
7541 if ( phy.getNumberOfExternalNodes() != 3 ) {
7544 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7547 if ( !phy.getName().equals( "tree 10" ) ) {
7550 if ( !phy.isRooted() ) {
7554 if ( !p.hasNext() ) {
7558 if ( phy.getNumberOfExternalNodes() != 3 ) {
7561 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7564 if ( !phy.getName().equals( "tree 11" ) ) {
7567 if ( phy.isRooted() ) {
7571 if ( !p.hasNext() ) {
7575 if ( phy.getNumberOfExternalNodes() != 3 ) {
7578 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7581 if ( !phy.getName().equals( "tree 12" ) ) {
7584 if ( !phy.isRooted() ) {
7588 if ( !p.hasNext() ) {
7592 if ( phy.getNumberOfExternalNodes() != 3 ) {
7595 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7598 if ( !phy.getName().equals( "tree 13" ) ) {
7601 if ( !phy.isRooted() ) {
7605 if ( !p.hasNext() ) {
7609 if ( phy.getNumberOfExternalNodes() != 10 ) {
7610 System.out.println( phy.getNumberOfExternalNodes() );
7615 .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;" ) ) {
7616 System.out.println( phy.toNewHampshire() );
7619 if ( !phy.getName().equals( "tree 14" ) ) {
7622 if ( !phy.isRooted() ) {
7626 if ( !p.hasNext() ) {
7630 if ( phy.getNumberOfExternalNodes() != 10 ) {
7631 System.out.println( phy.getNumberOfExternalNodes() );
7636 .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;" ) ) {
7637 System.out.println( phy.toNewHampshire() );
7640 if ( !phy.getName().equals( "tree 15" ) ) {
7643 if ( phy.isRooted() ) {
7647 if ( !p.hasNext() ) {
7651 if ( phy.getNumberOfExternalNodes() != 10 ) {
7652 System.out.println( phy.getNumberOfExternalNodes() );
7657 .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;" ) ) {
7658 System.out.println( phy.toNewHampshire() );
7661 if ( !phy.getName().equals( "tree 16" ) ) {
7664 if ( !phy.isRooted() ) {
7668 if ( !p.hasNext() ) {
7672 if ( phy.getNumberOfExternalNodes() != 10 ) {
7673 System.out.println( phy.getNumberOfExternalNodes() );
7678 .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;" ) ) {
7679 System.out.println( phy.toNewHampshire() );
7682 if ( !phy.getName().equals( "tree 17" ) ) {
7685 if ( phy.isRooted() ) {
7689 if ( p.hasNext() ) {
7693 if ( phy != null ) {
7698 if ( !p.hasNext() ) {
7702 if ( phy == null ) {
7705 if ( phy.getNumberOfExternalNodes() != 10 ) {
7708 if ( !phy.getName().equals( "tree 0" ) ) {
7712 if ( !p.hasNext() ) {
7716 if ( phy == null ) {
7719 if ( phy.getNumberOfExternalNodes() != 10 ) {
7722 if ( !phy.getName().equals( "tree 1" ) ) {
7726 if ( !p.hasNext() ) {
7730 if ( phy == null ) {
7733 if ( phy.getNumberOfExternalNodes() != 3 ) {
7736 if ( !phy.getName().equals( "" ) ) {
7739 if ( phy.isRooted() ) {
7743 if ( !p.hasNext() ) {
7747 if ( phy == null ) {
7750 if ( phy.getNumberOfExternalNodes() != 4 ) {
7753 if ( !phy.getName().equals( "" ) ) {
7756 if ( !phy.isRooted() ) {
7760 if ( !p.hasNext() ) {
7764 if ( phy == null ) {
7767 if ( phy.getNumberOfExternalNodes() != 5 ) {
7768 System.out.println( phy.getNumberOfExternalNodes() );
7771 if ( !phy.getName().equals( "" ) ) {
7774 if ( !phy.isRooted() ) {
7778 if ( !p.hasNext() ) {
7782 if ( phy == null ) {
7785 if ( phy.getNumberOfExternalNodes() != 3 ) {
7788 if ( !phy.getName().equals( "" ) ) {
7791 if ( phy.isRooted() ) {
7795 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7796 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7798 if ( !p2.hasNext() ) {
7802 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7805 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7809 if ( !p2.hasNext() ) {
7814 if ( !p2.hasNext() ) {
7819 if ( !p2.hasNext() ) {
7824 if ( !p2.hasNext() ) {
7829 if ( !p2.hasNext() ) {
7834 if ( !p2.hasNext() ) {
7839 if ( !p2.hasNext() ) {
7844 if ( !p2.hasNext() ) {
7848 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7851 if ( p2.hasNext() ) {
7855 if ( phy != null ) {
7860 if ( !p2.hasNext() ) {
7864 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7867 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7871 catch ( final Exception e ) {
7872 e.printStackTrace( System.out );
7878 private static boolean testNexusTreeParsingTranslating() {
7880 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7881 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7882 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7883 if ( phylogenies.length != 1 ) {
7886 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7889 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7892 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7895 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7898 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7899 .equals( "Aranaeus" ) ) {
7903 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7904 if ( phylogenies.length != 3 ) {
7907 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7910 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7913 if ( phylogenies[ 0 ].isRooted() ) {
7916 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7919 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7922 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7923 .equals( "Aranaeus" ) ) {
7926 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7929 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7932 if ( phylogenies[ 1 ].isRooted() ) {
7935 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7938 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7941 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7942 .equals( "Aranaeus" ) ) {
7945 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7948 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
7951 if ( !phylogenies[ 2 ].isRooted() ) {
7954 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7957 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7960 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7961 .equals( "Aranaeus" ) ) {
7965 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
7966 if ( phylogenies.length != 3 ) {
7969 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7972 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7975 if ( phylogenies[ 0 ].isRooted() ) {
7978 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7981 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7984 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7985 .equals( "Aranaeus" ) ) {
7988 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
7991 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
7994 if ( phylogenies[ 1 ].isRooted() ) {
7997 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8000 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8003 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8004 .equals( "Aranaeus" ) ) {
8007 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8010 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8013 if ( !phylogenies[ 2 ].isRooted() ) {
8016 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8019 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8022 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8023 .equals( "Aranaeus" ) ) {
8026 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8027 if ( phylogenies.length != 3 ) {
8030 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8035 catch ( final Exception e ) {
8036 e.printStackTrace( System.out );
8042 private static boolean testNHParsing() {
8044 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8045 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8046 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8049 final NHXParser nhxp = new NHXParser();
8050 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8051 nhxp.setReplaceUnderscores( true );
8052 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8053 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8056 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8059 final Phylogeny p1b = factory
8060 .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 ",
8061 new NHXParser() )[ 0 ];
8062 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8065 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8068 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
8069 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8070 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8071 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
8072 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8073 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8074 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8075 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8076 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8077 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8078 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8079 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8080 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8082 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8085 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8088 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8091 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8094 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8095 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8096 final String p16_S = "((A,B),C)";
8097 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8098 if ( p16.length != 1 ) {
8101 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8104 final String p17_S = "(C,(A,B))";
8105 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8106 if ( p17.length != 1 ) {
8109 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8112 final String p18_S = "((A,B),(C,D))";
8113 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8114 if ( p18.length != 1 ) {
8117 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8120 final String p19_S = "(((A,B),C),D)";
8121 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8122 if ( p19.length != 1 ) {
8125 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8128 final String p20_S = "(A,(B,(C,D)))";
8129 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8130 if ( p20.length != 1 ) {
8133 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8136 final String p21_S = "(A,(B,(C,(D,E))))";
8137 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8138 if ( p21.length != 1 ) {
8141 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8144 final String p22_S = "((((A,B),C),D),E)";
8145 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8146 if ( p22.length != 1 ) {
8149 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8152 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8153 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8154 if ( p23.length != 1 ) {
8155 System.out.println( "xl=" + p23.length );
8159 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8162 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8163 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8164 if ( p24.length != 1 ) {
8167 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8170 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8171 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8172 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8173 if ( p241.length != 2 ) {
8176 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8179 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8182 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8183 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8184 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8185 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8186 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8187 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8188 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8189 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8190 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8191 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8194 final String p26_S = "(A,B)ab";
8195 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8196 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8199 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8200 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8201 if ( p27s.length != 1 ) {
8202 System.out.println( "xxl=" + p27s.length );
8206 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8207 System.out.println( p27s[ 0 ].toNewHampshireX() );
8211 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8213 if ( p27.length != 1 ) {
8214 System.out.println( "yl=" + p27.length );
8218 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8219 System.out.println( p27[ 0 ].toNewHampshireX() );
8223 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8224 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8225 final String p28_S3 = "(A,B)ab";
8226 final String p28_S4 = "((((A,B),C),D),;E;)";
8227 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8229 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8232 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8235 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8238 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8241 if ( p28.length != 4 ) {
8244 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";
8245 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8246 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8249 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";
8250 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8251 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8254 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8255 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8256 if ( ( p32.length != 0 ) ) {
8259 final String p33_S = "A";
8260 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8261 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8264 final String p34_S = "B;";
8265 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8266 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8269 final String p35_S = "B:0.2";
8270 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8271 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8274 final String p36_S = "(A)";
8275 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8276 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8279 final String p37_S = "((A))";
8280 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8281 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8284 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8285 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8286 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8289 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8290 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8291 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8294 final String p40_S = "(A,B,C)";
8295 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8296 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8299 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8300 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8301 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8304 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8305 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8306 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8309 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)";
8310 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8311 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8314 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)))";
8315 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8316 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8319 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8320 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8321 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8324 final String p46_S = "";
8325 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8326 if ( p46.length != 0 ) {
8329 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8330 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8333 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8334 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8337 final Phylogeny p49 = factory
8338 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8339 new NHXParser() )[ 0 ];
8340 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8343 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8344 if ( p50.getNode( "A" ) == null ) {
8347 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8348 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8351 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8354 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8355 .equals( "((A,B)88:2.0,C);" ) ) {
8358 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8359 if ( p51.getNode( "A(A" ) == null ) {
8362 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8363 if ( p52.getNode( "A(A" ) == null ) {
8366 final Phylogeny p53 = factory
8367 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8368 new NHXParser() )[ 0 ];
8369 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8372 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8373 if ( p54.getNode( "A" ) == null ) {
8376 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8379 final Phylogeny p55 = factory
8380 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1x\":0.0798012);" ),
8381 new NHXParser() )[ 0 ];
8384 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,lcl|HPV66_L1.1x:0.0798012);" ) ) {
8385 System.out.println( p55.toNewHampshire() );
8388 final Phylogeny p56 = factory
8389 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8390 new NHXParser() )[ 0 ];
8393 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8394 System.out.println( p56.toNewHampshire() );
8397 final Phylogeny p57 = factory
8398 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ),
8399 new NHXParser() )[ 0 ];
8402 .equals( "(('lcl|HPV32_L1.:1 s':0.195593,'lcl|HPV30_L1.1|;a':0.114237):0.0359322,'lcl|HPV56_L1.1|,d':0.0727412,'lcl|HPV66_L1.1:x':0.0798012);" ) ) {
8403 System.out.println( p56.toNewHampshire() );
8406 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8407 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8408 if ( !p58.toNewHampshire().equals( s58 ) ) {
8409 System.out.println( p58.toNewHampshire() );
8412 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8413 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8414 if ( !p59.toNewHampshire().equals( s59 ) ) {
8415 System.out.println( p59.toNewHampshire() );
8418 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8419 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8420 if ( !p60.toNewHampshire().equals( s60 ) ) {
8421 System.out.println( p60.toNewHampshire() );
8424 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8425 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8426 if ( !p61.toNewHampshire()
8427 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8428 System.out.println( p61.toNewHampshire() );
8432 catch ( final Exception e ) {
8433 e.printStackTrace( System.out );
8439 private static boolean testNHParsingIter() {
8441 final String p0_str = "(A,B);";
8442 final NHXParser p = new NHXParser();
8443 p.setSource( p0_str );
8444 if ( !p.hasNext() ) {
8447 final Phylogeny p0 = p.next();
8448 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8449 System.out.println( p0.toNewHampshire() );
8452 if ( p.hasNext() ) {
8455 if ( p.next() != null ) {
8459 final String p00_str = "(A,B)root;";
8460 p.setSource( p00_str );
8461 final Phylogeny p00 = p.next();
8462 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8463 System.out.println( p00.toNewHampshire() );
8467 final String p000_str = "A;";
8468 p.setSource( p000_str );
8469 final Phylogeny p000 = p.next();
8470 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8471 System.out.println( p000.toNewHampshire() );
8475 final String p0000_str = "A";
8476 p.setSource( p0000_str );
8477 final Phylogeny p0000 = p.next();
8478 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8479 System.out.println( p0000.toNewHampshire() );
8483 p.setSource( "(A)" );
8484 final Phylogeny p00000 = p.next();
8485 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8486 System.out.println( p00000.toNewHampshire() );
8490 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8491 p.setSource( p1_str );
8492 if ( !p.hasNext() ) {
8495 final Phylogeny p1_0 = p.next();
8496 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8497 System.out.println( p1_0.toNewHampshire() );
8500 if ( !p.hasNext() ) {
8503 final Phylogeny p1_1 = p.next();
8504 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8505 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8508 if ( !p.hasNext() ) {
8511 final Phylogeny p1_2 = p.next();
8512 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8513 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8516 if ( !p.hasNext() ) {
8519 final Phylogeny p1_3 = p.next();
8520 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8521 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8524 if ( p.hasNext() ) {
8527 if ( p.next() != null ) {
8531 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8532 p.setSource( p2_str );
8533 if ( !p.hasNext() ) {
8536 Phylogeny p2_0 = p.next();
8537 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8538 System.out.println( p2_0.toNewHampshire() );
8541 if ( !p.hasNext() ) {
8544 Phylogeny p2_1 = p.next();
8545 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8546 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8549 if ( !p.hasNext() ) {
8552 Phylogeny p2_2 = p.next();
8553 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8554 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8557 if ( !p.hasNext() ) {
8560 Phylogeny p2_3 = p.next();
8561 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8562 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8565 if ( !p.hasNext() ) {
8568 Phylogeny p2_4 = p.next();
8569 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8570 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8573 if ( p.hasNext() ) {
8576 if ( p.next() != null ) {
8581 if ( !p.hasNext() ) {
8585 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8586 System.out.println( p2_0.toNewHampshire() );
8589 if ( !p.hasNext() ) {
8593 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8594 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8597 if ( !p.hasNext() ) {
8601 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8602 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8605 if ( !p.hasNext() ) {
8609 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8610 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8613 if ( !p.hasNext() ) {
8617 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8618 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8621 if ( p.hasNext() ) {
8624 if ( p.next() != null ) {
8628 final String p3_str = "((A,B),C)abc";
8629 p.setSource( p3_str );
8630 if ( !p.hasNext() ) {
8633 final Phylogeny p3_0 = p.next();
8634 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8637 if ( p.hasNext() ) {
8640 if ( p.next() != null ) {
8644 final String p4_str = "((A,B)ab,C)abc";
8645 p.setSource( p4_str );
8646 if ( !p.hasNext() ) {
8649 final Phylogeny p4_0 = p.next();
8650 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8653 if ( p.hasNext() ) {
8656 if ( p.next() != null ) {
8660 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8661 p.setSource( p5_str );
8662 if ( !p.hasNext() ) {
8665 final Phylogeny p5_0 = p.next();
8666 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8669 if ( p.hasNext() ) {
8672 if ( p.next() != null ) {
8676 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8677 p.setSource( p6_str );
8678 if ( !p.hasNext() ) {
8681 Phylogeny p6_0 = p.next();
8682 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8685 if ( p.hasNext() ) {
8688 if ( p.next() != null ) {
8692 if ( !p.hasNext() ) {
8696 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8699 if ( p.hasNext() ) {
8702 if ( p.next() != null ) {
8706 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8707 p.setSource( p7_str );
8708 if ( !p.hasNext() ) {
8711 Phylogeny p7_0 = p.next();
8712 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8715 if ( p.hasNext() ) {
8718 if ( p.next() != null ) {
8722 if ( !p.hasNext() ) {
8726 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8729 if ( p.hasNext() ) {
8732 if ( p.next() != null ) {
8736 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8737 p.setSource( p8_str );
8738 if ( !p.hasNext() ) {
8741 Phylogeny p8_0 = p.next();
8742 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8745 if ( !p.hasNext() ) {
8748 if ( !p.hasNext() ) {
8751 Phylogeny p8_1 = p.next();
8752 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8755 if ( p.hasNext() ) {
8758 if ( p.next() != null ) {
8762 if ( !p.hasNext() ) {
8766 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8769 if ( !p.hasNext() ) {
8773 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8776 if ( p.hasNext() ) {
8779 if ( p.next() != null ) {
8785 if ( p.hasNext() ) {
8789 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8790 if ( !p.hasNext() ) {
8793 Phylogeny p_27 = p.next();
8794 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8795 System.out.println( p_27.toNewHampshireX() );
8799 if ( p.hasNext() ) {
8802 if ( p.next() != null ) {
8806 if ( !p.hasNext() ) {
8810 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8811 System.out.println( p_27.toNewHampshireX() );
8815 if ( p.hasNext() ) {
8818 if ( p.next() != null ) {
8822 final String p30_str = "(A,B);(C,D)";
8823 final NHXParser p30 = new NHXParser();
8824 p30.setSource( p30_str );
8825 if ( !p30.hasNext() ) {
8828 Phylogeny phy30 = p30.next();
8829 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8830 System.out.println( phy30.toNewHampshire() );
8833 if ( !p30.hasNext() ) {
8836 Phylogeny phy301 = p30.next();
8837 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8838 System.out.println( phy301.toNewHampshire() );
8841 if ( p30.hasNext() ) {
8844 if ( p30.hasNext() ) {
8847 if ( p30.next() != null ) {
8850 if ( p30.next() != null ) {
8854 if ( !p30.hasNext() ) {
8858 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8859 System.out.println( phy30.toNewHampshire() );
8862 if ( !p30.hasNext() ) {
8865 phy301 = p30.next();
8866 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8867 System.out.println( phy301.toNewHampshire() );
8870 if ( p30.hasNext() ) {
8873 if ( p30.hasNext() ) {
8876 if ( p30.next() != null ) {
8879 if ( p30.next() != null ) {
8883 catch ( final Exception e ) {
8884 e.printStackTrace( System.out );
8890 private static boolean testNHXconversion() {
8892 final PhylogenyNode n1 = new PhylogenyNode();
8893 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8894 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8895 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8896 final PhylogenyNode n5 = PhylogenyNode
8897 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8898 final PhylogenyNode n6 = PhylogenyNode
8899 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8900 if ( !n1.toNewHampshireX().equals( "" ) ) {
8903 if ( !n2.toNewHampshireX().equals( "" ) ) {
8906 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8909 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8912 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8915 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8916 System.out.println( n6.toNewHampshireX() );
8919 final PhylogenyNode n7 = new PhylogenyNode();
8920 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8921 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8922 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8923 System.out.println( n7
8924 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
8928 catch ( final Exception e ) {
8929 e.printStackTrace( System.out );
8935 private static boolean testNHXNodeParsing() {
8937 final PhylogenyNode n1 = new PhylogenyNode();
8938 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8939 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8940 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8941 final PhylogenyNode n5 = PhylogenyNode
8942 .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]" );
8943 if ( !n3.getName().equals( "n3" ) ) {
8946 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
8949 if ( n3.isDuplication() ) {
8952 if ( n3.isHasAssignedEvent() ) {
8955 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
8958 if ( !n4.getName().equals( "n4" ) ) {
8961 if ( n4.getDistanceToParent() != 0.01 ) {
8964 if ( !n5.getName().equals( "n5" ) ) {
8967 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
8970 if ( n5.getDistanceToParent() != 0.1 ) {
8973 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
8976 if ( !n5.isDuplication() ) {
8979 if ( !n5.isHasAssignedEvent() ) {
8982 final PhylogenyNode n8 = PhylogenyNode
8983 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
8984 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8985 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
8988 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
8991 final PhylogenyNode n9 = PhylogenyNode
8992 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
8993 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
8994 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
8997 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9000 final PhylogenyNode n10 = PhylogenyNode
9001 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9002 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9005 final PhylogenyNode n20 = PhylogenyNode
9006 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9007 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9010 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9013 final PhylogenyNode n20x = PhylogenyNode
9014 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9015 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9018 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9021 final PhylogenyNode n20xx = PhylogenyNode
9022 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9023 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9026 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9029 final PhylogenyNode n20xxx = PhylogenyNode
9030 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9031 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9034 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9037 final PhylogenyNode n20xxxx = PhylogenyNode
9038 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9039 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9042 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9045 final PhylogenyNode n21 = PhylogenyNode
9046 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9047 if ( !n21.getName().equals( "N21_PIG" ) ) {
9050 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9053 final PhylogenyNode n21x = PhylogenyNode
9054 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9055 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9058 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9061 final PhylogenyNode n22 = PhylogenyNode
9062 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9063 if ( !n22.getName().equals( "n22/PIG" ) ) {
9066 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9069 final PhylogenyNode n23 = PhylogenyNode
9070 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9071 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9074 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9077 final PhylogenyNode a = PhylogenyNode
9078 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9079 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9082 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9085 final PhylogenyNode c1 = PhylogenyNode
9086 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9087 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9088 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9091 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9094 final PhylogenyNode c2 = PhylogenyNode
9095 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9096 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9097 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9100 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9103 final PhylogenyNode e3 = PhylogenyNode
9104 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9105 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9108 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9111 final PhylogenyNode n11 = PhylogenyNode
9112 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9113 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9114 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9117 if ( n11.getDistanceToParent() != 0.4 ) {
9120 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9123 final PhylogenyNode n12 = PhylogenyNode
9124 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9125 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9126 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9129 if ( n12.getDistanceToParent() != 0.4 ) {
9132 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9135 final PhylogenyNode o = PhylogenyNode
9136 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9137 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9140 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9143 if ( n1.getName().compareTo( "" ) != 0 ) {
9146 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9149 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9152 if ( n2.getName().compareTo( "" ) != 0 ) {
9155 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9158 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9161 final PhylogenyNode n00 = PhylogenyNode
9162 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9163 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9166 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9169 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9170 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9173 final PhylogenyNode n13 = PhylogenyNode
9174 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9175 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9178 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9181 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9184 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9187 final PhylogenyNode n14 = PhylogenyNode
9188 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9189 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9192 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9195 final PhylogenyNode n15 = PhylogenyNode
9196 .createInstanceFromNhxString( "something_wicked[123]",
9197 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9198 if ( !n15.getName().equals( "something_wicked" ) ) {
9201 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9204 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9207 final PhylogenyNode n16 = PhylogenyNode
9208 .createInstanceFromNhxString( "something_wicked2[9]",
9209 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9210 if ( !n16.getName().equals( "something_wicked2" ) ) {
9213 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9216 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9219 final PhylogenyNode n17 = PhylogenyNode
9220 .createInstanceFromNhxString( "something_wicked3[a]",
9221 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9222 if ( !n17.getName().equals( "something_wicked3" ) ) {
9225 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9228 final PhylogenyNode n18 = PhylogenyNode
9229 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9230 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9233 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9236 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9239 final PhylogenyNode n19 = PhylogenyNode
9240 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9241 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9244 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9247 final PhylogenyNode n30 = PhylogenyNode
9248 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9249 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9250 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9253 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9256 final PhylogenyNode n31 = PhylogenyNode
9257 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9258 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9259 if ( n31.getNodeData().isHasTaxonomy() ) {
9262 final PhylogenyNode n32 = PhylogenyNode
9263 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9264 if ( n32.getNodeData().isHasTaxonomy() ) {
9267 final PhylogenyNode n40 = PhylogenyNode
9268 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9269 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9272 final PhylogenyNode n41 = PhylogenyNode
9273 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9274 if ( n41.getNodeData().isHasTaxonomy() ) {
9277 final PhylogenyNode n42 = PhylogenyNode
9278 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9279 if ( n42.getNodeData().isHasTaxonomy() ) {
9282 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9283 NHXParser.TAXONOMY_EXTRACTION.NO );
9284 if ( n43.getNodeData().isHasTaxonomy() ) {
9287 final PhylogenyNode n44 = PhylogenyNode
9288 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9289 if ( n44.getNodeData().isHasTaxonomy() ) {
9293 catch ( final Exception e ) {
9294 e.printStackTrace( System.out );
9300 private static boolean testNHXParsing() {
9302 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9303 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9304 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9307 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]";
9308 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9309 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9312 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]";
9313 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9314 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9317 final Phylogeny[] p3 = factory
9318 .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]",
9320 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9323 final Phylogeny[] p4 = factory
9324 .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(]",
9326 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9329 final Phylogeny[] p5 = factory
9330 .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(((]",
9332 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9335 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)";
9336 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)";
9337 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9338 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9341 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)))";
9342 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)))";
9343 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9344 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9347 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]) ))[,,, ])))))))";
9348 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9349 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9350 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9353 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9354 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9357 final Phylogeny p10 = factory
9358 .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]",
9359 new NHXParser() )[ 0 ];
9360 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9363 final Phylogeny p11 = factory
9364 .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]",
9365 new NHXParser() )[ 0 ];
9366 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9370 catch ( final Exception e ) {
9371 e.printStackTrace( System.out );
9377 private static boolean testNHXParsingMB() {
9379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9380 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9381 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9382 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9383 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9384 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9385 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9386 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9387 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9388 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9389 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9392 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9395 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9396 0.1100000000000000e+00 ) ) {
9399 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9402 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9405 final Phylogeny p2 = factory
9406 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9407 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9408 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9409 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9410 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9411 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9412 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9413 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9414 + "7.369400000000000e-02}])",
9415 new NHXParser() )[ 0 ];
9416 if ( p2.getNode( "1" ) == null ) {
9419 if ( p2.getNode( "2" ) == null ) {
9423 catch ( final Exception e ) {
9424 e.printStackTrace( System.out );
9431 private static boolean testNHXParsingQuotes() {
9433 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9434 final NHXParser p = new NHXParser();
9435 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9436 if ( phylogenies_0.length != 5 ) {
9439 final Phylogeny phy = phylogenies_0[ 4 ];
9440 if ( phy.getNumberOfExternalNodes() != 7 ) {
9443 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9446 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9449 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9450 .getScientificName().equals( "hsapiens" ) ) {
9453 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9456 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9459 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9462 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9465 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9468 final NHXParser p1p = new NHXParser();
9469 p1p.setIgnoreQuotes( true );
9470 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9471 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9474 final NHXParser p2p = new NHXParser();
9475 p1p.setIgnoreQuotes( false );
9476 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9477 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9480 final NHXParser p3p = new NHXParser();
9481 p3p.setIgnoreQuotes( false );
9482 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9483 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9486 final NHXParser p4p = new NHXParser();
9487 p4p.setIgnoreQuotes( false );
9488 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9489 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9492 final Phylogeny p10 = factory
9493 .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]",
9494 new NHXParser() )[ 0 ];
9495 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]";
9496 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9499 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9500 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9503 final Phylogeny p12 = factory
9504 .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]",
9505 new NHXParser() )[ 0 ];
9506 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]";
9507 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9510 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9511 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9514 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;";
9515 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9518 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9519 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9523 catch ( final Exception e ) {
9524 e.printStackTrace( System.out );
9530 private static boolean testNodeRemoval() {
9532 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9533 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9534 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9535 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9538 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9539 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9540 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9543 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9544 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9545 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9549 catch ( final Exception e ) {
9550 e.printStackTrace( System.out );
9556 private static boolean testPhylogenyBranch() {
9558 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9559 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9560 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9561 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9562 if ( !a1b1.equals( a1b1 ) ) {
9565 if ( !a1b1.equals( b1a1 ) ) {
9568 if ( !b1a1.equals( a1b1 ) ) {
9571 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9572 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9573 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9574 if ( a1_b1.equals( b1_a1 ) ) {
9577 if ( a1_b1.equals( a1_b1_ ) ) {
9580 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9581 if ( !a1_b1.equals( b1_a1_ ) ) {
9584 if ( a1_b1_.equals( b1_a1_ ) ) {
9587 if ( !a1_b1_.equals( b1_a1 ) ) {
9591 catch ( final Exception e ) {
9592 e.printStackTrace( System.out );
9598 private static boolean testPhyloXMLparsingOfDistributionElement() {
9600 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9601 PhyloXmlParser xml_parser = null;
9603 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9605 catch ( final Exception e ) {
9606 // Do nothing -- means were not running from jar.
9608 if ( xml_parser == null ) {
9609 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9610 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9611 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9614 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9617 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9619 if ( xml_parser.getErrorCount() > 0 ) {
9620 System.out.println( xml_parser.getErrorMessages().toString() );
9623 if ( phylogenies_0.length != 1 ) {
9626 final Phylogeny t1 = phylogenies_0[ 0 ];
9627 PhylogenyNode n = null;
9628 Distribution d = null;
9629 n = t1.getNode( "root node" );
9630 if ( !n.getNodeData().isHasDistribution() ) {
9633 if ( n.getNodeData().getDistributions().size() != 1 ) {
9636 d = n.getNodeData().getDistribution();
9637 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9640 if ( d.getPoints().size() != 1 ) {
9643 if ( d.getPolygons() != null ) {
9646 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9649 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9652 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9655 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9658 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9661 n = t1.getNode( "node a" );
9662 if ( !n.getNodeData().isHasDistribution() ) {
9665 if ( n.getNodeData().getDistributions().size() != 2 ) {
9668 d = n.getNodeData().getDistribution( 1 );
9669 if ( !d.getDesc().equals( "San Diego" ) ) {
9672 if ( d.getPoints().size() != 1 ) {
9675 if ( d.getPolygons() != null ) {
9678 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9681 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9684 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9687 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9690 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9693 n = t1.getNode( "node bb" );
9694 if ( !n.getNodeData().isHasDistribution() ) {
9697 if ( n.getNodeData().getDistributions().size() != 1 ) {
9700 d = n.getNodeData().getDistribution( 0 );
9701 if ( d.getPoints().size() != 3 ) {
9704 if ( d.getPolygons().size() != 2 ) {
9707 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9710 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9713 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9716 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9719 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9722 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9725 Polygon p = d.getPolygons().get( 0 );
9726 if ( p.getPoints().size() != 3 ) {
9729 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9732 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9735 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9738 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9741 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9744 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9747 p = d.getPolygons().get( 1 );
9748 if ( p.getPoints().size() != 3 ) {
9751 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9754 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9757 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9761 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9762 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9763 if ( rt.length != 1 ) {
9766 final Phylogeny t1_rt = rt[ 0 ];
9767 n = t1_rt.getNode( "root node" );
9768 if ( !n.getNodeData().isHasDistribution() ) {
9771 if ( n.getNodeData().getDistributions().size() != 1 ) {
9774 d = n.getNodeData().getDistribution();
9775 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9778 if ( d.getPoints().size() != 1 ) {
9781 if ( d.getPolygons() != null ) {
9784 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9787 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9790 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9793 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9796 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9799 n = t1_rt.getNode( "node a" );
9800 if ( !n.getNodeData().isHasDistribution() ) {
9803 if ( n.getNodeData().getDistributions().size() != 2 ) {
9806 d = n.getNodeData().getDistribution( 1 );
9807 if ( !d.getDesc().equals( "San Diego" ) ) {
9810 if ( d.getPoints().size() != 1 ) {
9813 if ( d.getPolygons() != null ) {
9816 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9819 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9822 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9825 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9828 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9831 n = t1_rt.getNode( "node bb" );
9832 if ( !n.getNodeData().isHasDistribution() ) {
9835 if ( n.getNodeData().getDistributions().size() != 1 ) {
9838 d = n.getNodeData().getDistribution( 0 );
9839 if ( d.getPoints().size() != 3 ) {
9842 if ( d.getPolygons().size() != 2 ) {
9845 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9848 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9851 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9854 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9857 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9860 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9863 p = d.getPolygons().get( 0 );
9864 if ( p.getPoints().size() != 3 ) {
9867 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9870 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9873 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9876 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9879 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9882 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9885 p = d.getPolygons().get( 1 );
9886 if ( p.getPoints().size() != 3 ) {
9889 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9892 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9895 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9899 catch ( final Exception e ) {
9900 e.printStackTrace( System.out );
9906 private static boolean testPostOrderIterator() {
9908 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9909 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9910 PhylogenyNodeIterator it0;
9911 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9914 for( it0.reset(); it0.hasNext(); ) {
9917 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9918 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9919 if ( !it.next().getName().equals( "A" ) ) {
9922 if ( !it.next().getName().equals( "B" ) ) {
9925 if ( !it.next().getName().equals( "ab" ) ) {
9928 if ( !it.next().getName().equals( "C" ) ) {
9931 if ( !it.next().getName().equals( "D" ) ) {
9934 if ( !it.next().getName().equals( "cd" ) ) {
9937 if ( !it.next().getName().equals( "abcd" ) ) {
9940 if ( !it.next().getName().equals( "E" ) ) {
9943 if ( !it.next().getName().equals( "F" ) ) {
9946 if ( !it.next().getName().equals( "ef" ) ) {
9949 if ( !it.next().getName().equals( "G" ) ) {
9952 if ( !it.next().getName().equals( "H" ) ) {
9955 if ( !it.next().getName().equals( "gh" ) ) {
9958 if ( !it.next().getName().equals( "efgh" ) ) {
9961 if ( !it.next().getName().equals( "r" ) ) {
9964 if ( it.hasNext() ) {
9968 catch ( final Exception e ) {
9969 e.printStackTrace( System.out );
9975 private static boolean testPreOrderIterator() {
9977 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9978 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9979 PhylogenyNodeIterator it0;
9980 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
9983 for( it0.reset(); it0.hasNext(); ) {
9986 PhylogenyNodeIterator it = t0.iteratorPreorder();
9987 if ( !it.next().getName().equals( "r" ) ) {
9990 if ( !it.next().getName().equals( "ab" ) ) {
9993 if ( !it.next().getName().equals( "A" ) ) {
9996 if ( !it.next().getName().equals( "B" ) ) {
9999 if ( !it.next().getName().equals( "cd" ) ) {
10002 if ( !it.next().getName().equals( "C" ) ) {
10005 if ( !it.next().getName().equals( "D" ) ) {
10008 if ( it.hasNext() ) {
10011 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10012 it = t1.iteratorPreorder();
10013 if ( !it.next().getName().equals( "r" ) ) {
10016 if ( !it.next().getName().equals( "abcd" ) ) {
10019 if ( !it.next().getName().equals( "ab" ) ) {
10022 if ( !it.next().getName().equals( "A" ) ) {
10025 if ( !it.next().getName().equals( "B" ) ) {
10028 if ( !it.next().getName().equals( "cd" ) ) {
10031 if ( !it.next().getName().equals( "C" ) ) {
10034 if ( !it.next().getName().equals( "D" ) ) {
10037 if ( !it.next().getName().equals( "efgh" ) ) {
10040 if ( !it.next().getName().equals( "ef" ) ) {
10043 if ( !it.next().getName().equals( "E" ) ) {
10046 if ( !it.next().getName().equals( "F" ) ) {
10049 if ( !it.next().getName().equals( "gh" ) ) {
10052 if ( !it.next().getName().equals( "G" ) ) {
10055 if ( !it.next().getName().equals( "H" ) ) {
10058 if ( it.hasNext() ) {
10062 catch ( final Exception e ) {
10063 e.printStackTrace( System.out );
10069 private static boolean testPropertiesMap() {
10071 final PropertiesMap pm = new PropertiesMap();
10072 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10073 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10074 final Property p2 = new Property( "something:else",
10076 "improbable:research",
10079 pm.addProperty( p0 );
10080 pm.addProperty( p1 );
10081 pm.addProperty( p2 );
10082 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10085 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10088 if ( pm.getProperties().size() != 3 ) {
10091 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10094 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10097 if ( pm.getProperties().size() != 3 ) {
10100 pm.removeProperty( "dimensions:diameter" );
10101 if ( pm.getProperties().size() != 2 ) {
10104 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10107 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10111 catch ( final Exception e ) {
10112 e.printStackTrace( System.out );
10118 private static boolean testProteinId() {
10120 final ProteinId id1 = new ProteinId( "a" );
10121 final ProteinId id2 = new ProteinId( "a" );
10122 final ProteinId id3 = new ProteinId( "A" );
10123 final ProteinId id4 = new ProteinId( "b" );
10124 if ( !id1.equals( id1 ) ) {
10127 if ( id1.getId().equals( "x" ) ) {
10130 if ( id1.getId().equals( null ) ) {
10133 if ( !id1.equals( id2 ) ) {
10136 if ( id1.equals( id3 ) ) {
10139 if ( id1.hashCode() != id1.hashCode() ) {
10142 if ( id1.hashCode() != id2.hashCode() ) {
10145 if ( id1.hashCode() == id3.hashCode() ) {
10148 if ( id1.compareTo( id1 ) != 0 ) {
10151 if ( id1.compareTo( id2 ) != 0 ) {
10154 if ( id1.compareTo( id3 ) != 0 ) {
10157 if ( id1.compareTo( id4 ) >= 0 ) {
10160 if ( id4.compareTo( id1 ) <= 0 ) {
10163 if ( !id4.getId().equals( "b" ) ) {
10166 final ProteinId id5 = new ProteinId( " C " );
10167 if ( !id5.getId().equals( "C" ) ) {
10170 if ( id5.equals( id1 ) ) {
10174 catch ( final Exception e ) {
10175 e.printStackTrace( System.out );
10181 private static boolean testReIdMethods() {
10183 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10184 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10185 final long count = PhylogenyNode.getNodeCount();
10186 p.levelOrderReID();
10187 if ( p.getNode( "r" ).getId() != count ) {
10190 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10193 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10196 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10199 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10202 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10205 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10208 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10211 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10214 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10217 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10220 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10223 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10226 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10229 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10233 catch ( final Exception e ) {
10234 e.printStackTrace( System.out );
10240 private static boolean testRerooting() {
10242 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10243 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",
10244 new NHXParser() )[ 0 ];
10245 if ( !t1.isRooted() ) {
10248 t1.reRoot( t1.getNode( "D" ) );
10249 t1.reRoot( t1.getNode( "CD" ) );
10250 t1.reRoot( t1.getNode( "A" ) );
10251 t1.reRoot( t1.getNode( "B" ) );
10252 t1.reRoot( t1.getNode( "AB" ) );
10253 t1.reRoot( t1.getNode( "D" ) );
10254 t1.reRoot( t1.getNode( "C" ) );
10255 t1.reRoot( t1.getNode( "CD" ) );
10256 t1.reRoot( t1.getNode( "A" ) );
10257 t1.reRoot( t1.getNode( "B" ) );
10258 t1.reRoot( t1.getNode( "AB" ) );
10259 t1.reRoot( t1.getNode( "D" ) );
10260 t1.reRoot( t1.getNode( "D" ) );
10261 t1.reRoot( t1.getNode( "C" ) );
10262 t1.reRoot( t1.getNode( "A" ) );
10263 t1.reRoot( t1.getNode( "B" ) );
10264 t1.reRoot( t1.getNode( "AB" ) );
10265 t1.reRoot( t1.getNode( "C" ) );
10266 t1.reRoot( t1.getNode( "D" ) );
10267 t1.reRoot( t1.getNode( "CD" ) );
10268 t1.reRoot( t1.getNode( "D" ) );
10269 t1.reRoot( t1.getNode( "A" ) );
10270 t1.reRoot( t1.getNode( "B" ) );
10271 t1.reRoot( t1.getNode( "AB" ) );
10272 t1.reRoot( t1.getNode( "C" ) );
10273 t1.reRoot( t1.getNode( "D" ) );
10274 t1.reRoot( t1.getNode( "CD" ) );
10275 t1.reRoot( t1.getNode( "D" ) );
10276 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10279 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10282 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10285 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10288 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10291 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10294 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",
10295 new NHXParser() )[ 0 ];
10296 t2.reRoot( t2.getNode( "A" ) );
10297 t2.reRoot( t2.getNode( "D" ) );
10298 t2.reRoot( t2.getNode( "ABC" ) );
10299 t2.reRoot( t2.getNode( "A" ) );
10300 t2.reRoot( t2.getNode( "B" ) );
10301 t2.reRoot( t2.getNode( "D" ) );
10302 t2.reRoot( t2.getNode( "C" ) );
10303 t2.reRoot( t2.getNode( "ABC" ) );
10304 t2.reRoot( t2.getNode( "A" ) );
10305 t2.reRoot( t2.getNode( "B" ) );
10306 t2.reRoot( t2.getNode( "AB" ) );
10307 t2.reRoot( t2.getNode( "AB" ) );
10308 t2.reRoot( t2.getNode( "D" ) );
10309 t2.reRoot( t2.getNode( "C" ) );
10310 t2.reRoot( t2.getNode( "B" ) );
10311 t2.reRoot( t2.getNode( "AB" ) );
10312 t2.reRoot( t2.getNode( "D" ) );
10313 t2.reRoot( t2.getNode( "D" ) );
10314 t2.reRoot( t2.getNode( "ABC" ) );
10315 t2.reRoot( t2.getNode( "A" ) );
10316 t2.reRoot( t2.getNode( "B" ) );
10317 t2.reRoot( t2.getNode( "AB" ) );
10318 t2.reRoot( t2.getNode( "D" ) );
10319 t2.reRoot( t2.getNode( "C" ) );
10320 t2.reRoot( t2.getNode( "ABC" ) );
10321 t2.reRoot( t2.getNode( "A" ) );
10322 t2.reRoot( t2.getNode( "B" ) );
10323 t2.reRoot( t2.getNode( "AB" ) );
10324 t2.reRoot( t2.getNode( "D" ) );
10325 t2.reRoot( t2.getNode( "D" ) );
10326 t2.reRoot( t2.getNode( "C" ) );
10327 t2.reRoot( t2.getNode( "A" ) );
10328 t2.reRoot( t2.getNode( "B" ) );
10329 t2.reRoot( t2.getNode( "AB" ) );
10330 t2.reRoot( t2.getNode( "C" ) );
10331 t2.reRoot( t2.getNode( "D" ) );
10332 t2.reRoot( t2.getNode( "ABC" ) );
10333 t2.reRoot( t2.getNode( "D" ) );
10334 t2.reRoot( t2.getNode( "A" ) );
10335 t2.reRoot( t2.getNode( "B" ) );
10336 t2.reRoot( t2.getNode( "AB" ) );
10337 t2.reRoot( t2.getNode( "C" ) );
10338 t2.reRoot( t2.getNode( "D" ) );
10339 t2.reRoot( t2.getNode( "ABC" ) );
10340 t2.reRoot( t2.getNode( "D" ) );
10341 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10344 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10347 t2.reRoot( t2.getNode( "ABC" ) );
10348 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10351 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10354 t2.reRoot( t2.getNode( "AB" ) );
10355 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10358 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10361 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10364 t2.reRoot( t2.getNode( "AB" ) );
10365 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10368 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10371 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10374 t2.reRoot( t2.getNode( "D" ) );
10375 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10378 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10381 t2.reRoot( t2.getNode( "ABC" ) );
10382 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10385 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10388 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10389 new NHXParser() )[ 0 ];
10390 t3.reRoot( t3.getNode( "B" ) );
10391 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10394 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10397 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10400 t3.reRoot( t3.getNode( "B" ) );
10401 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10404 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10407 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10410 t3.reRoot( t3.getRoot() );
10411 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10414 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10417 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10421 catch ( final Exception e ) {
10422 e.printStackTrace( System.out );
10428 private static boolean testSDIse() {
10430 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10431 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10432 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10433 gene1.setRooted( true );
10434 species1.setRooted( true );
10435 final SDI sdi = new SDI( gene1, species1 );
10436 if ( !gene1.getRoot().isDuplication() ) {
10439 final Phylogeny species2 = factory
10440 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10441 new NHXParser() )[ 0 ];
10442 final Phylogeny gene2 = factory
10443 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10444 new NHXParser() )[ 0 ];
10445 species2.setRooted( true );
10446 gene2.setRooted( true );
10447 final SDI sdi2 = new SDI( gene2, species2 );
10448 if ( sdi2.getDuplicationsSum() != 0 ) {
10451 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10454 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10457 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10460 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10463 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10466 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10469 final Phylogeny species3 = factory
10470 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10471 new NHXParser() )[ 0 ];
10472 final Phylogeny gene3 = factory
10473 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10474 new NHXParser() )[ 0 ];
10475 species3.setRooted( true );
10476 gene3.setRooted( true );
10477 final SDI sdi3 = new SDI( gene3, species3 );
10478 if ( sdi3.getDuplicationsSum() != 1 ) {
10481 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10484 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10487 final Phylogeny species4 = factory
10488 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10489 new NHXParser() )[ 0 ];
10490 final Phylogeny gene4 = factory
10491 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10492 new NHXParser() )[ 0 ];
10493 species4.setRooted( true );
10494 gene4.setRooted( true );
10495 final SDI sdi4 = new SDI( gene4, species4 );
10496 if ( sdi4.getDuplicationsSum() != 1 ) {
10499 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10502 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10505 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10508 if ( species4.getNumberOfExternalNodes() != 6 ) {
10511 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10514 final Phylogeny species5 = factory
10515 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10516 new NHXParser() )[ 0 ];
10517 final Phylogeny gene5 = factory
10518 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10519 new NHXParser() )[ 0 ];
10520 species5.setRooted( true );
10521 gene5.setRooted( true );
10522 final SDI sdi5 = new SDI( gene5, species5 );
10523 if ( sdi5.getDuplicationsSum() != 2 ) {
10526 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10529 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10532 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10535 if ( species5.getNumberOfExternalNodes() != 6 ) {
10538 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10541 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10542 // Conjecture for Comparing Molecular Phylogenies"
10543 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10544 final Phylogeny species6 = factory
10545 .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,"
10546 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10547 new NHXParser() )[ 0 ];
10548 final Phylogeny gene6 = factory
10549 .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,"
10550 + "((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,"
10551 + "(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;",
10552 new NHXParser() )[ 0 ];
10553 species6.setRooted( true );
10554 gene6.setRooted( true );
10555 final SDI sdi6 = new SDI( gene6, species6 );
10556 if ( sdi6.getDuplicationsSum() != 3 ) {
10559 if ( !gene6.getNode( "r" ).isDuplication() ) {
10562 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10565 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10568 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10571 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10574 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10577 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10580 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10583 sdi6.computeMappingCostL();
10584 if ( sdi6.computeMappingCostL() != 17 ) {
10587 if ( species6.getNumberOfExternalNodes() != 9 ) {
10590 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10593 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10594 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10595 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10596 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10597 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10598 species7.setRooted( true );
10599 final Phylogeny gene7_1 = Test
10600 .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])" );
10601 gene7_1.setRooted( true );
10602 final SDI sdi7 = new SDI( gene7_1, species7 );
10603 if ( sdi7.getDuplicationsSum() != 0 ) {
10606 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10609 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10612 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10615 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10618 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10621 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10624 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10627 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10630 final Phylogeny gene7_2 = Test
10631 .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])" );
10632 gene7_2.setRooted( true );
10633 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10634 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10637 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10640 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10643 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10646 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10649 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10652 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10655 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10658 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10661 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10665 catch ( final Exception e ) {
10671 private static boolean testSDIunrooted() {
10673 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10674 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10675 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10676 final Iterator<PhylogenyBranch> iter = l.iterator();
10677 PhylogenyBranch br = iter.next();
10678 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10681 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10685 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10688 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10692 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10695 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10699 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10702 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10706 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10709 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10713 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10716 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10720 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10723 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10727 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10730 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10734 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10737 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10741 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10744 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10748 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10751 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10755 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10758 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10762 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10765 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10769 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10772 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10776 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10779 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10782 if ( iter.hasNext() ) {
10785 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10786 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10787 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10789 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10792 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10796 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10799 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10803 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10806 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10809 if ( iter1.hasNext() ) {
10812 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10813 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10814 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10816 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10819 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10823 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10826 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10830 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10833 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10836 if ( iter2.hasNext() ) {
10839 final Phylogeny species0 = factory
10840 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10841 new NHXParser() )[ 0 ];
10842 final Phylogeny gene1 = factory
10843 .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])",
10844 new NHXParser() )[ 0 ];
10845 species0.setRooted( true );
10846 gene1.setRooted( true );
10847 final SDIR sdi_unrooted = new SDIR();
10848 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10849 if ( sdi_unrooted.getCount() != 1 ) {
10852 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10855 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10858 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10861 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10864 final Phylogeny gene2 = factory
10865 .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])",
10866 new NHXParser() )[ 0 ];
10867 gene2.setRooted( true );
10868 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10869 if ( sdi_unrooted.getCount() != 1 ) {
10872 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10875 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10878 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10881 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10884 final Phylogeny species6 = factory
10885 .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,"
10886 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10887 new NHXParser() )[ 0 ];
10888 final Phylogeny gene6 = factory
10889 .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],"
10890 + "(((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],"
10891 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10892 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10893 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10894 new NHXParser() )[ 0 ];
10895 species6.setRooted( true );
10896 gene6.setRooted( true );
10897 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10898 if ( sdi_unrooted.getCount() != 1 ) {
10901 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10904 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10907 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10910 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10913 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10916 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10919 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10922 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
10925 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10928 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
10931 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
10934 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10938 final Phylogeny species7 = factory
10939 .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,"
10940 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10941 new NHXParser() )[ 0 ];
10942 final Phylogeny gene7 = factory
10943 .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],"
10944 + "(((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],"
10945 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10946 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10947 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10948 new NHXParser() )[ 0 ];
10949 species7.setRooted( true );
10950 gene7.setRooted( true );
10951 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
10952 if ( sdi_unrooted.getCount() != 1 ) {
10955 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10958 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10961 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10964 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
10967 if ( !p7[ 0 ].getRoot().isDuplication() ) {
10970 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10973 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10976 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
10979 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
10982 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
10985 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
10988 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
10992 final Phylogeny species8 = factory
10993 .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,"
10994 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10995 new NHXParser() )[ 0 ];
10996 final Phylogeny gene8 = factory
10997 .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],"
10998 + "(((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],"
10999 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11000 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11001 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11002 new NHXParser() )[ 0 ];
11003 species8.setRooted( true );
11004 gene8.setRooted( true );
11005 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11006 if ( sdi_unrooted.getCount() != 1 ) {
11009 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11012 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11015 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11018 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11021 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11024 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11027 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11030 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11033 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11036 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11039 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11042 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11047 catch ( final Exception e ) {
11048 e.printStackTrace( System.out );
11054 private static boolean testSequenceDbWsTools1() {
11056 final PhylogenyNode n = new PhylogenyNode();
11057 n.setName( "NP_001025424" );
11058 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11059 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11060 || !acc.getValue().equals( "NP_001025424" ) ) {
11063 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11064 acc = SequenceDbWsTools.obtainSeqAccession( n );
11065 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11066 || !acc.getValue().equals( "NP_001025424" ) ) {
11069 n.setName( "NP_001025424.1" );
11070 acc = SequenceDbWsTools.obtainSeqAccession( n );
11071 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11072 || !acc.getValue().equals( "NP_001025424" ) ) {
11075 n.setName( "NM_001030253" );
11076 acc = SequenceDbWsTools.obtainSeqAccession( n );
11077 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11078 || !acc.getValue().equals( "NM_001030253" ) ) {
11081 n.setName( "BCL2_HUMAN" );
11082 acc = SequenceDbWsTools.obtainSeqAccession( n );
11083 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11084 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11085 System.out.println( acc.toString() );
11088 n.setName( "P10415" );
11089 acc = SequenceDbWsTools.obtainSeqAccession( n );
11090 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11091 || !acc.getValue().equals( "P10415" ) ) {
11092 System.out.println( acc.toString() );
11095 n.setName( " P10415 " );
11096 acc = SequenceDbWsTools.obtainSeqAccession( n );
11097 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11098 || !acc.getValue().equals( "P10415" ) ) {
11099 System.out.println( acc.toString() );
11102 n.setName( "_P10415|" );
11103 acc = SequenceDbWsTools.obtainSeqAccession( n );
11104 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11105 || !acc.getValue().equals( "P10415" ) ) {
11106 System.out.println( acc.toString() );
11109 n.setName( "AY695820" );
11110 acc = SequenceDbWsTools.obtainSeqAccession( n );
11111 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11112 || !acc.getValue().equals( "AY695820" ) ) {
11113 System.out.println( acc.toString() );
11116 n.setName( "_AY695820_" );
11117 acc = SequenceDbWsTools.obtainSeqAccession( n );
11118 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11119 || !acc.getValue().equals( "AY695820" ) ) {
11120 System.out.println( acc.toString() );
11123 n.setName( "AAA59452" );
11124 acc = SequenceDbWsTools.obtainSeqAccession( n );
11125 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11126 || !acc.getValue().equals( "AAA59452" ) ) {
11127 System.out.println( acc.toString() );
11130 n.setName( "_AAA59452_" );
11131 acc = SequenceDbWsTools.obtainSeqAccession( n );
11132 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11133 || !acc.getValue().equals( "AAA59452" ) ) {
11134 System.out.println( acc.toString() );
11137 n.setName( "AAA59452.1" );
11138 acc = SequenceDbWsTools.obtainSeqAccession( n );
11139 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11140 || !acc.getValue().equals( "AAA59452.1" ) ) {
11141 System.out.println( acc.toString() );
11144 n.setName( "_AAA59452.1_" );
11145 acc = SequenceDbWsTools.obtainSeqAccession( n );
11146 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11147 || !acc.getValue().equals( "AAA59452.1" ) ) {
11148 System.out.println( acc.toString() );
11151 n.setName( "GI:94894583" );
11152 acc = SequenceDbWsTools.obtainSeqAccession( n );
11153 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11154 || !acc.getValue().equals( "94894583" ) ) {
11155 System.out.println( acc.toString() );
11158 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11159 acc = SequenceDbWsTools.obtainSeqAccession( n );
11160 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11161 || !acc.getValue().equals( "71845847" ) ) {
11162 System.out.println( acc.toString() );
11165 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11166 acc = SequenceDbWsTools.obtainSeqAccession( n );
11167 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11168 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11169 System.out.println( acc.toString() );
11173 catch ( final Exception e ) {
11179 private static boolean testSequenceDbWsTools2() {
11181 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11182 SequenceDbWsTools.obtainSeqInformation( n1 );
11183 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11186 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11189 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11192 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11195 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11196 SequenceDbWsTools.obtainSeqInformation( n2 );
11197 if ( !n2.getNodeData().getSequence().getName()
11198 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11201 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11204 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11207 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11210 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11211 SequenceDbWsTools.obtainSeqInformation( n3 );
11212 if ( !n3.getNodeData().getSequence().getName()
11213 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11216 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11219 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11222 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11226 catch ( final IOException e ) {
11227 System.out.println();
11228 System.out.println( "the following might be due to absence internet connection:" );
11229 e.printStackTrace( System.out );
11232 catch ( final Exception e ) {
11233 e.printStackTrace();
11239 private static boolean testSequenceIdParsing() {
11241 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11242 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11243 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11244 if ( id != null ) {
11245 System.out.println( "value =" + id.getValue() );
11246 System.out.println( "provider=" + id.getSource() );
11251 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11252 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11253 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11254 if ( id != null ) {
11255 System.out.println( "value =" + id.getValue() );
11256 System.out.println( "provider=" + id.getSource() );
11261 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11262 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11263 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11264 if ( id != null ) {
11265 System.out.println( "value =" + id.getValue() );
11266 System.out.println( "provider=" + id.getSource() );
11271 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11272 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11273 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11274 if ( id != null ) {
11275 System.out.println( "value =" + id.getValue() );
11276 System.out.println( "provider=" + id.getSource() );
11281 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11282 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11283 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11284 if ( id != null ) {
11285 System.out.println( "value =" + id.getValue() );
11286 System.out.println( "provider=" + id.getSource() );
11291 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11292 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11293 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11294 if ( id != null ) {
11295 System.out.println( "value =" + id.getValue() );
11296 System.out.println( "provider=" + id.getSource() );
11301 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11302 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11303 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11304 if ( id != null ) {
11305 System.out.println( "value =" + id.getValue() );
11306 System.out.println( "provider=" + id.getSource() );
11311 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11312 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11313 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11314 if ( id != null ) {
11315 System.out.println( "value =" + id.getValue() );
11316 System.out.println( "provider=" + id.getSource() );
11321 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11322 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11323 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11324 if ( id != null ) {
11325 System.out.println( "value =" + id.getValue() );
11326 System.out.println( "provider=" + id.getSource() );
11331 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11332 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11333 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11334 if ( id != null ) {
11335 System.out.println( "value =" + id.getValue() );
11336 System.out.println( "provider=" + id.getSource() );
11340 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11341 if ( id != null ) {
11342 System.out.println( "value =" + id.getValue() );
11343 System.out.println( "provider=" + id.getSource() );
11347 catch ( final Exception e ) {
11348 e.printStackTrace( System.out );
11354 private static boolean testSequenceWriter() {
11356 final String n = ForesterUtil.LINE_SEPARATOR;
11357 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11360 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11363 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11366 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11369 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11370 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11373 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11374 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11378 catch ( final Exception e ) {
11379 e.printStackTrace();
11385 private static boolean testSpecies() {
11387 final Species s1 = new BasicSpecies( "a" );
11388 final Species s2 = new BasicSpecies( "a" );
11389 final Species s3 = new BasicSpecies( "A" );
11390 final Species s4 = new BasicSpecies( "b" );
11391 if ( !s1.equals( s1 ) ) {
11394 if ( s1.getSpeciesId().equals( "x" ) ) {
11397 if ( s1.getSpeciesId().equals( null ) ) {
11400 if ( !s1.equals( s2 ) ) {
11403 if ( s1.equals( s3 ) ) {
11406 if ( s1.hashCode() != s1.hashCode() ) {
11409 if ( s1.hashCode() != s2.hashCode() ) {
11412 if ( s1.hashCode() == s3.hashCode() ) {
11415 if ( s1.compareTo( s1 ) != 0 ) {
11418 if ( s1.compareTo( s2 ) != 0 ) {
11421 if ( s1.compareTo( s3 ) != 0 ) {
11424 if ( s1.compareTo( s4 ) >= 0 ) {
11427 if ( s4.compareTo( s1 ) <= 0 ) {
11430 if ( !s4.getSpeciesId().equals( "b" ) ) {
11433 final Species s5 = new BasicSpecies( " C " );
11434 if ( !s5.getSpeciesId().equals( "C" ) ) {
11437 if ( s5.equals( s1 ) ) {
11441 catch ( final Exception e ) {
11442 e.printStackTrace( System.out );
11448 private static boolean testSplit() {
11450 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11451 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11452 //Archaeopteryx.createApplication( p0 );
11453 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11454 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11455 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11456 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11457 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11458 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11459 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11460 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11461 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11462 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11463 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11464 // System.out.println( s0.toString() );
11466 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11467 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11469 if ( s0.match( query_nodes ) ) {
11472 query_nodes = new HashSet<PhylogenyNode>();
11473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11475 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11476 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11480 if ( !s0.match( query_nodes ) ) {
11484 query_nodes = new HashSet<PhylogenyNode>();
11485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11488 if ( !s0.match( query_nodes ) ) {
11492 query_nodes = new HashSet<PhylogenyNode>();
11493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11497 if ( !s0.match( query_nodes ) ) {
11501 query_nodes = new HashSet<PhylogenyNode>();
11502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11505 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11506 if ( !s0.match( query_nodes ) ) {
11510 query_nodes = new HashSet<PhylogenyNode>();
11511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11513 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11514 if ( !s0.match( query_nodes ) ) {
11518 query_nodes = new HashSet<PhylogenyNode>();
11519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11521 if ( !s0.match( query_nodes ) ) {
11525 query_nodes = new HashSet<PhylogenyNode>();
11526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11531 if ( !s0.match( query_nodes ) ) {
11535 query_nodes = new HashSet<PhylogenyNode>();
11536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11537 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11538 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11539 if ( !s0.match( query_nodes ) ) {
11543 query_nodes = new HashSet<PhylogenyNode>();
11544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11548 if ( !s0.match( query_nodes ) ) {
11552 query_nodes = new HashSet<PhylogenyNode>();
11553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11555 if ( s0.match( query_nodes ) ) {
11559 query_nodes = new HashSet<PhylogenyNode>();
11560 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11561 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11564 if ( s0.match( query_nodes ) ) {
11568 query_nodes = new HashSet<PhylogenyNode>();
11569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11572 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11574 if ( s0.match( query_nodes ) ) {
11578 query_nodes = new HashSet<PhylogenyNode>();
11579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11580 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11581 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11582 if ( s0.match( query_nodes ) ) {
11586 query_nodes = new HashSet<PhylogenyNode>();
11587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11589 if ( s0.match( query_nodes ) ) {
11593 query_nodes = new HashSet<PhylogenyNode>();
11594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11596 if ( s0.match( query_nodes ) ) {
11600 query_nodes = new HashSet<PhylogenyNode>();
11601 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11603 if ( s0.match( query_nodes ) ) {
11607 query_nodes = new HashSet<PhylogenyNode>();
11608 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11609 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11610 if ( s0.match( query_nodes ) ) {
11614 query_nodes = new HashSet<PhylogenyNode>();
11615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11617 if ( s0.match( query_nodes ) ) {
11621 query_nodes = new HashSet<PhylogenyNode>();
11622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11624 if ( s0.match( query_nodes ) ) {
11628 query_nodes = new HashSet<PhylogenyNode>();
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11632 if ( s0.match( query_nodes ) ) {
11636 query_nodes = new HashSet<PhylogenyNode>();
11637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11640 if ( s0.match( query_nodes ) ) {
11644 query_nodes = new HashSet<PhylogenyNode>();
11645 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11648 if ( s0.match( query_nodes ) ) {
11652 query_nodes = new HashSet<PhylogenyNode>();
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11657 if ( s0.match( query_nodes ) ) {
11661 // query_nodes = new HashSet<PhylogenyNode>();
11662 // query_nodes.add( new PhylogenyNode( "X" ) );
11663 // query_nodes.add( new PhylogenyNode( "Y" ) );
11664 // query_nodes.add( new PhylogenyNode( "A" ) );
11665 // query_nodes.add( new PhylogenyNode( "B" ) );
11666 // query_nodes.add( new PhylogenyNode( "C" ) );
11667 // query_nodes.add( new PhylogenyNode( "D" ) );
11668 // query_nodes.add( new PhylogenyNode( "E" ) );
11669 // query_nodes.add( new PhylogenyNode( "F" ) );
11670 // query_nodes.add( new PhylogenyNode( "G" ) );
11671 // if ( !s0.match( query_nodes ) ) {
11674 // query_nodes = new HashSet<PhylogenyNode>();
11675 // query_nodes.add( new PhylogenyNode( "X" ) );
11676 // query_nodes.add( new PhylogenyNode( "Y" ) );
11677 // query_nodes.add( new PhylogenyNode( "A" ) );
11678 // query_nodes.add( new PhylogenyNode( "B" ) );
11679 // query_nodes.add( new PhylogenyNode( "C" ) );
11680 // if ( !s0.match( query_nodes ) ) {
11684 // query_nodes = new HashSet<PhylogenyNode>();
11685 // query_nodes.add( new PhylogenyNode( "X" ) );
11686 // query_nodes.add( new PhylogenyNode( "Y" ) );
11687 // query_nodes.add( new PhylogenyNode( "D" ) );
11688 // query_nodes.add( new PhylogenyNode( "E" ) );
11689 // query_nodes.add( new PhylogenyNode( "F" ) );
11690 // query_nodes.add( new PhylogenyNode( "G" ) );
11691 // if ( !s0.match( query_nodes ) ) {
11695 // query_nodes = new HashSet<PhylogenyNode>();
11696 // query_nodes.add( new PhylogenyNode( "X" ) );
11697 // query_nodes.add( new PhylogenyNode( "Y" ) );
11698 // query_nodes.add( new PhylogenyNode( "A" ) );
11699 // query_nodes.add( new PhylogenyNode( "B" ) );
11700 // query_nodes.add( new PhylogenyNode( "C" ) );
11701 // query_nodes.add( new PhylogenyNode( "D" ) );
11702 // if ( !s0.match( query_nodes ) ) {
11706 // query_nodes = new HashSet<PhylogenyNode>();
11707 // query_nodes.add( new PhylogenyNode( "X" ) );
11708 // query_nodes.add( new PhylogenyNode( "Y" ) );
11709 // query_nodes.add( new PhylogenyNode( "E" ) );
11710 // query_nodes.add( new PhylogenyNode( "F" ) );
11711 // query_nodes.add( new PhylogenyNode( "G" ) );
11712 // if ( !s0.match( query_nodes ) ) {
11716 // query_nodes = new HashSet<PhylogenyNode>();
11717 // query_nodes.add( new PhylogenyNode( "X" ) );
11718 // query_nodes.add( new PhylogenyNode( "Y" ) );
11719 // query_nodes.add( new PhylogenyNode( "F" ) );
11720 // query_nodes.add( new PhylogenyNode( "G" ) );
11721 // if ( !s0.match( query_nodes ) ) {
11725 query_nodes = new HashSet<PhylogenyNode>();
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11730 if ( s0.match( query_nodes ) ) {
11734 query_nodes = new HashSet<PhylogenyNode>();
11735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11739 if ( s0.match( query_nodes ) ) {
11742 ///////////////////////////
11744 query_nodes = new HashSet<PhylogenyNode>();
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11749 if ( s0.match( query_nodes ) ) {
11753 query_nodes = new HashSet<PhylogenyNode>();
11754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11757 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11758 if ( s0.match( query_nodes ) ) {
11762 query_nodes = new HashSet<PhylogenyNode>();
11763 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11767 if ( s0.match( query_nodes ) ) {
11771 query_nodes = new HashSet<PhylogenyNode>();
11772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11776 if ( s0.match( query_nodes ) ) {
11780 query_nodes = new HashSet<PhylogenyNode>();
11781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11785 if ( s0.match( query_nodes ) ) {
11789 query_nodes = new HashSet<PhylogenyNode>();
11790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11793 if ( s0.match( query_nodes ) ) {
11797 query_nodes = new HashSet<PhylogenyNode>();
11798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11800 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11801 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11802 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11803 if ( s0.match( query_nodes ) ) {
11807 query_nodes = new HashSet<PhylogenyNode>();
11808 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11809 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11810 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11811 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11813 if ( s0.match( query_nodes ) ) {
11817 query_nodes = new HashSet<PhylogenyNode>();
11818 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11819 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11823 if ( s0.match( query_nodes ) ) {
11827 query_nodes = new HashSet<PhylogenyNode>();
11828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11834 if ( s0.match( query_nodes ) ) {
11838 catch ( final Exception e ) {
11839 e.printStackTrace();
11845 private static boolean testSplitStrict() {
11847 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11848 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11849 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11850 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11851 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11852 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11853 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11854 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11855 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11856 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11857 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11858 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11859 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11861 if ( s0.match( query_nodes ) ) {
11864 query_nodes = new HashSet<PhylogenyNode>();
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11867 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11872 if ( !s0.match( query_nodes ) ) {
11876 query_nodes = new HashSet<PhylogenyNode>();
11877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11880 if ( !s0.match( query_nodes ) ) {
11884 query_nodes = new HashSet<PhylogenyNode>();
11885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11889 if ( !s0.match( query_nodes ) ) {
11893 query_nodes = new HashSet<PhylogenyNode>();
11894 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11898 if ( !s0.match( query_nodes ) ) {
11902 query_nodes = new HashSet<PhylogenyNode>();
11903 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11904 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11906 if ( !s0.match( query_nodes ) ) {
11910 query_nodes = new HashSet<PhylogenyNode>();
11911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11912 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11913 if ( !s0.match( query_nodes ) ) {
11917 query_nodes = new HashSet<PhylogenyNode>();
11918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11923 if ( !s0.match( query_nodes ) ) {
11927 query_nodes = new HashSet<PhylogenyNode>();
11928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11931 if ( !s0.match( query_nodes ) ) {
11935 query_nodes = new HashSet<PhylogenyNode>();
11936 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11937 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11938 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11939 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11940 if ( !s0.match( query_nodes ) ) {
11944 query_nodes = new HashSet<PhylogenyNode>();
11945 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11946 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11947 if ( s0.match( query_nodes ) ) {
11951 query_nodes = new HashSet<PhylogenyNode>();
11952 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11953 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11954 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11955 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11956 if ( s0.match( query_nodes ) ) {
11960 query_nodes = new HashSet<PhylogenyNode>();
11961 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11966 if ( s0.match( query_nodes ) ) {
11970 query_nodes = new HashSet<PhylogenyNode>();
11971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11972 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11973 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11974 if ( s0.match( query_nodes ) ) {
11978 query_nodes = new HashSet<PhylogenyNode>();
11979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11980 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11981 if ( s0.match( query_nodes ) ) {
11985 query_nodes = new HashSet<PhylogenyNode>();
11986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11988 if ( s0.match( query_nodes ) ) {
11992 query_nodes = new HashSet<PhylogenyNode>();
11993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11995 if ( s0.match( query_nodes ) ) {
11999 query_nodes = new HashSet<PhylogenyNode>();
12000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12002 if ( s0.match( query_nodes ) ) {
12006 query_nodes = new HashSet<PhylogenyNode>();
12007 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12009 if ( s0.match( query_nodes ) ) {
12013 query_nodes = new HashSet<PhylogenyNode>();
12014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12016 if ( s0.match( query_nodes ) ) {
12020 query_nodes = new HashSet<PhylogenyNode>();
12021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12024 if ( s0.match( query_nodes ) ) {
12028 query_nodes = new HashSet<PhylogenyNode>();
12029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12032 if ( s0.match( query_nodes ) ) {
12036 query_nodes = new HashSet<PhylogenyNode>();
12037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12040 if ( s0.match( query_nodes ) ) {
12044 query_nodes = new HashSet<PhylogenyNode>();
12045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12046 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12048 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12049 if ( s0.match( query_nodes ) ) {
12053 catch ( final Exception e ) {
12054 e.printStackTrace();
12060 private static boolean testSubtreeDeletion() {
12062 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12063 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12064 t1.deleteSubtree( t1.getNode( "A" ), false );
12065 if ( t1.getNumberOfExternalNodes() != 5 ) {
12068 t1.toNewHampshireX();
12069 t1.deleteSubtree( t1.getNode( "E" ), false );
12070 if ( t1.getNumberOfExternalNodes() != 4 ) {
12073 t1.toNewHampshireX();
12074 t1.deleteSubtree( t1.getNode( "F" ), false );
12075 if ( t1.getNumberOfExternalNodes() != 3 ) {
12078 t1.toNewHampshireX();
12079 t1.deleteSubtree( t1.getNode( "D" ), false );
12080 t1.toNewHampshireX();
12081 if ( t1.getNumberOfExternalNodes() != 3 ) {
12084 t1.deleteSubtree( t1.getNode( "def" ), false );
12085 t1.toNewHampshireX();
12086 if ( t1.getNumberOfExternalNodes() != 2 ) {
12089 t1.deleteSubtree( t1.getNode( "B" ), false );
12090 t1.toNewHampshireX();
12091 if ( t1.getNumberOfExternalNodes() != 1 ) {
12094 t1.deleteSubtree( t1.getNode( "C" ), false );
12095 t1.toNewHampshireX();
12096 if ( t1.getNumberOfExternalNodes() != 1 ) {
12099 t1.deleteSubtree( t1.getNode( "abc" ), false );
12100 t1.toNewHampshireX();
12101 if ( t1.getNumberOfExternalNodes() != 1 ) {
12104 t1.deleteSubtree( t1.getNode( "r" ), false );
12105 if ( t1.getNumberOfExternalNodes() != 0 ) {
12108 if ( !t1.isEmpty() ) {
12111 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12112 t2.deleteSubtree( t2.getNode( "A" ), false );
12113 t2.toNewHampshireX();
12114 if ( t2.getNumberOfExternalNodes() != 5 ) {
12117 t2.deleteSubtree( t2.getNode( "abc" ), false );
12118 t2.toNewHampshireX();
12119 if ( t2.getNumberOfExternalNodes() != 3 ) {
12122 t2.deleteSubtree( t2.getNode( "def" ), false );
12123 t2.toNewHampshireX();
12124 if ( t2.getNumberOfExternalNodes() != 1 ) {
12128 catch ( final Exception e ) {
12129 e.printStackTrace( System.out );
12135 private static boolean testSupportCount() {
12137 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12138 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12139 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12140 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12141 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12142 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12143 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12145 SupportCount.count( t0_1, phylogenies_1, true, false );
12146 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12147 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12148 + "(((((A,B),C),D),E),((F,G),X))"
12149 + "(((((A,Y),B),C),D),((F,G),E))"
12150 + "(((((A,B),C),D),E),(F,G))"
12151 + "(((((A,B),C),D),E),(F,G))"
12152 + "(((((A,B),C),D),E),(F,G))"
12153 + "(((((A,B),C),D),E),(F,G),Z)"
12154 + "(((((A,B),C),D),E),(F,G))"
12155 + "((((((A,B),C),D),E),F),G)"
12156 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12158 SupportCount.count( t0_2, phylogenies_2, true, false );
12159 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12160 while ( it.hasNext() ) {
12161 final PhylogenyNode n = it.next();
12162 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12166 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12167 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12168 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12169 SupportCount.count( t0_3, phylogenies_3, true, false );
12170 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12171 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12174 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12177 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12180 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12183 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12186 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12189 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12192 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12195 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12198 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12201 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12202 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12203 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12204 SupportCount.count( t0_4, phylogenies_4, true, false );
12205 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12206 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12209 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12212 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12215 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12218 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12221 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12224 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12227 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12230 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12233 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12236 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12237 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12238 double d = SupportCount.compare( b1, a, true, true, true );
12239 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12242 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12243 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12244 d = SupportCount.compare( b2, a, true, true, true );
12245 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12248 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12249 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12250 d = SupportCount.compare( b3, a, true, true, true );
12251 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12254 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12255 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12256 d = SupportCount.compare( b4, a, true, true, false );
12257 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12261 catch ( final Exception e ) {
12262 e.printStackTrace( System.out );
12268 private static boolean testSupportTransfer() {
12270 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12271 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)",
12272 new NHXParser() )[ 0 ];
12273 final Phylogeny p2 = factory
12274 .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 ];
12275 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12278 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12281 support_transfer.moveBranchLengthsToBootstrap( p1 );
12282 support_transfer.transferSupportValues( p1, p2 );
12283 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12286 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12289 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12292 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12295 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12298 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12301 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12304 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12308 catch ( final Exception e ) {
12309 e.printStackTrace( System.out );
12315 private static boolean testTaxonomyExtraction() {
12317 final PhylogenyNode n0 = PhylogenyNode
12318 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12319 if ( n0.getNodeData().isHasTaxonomy() ) {
12322 final PhylogenyNode n1 = PhylogenyNode
12323 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12324 if ( n1.getNodeData().isHasTaxonomy() ) {
12325 System.out.println( n1.toString() );
12328 final PhylogenyNode n2x = PhylogenyNode
12329 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12330 if ( n2x.getNodeData().isHasTaxonomy() ) {
12333 final PhylogenyNode n3 = PhylogenyNode
12334 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12335 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12336 System.out.println( n3.toString() );
12339 final PhylogenyNode n4 = PhylogenyNode
12340 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12341 if ( n4.getNodeData().isHasTaxonomy() ) {
12342 System.out.println( n4.toString() );
12345 final PhylogenyNode n5 = PhylogenyNode
12346 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12347 if ( n5.getNodeData().isHasTaxonomy() ) {
12348 System.out.println( n5.toString() );
12351 final PhylogenyNode n6 = PhylogenyNode
12352 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12353 if ( n6.getNodeData().isHasTaxonomy() ) {
12354 System.out.println( n6.toString() );
12357 final PhylogenyNode n7 = PhylogenyNode
12358 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12359 if ( n7.getNodeData().isHasTaxonomy() ) {
12360 System.out.println( n7.toString() );
12363 final PhylogenyNode n8 = PhylogenyNode
12364 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12365 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12366 System.out.println( n8.toString() );
12369 final PhylogenyNode n9 = PhylogenyNode
12370 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12371 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12372 System.out.println( n9.toString() );
12375 final PhylogenyNode n10x = PhylogenyNode
12376 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12377 if ( n10x.getNodeData().isHasTaxonomy() ) {
12378 System.out.println( n10x.toString() );
12381 final PhylogenyNode n10xx = PhylogenyNode
12382 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12383 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12384 System.out.println( n10xx.toString() );
12387 final PhylogenyNode n10 = PhylogenyNode
12388 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12389 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12390 System.out.println( n10.toString() );
12393 final PhylogenyNode n11 = PhylogenyNode
12394 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12395 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12396 System.out.println( n11.toString() );
12399 final PhylogenyNode n12 = PhylogenyNode
12400 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12401 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12402 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12403 System.out.println( n12.toString() );
12406 final PhylogenyNode n13 = PhylogenyNode
12407 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12408 if ( n13.getNodeData().isHasTaxonomy() ) {
12409 System.out.println( n13.toString() );
12412 final PhylogenyNode n14 = PhylogenyNode
12413 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12414 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12415 System.out.println( n14.toString() );
12418 final PhylogenyNode n15 = PhylogenyNode
12419 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12420 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12421 System.out.println( n15.toString() );
12424 final PhylogenyNode n16 = PhylogenyNode
12425 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12426 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12427 System.out.println( n16.toString() );
12430 final PhylogenyNode n17 = PhylogenyNode
12431 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12432 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12433 System.out.println( n17.toString() );
12437 final PhylogenyNode n18 = PhylogenyNode
12438 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12439 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12440 System.out.println( n18.toString() );
12443 final PhylogenyNode n19 = PhylogenyNode
12444 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12445 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12446 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12447 System.out.println( n19.toString() );
12450 final PhylogenyNode n20 = PhylogenyNode
12451 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12452 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12453 System.out.println( n20.toString() );
12456 final PhylogenyNode n21 = PhylogenyNode
12457 .createInstanceFromNhxString( "Mus musculus musculus K392",
12458 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12459 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12460 System.out.println( n21.toString() );
12463 final PhylogenyNode n22 = PhylogenyNode
12464 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12465 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12466 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12467 System.out.println( n22.toString() );
12470 final PhylogenyNode n23 = PhylogenyNode
12471 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12472 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12473 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12474 System.out.println( n23.toString() );
12477 final PhylogenyNode n24 = PhylogenyNode
12478 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12479 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12480 System.out.println( n24.toString() );
12484 final PhylogenyNode n25 = PhylogenyNode
12485 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12486 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12487 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12488 System.out.println( n25.toString() );
12491 final PhylogenyNode n26 = PhylogenyNode
12492 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12493 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12494 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12495 System.out.println( n26.toString() );
12498 final PhylogenyNode n27 = PhylogenyNode
12499 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12500 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12501 System.out.println( n27.toString() );
12505 catch ( final Exception e ) {
12506 e.printStackTrace( System.out );
12512 private static boolean testTreeCopy() {
12514 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12515 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12516 final Phylogeny t1 = t0.copy();
12517 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12520 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12523 t0.deleteSubtree( t0.getNode( "c" ), true );
12524 t0.deleteSubtree( t0.getNode( "a" ), true );
12525 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12526 t0.getNode( "b" ).setName( "Bee" );
12527 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12530 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12533 t0.deleteSubtree( t0.getNode( "e" ), true );
12534 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12535 t0.deleteSubtree( t0.getNode( "d" ), true );
12536 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12540 catch ( final Exception e ) {
12541 e.printStackTrace();
12547 private static boolean testTreeMethods() {
12549 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12550 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12551 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12552 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12553 System.out.println( t0.toNewHampshireX() );
12556 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12557 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12558 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12561 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12564 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12568 catch ( final Exception e ) {
12569 e.printStackTrace( System.out );
12575 private static boolean testUniprotEntryRetrieval() {
12577 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12578 if ( !entry.getAccession().equals( "P12345" ) ) {
12581 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12584 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12587 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12590 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12593 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12597 catch ( final IOException e ) {
12598 System.out.println();
12599 System.out.println( "the following might be due to absence internet connection:" );
12600 e.printStackTrace( System.out );
12603 catch ( final Exception e ) {
12609 private static boolean testUniprotTaxonomySearch() {
12611 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12613 if ( results.size() != 1 ) {
12616 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12619 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12622 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12625 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12628 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12632 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12633 if ( results.size() != 1 ) {
12636 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12639 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12642 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12645 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12648 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12652 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12653 if ( results.size() != 1 ) {
12656 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12659 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12662 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12665 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12668 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12672 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12673 if ( results.size() != 1 ) {
12676 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12679 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12682 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12685 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12688 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12691 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12694 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12697 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12698 .equals( "Nematostella vectensis" ) ) {
12699 System.out.println( results.get( 0 ).getLineage() );
12704 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12705 if ( results.size() != 1 ) {
12708 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12711 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12714 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12717 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12720 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12723 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12724 .equals( "Xenopus tropicalis" ) ) {
12725 System.out.println( results.get( 0 ).getLineage() );
12730 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12731 if ( results.size() != 1 ) {
12734 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12737 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12740 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12743 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12746 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12749 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12750 .equals( "Xenopus tropicalis" ) ) {
12751 System.out.println( results.get( 0 ).getLineage() );
12756 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12757 if ( results.size() != 1 ) {
12760 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12763 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12766 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12769 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12772 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12775 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12776 .equals( "Xenopus tropicalis" ) ) {
12777 System.out.println( results.get( 0 ).getLineage() );
12781 catch ( final IOException e ) {
12782 System.out.println();
12783 System.out.println( "the following might be due to absence internet connection:" );
12784 e.printStackTrace( System.out );
12787 catch ( final Exception e ) {
12793 private static boolean testWabiTxSearch() {
12795 String result = "";
12796 result = TxSearch.searchSimple( "nematostella" );
12797 result = TxSearch.getTxId( "nematostella" );
12798 if ( !result.equals( "45350" ) ) {
12801 result = TxSearch.getTxName( "45350" );
12802 if ( !result.equals( "Nematostella" ) ) {
12805 result = TxSearch.getTxId( "nematostella vectensis" );
12806 if ( !result.equals( "45351" ) ) {
12809 result = TxSearch.getTxName( "45351" );
12810 if ( !result.equals( "Nematostella vectensis" ) ) {
12813 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12814 if ( !result.equals( "536089" ) ) {
12817 result = TxSearch.getTxName( "536089" );
12818 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12821 final List<String> queries = new ArrayList<String>();
12822 queries.add( "Campylobacter coli" );
12823 queries.add( "Escherichia coli" );
12824 queries.add( "Arabidopsis" );
12825 queries.add( "Trichoplax" );
12826 queries.add( "Samanea saman" );
12827 queries.add( "Kluyveromyces marxianus" );
12828 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12829 queries.add( "Bornavirus parrot/PDD/2008" );
12830 final List<RANKS> ranks = new ArrayList<RANKS>();
12831 ranks.add( RANKS.SUPERKINGDOM );
12832 ranks.add( RANKS.KINGDOM );
12833 ranks.add( RANKS.FAMILY );
12834 ranks.add( RANKS.GENUS );
12835 ranks.add( RANKS.TRIBE );
12836 result = TxSearch.searchLineage( queries, ranks );
12837 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12838 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12840 catch ( final Exception e ) {
12841 System.out.println();
12842 System.out.println( "the following might be due to absence internet connection:" );
12843 e.printStackTrace( System.out );