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.AptxUtil;
45 import org.forester.archaeopteryx.TreePanelUtil;
46 import org.forester.archaeopteryx.webservices.WebserviceUtil;
47 import org.forester.clade_analysis.CladeAnalysisTest;
48 import org.forester.development.DevelopmentTools;
49 import org.forester.evoinference.TestPhylogenyReconstruction;
50 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
51 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
52 import org.forester.go.TestGo;
53 import org.forester.io.parsers.FastaParser;
54 import org.forester.io.parsers.GeneralMsaParser;
55 import org.forester.io.parsers.HmmscanPerDomainTableParser;
56 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
57 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
58 import org.forester.io.parsers.nexus.NexusCharactersParser;
59 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
60 import org.forester.io.parsers.nhx.NHXParser;
61 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
62 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
63 import org.forester.io.parsers.tol.TolParser;
64 import org.forester.io.parsers.util.ParserUtils;
65 import org.forester.io.writers.PhylogenyWriter;
66 import org.forester.io.writers.SequenceWriter;
67 import org.forester.msa.BasicMsa;
68 import org.forester.msa.DeleteableMsa;
69 import org.forester.msa.Mafft;
70 import org.forester.msa.Msa;
71 import org.forester.msa.Msa.MSA_FORMAT;
72 import org.forester.msa.MsaInferrer;
73 import org.forester.msa.MsaMethods;
74 import org.forester.pccx.TestPccx;
75 import org.forester.phylogeny.Phylogeny;
76 import org.forester.phylogeny.PhylogenyBranch;
77 import org.forester.phylogeny.PhylogenyMethods;
78 import org.forester.phylogeny.PhylogenyNode;
79 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
80 import org.forester.phylogeny.data.Accession;
81 import org.forester.phylogeny.data.Accession.Source;
82 import org.forester.phylogeny.data.BinaryCharacters;
83 import org.forester.phylogeny.data.BranchWidth;
84 import org.forester.phylogeny.data.Confidence;
85 import org.forester.phylogeny.data.Distribution;
86 import org.forester.phylogeny.data.DomainArchitecture;
87 import org.forester.phylogeny.data.Event;
88 import org.forester.phylogeny.data.Identifier;
89 import org.forester.phylogeny.data.PhylogenyData;
90 import org.forester.phylogeny.data.PhylogenyDataUtil;
91 import org.forester.phylogeny.data.Polygon;
92 import org.forester.phylogeny.data.PropertiesList;
93 import org.forester.phylogeny.data.Property;
94 import org.forester.phylogeny.data.Property.AppliesTo;
95 import org.forester.phylogeny.data.ProteinDomain;
96 import org.forester.phylogeny.data.Taxonomy;
97 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
98 import org.forester.phylogeny.factories.PhylogenyFactory;
99 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
100 import org.forester.protein.BasicDomain;
101 import org.forester.protein.BasicProtein;
102 import org.forester.protein.Domain;
103 import org.forester.protein.Protein;
104 import org.forester.protein.ProteinId;
105 import org.forester.rio.TestRIO;
106 import org.forester.sdi.SDI;
107 import org.forester.sdi.SDIR;
108 import org.forester.sdi.TestGSDI;
109 import org.forester.sequence.BasicSequence;
110 import org.forester.sequence.MolecularSequence;
111 import org.forester.species.BasicSpecies;
112 import org.forester.species.Species;
113 import org.forester.surfacing.TestSurfacing;
114 import org.forester.tools.ConfidenceAssessor;
115 import org.forester.tools.SupportCount;
116 import org.forester.tools.TreeSplitMatrix;
117 import org.forester.util.AsciiHistogram;
118 import org.forester.util.BasicDescriptiveStatistics;
119 import org.forester.util.BasicTable;
120 import org.forester.util.BasicTableParser;
121 import org.forester.util.DescriptiveStatistics;
122 import org.forester.util.ForesterConstants;
123 import org.forester.util.ForesterUtil;
124 import org.forester.util.GeneralTable;
125 import org.forester.util.SequenceAccessionTools;
126 import org.forester.ws.seqdb.SequenceDatabaseEntry;
127 import org.forester.ws.seqdb.SequenceDbWsTools;
128 import org.forester.ws.seqdb.UniProtTaxonomy;
130 @SuppressWarnings( "unused")
131 public final class Test {
133 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
134 + ForesterUtil.getFileSeparator() + "resources" + ForesterUtil.getFileSeparator();
135 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
136 + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator();
137 private final static boolean PERFORM_DB_TESTS = false;
138 private static final boolean PERFORM_WEB_TREE_ACCESS = false;
139 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
140 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
141 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
142 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
143 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
144 private final static double ZERO_DIFF = 1.0E-9;
146 private static boolean isEqual( final double a, final double b ) {
147 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
150 public static void main( final String[] args ) {
151 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
152 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
154 Locale.setDefault( Locale.US );
155 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
158 System.out.print( "[Test if directory with files for testing exists/is readable: " );
159 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
160 System.out.println( "OK.]" );
163 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
164 System.out.println( "Testing aborted." );
167 System.out.print( "[Test if resources directory exists/is readable: " );
168 if ( testDir( PATH_TO_RESOURCES ) ) {
169 System.out.println( "OK.]" );
172 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
173 System.out.println( "Testing aborted." );
176 final long start_time = new Date().getTime();
177 System.out.print( "Basic node methods: " );
178 if ( Test.testBasicNodeMethods() ) {
179 System.out.println( "OK." );
183 System.out.println( "failed." );
186 System.out.print( "Protein id: " );
187 if ( !testProteinId() ) {
188 System.out.println( "failed." );
194 System.out.println( "OK." );
195 System.out.print( "Species: " );
196 if ( !testSpecies() ) {
197 System.out.println( "failed." );
203 System.out.println( "OK." );
204 System.out.print( "Basic domain: " );
205 if ( !testBasicDomain() ) {
206 System.out.println( "failed." );
212 System.out.println( "OK." );
213 System.out.print( "Basic protein: " );
214 if ( !testBasicProtein() ) {
215 System.out.println( "failed." );
221 System.out.println( "OK." );
222 System.out.print( "Common prefix: " );
223 if ( !testCommonPrefix() ) {
224 System.out.println( "failed." );
230 System.out.println( "OK." );
231 System.out.print( "Common prefix sep: " );
232 if ( !testCommonPrefixSep() ) {
233 System.out.println( "failed." );
239 System.out.println( "OK." );
240 System.out.print( "Contains prefix: " );
241 if ( !testContainsPrefix() ) {
242 System.out.println( "failed." );
248 System.out.println( "OK." );
249 System.out.print( "Sequence writer: " );
250 if ( testSequenceWriter() ) {
251 System.out.println( "OK." );
255 System.out.println( "failed." );
258 System.out.print( "Sequence id parsing: " );
259 if ( testSequenceIdParsing() ) {
260 System.out.println( "OK." );
264 System.out.println( "failed." );
267 System.out.print( "UniProtKB id extraction: " );
268 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
269 System.out.println( "OK." );
273 System.out.println( "failed." );
276 System.out.print( "Sequence DB tools 1: " );
277 if ( testSequenceDbWsTools1() ) {
278 System.out.println( "OK." );
282 System.out.println( "failed." );
285 System.out.print( "Hmmscan output parser: " );
286 if ( testHmmscanOutputParser() ) {
287 System.out.println( "OK." );
291 System.out.println( "failed." );
294 System.out.print( "Overlap removal: " );
295 if ( !org.forester.test.Test.testOverlapRemoval() ) {
296 System.out.println( "failed." );
302 System.out.println( "OK." );
303 System.out.print( "Engulfing overlap removal: " );
304 if ( !Test.testEngulfingOverlapRemoval() ) {
305 System.out.println( "failed." );
311 System.out.println( "OK." );
312 System.out.print( "Taxonomy data extraction: " );
313 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
314 System.out.println( "OK." );
318 System.out.println( "failed." );
321 System.out.print( "Taxonomy code extraction: " );
322 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
323 System.out.println( "OK." );
327 System.out.println( "failed." );
330 System.out.print( "SN extraction: " );
331 if ( Test.testExtractSNFromNodeName() ) {
332 System.out.println( "OK." );
336 System.out.println( "failed." );
339 System.out.print( "Taxonomy extraction (general): " );
340 if ( Test.testTaxonomyExtraction() ) {
341 System.out.println( "OK." );
345 System.out.println( "failed." );
348 System.out.print( "Uri for Aptx web sequence accession: " );
349 if ( Test.testCreateUriForSeqWeb() ) {
350 System.out.println( "OK." );
354 System.out.println( "failed." );
357 System.out.print( "Basic node construction and parsing of NHX (node level): " );
358 if ( Test.testNHXNodeParsing() ) {
359 System.out.println( "OK." );
363 System.out.println( "failed." );
366 System.out.print( "Node construction and parsing of NHX (node level): " );
367 if ( Test.testNHXNodeParsing2() ) {
368 System.out.println( "OK." );
372 System.out.println( "failed." );
375 System.out.print( "NHX parsing iterating: " );
376 if ( Test.testNHParsingIter() ) {
377 System.out.println( "OK." );
381 System.out.println( "failed." );
384 System.out.print( "NH parsing: " );
385 if ( Test.testNHParsing() ) {
386 System.out.println( "OK." );
390 System.out.println( "failed." );
393 System.out.print( "NH parsing - special chars: " );
394 if ( Test.testNHParsingSpecialChars() ) {
395 System.out.println( "OK." );
399 System.out.println( "failed." );
402 System.out.print( "Conversion to NHX (node level): " );
403 if ( Test.testNHXconversion() ) {
404 System.out.println( "OK." );
408 System.out.println( "failed." );
411 System.out.print( "NHX parsing: " );
412 if ( Test.testNHXParsing() ) {
413 System.out.println( "OK." );
417 System.out.println( "failed." );
420 System.out.print( "NHX parsing with quotes: " );
421 if ( Test.testNHXParsingQuotes() ) {
422 System.out.println( "OK." );
426 System.out.println( "failed." );
429 System.out.print( "NHX parsing (MrBayes): " );
430 if ( Test.testNHXParsingMB() ) {
431 System.out.println( "OK." );
435 System.out.println( "failed." );
438 System.out.print( "Nexus characters parsing: " );
439 if ( Test.testNexusCharactersParsing() ) {
440 System.out.println( "OK." );
444 System.out.println( "failed." );
447 System.out.print( "Nexus tree parsing iterating: " );
448 if ( Test.testNexusTreeParsingIterating() ) {
449 System.out.println( "OK." );
453 System.out.println( "failed." );
456 System.out.print( "Nexus tree parsing: " );
457 if ( Test.testNexusTreeParsing() ) {
458 System.out.println( "OK." );
462 System.out.println( "failed." );
465 System.out.print( "Nexus tree parsing (translating): " );
466 if ( Test.testNexusTreeParsingTranslating() ) {
467 System.out.println( "OK." );
471 System.out.println( "failed." );
474 System.out.print( "Nexus matrix parsing: " );
475 if ( Test.testNexusMatrixParsing() ) {
476 System.out.println( "OK." );
480 System.out.println( "failed." );
483 System.out.print( "Basic phyloXML parsing: " );
484 if ( Test.testBasicPhyloXMLparsing() ) {
485 System.out.println( "OK." );
489 System.out.println( "failed." );
492 System.out.print( "Basic phyloXML parsing (validating against schema): " );
493 if ( testBasicPhyloXMLparsingValidating() ) {
494 System.out.println( "OK." );
498 System.out.println( "failed." );
501 System.out.print( "phyloXML parsing (validating against schema): " );
502 if ( testPhyloXMLparsingValidating() ) {
503 System.out.println( "OK." );
507 System.out.println( "failed." );
510 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
511 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
512 System.out.println( "OK." );
516 System.out.println( "failed." );
519 System.out.print( "phyloXML Distribution Element: " );
520 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
521 System.out.println( "OK." );
525 System.out.println( "failed." );
528 System.out.print( "Tol XML parsing: " );
529 if ( Test.testBasicTolXMLparsing() ) {
530 System.out.println( "OK." );
534 System.out.println( "failed." );
537 System.out.print( "UTF-8 parsing from file: " );
538 if ( Test.testUTF8ParsingFromFile() ) {
539 System.out.println( "OK." );
543 System.out.println( "failed." );
546 System.out.print( "Copying of node data: " );
547 if ( Test.testCopyOfNodeData() ) {
548 System.out.println( "OK." );
552 System.out.println( "failed." );
555 System.out.print( "Tree copy: " );
556 if ( Test.testTreeCopy() ) {
557 System.out.println( "OK." );
561 System.out.println( "failed." );
564 System.out.print( "Basic tree methods: " );
565 if ( Test.testBasicTreeMethods() ) {
566 System.out.println( "OK." );
570 System.out.println( "failed." );
573 System.out.print( "Tree methods: " );
574 if ( Test.testTreeMethods() ) {
575 System.out.println( "OK." );
579 System.out.println( "failed." );
582 System.out.print( "Phylogeny methods:" );
583 if ( Test.testPhylogenyMethods() ) {
584 System.out.println( "OK." );
588 System.out.println( "failed." );
591 System.out.print( "Postorder Iterator: " );
592 if ( Test.testPostOrderIterator() ) {
593 System.out.println( "OK." );
597 System.out.println( "failed." );
600 System.out.print( "Preorder Iterator: " );
601 if ( Test.testPreOrderIterator() ) {
602 System.out.println( "OK." );
606 System.out.println( "failed." );
609 System.out.print( "Levelorder Iterator: " );
610 if ( Test.testLevelOrderIterator() ) {
611 System.out.println( "OK." );
615 System.out.println( "failed." );
618 System.out.print( "Re-id methods: " );
619 if ( Test.testReIdMethods() ) {
620 System.out.println( "OK." );
624 System.out.println( "failed." );
627 System.out.print( "Methods on last external nodes: " );
628 if ( Test.testLastExternalNodeMethods() ) {
629 System.out.println( "OK." );
633 System.out.println( "failed." );
636 System.out.print( "Methods on external nodes: " );
637 if ( Test.testExternalNodeRelatedMethods() ) {
638 System.out.println( "OK." );
642 System.out.println( "failed." );
645 System.out.print( "Deletion of external nodes: " );
646 if ( Test.testDeletionOfExternalNodes() ) {
647 System.out.println( "OK." );
651 System.out.println( "failed." );
654 System.out.print( "Subtree deletion: " );
655 if ( Test.testSubtreeDeletion() ) {
656 System.out.println( "OK." );
660 System.out.println( "failed." );
663 System.out.print( "Phylogeny branch: " );
664 if ( Test.testPhylogenyBranch() ) {
665 System.out.println( "OK." );
669 System.out.println( "failed." );
672 System.out.print( "Rerooting: " );
673 if ( Test.testRerooting() ) {
674 System.out.println( "OK." );
678 System.out.println( "failed." );
681 System.out.print( "Mipoint rooting: " );
682 if ( Test.testMidpointrooting() ) {
683 System.out.println( "OK." );
687 System.out.println( "failed." );
690 System.out.print( "Node removal: " );
691 if ( Test.testNodeRemoval() ) {
692 System.out.println( "OK." );
696 System.out.println( "failed." );
699 System.out.print( "Support count: " );
700 if ( Test.testSupportCount() ) {
701 System.out.println( "OK." );
705 System.out.println( "failed." );
708 System.out.print( "Support transfer: " );
709 if ( Test.testSupportTransfer() ) {
710 System.out.println( "OK." );
714 System.out.println( "failed." );
717 System.out.print( "Finding of LCA: " );
718 if ( Test.testGetLCA() ) {
719 System.out.println( "OK." );
723 System.out.println( "failed." );
726 System.out.print( "Finding of LCA 2: " );
727 if ( Test.testGetLCA2() ) {
728 System.out.println( "OK." );
732 System.out.println( "failed." );
735 System.out.print( "Calculation of distance between nodes: " );
736 if ( Test.testGetDistance() ) {
737 System.out.println( "OK." );
741 System.out.println( "failed." );
744 System.out.print( "Descriptive statistics: " );
745 if ( Test.testDescriptiveStatistics() ) {
746 System.out.println( "OK." );
750 System.out.println( "failed." );
753 System.out.print( "Data objects and methods: " );
754 if ( Test.testDataObjects() ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "Properties map: " );
763 if ( Test.testPropertiesMap() ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "SDIse: " );
772 if ( Test.testSDIse() ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "SDIunrooted: " );
781 if ( Test.testSDIunrooted() ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "GSDI: " );
790 if ( TestGSDI.test() ) {
791 System.out.println( "OK." );
795 System.out.println( "failed." );
798 System.out.print( "RIO: " );
799 if ( TestRIO.test() ) {
800 System.out.println( "OK." );
804 System.out.println( "failed." );
807 System.out.print( "Clade analyis: " );
808 if ( CladeAnalysisTest.test() ) {
809 System.out.println( "OK." );
813 System.out.println( "failed." );
816 System.out.print( "Phylogeny reconstruction:" );
817 System.out.println();
818 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Analysis of domain architectures: " );
827 System.out.println();
828 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
829 System.out.println( "OK." );
833 System.out.println( "failed." );
836 System.out.print( "GO: " );
837 System.out.println();
838 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
839 System.out.println( "OK." );
843 System.out.println( "failed." );
846 System.out.print( "Modeling tools: " );
847 if ( TestPccx.test() ) {
848 System.out.println( "OK." );
852 System.out.println( "failed." );
855 System.out.print( "Split Matrix strict: " );
856 if ( Test.testSplitStrict() ) {
857 System.out.println( "OK." );
861 System.out.println( "failed." );
864 System.out.print( "Split Matrix: " );
865 if ( Test.testSplit() ) {
866 System.out.println( "OK." );
870 System.out.println( "failed." );
873 System.out.print( "Confidence Assessor: " );
874 if ( Test.testConfidenceAssessor() ) {
875 System.out.println( "OK." );
879 System.out.println( "failed." );
882 System.out.print( "Basic table: " );
883 if ( Test.testBasicTable() ) {
884 System.out.println( "OK." );
888 System.out.println( "failed." );
891 System.out.print( "General table: " );
892 if ( Test.testGeneralTable() ) {
893 System.out.println( "OK." );
897 System.out.println( "failed." );
900 System.out.print( "Amino acid sequence: " );
901 if ( Test.testAminoAcidSequence() ) {
902 System.out.println( "OK." );
906 System.out.println( "failed." );
909 System.out.print( "General MSA parser: " );
910 if ( Test.testGeneralMsaParser() ) {
911 System.out.println( "OK." );
915 System.out.println( "failed." );
918 System.out.print( "Fasta parser for msa: " );
919 if ( Test.testFastaParser() ) {
920 System.out.println( "OK." );
924 System.out.println( "failed." );
927 System.out.print( "Creation of balanced phylogeny: " );
928 if ( Test.testCreateBalancedPhylogeny() ) {
929 System.out.println( "OK." );
933 System.out.println( "failed." );
936 System.out.print( "Genbank accessor parsing: " );
937 if ( Test.testGenbankAccessorParsing() ) {
938 System.out.println( "OK." );
942 System.out.println( "failed." );
946 final String os = ForesterUtil.OS_NAME.toLowerCase();
947 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
948 path = "/usr/local/bin/mafft";
950 else if ( os.indexOf( "win" ) >= 0 ) {
951 path = "C:\\Program Files\\mafft-win\\mafft.bat";
955 if ( !MsaInferrer.isInstalled( path ) ) {
956 path = "/usr/bin/mafft";
958 if ( !MsaInferrer.isInstalled( path ) ) {
959 path = "/usr/local/bin/mafft";
962 if ( MsaInferrer.isInstalled( path ) ) {
963 System.out.print( "MAFFT (external program): " );
964 if ( Test.testMafft( path ) ) {
965 System.out.println( "OK." );
969 System.out.println( "failed [will not count towards failed tests]" );
972 System.out.print( "Next nodes with collapsed: " );
973 if ( Test.testNextNodeWithCollapsing() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
981 System.out.print( "Simple MSA quality: " );
982 if ( Test.testMsaQualityMethod() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
990 System.out.print( "Deleteable MSA: " );
991 if ( Test.testDeleteableMsa() ) {
992 System.out.println( "OK." );
996 System.out.println( "failed." );
999 System.out.print( "MSA entropy: " );
1000 if ( Test.testMsaEntropy() ) {
1001 System.out.println( "OK." );
1005 System.out.println( "failed." );
1008 if ( PERFORM_DB_TESTS ) {
1009 System.out.print( "Uniprot Entry Retrieval: " );
1010 if ( Test.testUniprotEntryRetrieval() ) {
1011 System.out.println( "OK." );
1015 System.out.println( "failed." );
1018 System.out.print( "Ebi Entry Retrieval: " );
1019 if ( Test.testEbiEntryRetrieval() ) {
1020 System.out.println( "OK." );
1024 System.out.println( "failed." );
1027 System.out.print( "Sequence DB tools 2: " );
1028 if ( testSequenceDbWsTools2() ) {
1029 System.out.println( "OK." );
1033 System.out.println( "failed." );
1037 System.out.print( "Uniprot Taxonomy Search: " );
1038 if ( Test.testUniprotTaxonomySearch() ) {
1039 System.out.println( "OK." );
1043 System.out.println( "failed." );
1047 if ( PERFORM_WEB_TREE_ACCESS ) {
1048 System.out.print( "TreeBase acccess: " );
1049 if ( Test.testTreeBaseReading() ) {
1050 System.out.println( "OK." );
1054 System.out.println( "failed." );
1057 System.out.print( "ToL access: " );
1058 if ( Test.testToLReading() ) {
1059 System.out.println( "OK." );
1063 System.out.println( "failed." );
1066 System.out.print( "NHX parsing from URL: " );
1067 if ( Test.testNHXparsingFromURL() ) {
1068 System.out.println( "OK." );
1072 System.out.println( "failed." );
1075 System.out.print( "NHX parsing from URL 2: " );
1076 if ( Test.testNHXparsingFromURL2() ) {
1077 System.out.println( "OK." );
1081 System.out.println( "failed." );
1084 System.out.print( "phyloXML parsing from URL: " );
1085 if ( Test.testPhyloXMLparsingFromURL() ) {
1086 System.out.println( "OK." );
1090 System.out.println( "failed." );
1093 System.out.print( "TreeFam access: " );
1094 if ( Test.testTreeFamReading() ) {
1095 System.out.println( "OK." );
1099 System.out.println( "failed." );
1102 System.out.print( "Pfam tree access: " );
1103 if ( Test.testPfamTreeReading() ) {
1104 System.out.println( "OK." );
1108 System.out.println( "failed." );
1112 System.out.println();
1113 final Runtime rt = java.lang.Runtime.getRuntime();
1114 final long free_memory = rt.freeMemory() / 1000000;
1115 final long total_memory = rt.totalMemory() / 1000000;
1116 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1117 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1118 System.out.println();
1119 System.out.println( "Successful tests: " + succeeded );
1120 System.out.println( "Failed tests: " + failed );
1121 System.out.println();
1123 System.out.println( "OK." );
1126 System.out.println( "Not OK." );
1130 private static boolean testEngulfingOverlapRemoval() {
1132 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1133 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1134 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1135 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1136 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1137 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1138 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1139 final List<Boolean> covered = new ArrayList<>();
1140 covered.add( true ); // 0
1141 covered.add( false ); // 1
1142 covered.add( true ); // 2
1143 covered.add( false ); // 3
1144 covered.add( true ); // 4
1145 covered.add( true ); // 5
1146 covered.add( false ); // 6
1147 covered.add( true ); // 7
1148 covered.add( true ); // 8
1149 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1152 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1155 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1158 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1161 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1164 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1167 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1170 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1171 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1172 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1173 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1174 abc.addProteinDomain( a );
1175 abc.addProteinDomain( b );
1176 abc.addProteinDomain( c );
1177 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1178 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1179 if ( abc.getNumberOfProteinDomains() != 3 ) {
1182 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1185 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1188 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1191 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1194 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1195 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1196 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1197 final Protein def = new BasicProtein( "def", "nemve", 0 );
1198 def.addProteinDomain( d );
1199 def.addProteinDomain( e );
1200 def.addProteinDomain( f );
1201 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1202 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1203 if ( def.getNumberOfProteinDomains() != 3 ) {
1206 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1209 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1212 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1215 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1218 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1222 catch ( final Exception e ) {
1223 e.printStackTrace( System.out );
1229 private static final boolean testNHXparsingFromURL2() {
1231 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1232 final Phylogeny phys[] = AptxUtil
1233 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1234 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1237 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1238 System.out.println( phys[ 0 ].toNewHampshire() );
1241 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1242 System.out.println( phys[ 1 ].toNewHampshire() );
1245 final Phylogeny phys2[] = AptxUtil
1246 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1247 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1250 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1251 System.out.println( phys2[ 0 ].toNewHampshire() );
1254 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1255 System.out.println( phys2[ 1 ].toNewHampshire() );
1258 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1259 + "SwissTree/ST001/consensus_tree.nhx" ),
1263 TAXONOMY_EXTRACTION.NO,
1265 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1268 if ( !phys3[ 0 ].toNewHampshire()
1269 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1270 System.out.println( phys3[ 0 ].toNewHampshire() );
1273 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1274 + "SwissTree/ST001/consensus_tree.nhx" ),
1278 TAXONOMY_EXTRACTION.NO,
1280 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1283 if ( !phys4[ 0 ].toNewHampshire()
1284 .equals( "((((POP23a_CIOIN_ENSCING00000016202,POP23b_CIOIN_ENSCING00000016169),POP23_CIOSA_ENSCSAVG00000000248),((POP23a_BRAFL_C3ZMF1,POP23b_BRAFL_121417),(((POP3_ORYLA_ENSORLG00000019669,POP3_GASAC_ENSGACG00000014023,POP3_DANRE_Q6JWW1),(POP3_XENTR_B1H1F6,(POP3_CHICK_Q9DG25,(POP3_ORNAN_ENSOANG00000004179,POP3_MONDO_ENSMODG00000018033,((POP3_MOUSE_Q9ES81,POP3_RAT_Q3BCU3),POP3_RABIT_ENSOCUG00000025973,POP3_MACMU_ENSMMUG00000014473,POP3_HUMAN_Q9HBV1))))),(((POP2_GASAC_ENSGACG00000001420,POP2_ORYLA_ENSORLG00000008627,POP2_TAKRU_ENSTRUG00000015933),POP2_DANRE_ENSDARG00000069922),POP2_XENTR_ENSXETG00000018064,(((POP2_TAEGU_ENSTGUG00000013383,POP2_CHICK_Q6T9Z5),POP2_ANOCA_ENSACAG00000003557),((POP2_MACEU_ENSMEUG00000015825,POP2_MONDO_ENSMODG00000018205),((POP2_RABIT_ENSOCUG00000009515,(POP2_RAT_Q6P722,POP2_MOUSE_Q9ES82)),(POP2_MACMU_ENSMMUG00000000905,POP2_HUMAN_Q9HBU9)))))))),((POP1_CIOSA_ENSCSAVG00000000247,POP1_CIOIN_ENSCING00000000496),((POP1_DANRE_Q5PQZ7,(POP1_ORYLA_ENSORLG00000019663,POP1_GASAC_ENSGACG00000014015,POP1_TAKRU_ENSORLG00000019663)),(POP1_XENTR_B1H1G2,(POP1_ANOCA_ENSACAG00000003910,(POP1_TAEGU_ENSTGUG00000012218,POP1_CHICK_Q9DG23)),POP1_ORNAN_ENSOANG00000004180,POP1_MONDO_ENSMODG00000018034,(POP1_RABIT_ENSOCUG00000016944,(POP1_RAT_Q3BCU4,POP1_MOUSE_Q9ES83),(POP1_HUMAN_Q8NE79,POP1_MACMU_ENSMMUG00000014471))))));" ) ) {
1285 System.out.println( phys4[ 0 ].toNewHampshire() );
1289 catch ( final Exception e ) {
1290 e.printStackTrace();
1296 private static final boolean testNHXparsingFromURL() {
1298 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1299 final URL u = new URL( s );
1300 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1301 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1302 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1305 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1306 System.out.println( phys[ 0 ].toNewHampshire() );
1309 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1310 System.out.println( phys[ 1 ].toNewHampshire() );
1313 final URL u2 = new URL( s );
1314 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1315 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1318 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1319 System.out.println( phys2[ 0 ].toNewHampshire() );
1322 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1323 final NHXParser p = new NHXParser();
1324 final URL u3 = new URL( s );
1326 if ( !p.hasNext() ) {
1329 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1332 if ( !p.hasNext() ) {
1336 if ( !p.hasNext() ) {
1339 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1342 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1346 if ( !p.hasNext() ) {
1349 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1352 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1356 catch ( final Exception e ) {
1357 System.out.println( e.toString() );
1358 e.printStackTrace();
1364 private static boolean testOverlapRemoval() {
1366 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1367 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1368 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1369 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1370 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1371 final List<Boolean> covered = new ArrayList<>();
1372 covered.add( true ); // 0
1373 covered.add( false ); // 1
1374 covered.add( true ); // 2
1375 covered.add( false ); // 3
1376 covered.add( true ); // 4
1377 covered.add( true ); // 5
1378 covered.add( false ); // 6
1379 covered.add( true ); // 7
1380 covered.add( true ); // 8
1381 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1384 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1387 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1390 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1393 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1396 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1397 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1398 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1399 ab.addProteinDomain( a );
1400 ab.addProteinDomain( b );
1401 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1402 if ( ab.getNumberOfProteinDomains() != 2 ) {
1405 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1408 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1411 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1412 if ( ab.getNumberOfProteinDomains() != 2 ) {
1415 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1418 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1419 final Domain d = new BasicDomain( "d",
1426 final Domain e = new BasicDomain( "e",
1433 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1434 cde.addProteinDomain( c );
1435 cde.addProteinDomain( d );
1436 cde.addProteinDomain( e );
1437 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1438 if ( cde.getNumberOfProteinDomains() != 3 ) {
1441 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1444 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1445 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1446 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1447 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1448 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1449 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1450 fghi.addProteinDomain( f );
1451 fghi.addProteinDomain( g );
1452 fghi.addProteinDomain( h );
1453 fghi.addProteinDomain( i );
1454 fghi.addProteinDomain( i );
1455 fghi.addProteinDomain( i );
1456 fghi.addProteinDomain( i2 );
1457 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1458 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1461 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1464 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1467 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1468 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1471 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1474 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1475 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1476 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1477 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1478 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1479 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1480 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1481 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1482 jklm.addProteinDomain( j );
1483 jklm.addProteinDomain( k );
1484 jklm.addProteinDomain( l );
1485 jklm.addProteinDomain( m );
1486 jklm.addProteinDomain( m0 );
1487 jklm.addProteinDomain( m1 );
1488 jklm.addProteinDomain( m2 );
1489 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1490 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1493 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1496 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1499 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1500 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1503 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1506 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1507 final Protein od = new BasicProtein( "od", "varanus", 0 );
1508 od.addProteinDomain( only );
1509 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1510 if ( od.getNumberOfProteinDomains() != 1 ) {
1513 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1517 catch ( final Exception e ) {
1518 e.printStackTrace( System.out );
1524 private static final boolean testPfamTreeReading() {
1526 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1527 final NHXParser parser = new NHXParser();
1528 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1529 parser.setReplaceUnderscores( false );
1530 parser.setGuessRootedness( true );
1531 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1532 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1535 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1539 catch ( final Exception e ) {
1540 e.printStackTrace();
1546 private static final boolean testPhyloXMLparsingFromURL() {
1548 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1549 final URL u = new URL( s );
1550 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1551 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1554 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1555 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1559 catch ( final Exception e ) {
1560 e.printStackTrace();
1566 private static final boolean testToLReading() {
1568 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1569 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1570 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1573 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1576 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName()
1577 .equals( "Protacanthopterygii" ) ) {
1580 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1584 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1585 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1586 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1589 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1592 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1596 catch ( final Exception e ) {
1597 e.printStackTrace();
1603 private static final boolean testTreeBaseReading() {
1605 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1606 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1607 parser.setReplaceUnderscores( true );
1608 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1609 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1612 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1613 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1614 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1615 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1618 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1619 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1620 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1621 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1624 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1625 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1626 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1627 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1630 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1631 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1632 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1633 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1636 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1637 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1638 parser2.setReplaceUnderscores( true );
1639 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1640 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1643 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1644 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1645 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1646 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1649 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl(
1650 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1651 + "14525?format=nexus" ),
1652 new NexusPhylogeniesParser() );
1653 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1656 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl(
1657 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1658 + "15632?format=nexus" ),
1659 new NexusPhylogeniesParser() );
1660 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1663 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl(
1664 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1665 + "10190?format=nexus" ),
1666 new NexusPhylogeniesParser() );
1667 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1670 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl(
1671 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1672 + "13246?format=nexus" ),
1673 new NexusPhylogeniesParser() );
1674 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1677 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl(
1678 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1679 + "11662?format=nexus" ),
1680 new NexusPhylogeniesParser() );
1681 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1684 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl(
1685 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1686 + "562?format=nexus" ),
1687 new NexusPhylogeniesParser() );
1688 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1691 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl(
1692 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1693 + "16424?format=nexus" ),
1694 new NexusPhylogeniesParser() );
1695 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1698 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl(
1699 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1700 + "17878?format=nexus" ),
1701 new NexusPhylogeniesParser() );
1702 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1705 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl(
1706 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1707 + "18804?format=nexus" ),
1708 new NexusPhylogeniesParser() );
1709 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1712 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl(
1713 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1714 + "346?format=nexus" ),
1715 new NexusPhylogeniesParser() );
1716 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1720 catch ( final Exception e ) {
1721 e.printStackTrace();
1727 private static final boolean testTreeFamReading() {
1729 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1730 final NHXParser parser = new NHXParser();
1731 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1732 parser.setReplaceUnderscores( false );
1733 parser.setGuessRootedness( true );
1734 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1735 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1738 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1742 catch ( final Exception e ) {
1743 e.printStackTrace();
1749 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1750 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1754 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1755 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1758 private static boolean testAminoAcidSequence() {
1760 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1761 if ( aa1.getLength() != 13 ) {
1764 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1767 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1770 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1773 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1774 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1777 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1778 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1781 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1782 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1786 catch ( final Exception e ) {
1787 e.printStackTrace();
1793 private static boolean testBasicDomain() {
1795 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1796 if ( !pd.getDomainId().equals( "id" ) ) {
1799 if ( pd.getNumber() != 1 ) {
1802 if ( pd.getTotalCount() != 4 ) {
1805 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1808 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1809 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1810 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1811 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1812 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1813 if ( !a1.equals( a1 ) ) {
1816 if ( !a1.equals( a1_copy ) ) {
1819 if ( !a1.equals( a1_equal ) ) {
1822 if ( !a1.equals( a2 ) ) {
1825 if ( a1.equals( a3 ) ) {
1828 if ( a1.compareTo( a1 ) != 0 ) {
1831 if ( a1.compareTo( a1_copy ) != 0 ) {
1834 if ( a1.compareTo( a1_equal ) != 0 ) {
1837 if ( a1.compareTo( a2 ) != 0 ) {
1840 if ( a1.compareTo( a3 ) == 0 ) {
1844 catch ( final Exception e ) {
1845 e.printStackTrace( System.out );
1851 private static boolean testBasicNodeMethods() {
1853 if ( PhylogenyNode.getNodeCount() != 0 ) {
1856 final PhylogenyNode n1 = new PhylogenyNode();
1857 final PhylogenyNode n2 = PhylogenyNode
1858 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1859 final PhylogenyNode n3 = PhylogenyNode
1860 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1861 final PhylogenyNode n4 = PhylogenyNode
1862 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1863 if ( n1.isHasAssignedEvent() ) {
1866 if ( PhylogenyNode.getNodeCount() != 4 ) {
1869 if ( n3.getIndicator() != 0 ) {
1872 if ( n3.getNumberOfExternalNodes() != 1 ) {
1875 if ( !n3.isExternal() ) {
1878 if ( !n3.isRoot() ) {
1881 if ( !n4.getName().equals( "n4" ) ) {
1885 catch ( final Exception e ) {
1886 e.printStackTrace( System.out );
1892 private static boolean testCommonPrefix() {
1893 final List<String> l0 = new ArrayList<>();
1895 if ( !ForesterUtil.greatestCommonPrefix( l0 ).equals( "abc" ) ) {
1898 final List<String> l1 = new ArrayList<>();
1901 if ( !ForesterUtil.greatestCommonPrefix( l1 ).equals( "ab" ) ) {
1904 final List<String> l2 = new ArrayList<>();
1908 if ( !ForesterUtil.greatestCommonPrefix( l2 ).equals( "a" ) ) {
1911 final List<String> l3 = new ArrayList<>();
1912 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1913 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1915 l3.add( "abXsdfsdfsdfsdfsdfsd" );
1919 if ( !ForesterUtil.greatestCommonPrefix( l3 ).equals( "ab" ) ) {
1922 final List<String> l4 = new ArrayList<>();
1923 l4.add( "abXsdfsdfsdfsdfsdfsd" );
1924 l4.add( "abXsdfsdfsdfsdfsdfsd" );
1926 l4.add( "Xsdfsdfsdfsdfsdfsd" );
1929 if ( !ForesterUtil.greatestCommonPrefix( l4 ).equals( "" ) ) {
1932 final List<String> l5 = new ArrayList<>();
1934 if ( !ForesterUtil.greatestCommonPrefix( l5 ).equals( "" ) ) {
1937 final List<String> l6 = new ArrayList<>();
1941 if ( !ForesterUtil.greatestCommonPrefix( l6 ).equals( "" ) ) {
1947 private static boolean testCommonPrefixSep() {
1948 final List<String> l0 = new ArrayList<>();
1950 if ( !ForesterUtil.greatestCommonPrefix( l0, "." ).equals( "a.b.c" ) ) {
1953 final List<String> l1 = new ArrayList<>();
1956 if ( !ForesterUtil.greatestCommonPrefix( l1, "." ).equals( "a.b" ) ) {
1959 final List<String> l2 = new ArrayList<>();
1963 if ( !ForesterUtil.greatestCommonPrefix( l2, "." ).equals( "a" ) ) {
1966 final List<String> l3 = new ArrayList<>();
1967 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
1968 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d" );
1970 l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
1973 l3.add( "a/b////////" );
1974 if ( !ForesterUtil.greatestCommonPrefix( l3, "/" ).equals( "a/b" ) ) {
1977 final List<String> l4 = new ArrayList<>();
1978 l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
1979 l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
1981 l4.add( "X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d..." );
1984 if ( !ForesterUtil.greatestCommonPrefix( l4, "." ).equals( "" ) ) {
1987 final List<String> l5 = new ArrayList<>();
1989 if ( !ForesterUtil.greatestCommonPrefix( l5, "_" ).equals( "" ) ) {
1992 final List<String> l6 = new ArrayList<>();
1995 if ( !ForesterUtil.greatestCommonPrefix( l6, "_" ).equals( "" ) ) {
1998 final List<String> l7 = new ArrayList<>();
2002 l7.add( ",,,,,,,,,," );
2003 if ( !ForesterUtil.greatestCommonPrefix( l7, "," ).equals( "" ) ) {
2006 final List<String> l8 = new ArrayList<>();
2007 l8.add( "123.304.403.04" );
2008 l8.add( "123.304.403.04.02" );
2009 l8.add( "123.304.403.03.03" );
2010 if ( !ForesterUtil.greatestCommonPrefix( l8, "." ).equals( "123.304.403" ) ) {
2013 final List<String> l9 = new ArrayList<>();
2014 l9.add( "123.304.403.04" );
2015 l9.add( "123.304.403.04.02" );
2016 l9.add( "123.304.402.03.03" );
2017 if ( !ForesterUtil.greatestCommonPrefix( l9, "." ).equals( "123.304" ) ) {
2020 final List<String> l10 = new ArrayList<>();
2023 if ( !ForesterUtil.greatestCommonPrefix( l10, "." ).equals( "" ) ) {
2029 private static boolean testContainsPrefix() {
2030 if ( !ForesterUtil.isContainsPrefix( "a.b", "a", "." ) ) {
2033 if ( !ForesterUtil.isContainsPrefix( "a.b.c", "a", "." ) ) {
2036 if ( !ForesterUtil.isContainsPrefix( "a.b.c", "a.b", "." ) ) {
2039 if ( !ForesterUtil.isContainsPrefix( "a.b", "a.b", "." ) ) {
2042 if ( !ForesterUtil.isContainsPrefix( "a", "a", "." ) ) {
2045 if ( !ForesterUtil.isContainsPrefix( ".a.b", ".a", "." ) ) {
2048 if ( !ForesterUtil.isContainsPrefix( ".a.b.", ".a", "." ) ) {
2051 if ( !ForesterUtil.isContainsPrefix( ".a.b.", ".a.", "." ) ) {
2054 if ( !ForesterUtil.isContainsPrefix( "a..b.", "a", "." ) ) {
2057 if ( !ForesterUtil.isContainsPrefix( "a..b.", "a..", "." ) ) {
2060 if ( ForesterUtil.isContainsPrefix( "a", "a.b", "." ) ) {
2063 if ( ForesterUtil.isContainsPrefix( "a_b", "a", "." ) ) {
2066 if ( ForesterUtil.isContainsPrefix( ".a.", ".a.b.", "." ) ) {
2069 if ( ForesterUtil.isContainsPrefix( "a.b.c", "a.x", "." ) ) {
2075 private static boolean testUTF8ParsingFromFile() {
2077 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2078 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance()
2079 .create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ), xml_parser );
2080 if ( xml_parser.getErrorCount() > 0 ) {
2081 System.out.println( xml_parser.getErrorMessages().toString() );
2084 if ( phylogenies_xml.length != 1 ) {
2087 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance()
2088 .create( new StringBuffer( phylogenies_xml[ 0 ].toPhyloXML( 0 ) ), xml_parser );
2089 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance()
2090 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
2091 if ( phylogenies_nh.length != 1 ) {
2094 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance()
2095 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
2096 if ( phylogenies_nex.length != 1 ) {
2099 final String[] xml_n = phylogenies_xml[ 0 ].getAllExternalNodeNames();
2100 final String[] xml_n2 = phylogenies_xml2[ 0 ].getAllExternalNodeNames();
2101 final String[] nh_n = phylogenies_nh[ 0 ].getAllExternalNodeNames();
2102 final String[] nex_n = phylogenies_nex[ 0 ].getAllExternalNodeNames();
2103 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
2104 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
2105 final String n2 = "漢字ひらがなカタカナ";
2106 final String n3 = "อักษรไทย";
2107 final String n4 = "繁體字";
2108 final String n5 = "한글";
2109 final String n6 = "देवनागरी";
2110 final String n7 = "chữ Quốc ngữ";
2111 final String n8 = "ру́сский язы́к";
2112 final String n9 = "អក្សរខ្មែរ";
2113 if ( !xml_n[ 0 ].equals( n0 ) ) {
2114 System.out.println( xml_n[ 0 ] );
2115 System.out.println( n0 );
2118 if ( !xml_n2[ 0 ].equals( n0 ) ) {
2119 System.out.println( xml_n2[ 0 ] );
2120 System.out.println( n0 );
2123 if ( !nh_n[ 0 ].equals( n0 ) ) {
2124 System.out.println( nh_n[ 0 ] );
2125 System.out.println( n0 );
2128 if ( !nex_n[ 0 ].equals( n0 ) ) {
2129 System.out.println( nex_n[ 0 ] );
2130 System.out.println( n0 );
2133 if ( !xml_n[ 1 ].equals( n1 ) ) {
2134 System.out.println( xml_n[ 1 ] );
2135 System.out.println( n1 );
2138 if ( !xml_n2[ 1 ].equals( n1 ) ) {
2139 System.out.println( xml_n2[ 1 ] );
2140 System.out.println( n1 );
2143 if ( !nh_n[ 1 ].equals( n1 ) ) {
2144 System.out.println( nh_n[ 1 ] );
2145 System.out.println( n1 );
2148 if ( !nex_n[ 1 ].equals( n1 ) ) {
2149 System.out.println( nex_n[ 1 ] );
2150 System.out.println( n1 );
2153 if ( !xml_n[ 2 ].equals( n2 ) ) {
2154 System.out.println( xml_n[ 2 ] );
2155 System.out.println( n2 );
2158 if ( !xml_n2[ 2 ].equals( n2 ) ) {
2159 System.out.println( xml_n2[ 2 ] );
2160 System.out.println( n2 );
2163 if ( !nh_n[ 2 ].equals( n2 ) ) {
2164 System.out.println( nh_n[ 2 ] );
2165 System.out.println( n2 );
2168 if ( !nex_n[ 2 ].equals( n2 ) ) {
2169 System.out.println( nex_n[ 2 ] );
2170 System.out.println( n2 );
2174 if ( !xml_n[ 3 ].equals( n3 ) ) {
2175 System.out.println( xml_n[ 3 ] );
2176 System.out.println( n3 );
2179 if ( !xml_n2[ 3 ].equals( n3 ) ) {
2180 System.out.println( xml_n2[ 3 ] );
2181 System.out.println( n3 );
2184 if ( !nh_n[ 3 ].equals( n3 ) ) {
2185 System.out.println( nh_n[ 3 ] );
2186 System.out.println( n3 );
2189 if ( !nex_n[ 3 ].equals( n3 ) ) {
2190 System.out.println( nex_n[ 3 ] );
2191 System.out.println( n3 );
2195 if ( !xml_n[ 4 ].equals( n4 ) ) {
2196 System.out.println( xml_n[ 4 ] );
2197 System.out.println( n4 );
2200 if ( !nh_n[ 4 ].equals( n4 ) ) {
2201 System.out.println( nh_n[ 4 ] );
2202 System.out.println( n4 );
2205 if ( !nex_n[ 4 ].equals( n4 ) ) {
2206 System.out.println( nex_n[ 4 ] );
2207 System.out.println( n4 );
2211 if ( !xml_n[ 5 ].equals( n5 ) ) {
2212 System.out.println( xml_n[ 5 ] );
2213 System.out.println( n5 );
2216 if ( !nh_n[ 5 ].equals( n5 ) ) {
2217 System.out.println( nh_n[ 5 ] );
2218 System.out.println( n5 );
2221 if ( !nex_n[ 5 ].equals( n5 ) ) {
2222 System.out.println( nex_n[ 5 ] );
2223 System.out.println( n5 );
2227 if ( !xml_n[ 6 ].equals( n6 ) ) {
2228 System.out.println( xml_n[ 6 ] );
2229 System.out.println( n6 );
2232 if ( !nh_n[ 6 ].equals( n6 ) ) {
2233 System.out.println( nh_n[ 6 ] );
2234 System.out.println( n6 );
2237 if ( !nex_n[ 6 ].equals( n6 ) ) {
2238 System.out.println( nex_n[ 6 ] );
2239 System.out.println( n6 );
2243 if ( !xml_n[ 7 ].equals( n7 ) ) {
2244 System.out.println( xml_n[ 7 ] );
2245 System.out.println( n7 );
2248 if ( !nh_n[ 7 ].equals( n7 ) ) {
2249 System.out.println( nh_n[ 7 ] );
2250 System.out.println( n7 );
2253 if ( !nex_n[ 7 ].equals( n7 ) ) {
2254 System.out.println( nex_n[ 7 ] );
2255 System.out.println( n7 );
2258 if ( !xml_n[ 8 ].equals( n8 ) ) {
2259 System.out.println( xml_n[ 8 ] );
2260 System.out.println( n8 );
2263 if ( !nh_n[ 8 ].equals( n8 ) ) {
2264 System.out.println( nh_n[ 8 ] );
2265 System.out.println( n8 );
2268 if ( !nex_n[ 8 ].equals( n8 ) ) {
2269 System.out.println( nex_n[ 8 ] );
2270 System.out.println( n8 );
2273 if ( !xml_n[ 9 ].equals( n9 ) ) {
2274 System.out.println( xml_n[ 9 ] );
2275 System.out.println( n9 );
2278 if ( !xml_n2[ 9 ].equals( n9 ) ) {
2279 System.out.println( xml_n2[ 9 ] );
2280 System.out.println( n9 );
2283 if ( !nh_n[ 9 ].equals( n9 ) ) {
2284 System.out.println( nh_n[ 9 ] );
2285 System.out.println( n9 );
2288 if ( !nex_n[ 9 ].equals( n9 ) ) {
2289 System.out.println( nex_n[ 9 ] );
2290 System.out.println( n9 );
2293 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nh[ 0 ].toNewHampshire() ) ) {
2294 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2295 System.out.println( phylogenies_nh[ 0 ].toNewHampshire() );
2298 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nex[ 0 ].toNewHampshire() ) ) {
2299 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2300 System.out.println( phylogenies_nex[ 0 ].toNewHampshire() );
2304 catch ( final Exception e ) {
2305 e.printStackTrace( System.out );
2311 private static boolean testBasicPhyloXMLparsing() {
2313 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2314 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2315 final Phylogeny[] phylogenies_0 = factory
2316 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2317 if ( xml_parser.getErrorCount() > 0 ) {
2318 System.out.println( xml_parser.getErrorMessages().toString() );
2321 if ( phylogenies_0.length != 4 ) {
2324 final Phylogeny t1 = phylogenies_0[ 0 ];
2325 final Phylogeny t2 = phylogenies_0[ 1 ];
2326 final Phylogeny t3 = phylogenies_0[ 2 ];
2327 final Phylogeny t4 = phylogenies_0[ 3 ];
2328 if ( t1.getNumberOfExternalNodes() != 1 ) {
2331 if ( !t1.isRooted() ) {
2334 if ( t1.isRerootable() ) {
2337 if ( !t1.getType().equals( "gene_tree" ) ) {
2340 if ( t2.getNumberOfExternalNodes() != 2 ) {
2343 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2346 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2349 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2352 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2355 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2358 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2361 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2362 .startsWith( "actgtgggggt" ) ) {
2365 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2366 .startsWith( "ctgtgatgcat" ) ) {
2369 if ( t3.getNumberOfExternalNodes() != 4 ) {
2372 if ( !t1.getName().equals( "t1" ) ) {
2375 if ( !t2.getName().equals( "t2" ) ) {
2378 if ( !t3.getName().equals( "t3" ) ) {
2381 if ( !t4.getName().equals( "t4" ) ) {
2384 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2387 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2390 if ( !t3.getNode( "root node" ).isDuplication() ) {
2393 if ( !t3.getNode( "node a" ).isDuplication() ) {
2396 if ( t3.getNode( "node a" ).isSpeciation() ) {
2399 if ( t3.getNode( "node bc" ).isDuplication() ) {
2402 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2405 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2408 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2409 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2412 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2415 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2418 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2419 .equals( "UniProtKB" ) ) {
2422 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2423 .equals( "apoptosis" ) ) {
2426 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2427 .equals( "GO:0006915" ) ) {
2430 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2431 .equals( "UniProtKB" ) ) {
2434 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2435 .equals( "experimental" ) ) {
2438 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2439 .equals( "function" ) ) {
2442 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2443 .getValue() != 1 ) {
2446 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence().getType()
2450 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2451 .equals( "apoptosis" ) ) {
2454 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2455 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2458 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2459 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2462 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2463 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2466 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2467 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2470 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2471 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2474 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2475 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2478 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2479 .equals( "GO:0005829" ) ) {
2482 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2483 .equals( "intracellular organelle" ) ) {
2486 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2489 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2490 .equals( "UniProt link" ) ) ) {
2493 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2496 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2497 if ( x.size() != 4 ) {
2501 for( final Accession acc : x ) {
2503 if ( !acc.getSource().equals( "KEGG" ) ) {
2506 if ( !acc.getValue().equals( "hsa:596" ) ) {
2513 catch ( final Exception e ) {
2514 e.printStackTrace( System.out );
2520 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2522 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2523 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2524 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2525 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2528 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2530 final Phylogeny[] phylogenies_0 = factory
2531 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2532 if ( xml_parser.getErrorCount() > 0 ) {
2533 System.out.println( xml_parser.getErrorMessages().toString() );
2536 if ( phylogenies_0.length != 4 ) {
2539 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2540 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2541 if ( phylogenies_t1.length != 1 ) {
2544 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2545 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2548 if ( !t1_rt.isRooted() ) {
2551 if ( t1_rt.isRerootable() ) {
2554 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2557 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2558 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2559 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2560 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2563 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2566 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2569 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2572 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2573 .startsWith( "actgtgggggt" ) ) {
2576 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2577 .startsWith( "ctgtgatgcat" ) ) {
2580 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2581 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2582 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2583 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2584 if ( phylogenies_1.length != 1 ) {
2587 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2588 if ( !t3_rt.getName().equals( "t3" ) ) {
2591 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2594 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2597 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2600 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2603 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2604 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2607 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2610 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue()
2611 .equals( "Q9BZR8" ) ) {
2614 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2615 .equals( "UniProtKB" ) ) {
2618 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2619 .equals( "apoptosis" ) ) {
2622 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2623 .equals( "GO:0006915" ) ) {
2626 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2627 .equals( "UniProtKB" ) ) {
2630 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2631 .equals( "experimental" ) ) {
2634 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2635 .equals( "function" ) ) {
2638 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2639 .getValue() != 1 ) {
2642 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2643 .getType().equals( "ml" ) ) {
2646 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2647 .equals( "apoptosis" ) ) {
2650 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2651 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2654 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2655 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2658 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2659 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2662 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2663 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2666 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2667 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2670 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2671 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2674 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2675 .equals( "GO:0005829" ) ) {
2678 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2679 .equals( "intracellular organelle" ) ) {
2682 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType()
2683 .equals( "source" ) ) ) {
2686 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2687 .equals( "UniProt link" ) ) ) {
2690 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2693 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi()
2694 .equals( "10.1038/387489a0" ) ) ) {
2697 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2698 .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." ) ) ) {
2699 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2702 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2705 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2708 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName()
2709 .equals( "molting animals" ) ) {
2712 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2715 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2716 .equals( "ncbi" ) ) {
2719 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture()
2720 .getTotalLength() != 124 ) {
2723 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2724 .getName().equals( "B" ) ) {
2727 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2728 .getFrom() != 21 ) {
2731 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2735 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2736 .getLength() != 24 ) {
2739 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2740 .getConfidence() != 0 ) {
2743 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2744 .equals( "pfam" ) ) {
2747 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2750 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2753 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2756 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2759 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2760 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2763 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2766 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2769 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2772 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2775 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2778 if ( taxbb.getSynonyms().size() != 2 ) {
2781 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2784 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2787 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2790 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2793 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2796 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2797 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2800 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2803 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2806 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2809 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2812 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2815 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2818 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2821 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2824 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2825 .equalsIgnoreCase( "435" ) ) {
2828 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString()
2829 .equalsIgnoreCase( "416" ) ) {
2832 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2833 .equalsIgnoreCase( "443.7" ) ) {
2836 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2839 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2842 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2843 .equalsIgnoreCase( "433" ) ) {
2846 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2847 .getCrossReferences();
2848 if ( x.size() != 4 ) {
2852 for( final Accession acc : x ) {
2854 if ( !acc.getSource().equals( "KEGG" ) ) {
2857 if ( !acc.getValue().equals( "hsa:596" ) ) {
2864 catch ( final Exception e ) {
2865 e.printStackTrace( System.out );
2871 private static boolean testBasicPhyloXMLparsingValidating() {
2873 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2874 PhyloXmlParser xml_parser = null;
2876 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2878 catch ( final Exception e ) {
2879 // Do nothing -- means were not running from jar.
2881 if ( xml_parser == null ) {
2882 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2883 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2884 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2887 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2890 final Phylogeny[] phylogenies_0 = factory
2891 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2892 if ( xml_parser.getErrorCount() > 0 ) {
2893 System.out.println( xml_parser.getErrorMessages().toString() );
2896 if ( phylogenies_0.length != 4 ) {
2899 final Phylogeny t1 = phylogenies_0[ 0 ];
2900 final Phylogeny t2 = phylogenies_0[ 1 ];
2901 final Phylogeny t3 = phylogenies_0[ 2 ];
2902 final Phylogeny t4 = phylogenies_0[ 3 ];
2903 if ( !t1.getName().equals( "t1" ) ) {
2906 if ( !t2.getName().equals( "t2" ) ) {
2909 if ( !t3.getName().equals( "t3" ) ) {
2912 if ( !t4.getName().equals( "t4" ) ) {
2915 if ( t1.getNumberOfExternalNodes() != 1 ) {
2918 if ( t2.getNumberOfExternalNodes() != 2 ) {
2921 if ( t3.getNumberOfExternalNodes() != 4 ) {
2924 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2925 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2926 if ( xml_parser.getErrorCount() > 0 ) {
2927 System.out.println( "errors:" );
2928 System.out.println( xml_parser.getErrorMessages().toString() );
2931 if ( phylogenies_1.length != 4 ) {
2934 final Phylogeny[] phylogenies_2 = factory
2935 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ), xml_parser );
2936 if ( xml_parser.getErrorCount() > 0 ) {
2937 System.out.println( "errors:" );
2938 System.out.println( xml_parser.getErrorMessages().toString() );
2941 if ( phylogenies_2.length != 1 ) {
2944 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2947 final Phylogeny[] phylogenies_3 = factory
2948 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ), xml_parser );
2949 if ( xml_parser.getErrorCount() > 0 ) {
2950 System.out.println( xml_parser.getErrorMessages().toString() );
2953 if ( phylogenies_3.length != 2 ) {
2956 final Phylogeny a = phylogenies_3[ 0 ];
2957 if ( !a.getName().equals( "tree 4" ) ) {
2960 if ( a.getNumberOfExternalNodes() != 3 ) {
2963 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2966 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2969 final Phylogeny[] phylogenies_4 = factory
2970 .create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml" ), xml_parser );
2971 if ( xml_parser.getErrorCount() > 0 ) {
2972 System.out.println( xml_parser.getErrorMessages().toString() );
2975 if ( phylogenies_4.length != 1 ) {
2978 final Phylogeny s = phylogenies_4[ 0 ];
2979 if ( s.getNumberOfExternalNodes() != 6 ) {
2982 s.getNode( "first" );
2984 s.getNode( "\"<a'b&c'd\">\"" );
2985 s.getNode( "'''\"" );
2986 s.getNode( "\"\"\"" );
2987 s.getNode( "dick & doof" );
2989 catch ( final Exception e ) {
2990 e.printStackTrace( System.out );
2996 private static boolean testPhyloXMLparsingValidating() {
2998 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2999 PhyloXmlParser xml_parser = null;
3001 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
3003 catch ( final Exception e ) {
3004 // Do nothing -- means were not running from jar.
3006 if ( xml_parser == null ) {
3007 xml_parser = PhyloXmlParser.createPhyloXmlParser();
3008 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
3009 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
3012 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
3015 final Phylogeny[] phylogenies_0 = factory
3016 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ), xml_parser );
3017 if ( xml_parser.getErrorCount() > 0 ) {
3018 System.out.println( xml_parser.getErrorMessages().toString() );
3021 if ( phylogenies_0.length != 3 ) {
3025 catch ( final Exception e ) {
3026 e.printStackTrace( System.out );
3032 private static boolean testBasicProtein() {
3034 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
3035 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3036 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
3037 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
3038 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
3039 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
3040 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3041 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3042 p0.addProteinDomain( y );
3043 p0.addProteinDomain( e );
3044 p0.addProteinDomain( b );
3045 p0.addProteinDomain( c );
3046 p0.addProteinDomain( d );
3047 p0.addProteinDomain( a );
3048 p0.addProteinDomain( x );
3049 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
3052 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
3056 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
3057 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3058 aa0.addProteinDomain( a1 );
3059 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
3062 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
3066 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
3067 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3068 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
3069 aa1.addProteinDomain( a11 );
3070 aa1.addProteinDomain( a12 );
3071 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
3074 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
3077 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3078 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
3081 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
3084 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
3087 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3088 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
3091 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
3094 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
3097 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
3100 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3101 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
3104 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
3107 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
3110 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
3113 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
3114 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
3117 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
3120 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
3123 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
3127 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
3128 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
3129 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
3130 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
3131 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
3132 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
3133 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
3134 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
3135 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
3136 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
3137 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
3138 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3139 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
3140 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
3141 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
3142 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
3143 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
3144 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
3145 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
3146 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
3147 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
3148 p00.addProteinDomain( y0 );
3149 p00.addProteinDomain( e0 );
3150 p00.addProteinDomain( b0 );
3151 p00.addProteinDomain( c0 );
3152 p00.addProteinDomain( d0 );
3153 p00.addProteinDomain( a0 );
3154 p00.addProteinDomain( x0 );
3155 p00.addProteinDomain( y1 );
3156 p00.addProteinDomain( y2 );
3157 p00.addProteinDomain( y3 );
3158 p00.addProteinDomain( e1 );
3159 p00.addProteinDomain( e2 );
3160 p00.addProteinDomain( e3 );
3161 p00.addProteinDomain( e4 );
3162 p00.addProteinDomain( e5 );
3163 p00.addProteinDomain( z0 );
3164 p00.addProteinDomain( z1 );
3165 p00.addProteinDomain( z2 );
3166 p00.addProteinDomain( zz0 );
3167 p00.addProteinDomain( zz1 );
3168 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
3171 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
3174 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
3177 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
3180 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" ) ) {
3183 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
3184 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3185 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
3186 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
3187 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
3188 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
3189 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
3190 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
3191 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
3192 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
3193 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
3194 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
3195 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
3196 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
3197 p.addProteinDomain( B15 );
3198 p.addProteinDomain( C50 );
3199 p.addProteinDomain( A60 );
3200 p.addProteinDomain( A30 );
3201 p.addProteinDomain( C70 );
3202 p.addProteinDomain( B35 );
3203 p.addProteinDomain( B40 );
3204 p.addProteinDomain( A0 );
3205 p.addProteinDomain( A10 );
3206 p.addProteinDomain( A20 );
3207 p.addProteinDomain( B25 );
3208 p.addProteinDomain( D80 );
3209 List<String> domains_ids = new ArrayList<>();
3210 domains_ids.add( "A" );
3211 domains_ids.add( "B" );
3212 domains_ids.add( "C" );
3213 if ( !p.contains( domains_ids, false ) ) {
3216 if ( !p.contains( domains_ids, true ) ) {
3219 domains_ids.add( "X" );
3220 if ( p.contains( domains_ids, false ) ) {
3223 if ( p.contains( domains_ids, true ) ) {
3226 domains_ids = new ArrayList<>();
3227 domains_ids.add( "A" );
3228 domains_ids.add( "C" );
3229 domains_ids.add( "D" );
3230 if ( !p.contains( domains_ids, false ) ) {
3233 if ( !p.contains( domains_ids, true ) ) {
3236 domains_ids = new ArrayList<>();
3237 domains_ids.add( "A" );
3238 domains_ids.add( "D" );
3239 domains_ids.add( "C" );
3240 if ( !p.contains( domains_ids, false ) ) {
3243 if ( p.contains( domains_ids, true ) ) {
3246 domains_ids = new ArrayList<>();
3247 domains_ids.add( "A" );
3248 domains_ids.add( "A" );
3249 domains_ids.add( "B" );
3250 if ( !p.contains( domains_ids, false ) ) {
3253 if ( !p.contains( domains_ids, true ) ) {
3256 domains_ids = new ArrayList<>();
3257 domains_ids.add( "A" );
3258 domains_ids.add( "A" );
3259 domains_ids.add( "A" );
3260 domains_ids.add( "B" );
3261 domains_ids.add( "B" );
3262 if ( !p.contains( domains_ids, false ) ) {
3265 if ( !p.contains( domains_ids, true ) ) {
3268 domains_ids = new ArrayList<>();
3269 domains_ids.add( "A" );
3270 domains_ids.add( "A" );
3271 domains_ids.add( "B" );
3272 domains_ids.add( "A" );
3273 domains_ids.add( "B" );
3274 domains_ids.add( "B" );
3275 domains_ids.add( "A" );
3276 domains_ids.add( "B" );
3277 domains_ids.add( "C" );
3278 domains_ids.add( "A" );
3279 domains_ids.add( "C" );
3280 domains_ids.add( "D" );
3281 if ( !p.contains( domains_ids, false ) ) {
3284 if ( p.contains( domains_ids, true ) ) {
3288 catch ( final Exception e ) {
3289 e.printStackTrace( System.out );
3295 private static boolean testBasicTable() {
3297 final BasicTable<String> t0 = new BasicTable<>();
3298 if ( t0.getNumberOfColumns() != 0 ) {
3301 if ( t0.getNumberOfRows() != 0 ) {
3304 t0.setValue( 3, 2, "23" );
3305 t0.setValue( 10, 1, "error" );
3306 t0.setValue( 10, 1, "110" );
3307 t0.setValue( 9, 1, "19" );
3308 t0.setValue( 1, 10, "101" );
3309 t0.setValue( 10, 10, "1010" );
3310 t0.setValue( 100, 10, "10100" );
3311 t0.setValue( 0, 0, "00" );
3312 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3315 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3318 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3321 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3324 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3327 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3330 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3333 if ( t0.getNumberOfColumns() != 101 ) {
3336 if ( t0.getNumberOfRows() != 11 ) {
3339 if ( t0.getValueAsString( 49, 4 ) != null ) {
3342 final String l = ForesterUtil.getLineSeparator();
3343 final StringBuffer source = new StringBuffer();
3344 source.append( "" + l );
3345 source.append( "# 1 1 1 1 1 1 1 1" + l );
3346 source.append( " 00 01 02 03" + l );
3347 source.append( " 10 11 12 13 " + l );
3348 source.append( "20 21 22 23 " + l );
3349 source.append( " 30 31 32 33" + l );
3350 source.append( "40 41 42 43" + l );
3351 source.append( " # 1 1 1 1 1 " + l );
3352 source.append( "50 51 52 53 54" + l );
3353 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3354 if ( t1.getNumberOfColumns() != 5 ) {
3357 if ( t1.getNumberOfRows() != 6 ) {
3360 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3363 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3366 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3369 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3372 final StringBuffer source1 = new StringBuffer();
3373 source1.append( "" + l );
3374 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3375 source1.append( " 00; 01 ;02;03" + l );
3376 source1.append( " 10; 11; 12; 13 " + l );
3377 source1.append( "20; 21; 22; 23 " + l );
3378 source1.append( " 30; 31; 32; 33" + l );
3379 source1.append( "40;41;42;43" + l );
3380 source1.append( " # 1 1 1 1 1 " + l );
3381 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3382 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3383 if ( t2.getNumberOfColumns() != 5 ) {
3386 if ( t2.getNumberOfRows() != 6 ) {
3389 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3392 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3395 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3398 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3401 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3404 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3407 final StringBuffer source2 = new StringBuffer();
3408 source2.append( "" + l );
3409 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3410 source2.append( " 00; 01 ;02;03" + l );
3411 source2.append( " 10; 11; 12; 13 " + l );
3412 source2.append( "20; 21; 22; 23 " + l );
3413 source2.append( " " + l );
3414 source2.append( " 30; 31; 32; 33" + l );
3415 source2.append( "40;41;42;43" + l );
3416 source2.append( " comment: 1 1 1 1 1 " + l );
3417 source2.append( ";;;50 ; 52; 53;;54 " + l );
3418 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3424 if ( tl.size() != 2 ) {
3427 final BasicTable<String> t3 = tl.get( 0 );
3428 final BasicTable<String> t4 = tl.get( 1 );
3429 if ( t3.getNumberOfColumns() != 4 ) {
3432 if ( t3.getNumberOfRows() != 3 ) {
3435 if ( t4.getNumberOfColumns() != 4 ) {
3438 if ( t4.getNumberOfRows() != 3 ) {
3441 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3444 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3448 catch ( final Exception e ) {
3449 e.printStackTrace( System.out );
3455 private static boolean testBasicTolXMLparsing() {
3457 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3458 final TolParser parser = new TolParser();
3459 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3460 if ( parser.getErrorCount() > 0 ) {
3461 System.out.println( parser.getErrorMessages().toString() );
3464 if ( phylogenies_0.length != 1 ) {
3467 final Phylogeny t1 = phylogenies_0[ 0 ];
3468 if ( t1.getNumberOfExternalNodes() != 5 ) {
3471 if ( !t1.isRooted() ) {
3474 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3477 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3480 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3481 .equals( "Rhombozoa" ) ) {
3484 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3487 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3488 if ( parser.getErrorCount() > 0 ) {
3489 System.out.println( parser.getErrorMessages().toString() );
3492 if ( phylogenies_1.length != 1 ) {
3495 final Phylogeny t2 = phylogenies_1[ 0 ];
3496 if ( t2.getNumberOfExternalNodes() != 664 ) {
3499 if ( !t2.isRooted() ) {
3502 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3505 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3508 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3511 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3514 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3515 .equals( "Aquificae" ) ) {
3518 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3519 .equals( "Aquifex" ) ) {
3522 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3523 if ( parser.getErrorCount() > 0 ) {
3524 System.out.println( parser.getErrorMessages().toString() );
3527 if ( phylogenies_2.length != 1 ) {
3530 final Phylogeny t3 = phylogenies_2[ 0 ];
3531 if ( t3.getNumberOfExternalNodes() != 184 ) {
3534 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3537 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3540 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3543 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3544 if ( parser.getErrorCount() > 0 ) {
3545 System.out.println( parser.getErrorMessages().toString() );
3548 if ( phylogenies_3.length != 1 ) {
3551 final Phylogeny t4 = phylogenies_3[ 0 ];
3552 if ( t4.getNumberOfExternalNodes() != 1 ) {
3555 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3558 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3561 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3564 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3565 if ( parser.getErrorCount() > 0 ) {
3566 System.out.println( parser.getErrorMessages().toString() );
3569 if ( phylogenies_4.length != 1 ) {
3572 final Phylogeny t5 = phylogenies_4[ 0 ];
3573 if ( t5.getNumberOfExternalNodes() != 13 ) {
3576 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3579 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3582 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3586 catch ( final Exception e ) {
3587 e.printStackTrace( System.out );
3593 private static boolean testBasicTreeMethods() {
3595 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3596 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3597 if ( t2.getNumberOfExternalNodes() != 4 ) {
3600 if ( t2.calculateHeight( false ) != 8.5 ) {
3603 if ( !t2.isCompletelyBinary() ) {
3606 if ( t2.isEmpty() ) {
3609 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3610 if ( t3.getNumberOfExternalNodes() != 5 ) {
3613 if ( t3.calculateHeight( true ) != 11 ) {
3616 if ( t3.isCompletelyBinary() ) {
3619 final PhylogenyNode n = t3.getNode( "ABC" );
3620 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))",
3621 new NHXParser() )[ 0 ];
3622 if ( t4.getNumberOfExternalNodes() != 9 ) {
3625 if ( t4.calculateHeight( false ) != 11 ) {
3628 if ( t4.isCompletelyBinary() ) {
3631 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)" );
3632 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3633 if ( t5.getNumberOfExternalNodes() != 8 ) {
3636 if ( t5.calculateHeight( false ) != 15 ) {
3639 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)" );
3640 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3641 if ( t6.calculateHeight( true ) != 15 ) {
3644 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)" );
3645 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3646 if ( t7.calculateHeight( true ) != 15 ) {
3649 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)" );
3650 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3651 if ( t8.getNumberOfExternalNodes() != 10 ) {
3654 if ( t8.calculateHeight( true ) != 15 ) {
3657 final char[] a9 = new char[] { 'a' };
3658 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3659 if ( t9.calculateHeight( true ) != 0 ) {
3662 final char[] a10 = new char[] { 'a', ':', '6' };
3663 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3664 if ( t10.calculateHeight( true ) != 6 ) {
3668 catch ( final Exception e ) {
3669 e.printStackTrace( System.out );
3675 private static boolean testConfidenceAssessor() {
3677 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3678 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3679 final Phylogeny[] ev0 = factory.create(
3680 "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3682 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3683 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3686 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3689 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3690 final Phylogeny[] ev1 = factory.create(
3691 "((((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)));",
3693 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3694 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3697 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3700 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3701 final Phylogeny[] ev_b = factory.create(
3702 "((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",
3704 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3705 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3708 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3712 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3713 final Phylogeny[] ev1x = factory.create(
3714 "((((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)));",
3716 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3717 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3720 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3723 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3724 final Phylogeny[] ev_bx = factory.create(
3725 "((((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",
3727 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3728 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3731 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3734 final Phylogeny[] t2 = factory.create(
3735 "((((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);",
3737 final Phylogeny[] ev2 = factory.create(
3738 "((((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);",
3740 for( final Phylogeny target : t2 ) {
3741 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3743 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3744 new NHXParser() )[ 0 ];
3745 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3746 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3747 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3750 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3753 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3757 catch ( final Exception e ) {
3758 e.printStackTrace();
3764 private static boolean testCopyOfNodeData() {
3766 final PhylogenyNode n1 = PhylogenyNode
3767 .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]" );
3768 final PhylogenyNode n2 = n1.copyNodeData();
3769 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3773 catch ( final Exception e ) {
3774 e.printStackTrace();
3780 private static boolean testCreateBalancedPhylogeny() {
3782 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3783 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3786 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3789 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3790 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3793 if ( p1.getNumberOfExternalNodes() != 100 ) {
3797 catch ( final Exception e ) {
3798 e.printStackTrace();
3804 private static boolean testCreateUriForSeqWeb() {
3806 final PhylogenyNode n = new PhylogenyNode();
3807 n.setName( "tr|B3RJ64" );
3808 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3811 n.setName( "B0LM41_HUMAN" );
3812 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3813 .equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3816 n.setName( "NP_001025424" );
3817 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3818 .equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3821 n.setName( "_NM_001030253-" );
3822 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3823 .equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3826 n.setName( "XM_002122186" );
3827 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3828 .equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3831 n.setName( "dgh_AAA34956_gdg" );
3832 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3835 n.setName( "AAA34956" );
3836 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3839 n.setName( "GI:394892" );
3840 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3841 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3844 n.setName( "gi_394892" );
3845 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3846 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3849 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3850 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3851 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3854 n.setName( "P12345" );
3855 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3856 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3859 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3860 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3861 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3865 catch ( final Exception e ) {
3866 e.printStackTrace( System.out );
3872 private static boolean testDataObjects() {
3874 final Confidence s0 = new Confidence();
3875 final Confidence s1 = new Confidence();
3876 if ( !s0.isEqual( s1 ) ) {
3879 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3880 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3881 if ( s2.isEqual( s1 ) ) {
3884 if ( !s2.isEqual( s3 ) ) {
3887 final Confidence s4 = ( Confidence ) s3.copy();
3888 if ( !s4.isEqual( s3 ) ) {
3895 final Taxonomy t1 = new Taxonomy();
3896 final Taxonomy t2 = new Taxonomy();
3897 final Taxonomy t3 = new Taxonomy();
3898 final Taxonomy t4 = new Taxonomy();
3899 final Taxonomy t5 = new Taxonomy();
3900 t1.setIdentifier( new Identifier( "ecoli" ) );
3901 t1.setTaxonomyCode( "ECOLI" );
3902 t1.setScientificName( "E. coli" );
3903 t1.setCommonName( "coli" );
3904 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3905 if ( !t1.isEqual( t0 ) ) {
3908 t2.setIdentifier( new Identifier( "ecoli" ) );
3909 t2.setTaxonomyCode( "OTHER" );
3910 t2.setScientificName( "what" );
3911 t2.setCommonName( "something" );
3912 if ( !t1.isEqual( t2 ) ) {
3915 t2.setIdentifier( new Identifier( "nemve" ) );
3916 if ( t1.isEqual( t2 ) ) {
3919 t1.setIdentifier( null );
3920 t3.setTaxonomyCode( "ECOLI" );
3921 t3.setScientificName( "what" );
3922 t3.setCommonName( "something" );
3923 if ( !t1.isEqual( t3 ) ) {
3926 t1.setIdentifier( null );
3927 t1.setTaxonomyCode( "" );
3928 t4.setScientificName( "E. ColI" );
3929 t4.setCommonName( "something" );
3930 if ( !t1.isEqual( t4 ) ) {
3933 t4.setScientificName( "B. subtilis" );
3934 t4.setCommonName( "something" );
3935 if ( t1.isEqual( t4 ) ) {
3938 t1.setIdentifier( null );
3939 t1.setTaxonomyCode( "" );
3940 t1.setScientificName( "" );
3941 t5.setCommonName( "COLI" );
3942 if ( !t1.isEqual( t5 ) ) {
3945 t5.setCommonName( "vibrio" );
3946 if ( t1.isEqual( t5 ) ) {
3951 final Identifier id0 = new Identifier( "123", "pfam" );
3952 final Identifier id1 = ( Identifier ) id0.copy();
3953 if ( !id1.isEqual( id1 ) ) {
3956 if ( !id1.isEqual( id0 ) ) {
3959 if ( !id0.isEqual( id1 ) ) {
3966 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3967 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3968 if ( !pd1.isEqual( pd1 ) ) {
3971 if ( !pd1.isEqual( pd0 ) ) {
3976 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3977 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3978 if ( !pd3.isEqual( pd3 ) ) {
3981 if ( !pd2.isEqual( pd3 ) ) {
3984 if ( !pd0.isEqual( pd3 ) ) {
3989 // DomainArchitecture
3990 // ------------------
3991 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3992 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3993 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3994 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3995 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3996 final ArrayList<PhylogenyData> domains0 = new ArrayList<>();
4001 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
4002 if ( ds0.getNumberOfDomains() != 4 ) {
4005 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
4006 if ( !ds0.isEqual( ds0 ) ) {
4009 if ( !ds0.isEqual( ds1 ) ) {
4012 if ( ds1.getNumberOfDomains() != 4 ) {
4015 final ArrayList<PhylogenyData> domains1 = new ArrayList<>();
4020 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
4021 if ( ds0.isEqual( ds2 ) ) {
4027 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
4028 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
4029 System.out.println( ds3.toNHX() );
4032 if ( ds3.getNumberOfDomains() != 3 ) {
4037 final Event e1 = new Event( Event.EventType.fusion );
4038 if ( e1.isDuplication() ) {
4041 if ( !e1.isFusion() ) {
4044 if ( !e1.asText().toString().equals( "fusion" ) ) {
4047 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
4050 final Event e11 = new Event( Event.EventType.fusion );
4051 if ( !e11.isEqual( e1 ) ) {
4054 if ( !e11.toNHX().toString().equals( "" ) ) {
4057 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
4058 if ( e2.isDuplication() ) {
4061 if ( !e2.isSpeciationOrDuplication() ) {
4064 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
4067 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
4070 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
4073 if ( e11.isEqual( e2 ) ) {
4076 final Event e2c = ( Event ) e2.copy();
4077 if ( !e2c.isEqual( e2 ) ) {
4080 Event e3 = new Event( 1, 2, 3 );
4081 if ( e3.isDuplication() ) {
4084 if ( e3.isSpeciation() ) {
4087 if ( e3.isGeneLoss() ) {
4090 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4093 final Event e3c = ( Event ) e3.copy();
4094 final Event e3cc = ( Event ) e3c.copy();
4095 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
4099 if ( !e3c.isEqual( e3cc ) ) {
4102 Event e4 = new Event( 1, 2, 3 );
4103 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4106 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
4109 final Event e4c = ( Event ) e4.copy();
4111 final Event e4cc = ( Event ) e4c.copy();
4112 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
4115 if ( !e4c.isEqual( e4cc ) ) {
4118 final Event e5 = new Event();
4119 if ( !e5.isUnassigned() ) {
4122 if ( !e5.asText().toString().equals( "unassigned" ) ) {
4125 if ( !e5.asSimpleText().toString().equals( "" ) ) {
4128 final Event e6 = new Event( 1, 0, 0 );
4129 if ( !e6.asText().toString().equals( "duplication" ) ) {
4132 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
4135 final Event e7 = new Event( 0, 1, 0 );
4136 if ( !e7.asText().toString().equals( "speciation" ) ) {
4139 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
4142 final Event e8 = new Event( 0, 0, 1 );
4143 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
4146 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
4150 catch ( final Exception e ) {
4151 e.printStackTrace( System.out );
4157 private static boolean testDeletionOfExternalNodes() {
4159 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4160 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
4161 final PhylogenyWriter w = new PhylogenyWriter();
4162 if ( t0.isEmpty() ) {
4165 if ( t0.getNumberOfExternalNodes() != 1 ) {
4168 t0.deleteSubtree( t0.getNode( "A" ), false );
4169 if ( t0.getNumberOfExternalNodes() != 0 ) {
4172 if ( !t0.isEmpty() ) {
4175 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
4176 if ( t1.getNumberOfExternalNodes() != 2 ) {
4179 t1.deleteSubtree( t1.getNode( "A" ), false );
4180 if ( t1.getNumberOfExternalNodes() != 1 ) {
4183 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
4186 t1.deleteSubtree( t1.getNode( "B" ), false );
4187 if ( t1.getNumberOfExternalNodes() != 1 ) {
4190 t1.deleteSubtree( t1.getNode( "r" ), false );
4191 if ( !t1.isEmpty() ) {
4194 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
4195 if ( t2.getNumberOfExternalNodes() != 3 ) {
4198 t2.deleteSubtree( t2.getNode( "B" ), false );
4199 if ( t2.getNumberOfExternalNodes() != 2 ) {
4202 t2.toNewHampshireX();
4203 PhylogenyNode n = t2.getNode( "A" );
4204 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
4207 t2.deleteSubtree( t2.getNode( "A" ), false );
4208 if ( t2.getNumberOfExternalNodes() != 2 ) {
4211 t2.deleteSubtree( t2.getNode( "C" ), true );
4212 if ( t2.getNumberOfExternalNodes() != 1 ) {
4215 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4216 if ( t3.getNumberOfExternalNodes() != 4 ) {
4219 t3.deleteSubtree( t3.getNode( "B" ), true );
4220 if ( t3.getNumberOfExternalNodes() != 3 ) {
4223 n = t3.getNode( "A" );
4224 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
4227 n = n.getNextExternalNode();
4228 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4231 t3.deleteSubtree( t3.getNode( "A" ), true );
4232 if ( t3.getNumberOfExternalNodes() != 2 ) {
4235 n = t3.getNode( "C" );
4236 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4239 t3.deleteSubtree( t3.getNode( "C" ), true );
4240 if ( t3.getNumberOfExternalNodes() != 1 ) {
4243 t3.deleteSubtree( t3.getNode( "D" ), true );
4244 if ( t3.getNumberOfExternalNodes() != 0 ) {
4247 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4248 if ( t4.getNumberOfExternalNodes() != 6 ) {
4251 t4.deleteSubtree( t4.getNode( "B2" ), true );
4252 if ( t4.getNumberOfExternalNodes() != 5 ) {
4255 String s = w.toNewHampshire( t4, true ).toString();
4256 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4259 t4.deleteSubtree( t4.getNode( "B11" ), true );
4260 if ( t4.getNumberOfExternalNodes() != 4 ) {
4263 t4.deleteSubtree( t4.getNode( "C" ), true );
4264 if ( t4.getNumberOfExternalNodes() != 3 ) {
4267 n = t4.getNode( "A" );
4268 n = n.getNextExternalNode();
4269 if ( !n.getName().equals( "B12" ) ) {
4272 n = n.getNextExternalNode();
4273 if ( !n.getName().equals( "D" ) ) {
4276 s = w.toNewHampshire( t4, true ).toString();
4277 if ( !s.equals( "((A,B12),D);" ) ) {
4280 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4281 t5.deleteSubtree( t5.getNode( "A" ), true );
4282 if ( t5.getNumberOfExternalNodes() != 5 ) {
4285 s = w.toNewHampshire( t5, true ).toString();
4286 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
4289 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4290 t6.deleteSubtree( t6.getNode( "B11" ), true );
4291 if ( t6.getNumberOfExternalNodes() != 5 ) {
4294 s = w.toNewHampshire( t6, false ).toString();
4295 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4298 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4299 t7.deleteSubtree( t7.getNode( "B12" ), true );
4300 if ( t7.getNumberOfExternalNodes() != 5 ) {
4303 s = w.toNewHampshire( t7, true ).toString();
4304 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4307 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4308 t8.deleteSubtree( t8.getNode( "B2" ), true );
4309 if ( t8.getNumberOfExternalNodes() != 5 ) {
4312 s = w.toNewHampshire( t8, false ).toString();
4313 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4316 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4317 t9.deleteSubtree( t9.getNode( "C" ), true );
4318 if ( t9.getNumberOfExternalNodes() != 5 ) {
4321 s = w.toNewHampshire( t9, true ).toString();
4322 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4325 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4326 t10.deleteSubtree( t10.getNode( "D" ), true );
4327 if ( t10.getNumberOfExternalNodes() != 5 ) {
4330 s = w.toNewHampshire( t10, true ).toString();
4331 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4334 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4335 t11.deleteSubtree( t11.getNode( "A" ), true );
4336 if ( t11.getNumberOfExternalNodes() != 2 ) {
4339 s = w.toNewHampshire( t11, true ).toString();
4340 if ( !s.equals( "(B,C);" ) ) {
4343 t11.deleteSubtree( t11.getNode( "C" ), true );
4344 if ( t11.getNumberOfExternalNodes() != 1 ) {
4347 s = w.toNewHampshire( t11, false ).toString();
4348 if ( !s.equals( "B;" ) ) {
4351 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4352 t12.deleteSubtree( t12.getNode( "B2" ), true );
4353 if ( t12.getNumberOfExternalNodes() != 8 ) {
4356 s = w.toNewHampshire( t12, true ).toString();
4357 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4360 t12.deleteSubtree( t12.getNode( "B3" ), true );
4361 if ( t12.getNumberOfExternalNodes() != 7 ) {
4364 s = w.toNewHampshire( t12, true ).toString();
4365 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4368 t12.deleteSubtree( t12.getNode( "C3" ), true );
4369 if ( t12.getNumberOfExternalNodes() != 6 ) {
4372 s = w.toNewHampshire( t12, true ).toString();
4373 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4376 t12.deleteSubtree( t12.getNode( "A1" ), true );
4377 if ( t12.getNumberOfExternalNodes() != 5 ) {
4380 s = w.toNewHampshire( t12, true ).toString();
4381 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4384 t12.deleteSubtree( t12.getNode( "B1" ), true );
4385 if ( t12.getNumberOfExternalNodes() != 4 ) {
4388 s = w.toNewHampshire( t12, true ).toString();
4389 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4392 t12.deleteSubtree( t12.getNode( "A3" ), true );
4393 if ( t12.getNumberOfExternalNodes() != 3 ) {
4396 s = w.toNewHampshire( t12, true ).toString();
4397 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4400 t12.deleteSubtree( t12.getNode( "A2" ), true );
4401 if ( t12.getNumberOfExternalNodes() != 2 ) {
4404 s = w.toNewHampshire( t12, true ).toString();
4405 if ( !s.equals( "(C1,C2);" ) ) {
4408 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4409 t13.deleteSubtree( t13.getNode( "D" ), true );
4410 if ( t13.getNumberOfExternalNodes() != 4 ) {
4413 s = w.toNewHampshire( t13, true ).toString();
4414 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4417 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4418 t14.deleteSubtree( t14.getNode( "E" ), true );
4419 if ( t14.getNumberOfExternalNodes() != 5 ) {
4422 s = w.toNewHampshire( t14, true ).toString();
4423 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4426 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4427 t15.deleteSubtree( t15.getNode( "B2" ), true );
4428 if ( t15.getNumberOfExternalNodes() != 11 ) {
4431 t15.deleteSubtree( t15.getNode( "B1" ), true );
4432 if ( t15.getNumberOfExternalNodes() != 10 ) {
4435 t15.deleteSubtree( t15.getNode( "B3" ), true );
4436 if ( t15.getNumberOfExternalNodes() != 9 ) {
4439 t15.deleteSubtree( t15.getNode( "B4" ), true );
4440 if ( t15.getNumberOfExternalNodes() != 8 ) {
4443 t15.deleteSubtree( t15.getNode( "A1" ), true );
4444 if ( t15.getNumberOfExternalNodes() != 7 ) {
4447 t15.deleteSubtree( t15.getNode( "C4" ), true );
4448 if ( t15.getNumberOfExternalNodes() != 6 ) {
4452 catch ( final Exception e ) {
4453 e.printStackTrace( System.out );
4459 private static boolean testDescriptiveStatistics() {
4461 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4462 dss1.addValue( 82 );
4463 dss1.addValue( 78 );
4464 dss1.addValue( 70 );
4465 dss1.addValue( 58 );
4466 dss1.addValue( 42 );
4467 if ( dss1.getN() != 5 ) {
4470 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4473 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4476 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4479 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4482 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4485 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4488 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4491 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4494 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4497 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4500 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4503 dss1.addValue( 123 );
4504 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4507 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4510 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4513 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4514 dss2.addValue( -1.85 );
4515 dss2.addValue( 57.5 );
4516 dss2.addValue( 92.78 );
4517 dss2.addValue( 57.78 );
4518 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4521 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4524 final double[] a = dss2.getDataAsDoubleArray();
4525 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4528 dss2.addValue( -100 );
4529 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4532 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4535 final double[] ds = new double[ 14 ];
4550 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4551 if ( bins.length != 4 ) {
4554 if ( bins[ 0 ] != 2 ) {
4557 if ( bins[ 1 ] != 3 ) {
4560 if ( bins[ 2 ] != 4 ) {
4563 if ( bins[ 3 ] != 5 ) {
4566 final double[] ds1 = new double[ 9 ];
4576 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4577 if ( bins1.length != 4 ) {
4580 if ( bins1[ 0 ] != 2 ) {
4583 if ( bins1[ 1 ] != 3 ) {
4586 if ( bins1[ 2 ] != 0 ) {
4589 if ( bins1[ 3 ] != 4 ) {
4592 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4593 if ( bins1_1.length != 3 ) {
4596 if ( bins1_1[ 0 ] != 3 ) {
4599 if ( bins1_1[ 1 ] != 2 ) {
4602 if ( bins1_1[ 2 ] != 4 ) {
4605 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4606 if ( bins1_2.length != 3 ) {
4609 if ( bins1_2[ 0 ] != 2 ) {
4612 if ( bins1_2[ 1 ] != 2 ) {
4615 if ( bins1_2[ 2 ] != 2 ) {
4618 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4632 dss3.addValue( 10 );
4633 dss3.addValue( 10 );
4634 dss3.addValue( 10 );
4635 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4636 histo.toStringBuffer( 10, '=', 40, 5 );
4637 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4639 catch ( final Exception e ) {
4640 e.printStackTrace( System.out );
4646 private static boolean testDir( final String file ) {
4648 final File f = new File( file );
4649 if ( !f.exists() ) {
4652 if ( !f.isDirectory() ) {
4655 if ( !f.canRead() ) {
4659 catch ( final Exception e ) {
4665 private static boolean testEbiEntryRetrieval() {
4667 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4668 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4669 System.out.println( entry.getAccession() );
4672 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4673 System.out.println( entry.getTaxonomyScientificName() );
4676 if ( !entry.getSequenceName()
4677 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4678 System.out.println( entry.getSequenceName() );
4681 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4682 System.out.println( entry.getGeneName() );
4685 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4686 System.out.println( entry.getTaxonomyIdentifier() );
4689 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4690 System.out.println( entry.getAnnotations().first().getRefValue() );
4693 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4694 System.out.println( entry.getAnnotations().first().getRefSource() );
4697 if ( entry.getCrossReferences().size() < 1 ) {
4700 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4701 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4704 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4705 System.out.println( entry1.getTaxonomyScientificName() );
4708 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4709 System.out.println( entry1.getSequenceName() );
4712 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4713 System.out.println( entry1.getTaxonomyIdentifier() );
4716 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4717 System.out.println( entry1.getGeneName() );
4720 if ( entry1.getCrossReferences().size() < 1 ) {
4723 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4724 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4727 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4728 System.out.println( entry2.getTaxonomyScientificName() );
4731 if ( !entry2.getSequenceName()
4732 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4733 System.out.println( entry2.getSequenceName() );
4736 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4737 System.out.println( entry2.getTaxonomyIdentifier() );
4740 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4741 System.out.println( entry2.getGeneName() );
4744 if ( entry2.getCrossReferences().size() < 1 ) {
4747 if ( !entry2.getChromosome().equals( "20" ) ) {
4750 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4753 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4754 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4757 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4758 System.out.println( entry3.getTaxonomyScientificName() );
4761 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4762 System.out.println( entry3.getSequenceName() );
4765 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4766 System.out.println( entry3.getTaxonomyIdentifier() );
4769 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4770 System.out.println( entry3.getSequenceSymbol() );
4773 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4776 if ( entry3.getCrossReferences().size() < 1 ) {
4779 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4780 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4783 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4784 System.out.println( entry4.getTaxonomyScientificName() );
4787 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4788 System.out.println( entry4.getSequenceName() );
4791 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4792 System.out.println( entry4.getTaxonomyIdentifier() );
4795 if ( !entry4.getGeneName().equals( "ras" ) ) {
4796 System.out.println( entry4.getGeneName() );
4799 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4800 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4803 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4804 System.out.println( entry5.getTaxonomyScientificName() );
4807 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4808 System.out.println( entry5.getSequenceName() );
4811 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4812 System.out.println( entry5.getTaxonomyIdentifier() );
4815 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4816 if ( !entry6.getAccession().equals( "M30539" ) ) {
4819 if ( !entry6.getGeneName().equals( "ras" ) ) {
4822 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4825 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4828 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4831 if ( entry6.getCrossReferences().size() < 1 ) {
4835 catch ( final IOException e ) {
4836 System.out.println();
4837 System.out.println( "the following might be due to absence internet connection:" );
4838 e.printStackTrace( System.out );
4841 catch ( final Exception e ) {
4842 e.printStackTrace();
4848 private static boolean testExternalNodeRelatedMethods() {
4850 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4851 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4852 PhylogenyNode n = t1.getNode( "A" );
4853 n = n.getNextExternalNode();
4854 if ( !n.getName().equals( "B" ) ) {
4857 n = n.getNextExternalNode();
4858 if ( !n.getName().equals( "C" ) ) {
4861 n = n.getNextExternalNode();
4862 if ( !n.getName().equals( "D" ) ) {
4865 n = t1.getNode( "B" );
4866 while ( !n.isLastExternalNode() ) {
4867 n = n.getNextExternalNode();
4869 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4870 n = t2.getNode( "A" );
4871 n = n.getNextExternalNode();
4872 if ( !n.getName().equals( "B" ) ) {
4875 n = n.getNextExternalNode();
4876 if ( !n.getName().equals( "C" ) ) {
4879 n = n.getNextExternalNode();
4880 if ( !n.getName().equals( "D" ) ) {
4883 n = t2.getNode( "B" );
4884 while ( !n.isLastExternalNode() ) {
4885 n = n.getNextExternalNode();
4887 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4888 n = t3.getNode( "A" );
4889 n = n.getNextExternalNode();
4890 if ( !n.getName().equals( "B" ) ) {
4893 n = n.getNextExternalNode();
4894 if ( !n.getName().equals( "C" ) ) {
4897 n = n.getNextExternalNode();
4898 if ( !n.getName().equals( "D" ) ) {
4901 n = n.getNextExternalNode();
4902 if ( !n.getName().equals( "E" ) ) {
4905 n = n.getNextExternalNode();
4906 if ( !n.getName().equals( "F" ) ) {
4909 n = n.getNextExternalNode();
4910 if ( !n.getName().equals( "G" ) ) {
4913 n = n.getNextExternalNode();
4914 if ( !n.getName().equals( "H" ) ) {
4917 n = t3.getNode( "B" );
4918 while ( !n.isLastExternalNode() ) {
4919 n = n.getNextExternalNode();
4921 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4922 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4923 final PhylogenyNode node = iter.next();
4925 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4926 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4927 final PhylogenyNode node = iter.next();
4929 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))",
4930 new NHXParser() )[ 0 ];
4931 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4932 if ( !iter.next().getName().equals( "A" ) ) {
4935 if ( !iter.next().getName().equals( "B" ) ) {
4938 if ( !iter.next().getName().equals( "C" ) ) {
4941 if ( !iter.next().getName().equals( "D" ) ) {
4944 if ( !iter.next().getName().equals( "E" ) ) {
4947 if ( !iter.next().getName().equals( "F" ) ) {
4950 if ( iter.hasNext() ) {
4954 catch ( final Exception e ) {
4955 e.printStackTrace( System.out );
4961 private static boolean testExtractSNFromNodeName() {
4963 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4966 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4969 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4972 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4973 .equals( "Mus musculus musculus" ) ) {
4976 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4977 .equals( "Mus musculus musculus" ) ) {
4980 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4981 .equals( "Mus musculus musculus" ) ) {
4984 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4985 .equals( "Mus musculus musculus" ) ) {
4988 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4991 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4992 .equals( "Mus musculus musculus" ) ) {
4995 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4996 .equals( "Mus musculus musculus" ) ) {
5000 .extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
5003 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
5006 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
5009 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
5012 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
5013 .equals( "Mus musculus musculus" ) ) {
5016 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
5019 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
5022 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
5025 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
5028 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
5031 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
5034 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
5037 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
5040 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
5041 .equals( "Mus musculus" ) ) {
5044 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
5045 .equals( "Mus musculus" ) ) {
5048 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
5051 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
5052 .equals( "Mus musculus musculus" ) ) {
5055 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
5056 .equals( "Mus musculus musculus" ) ) {
5059 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
5060 .equals( "Mus musculus musculus" ) ) {
5063 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
5066 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
5067 .equals( "Pilostyles mexicana" ) ) {
5070 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
5071 .equals( "Escherichia coli strain K12/DH10B" ) ) {
5074 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
5075 .equals( "Escherichia coli str. K12/DH10B" ) ) {
5078 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
5079 .equals( "Escherichia coli str. K12/DH10B" ) ) {
5082 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
5083 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5086 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
5087 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5090 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
5091 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5094 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
5095 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5098 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
5099 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
5102 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
5103 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
5106 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
5107 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
5110 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
5111 .equals( "Escherichia coli (strain K12)" ) ) {
5114 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
5115 .equals( "Escherichia coli (strain K12)" ) ) {
5118 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
5119 .equals( "Escherichia coli (str. K12)" ) ) {
5122 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
5123 .equals( "Escherichia coli (str. K12)" ) ) {
5126 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
5127 .equals( "Escherichia coli (str. K12)" ) ) {
5130 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
5131 .equals( "Escherichia coli (var. K12)" ) ) {
5134 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
5135 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5138 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
5139 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5143 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
5144 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5147 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
5148 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5152 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
5153 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5156 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
5157 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5160 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
5161 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
5164 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
5167 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
5170 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
5173 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
5174 .equals( "Macrocera sp." ) ) {
5177 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
5180 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
5181 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
5184 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
5185 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
5188 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
5189 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
5192 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
5193 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
5197 catch ( final Exception e ) {
5198 e.printStackTrace( System.out );
5204 private static boolean testExtractTaxonomyDataFromNodeName() {
5206 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
5207 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5210 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
5211 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5214 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
5215 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5218 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
5219 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5222 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
5223 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5226 n = new PhylogenyNode( "HNRPR_HUMAN" );
5227 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5230 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
5231 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5235 catch ( final Exception e ) {
5236 e.printStackTrace( System.out );
5242 private static boolean testExtractTaxonomyCodeFromNodeName() {
5244 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE",
5245 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5248 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5249 .equals( "SOYBN" ) ) {
5252 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5253 .equals( "ARATH" ) ) {
5256 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5257 .equals( "ARATH" ) ) {
5260 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5261 .equals( "RAT" ) ) {
5264 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5265 .equals( "RAT" ) ) {
5268 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1",
5269 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5272 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5273 .equals( "SOYBN" ) ) {
5276 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5277 .equals( "SOYBN" ) ) {
5280 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5281 .equals( "SOYBN" ) ) {
5284 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5285 .equals( "SOYBN" ) ) {
5288 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5289 .equals( "SOYBN" ) ) {
5292 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5293 .equals( "SOYBN" ) ) {
5296 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
5297 .equals( "SOYBN" ) ) {
5300 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5301 .equals( "SOYBN" ) ) {
5304 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx",
5305 TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5308 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5309 .equals( "SOYBN" ) ) {
5313 .extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5314 .equals( "ECOLI" ) ) {
5317 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blagg_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5318 .equals( "9YX45" ) ) {
5321 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5322 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5323 .equals( "MOUSE" ) ) {
5326 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5327 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5328 .equals( "MOUSE" ) ) {
5331 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5332 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5333 .equals( "MOUSE" ) ) {
5336 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5337 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5340 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5341 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5344 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5345 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5346 .equals( "RAT" ) ) {
5349 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5350 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5351 .equals( "RAT" ) ) {
5354 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5355 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5356 .equals( "RAT" ) ) {
5359 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5360 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5363 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5364 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5367 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5368 .equals( "RAT" ) ) {
5371 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5372 .equals( "PIG" ) ) {
5376 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5377 .equals( "MOUSE" ) ) {
5380 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5381 .equals( "MOUSE" ) ) {
5384 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ",
5385 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5389 catch ( final Exception e ) {
5390 e.printStackTrace( System.out );
5396 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5398 PhylogenyNode n = new PhylogenyNode();
5399 n.setName( "tr|B3RJ64" );
5400 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5403 n.setName( "tr.B3RJ64" );
5404 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5407 n.setName( "tr=B3RJ64" );
5408 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5411 n.setName( "tr-B3RJ64" );
5412 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5415 n.setName( "tr/B3RJ64" );
5416 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5419 n.setName( "tr\\B3RJ64" );
5420 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5423 n.setName( "tr_B3RJ64" );
5424 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5427 n.setName( " tr|B3RJ64 " );
5428 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5431 n.setName( "-tr|B3RJ64-" );
5432 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5435 n.setName( "-tr=B3RJ64-" );
5436 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5439 n.setName( "_tr=B3RJ64_" );
5440 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5443 n.setName( " tr_tr|B3RJ64_sp|123 " );
5444 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5447 n.setName( "B3RJ64" );
5448 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5451 n.setName( "sp|B3RJ64" );
5452 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5455 n.setName( "sp|B3RJ64C" );
5456 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5459 n.setName( "sp B3RJ64" );
5460 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5463 n.setName( "sp|B3RJ6X" );
5464 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5467 n.setName( "sp|B3RJ6" );
5468 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5471 n.setName( "K1PYK7_CRAGI" );
5472 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5475 n.setName( "K1PYK7_PEA" );
5476 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5479 n.setName( "K1PYK7_RAT" );
5480 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5483 n.setName( "K1PYK7_PIG" );
5484 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5487 n.setName( "~K1PYK7_PIG~" );
5488 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5491 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5492 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5495 n.setName( "K1PYKX_CRAGI" );
5496 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5499 n.setName( "XXXXX_CRAGI" );
5500 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5503 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5504 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5507 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5508 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5511 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5512 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5515 n = new PhylogenyNode();
5516 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5517 seq.setSymbol( "K1PYK7_CRAGI" );
5518 n.getNodeData().addSequence( seq );
5519 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5522 seq.setSymbol( "tr|B3RJ64" );
5523 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5526 n = new PhylogenyNode();
5527 seq = new org.forester.phylogeny.data.Sequence();
5528 seq.setName( "K1PYK7_CRAGI" );
5529 n.getNodeData().addSequence( seq );
5530 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5533 seq.setName( "tr|B3RJ64" );
5534 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5537 n = new PhylogenyNode();
5538 seq = new org.forester.phylogeny.data.Sequence();
5539 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5540 n.getNodeData().addSequence( seq );
5541 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5544 n = new PhylogenyNode();
5545 seq = new org.forester.phylogeny.data.Sequence();
5546 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5547 n.getNodeData().addSequence( seq );
5548 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5552 n = new PhylogenyNode();
5553 n.setName( "ACP19736" );
5554 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5557 n = new PhylogenyNode();
5558 n.setName( "|ACP19736|" );
5559 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5563 catch ( final Exception e ) {
5564 e.printStackTrace( System.out );
5570 private static boolean testFastaParser() {
5572 final FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5573 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5580 final FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5581 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5588 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5589 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5592 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5595 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5598 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5601 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5604 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5608 catch ( final Exception e ) {
5609 e.printStackTrace();
5615 private static boolean testGenbankAccessorParsing() {
5616 //The format for GenBank Accession numbers are:
5617 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5618 //Protein: 3 letters + 5 numerals
5619 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5620 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5623 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5626 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" )
5627 .equals( "AY423861.24" ) ) {
5630 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5633 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5636 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5639 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5642 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5645 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5648 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5651 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5654 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5657 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5660 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5666 private static boolean testGeneralMsaParser() {
5668 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5669 final Msa msa_0 = GeneralMsaParser.parseMsa( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5670 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5671 final Msa msa_1 = GeneralMsaParser.parseMsa( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5672 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5673 final Msa msa_2 = GeneralMsaParser.parseMsa( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5674 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5675 final Msa msa_3 = GeneralMsaParser.parseMsa( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5676 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5679 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5682 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5685 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5688 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5691 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5694 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5697 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5700 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5703 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5706 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5709 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5712 final Msa msa_4 = GeneralMsaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5713 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5716 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5719 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5722 final Msa msa_5 = GeneralMsaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5723 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5726 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5729 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5732 final Msa msa_6 = GeneralMsaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5733 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5736 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5739 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5743 catch ( final Exception e ) {
5744 e.printStackTrace();
5750 private static boolean testGeneralTable() {
5752 final GeneralTable<Integer, String> t0 = new GeneralTable<>();
5753 t0.setValue( 3, 2, "23" );
5754 t0.setValue( 10, 1, "error" );
5755 t0.setValue( 10, 1, "110" );
5756 t0.setValue( 9, 1, "19" );
5757 t0.setValue( 1, 10, "101" );
5758 t0.setValue( 10, 10, "1010" );
5759 t0.setValue( 100, 10, "10100" );
5760 t0.setValue( 0, 0, "00" );
5761 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5764 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5767 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5770 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5773 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5776 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5779 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5782 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5785 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5788 final GeneralTable<String, String> t1 = new GeneralTable<>();
5789 t1.setValue( "3", "2", "23" );
5790 t1.setValue( "10", "1", "error" );
5791 t1.setValue( "10", "1", "110" );
5792 t1.setValue( "9", "1", "19" );
5793 t1.setValue( "1", "10", "101" );
5794 t1.setValue( "10", "10", "1010" );
5795 t1.setValue( "100", "10", "10100" );
5796 t1.setValue( "0", "0", "00" );
5797 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5798 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5801 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5804 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5807 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5810 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5813 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5816 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5819 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5822 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5825 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5829 catch ( final Exception e ) {
5830 e.printStackTrace( System.out );
5836 private static boolean testGetDistance() {
5838 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5839 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",
5840 new NHXParser() )[ 0 ];
5841 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5844 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5847 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5850 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5853 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5856 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5859 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5862 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5865 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5868 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5871 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5874 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5877 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5880 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5883 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5886 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5889 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5892 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5895 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5898 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5901 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5904 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5907 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5910 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5913 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5916 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5919 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5922 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5925 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5928 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5931 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5934 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",
5935 new NHXParser() )[ 0 ];
5936 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5939 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5942 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5945 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5948 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5951 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5954 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5957 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5960 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5963 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5966 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5970 catch ( final Exception e ) {
5971 e.printStackTrace( System.out );
5977 private static boolean testGetLCA() {
5979 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5980 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5981 new NHXParser() )[ 0 ];
5982 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5983 if ( !A.getName().equals( "A" ) ) {
5986 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5987 if ( !gh.getName().equals( "gh" ) ) {
5990 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5991 if ( !ab.getName().equals( "ab" ) ) {
5994 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5995 if ( !ab2.getName().equals( "ab" ) ) {
5998 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5999 if ( !gh2.getName().equals( "gh" ) ) {
6002 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
6003 if ( !gh3.getName().equals( "gh" ) ) {
6006 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
6007 if ( !abc.getName().equals( "abc" ) ) {
6010 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
6011 if ( !abc2.getName().equals( "abc" ) ) {
6014 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
6015 if ( !abcd.getName().equals( "abcd" ) ) {
6018 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
6019 if ( !abcd2.getName().equals( "abcd" ) ) {
6022 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
6023 if ( !abcdef.getName().equals( "abcdef" ) ) {
6026 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
6027 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6030 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
6031 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6034 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
6035 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6038 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
6039 if ( !abcde.getName().equals( "abcde" ) ) {
6042 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
6043 if ( !abcde2.getName().equals( "abcde" ) ) {
6046 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
6047 if ( !r.getName().equals( "abcdefgh" ) ) {
6050 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
6051 if ( !r2.getName().equals( "abcdefgh" ) ) {
6054 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
6055 if ( !r3.getName().equals( "abcdefgh" ) ) {
6058 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
6059 if ( !abcde3.getName().equals( "abcde" ) ) {
6062 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
6063 if ( !abcde4.getName().equals( "abcde" ) ) {
6066 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
6067 if ( !ab3.getName().equals( "ab" ) ) {
6070 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
6071 if ( !ab4.getName().equals( "ab" ) ) {
6074 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6075 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
6076 if ( !cd.getName().equals( "cd" ) ) {
6079 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
6080 if ( !cd2.getName().equals( "cd" ) ) {
6083 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
6084 if ( !cde.getName().equals( "cde" ) ) {
6087 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
6088 if ( !cde2.getName().equals( "cde" ) ) {
6091 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
6092 if ( !cdef.getName().equals( "cdef" ) ) {
6095 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
6096 if ( !cdef2.getName().equals( "cdef" ) ) {
6099 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
6100 if ( !cdef3.getName().equals( "cdef" ) ) {
6103 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
6104 if ( !rt.getName().equals( "r" ) ) {
6107 final Phylogeny p3 = factory.create(
6108 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6109 new NHXParser() )[ 0 ];
6110 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
6111 if ( !bc_3.getName().equals( "bc" ) ) {
6114 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
6115 if ( !ac_3.getName().equals( "abc" ) ) {
6118 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
6119 if ( !ad_3.getName().equals( "abcde" ) ) {
6122 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
6123 if ( !af_3.getName().equals( "abcdef" ) ) {
6126 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
6127 if ( !ag_3.getName().equals( "" ) ) {
6130 if ( !ag_3.isRoot() ) {
6133 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
6134 if ( !al_3.getName().equals( "" ) ) {
6137 if ( !al_3.isRoot() ) {
6140 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
6141 if ( !kl_3.getName().equals( "" ) ) {
6144 if ( !kl_3.isRoot() ) {
6147 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
6148 if ( !fl_3.getName().equals( "" ) ) {
6151 if ( !fl_3.isRoot() ) {
6154 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
6155 if ( !gk_3.getName().equals( "ghijk" ) ) {
6158 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6159 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
6160 if ( !r_4.getName().equals( "r" ) ) {
6163 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6164 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
6165 if ( !r_5.getName().equals( "root" ) ) {
6168 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6169 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
6170 if ( !r_6.getName().equals( "rot" ) ) {
6173 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6174 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
6175 if ( !r_7.getName().equals( "rott" ) ) {
6179 catch ( final Exception e ) {
6180 e.printStackTrace( System.out );
6186 private static boolean testGetLCA2() {
6188 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6189 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
6190 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
6191 PhylogenyMethods.preOrderReId( p_a );
6192 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
6193 p_a.getNode( "a" ) );
6194 if ( !p_a_1.getName().equals( "a" ) ) {
6197 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
6198 PhylogenyMethods.preOrderReId( p_b );
6199 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
6200 p_b.getNode( "a" ) );
6201 if ( !p_b_1.getName().equals( "b" ) ) {
6204 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
6205 p_b.getNode( "b" ) );
6206 if ( !p_b_2.getName().equals( "b" ) ) {
6209 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
6210 PhylogenyMethods.preOrderReId( p_c );
6211 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
6212 p_c.getNode( "a" ) );
6213 if ( !p_c_1.getName().equals( "b" ) ) {
6216 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
6217 p_c.getNode( "c" ) );
6218 if ( !p_c_2.getName().equals( "c" ) ) {
6219 System.out.println( p_c_2.getName() );
6223 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
6224 p_c.getNode( "b" ) );
6225 if ( !p_c_3.getName().equals( "b" ) ) {
6228 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
6229 p_c.getNode( "a" ) );
6230 if ( !p_c_4.getName().equals( "c" ) ) {
6233 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
6234 new NHXParser() )[ 0 ];
6235 PhylogenyMethods.preOrderReId( p1 );
6236 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6237 p1.getNode( "A" ) );
6238 if ( !A.getName().equals( "A" ) ) {
6241 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
6242 p1.getNode( "gh" ) );
6243 if ( !gh.getName().equals( "gh" ) ) {
6246 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6247 p1.getNode( "B" ) );
6248 if ( !ab.getName().equals( "ab" ) ) {
6251 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6252 p1.getNode( "A" ) );
6253 if ( !ab2.getName().equals( "ab" ) ) {
6256 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6257 p1.getNode( "G" ) );
6258 if ( !gh2.getName().equals( "gh" ) ) {
6261 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
6262 p1.getNode( "H" ) );
6263 if ( !gh3.getName().equals( "gh" ) ) {
6266 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
6267 p1.getNode( "A" ) );
6268 if ( !abc.getName().equals( "abc" ) ) {
6271 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6272 p1.getNode( "C" ) );
6273 if ( !abc2.getName().equals( "abc" ) ) {
6276 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6277 p1.getNode( "D" ) );
6278 if ( !abcd.getName().equals( "abcd" ) ) {
6281 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
6282 p1.getNode( "A" ) );
6283 if ( !abcd2.getName().equals( "abcd" ) ) {
6286 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6287 p1.getNode( "F" ) );
6288 if ( !abcdef.getName().equals( "abcdef" ) ) {
6291 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6292 p1.getNode( "A" ) );
6293 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6296 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6297 p1.getNode( "F" ) );
6298 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6301 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6302 p1.getNode( "ab" ) );
6303 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6306 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6307 p1.getNode( "E" ) );
6308 if ( !abcde.getName().equals( "abcde" ) ) {
6311 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6312 p1.getNode( "A" ) );
6313 if ( !abcde2.getName().equals( "abcde" ) ) {
6316 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6317 p1.getNode( "abcdefgh" ) );
6318 if ( !r.getName().equals( "abcdefgh" ) ) {
6321 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6322 p1.getNode( "H" ) );
6323 if ( !r2.getName().equals( "abcdefgh" ) ) {
6326 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6327 p1.getNode( "A" ) );
6328 if ( !r3.getName().equals( "abcdefgh" ) ) {
6331 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6332 p1.getNode( "abcde" ) );
6333 if ( !abcde3.getName().equals( "abcde" ) ) {
6336 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6337 p1.getNode( "E" ) );
6338 if ( !abcde4.getName().equals( "abcde" ) ) {
6341 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6342 p1.getNode( "B" ) );
6343 if ( !ab3.getName().equals( "ab" ) ) {
6346 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6347 p1.getNode( "ab" ) );
6348 if ( !ab4.getName().equals( "ab" ) ) {
6351 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6352 PhylogenyMethods.preOrderReId( p2 );
6353 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6354 p2.getNode( "d" ) );
6355 if ( !cd.getName().equals( "cd" ) ) {
6358 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6359 p2.getNode( "c" ) );
6360 if ( !cd2.getName().equals( "cd" ) ) {
6363 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6364 p2.getNode( "e" ) );
6365 if ( !cde.getName().equals( "cde" ) ) {
6368 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6369 p2.getNode( "c" ) );
6370 if ( !cde2.getName().equals( "cde" ) ) {
6373 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6374 p2.getNode( "f" ) );
6375 if ( !cdef.getName().equals( "cdef" ) ) {
6378 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6379 p2.getNode( "f" ) );
6380 if ( !cdef2.getName().equals( "cdef" ) ) {
6383 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6384 p2.getNode( "d" ) );
6385 if ( !cdef3.getName().equals( "cdef" ) ) {
6388 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6389 p2.getNode( "a" ) );
6390 if ( !rt.getName().equals( "r" ) ) {
6393 final Phylogeny p3 = factory.create(
6394 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6395 new NHXParser() )[ 0 ];
6396 PhylogenyMethods.preOrderReId( p3 );
6397 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6398 p3.getNode( "c" ) );
6399 if ( !bc_3.getName().equals( "bc" ) ) {
6402 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6403 p3.getNode( "c" ) );
6404 if ( !ac_3.getName().equals( "abc" ) ) {
6407 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6408 p3.getNode( "d" ) );
6409 if ( !ad_3.getName().equals( "abcde" ) ) {
6412 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6413 p3.getNode( "f" ) );
6414 if ( !af_3.getName().equals( "abcdef" ) ) {
6417 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6418 p3.getNode( "g" ) );
6419 if ( !ag_3.getName().equals( "" ) ) {
6422 if ( !ag_3.isRoot() ) {
6425 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6426 p3.getNode( "l" ) );
6427 if ( !al_3.getName().equals( "" ) ) {
6430 if ( !al_3.isRoot() ) {
6433 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6434 p3.getNode( "l" ) );
6435 if ( !kl_3.getName().equals( "" ) ) {
6438 if ( !kl_3.isRoot() ) {
6441 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6442 p3.getNode( "l" ) );
6443 if ( !fl_3.getName().equals( "" ) ) {
6446 if ( !fl_3.isRoot() ) {
6449 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6450 p3.getNode( "k" ) );
6451 if ( !gk_3.getName().equals( "ghijk" ) ) {
6454 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6455 PhylogenyMethods.preOrderReId( p4 );
6456 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6457 p4.getNode( "c" ) );
6458 if ( !r_4.getName().equals( "r" ) ) {
6461 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6462 PhylogenyMethods.preOrderReId( p5 );
6463 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6464 p5.getNode( "c" ) );
6465 if ( !r_5.getName().equals( "root" ) ) {
6468 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6469 PhylogenyMethods.preOrderReId( p6 );
6470 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6471 p6.getNode( "a" ) );
6472 if ( !r_6.getName().equals( "rot" ) ) {
6475 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6476 PhylogenyMethods.preOrderReId( p7 );
6477 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6478 p7.getNode( "e" ) );
6479 if ( !r_7.getName().equals( "rott" ) ) {
6482 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6483 p7.getNode( "a" ) );
6484 if ( !r_71.getName().equals( "rott" ) ) {
6487 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6488 p7.getNode( "rott" ) );
6489 if ( !r_72.getName().equals( "rott" ) ) {
6492 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6493 p7.getNode( "a" ) );
6494 if ( !r_73.getName().equals( "rott" ) ) {
6497 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6498 p7.getNode( "rott" ) );
6499 if ( !r_74.getName().equals( "rott" ) ) {
6502 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6503 p7.getNode( "e" ) );
6504 if ( !r_75.getName().equals( "e" ) ) {
6508 catch ( final Exception e ) {
6509 e.printStackTrace( System.out );
6515 private static boolean testHmmscanOutputParser() {
6516 final String test_dir = Test.PATH_TO_TEST_DATA;
6518 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6519 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ),
6521 INDIVIDUAL_SCORE_CUTOFF.NONE );
6523 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6524 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ),
6526 INDIVIDUAL_SCORE_CUTOFF.NONE );
6527 final List<Protein> proteins = parser2.parse();
6528 if ( parser2.getProteinsEncountered() != 4 ) {
6531 if ( proteins.size() != 4 ) {
6534 if ( parser2.getDomainsEncountered() != 69 ) {
6537 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6540 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6543 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6546 final Protein p1 = proteins.get( 0 );
6547 if ( p1.getNumberOfProteinDomains() != 15 ) {
6550 if ( p1.getLength() != 850 ) {
6553 final Protein p2 = proteins.get( 1 );
6554 if ( p2.getNumberOfProteinDomains() != 51 ) {
6557 if ( p2.getLength() != 1291 ) {
6560 final Protein p3 = proteins.get( 2 );
6561 if ( p3.getNumberOfProteinDomains() != 2 ) {
6564 final Protein p4 = proteins.get( 3 );
6565 if ( p4.getNumberOfProteinDomains() != 1 ) {
6568 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6571 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6574 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6577 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6580 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6583 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6586 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6590 catch ( final Exception e ) {
6591 e.printStackTrace( System.out );
6597 private static boolean testLastExternalNodeMethods() {
6599 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6600 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6601 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6602 final PhylogenyNode n1 = t0.getNode( "A" );
6603 if ( n1.isLastExternalNode() ) {
6606 final PhylogenyNode n2 = t0.getNode( "B" );
6607 if ( n2.isLastExternalNode() ) {
6610 final PhylogenyNode n3 = t0.getNode( "C" );
6611 if ( n3.isLastExternalNode() ) {
6614 final PhylogenyNode n4 = t0.getNode( "D" );
6615 if ( !n4.isLastExternalNode() ) {
6619 catch ( final Exception e ) {
6620 e.printStackTrace( System.out );
6626 private static boolean testLevelOrderIterator() {
6628 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6629 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6630 PhylogenyNodeIterator it0;
6631 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6634 for( it0.reset(); it0.hasNext(); ) {
6637 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6638 if ( !it.next().getName().equals( "r" ) ) {
6641 if ( !it.next().getName().equals( "ab" ) ) {
6644 if ( !it.next().getName().equals( "cd" ) ) {
6647 if ( !it.next().getName().equals( "A" ) ) {
6650 if ( !it.next().getName().equals( "B" ) ) {
6653 if ( !it.next().getName().equals( "C" ) ) {
6656 if ( !it.next().getName().equals( "D" ) ) {
6659 if ( it.hasNext() ) {
6662 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",
6663 new NHXParser() )[ 0 ];
6664 PhylogenyNodeIterator it2;
6665 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6668 for( it2.reset(); it2.hasNext(); ) {
6671 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6672 if ( !it3.next().getName().equals( "r" ) ) {
6675 if ( !it3.next().getName().equals( "abc" ) ) {
6678 if ( !it3.next().getName().equals( "defg" ) ) {
6681 if ( !it3.next().getName().equals( "A" ) ) {
6684 if ( !it3.next().getName().equals( "B" ) ) {
6687 if ( !it3.next().getName().equals( "C" ) ) {
6690 if ( !it3.next().getName().equals( "D" ) ) {
6693 if ( !it3.next().getName().equals( "E" ) ) {
6696 if ( !it3.next().getName().equals( "F" ) ) {
6699 if ( !it3.next().getName().equals( "G" ) ) {
6702 if ( !it3.next().getName().equals( "1" ) ) {
6705 if ( !it3.next().getName().equals( "2" ) ) {
6708 if ( !it3.next().getName().equals( "3" ) ) {
6711 if ( !it3.next().getName().equals( "4" ) ) {
6714 if ( !it3.next().getName().equals( "5" ) ) {
6717 if ( !it3.next().getName().equals( "6" ) ) {
6720 if ( !it3.next().getName().equals( "f1" ) ) {
6723 if ( !it3.next().getName().equals( "f2" ) ) {
6726 if ( !it3.next().getName().equals( "f3" ) ) {
6729 if ( !it3.next().getName().equals( "a" ) ) {
6732 if ( !it3.next().getName().equals( "b" ) ) {
6735 if ( !it3.next().getName().equals( "f21" ) ) {
6738 if ( !it3.next().getName().equals( "X" ) ) {
6741 if ( !it3.next().getName().equals( "Y" ) ) {
6744 if ( !it3.next().getName().equals( "Z" ) ) {
6747 if ( it3.hasNext() ) {
6750 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6751 PhylogenyNodeIterator it4;
6752 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6755 for( it4.reset(); it4.hasNext(); ) {
6758 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6759 if ( !it5.next().getName().equals( "r" ) ) {
6762 if ( !it5.next().getName().equals( "A" ) ) {
6765 if ( !it5.next().getName().equals( "B" ) ) {
6768 if ( !it5.next().getName().equals( "C" ) ) {
6771 if ( !it5.next().getName().equals( "D" ) ) {
6774 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6775 PhylogenyNodeIterator it6;
6776 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6779 for( it6.reset(); it6.hasNext(); ) {
6782 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6783 if ( !it7.next().getName().equals( "A" ) ) {
6786 if ( it.hasNext() ) {
6790 catch ( final Exception e ) {
6791 e.printStackTrace( System.out );
6797 private static boolean testMafft( final String path ) {
6799 final List<String> opts = new ArrayList<>();
6800 opts.add( "--maxiterate" );
6802 opts.add( "--localpair" );
6803 opts.add( "--quiet" );
6805 final MsaInferrer mafft = Mafft.createInstance( path );
6806 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6807 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6810 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6814 catch ( final Exception e ) {
6815 e.printStackTrace( System.out );
6821 private static boolean testMidpointrooting() {
6823 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6824 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6825 PhylogenyMethods.midpointRoot( t0 );
6826 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6829 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6832 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6836 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",
6837 new NHXParser() )[ 0 ];
6838 if ( !t1.isRooted() ) {
6841 PhylogenyMethods.midpointRoot( t1 );
6842 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6845 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6848 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6851 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6854 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6857 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6860 t1.reRoot( t1.getNode( "A" ) );
6861 PhylogenyMethods.midpointRoot( t1 );
6862 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6865 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6868 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6871 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6874 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6878 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6882 catch ( final Exception e ) {
6883 e.printStackTrace( System.out );
6889 private static boolean testMsaQualityMethod() {
6891 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6892 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6893 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6894 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6895 final List<MolecularSequence> l = new ArrayList<>();
6900 final Msa msa = BasicMsa.createInstance( l );
6901 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6904 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6907 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6910 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6913 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6916 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6919 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6923 catch ( final Exception e ) {
6924 e.printStackTrace( System.out );
6930 private static boolean testMsaEntropy() {
6932 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6933 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6934 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6935 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6936 final List<MolecularSequence> l = new ArrayList<>();
6941 final Msa msa = BasicMsa.createInstance( l );
6942 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6944 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6945 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6946 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6947 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6948 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6949 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6950 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6951 // System.out.println();
6952 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6953 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6954 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6955 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6956 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6957 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6958 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6959 final List<MolecularSequence> l2 = new ArrayList<>();
6960 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6961 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6962 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6963 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6964 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6965 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6966 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6967 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6968 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6969 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6970 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6971 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6972 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6973 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6974 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6975 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6976 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6977 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6978 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6979 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6980 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6981 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6982 final Msa msa2 = BasicMsa.createInstance( l2 );
6983 // System.out.println();
6984 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6985 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6986 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6988 catch ( final Exception e ) {
6989 e.printStackTrace( System.out );
6995 private static boolean testDeleteableMsa() {
6997 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6998 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6999 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
7000 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
7001 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
7002 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
7003 final List<MolecularSequence> l0 = new ArrayList<>();
7010 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
7011 dmsa0.deleteRow( "b", false );
7012 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
7015 dmsa0.deleteRow( "e", false );
7016 dmsa0.deleteRow( "a", false );
7017 dmsa0.deleteRow( "f", false );
7018 if ( dmsa0.getLength() != 4 ) {
7021 if ( dmsa0.getNumberOfSequences() != 2 ) {
7024 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
7027 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
7030 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
7033 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
7036 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
7039 dmsa0.deleteRow( "c", false );
7040 dmsa0.deleteRow( "d", false );
7041 if ( dmsa0.getNumberOfSequences() != 0 ) {
7045 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
7046 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
7047 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
7048 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
7049 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
7050 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
7051 final List<MolecularSequence> l1 = new ArrayList<>();
7058 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
7059 dmsa1.deleteGapOnlyColumns();
7060 dmsa1.deleteRow( "a", false );
7061 dmsa1.deleteRow( "f", false );
7062 dmsa1.deleteRow( "d", false );
7063 dmsa1.deleteGapOnlyColumns();
7064 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
7067 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
7070 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
7073 dmsa1.deleteRow( "c", false );
7074 dmsa1.deleteGapOnlyColumns();
7075 final Writer w0 = new StringWriter();
7076 dmsa1.write( w0, MSA_FORMAT.FASTA );
7077 final Writer w1 = new StringWriter();
7078 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
7079 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
7082 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
7085 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
7086 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
7087 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
7088 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
7089 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
7090 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
7091 final List<MolecularSequence> l2 = new ArrayList<>();
7098 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
7099 dmsa2.deleteGapColumns( 0.5 );
7100 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
7103 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
7106 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
7109 dmsa2.deleteGapColumns( 0.2 );
7110 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
7113 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
7116 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
7119 dmsa2.deleteGapColumns( 0 );
7120 dmsa2.deleteRow( "a", false );
7121 dmsa2.deleteRow( "b", false );
7122 dmsa2.deleteRow( "f", false );
7123 dmsa2.deleteRow( "e", false );
7124 dmsa2.setIdentifier( 0, "new_c" );
7125 dmsa2.setIdentifier( 1, "new_d" );
7126 dmsa2.setResidueAt( 0, 0, 'x' );
7127 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
7128 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
7131 final Writer w = new StringWriter();
7132 dmsa2.write( w, MSA_FORMAT.PHYLIP );
7133 final String phylip = w.toString();
7134 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
7135 System.out.println( phylip );
7138 final Writer w2 = new StringWriter();
7139 dmsa2.write( w2, MSA_FORMAT.FASTA );
7140 final String fasta = w2.toString();
7141 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
7142 System.out.println( fasta );
7146 catch ( final Exception e ) {
7147 e.printStackTrace( System.out );
7153 private static boolean testNextNodeWithCollapsing() {
7155 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7157 List<PhylogenyNode> ext = new ArrayList<>();
7158 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7159 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
7160 t0.getNode( "cd" ).setCollapse( true );
7161 t0.getNode( "cde" ).setCollapse( true );
7162 n = t0.getFirstExternalNode();
7163 while ( n != null ) {
7165 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7167 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7170 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7173 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
7176 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
7179 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
7182 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
7186 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7187 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
7188 t1.getNode( "ab" ).setCollapse( true );
7189 t1.getNode( "cd" ).setCollapse( true );
7190 t1.getNode( "cde" ).setCollapse( true );
7191 n = t1.getNode( "ab" );
7192 ext = new ArrayList<>();
7193 while ( n != null ) {
7195 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7197 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7200 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7203 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7206 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
7209 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
7213 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7214 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
7215 t2.getNode( "ab" ).setCollapse( true );
7216 t2.getNode( "cd" ).setCollapse( true );
7217 t2.getNode( "cde" ).setCollapse( true );
7218 t2.getNode( "c" ).setCollapse( true );
7219 t2.getNode( "d" ).setCollapse( true );
7220 t2.getNode( "e" ).setCollapse( true );
7221 t2.getNode( "gh" ).setCollapse( true );
7222 n = t2.getNode( "ab" );
7223 ext = new ArrayList<>();
7224 while ( n != null ) {
7226 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7228 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7231 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7234 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7237 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
7241 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7242 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
7243 t3.getNode( "ab" ).setCollapse( true );
7244 t3.getNode( "cd" ).setCollapse( true );
7245 t3.getNode( "cde" ).setCollapse( true );
7246 t3.getNode( "c" ).setCollapse( true );
7247 t3.getNode( "d" ).setCollapse( true );
7248 t3.getNode( "e" ).setCollapse( true );
7249 t3.getNode( "gh" ).setCollapse( true );
7250 t3.getNode( "fgh" ).setCollapse( true );
7251 n = t3.getNode( "ab" );
7252 ext = new ArrayList<>();
7253 while ( n != null ) {
7255 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7257 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7260 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7263 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
7267 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7268 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
7269 t4.getNode( "ab" ).setCollapse( true );
7270 t4.getNode( "cd" ).setCollapse( true );
7271 t4.getNode( "cde" ).setCollapse( true );
7272 t4.getNode( "c" ).setCollapse( true );
7273 t4.getNode( "d" ).setCollapse( true );
7274 t4.getNode( "e" ).setCollapse( true );
7275 t4.getNode( "gh" ).setCollapse( true );
7276 t4.getNode( "fgh" ).setCollapse( true );
7277 t4.getNode( "abcdefgh" ).setCollapse( true );
7278 n = t4.getNode( "abcdefgh" );
7279 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
7282 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7283 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
7285 n = t5.getFirstExternalNode();
7286 while ( n != null ) {
7288 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7290 if ( ext.size() != 8 ) {
7293 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7296 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7299 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7302 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7305 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7308 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7311 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7314 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7317 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7318 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7320 t6.getNode( "ab" ).setCollapse( true );
7321 n = t6.getNode( "ab" );
7322 while ( n != null ) {
7324 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7326 if ( ext.size() != 7 ) {
7329 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7332 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7335 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7338 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7341 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7344 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7347 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7350 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7351 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7353 t7.getNode( "cd" ).setCollapse( true );
7354 n = t7.getNode( "a" );
7355 while ( n != null ) {
7357 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7359 if ( ext.size() != 7 ) {
7362 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7365 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7368 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7371 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7374 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7377 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7380 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7383 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7384 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7386 t8.getNode( "cd" ).setCollapse( true );
7387 t8.getNode( "c" ).setCollapse( true );
7388 t8.getNode( "d" ).setCollapse( true );
7389 n = t8.getNode( "a" );
7390 while ( n != null ) {
7392 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7394 if ( ext.size() != 7 ) {
7397 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7400 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7403 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7404 System.out.println( "2 fail" );
7407 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7410 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7413 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7416 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7419 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7420 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7422 t9.getNode( "gh" ).setCollapse( true );
7423 n = t9.getNode( "a" );
7424 while ( n != null ) {
7426 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7428 if ( ext.size() != 7 ) {
7431 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7434 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7437 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7440 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7443 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7446 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7449 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7452 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7453 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7455 t10.getNode( "gh" ).setCollapse( true );
7456 t10.getNode( "g" ).setCollapse( true );
7457 t10.getNode( "h" ).setCollapse( true );
7458 n = t10.getNode( "a" );
7459 while ( n != null ) {
7461 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7463 if ( ext.size() != 7 ) {
7466 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7469 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7472 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7475 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7478 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7481 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7484 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7487 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7488 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7490 t11.getNode( "gh" ).setCollapse( true );
7491 t11.getNode( "fgh" ).setCollapse( true );
7492 n = t11.getNode( "a" );
7493 while ( n != null ) {
7495 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7497 if ( ext.size() != 6 ) {
7500 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7503 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7506 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7509 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7512 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7515 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7518 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7519 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7521 t12.getNode( "gh" ).setCollapse( true );
7522 t12.getNode( "fgh" ).setCollapse( true );
7523 t12.getNode( "g" ).setCollapse( true );
7524 t12.getNode( "h" ).setCollapse( true );
7525 t12.getNode( "f" ).setCollapse( true );
7526 n = t12.getNode( "a" );
7527 while ( n != null ) {
7529 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7531 if ( ext.size() != 6 ) {
7534 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7537 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7540 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7543 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7546 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7549 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7552 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7553 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7555 t13.getNode( "ab" ).setCollapse( true );
7556 t13.getNode( "b" ).setCollapse( true );
7557 t13.getNode( "fgh" ).setCollapse( true );
7558 t13.getNode( "gh" ).setCollapse( true );
7559 n = t13.getNode( "ab" );
7560 while ( n != null ) {
7562 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7564 if ( ext.size() != 5 ) {
7567 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7570 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7573 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7576 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7579 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7582 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7583 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7585 t14.getNode( "ab" ).setCollapse( true );
7586 t14.getNode( "a" ).setCollapse( true );
7587 t14.getNode( "fgh" ).setCollapse( true );
7588 t14.getNode( "gh" ).setCollapse( true );
7589 n = t14.getNode( "ab" );
7590 while ( n != null ) {
7592 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7594 if ( ext.size() != 5 ) {
7597 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7600 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7603 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7606 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7609 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7612 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" );
7613 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7615 t15.getNode( "ab" ).setCollapse( true );
7616 t15.getNode( "a" ).setCollapse( true );
7617 t15.getNode( "fgh" ).setCollapse( true );
7618 t15.getNode( "gh" ).setCollapse( true );
7619 n = t15.getNode( "ab" );
7620 while ( n != null ) {
7622 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7624 if ( ext.size() != 6 ) {
7627 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7630 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7633 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7636 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7639 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7642 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7647 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" );
7648 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7650 t16.getNode( "ab" ).setCollapse( true );
7651 t16.getNode( "a" ).setCollapse( true );
7652 t16.getNode( "fgh" ).setCollapse( true );
7653 t16.getNode( "gh" ).setCollapse( true );
7654 t16.getNode( "cd" ).setCollapse( true );
7655 t16.getNode( "cde" ).setCollapse( true );
7656 t16.getNode( "d" ).setCollapse( true );
7657 t16.getNode( "x" ).setCollapse( true );
7658 n = t16.getNode( "ab" );
7659 while ( n != null ) {
7661 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7663 if ( ext.size() != 4 ) {
7666 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7669 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7672 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7675 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7679 catch ( final Exception e ) {
7680 e.printStackTrace( System.out );
7686 private static boolean testNexusCharactersParsing() {
7688 final NexusCharactersParser parser = new NexusCharactersParser();
7689 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7691 String[] labels = parser.getCharStateLabels();
7692 if ( labels.length != 7 ) {
7695 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7698 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7701 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7704 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7707 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7710 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7713 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7716 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7718 labels = parser.getCharStateLabels();
7719 if ( labels.length != 7 ) {
7722 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7725 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7728 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7731 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7734 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7737 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7740 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7744 catch ( final Exception e ) {
7745 e.printStackTrace( System.out );
7751 private static boolean testNexusMatrixParsing() {
7753 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7754 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7756 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7757 if ( m.getNumberOfCharacters() != 9 ) {
7760 if ( m.getNumberOfIdentifiers() != 5 ) {
7763 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7766 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7769 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7772 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7775 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7778 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7781 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7784 // if ( labels.length != 7 ) {
7787 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7790 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7793 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7796 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7799 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7802 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7805 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7808 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7810 // labels = parser.getCharStateLabels();
7811 // if ( labels.length != 7 ) {
7814 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7817 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7820 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7823 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7826 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7829 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7832 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7836 catch ( final Exception e ) {
7837 e.printStackTrace( System.out );
7843 private static boolean testNexusTreeParsing() {
7845 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7846 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7847 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7848 if ( phylogenies.length != 1 ) {
7851 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7854 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7858 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7859 if ( phylogenies.length != 1 ) {
7862 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7865 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7869 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7870 if ( phylogenies.length != 1 ) {
7873 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7876 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7879 if ( phylogenies[ 0 ].isRooted() ) {
7883 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7884 if ( phylogenies.length != 18 ) {
7887 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7890 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7893 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7896 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7899 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7902 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7905 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7908 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7911 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7914 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7917 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7920 if ( phylogenies[ 8 ].isRooted() ) {
7923 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7926 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7929 if ( !phylogenies[ 9 ].isRooted() ) {
7932 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7935 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7938 if ( !phylogenies[ 10 ].isRooted() ) {
7941 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7944 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7947 if ( phylogenies[ 11 ].isRooted() ) {
7950 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7953 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7956 if ( !phylogenies[ 12 ].isRooted() ) {
7959 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7962 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7965 if ( !phylogenies[ 13 ].isRooted() ) {
7968 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7971 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7974 if ( !phylogenies[ 14 ].isRooted() ) {
7977 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7980 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7983 if ( phylogenies[ 15 ].isRooted() ) {
7986 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7989 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7992 if ( !phylogenies[ 16 ].isRooted() ) {
7995 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7998 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
8001 if ( phylogenies[ 17 ].isRooted() ) {
8004 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
8007 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8009 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
8010 if ( phylogenies.length != 9 ) {
8013 if ( !isEqual( 0.48039661496919533,
8014 phylogenies[ 0 ].getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8017 if ( !isEqual( 0.3959796191512233,
8018 phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8021 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
8024 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
8027 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
8030 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8033 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8037 catch ( final Exception e ) {
8038 e.printStackTrace( System.out );
8044 private static boolean testNexusTreeParsingIterating() {
8046 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
8047 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
8048 if ( !p.hasNext() ) {
8051 Phylogeny phy = p.next();
8052 if ( phy == null ) {
8055 if ( phy.getNumberOfExternalNodes() != 25 ) {
8058 if ( !phy.getName().equals( "" ) ) {
8061 if ( p.hasNext() ) {
8065 if ( phy != null ) {
8069 if ( !p.hasNext() ) {
8073 if ( phy == null ) {
8076 if ( phy.getNumberOfExternalNodes() != 25 ) {
8079 if ( !phy.getName().equals( "" ) ) {
8082 if ( p.hasNext() ) {
8086 if ( phy != null ) {
8089 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
8090 if ( !p.hasNext() ) {
8094 if ( phy == null ) {
8097 if ( phy.getNumberOfExternalNodes() != 10 ) {
8100 if ( !phy.getName().equals( "name" ) ) {
8103 if ( p.hasNext() ) {
8107 if ( phy != null ) {
8111 if ( !p.hasNext() ) {
8115 if ( phy == null ) {
8118 if ( phy.getNumberOfExternalNodes() != 10 ) {
8121 if ( !phy.getName().equals( "name" ) ) {
8124 if ( p.hasNext() ) {
8128 if ( phy != null ) {
8131 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
8132 if ( !p.hasNext() ) {
8136 if ( phy == null ) {
8139 if ( phy.getNumberOfExternalNodes() != 3 ) {
8142 if ( !phy.getName().equals( "" ) ) {
8145 if ( phy.isRooted() ) {
8148 if ( p.hasNext() ) {
8152 if ( phy != null ) {
8157 if ( !p.hasNext() ) {
8161 if ( phy == null ) {
8164 if ( phy.getNumberOfExternalNodes() != 3 ) {
8167 if ( !phy.getName().equals( "" ) ) {
8170 if ( p.hasNext() ) {
8174 if ( phy != null ) {
8178 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
8179 if ( !p.hasNext() ) {
8184 if ( phy == null ) {
8187 if ( phy.getNumberOfExternalNodes() != 10 ) {
8190 if ( !phy.getName().equals( "tree 0" ) ) {
8194 if ( !p.hasNext() ) {
8198 if ( phy == null ) {
8201 if ( phy.getNumberOfExternalNodes() != 10 ) {
8204 if ( !phy.getName().equals( "tree 1" ) ) {
8208 if ( !p.hasNext() ) {
8212 if ( phy == null ) {
8215 if ( phy.getNumberOfExternalNodes() != 3 ) {
8216 System.out.println( phy.toString() );
8219 if ( !phy.getName().equals( "" ) ) {
8222 if ( phy.isRooted() ) {
8226 if ( !p.hasNext() ) {
8230 if ( phy == null ) {
8233 if ( phy.getNumberOfExternalNodes() != 4 ) {
8236 if ( !phy.getName().equals( "" ) ) {
8239 if ( !phy.isRooted() ) {
8243 if ( !p.hasNext() ) {
8247 if ( phy == null ) {
8250 if ( phy.getNumberOfExternalNodes() != 5 ) {
8251 System.out.println( phy.getNumberOfExternalNodes() );
8254 if ( !phy.getName().equals( "" ) ) {
8257 if ( !phy.isRooted() ) {
8261 if ( !p.hasNext() ) {
8265 if ( phy == null ) {
8268 if ( phy.getNumberOfExternalNodes() != 3 ) {
8271 if ( !phy.getName().equals( "" ) ) {
8274 if ( phy.isRooted() ) {
8278 if ( !p.hasNext() ) {
8282 if ( phy == null ) {
8285 if ( phy.getNumberOfExternalNodes() != 2 ) {
8288 if ( !phy.getName().equals( "" ) ) {
8291 if ( !phy.isRooted() ) {
8295 if ( !p.hasNext() ) {
8299 if ( phy.getNumberOfExternalNodes() != 3 ) {
8302 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8305 if ( !phy.isRooted() ) {
8309 if ( !p.hasNext() ) {
8313 if ( phy.getNumberOfExternalNodes() != 3 ) {
8316 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8319 if ( !phy.getName().equals( "tree 8" ) ) {
8323 if ( !p.hasNext() ) {
8327 if ( phy.getNumberOfExternalNodes() != 3 ) {
8330 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8333 if ( !phy.getName().equals( "tree 9" ) ) {
8337 if ( !p.hasNext() ) {
8341 if ( phy.getNumberOfExternalNodes() != 3 ) {
8344 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8347 if ( !phy.getName().equals( "tree 10" ) ) {
8350 if ( !phy.isRooted() ) {
8354 if ( !p.hasNext() ) {
8358 if ( phy.getNumberOfExternalNodes() != 3 ) {
8361 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8364 if ( !phy.getName().equals( "tree 11" ) ) {
8367 if ( phy.isRooted() ) {
8371 if ( !p.hasNext() ) {
8375 if ( phy.getNumberOfExternalNodes() != 3 ) {
8378 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8381 if ( !phy.getName().equals( "tree 12" ) ) {
8384 if ( !phy.isRooted() ) {
8388 if ( !p.hasNext() ) {
8392 if ( phy.getNumberOfExternalNodes() != 3 ) {
8395 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8398 if ( !phy.getName().equals( "tree 13" ) ) {
8401 if ( !phy.isRooted() ) {
8405 if ( !p.hasNext() ) {
8409 if ( phy.getNumberOfExternalNodes() != 10 ) {
8410 System.out.println( phy.getNumberOfExternalNodes() );
8413 if ( !phy.toNewHampshire()
8414 .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;" ) ) {
8415 System.out.println( phy.toNewHampshire() );
8418 if ( !phy.getName().equals( "tree 14" ) ) {
8421 if ( !phy.isRooted() ) {
8425 if ( !p.hasNext() ) {
8429 if ( phy.getNumberOfExternalNodes() != 10 ) {
8430 System.out.println( phy.getNumberOfExternalNodes() );
8433 if ( !phy.toNewHampshire()
8434 .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;" ) ) {
8435 System.out.println( phy.toNewHampshire() );
8438 if ( !phy.getName().equals( "tree 15" ) ) {
8441 if ( phy.isRooted() ) {
8445 if ( !p.hasNext() ) {
8449 if ( phy.getNumberOfExternalNodes() != 10 ) {
8450 System.out.println( phy.getNumberOfExternalNodes() );
8453 if ( !phy.toNewHampshire()
8454 .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;" ) ) {
8455 System.out.println( phy.toNewHampshire() );
8458 if ( !phy.getName().equals( "tree 16" ) ) {
8461 if ( !phy.isRooted() ) {
8465 if ( !p.hasNext() ) {
8469 if ( phy.getNumberOfExternalNodes() != 10 ) {
8470 System.out.println( phy.getNumberOfExternalNodes() );
8473 if ( !phy.toNewHampshire()
8474 .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;" ) ) {
8475 System.out.println( phy.toNewHampshire() );
8478 if ( !phy.getName().equals( "tree 17" ) ) {
8481 if ( phy.isRooted() ) {
8485 if ( p.hasNext() ) {
8489 if ( phy != null ) {
8494 if ( !p.hasNext() ) {
8498 if ( phy == null ) {
8501 if ( phy.getNumberOfExternalNodes() != 10 ) {
8504 if ( !phy.getName().equals( "tree 0" ) ) {
8508 if ( !p.hasNext() ) {
8512 if ( phy == null ) {
8515 if ( phy.getNumberOfExternalNodes() != 10 ) {
8518 if ( !phy.getName().equals( "tree 1" ) ) {
8522 if ( !p.hasNext() ) {
8526 if ( phy == null ) {
8529 if ( phy.getNumberOfExternalNodes() != 3 ) {
8532 if ( !phy.getName().equals( "" ) ) {
8535 if ( phy.isRooted() ) {
8539 if ( !p.hasNext() ) {
8543 if ( phy == null ) {
8546 if ( phy.getNumberOfExternalNodes() != 4 ) {
8549 if ( !phy.getName().equals( "" ) ) {
8552 if ( !phy.isRooted() ) {
8556 if ( !p.hasNext() ) {
8560 if ( phy == null ) {
8563 if ( phy.getNumberOfExternalNodes() != 5 ) {
8564 System.out.println( phy.getNumberOfExternalNodes() );
8567 if ( !phy.getName().equals( "" ) ) {
8570 if ( !phy.isRooted() ) {
8574 if ( !p.hasNext() ) {
8578 if ( phy == null ) {
8581 if ( phy.getNumberOfExternalNodes() != 3 ) {
8584 if ( !phy.getName().equals( "" ) ) {
8587 if ( phy.isRooted() ) {
8591 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8592 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8594 if ( !p2.hasNext() ) {
8598 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8601 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8605 if ( !p2.hasNext() ) {
8610 if ( !p2.hasNext() ) {
8615 if ( !p2.hasNext() ) {
8620 if ( !p2.hasNext() ) {
8625 if ( !p2.hasNext() ) {
8630 if ( !p2.hasNext() ) {
8635 if ( !p2.hasNext() ) {
8640 if ( !p2.hasNext() ) {
8644 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8647 if ( p2.hasNext() ) {
8651 if ( phy != null ) {
8656 if ( !p2.hasNext() ) {
8660 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8663 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8667 catch ( final Exception e ) {
8668 e.printStackTrace( System.out );
8674 private static boolean testNexusTreeParsingTranslating() {
8676 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8677 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8678 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8679 if ( phylogenies.length != 1 ) {
8682 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8685 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8688 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8691 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8694 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8695 .equals( "Aranaeus" ) ) {
8699 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8700 if ( phylogenies.length != 3 ) {
8703 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8706 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8709 if ( phylogenies[ 0 ].isRooted() ) {
8712 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8715 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8718 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8719 .equals( "Aranaeus" ) ) {
8722 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8725 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8728 if ( phylogenies[ 1 ].isRooted() ) {
8731 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8734 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8737 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8738 .equals( "Aranaeus" ) ) {
8741 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8744 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8747 if ( !phylogenies[ 2 ].isRooted() ) {
8750 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8753 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8756 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8757 .equals( "Aranaeus" ) ) {
8761 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8762 if ( phylogenies.length != 3 ) {
8765 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8768 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8771 if ( phylogenies[ 0 ].isRooted() ) {
8774 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8777 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8780 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8781 .equals( "Aranaeus" ) ) {
8784 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8787 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8790 if ( phylogenies[ 1 ].isRooted() ) {
8793 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8796 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8799 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8800 .equals( "Aranaeus" ) ) {
8803 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8806 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8809 if ( !phylogenies[ 2 ].isRooted() ) {
8812 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8815 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8818 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8819 .equals( "Aranaeus" ) ) {
8822 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8823 if ( phylogenies.length != 3 ) {
8826 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8831 catch ( final Exception e ) {
8832 e.printStackTrace( System.out );
8838 private static boolean testNHParsing() {
8840 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8841 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8842 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8845 final NHXParser nhxp = new NHXParser();
8846 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8847 nhxp.setReplaceUnderscores( true );
8848 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8849 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8852 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8855 final Phylogeny p1b = factory.create(
8856 " \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 ",
8857 new NHXParser() )[ 0 ];
8858 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8861 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8864 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8865 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8866 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8867 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8868 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8869 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8870 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8871 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8872 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8873 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8874 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8875 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; " + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8877 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8880 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8883 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8886 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8889 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8890 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8891 final String p16_S = "((A,B),C)";
8892 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8893 if ( p16.length != 1 ) {
8896 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8899 final String p17_S = "(C,(A,B))";
8900 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8901 if ( p17.length != 1 ) {
8904 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8907 final String p18_S = "((A,B),(C,D))";
8908 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8909 if ( p18.length != 1 ) {
8912 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8915 final String p19_S = "(((A,B),C),D)";
8916 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8917 if ( p19.length != 1 ) {
8920 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8923 final String p20_S = "(A,(B,(C,D)))";
8924 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8925 if ( p20.length != 1 ) {
8928 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8931 final String p21_S = "(A,(B,(C,(D,E))))";
8932 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8933 if ( p21.length != 1 ) {
8936 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8939 final String p22_S = "((((A,B),C),D),E)";
8940 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8941 if ( p22.length != 1 ) {
8944 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8947 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8948 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8949 if ( p23.length != 1 ) {
8950 System.out.println( "xl=" + p23.length );
8954 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8957 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8958 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8959 if ( p24.length != 1 ) {
8962 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8965 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8966 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8967 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8968 if ( p241.length != 2 ) {
8971 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8974 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8977 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8978 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8979 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8980 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8981 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8982 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8983 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8984 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8985 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8986 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8989 final String p26_S = "(A,B)ab";
8990 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8991 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8994 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8995 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8996 if ( p27s.length != 1 ) {
8997 System.out.println( "xxl=" + p27s.length );
9001 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
9002 System.out.println( p27s[ 0 ].toNewHampshireX() );
9006 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
9008 if ( p27.length != 1 ) {
9009 System.out.println( "yl=" + p27.length );
9013 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
9014 System.out.println( p27[ 0 ].toNewHampshireX() );
9018 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9019 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9020 final String p28_S3 = "(A,B)ab";
9021 final String p28_S4 = "((((A,B),C),D),;E;)";
9022 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
9024 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
9027 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
9030 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
9033 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
9036 if ( p28.length != 4 ) {
9039 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";
9040 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
9041 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
9044 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";
9045 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
9046 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
9049 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
9050 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
9051 if ( ( p32.length != 0 ) ) {
9054 final String p33_S = "A";
9055 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
9056 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
9059 final String p34_S = "B;";
9060 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
9061 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
9064 final String p35_S = "B:0.2";
9065 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
9066 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
9069 final String p36_S = "(A)";
9070 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
9071 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
9074 final String p37_S = "((A))";
9075 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
9076 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
9079 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
9080 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
9081 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
9084 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
9085 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
9086 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
9089 final String p40_S = "(A,B,C)";
9090 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
9091 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
9094 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
9095 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
9096 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
9099 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
9100 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
9101 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
9104 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)";
9105 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
9106 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
9109 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)))";
9110 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
9111 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
9114 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
9115 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
9116 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
9119 final String p46_S = "";
9120 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
9121 if ( p46.length != 0 ) {
9124 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(),
9125 new NHXParser() )[ 0 ];
9126 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9129 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(),
9130 new NHXParser() )[ 0 ];
9131 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9134 final Phylogeny p49 = factory
9135 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
9136 new NHXParser() )[ 0 ];
9137 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9140 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(),
9141 new NHXParser() )[ 0 ];
9142 if ( p50.getNode( "A" ) == null ) {
9145 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9146 .equals( "((A,B)ab:2.0[88],C);" ) ) {
9149 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
9152 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
9153 .equals( "((A,B)88:2.0,C);" ) ) {
9156 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(),
9157 new NHXParser() )[ 0 ];
9158 if ( p51.getNode( "A(A" ) == null ) {
9161 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(),
9162 new NHXParser() )[ 0 ];
9163 if ( p52.getNode( "A(A" ) == null ) {
9166 final Phylogeny p53 = factory
9167 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
9168 new NHXParser() )[ 0 ];
9169 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
9172 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(),
9173 new NHXParser() )[ 0 ];
9174 if ( p54.getNode( "A" ) == null ) {
9177 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9178 .equals( "((A,B)[88],C);" ) ) {
9181 final Phylogeny p55 = factory
9182 .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);" )
9183 .toString(), new NHXParser() )[ 0 ];
9184 if ( !p55.toNewHampshire()
9185 .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);" ) ) {
9186 System.out.println( p55.toNewHampshire() );
9189 final Phylogeny p56 = factory
9190 .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);" )
9191 .toString(), new NHXParser() )[ 0 ];
9192 if ( !p56.toNewHampshire()
9193 .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);" ) ) {
9194 System.out.println( p56.toNewHampshire() );
9197 final Phylogeny p57 = factory
9198 .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);" )
9199 .toString(), new NHXParser() )[ 0 ];
9200 if ( !p57.toNewHampshire()
9201 .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);" ) ) {
9202 System.out.println( p56.toNewHampshire() );
9205 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
9206 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
9207 if ( !p58.toNewHampshire().equals( s58 ) ) {
9208 System.out.println( p58.toNewHampshire() );
9211 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
9212 final Phylogeny p59 = factory.create( s59, new NHXParser() )[ 0 ];
9213 if ( !p59.toNewHampshire().equals( s59 ) ) {
9214 System.out.println( p59.toNewHampshire() );
9217 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
9218 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
9219 if ( !p60.toNewHampshire().equals( s60 ) ) {
9220 System.out.println( p60.toNewHampshire() );
9223 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
9224 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
9225 if ( !p61.toNewHampshire()
9226 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
9227 System.out.println( p61.toNewHampshire() );
9230 final String s62 = "(1[&type=\"X\",size=123,subtree=(1,2);]:0.003,2[&type=\"(X,Y:3)\"]:0.004)[&type=\"(X,Y)\"]:0.0;";
9231 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
9232 if ( !p62.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9233 System.out.println( p62.toNewHampshire() );
9236 final String s63 = "(1:0.003[&type=\"X\",size=123,subtree=(1,2);],2:0.004[&type=\"(X,Y:3)\"]):0.0[&type=\"(X,Y)\"];";
9237 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
9238 if ( !p63.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9239 System.out.println( p63.toNewHampshire() );
9242 final String s64 = "((1,2):[95.5],3);";
9243 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
9244 if ( !p64.toNewHampshireX().equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
9245 System.out.println( p64.toNewHampshireX() );
9248 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
9249 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
9250 if ( !p65.toNewHampshireX().equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
9251 System.out.println( p65.toNewHampshireX() );
9254 final Phylogeny p66 = factory.create( "((A,B)ab:2[0.44],C)", new NHXParser() )[ 0 ];
9255 if ( !isEqual( 0.44, p66.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9258 final Phylogeny p67 = factory.create( "((A,B):2[0.67],C)", new NHXParser() )[ 0 ];
9259 if ( !isEqual( 0.67, p67.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9262 final Phylogeny p68 = factory.create( "((A,B):[0.68],C)", new NHXParser() )[ 0 ];
9263 if ( !isEqual( 0.68, p68.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9266 final Phylogeny p69 = factory.create( "((A,B)[0.69],C)", new NHXParser() )[ 0 ];
9267 if ( !isEqual( 0.69, p69.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9270 final Phylogeny p70 = factory.create( "((A,B)[+0.7],C)", new NHXParser() )[ 0 ];
9271 if ( !isEqual( 0.7, p70.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9274 final Phylogeny p71 = factory.create( "((A,B)[-0.71],C)", new NHXParser() )[ 0 ];
9275 if ( !isEqual( -0.71, p71.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9278 final Phylogeny p72 = factory.create( "((A,B)[],C)", new NHXParser() )[ 0 ];
9279 if ( !p72.toNewHampshireX().equals( "((A,B),C)" ) ) {
9282 final Phylogeny p73 = factory.create( "((A,B)[12x],C)", new NHXParser() )[ 0 ];
9283 if ( !p73.toNewHampshireX().equals( "((A,B),C)" ) ) {
9286 final Phylogeny p74 = factory.create( "((A,B)[12+],C)", new NHXParser() )[ 0 ];
9287 if ( !p74.toNewHampshireX().equals( "((A,B),C)" ) ) {
9290 final Phylogeny p75 = factory.create( "((A,B)ab[222]:3,C)", new NHXParser() )[ 0 ];
9291 if ( !isEqual( 222, p75.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9294 final Phylogeny p76 = factory.create( "((A,B)[100]:12,C)", new NHXParser() )[ 0 ];
9295 if ( !isEqual( 100, p76.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9298 final Phylogeny p77 = factory.create( "((A,B)abcde:13[77],C)", new NHXParser() )[ 0 ];
9299 if ( !isEqual( 77, p77.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9302 final Phylogeny p78 = factory.create( "((A,B):14[0],C)", new NHXParser() )[ 0 ];
9303 if ( !isEqual( 0, p78.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9306 final String the_one = "((((((a,b)ab:3.0[2],c):12.0[100],(d,e)de)abcde:13.0[2],f):14.0[0]):0.0[0]):0.0[0];";
9307 final Phylogeny p79 = factory.create(
9308 "((((((a,b)ab[2]:3,c)[100]:12,(d,e)de)abcde:13[2],f):14[0]):0[0])[0]:0;",
9309 new NHXParser() )[ 0 ];
9310 final String str79 = p79.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9311 if ( !str79.equals( the_one ) ) {
9312 System.out.println( str79 );
9315 final Phylogeny p80 = factory.create(
9316 "((((((a[a)],b[12])ab[2]:3,c)[+100]:12,(d,e)de[12d,)])ab[]c[]de:13[2],f):14[0]):0[0])[0]:0;",
9317 new NHXParser() )[ 0 ];
9318 final String str80 = p80.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9319 if ( !str80.equals( the_one ) ) {
9320 System.out.println( str80 );
9324 catch ( final Exception e ) {
9325 e.printStackTrace( System.out );
9331 private static boolean testNHParsingSpecialChars() {
9333 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9334 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
9335 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
9336 if ( !p0.toNewHampshireX().equals( i0 ) ) {
9337 System.out.println();
9338 System.out.println( p0.toNewHampshireX() );
9339 System.out.println( i0 );
9342 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
9343 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
9344 if ( !p1.toNewHampshireX().equals( i1 ) ) {
9345 System.out.println();
9346 System.out.println( p1.toNewHampshireX() );
9347 System.out.println( i1 );
9351 catch ( final Exception e ) {
9352 e.printStackTrace( System.out );
9358 private static boolean testNHParsingIter() {
9360 final String p0_str = "(A,B);";
9361 final NHXParser p = new NHXParser();
9362 p.setSource( p0_str );
9363 if ( !p.hasNext() ) {
9366 final Phylogeny p0 = p.next();
9367 if ( !p0.toNewHampshire().equals( p0_str ) ) {
9368 System.out.println( p0.toNewHampshire() );
9371 if ( p.hasNext() ) {
9374 if ( p.next() != null ) {
9378 final String p00_str = "(A,B)root;";
9379 p.setSource( p00_str );
9380 final Phylogeny p00 = p.next();
9381 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9382 System.out.println( p00.toNewHampshire() );
9386 final String p000_str = "A;";
9387 p.setSource( p000_str );
9388 final Phylogeny p000 = p.next();
9389 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9390 System.out.println( p000.toNewHampshire() );
9394 final String p0000_str = "A";
9395 p.setSource( p0000_str );
9396 final Phylogeny p0000 = p.next();
9397 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9398 System.out.println( p0000.toNewHampshire() );
9402 p.setSource( "(A)" );
9403 final Phylogeny p00000 = p.next();
9404 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9405 System.out.println( p00000.toNewHampshire() );
9409 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9410 p.setSource( p1_str );
9411 if ( !p.hasNext() ) {
9414 final Phylogeny p1_0 = p.next();
9415 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9416 System.out.println( p1_0.toNewHampshire() );
9419 if ( !p.hasNext() ) {
9422 final Phylogeny p1_1 = p.next();
9423 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9424 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9427 if ( !p.hasNext() ) {
9430 final Phylogeny p1_2 = p.next();
9431 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9432 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9435 if ( !p.hasNext() ) {
9438 final Phylogeny p1_3 = p.next();
9439 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9440 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9443 if ( p.hasNext() ) {
9446 if ( p.next() != null ) {
9450 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9451 p.setSource( p2_str );
9452 if ( !p.hasNext() ) {
9455 Phylogeny p2_0 = p.next();
9456 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9457 System.out.println( p2_0.toNewHampshire() );
9460 if ( !p.hasNext() ) {
9463 Phylogeny p2_1 = p.next();
9464 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9465 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9468 if ( !p.hasNext() ) {
9471 Phylogeny p2_2 = p.next();
9472 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9473 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9476 if ( !p.hasNext() ) {
9479 Phylogeny p2_3 = p.next();
9480 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9481 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9484 if ( !p.hasNext() ) {
9487 Phylogeny p2_4 = p.next();
9488 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9489 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9492 if ( p.hasNext() ) {
9495 if ( p.next() != null ) {
9500 if ( !p.hasNext() ) {
9504 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9505 System.out.println( p2_0.toNewHampshire() );
9508 if ( !p.hasNext() ) {
9512 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9513 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9516 if ( !p.hasNext() ) {
9520 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9521 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9524 if ( !p.hasNext() ) {
9528 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9529 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9532 if ( !p.hasNext() ) {
9536 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9537 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9540 if ( p.hasNext() ) {
9543 if ( p.next() != null ) {
9547 final String p3_str = "((A,B),C)abc";
9548 p.setSource( p3_str );
9549 if ( !p.hasNext() ) {
9552 final Phylogeny p3_0 = p.next();
9553 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9556 if ( p.hasNext() ) {
9559 if ( p.next() != null ) {
9563 final String p4_str = "((A,B)ab,C)abc";
9564 p.setSource( p4_str );
9565 if ( !p.hasNext() ) {
9568 final Phylogeny p4_0 = p.next();
9569 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9572 if ( p.hasNext() ) {
9575 if ( p.next() != null ) {
9579 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9580 p.setSource( p5_str );
9581 if ( !p.hasNext() ) {
9584 final Phylogeny p5_0 = p.next();
9585 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9588 if ( p.hasNext() ) {
9591 if ( p.next() != null ) {
9595 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9596 p.setSource( p6_str );
9597 if ( !p.hasNext() ) {
9600 Phylogeny p6_0 = p.next();
9601 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9604 if ( p.hasNext() ) {
9607 if ( p.next() != null ) {
9611 if ( !p.hasNext() ) {
9615 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9618 if ( p.hasNext() ) {
9621 if ( p.next() != null ) {
9625 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9626 p.setSource( p7_str );
9627 if ( !p.hasNext() ) {
9630 Phylogeny p7_0 = p.next();
9631 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9634 if ( p.hasNext() ) {
9637 if ( p.next() != null ) {
9641 if ( !p.hasNext() ) {
9645 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9648 if ( p.hasNext() ) {
9651 if ( p.next() != null ) {
9655 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9656 p.setSource( p8_str );
9657 if ( !p.hasNext() ) {
9660 Phylogeny p8_0 = p.next();
9661 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9664 if ( !p.hasNext() ) {
9667 if ( !p.hasNext() ) {
9670 Phylogeny p8_1 = p.next();
9671 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9674 if ( p.hasNext() ) {
9677 if ( p.next() != null ) {
9681 if ( !p.hasNext() ) {
9685 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9688 if ( !p.hasNext() ) {
9692 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9695 if ( p.hasNext() ) {
9698 if ( p.next() != null ) {
9704 if ( p.hasNext() ) {
9708 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9709 if ( !p.hasNext() ) {
9712 Phylogeny p_27 = p.next();
9713 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9714 System.out.println( p_27.toNewHampshireX() );
9718 if ( p.hasNext() ) {
9721 if ( p.next() != null ) {
9725 if ( !p.hasNext() ) {
9729 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9730 System.out.println( p_27.toNewHampshireX() );
9734 if ( p.hasNext() ) {
9737 if ( p.next() != null ) {
9741 final String p30_str = "(A,B);(C,D)";
9742 final NHXParser p30 = new NHXParser();
9743 p30.setSource( p30_str );
9744 if ( !p30.hasNext() ) {
9747 Phylogeny phy30 = p30.next();
9748 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9749 System.out.println( phy30.toNewHampshire() );
9752 if ( !p30.hasNext() ) {
9755 Phylogeny phy301 = p30.next();
9756 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9757 System.out.println( phy301.toNewHampshire() );
9760 if ( p30.hasNext() ) {
9763 if ( p30.hasNext() ) {
9766 if ( p30.next() != null ) {
9769 if ( p30.next() != null ) {
9773 if ( !p30.hasNext() ) {
9777 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9778 System.out.println( phy30.toNewHampshire() );
9781 if ( !p30.hasNext() ) {
9784 phy301 = p30.next();
9785 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9786 System.out.println( phy301.toNewHampshire() );
9789 if ( p30.hasNext() ) {
9792 if ( p30.hasNext() ) {
9795 if ( p30.next() != null ) {
9798 if ( p30.next() != null ) {
9802 catch ( final Exception e ) {
9803 e.printStackTrace( System.out );
9809 private static boolean testNHXconversion() {
9811 final PhylogenyNode n1 = new PhylogenyNode();
9812 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9813 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9814 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9815 final PhylogenyNode n5 = PhylogenyNode
9816 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9817 final PhylogenyNode n6 = PhylogenyNode
9818 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9819 if ( !n1.toNewHampshireX().equals( "" ) ) {
9822 if ( !n2.toNewHampshireX().equals( "" ) ) {
9825 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9828 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9831 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9834 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9835 System.out.println( n6.toNewHampshireX() );
9838 final PhylogenyNode n7 = new PhylogenyNode();
9839 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9840 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9841 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9842 System.out.println( n7
9843 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9847 catch ( final Exception e ) {
9848 e.printStackTrace( System.out );
9854 private static boolean testNHXNodeParsing() {
9856 final PhylogenyNode n1 = new PhylogenyNode();
9857 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9858 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9859 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9860 final PhylogenyNode n5 = PhylogenyNode
9861 .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]" );
9862 if ( !n3.getName().equals( "n3" ) ) {
9865 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9868 if ( n3.isDuplication() ) {
9871 if ( n3.isHasAssignedEvent() ) {
9874 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9877 if ( !n4.getName().equals( "n4" ) ) {
9880 if ( n4.getDistanceToParent() != 0.01 ) {
9883 if ( !n5.getName().equals( "n5" ) ) {
9886 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9889 if ( n5.getDistanceToParent() != 0.1 ) {
9892 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9895 if ( !n5.isDuplication() ) {
9898 if ( !n5.isHasAssignedEvent() ) {
9901 final PhylogenyNode n8 = PhylogenyNode
9902 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9903 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9904 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9907 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9910 final PhylogenyNode n9 = PhylogenyNode
9911 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9912 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9913 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9916 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9919 final PhylogenyNode n10 = PhylogenyNode
9920 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9921 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9924 final PhylogenyNode n20 = PhylogenyNode
9925 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9926 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9929 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9932 final PhylogenyNode n20x = PhylogenyNode
9933 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9934 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9937 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9940 final PhylogenyNode n20xx = PhylogenyNode
9941 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9942 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9945 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9948 final PhylogenyNode n20xxx = PhylogenyNode
9949 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9950 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9953 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9956 final PhylogenyNode n20xxxx = PhylogenyNode
9957 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9958 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9961 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9964 final PhylogenyNode n21 = PhylogenyNode
9965 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9966 if ( !n21.getName().equals( "N21_PIG" ) ) {
9969 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9972 final PhylogenyNode n21x = PhylogenyNode
9973 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9974 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9977 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9980 final PhylogenyNode n22 = PhylogenyNode
9981 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9982 if ( !n22.getName().equals( "n22/PIG" ) ) {
9985 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9988 final PhylogenyNode n23 = PhylogenyNode
9989 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9990 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9993 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9996 final PhylogenyNode a = PhylogenyNode
9997 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9998 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
10001 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
10004 final PhylogenyNode c1 = PhylogenyNode
10005 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
10006 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10007 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
10010 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
10013 final PhylogenyNode c2 = PhylogenyNode
10014 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
10015 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10016 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
10019 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
10022 final PhylogenyNode e3 = PhylogenyNode
10023 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10024 if ( !e3.getName().equals( "n10_RAT~" ) ) {
10027 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
10030 final PhylogenyNode n11 = PhylogenyNode
10031 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
10032 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10033 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
10036 if ( n11.getDistanceToParent() != 0.4 ) {
10039 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
10042 final PhylogenyNode n12 = PhylogenyNode
10043 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
10044 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10045 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
10048 if ( n12.getDistanceToParent() != 0.4 ) {
10051 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
10054 final PhylogenyNode o = PhylogenyNode
10055 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10056 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
10059 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
10062 if ( n1.getName().compareTo( "" ) != 0 ) {
10065 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
10068 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
10071 if ( n2.getName().compareTo( "" ) != 0 ) {
10074 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
10077 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
10080 final PhylogenyNode n00 = PhylogenyNode
10081 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
10082 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
10085 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
10088 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
10089 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
10092 final PhylogenyNode n13 = PhylogenyNode
10093 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10094 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
10097 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
10100 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10103 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10106 final PhylogenyNode n14 = PhylogenyNode
10107 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10108 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
10111 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
10114 final PhylogenyNode n15 = PhylogenyNode
10115 .createInstanceFromNhxString( "something_wicked[123]",
10116 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10117 if ( !n15.getName().equals( "something_wicked" ) ) {
10120 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
10123 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
10126 final PhylogenyNode n16 = PhylogenyNode
10127 .createInstanceFromNhxString( "something_wicked2[9]",
10128 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10129 if ( !n16.getName().equals( "something_wicked2" ) ) {
10132 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
10135 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
10138 final PhylogenyNode n17 = PhylogenyNode
10139 .createInstanceFromNhxString( "something_wicked3[a]",
10140 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10141 if ( !n17.getName().equals( "something_wicked3" ) ) {
10144 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
10147 final PhylogenyNode n18 = PhylogenyNode
10148 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10149 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
10152 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
10155 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
10158 final PhylogenyNode n19 = PhylogenyNode
10159 .createInstanceFromNhxString( "BLAH_1-roejojoej",
10160 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10161 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
10164 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10167 final PhylogenyNode n30 = PhylogenyNode
10168 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
10169 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10170 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
10173 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
10176 final PhylogenyNode n31 = PhylogenyNode
10177 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
10178 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10179 if ( n31.getNodeData().isHasTaxonomy() ) {
10182 final PhylogenyNode n32 = PhylogenyNode
10183 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10184 if ( n32.getNodeData().isHasTaxonomy() ) {
10187 final PhylogenyNode n40 = PhylogenyNode
10188 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10189 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
10192 final PhylogenyNode n41 = PhylogenyNode
10193 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10194 if ( n41.getNodeData().isHasTaxonomy() ) {
10197 final PhylogenyNode n42 = PhylogenyNode
10198 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
10199 if ( n42.getNodeData().isHasTaxonomy() ) {
10202 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
10203 NHXParser.TAXONOMY_EXTRACTION.NO );
10204 if ( n43.getNodeData().isHasTaxonomy() ) {
10207 final PhylogenyNode n44 = PhylogenyNode
10208 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
10209 if ( n44.getNodeData().isHasTaxonomy() ) {
10213 catch ( final Exception e ) {
10214 e.printStackTrace( System.out );
10220 private static boolean testNHXNodeParsing2() {
10222 final PhylogenyNode n0_0 = PhylogenyNode.createInstanceFromNhxString( "n0:[ignore me 123]:1E-3",
10223 NHXParser.TAXONOMY_EXTRACTION.NO,
10226 if ( !n0_0.getName().equals( "n0" ) ) {
10229 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
10232 final PhylogenyNode n0_1 = PhylogenyNode.createInstanceFromNhxString( "n0[ignore me 123]:1E-3",
10233 NHXParser.TAXONOMY_EXTRACTION.NO,
10236 if ( !n0_1.getName().equals( "n0" ) ) {
10239 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
10242 final PhylogenyNode n0_2 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3[ignore me 123]",
10243 NHXParser.TAXONOMY_EXTRACTION.NO,
10246 if ( !n0_2.getName().equals( "n0" ) ) {
10249 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
10252 final PhylogenyNode n0_3 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3:[ignore me 123]",
10253 NHXParser.TAXONOMY_EXTRACTION.NO,
10256 if ( !n0_3.getName().equals( "n0" ) ) {
10259 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
10262 final PhylogenyNode n0_4 = PhylogenyNode.createInstanceFromNhxString( "n0:0.001:[ignore me 123]",
10263 NHXParser.TAXONOMY_EXTRACTION.NO,
10266 if ( !n0_4.getName().equals( "n0" ) ) {
10269 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
10272 final PhylogenyNode n1_0 = PhylogenyNode
10273 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]",
10274 NHXParser.TAXONOMY_EXTRACTION.NO,
10277 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10280 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10283 final PhylogenyNode n1_1 = PhylogenyNode
10284 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001",
10285 NHXParser.TAXONOMY_EXTRACTION.NO,
10288 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10291 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10294 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
10297 final PhylogenyNode n1_2 = PhylogenyNode
10298 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]",
10299 NHXParser.TAXONOMY_EXTRACTION.NO,
10302 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10305 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10308 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
10311 final PhylogenyNode n1_3 = PhylogenyNode
10312 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]",
10313 NHXParser.TAXONOMY_EXTRACTION.NO,
10316 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10319 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10322 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
10325 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10328 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10331 final PhylogenyNode n1_4 = PhylogenyNode
10332 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3",
10333 NHXParser.TAXONOMY_EXTRACTION.NO,
10336 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10339 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10342 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
10345 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10348 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10351 final PhylogenyNode n1_5 = PhylogenyNode
10352 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]",
10353 NHXParser.TAXONOMY_EXTRACTION.NO,
10356 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10359 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
10362 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10365 final PhylogenyNode n1_6 = PhylogenyNode
10366 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3",
10367 NHXParser.TAXONOMY_EXTRACTION.NO,
10370 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10373 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
10376 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
10379 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
10382 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
10386 catch ( final Exception e ) {
10387 e.printStackTrace( System.out );
10393 private static boolean testNHXParsing() {
10395 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10396 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])",
10397 new NHXParser() )[ 0 ];
10398 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
10401 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]";
10402 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
10403 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10406 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]";
10407 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10408 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10411 final Phylogeny[] p3 = factory.create(
10412 "[ 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]",
10414 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10417 final Phylogeny[] p4 = factory.create(
10418 "(((((((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(]",
10420 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10423 final Phylogeny[] p5 = factory.create(
10424 "[] ( [][ ][ ] ([((( &&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(((]",
10426 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10429 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)";
10430 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)";
10431 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10432 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10435 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)))";
10436 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)))";
10437 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10438 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10441 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]) ))[,,, ])))))))";
10442 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10443 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10444 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10447 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10448 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10451 final Phylogeny p10 = factory.create(
10452 " [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]",
10453 new NHXParser() )[ 0 ];
10454 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10457 final Phylogeny p11 = factory.create(
10458 " [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]",
10459 new NHXParser() )[ 0 ];
10460 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10463 final Phylogeny p12 = factory.create( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]",
10464 new NHXParser() )[ 0 ];
10465 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10469 catch ( final Exception e ) {
10470 e.printStackTrace( System.out );
10476 private static boolean testNHXParsingMB() {
10478 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10479 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10480 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10481 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10482 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10483 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10484 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10485 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10486 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10487 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10488 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10491 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10494 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10495 0.1100000000000000e+00 ) ) {
10498 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10501 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10504 final Phylogeny p2 = factory
10505 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10506 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10507 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10508 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10509 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10510 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10511 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10512 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10513 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10514 if ( p2.getNode( "1" ) == null ) {
10517 if ( p2.getNode( "2" ) == null ) {
10521 catch ( final Exception e ) {
10522 e.printStackTrace( System.out );
10529 private static boolean testNHXParsingQuotes() {
10531 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10532 final NHXParser p = new NHXParser();
10533 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10534 if ( phylogenies_0.length != 5 ) {
10537 final Phylogeny phy = phylogenies_0[ 4 ];
10538 if ( phy.getNumberOfExternalNodes() != 7 ) {
10541 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10544 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10547 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10548 .getScientificName().equals( "hsapiens" ) ) {
10551 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10554 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10557 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10560 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10563 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10566 final NHXParser p1p = new NHXParser();
10567 p1p.setIgnoreQuotes( true );
10568 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10569 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10572 final NHXParser p2p = new NHXParser();
10573 p1p.setIgnoreQuotes( false );
10574 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10575 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10578 final NHXParser p3p = new NHXParser();
10579 p3p.setIgnoreQuotes( false );
10580 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10581 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10584 final NHXParser p4p = new NHXParser();
10585 p4p.setIgnoreQuotes( false );
10586 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10587 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10590 final Phylogeny p10 = factory.create(
10591 " [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]",
10592 new NHXParser() )[ 0 ];
10593 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]";
10594 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10597 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10598 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10601 final Phylogeny p12 = factory.create(
10602 " [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]",
10603 new NHXParser() )[ 0 ];
10604 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]";
10605 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10608 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10609 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10612 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;";
10613 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10616 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10617 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10621 catch ( final Exception e ) {
10622 e.printStackTrace( System.out );
10628 private static boolean testNodeRemoval() {
10630 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10631 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10632 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10633 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10636 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10637 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10638 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10641 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10642 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10643 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10647 catch ( final Exception e ) {
10648 e.printStackTrace( System.out );
10654 private static boolean testPhylogenyBranch() {
10656 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10657 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10658 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10659 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10660 if ( !a1b1.equals( a1b1 ) ) {
10663 if ( !a1b1.equals( b1a1 ) ) {
10666 if ( !b1a1.equals( a1b1 ) ) {
10669 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10670 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10671 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10672 if ( a1_b1.equals( b1_a1 ) ) {
10675 if ( a1_b1.equals( a1_b1_ ) ) {
10678 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10679 if ( !a1_b1.equals( b1_a1_ ) ) {
10682 if ( a1_b1_.equals( b1_a1_ ) ) {
10685 if ( !a1_b1_.equals( b1_a1 ) ) {
10689 catch ( final Exception e ) {
10690 e.printStackTrace( System.out );
10696 private static boolean testPhyloXMLparsingOfDistributionElement() {
10698 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10699 PhyloXmlParser xml_parser = null;
10701 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10703 catch ( final Exception e ) {
10704 // Do nothing -- means were not running from jar.
10706 if ( xml_parser == null ) {
10707 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10708 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10709 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10712 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10715 final Phylogeny[] phylogenies_0 = factory
10716 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ), xml_parser );
10717 if ( xml_parser.getErrorCount() > 0 ) {
10718 System.out.println( xml_parser.getErrorMessages().toString() );
10721 if ( phylogenies_0.length != 1 ) {
10724 final Phylogeny t1 = phylogenies_0[ 0 ];
10725 PhylogenyNode n = null;
10726 Distribution d = null;
10727 n = t1.getNode( "root node" );
10728 if ( !n.getNodeData().isHasDistribution() ) {
10731 if ( n.getNodeData().getDistributions().size() != 1 ) {
10734 d = n.getNodeData().getDistribution();
10735 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10738 if ( d.getPoints().size() != 1 ) {
10741 if ( d.getPolygons() != null ) {
10744 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10747 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10750 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10753 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10756 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10759 n = t1.getNode( "node a" );
10760 if ( !n.getNodeData().isHasDistribution() ) {
10763 if ( n.getNodeData().getDistributions().size() != 2 ) {
10766 d = n.getNodeData().getDistribution( 1 );
10767 if ( !d.getDesc().equals( "San Diego" ) ) {
10770 if ( d.getPoints().size() != 1 ) {
10773 if ( d.getPolygons() != null ) {
10776 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10779 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10782 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10785 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10788 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10791 n = t1.getNode( "node bb" );
10792 if ( !n.getNodeData().isHasDistribution() ) {
10795 if ( n.getNodeData().getDistributions().size() != 1 ) {
10798 d = n.getNodeData().getDistribution( 0 );
10799 if ( d.getPoints().size() != 3 ) {
10802 if ( d.getPolygons().size() != 2 ) {
10805 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10808 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10811 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10814 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10817 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10820 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10823 Polygon p = d.getPolygons().get( 0 );
10824 if ( p.getPoints().size() != 3 ) {
10827 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10830 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10833 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10836 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10839 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10842 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10845 p = d.getPolygons().get( 1 );
10846 if ( p.getPoints().size() != 3 ) {
10849 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10852 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10855 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10859 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10860 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10861 if ( rt.length != 1 ) {
10864 final Phylogeny t1_rt = rt[ 0 ];
10865 n = t1_rt.getNode( "root node" );
10866 if ( !n.getNodeData().isHasDistribution() ) {
10869 if ( n.getNodeData().getDistributions().size() != 1 ) {
10872 d = n.getNodeData().getDistribution();
10873 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10876 if ( d.getPoints().size() != 1 ) {
10879 if ( d.getPolygons() != null ) {
10882 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10885 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10888 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10891 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10894 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10897 n = t1_rt.getNode( "node a" );
10898 if ( !n.getNodeData().isHasDistribution() ) {
10901 if ( n.getNodeData().getDistributions().size() != 2 ) {
10904 d = n.getNodeData().getDistribution( 1 );
10905 if ( !d.getDesc().equals( "San Diego" ) ) {
10908 if ( d.getPoints().size() != 1 ) {
10911 if ( d.getPolygons() != null ) {
10914 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10917 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10920 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10923 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10926 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10929 n = t1_rt.getNode( "node bb" );
10930 if ( !n.getNodeData().isHasDistribution() ) {
10933 if ( n.getNodeData().getDistributions().size() != 1 ) {
10936 d = n.getNodeData().getDistribution( 0 );
10937 if ( d.getPoints().size() != 3 ) {
10940 if ( d.getPolygons().size() != 2 ) {
10943 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10946 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10949 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10952 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10955 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10958 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10961 p = d.getPolygons().get( 0 );
10962 if ( p.getPoints().size() != 3 ) {
10965 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10968 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10971 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10974 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10977 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10980 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10983 p = d.getPolygons().get( 1 );
10984 if ( p.getPoints().size() != 3 ) {
10987 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10990 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10993 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10997 catch ( final Exception e ) {
10998 e.printStackTrace( System.out );
11004 private static boolean testPostOrderIterator() {
11006 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11007 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
11008 PhylogenyNodeIterator it0;
11009 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
11012 for( it0.reset(); it0.hasNext(); ) {
11015 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
11016 new NHXParser() )[ 0 ];
11017 final PhylogenyNodeIterator it = t1.iteratorPostorder();
11018 if ( !it.next().getName().equals( "A" ) ) {
11021 if ( !it.next().getName().equals( "B" ) ) {
11024 if ( !it.next().getName().equals( "ab" ) ) {
11027 if ( !it.next().getName().equals( "C" ) ) {
11030 if ( !it.next().getName().equals( "D" ) ) {
11033 if ( !it.next().getName().equals( "cd" ) ) {
11036 if ( !it.next().getName().equals( "abcd" ) ) {
11039 if ( !it.next().getName().equals( "E" ) ) {
11042 if ( !it.next().getName().equals( "F" ) ) {
11045 if ( !it.next().getName().equals( "ef" ) ) {
11048 if ( !it.next().getName().equals( "G" ) ) {
11051 if ( !it.next().getName().equals( "H" ) ) {
11054 if ( !it.next().getName().equals( "gh" ) ) {
11057 if ( !it.next().getName().equals( "efgh" ) ) {
11060 if ( !it.next().getName().equals( "r" ) ) {
11063 if ( it.hasNext() ) {
11067 catch ( final Exception e ) {
11068 e.printStackTrace( System.out );
11074 private static boolean testPreOrderIterator() {
11076 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11077 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
11078 PhylogenyNodeIterator it0;
11079 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
11082 for( it0.reset(); it0.hasNext(); ) {
11085 PhylogenyNodeIterator it = t0.iteratorPreorder();
11086 if ( !it.next().getName().equals( "r" ) ) {
11089 if ( !it.next().getName().equals( "ab" ) ) {
11092 if ( !it.next().getName().equals( "A" ) ) {
11095 if ( !it.next().getName().equals( "B" ) ) {
11098 if ( !it.next().getName().equals( "cd" ) ) {
11101 if ( !it.next().getName().equals( "C" ) ) {
11104 if ( !it.next().getName().equals( "D" ) ) {
11107 if ( it.hasNext() ) {
11110 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
11111 new NHXParser() )[ 0 ];
11112 it = t1.iteratorPreorder();
11113 if ( !it.next().getName().equals( "r" ) ) {
11116 if ( !it.next().getName().equals( "abcd" ) ) {
11119 if ( !it.next().getName().equals( "ab" ) ) {
11122 if ( !it.next().getName().equals( "A" ) ) {
11125 if ( !it.next().getName().equals( "B" ) ) {
11128 if ( !it.next().getName().equals( "cd" ) ) {
11131 if ( !it.next().getName().equals( "C" ) ) {
11134 if ( !it.next().getName().equals( "D" ) ) {
11137 if ( !it.next().getName().equals( "efgh" ) ) {
11140 if ( !it.next().getName().equals( "ef" ) ) {
11143 if ( !it.next().getName().equals( "E" ) ) {
11146 if ( !it.next().getName().equals( "F" ) ) {
11149 if ( !it.next().getName().equals( "gh" ) ) {
11152 if ( !it.next().getName().equals( "G" ) ) {
11155 if ( !it.next().getName().equals( "H" ) ) {
11158 if ( it.hasNext() ) {
11162 catch ( final Exception e ) {
11163 e.printStackTrace( System.out );
11169 private static boolean testPropertiesMap() {
11171 final PropertiesList pm = new PropertiesList();
11172 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
11173 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
11174 final Property p2 = new Property( "something:else",
11176 "improbable:research",
11179 pm.addProperty( p0 );
11180 pm.addProperty( p1 );
11181 pm.addProperty( p2 );
11182 if ( !pm.getProperties( "dimensions:diameter" ).get( 0 ).getValue().equals( "1" ) ) {
11185 if ( !pm.getProperties( "dimensions:length" ).get( 0 ).getValue().equals( "2" ) ) {
11188 if ( pm.getProperties().size() != 3 ) {
11191 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
11194 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
11197 if ( pm.getProperties().size() != 3 ) {
11201 catch ( final Exception e ) {
11202 e.printStackTrace( System.out );
11208 private static boolean testProteinId() {
11210 final ProteinId id1 = new ProteinId( "a" );
11211 final ProteinId id2 = new ProteinId( "a" );
11212 final ProteinId id3 = new ProteinId( "A" );
11213 final ProteinId id4 = new ProteinId( "b" );
11214 if ( !id1.equals( id1 ) ) {
11217 if ( id1.getId().equals( "x" ) ) {
11220 if ( id1.getId().equals( null ) ) {
11223 if ( !id1.equals( id2 ) ) {
11226 if ( id1.equals( id3 ) ) {
11229 if ( id1.hashCode() != id1.hashCode() ) {
11232 if ( id1.hashCode() != id2.hashCode() ) {
11235 if ( id1.hashCode() == id3.hashCode() ) {
11238 if ( id1.compareTo( id1 ) != 0 ) {
11241 if ( id1.compareTo( id2 ) != 0 ) {
11244 if ( id1.compareTo( id3 ) != 0 ) {
11247 if ( id1.compareTo( id4 ) >= 0 ) {
11250 if ( id4.compareTo( id1 ) <= 0 ) {
11253 if ( !id4.getId().equals( "b" ) ) {
11256 final ProteinId id5 = new ProteinId( " C " );
11257 if ( !id5.getId().equals( "C" ) ) {
11260 if ( id5.equals( id1 ) ) {
11264 catch ( final Exception e ) {
11265 e.printStackTrace( System.out );
11271 private static boolean testReIdMethods() {
11273 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11274 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
11275 final long count = PhylogenyNode.getNodeCount();
11276 p.levelOrderReID();
11277 if ( p.getNode( "r" ).getId() != count ) {
11280 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
11283 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
11286 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
11289 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
11292 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
11295 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
11298 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
11301 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
11304 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
11307 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
11310 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
11313 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
11316 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
11319 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
11323 catch ( final Exception e ) {
11324 e.printStackTrace( System.out );
11330 private static boolean testRerooting() {
11332 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11333 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",
11334 new NHXParser() )[ 0 ];
11335 if ( !t1.isRooted() ) {
11338 t1.reRoot( t1.getNode( "D" ) );
11339 t1.reRoot( t1.getNode( "CD" ) );
11340 t1.reRoot( t1.getNode( "A" ) );
11341 t1.reRoot( t1.getNode( "B" ) );
11342 t1.reRoot( t1.getNode( "AB" ) );
11343 t1.reRoot( t1.getNode( "D" ) );
11344 t1.reRoot( t1.getNode( "C" ) );
11345 t1.reRoot( t1.getNode( "CD" ) );
11346 t1.reRoot( t1.getNode( "A" ) );
11347 t1.reRoot( t1.getNode( "B" ) );
11348 t1.reRoot( t1.getNode( "AB" ) );
11349 t1.reRoot( t1.getNode( "D" ) );
11350 t1.reRoot( t1.getNode( "D" ) );
11351 t1.reRoot( t1.getNode( "C" ) );
11352 t1.reRoot( t1.getNode( "A" ) );
11353 t1.reRoot( t1.getNode( "B" ) );
11354 t1.reRoot( t1.getNode( "AB" ) );
11355 t1.reRoot( t1.getNode( "C" ) );
11356 t1.reRoot( t1.getNode( "D" ) );
11357 t1.reRoot( t1.getNode( "CD" ) );
11358 t1.reRoot( t1.getNode( "D" ) );
11359 t1.reRoot( t1.getNode( "A" ) );
11360 t1.reRoot( t1.getNode( "B" ) );
11361 t1.reRoot( t1.getNode( "AB" ) );
11362 t1.reRoot( t1.getNode( "C" ) );
11363 t1.reRoot( t1.getNode( "D" ) );
11364 t1.reRoot( t1.getNode( "CD" ) );
11365 t1.reRoot( t1.getNode( "D" ) );
11366 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
11369 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
11372 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
11375 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
11378 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
11381 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
11384 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",
11385 new NHXParser() )[ 0 ];
11386 t2.reRoot( t2.getNode( "A" ) );
11387 t2.reRoot( t2.getNode( "D" ) );
11388 t2.reRoot( t2.getNode( "ABC" ) );
11389 t2.reRoot( t2.getNode( "A" ) );
11390 t2.reRoot( t2.getNode( "B" ) );
11391 t2.reRoot( t2.getNode( "D" ) );
11392 t2.reRoot( t2.getNode( "C" ) );
11393 t2.reRoot( t2.getNode( "ABC" ) );
11394 t2.reRoot( t2.getNode( "A" ) );
11395 t2.reRoot( t2.getNode( "B" ) );
11396 t2.reRoot( t2.getNode( "AB" ) );
11397 t2.reRoot( t2.getNode( "AB" ) );
11398 t2.reRoot( t2.getNode( "D" ) );
11399 t2.reRoot( t2.getNode( "C" ) );
11400 t2.reRoot( t2.getNode( "B" ) );
11401 t2.reRoot( t2.getNode( "AB" ) );
11402 t2.reRoot( t2.getNode( "D" ) );
11403 t2.reRoot( t2.getNode( "D" ) );
11404 t2.reRoot( t2.getNode( "ABC" ) );
11405 t2.reRoot( t2.getNode( "A" ) );
11406 t2.reRoot( t2.getNode( "B" ) );
11407 t2.reRoot( t2.getNode( "AB" ) );
11408 t2.reRoot( t2.getNode( "D" ) );
11409 t2.reRoot( t2.getNode( "C" ) );
11410 t2.reRoot( t2.getNode( "ABC" ) );
11411 t2.reRoot( t2.getNode( "A" ) );
11412 t2.reRoot( t2.getNode( "B" ) );
11413 t2.reRoot( t2.getNode( "AB" ) );
11414 t2.reRoot( t2.getNode( "D" ) );
11415 t2.reRoot( t2.getNode( "D" ) );
11416 t2.reRoot( t2.getNode( "C" ) );
11417 t2.reRoot( t2.getNode( "A" ) );
11418 t2.reRoot( t2.getNode( "B" ) );
11419 t2.reRoot( t2.getNode( "AB" ) );
11420 t2.reRoot( t2.getNode( "C" ) );
11421 t2.reRoot( t2.getNode( "D" ) );
11422 t2.reRoot( t2.getNode( "ABC" ) );
11423 t2.reRoot( t2.getNode( "D" ) );
11424 t2.reRoot( t2.getNode( "A" ) );
11425 t2.reRoot( t2.getNode( "B" ) );
11426 t2.reRoot( t2.getNode( "AB" ) );
11427 t2.reRoot( t2.getNode( "C" ) );
11428 t2.reRoot( t2.getNode( "D" ) );
11429 t2.reRoot( t2.getNode( "ABC" ) );
11430 t2.reRoot( t2.getNode( "D" ) );
11431 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11434 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11437 t2.reRoot( t2.getNode( "ABC" ) );
11438 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11441 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11444 t2.reRoot( t2.getNode( "AB" ) );
11445 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11448 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11451 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11454 t2.reRoot( t2.getNode( "AB" ) );
11455 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11458 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11461 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11464 t2.reRoot( t2.getNode( "D" ) );
11465 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11468 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11471 t2.reRoot( t2.getNode( "ABC" ) );
11472 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11475 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11478 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11479 new NHXParser() )[ 0 ];
11480 t3.reRoot( t3.getNode( "B" ) );
11481 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11484 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11487 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11490 t3.reRoot( t3.getNode( "B" ) );
11491 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11494 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11497 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11500 t3.reRoot( t3.getRoot() );
11501 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11504 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11507 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11511 catch ( final Exception e ) {
11512 e.printStackTrace( System.out );
11518 private static boolean testSDIse() {
11520 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11521 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11522 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11523 gene1.setRooted( true );
11524 species1.setRooted( true );
11525 final SDI sdi = new SDI( gene1, species1 );
11526 if ( !gene1.getRoot().isDuplication() ) {
11529 final Phylogeny species2 = factory.create(
11530 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11531 new NHXParser() )[ 0 ];
11532 final Phylogeny gene2 = factory.create(
11533 "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11534 new NHXParser() )[ 0 ];
11535 species2.setRooted( true );
11536 gene2.setRooted( true );
11537 final SDI sdi2 = new SDI( gene2, species2 );
11538 if ( sdi2.getDuplicationsSum() != 0 ) {
11541 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11544 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11547 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11550 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11553 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11556 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11559 final Phylogeny species3 = factory.create(
11560 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11561 new NHXParser() )[ 0 ];
11562 final Phylogeny gene3 = factory.create(
11563 "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11564 new NHXParser() )[ 0 ];
11565 species3.setRooted( true );
11566 gene3.setRooted( true );
11567 final SDI sdi3 = new SDI( gene3, species3 );
11568 if ( sdi3.getDuplicationsSum() != 1 ) {
11571 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11574 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11577 final Phylogeny species4 = factory.create(
11578 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11579 new NHXParser() )[ 0 ];
11580 final Phylogeny gene4 = factory.create(
11581 "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11582 new NHXParser() )[ 0 ];
11583 species4.setRooted( true );
11584 gene4.setRooted( true );
11585 final SDI sdi4 = new SDI( gene4, species4 );
11586 if ( sdi4.getDuplicationsSum() != 1 ) {
11589 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11592 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11595 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11598 if ( species4.getNumberOfExternalNodes() != 6 ) {
11601 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11604 final Phylogeny species5 = factory.create(
11605 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11606 new NHXParser() )[ 0 ];
11607 final Phylogeny gene5 = factory.create(
11608 "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11609 new NHXParser() )[ 0 ];
11610 species5.setRooted( true );
11611 gene5.setRooted( true );
11612 final SDI sdi5 = new SDI( gene5, species5 );
11613 if ( sdi5.getDuplicationsSum() != 2 ) {
11616 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11619 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11622 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11625 if ( species5.getNumberOfExternalNodes() != 6 ) {
11628 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11631 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11632 // Conjecture for Comparing Molecular Phylogenies"
11633 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11634 final Phylogeny species6 = factory.create(
11635 "(((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,"
11636 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11637 new NHXParser() )[ 0 ];
11638 final Phylogeny gene6 = factory.create(
11639 "(((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,"
11640 + "((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,"
11641 + "(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;",
11642 new NHXParser() )[ 0 ];
11643 species6.setRooted( true );
11644 gene6.setRooted( true );
11645 final SDI sdi6 = new SDI( gene6, species6 );
11646 if ( sdi6.getDuplicationsSum() != 3 ) {
11649 if ( !gene6.getNode( "r" ).isDuplication() ) {
11652 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11655 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11658 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11661 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11664 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11667 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11670 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11673 sdi6.computeMappingCostL();
11674 if ( sdi6.computeMappingCostL() != 17 ) {
11677 if ( species6.getNumberOfExternalNodes() != 9 ) {
11680 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11683 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11684 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11685 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11686 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11687 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11688 species7.setRooted( true );
11689 final Phylogeny gene7_1 = Test
11690 .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])" );
11691 gene7_1.setRooted( true );
11692 final SDI sdi7 = new SDI( gene7_1, species7 );
11693 if ( sdi7.getDuplicationsSum() != 0 ) {
11696 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11699 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11702 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11705 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11708 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11711 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11714 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11717 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11720 final Phylogeny gene7_2 = Test
11721 .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])" );
11722 gene7_2.setRooted( true );
11723 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11724 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11727 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11730 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11733 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11736 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11739 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11742 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11745 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11748 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11751 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11755 catch ( final Exception e ) {
11761 private static boolean testSDIunrooted() {
11763 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11764 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef",
11765 new NHXParser() )[ 0 ];
11766 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11767 final Iterator<PhylogenyBranch> iter = l.iterator();
11768 PhylogenyBranch br = iter.next();
11769 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11772 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11776 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11779 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11783 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11786 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11790 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11793 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11797 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11800 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11804 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11807 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11811 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11814 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11818 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11821 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11825 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11828 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11832 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11835 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11839 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11842 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11846 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11849 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11853 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11856 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11860 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11863 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11867 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11870 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11873 if ( iter.hasNext() ) {
11876 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11877 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11878 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11880 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11883 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11887 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11890 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11894 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11897 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11900 if ( iter1.hasNext() ) {
11903 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11904 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11905 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11907 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11910 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11914 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11917 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11921 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11924 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11927 if ( iter2.hasNext() ) {
11930 final Phylogeny species0 = factory.create(
11931 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11932 new NHXParser() )[ 0 ];
11933 final Phylogeny gene1 = factory.create(
11934 "(((((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])",
11935 new NHXParser() )[ 0 ];
11936 species0.setRooted( true );
11937 gene1.setRooted( true );
11938 final SDIR sdi_unrooted = new SDIR();
11939 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11940 if ( sdi_unrooted.getCount() != 1 ) {
11943 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11946 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11949 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11952 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11955 final Phylogeny gene2 = factory.create(
11956 "(((((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])",
11957 new NHXParser() )[ 0 ];
11958 gene2.setRooted( true );
11959 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11960 if ( sdi_unrooted.getCount() != 1 ) {
11963 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11966 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11969 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11972 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11975 final Phylogeny species6 = factory.create(
11976 "(((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,"
11977 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11978 new NHXParser() )[ 0 ];
11979 final Phylogeny gene6 = factory.create(
11980 "((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],"
11981 + "(((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],"
11982 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11983 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11984 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11985 new NHXParser() )[ 0 ];
11986 species6.setRooted( true );
11987 gene6.setRooted( true );
11988 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11989 if ( sdi_unrooted.getCount() != 1 ) {
11992 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11995 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11998 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
12001 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
12004 if ( !p6[ 0 ].getRoot().isDuplication() ) {
12007 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
12010 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
12013 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
12016 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
12019 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
12022 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
12025 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
12029 final Phylogeny species7 = factory.create(
12030 "(((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,"
12031 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
12032 new NHXParser() )[ 0 ];
12033 final Phylogeny gene7 = factory.create(
12034 "((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],"
12035 + "(((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],"
12036 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
12037 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
12038 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
12039 new NHXParser() )[ 0 ];
12040 species7.setRooted( true );
12041 gene7.setRooted( true );
12042 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
12043 if ( sdi_unrooted.getCount() != 1 ) {
12046 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
12049 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
12052 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
12055 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
12058 if ( !p7[ 0 ].getRoot().isDuplication() ) {
12061 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
12064 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
12067 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
12070 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
12073 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
12076 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
12079 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
12083 final Phylogeny species8 = factory.create(
12084 "(((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,"
12085 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
12086 new NHXParser() )[ 0 ];
12087 final Phylogeny gene8 = factory.create(
12088 "((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],"
12089 + "(((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],"
12090 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
12091 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
12092 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
12093 new NHXParser() )[ 0 ];
12094 species8.setRooted( true );
12095 gene8.setRooted( true );
12096 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
12097 if ( sdi_unrooted.getCount() != 1 ) {
12100 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
12103 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
12106 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
12109 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
12112 if ( !p8[ 0 ].getRoot().isDuplication() ) {
12115 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
12118 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
12121 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
12124 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
12127 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
12130 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
12133 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
12138 catch ( final Exception e ) {
12139 e.printStackTrace( System.out );
12145 private static boolean testSequenceDbWsTools1() {
12147 final PhylogenyNode n = new PhylogenyNode();
12148 n.setName( "NP_001025424" );
12149 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
12150 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12151 || !acc.getValue().equals( "NP_001025424" ) ) {
12154 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
12155 acc = SequenceDbWsTools.obtainSeqAccession( n );
12156 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12157 || !acc.getValue().equals( "NP_001025424" ) ) {
12160 n.setName( "NP_001025424.1" );
12161 acc = SequenceDbWsTools.obtainSeqAccession( n );
12162 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12163 || !acc.getValue().equals( "NP_001025424" ) ) {
12166 n.setName( "NM_001030253" );
12167 acc = SequenceDbWsTools.obtainSeqAccession( n );
12168 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
12169 || !acc.getValue().equals( "NM_001030253" ) ) {
12172 n.setName( "BCL2_HUMAN" );
12173 acc = SequenceDbWsTools.obtainSeqAccession( n );
12174 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12175 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
12176 System.out.println( acc.toString() );
12179 n.setName( "P10415" );
12180 acc = SequenceDbWsTools.obtainSeqAccession( n );
12181 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12182 || !acc.getValue().equals( "P10415" ) ) {
12183 System.out.println( acc.toString() );
12186 n.setName( " P10415 " );
12187 acc = SequenceDbWsTools.obtainSeqAccession( n );
12188 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12189 || !acc.getValue().equals( "P10415" ) ) {
12190 System.out.println( acc.toString() );
12193 n.setName( "_P10415|" );
12194 acc = SequenceDbWsTools.obtainSeqAccession( n );
12195 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
12196 || !acc.getValue().equals( "P10415" ) ) {
12197 System.out.println( acc.toString() );
12200 n.setName( "AY695820" );
12201 acc = SequenceDbWsTools.obtainSeqAccession( n );
12202 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12203 || !acc.getValue().equals( "AY695820" ) ) {
12204 System.out.println( acc.toString() );
12207 n.setName( "_AY695820_" );
12208 acc = SequenceDbWsTools.obtainSeqAccession( n );
12209 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12210 || !acc.getValue().equals( "AY695820" ) ) {
12211 System.out.println( acc.toString() );
12214 n.setName( "AAA59452" );
12215 acc = SequenceDbWsTools.obtainSeqAccession( n );
12216 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12217 || !acc.getValue().equals( "AAA59452" ) ) {
12218 System.out.println( acc.toString() );
12221 n.setName( "_AAA59452_" );
12222 acc = SequenceDbWsTools.obtainSeqAccession( n );
12223 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12224 || !acc.getValue().equals( "AAA59452" ) ) {
12225 System.out.println( acc.toString() );
12228 n.setName( "AAA59452.1" );
12229 acc = SequenceDbWsTools.obtainSeqAccession( n );
12230 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12231 || !acc.getValue().equals( "AAA59452.1" ) ) {
12232 System.out.println( acc.toString() );
12235 n.setName( "_AAA59452.1_" );
12236 acc = SequenceDbWsTools.obtainSeqAccession( n );
12237 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12238 || !acc.getValue().equals( "AAA59452.1" ) ) {
12239 System.out.println( acc.toString() );
12242 n.setName( "GI:94894583" );
12243 acc = SequenceDbWsTools.obtainSeqAccession( n );
12244 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12245 || !acc.getValue().equals( "94894583" ) ) {
12246 System.out.println( acc.toString() );
12249 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12250 acc = SequenceDbWsTools.obtainSeqAccession( n );
12251 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12252 || !acc.getValue().equals( "71845847" ) ) {
12253 System.out.println( acc.toString() );
12256 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12257 acc = SequenceDbWsTools.obtainSeqAccession( n );
12258 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12259 || !acc.getValue().equals( "AAZ45343.1" ) ) {
12260 System.out.println( acc.toString() );
12264 catch ( final Exception e ) {
12270 private static boolean testSequenceDbWsTools2() {
12272 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
12273 SequenceDbWsTools.obtainSeqInformation( n1 );
12274 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
12277 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12280 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12283 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
12286 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
12287 SequenceDbWsTools.obtainSeqInformation( n2 );
12288 if ( !n2.getNodeData().getSequence().getName()
12289 .equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
12292 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12295 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12298 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
12301 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
12302 SequenceDbWsTools.obtainSeqInformation( n3 );
12303 if ( !n3.getNodeData().getSequence().getName()
12304 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
12307 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
12310 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12313 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
12317 catch ( final IOException e ) {
12318 System.out.println();
12319 System.out.println( "the following might be due to absence internet connection:" );
12320 e.printStackTrace( System.out );
12323 catch ( final Exception e ) {
12324 e.printStackTrace();
12330 private static boolean testSequenceIdParsing() {
12332 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
12333 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12334 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12335 if ( id != null ) {
12336 System.out.println( "value =" + id.getValue() );
12337 System.out.println( "provider=" + id.getSource() );
12341 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
12342 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12343 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12344 if ( id != null ) {
12345 System.out.println( "value =" + id.getValue() );
12346 System.out.println( "provider=" + id.getSource() );
12350 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
12351 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12352 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12353 if ( id != null ) {
12354 System.out.println( "value =" + id.getValue() );
12355 System.out.println( "provider=" + id.getSource() );
12359 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
12360 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12361 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
12362 if ( id != null ) {
12363 System.out.println( "value =" + id.getValue() );
12364 System.out.println( "provider=" + id.getSource() );
12368 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
12369 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12370 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
12371 if ( id != null ) {
12372 System.out.println( "value =" + id.getValue() );
12373 System.out.println( "provider=" + id.getSource() );
12377 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
12378 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12379 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
12380 if ( id != null ) {
12381 System.out.println( "value =" + id.getValue() );
12382 System.out.println( "provider=" + id.getSource() );
12386 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
12387 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12388 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
12389 if ( id != null ) {
12390 System.out.println( "value =" + id.getValue() );
12391 System.out.println( "provider=" + id.getSource() );
12395 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
12396 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12397 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12398 if ( id != null ) {
12399 System.out.println( "value =" + id.getValue() );
12400 System.out.println( "provider=" + id.getSource() );
12404 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12405 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12406 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12407 if ( id != null ) {
12408 System.out.println( "value =" + id.getValue() );
12409 System.out.println( "provider=" + id.getSource() );
12413 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12414 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12415 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12416 if ( id != null ) {
12417 System.out.println( "value =" + id.getValue() );
12418 System.out.println( "provider=" + id.getSource() );
12422 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12423 if ( id != null ) {
12424 System.out.println( "value =" + id.getValue() );
12425 System.out.println( "provider=" + id.getSource() );
12428 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12429 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12430 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12431 if ( id != null ) {
12432 System.out.println( "value =" + id.getValue() );
12433 System.out.println( "provider=" + id.getSource() );
12437 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12438 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12439 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12440 if ( id != null ) {
12441 System.out.println( "value =" + id.getValue() );
12442 System.out.println( "provider=" + id.getSource() );
12446 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12447 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12448 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12449 if ( id != null ) {
12450 System.out.println( "value =" + id.getValue() );
12451 System.out.println( "provider=" + id.getSource() );
12455 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12456 if ( id != null ) {
12457 System.out.println( "value =" + id.getValue() );
12458 System.out.println( "provider=" + id.getSource() );
12462 catch ( final Exception e ) {
12463 e.printStackTrace( System.out );
12469 private static boolean testSequenceWriter() {
12471 final String n = ForesterUtil.LINE_SEPARATOR;
12472 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12475 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12478 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12481 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12484 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12485 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12488 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12489 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12493 catch ( final Exception e ) {
12494 e.printStackTrace();
12500 private static boolean testSpecies() {
12502 final Species s1 = new BasicSpecies( "a" );
12503 final Species s2 = new BasicSpecies( "a" );
12504 final Species s3 = new BasicSpecies( "A" );
12505 final Species s4 = new BasicSpecies( "b" );
12506 if ( !s1.equals( s1 ) ) {
12509 if ( s1.getSpeciesId().equals( "x" ) ) {
12512 if ( s1.getSpeciesId().equals( null ) ) {
12515 if ( !s1.equals( s2 ) ) {
12518 if ( s1.equals( s3 ) ) {
12521 if ( s1.hashCode() != s1.hashCode() ) {
12524 if ( s1.hashCode() != s2.hashCode() ) {
12527 if ( s1.hashCode() == s3.hashCode() ) {
12530 if ( s1.compareTo( s1 ) != 0 ) {
12533 if ( s1.compareTo( s2 ) != 0 ) {
12536 if ( s1.compareTo( s3 ) != 0 ) {
12539 if ( s1.compareTo( s4 ) >= 0 ) {
12542 if ( s4.compareTo( s1 ) <= 0 ) {
12545 if ( !s4.getSpeciesId().equals( "b" ) ) {
12548 final Species s5 = new BasicSpecies( " C " );
12549 if ( !s5.getSpeciesId().equals( "C" ) ) {
12552 if ( s5.equals( s1 ) ) {
12556 catch ( final Exception e ) {
12557 e.printStackTrace( System.out );
12563 private static boolean testSplit() {
12565 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12566 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12567 //Archaeopteryx.createApplication( p0 );
12568 final Set<PhylogenyNode> ex = new HashSet<>();
12569 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12570 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12571 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12572 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12573 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12574 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12575 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12576 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12577 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12578 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12579 // System.out.println( s0.toString() );
12581 Set<PhylogenyNode> query_nodes = new HashSet<>();
12582 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12583 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12584 if ( s0.match( query_nodes ) ) {
12587 query_nodes = new HashSet<>();
12588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12589 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12590 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12591 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12592 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12593 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12595 if ( !s0.match( query_nodes ) ) {
12599 query_nodes = new HashSet<>();
12600 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12601 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12603 if ( !s0.match( query_nodes ) ) {
12607 query_nodes = new HashSet<>();
12608 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12609 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12612 if ( !s0.match( query_nodes ) ) {
12616 query_nodes = new HashSet<>();
12617 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12618 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12621 if ( !s0.match( query_nodes ) ) {
12625 query_nodes = new HashSet<>();
12626 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12627 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12629 if ( !s0.match( query_nodes ) ) {
12632 query_nodes = new HashSet<>();
12633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12635 if ( !s0.match( query_nodes ) ) {
12638 query_nodes = new HashSet<>();
12639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12644 if ( !s0.match( query_nodes ) ) {
12647 query_nodes = new HashSet<>();
12648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12651 if ( !s0.match( query_nodes ) ) {
12654 query_nodes = new HashSet<>();
12655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12659 if ( !s0.match( query_nodes ) ) {
12662 query_nodes = new HashSet<>();
12663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12665 if ( s0.match( query_nodes ) ) {
12668 query_nodes = new HashSet<>();
12669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12670 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12673 if ( s0.match( query_nodes ) ) {
12676 query_nodes = new HashSet<>();
12677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12682 if ( s0.match( query_nodes ) ) {
12685 query_nodes = new HashSet<>();
12686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12689 if ( s0.match( query_nodes ) ) {
12692 query_nodes = new HashSet<>();
12693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12695 if ( s0.match( query_nodes ) ) {
12698 query_nodes = new HashSet<>();
12699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12701 if ( s0.match( query_nodes ) ) {
12704 query_nodes = new HashSet<>();
12705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12707 if ( s0.match( query_nodes ) ) {
12710 query_nodes = new HashSet<>();
12711 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12712 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12713 if ( s0.match( query_nodes ) ) {
12716 query_nodes = new HashSet<>();
12717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12719 if ( s0.match( query_nodes ) ) {
12722 query_nodes = new HashSet<>();
12723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12725 if ( s0.match( query_nodes ) ) {
12728 query_nodes = new HashSet<>();
12729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12732 if ( s0.match( query_nodes ) ) {
12735 query_nodes = new HashSet<>();
12736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12739 if ( s0.match( query_nodes ) ) {
12742 query_nodes = new HashSet<>();
12743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12746 if ( s0.match( query_nodes ) ) {
12749 query_nodes = new HashSet<>();
12750 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12754 if ( s0.match( query_nodes ) ) {
12758 // query_nodes = new HashSet<PhylogenyNode>();
12759 // query_nodes.add( new PhylogenyNode( "X" ) );
12760 // query_nodes.add( new PhylogenyNode( "Y" ) );
12761 // query_nodes.add( new PhylogenyNode( "A" ) );
12762 // query_nodes.add( new PhylogenyNode( "B" ) );
12763 // query_nodes.add( new PhylogenyNode( "C" ) );
12764 // query_nodes.add( new PhylogenyNode( "D" ) );
12765 // query_nodes.add( new PhylogenyNode( "E" ) );
12766 // query_nodes.add( new PhylogenyNode( "F" ) );
12767 // query_nodes.add( new PhylogenyNode( "G" ) );
12768 // if ( !s0.match( query_nodes ) ) {
12771 // query_nodes = new HashSet<PhylogenyNode>();
12772 // query_nodes.add( new PhylogenyNode( "X" ) );
12773 // query_nodes.add( new PhylogenyNode( "Y" ) );
12774 // query_nodes.add( new PhylogenyNode( "A" ) );
12775 // query_nodes.add( new PhylogenyNode( "B" ) );
12776 // query_nodes.add( new PhylogenyNode( "C" ) );
12777 // if ( !s0.match( query_nodes ) ) {
12781 // query_nodes = new HashSet<PhylogenyNode>();
12782 // query_nodes.add( new PhylogenyNode( "X" ) );
12783 // query_nodes.add( new PhylogenyNode( "Y" ) );
12784 // query_nodes.add( new PhylogenyNode( "D" ) );
12785 // query_nodes.add( new PhylogenyNode( "E" ) );
12786 // query_nodes.add( new PhylogenyNode( "F" ) );
12787 // query_nodes.add( new PhylogenyNode( "G" ) );
12788 // if ( !s0.match( query_nodes ) ) {
12792 // query_nodes = new HashSet<PhylogenyNode>();
12793 // query_nodes.add( new PhylogenyNode( "X" ) );
12794 // query_nodes.add( new PhylogenyNode( "Y" ) );
12795 // query_nodes.add( new PhylogenyNode( "A" ) );
12796 // query_nodes.add( new PhylogenyNode( "B" ) );
12797 // query_nodes.add( new PhylogenyNode( "C" ) );
12798 // query_nodes.add( new PhylogenyNode( "D" ) );
12799 // if ( !s0.match( query_nodes ) ) {
12803 // query_nodes = new HashSet<PhylogenyNode>();
12804 // query_nodes.add( new PhylogenyNode( "X" ) );
12805 // query_nodes.add( new PhylogenyNode( "Y" ) );
12806 // query_nodes.add( new PhylogenyNode( "E" ) );
12807 // query_nodes.add( new PhylogenyNode( "F" ) );
12808 // query_nodes.add( new PhylogenyNode( "G" ) );
12809 // if ( !s0.match( query_nodes ) ) {
12813 // query_nodes = new HashSet<PhylogenyNode>();
12814 // query_nodes.add( new PhylogenyNode( "X" ) );
12815 // query_nodes.add( new PhylogenyNode( "Y" ) );
12816 // query_nodes.add( new PhylogenyNode( "F" ) );
12817 // query_nodes.add( new PhylogenyNode( "G" ) );
12818 // if ( !s0.match( query_nodes ) ) {
12822 query_nodes = new HashSet<>();
12823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12824 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12825 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12827 if ( s0.match( query_nodes ) ) {
12831 query_nodes = new HashSet<>();
12832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12836 if ( s0.match( query_nodes ) ) {
12839 ///////////////////////////
12841 query_nodes = new HashSet<>();
12842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12843 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12844 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12845 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12846 if ( s0.match( query_nodes ) ) {
12850 query_nodes = new HashSet<>();
12851 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12852 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12853 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12855 if ( s0.match( query_nodes ) ) {
12859 query_nodes = new HashSet<>();
12860 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12864 if ( s0.match( query_nodes ) ) {
12868 query_nodes = new HashSet<>();
12869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12873 if ( s0.match( query_nodes ) ) {
12877 query_nodes = new HashSet<>();
12878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12880 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12882 if ( s0.match( query_nodes ) ) {
12886 query_nodes = new HashSet<>();
12887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12888 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12890 if ( s0.match( query_nodes ) ) {
12894 query_nodes = new HashSet<>();
12895 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12896 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12900 if ( s0.match( query_nodes ) ) {
12904 query_nodes = new HashSet<>();
12905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12910 if ( s0.match( query_nodes ) ) {
12914 query_nodes = new HashSet<>();
12915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12917 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12920 if ( s0.match( query_nodes ) ) {
12924 query_nodes = new HashSet<>();
12925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12926 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12927 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12931 if ( s0.match( query_nodes ) ) {
12935 catch ( final Exception e ) {
12936 e.printStackTrace();
12942 private static boolean testSplitStrict() {
12944 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12945 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12946 final Set<PhylogenyNode> ex = new HashSet<>();
12947 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12948 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12949 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12950 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12951 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12952 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12953 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12954 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12955 Set<PhylogenyNode> query_nodes = new HashSet<>();
12956 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12958 if ( s0.match( query_nodes ) ) {
12961 query_nodes = new HashSet<>();
12962 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12963 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12964 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12969 if ( !s0.match( query_nodes ) ) {
12973 query_nodes = new HashSet<>();
12974 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12975 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12977 if ( !s0.match( query_nodes ) ) {
12981 query_nodes = new HashSet<>();
12982 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12983 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12984 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12986 if ( !s0.match( query_nodes ) ) {
12990 query_nodes = new HashSet<>();
12991 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12992 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12993 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12995 if ( !s0.match( query_nodes ) ) {
12999 query_nodes = new HashSet<>();
13000 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13001 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13002 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13003 if ( !s0.match( query_nodes ) ) {
13007 query_nodes = new HashSet<>();
13008 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13009 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13010 if ( !s0.match( query_nodes ) ) {
13014 query_nodes = new HashSet<>();
13015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13020 if ( !s0.match( query_nodes ) ) {
13024 query_nodes = new HashSet<>();
13025 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13026 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13027 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13028 if ( !s0.match( query_nodes ) ) {
13032 query_nodes = new HashSet<>();
13033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13034 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13035 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13037 if ( !s0.match( query_nodes ) ) {
13041 query_nodes = new HashSet<>();
13042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13044 if ( s0.match( query_nodes ) ) {
13048 query_nodes = new HashSet<>();
13049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13053 if ( s0.match( query_nodes ) ) {
13057 query_nodes = new HashSet<>();
13058 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13063 if ( s0.match( query_nodes ) ) {
13067 query_nodes = new HashSet<>();
13068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13071 if ( s0.match( query_nodes ) ) {
13075 query_nodes = new HashSet<>();
13076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13077 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13078 if ( s0.match( query_nodes ) ) {
13082 query_nodes = new HashSet<>();
13083 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13085 if ( s0.match( query_nodes ) ) {
13089 query_nodes = new HashSet<>();
13090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13091 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
13092 if ( s0.match( query_nodes ) ) {
13096 query_nodes = new HashSet<>();
13097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13099 if ( s0.match( query_nodes ) ) {
13103 query_nodes = new HashSet<>();
13104 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13106 if ( s0.match( query_nodes ) ) {
13110 query_nodes = new HashSet<>();
13111 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13112 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13113 if ( s0.match( query_nodes ) ) {
13117 query_nodes = new HashSet<>();
13118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13119 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
13120 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13121 if ( s0.match( query_nodes ) ) {
13125 query_nodes = new HashSet<>();
13126 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13127 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
13128 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13129 if ( s0.match( query_nodes ) ) {
13133 query_nodes = new HashSet<>();
13134 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13135 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13136 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13137 if ( s0.match( query_nodes ) ) {
13141 query_nodes = new HashSet<>();
13142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
13143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
13144 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
13145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
13146 if ( s0.match( query_nodes ) ) {
13150 catch ( final Exception e ) {
13151 e.printStackTrace();
13157 private static boolean testSubtreeDeletion() {
13159 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13160 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
13161 t1.deleteSubtree( t1.getNode( "A" ), false );
13162 if ( t1.getNumberOfExternalNodes() != 5 ) {
13165 t1.toNewHampshireX();
13166 t1.deleteSubtree( t1.getNode( "E" ), false );
13167 if ( t1.getNumberOfExternalNodes() != 4 ) {
13170 t1.toNewHampshireX();
13171 t1.deleteSubtree( t1.getNode( "F" ), false );
13172 if ( t1.getNumberOfExternalNodes() != 3 ) {
13175 t1.toNewHampshireX();
13176 t1.deleteSubtree( t1.getNode( "D" ), false );
13177 t1.toNewHampshireX();
13178 if ( t1.getNumberOfExternalNodes() != 3 ) {
13181 t1.deleteSubtree( t1.getNode( "def" ), false );
13182 t1.toNewHampshireX();
13183 if ( t1.getNumberOfExternalNodes() != 2 ) {
13186 t1.deleteSubtree( t1.getNode( "B" ), false );
13187 t1.toNewHampshireX();
13188 if ( t1.getNumberOfExternalNodes() != 1 ) {
13191 t1.deleteSubtree( t1.getNode( "C" ), false );
13192 t1.toNewHampshireX();
13193 if ( t1.getNumberOfExternalNodes() != 1 ) {
13196 t1.deleteSubtree( t1.getNode( "abc" ), false );
13197 t1.toNewHampshireX();
13198 if ( t1.getNumberOfExternalNodes() != 1 ) {
13201 t1.deleteSubtree( t1.getNode( "r" ), false );
13202 if ( t1.getNumberOfExternalNodes() != 0 ) {
13205 if ( !t1.isEmpty() ) {
13208 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
13209 t2.deleteSubtree( t2.getNode( "A" ), false );
13210 t2.toNewHampshireX();
13211 if ( t2.getNumberOfExternalNodes() != 5 ) {
13214 t2.deleteSubtree( t2.getNode( "abc" ), false );
13215 t2.toNewHampshireX();
13216 if ( t2.getNumberOfExternalNodes() != 3 ) {
13219 t2.deleteSubtree( t2.getNode( "def" ), false );
13220 t2.toNewHampshireX();
13221 if ( t2.getNumberOfExternalNodes() != 1 ) {
13225 catch ( final Exception e ) {
13226 e.printStackTrace( System.out );
13232 private static boolean testSupportCount() {
13234 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13235 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
13236 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
13237 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
13238 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))" + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
13240 SupportCount.count( t0_1, phylogenies_1, true, false );
13241 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
13242 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
13243 + "(((((A,B),C),D),E),((F,G),X))" + "(((((A,Y),B),C),D),((F,G),E))" + "(((((A,B),C),D),E),(F,G))"
13244 + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G),Z)"
13245 + "(((((A,B),C),D),E),(F,G))" + "((((((A,B),C),D),E),F),G)" + "(((((X,Y),F,G),E),((A,B),C)),D)",
13247 SupportCount.count( t0_2, phylogenies_2, true, false );
13248 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
13249 while ( it.hasNext() ) {
13250 final PhylogenyNode n = it.next();
13251 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
13255 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
13256 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
13257 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
13258 SupportCount.count( t0_3, phylogenies_3, true, false );
13259 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
13260 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
13263 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
13266 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
13269 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
13272 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
13275 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
13278 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
13281 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
13284 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
13287 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
13290 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13291 final Phylogeny[] phylogenies_4 = factory
13292 .create( "((((((A,X),C),B),D),E),F) " + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
13293 SupportCount.count( t0_4, phylogenies_4, true, false );
13294 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
13295 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
13298 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
13301 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
13304 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
13307 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
13310 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
13313 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
13316 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
13319 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
13322 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
13325 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13326 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13327 double d = SupportCount.compare( b1, a, true, true, true );
13328 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
13331 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13332 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13333 d = SupportCount.compare( b2, a, true, true, true );
13334 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
13337 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13338 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
13339 d = SupportCount.compare( b3, a, true, true, true );
13340 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
13343 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
13344 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
13345 d = SupportCount.compare( b4, a, true, true, false );
13346 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
13350 catch ( final Exception e ) {
13351 e.printStackTrace( System.out );
13357 private static boolean testSupportTransfer() {
13359 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13360 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)",
13361 new NHXParser() )[ 0 ];
13362 final Phylogeny p2 = factory.create(
13363 "(((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)",
13364 new NHXParser() )[ 0 ];
13365 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
13368 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
13371 support_transfer.moveBranchLengthsToBootstrap( p1 );
13372 support_transfer.transferSupportValues( p1, p2 );
13373 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
13376 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
13379 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
13382 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
13385 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
13388 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13391 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13394 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13398 catch ( final Exception e ) {
13399 e.printStackTrace( System.out );
13405 private static boolean testTaxonomyExtraction() {
13407 final PhylogenyNode n0 = PhylogenyNode
13408 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13409 if ( n0.getNodeData().isHasTaxonomy() ) {
13412 final PhylogenyNode n1 = PhylogenyNode
13413 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13414 if ( n1.getNodeData().isHasTaxonomy() ) {
13415 System.out.println( n1.toString() );
13418 final PhylogenyNode n2x = PhylogenyNode
13419 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13420 if ( n2x.getNodeData().isHasTaxonomy() ) {
13423 final PhylogenyNode n3 = PhylogenyNode
13424 .createInstanceFromNhxString( "BLAGG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13425 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13426 System.out.println( n3.toString() );
13429 final PhylogenyNode n4 = PhylogenyNode
13430 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13431 if ( n4.getNodeData().isHasTaxonomy() ) {
13432 System.out.println( n4.toString() );
13435 final PhylogenyNode n5 = PhylogenyNode
13436 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13437 if ( n5.getNodeData().isHasTaxonomy() ) {
13438 System.out.println( n5.toString() );
13441 final PhylogenyNode n6 = PhylogenyNode
13442 .createInstanceFromNhxString( "BLAGG-12345-blag",
13443 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13444 if ( n6.getNodeData().isHasTaxonomy() ) {
13445 System.out.println( n6.toString() );
13448 final PhylogenyNode n7 = PhylogenyNode
13449 .createInstanceFromNhxString( "BL-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13450 if ( n7.getNodeData().isHasTaxonomy() ) {
13451 System.out.println( n7.toString() );
13454 final PhylogenyNode n8 = PhylogenyNode
13455 .createInstanceFromNhxString( "BLAGG_12345-blag",
13456 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13457 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13458 System.out.println( n8.toString() );
13461 final PhylogenyNode n9 = PhylogenyNode
13462 .createInstanceFromNhxString( "BLAGG_12345/blag",
13463 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13464 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13465 System.out.println( n9.toString() );
13468 final PhylogenyNode n10x = PhylogenyNode
13469 .createInstanceFromNhxString( "BLAG!_12X45-blag",
13470 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13471 if ( n10x.getNodeData().isHasTaxonomy() ) {
13472 System.out.println( n10x.toString() );
13475 final PhylogenyNode n10xx = PhylogenyNode
13476 .createInstanceFromNhxString( "BLAG!_1YX45-blag",
13477 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13478 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13479 System.out.println( n10xx.toString() );
13482 final PhylogenyNode n10 = PhylogenyNode
13483 .createInstanceFromNhxString( "BLAGG_9YX45-blag",
13484 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13485 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13486 System.out.println( n10.toString() );
13489 final PhylogenyNode n10v = PhylogenyNode
13490 .createInstanceFromNhxString( "BLAGG_BPM1-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13491 if ( !n10v.getNodeData().getTaxonomy().getTaxonomyCode().equals( "BPM1" ) ) {
13492 System.out.println( n10v.toString() );
13495 final PhylogenyNode n10v2 = PhylogenyNode
13496 .createInstanceFromNhxString( "BLAGG_ABV-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13497 if ( !n10v2.getNodeData().getTaxonomy().getTaxonomyCode().equals( "ABV" ) ) {
13498 System.out.println( n10v2.toString() );
13501 final PhylogenyNode n11 = PhylogenyNode
13502 .createInstanceFromNhxString( "BLAG@_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13503 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13504 System.out.println( n11.toString() );
13507 final PhylogenyNode n12 = PhylogenyNode
13508 .createInstanceFromNhxString( "BLA_G_Mus_musculus_musculus",
13509 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13510 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13511 System.out.println( n12.toString() );
13514 final PhylogenyNode n13 = PhylogenyNode
13515 .createInstanceFromNhxString( "BLAaG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13516 if ( n13.getNodeData().isHasTaxonomy() ) {
13517 System.out.println( n13.toString() );
13520 final PhylogenyNode n14 = PhylogenyNode
13521 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13522 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13523 System.out.println( n14.toString() );
13526 final PhylogenyNode n15 = PhylogenyNode
13527 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13528 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13529 System.out.println( n15.toString() );
13532 final PhylogenyNode n16 = PhylogenyNode
13533 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13534 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13535 System.out.println( n16.toString() );
13538 final PhylogenyNode n17 = PhylogenyNode
13539 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13540 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13541 System.out.println( n17.toString() );
13544 final PhylogenyNode n18 = PhylogenyNode
13545 .createInstanceFromNhxString( "Mus_musculus_musculus_392",
13546 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13547 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13548 System.out.println( n18.toString() );
13551 final PhylogenyNode n19 = PhylogenyNode
13552 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13553 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13554 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13555 System.out.println( n19.toString() );
13558 final PhylogenyNode n20 = PhylogenyNode
13559 .createInstanceFromNhxString( "Mus musculus musculus 392",
13560 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13561 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13562 System.out.println( n20.toString() );
13565 final PhylogenyNode n21 = PhylogenyNode
13566 .createInstanceFromNhxString( "Mus musculus musculus K392",
13567 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13568 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13569 System.out.println( n21.toString() );
13572 final PhylogenyNode n23 = PhylogenyNode
13573 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13574 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13575 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13576 System.out.println( n23.toString() );
13579 final PhylogenyNode n24 = PhylogenyNode
13580 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13581 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13582 System.out.println( n24.toString() );
13586 final PhylogenyNode n25 = PhylogenyNode
13587 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13588 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13589 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13590 System.out.println( n25.toString() );
13593 final PhylogenyNode n26 = PhylogenyNode
13594 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13595 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13596 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13597 System.out.println( n26.toString() );
13600 final PhylogenyNode n27 = PhylogenyNode
13601 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13602 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13603 System.out.println( n27.toString() );
13607 catch ( final Exception e ) {
13608 e.printStackTrace( System.out );
13614 private static boolean testTreeCopy() {
13616 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13617 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13618 final Phylogeny t1 = t0.copy();
13619 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13622 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13625 t0.deleteSubtree( t0.getNode( "c" ), true );
13626 t0.deleteSubtree( t0.getNode( "a" ), true );
13627 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13628 t0.getNode( "b" ).setName( "Bee" );
13629 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13632 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13635 t0.deleteSubtree( t0.getNode( "e" ), true );
13636 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13637 t0.deleteSubtree( t0.getNode( "d" ), true );
13638 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13642 catch ( final Exception e ) {
13643 e.printStackTrace();
13649 private static boolean testTreeMethods() {
13651 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13652 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13653 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13654 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13655 System.out.println( t0.toNewHampshireX() );
13658 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13659 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13660 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13663 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13666 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13670 catch ( final Exception e ) {
13671 e.printStackTrace( System.out );
13677 private static boolean testPhylogenyMethods() {
13679 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13680 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)r", new NHXParser() )[ 0 ];
13681 if ( PhylogenyMethods.calculateLevel( t0.getNode( "A" ) ) != 0 ) {
13684 if ( PhylogenyMethods.calculateLevel( t0.getNode( "B" ) ) != 0 ) {
13687 if ( PhylogenyMethods.calculateLevel( t0.getNode( "ab" ) ) != 1 ) {
13690 if ( PhylogenyMethods.calculateLevel( t0.getNode( "C" ) ) != 0 ) {
13693 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abc" ) ) != 2 ) {
13696 if ( PhylogenyMethods.calculateLevel( t0.getNode( "D" ) ) != 0 ) {
13699 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abcd" ) ) != 3 ) {
13702 if ( PhylogenyMethods.calculateLevel( t0.getNode( "E" ) ) != 0 ) {
13705 if ( PhylogenyMethods.calculateLevel( t0.getNode( "r" ) ) != 4 ) {
13708 final Phylogeny t1 = factory.create( "((((A,B)ab,C)abc,D)abcd,E,((((((X)1)2)3)4)5)6)r",
13709 new NHXParser() )[ 0 ];
13710 if ( PhylogenyMethods.calculateLevel( t1.getNode( "r" ) ) != 7 ) {
13713 if ( PhylogenyMethods.calculateLevel( t1.getNode( "X" ) ) != 0 ) {
13716 if ( PhylogenyMethods.calculateLevel( t1.getNode( "6" ) ) != 6 ) {
13719 if ( PhylogenyMethods.calculateLevel( t1.getNode( "5" ) ) != 5 ) {
13722 if ( PhylogenyMethods.calculateLevel( t1.getNode( "4" ) ) != 4 ) {
13725 if ( PhylogenyMethods.calculateLevel( t1.getNode( "3" ) ) != 3 ) {
13728 if ( PhylogenyMethods.calculateLevel( t1.getNode( "2" ) ) != 2 ) {
13731 if ( PhylogenyMethods.calculateLevel( t1.getNode( "1" ) ) != 1 ) {
13734 if ( PhylogenyMethods.calculateLevel( t1.getNode( "abcd" ) ) != 3 ) {
13738 catch ( final Exception e ) {
13739 e.printStackTrace( System.out );
13745 private static boolean testUniprotEntryRetrieval() {
13747 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13748 if ( !entry.getAccession().equals( "P12345" ) ) {
13751 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13754 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13757 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13760 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13763 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13766 if ( entry.getMolecularSequence() == null ) {
13769 if ( !entry.getMolecularSequence().getMolecularSequenceAsString()
13770 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13771 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13772 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13773 System.out.println( "expected something else." );
13777 catch ( final IOException e ) {
13778 System.out.println();
13779 System.out.println( "the following might be due to absence internet connection:" );
13780 e.printStackTrace( System.out );
13783 catch ( final NullPointerException f ) {
13784 f.printStackTrace( System.out );
13787 catch ( final Exception e ) {
13793 private static boolean testUniprotTaxonomySearch() {
13795 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13797 if ( results.size() != 1 ) {
13800 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13803 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13806 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13809 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13812 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13816 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13817 if ( results.size() != 1 ) {
13820 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13823 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13826 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13829 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13832 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13836 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13837 if ( results.size() != 1 ) {
13840 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13843 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13846 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13849 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13852 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13856 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13857 if ( results.size() != 1 ) {
13860 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13863 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13866 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13869 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13872 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13875 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13878 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13881 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13882 .equals( "Nematostella vectensis" ) ) {
13883 System.out.println( results.get( 0 ).getLineage() );
13888 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13889 if ( results.size() != 1 ) {
13892 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13895 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13898 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13901 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13904 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13907 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13908 .equals( "Xenopus tropicalis" ) ) {
13909 System.out.println( results.get( 0 ).getLineage() );
13914 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13915 if ( results.size() != 1 ) {
13918 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13921 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13924 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13927 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13930 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13933 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13934 .equals( "Xenopus tropicalis" ) ) {
13935 System.out.println( results.get( 0 ).getLineage() );
13940 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13941 if ( results.size() != 1 ) {
13944 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13947 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13950 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13953 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13956 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13959 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13960 .equals( "Xenopus tropicalis" ) ) {
13961 System.out.println( results.get( 0 ).getLineage() );
13965 catch ( final IOException e ) {
13966 System.out.println();
13967 System.out.println( "the following might be due to absence internet connection:" );
13968 e.printStackTrace( System.out );
13971 catch ( final Exception e ) {