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 javax.net.ssl.HttpsURLConnection;
44 import javax.net.ssl.SSLContext;
46 import org.forester.application.support_transfer;
47 import org.forester.archaeopteryx.AptxUtil;
48 import org.forester.archaeopteryx.TreePanelUtil;
49 import org.forester.archaeopteryx.webservices.WebserviceUtil;
50 import org.forester.development.DevelopmentTools;
51 import org.forester.evoinference.TestPhylogenyReconstruction;
52 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
53 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
54 import org.forester.go.TestGo;
55 import org.forester.io.parsers.FastaParser;
56 import org.forester.io.parsers.GeneralMsaParser;
57 import org.forester.io.parsers.HmmscanPerDomainTableParser;
58 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
59 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
60 import org.forester.io.parsers.nexus.NexusCharactersParser;
61 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
62 import org.forester.io.parsers.nhx.NHXParser;
63 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
64 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
65 import org.forester.io.parsers.tol.TolParser;
66 import org.forester.io.parsers.util.ParserUtils;
67 import org.forester.io.writers.PhylogenyWriter;
68 import org.forester.io.writers.SequenceWriter;
69 import org.forester.msa.BasicMsa;
70 import org.forester.msa.DeleteableMsa;
71 import org.forester.msa.Mafft;
72 import org.forester.msa.Msa;
73 import org.forester.msa.Msa.MSA_FORMAT;
74 import org.forester.msa.MsaInferrer;
75 import org.forester.msa.MsaMethods;
76 import org.forester.pccx.TestPccx;
77 import org.forester.phylogeny.Phylogeny;
78 import org.forester.phylogeny.PhylogenyBranch;
79 import org.forester.phylogeny.PhylogenyMethods;
80 import org.forester.phylogeny.PhylogenyNode;
81 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
82 import org.forester.phylogeny.data.Accession;
83 import org.forester.phylogeny.data.Accession.Source;
84 import org.forester.phylogeny.data.BinaryCharacters;
85 import org.forester.phylogeny.data.BranchWidth;
86 import org.forester.phylogeny.data.Confidence;
87 import org.forester.phylogeny.data.Distribution;
88 import org.forester.phylogeny.data.DomainArchitecture;
89 import org.forester.phylogeny.data.Event;
90 import org.forester.phylogeny.data.Identifier;
91 import org.forester.phylogeny.data.PhylogenyData;
92 import org.forester.phylogeny.data.PhylogenyDataUtil;
93 import org.forester.phylogeny.data.Polygon;
94 import org.forester.phylogeny.data.PropertiesMap;
95 import org.forester.phylogeny.data.Property;
96 import org.forester.phylogeny.data.Property.AppliesTo;
97 import org.forester.phylogeny.data.ProteinDomain;
98 import org.forester.phylogeny.data.Taxonomy;
99 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
100 import org.forester.phylogeny.factories.PhylogenyFactory;
101 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
102 import org.forester.protein.BasicDomain;
103 import org.forester.protein.BasicProtein;
104 import org.forester.protein.Domain;
105 import org.forester.protein.Protein;
106 import org.forester.protein.ProteinId;
107 import org.forester.rio.TestRIO;
108 import org.forester.sdi.SDI;
109 import org.forester.sdi.SDIR;
110 import org.forester.sdi.TestGSDI;
111 import org.forester.sequence.BasicSequence;
112 import org.forester.sequence.MolecularSequence;
113 import org.forester.species.BasicSpecies;
114 import org.forester.species.Species;
115 import org.forester.surfacing.TestSurfacing;
116 import org.forester.tools.ConfidenceAssessor;
117 import org.forester.tools.SupportCount;
118 import org.forester.tools.TreeSplitMatrix;
119 import org.forester.util.AsciiHistogram;
120 import org.forester.util.BasicDescriptiveStatistics;
121 import org.forester.util.BasicTable;
122 import org.forester.util.BasicTableParser;
123 import org.forester.util.DescriptiveStatistics;
124 import org.forester.util.ForesterConstants;
125 import org.forester.util.ForesterUtil;
126 import org.forester.util.GeneralTable;
127 import org.forester.util.SequenceAccessionTools;
128 import org.forester.ws.seqdb.SequenceDatabaseEntry;
129 import org.forester.ws.seqdb.SequenceDbWsTools;
130 import org.forester.ws.seqdb.UniProtTaxonomy;
133 @SuppressWarnings( "unused")
134 public final class Test {
136 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
137 + ForesterUtil.getFileSeparator() + "resources"
138 + ForesterUtil.getFileSeparator();
139 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
140 + ForesterUtil.getFileSeparator() + "test_data"
141 + ForesterUtil.getFileSeparator();
142 private final static boolean PERFORM_DB_TESTS = true;
143 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
144 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
145 + ForesterConstants.PHYLO_XML_VERSION + "/"
146 + ForesterConstants.PHYLO_XML_XSD;
147 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
148 + ForesterConstants.PHYLO_XML_VERSION + "/"
149 + ForesterConstants.PHYLO_XML_XSD;
150 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
151 private final static double ZERO_DIFF = 1.0E-9;
153 private static boolean isEqual( final double a, final double b ) {
154 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
157 public static void main( final String[] args ) {
158 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
159 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
161 Locale.setDefault( Locale.US );
162 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
165 System.out.print( "[Test if directory with files for testing exists/is readable: " );
166 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
167 System.out.println( "OK.]" );
170 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
171 System.out.println( "Testing aborted." );
174 System.out.print( "[Test if resources directory exists/is readable: " );
175 if ( testDir( PATH_TO_RESOURCES ) ) {
176 System.out.println( "OK.]" );
179 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
180 System.out.println( "Testing aborted." );
183 final long start_time = new Date().getTime();
185 System.out.print( "Basic node methods: " );
186 if ( Test.testBasicNodeMethods() ) {
187 System.out.println( "OK." );
191 System.out.println( "failed." );
194 System.out.print( "Protein id: " );
195 if ( !testProteinId() ) {
196 System.out.println( "failed." );
202 System.out.println( "OK." );
203 System.out.print( "Species: " );
204 if ( !testSpecies() ) {
205 System.out.println( "failed." );
211 System.out.println( "OK." );
212 System.out.print( "Basic domain: " );
213 if ( !testBasicDomain() ) {
214 System.out.println( "failed." );
220 System.out.println( "OK." );
221 System.out.print( "Basic protein: " );
222 if ( !testBasicProtein() ) {
223 System.out.println( "failed." );
229 System.out.println( "OK." );
230 System.out.print( "Sequence writer: " );
231 if ( testSequenceWriter() ) {
232 System.out.println( "OK." );
236 System.out.println( "failed." );
239 System.out.print( "Sequence id parsing: " );
240 if ( testSequenceIdParsing() ) {
241 System.out.println( "OK." );
245 System.out.println( "failed." );
248 System.out.print( "UniProtKB id extraction: " );
249 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
250 System.out.println( "OK." );
254 System.out.println( "failed." );
257 System.out.print( "Sequence DB tools 1: " );
258 if ( testSequenceDbWsTools1() ) {
259 System.out.println( "OK." );
263 System.out.println( "failed." );
266 System.out.print( "Hmmscan output parser: " );
267 if ( testHmmscanOutputParser() ) {
268 System.out.println( "OK." );
272 System.out.println( "failed." );
275 System.out.print( "Overlap removal: " );
276 if ( !org.forester.test.Test.testOverlapRemoval() ) {
277 System.out.println( "failed." );
283 System.out.println( "OK." );
284 System.out.print( "Engulfing overlap removal: " );
285 if ( !Test.testEngulfingOverlapRemoval() ) {
286 System.out.println( "failed." );
292 System.out.println( "OK." );
293 System.out.print( "Taxonomy data extraction: " );
294 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
295 System.out.println( "OK." );
299 System.out.println( "failed." );
302 System.out.print( "Taxonomy code extraction: " );
303 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
304 System.out.println( "OK." );
308 System.out.println( "failed." );
311 System.out.print( "SN extraction: " );
312 if ( Test.testExtractSNFromNodeName() ) {
313 System.out.println( "OK." );
317 System.out.println( "failed." );
320 System.out.print( "Taxonomy extraction (general): " );
321 if ( Test.testTaxonomyExtraction() ) {
322 System.out.println( "OK." );
326 System.out.println( "failed." );
329 System.out.print( "Uri for Aptx web sequence accession: " );
330 if ( Test.testCreateUriForSeqWeb() ) {
331 System.out.println( "OK." );
335 System.out.println( "failed." );
338 System.out.print( "Basic node construction and parsing of NHX (node level): " );
339 if ( Test.testNHXNodeParsing() ) {
340 System.out.println( "OK." );
344 System.out.println( "failed." );
347 System.out.print( "NHX parsing iterating: " );
348 if ( Test.testNHParsingIter() ) {
349 System.out.println( "OK." );
353 System.out.println( "failed." );
356 System.out.print( "NH parsing: " );
357 if ( Test.testNHParsing() ) {
358 System.out.println( "OK." );
362 System.out.println( "failed." );
365 System.out.print( "Conversion to NHX (node level): " );
366 if ( Test.testNHXconversion() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "NHX parsing: " );
375 if ( Test.testNHXParsing() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "NHX parsing with quotes: " );
384 if ( Test.testNHXParsingQuotes() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing (MrBayes): " );
393 if ( Test.testNHXParsingMB() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "Nexus characters parsing: " );
402 if ( Test.testNexusCharactersParsing() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "Nexus tree parsing iterating: " );
411 if ( Test.testNexusTreeParsingIterating() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus tree parsing: " );
420 if ( Test.testNexusTreeParsing() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing (translating): " );
429 if ( Test.testNexusTreeParsingTranslating() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus matrix parsing: " );
438 if ( Test.testNexusMatrixParsing() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Basic phyloXML parsing: " );
447 if ( Test.testBasicPhyloXMLparsing() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Basic phyloXML parsing (validating against schema): " );
456 if ( testBasicPhyloXMLparsingValidating() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
465 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "phyloXML Distribution Element: " );
474 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "Tol XML parsing: " );
483 if ( Test.testBasicTolXMLparsing() ) {
484 System.out.println( "OK." );
488 System.out.println( "failed." );
491 System.out.print( "Copying of node data: " );
492 if ( Test.testCopyOfNodeData() ) {
493 System.out.println( "OK." );
497 System.out.println( "failed." );
500 System.out.print( "Tree copy: " );
501 if ( Test.testTreeCopy() ) {
502 System.out.println( "OK." );
506 System.out.println( "failed." );
509 System.out.print( "Basic tree methods: " );
510 if ( Test.testBasicTreeMethods() ) {
511 System.out.println( "OK." );
515 System.out.println( "failed." );
518 System.out.print( "Tree methods: " );
519 if ( Test.testTreeMethods() ) {
520 System.out.println( "OK." );
524 System.out.println( "failed." );
527 System.out.print( "Postorder Iterator: " );
528 if ( Test.testPostOrderIterator() ) {
529 System.out.println( "OK." );
533 System.out.println( "failed." );
536 System.out.print( "Preorder Iterator: " );
537 if ( Test.testPreOrderIterator() ) {
538 System.out.println( "OK." );
542 System.out.println( "failed." );
545 System.out.print( "Levelorder Iterator: " );
546 if ( Test.testLevelOrderIterator() ) {
547 System.out.println( "OK." );
551 System.out.println( "failed." );
554 System.out.print( "Re-id methods: " );
555 if ( Test.testReIdMethods() ) {
556 System.out.println( "OK." );
560 System.out.println( "failed." );
563 System.out.print( "Methods on last external nodes: " );
564 if ( Test.testLastExternalNodeMethods() ) {
565 System.out.println( "OK." );
569 System.out.println( "failed." );
572 System.out.print( "Methods on external nodes: " );
573 if ( Test.testExternalNodeRelatedMethods() ) {
574 System.out.println( "OK." );
578 System.out.println( "failed." );
581 System.out.print( "Deletion of external nodes: " );
582 if ( Test.testDeletionOfExternalNodes() ) {
583 System.out.println( "OK." );
587 System.out.println( "failed." );
590 System.out.print( "Subtree deletion: " );
591 if ( Test.testSubtreeDeletion() ) {
592 System.out.println( "OK." );
596 System.out.println( "failed." );
599 System.out.print( "Phylogeny branch: " );
600 if ( Test.testPhylogenyBranch() ) {
601 System.out.println( "OK." );
605 System.out.println( "failed." );
608 System.out.print( "Rerooting: " );
609 if ( Test.testRerooting() ) {
610 System.out.println( "OK." );
614 System.out.println( "failed." );
617 System.out.print( "Mipoint rooting: " );
618 if ( Test.testMidpointrooting() ) {
619 System.out.println( "OK." );
623 System.out.println( "failed." );
626 System.out.print( "Node removal: " );
627 if ( Test.testNodeRemoval() ) {
628 System.out.println( "OK." );
632 System.out.println( "failed." );
635 System.out.print( "Support count: " );
636 if ( Test.testSupportCount() ) {
637 System.out.println( "OK." );
641 System.out.println( "failed." );
644 System.out.print( "Support transfer: " );
645 if ( Test.testSupportTransfer() ) {
646 System.out.println( "OK." );
650 System.out.println( "failed." );
653 System.out.print( "Finding of LCA: " );
654 if ( Test.testGetLCA() ) {
655 System.out.println( "OK." );
659 System.out.println( "failed." );
662 System.out.print( "Finding of LCA 2: " );
663 if ( Test.testGetLCA2() ) {
664 System.out.println( "OK." );
668 System.out.println( "failed." );
671 System.out.print( "Calculation of distance between nodes: " );
672 if ( Test.testGetDistance() ) {
673 System.out.println( "OK." );
677 System.out.println( "failed." );
680 System.out.print( "Descriptive statistics: " );
681 if ( Test.testDescriptiveStatistics() ) {
682 System.out.println( "OK." );
686 System.out.println( "failed." );
689 System.out.print( "Data objects and methods: " );
690 if ( Test.testDataObjects() ) {
691 System.out.println( "OK." );
695 System.out.println( "failed." );
698 System.out.print( "Properties map: " );
699 if ( Test.testPropertiesMap() ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "SDIse: " );
708 if ( Test.testSDIse() ) {
709 System.out.println( "OK." );
713 System.out.println( "failed." );
716 System.out.print( "SDIunrooted: " );
717 if ( Test.testSDIunrooted() ) {
718 System.out.println( "OK." );
722 System.out.println( "failed." );
725 System.out.print( "GSDI: " );
726 if ( TestGSDI.test() ) {
727 System.out.println( "OK." );
731 System.out.println( "failed." );
734 System.out.print( "RIO: " );
735 if ( TestRIO.test() ) {
736 System.out.println( "OK." );
740 System.out.println( "failed." );
743 System.out.print( "Phylogeny reconstruction:" );
744 System.out.println();
745 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
746 System.out.println( "OK." );
750 System.out.println( "failed." );
753 System.out.print( "Analysis of domain architectures: " );
754 System.out.println();
755 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
756 System.out.println( "OK." );
760 System.out.println( "failed." );
763 System.out.print( "GO: " );
764 System.out.println();
765 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
766 System.out.println( "OK." );
770 System.out.println( "failed." );
773 System.out.print( "Modeling tools: " );
774 if ( TestPccx.test() ) {
775 System.out.println( "OK." );
779 System.out.println( "failed." );
782 System.out.print( "Split Matrix strict: " );
783 if ( Test.testSplitStrict() ) {
784 System.out.println( "OK." );
788 System.out.println( "failed." );
791 System.out.print( "Split Matrix: " );
792 if ( Test.testSplit() ) {
793 System.out.println( "OK." );
797 System.out.println( "failed." );
800 System.out.print( "Confidence Assessor: " );
801 if ( Test.testConfidenceAssessor() ) {
802 System.out.println( "OK." );
806 System.out.println( "failed." );
809 System.out.print( "Basic table: " );
810 if ( Test.testBasicTable() ) {
811 System.out.println( "OK." );
815 System.out.println( "failed." );
818 System.out.print( "General table: " );
819 if ( Test.testGeneralTable() ) {
820 System.out.println( "OK." );
824 System.out.println( "failed." );
827 System.out.print( "Amino acid sequence: " );
828 if ( Test.testAminoAcidSequence() ) {
829 System.out.println( "OK." );
833 System.out.println( "failed." );
836 System.out.print( "General MSA parser: " );
837 if ( Test.testGeneralMsaParser() ) {
838 System.out.println( "OK." );
842 System.out.println( "failed." );
845 System.out.print( "Fasta parser for msa: " );
846 if ( Test.testFastaParser() ) {
847 System.out.println( "OK." );
851 System.out.println( "failed." );
854 System.out.print( "Creation of balanced phylogeny: " );
855 if ( Test.testCreateBalancedPhylogeny() ) {
856 System.out.println( "OK." );
860 System.out.println( "failed." );
863 System.out.print( "Genbank accessor parsing: " );
864 if ( Test.testGenbankAccessorParsing() ) {
865 System.out.println( "OK." );
869 System.out.println( "failed." );
873 final String os = ForesterUtil.OS_NAME.toLowerCase();
874 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
875 path = "/usr/local/bin/mafft";
877 else if ( os.indexOf( "win" ) >= 0 ) {
878 path = "C:\\Program Files\\mafft-win\\mafft.bat";
882 if ( !MsaInferrer.isInstalled( path ) ) {
883 path = "/usr/bin/mafft";
885 if ( !MsaInferrer.isInstalled( path ) ) {
886 path = "/usr/local/bin/mafft";
889 if ( MsaInferrer.isInstalled( path ) ) {
890 System.out.print( "MAFFT (external program): " );
891 if ( Test.testMafft( path ) ) {
892 System.out.println( "OK." );
896 System.out.println( "failed [will not count towards failed tests]" );
899 System.out.print( "Next nodes with collapsed: " );
900 if ( Test.testNextNodeWithCollapsing() ) {
901 System.out.println( "OK." );
905 System.out.println( "failed." );
908 System.out.print( "Simple MSA quality: " );
909 if ( Test.testMsaQualityMethod() ) {
910 System.out.println( "OK." );
914 System.out.println( "failed." );
917 System.out.print( "Deleteable MSA: " );
918 if ( Test.testDeleteableMsa() ) {
919 System.out.println( "OK." );
923 System.out.println( "failed." );
926 System.out.print( "MSA entropy: " );
927 if ( Test.testMsaEntropy() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 if ( PERFORM_DB_TESTS ) {
936 System.out.print( "Uniprot Entry Retrieval: " );
937 if ( Test.testUniprotEntryRetrieval() ) {
938 System.out.println( "OK." );
942 System.out.println( "failed." );
945 System.out.print( "Ebi Entry Retrieval: " );
946 if ( Test.testEbiEntryRetrieval() ) {
947 System.out.println( "OK." );
951 System.out.println( "failed." );
954 System.out.print( "Sequence DB tools 2: " );
955 if ( testSequenceDbWsTools2() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
964 System.out.print( "Uniprot Taxonomy Search: " );
965 if ( Test.testUniprotTaxonomySearch() ) {
966 System.out.println( "OK." );
970 System.out.println( "failed." );
974 if ( PERFORM_WEB_TREE_ACCESS ) {
975 System.out.print( "TreeBase acccess: " );
976 if ( Test.testTreeBaseReading() ) {
977 System.out.println( "OK." );
981 System.out.println( "failed." );
984 System.out.print( "ToL access: " );
985 if ( Test.testToLReading() ) {
986 System.out.println( "OK." );
990 System.out.println( "failed." );
993 System.out.print( "NHX parsing from URL: " );
994 if ( Test.testNHXparsingFromURL() ) {
995 System.out.println( "OK." );
999 System.out.println( "failed." );
1002 System.out.print( "NHX parsing from URL 2: " );
1003 if ( Test.testNHXparsingFromURL2() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1011 System.out.print( "phyloXML parsing from URL: " );
1012 if ( Test.testPhyloXMLparsingFromURL() ) {
1013 System.out.println( "OK." );
1017 System.out.println( "failed." );
1020 System.out.print( "TreeFam access: " );
1021 if ( Test.testTreeFamReading() ) {
1022 System.out.println( "OK." );
1026 System.out.println( "failed." );
1029 System.out.print( "Pfam tree access: " );
1030 if ( Test.testPfamTreeReading() ) {
1031 System.out.println( "OK." );
1035 System.out.println( "failed." );
1039 System.out.println();
1040 final Runtime rt = java.lang.Runtime.getRuntime();
1041 final long free_memory = rt.freeMemory() / 1000000;
1042 final long total_memory = rt.totalMemory() / 1000000;
1043 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1044 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1045 System.out.println();
1046 System.out.println( "Successful tests: " + succeeded );
1047 System.out.println( "Failed tests: " + failed );
1048 System.out.println();
1050 System.out.println( "OK." );
1053 System.out.println( "Not OK." );
1057 private static boolean testEngulfingOverlapRemoval() {
1059 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1060 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1061 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1062 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1063 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1064 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1065 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1066 final List<Boolean> covered = new ArrayList<Boolean>();
1067 covered.add( true ); // 0
1068 covered.add( false ); // 1
1069 covered.add( true ); // 2
1070 covered.add( false ); // 3
1071 covered.add( true ); // 4
1072 covered.add( true ); // 5
1073 covered.add( false ); // 6
1074 covered.add( true ); // 7
1075 covered.add( true ); // 8
1076 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1079 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1082 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1085 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1088 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1091 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1094 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1097 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1098 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1099 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1100 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1101 abc.addProteinDomain( a );
1102 abc.addProteinDomain( b );
1103 abc.addProteinDomain( c );
1104 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1105 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1106 if ( abc.getNumberOfProteinDomains() != 3 ) {
1109 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1112 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1115 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1118 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1121 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1122 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1123 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1124 final Protein def = new BasicProtein( "def", "nemve", 0 );
1125 def.addProteinDomain( d );
1126 def.addProteinDomain( e );
1127 def.addProteinDomain( f );
1128 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1129 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1130 if ( def.getNumberOfProteinDomains() != 3 ) {
1133 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1136 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1139 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1142 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1145 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1149 catch ( final Exception e ) {
1150 e.printStackTrace( System.out );
1156 private static final boolean testNHXparsingFromURL2() {
1158 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1159 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1163 TAXONOMY_EXTRACTION.NO,
1165 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1168 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1169 System.out.println( phys[ 0 ].toNewHampshire() );
1172 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1173 System.out.println( phys[ 1 ].toNewHampshire() );
1176 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1180 TAXONOMY_EXTRACTION.NO,
1182 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1185 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1186 System.out.println( phys2[ 0 ].toNewHampshire() );
1189 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1190 System.out.println( phys2[ 1 ].toNewHampshire() );
1193 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1194 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1195 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1200 .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))))));" ) ) {
1201 System.out.println( phys3[ 0 ].toNewHampshire() );
1204 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1205 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1206 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1211 .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))))));" ) ) {
1212 System.out.println( phys4[ 0 ].toNewHampshire() );
1216 catch ( final Exception e ) {
1217 e.printStackTrace();
1223 private static final boolean testNHXparsingFromURL() {
1225 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1226 final URL u = new URL( s );
1227 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1228 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1229 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1232 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1233 System.out.println( phys[ 0 ].toNewHampshire() );
1236 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1237 System.out.println( phys[ 1 ].toNewHampshire() );
1240 final URL u2 = new URL( s );
1241 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1242 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1245 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1246 System.out.println( phys2[ 0 ].toNewHampshire() );
1249 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1250 final NHXParser p = new NHXParser();
1251 final URL u3 = new URL( s );
1253 if ( !p.hasNext() ) {
1256 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1259 if ( !p.hasNext() ) {
1263 if ( !p.hasNext() ) {
1266 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1269 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1273 if ( !p.hasNext() ) {
1276 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1279 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1283 catch ( final Exception e ) {
1284 System.out.println( e.toString() );
1285 e.printStackTrace();
1291 private static boolean testOverlapRemoval() {
1293 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1294 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1295 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1296 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1297 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1298 final List<Boolean> covered = new ArrayList<Boolean>();
1299 covered.add( true ); // 0
1300 covered.add( false ); // 1
1301 covered.add( true ); // 2
1302 covered.add( false ); // 3
1303 covered.add( true ); // 4
1304 covered.add( true ); // 5
1305 covered.add( false ); // 6
1306 covered.add( true ); // 7
1307 covered.add( true ); // 8
1308 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1311 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1314 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1317 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1320 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1323 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1324 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1325 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1326 ab.addProteinDomain( a );
1327 ab.addProteinDomain( b );
1328 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1329 if ( ab.getNumberOfProteinDomains() != 2 ) {
1332 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1335 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1338 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1339 if ( ab.getNumberOfProteinDomains() != 2 ) {
1342 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1345 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1346 final Domain d = new BasicDomain( "d",
1353 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1354 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1355 cde.addProteinDomain( c );
1356 cde.addProteinDomain( d );
1357 cde.addProteinDomain( e );
1358 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1359 if ( cde.getNumberOfProteinDomains() != 3 ) {
1362 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1365 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1366 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1367 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1368 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1369 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1370 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1371 fghi.addProteinDomain( f );
1372 fghi.addProteinDomain( g );
1373 fghi.addProteinDomain( h );
1374 fghi.addProteinDomain( i );
1375 fghi.addProteinDomain( i );
1376 fghi.addProteinDomain( i );
1377 fghi.addProteinDomain( i2 );
1378 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1379 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1382 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1385 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1388 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1389 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1392 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1395 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1396 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1397 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1398 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1399 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1400 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1401 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1402 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1403 jklm.addProteinDomain( j );
1404 jklm.addProteinDomain( k );
1405 jklm.addProteinDomain( l );
1406 jklm.addProteinDomain( m );
1407 jklm.addProteinDomain( m0 );
1408 jklm.addProteinDomain( m1 );
1409 jklm.addProteinDomain( m2 );
1410 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1411 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1414 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1417 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1420 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1421 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1424 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1427 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1428 final Protein od = new BasicProtein( "od", "varanus", 0 );
1429 od.addProteinDomain( only );
1430 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1431 if ( od.getNumberOfProteinDomains() != 1 ) {
1434 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1438 catch ( final Exception e ) {
1439 e.printStackTrace( System.out );
1445 private static final boolean testPfamTreeReading() {
1447 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1448 final NHXParser parser = new NHXParser();
1449 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1450 parser.setReplaceUnderscores( false );
1451 parser.setGuessRootedness( true );
1452 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1453 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1456 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1459 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1460 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1463 if ( phys2[ 0 ].getNumberOfExternalNodes() != phys[ 0 ].getNumberOfExternalNodes() ) {
1467 catch ( final Exception e ) {
1468 e.printStackTrace();
1474 private static final boolean testPhyloXMLparsingFromURL() {
1476 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1477 final URL u = new URL( s );
1478 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1480 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1483 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1485 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1489 catch ( final Exception e ) {
1490 e.printStackTrace();
1496 private static final boolean testToLReading() {
1498 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1499 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1500 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1503 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1506 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1509 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1513 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1514 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1515 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1518 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1521 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1525 catch ( final Exception e ) {
1526 e.printStackTrace();
1532 private static final boolean testTreeBaseReading() {
1534 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1535 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1536 parser.setReplaceUnderscores( true );
1537 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1538 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1541 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1542 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1543 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1544 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1547 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1548 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1549 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1550 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1553 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1554 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1555 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1556 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1559 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1560 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1561 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1562 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1565 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1566 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1567 parser2.setReplaceUnderscores( true );
1568 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1569 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1572 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1573 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1574 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1575 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1578 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ),
1579 new NexusPhylogeniesParser() );
1580 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1583 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) ,
1584 new NexusPhylogeniesParser() );
1585 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1588 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) ,
1589 new NexusPhylogeniesParser() );
1590 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1593 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) ,
1594 new NexusPhylogeniesParser() );
1595 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1598 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) ,
1599 new NexusPhylogeniesParser() );
1600 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1603 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) ,
1604 new NexusPhylogeniesParser() );
1605 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1608 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) ,
1609 new NexusPhylogeniesParser() );
1610 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1613 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) ,
1614 new NexusPhylogeniesParser() );
1615 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1618 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) ,
1619 new NexusPhylogeniesParser() );
1620 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1623 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) ,
1624 new NexusPhylogeniesParser() );
1625 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1629 catch ( final Exception e ) {
1630 e.printStackTrace();
1636 private static final boolean testTreeFamReading() {
1638 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1639 final NHXParser parser = new NHXParser();
1640 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1641 parser.setReplaceUnderscores( false );
1642 parser.setGuessRootedness( true );
1643 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1644 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1647 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1651 catch ( final Exception e ) {
1652 e.printStackTrace();
1658 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1659 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1663 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1664 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1667 private static boolean testAminoAcidSequence() {
1669 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1670 if ( aa1.getLength() != 13 ) {
1673 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1676 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1679 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1682 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1683 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1686 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1687 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1690 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1691 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1695 catch ( final Exception e ) {
1696 e.printStackTrace();
1702 private static boolean testBasicDomain() {
1704 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1705 if ( !pd.getDomainId().equals( "id" ) ) {
1708 if ( pd.getNumber() != 1 ) {
1711 if ( pd.getTotalCount() != 4 ) {
1714 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1717 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1718 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1719 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1720 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1721 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1722 if ( !a1.equals( a1 ) ) {
1725 if ( !a1.equals( a1_copy ) ) {
1728 if ( !a1.equals( a1_equal ) ) {
1731 if ( !a1.equals( a2 ) ) {
1734 if ( a1.equals( a3 ) ) {
1737 if ( a1.compareTo( a1 ) != 0 ) {
1740 if ( a1.compareTo( a1_copy ) != 0 ) {
1743 if ( a1.compareTo( a1_equal ) != 0 ) {
1746 if ( a1.compareTo( a2 ) != 0 ) {
1749 if ( a1.compareTo( a3 ) == 0 ) {
1753 catch ( final Exception e ) {
1754 e.printStackTrace( System.out );
1760 private static boolean testBasicNodeMethods() {
1762 if ( PhylogenyNode.getNodeCount() != 0 ) {
1765 final PhylogenyNode n1 = new PhylogenyNode();
1766 final PhylogenyNode n2 = PhylogenyNode
1767 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1768 final PhylogenyNode n3 = PhylogenyNode
1769 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1770 final PhylogenyNode n4 = PhylogenyNode
1771 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1772 if ( n1.isHasAssignedEvent() ) {
1775 if ( PhylogenyNode.getNodeCount() != 4 ) {
1778 if ( n3.getIndicator() != 0 ) {
1781 if ( n3.getNumberOfExternalNodes() != 1 ) {
1784 if ( !n3.isExternal() ) {
1787 if ( !n3.isRoot() ) {
1790 if ( !n4.getName().equals( "n4" ) ) {
1794 catch ( final Exception e ) {
1795 e.printStackTrace( System.out );
1801 private static boolean testBasicPhyloXMLparsing() {
1803 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1804 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1805 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1807 if ( xml_parser.getErrorCount() > 0 ) {
1808 System.out.println( xml_parser.getErrorMessages().toString() );
1811 if ( phylogenies_0.length != 4 ) {
1814 final Phylogeny t1 = phylogenies_0[ 0 ];
1815 final Phylogeny t2 = phylogenies_0[ 1 ];
1816 final Phylogeny t3 = phylogenies_0[ 2 ];
1817 final Phylogeny t4 = phylogenies_0[ 3 ];
1818 if ( t1.getNumberOfExternalNodes() != 1 ) {
1821 if ( !t1.isRooted() ) {
1824 if ( t1.isRerootable() ) {
1827 if ( !t1.getType().equals( "gene_tree" ) ) {
1830 if ( t2.getNumberOfExternalNodes() != 2 ) {
1833 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1836 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1839 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1842 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1845 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1848 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1851 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1852 .startsWith( "actgtgggggt" ) ) {
1855 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1856 .startsWith( "ctgtgatgcat" ) ) {
1859 if ( t3.getNumberOfExternalNodes() != 4 ) {
1862 if ( !t1.getName().equals( "t1" ) ) {
1865 if ( !t2.getName().equals( "t2" ) ) {
1868 if ( !t3.getName().equals( "t3" ) ) {
1871 if ( !t4.getName().equals( "t4" ) ) {
1874 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1877 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1880 if ( !t3.getNode( "root node" ).isDuplication() ) {
1883 if ( !t3.getNode( "node a" ).isDuplication() ) {
1886 if ( t3.getNode( "node a" ).isSpeciation() ) {
1889 if ( t3.getNode( "node bc" ).isDuplication() ) {
1892 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
1895 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1898 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1899 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1902 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1905 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1908 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1911 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1912 .equals( "apoptosis" ) ) {
1915 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1916 .equals( "GO:0006915" ) ) {
1919 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1920 .equals( "UniProtKB" ) ) {
1923 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1924 .equals( "experimental" ) ) {
1927 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1928 .equals( "function" ) ) {
1931 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1932 .getValue() != 1 ) {
1935 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1936 .getType().equals( "ml" ) ) {
1939 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1940 .equals( "apoptosis" ) ) {
1943 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1944 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1947 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1948 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1951 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1952 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1955 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1956 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1959 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1960 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1963 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1964 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1967 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1968 .equals( "GO:0005829" ) ) {
1971 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1972 .equals( "intracellular organelle" ) ) {
1975 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1978 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1979 .equals( "UniProt link" ) ) ) {
1982 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1985 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1986 if ( x.size() != 4 ) {
1990 for( final Accession acc : x ) {
1992 if ( !acc.getSource().equals( "KEGG" ) ) {
1995 if ( !acc.getValue().equals( "hsa:596" ) ) {
2002 catch ( final Exception e ) {
2003 e.printStackTrace( System.out );
2009 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2011 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2012 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2013 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2014 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2017 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2019 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2021 if ( xml_parser.getErrorCount() > 0 ) {
2022 System.out.println( xml_parser.getErrorMessages().toString() );
2025 if ( phylogenies_0.length != 4 ) {
2028 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2029 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2030 if ( phylogenies_t1.length != 1 ) {
2033 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2034 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2037 if ( !t1_rt.isRooted() ) {
2040 if ( t1_rt.isRerootable() ) {
2043 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2046 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2047 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2048 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2049 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2052 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2055 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2058 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2061 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2062 .startsWith( "actgtgggggt" ) ) {
2065 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2066 .startsWith( "ctgtgatgcat" ) ) {
2069 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2070 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2071 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2072 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2073 if ( phylogenies_1.length != 1 ) {
2076 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2077 if ( !t3_rt.getName().equals( "t3" ) ) {
2080 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2083 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2086 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2089 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2092 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2093 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2096 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2099 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2102 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2103 .equals( "UniProtKB" ) ) {
2106 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2107 .equals( "apoptosis" ) ) {
2110 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2111 .equals( "GO:0006915" ) ) {
2114 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2115 .equals( "UniProtKB" ) ) {
2118 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2119 .equals( "experimental" ) ) {
2122 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2123 .equals( "function" ) ) {
2126 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2127 .getValue() != 1 ) {
2130 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2131 .getType().equals( "ml" ) ) {
2134 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2135 .equals( "apoptosis" ) ) {
2138 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2139 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2142 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2143 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2146 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2147 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2150 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2151 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2154 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2155 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2158 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2159 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2162 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2163 .equals( "GO:0005829" ) ) {
2166 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2167 .equals( "intracellular organelle" ) ) {
2170 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2173 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2174 .equals( "UniProt link" ) ) ) {
2177 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2180 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2183 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2184 .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." ) ) ) {
2187 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2190 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2193 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2196 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2199 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2200 .equals( "ncbi" ) ) {
2203 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2206 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2207 .getName().equals( "B" ) ) {
2210 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2211 .getFrom() != 21 ) {
2214 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2217 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2218 .getLength() != 24 ) {
2221 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2222 .getConfidence() != 0 ) {
2225 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2226 .equals( "pfam" ) ) {
2229 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2232 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2235 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2238 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2241 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2242 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2245 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2248 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2251 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2254 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2257 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2260 if ( taxbb.getSynonyms().size() != 2 ) {
2263 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2266 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2269 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2272 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2275 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2278 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2279 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2282 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2285 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2288 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2291 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2294 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2297 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2300 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2303 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2306 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2307 .equalsIgnoreCase( "435" ) ) {
2310 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2313 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2314 .equalsIgnoreCase( "443.7" ) ) {
2317 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2320 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2323 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2324 .equalsIgnoreCase( "433" ) ) {
2327 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2328 .getCrossReferences();
2329 if ( x.size() != 4 ) {
2333 for( final Accession acc : x ) {
2335 if ( !acc.getSource().equals( "KEGG" ) ) {
2338 if ( !acc.getValue().equals( "hsa:596" ) ) {
2345 catch ( final Exception e ) {
2346 e.printStackTrace( System.out );
2352 private static boolean testBasicPhyloXMLparsingValidating() {
2354 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2355 PhyloXmlParser xml_parser = null;
2357 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2359 catch ( final Exception e ) {
2360 // Do nothing -- means were not running from jar.
2362 if ( xml_parser == null ) {
2363 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2364 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2365 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2368 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2371 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2373 if ( xml_parser.getErrorCount() > 0 ) {
2374 System.out.println( xml_parser.getErrorMessages().toString() );
2377 if ( phylogenies_0.length != 4 ) {
2380 final Phylogeny t1 = phylogenies_0[ 0 ];
2381 final Phylogeny t2 = phylogenies_0[ 1 ];
2382 final Phylogeny t3 = phylogenies_0[ 2 ];
2383 final Phylogeny t4 = phylogenies_0[ 3 ];
2384 if ( !t1.getName().equals( "t1" ) ) {
2387 if ( !t2.getName().equals( "t2" ) ) {
2390 if ( !t3.getName().equals( "t3" ) ) {
2393 if ( !t4.getName().equals( "t4" ) ) {
2396 if ( t1.getNumberOfExternalNodes() != 1 ) {
2399 if ( t2.getNumberOfExternalNodes() != 2 ) {
2402 if ( t3.getNumberOfExternalNodes() != 4 ) {
2405 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2406 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2407 if ( xml_parser.getErrorCount() > 0 ) {
2408 System.out.println( "errors:" );
2409 System.out.println( xml_parser.getErrorMessages().toString() );
2412 if ( phylogenies_1.length != 4 ) {
2415 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2417 if ( xml_parser.getErrorCount() > 0 ) {
2418 System.out.println( "errors:" );
2419 System.out.println( xml_parser.getErrorMessages().toString() );
2422 if ( phylogenies_2.length != 1 ) {
2425 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2428 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2430 if ( xml_parser.getErrorCount() > 0 ) {
2431 System.out.println( xml_parser.getErrorMessages().toString() );
2434 if ( phylogenies_3.length != 2 ) {
2437 final Phylogeny a = phylogenies_3[ 0 ];
2438 if ( !a.getName().equals( "tree 4" ) ) {
2441 if ( a.getNumberOfExternalNodes() != 3 ) {
2444 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2447 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2450 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2452 if ( xml_parser.getErrorCount() > 0 ) {
2453 System.out.println( xml_parser.getErrorMessages().toString() );
2456 if ( phylogenies_4.length != 1 ) {
2459 final Phylogeny s = phylogenies_4[ 0 ];
2460 if ( s.getNumberOfExternalNodes() != 6 ) {
2463 s.getNode( "first" );
2465 s.getNode( "\"<a'b&c'd\">\"" );
2466 s.getNode( "'''\"" );
2467 s.getNode( "\"\"\"" );
2468 s.getNode( "dick & doof" );
2470 catch ( final Exception e ) {
2471 e.printStackTrace( System.out );
2477 private static boolean testBasicProtein() {
2479 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2480 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2481 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2482 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2483 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2484 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2485 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2486 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2487 p0.addProteinDomain( y );
2488 p0.addProteinDomain( e );
2489 p0.addProteinDomain( b );
2490 p0.addProteinDomain( c );
2491 p0.addProteinDomain( d );
2492 p0.addProteinDomain( a );
2493 p0.addProteinDomain( x );
2494 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2497 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2501 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2502 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2503 aa0.addProteinDomain( a1 );
2504 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2507 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2511 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2512 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2513 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2514 aa1.addProteinDomain( a11 );
2515 aa1.addProteinDomain( a12 );
2516 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2519 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2522 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2523 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2526 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2529 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2532 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2533 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2536 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2539 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2542 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2545 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2546 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2549 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2552 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2555 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2558 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2559 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2562 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2565 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2568 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2572 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2573 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2574 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2575 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2576 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2577 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2578 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2579 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2580 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2581 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2582 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2583 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2584 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2585 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2586 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2587 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2588 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2589 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2590 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2591 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2592 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2593 p00.addProteinDomain( y0 );
2594 p00.addProteinDomain( e0 );
2595 p00.addProteinDomain( b0 );
2596 p00.addProteinDomain( c0 );
2597 p00.addProteinDomain( d0 );
2598 p00.addProteinDomain( a0 );
2599 p00.addProteinDomain( x0 );
2600 p00.addProteinDomain( y1 );
2601 p00.addProteinDomain( y2 );
2602 p00.addProteinDomain( y3 );
2603 p00.addProteinDomain( e1 );
2604 p00.addProteinDomain( e2 );
2605 p00.addProteinDomain( e3 );
2606 p00.addProteinDomain( e4 );
2607 p00.addProteinDomain( e5 );
2608 p00.addProteinDomain( z0 );
2609 p00.addProteinDomain( z1 );
2610 p00.addProteinDomain( z2 );
2611 p00.addProteinDomain( zz0 );
2612 p00.addProteinDomain( zz1 );
2613 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2616 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2619 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2622 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2625 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" ) ) {
2628 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2629 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2630 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2631 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2632 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2633 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2634 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2635 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2636 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2637 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2638 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2639 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2640 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2641 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2642 p.addProteinDomain( B15 );
2643 p.addProteinDomain( C50 );
2644 p.addProteinDomain( A60 );
2645 p.addProteinDomain( A30 );
2646 p.addProteinDomain( C70 );
2647 p.addProteinDomain( B35 );
2648 p.addProteinDomain( B40 );
2649 p.addProteinDomain( A0 );
2650 p.addProteinDomain( A10 );
2651 p.addProteinDomain( A20 );
2652 p.addProteinDomain( B25 );
2653 p.addProteinDomain( D80 );
2654 List<String> domains_ids = new ArrayList<String>();
2655 domains_ids.add( "A" );
2656 domains_ids.add( "B" );
2657 domains_ids.add( "C" );
2658 if ( !p.contains( domains_ids, false ) ) {
2661 if ( !p.contains( domains_ids, true ) ) {
2664 domains_ids.add( "X" );
2665 if ( p.contains( domains_ids, false ) ) {
2668 if ( p.contains( domains_ids, true ) ) {
2671 domains_ids = new ArrayList<String>();
2672 domains_ids.add( "A" );
2673 domains_ids.add( "C" );
2674 domains_ids.add( "D" );
2675 if ( !p.contains( domains_ids, false ) ) {
2678 if ( !p.contains( domains_ids, true ) ) {
2681 domains_ids = new ArrayList<String>();
2682 domains_ids.add( "A" );
2683 domains_ids.add( "D" );
2684 domains_ids.add( "C" );
2685 if ( !p.contains( domains_ids, false ) ) {
2688 if ( p.contains( domains_ids, true ) ) {
2691 domains_ids = new ArrayList<String>();
2692 domains_ids.add( "A" );
2693 domains_ids.add( "A" );
2694 domains_ids.add( "B" );
2695 if ( !p.contains( domains_ids, false ) ) {
2698 if ( !p.contains( domains_ids, true ) ) {
2701 domains_ids = new ArrayList<String>();
2702 domains_ids.add( "A" );
2703 domains_ids.add( "A" );
2704 domains_ids.add( "A" );
2705 domains_ids.add( "B" );
2706 domains_ids.add( "B" );
2707 if ( !p.contains( domains_ids, false ) ) {
2710 if ( !p.contains( domains_ids, true ) ) {
2713 domains_ids = new ArrayList<String>();
2714 domains_ids.add( "A" );
2715 domains_ids.add( "A" );
2716 domains_ids.add( "B" );
2717 domains_ids.add( "A" );
2718 domains_ids.add( "B" );
2719 domains_ids.add( "B" );
2720 domains_ids.add( "A" );
2721 domains_ids.add( "B" );
2722 domains_ids.add( "C" );
2723 domains_ids.add( "A" );
2724 domains_ids.add( "C" );
2725 domains_ids.add( "D" );
2726 if ( !p.contains( domains_ids, false ) ) {
2729 if ( p.contains( domains_ids, true ) ) {
2733 catch ( final Exception e ) {
2734 e.printStackTrace( System.out );
2740 private static boolean testBasicTable() {
2742 final BasicTable<String> t0 = new BasicTable<String>();
2743 if ( t0.getNumberOfColumns() != 0 ) {
2746 if ( t0.getNumberOfRows() != 0 ) {
2749 t0.setValue( 3, 2, "23" );
2750 t0.setValue( 10, 1, "error" );
2751 t0.setValue( 10, 1, "110" );
2752 t0.setValue( 9, 1, "19" );
2753 t0.setValue( 1, 10, "101" );
2754 t0.setValue( 10, 10, "1010" );
2755 t0.setValue( 100, 10, "10100" );
2756 t0.setValue( 0, 0, "00" );
2757 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2760 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2763 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2766 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2769 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2772 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2775 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2778 if ( t0.getNumberOfColumns() != 101 ) {
2781 if ( t0.getNumberOfRows() != 11 ) {
2784 if ( t0.getValueAsString( 49, 4 ) != null ) {
2787 final String l = ForesterUtil.getLineSeparator();
2788 final StringBuffer source = new StringBuffer();
2789 source.append( "" + l );
2790 source.append( "# 1 1 1 1 1 1 1 1" + l );
2791 source.append( " 00 01 02 03" + l );
2792 source.append( " 10 11 12 13 " + l );
2793 source.append( "20 21 22 23 " + l );
2794 source.append( " 30 31 32 33" + l );
2795 source.append( "40 41 42 43" + l );
2796 source.append( " # 1 1 1 1 1 " + l );
2797 source.append( "50 51 52 53 54" + l );
2798 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2799 if ( t1.getNumberOfColumns() != 5 ) {
2802 if ( t1.getNumberOfRows() != 6 ) {
2805 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2808 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2811 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2814 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2817 final StringBuffer source1 = new StringBuffer();
2818 source1.append( "" + l );
2819 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2820 source1.append( " 00; 01 ;02;03" + l );
2821 source1.append( " 10; 11; 12; 13 " + l );
2822 source1.append( "20; 21; 22; 23 " + l );
2823 source1.append( " 30; 31; 32; 33" + l );
2824 source1.append( "40;41;42;43" + l );
2825 source1.append( " # 1 1 1 1 1 " + l );
2826 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2827 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2828 if ( t2.getNumberOfColumns() != 5 ) {
2831 if ( t2.getNumberOfRows() != 6 ) {
2834 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2837 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2840 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2843 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2846 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2849 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2852 final StringBuffer source2 = new StringBuffer();
2853 source2.append( "" + l );
2854 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2855 source2.append( " 00; 01 ;02;03" + l );
2856 source2.append( " 10; 11; 12; 13 " + l );
2857 source2.append( "20; 21; 22; 23 " + l );
2858 source2.append( " " + l );
2859 source2.append( " 30; 31; 32; 33" + l );
2860 source2.append( "40;41;42;43" + l );
2861 source2.append( " comment: 1 1 1 1 1 " + l );
2862 source2.append( ";;;50 ; 52; 53;;54 " + l );
2863 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2869 if ( tl.size() != 2 ) {
2872 final BasicTable<String> t3 = tl.get( 0 );
2873 final BasicTable<String> t4 = tl.get( 1 );
2874 if ( t3.getNumberOfColumns() != 4 ) {
2877 if ( t3.getNumberOfRows() != 3 ) {
2880 if ( t4.getNumberOfColumns() != 4 ) {
2883 if ( t4.getNumberOfRows() != 3 ) {
2886 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2889 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2893 catch ( final Exception e ) {
2894 e.printStackTrace( System.out );
2900 private static boolean testBasicTolXMLparsing() {
2902 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2903 final TolParser parser = new TolParser();
2904 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2905 if ( parser.getErrorCount() > 0 ) {
2906 System.out.println( parser.getErrorMessages().toString() );
2909 if ( phylogenies_0.length != 1 ) {
2912 final Phylogeny t1 = phylogenies_0[ 0 ];
2913 if ( t1.getNumberOfExternalNodes() != 5 ) {
2916 if ( !t1.isRooted() ) {
2919 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2922 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2925 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2928 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2931 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2932 if ( parser.getErrorCount() > 0 ) {
2933 System.out.println( parser.getErrorMessages().toString() );
2936 if ( phylogenies_1.length != 1 ) {
2939 final Phylogeny t2 = phylogenies_1[ 0 ];
2940 if ( t2.getNumberOfExternalNodes() != 664 ) {
2943 if ( !t2.isRooted() ) {
2946 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2949 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2952 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2955 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2958 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2961 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2962 .equals( "Aquifex" ) ) {
2965 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2966 if ( parser.getErrorCount() > 0 ) {
2967 System.out.println( parser.getErrorMessages().toString() );
2970 if ( phylogenies_2.length != 1 ) {
2973 final Phylogeny t3 = phylogenies_2[ 0 ];
2974 if ( t3.getNumberOfExternalNodes() != 184 ) {
2977 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2980 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2983 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2986 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2987 if ( parser.getErrorCount() > 0 ) {
2988 System.out.println( parser.getErrorMessages().toString() );
2991 if ( phylogenies_3.length != 1 ) {
2994 final Phylogeny t4 = phylogenies_3[ 0 ];
2995 if ( t4.getNumberOfExternalNodes() != 1 ) {
2998 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3001 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3004 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3007 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3008 if ( parser.getErrorCount() > 0 ) {
3009 System.out.println( parser.getErrorMessages().toString() );
3012 if ( phylogenies_4.length != 1 ) {
3015 final Phylogeny t5 = phylogenies_4[ 0 ];
3016 if ( t5.getNumberOfExternalNodes() != 13 ) {
3019 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3022 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3025 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3029 catch ( final Exception e ) {
3030 e.printStackTrace( System.out );
3036 private static boolean testBasicTreeMethods() {
3038 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3039 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3040 if ( t2.getNumberOfExternalNodes() != 4 ) {
3043 if ( t2.getHeight() != 8.5 ) {
3046 if ( !t2.isCompletelyBinary() ) {
3049 if ( t2.isEmpty() ) {
3052 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3053 if ( t3.getNumberOfExternalNodes() != 5 ) {
3056 if ( t3.getHeight() != 11 ) {
3059 if ( t3.isCompletelyBinary() ) {
3062 final PhylogenyNode n = t3.getNode( "ABC" );
3063 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
3064 if ( t4.getNumberOfExternalNodes() != 9 ) {
3067 if ( t4.getHeight() != 11 ) {
3070 if ( t4.isCompletelyBinary() ) {
3073 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)" );
3074 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
3075 if ( t5.getNumberOfExternalNodes() != 8 ) {
3078 if ( t5.getHeight() != 15 ) {
3081 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)" );
3082 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
3083 if ( t6.getHeight() != 15 ) {
3086 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)" );
3087 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
3088 if ( t7.getHeight() != 15 ) {
3091 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)" );
3092 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
3093 if ( t8.getNumberOfExternalNodes() != 10 ) {
3096 if ( t8.getHeight() != 15 ) {
3099 final char[] a9 = new char[] { 'a' };
3100 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3101 if ( t9.getHeight() != 0 ) {
3104 final char[] a10 = new char[] { 'a', ':', '6' };
3105 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3106 if ( t10.getHeight() != 6 ) {
3110 catch ( final Exception e ) {
3111 e.printStackTrace( System.out );
3117 private static boolean testConfidenceAssessor() {
3119 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3120 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3121 final Phylogeny[] ev0 = factory
3122 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3124 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3125 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3128 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3131 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3132 final Phylogeny[] ev1 = factory
3133 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3135 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3136 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3139 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3142 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3143 final Phylogeny[] ev_b = factory
3144 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3146 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3147 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3150 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3154 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3155 final Phylogeny[] ev1x = factory
3156 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3158 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3159 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3162 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3165 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3166 final Phylogeny[] ev_bx = factory
3167 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3169 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3170 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3173 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3176 final Phylogeny[] t2 = factory
3177 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
3179 final Phylogeny[] ev2 = factory
3180 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
3182 for( final Phylogeny target : t2 ) {
3183 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3185 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3186 new NHXParser() )[ 0 ];
3187 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3188 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3189 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3192 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3195 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3199 catch ( final Exception e ) {
3200 e.printStackTrace();
3206 private static boolean testCopyOfNodeData() {
3208 final PhylogenyNode n1 = PhylogenyNode
3209 .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]" );
3210 final PhylogenyNode n2 = n1.copyNodeData();
3211 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3215 catch ( final Exception e ) {
3216 e.printStackTrace();
3222 private static boolean testCreateBalancedPhylogeny() {
3224 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3225 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3228 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3231 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3232 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3235 if ( p1.getNumberOfExternalNodes() != 100 ) {
3239 catch ( final Exception e ) {
3240 e.printStackTrace();
3246 private static boolean testCreateUriForSeqWeb() {
3248 final PhylogenyNode n = new PhylogenyNode();
3249 n.setName( "tr|B3RJ64" );
3250 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3253 n.setName( "B0LM41_HUMAN" );
3254 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3257 n.setName( "NP_001025424" );
3258 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3261 n.setName( "_NM_001030253-" );
3262 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3265 n.setName( "XM_002122186" );
3266 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3269 n.setName( "dgh_AAA34956_gdg" );
3270 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3273 n.setName( "AAA34956" );
3274 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3277 n.setName( "GI:394892" );
3278 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3279 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3282 n.setName( "gi_394892" );
3283 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3284 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3287 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3288 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3289 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3292 n.setName( "P12345" );
3293 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3294 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3297 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3298 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3299 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3303 catch ( final Exception e ) {
3304 e.printStackTrace( System.out );
3310 private static boolean testDataObjects() {
3312 final Confidence s0 = new Confidence();
3313 final Confidence s1 = new Confidence();
3314 if ( !s0.isEqual( s1 ) ) {
3317 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3318 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3319 if ( s2.isEqual( s1 ) ) {
3322 if ( !s2.isEqual( s3 ) ) {
3325 final Confidence s4 = ( Confidence ) s3.copy();
3326 if ( !s4.isEqual( s3 ) ) {
3333 final Taxonomy t1 = new Taxonomy();
3334 final Taxonomy t2 = new Taxonomy();
3335 final Taxonomy t3 = new Taxonomy();
3336 final Taxonomy t4 = new Taxonomy();
3337 final Taxonomy t5 = new Taxonomy();
3338 t1.setIdentifier( new Identifier( "ecoli" ) );
3339 t1.setTaxonomyCode( "ECOLI" );
3340 t1.setScientificName( "E. coli" );
3341 t1.setCommonName( "coli" );
3342 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3343 if ( !t1.isEqual( t0 ) ) {
3346 t2.setIdentifier( new Identifier( "ecoli" ) );
3347 t2.setTaxonomyCode( "OTHER" );
3348 t2.setScientificName( "what" );
3349 t2.setCommonName( "something" );
3350 if ( !t1.isEqual( t2 ) ) {
3353 t2.setIdentifier( new Identifier( "nemve" ) );
3354 if ( t1.isEqual( t2 ) ) {
3357 t1.setIdentifier( null );
3358 t3.setTaxonomyCode( "ECOLI" );
3359 t3.setScientificName( "what" );
3360 t3.setCommonName( "something" );
3361 if ( !t1.isEqual( t3 ) ) {
3364 t1.setIdentifier( null );
3365 t1.setTaxonomyCode( "" );
3366 t4.setScientificName( "E. ColI" );
3367 t4.setCommonName( "something" );
3368 if ( !t1.isEqual( t4 ) ) {
3371 t4.setScientificName( "B. subtilis" );
3372 t4.setCommonName( "something" );
3373 if ( t1.isEqual( t4 ) ) {
3376 t1.setIdentifier( null );
3377 t1.setTaxonomyCode( "" );
3378 t1.setScientificName( "" );
3379 t5.setCommonName( "COLI" );
3380 if ( !t1.isEqual( t5 ) ) {
3383 t5.setCommonName( "vibrio" );
3384 if ( t1.isEqual( t5 ) ) {
3389 final Identifier id0 = new Identifier( "123", "pfam" );
3390 final Identifier id1 = ( Identifier ) id0.copy();
3391 if ( !id1.isEqual( id1 ) ) {
3394 if ( !id1.isEqual( id0 ) ) {
3397 if ( !id0.isEqual( id1 ) ) {
3404 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3405 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3406 if ( !pd1.isEqual( pd1 ) ) {
3409 if ( !pd1.isEqual( pd0 ) ) {
3414 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3415 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3416 if ( !pd3.isEqual( pd3 ) ) {
3419 if ( !pd2.isEqual( pd3 ) ) {
3422 if ( !pd0.isEqual( pd3 ) ) {
3427 // DomainArchitecture
3428 // ------------------
3429 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3430 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3431 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3432 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3433 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3434 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3439 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3440 if ( ds0.getNumberOfDomains() != 4 ) {
3443 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3444 if ( !ds0.isEqual( ds0 ) ) {
3447 if ( !ds0.isEqual( ds1 ) ) {
3450 if ( ds1.getNumberOfDomains() != 4 ) {
3453 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3458 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3459 if ( ds0.isEqual( ds2 ) ) {
3465 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3466 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3467 System.out.println( ds3.toNHX() );
3470 if ( ds3.getNumberOfDomains() != 3 ) {
3475 final Event e1 = new Event( Event.EventType.fusion );
3476 if ( e1.isDuplication() ) {
3479 if ( !e1.isFusion() ) {
3482 if ( !e1.asText().toString().equals( "fusion" ) ) {
3485 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3488 final Event e11 = new Event( Event.EventType.fusion );
3489 if ( !e11.isEqual( e1 ) ) {
3492 if ( !e11.toNHX().toString().equals( "" ) ) {
3495 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3496 if ( e2.isDuplication() ) {
3499 if ( !e2.isSpeciationOrDuplication() ) {
3502 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3505 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3508 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3511 if ( e11.isEqual( e2 ) ) {
3514 final Event e2c = ( Event ) e2.copy();
3515 if ( !e2c.isEqual( e2 ) ) {
3518 Event e3 = new Event( 1, 2, 3 );
3519 if ( e3.isDuplication() ) {
3522 if ( e3.isSpeciation() ) {
3525 if ( e3.isGeneLoss() ) {
3528 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3531 final Event e3c = ( Event ) e3.copy();
3532 final Event e3cc = ( Event ) e3c.copy();
3533 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3537 if ( !e3c.isEqual( e3cc ) ) {
3540 Event e4 = new Event( 1, 2, 3 );
3541 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3544 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3547 final Event e4c = ( Event ) e4.copy();
3549 final Event e4cc = ( Event ) e4c.copy();
3550 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3553 if ( !e4c.isEqual( e4cc ) ) {
3556 final Event e5 = new Event();
3557 if ( !e5.isUnassigned() ) {
3560 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3563 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3566 final Event e6 = new Event( 1, 0, 0 );
3567 if ( !e6.asText().toString().equals( "duplication" ) ) {
3570 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3573 final Event e7 = new Event( 0, 1, 0 );
3574 if ( !e7.asText().toString().equals( "speciation" ) ) {
3577 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3580 final Event e8 = new Event( 0, 0, 1 );
3581 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3584 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3588 catch ( final Exception e ) {
3589 e.printStackTrace( System.out );
3595 private static boolean testDeletionOfExternalNodes() {
3597 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3598 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3599 final PhylogenyWriter w = new PhylogenyWriter();
3600 if ( t0.isEmpty() ) {
3603 if ( t0.getNumberOfExternalNodes() != 1 ) {
3606 t0.deleteSubtree( t0.getNode( "A" ), false );
3607 if ( t0.getNumberOfExternalNodes() != 0 ) {
3610 if ( !t0.isEmpty() ) {
3613 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3614 if ( t1.getNumberOfExternalNodes() != 2 ) {
3617 t1.deleteSubtree( t1.getNode( "A" ), false );
3618 if ( t1.getNumberOfExternalNodes() != 1 ) {
3621 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3624 t1.deleteSubtree( t1.getNode( "B" ), false );
3625 if ( t1.getNumberOfExternalNodes() != 1 ) {
3628 t1.deleteSubtree( t1.getNode( "r" ), false );
3629 if ( !t1.isEmpty() ) {
3632 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3633 if ( t2.getNumberOfExternalNodes() != 3 ) {
3636 t2.deleteSubtree( t2.getNode( "B" ), false );
3637 if ( t2.getNumberOfExternalNodes() != 2 ) {
3640 t2.toNewHampshireX();
3641 PhylogenyNode n = t2.getNode( "A" );
3642 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3645 t2.deleteSubtree( t2.getNode( "A" ), false );
3646 if ( t2.getNumberOfExternalNodes() != 2 ) {
3649 t2.deleteSubtree( t2.getNode( "C" ), true );
3650 if ( t2.getNumberOfExternalNodes() != 1 ) {
3653 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3654 if ( t3.getNumberOfExternalNodes() != 4 ) {
3657 t3.deleteSubtree( t3.getNode( "B" ), true );
3658 if ( t3.getNumberOfExternalNodes() != 3 ) {
3661 n = t3.getNode( "A" );
3662 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3665 n = n.getNextExternalNode();
3666 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3669 t3.deleteSubtree( t3.getNode( "A" ), true );
3670 if ( t3.getNumberOfExternalNodes() != 2 ) {
3673 n = t3.getNode( "C" );
3674 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3677 t3.deleteSubtree( t3.getNode( "C" ), true );
3678 if ( t3.getNumberOfExternalNodes() != 1 ) {
3681 t3.deleteSubtree( t3.getNode( "D" ), true );
3682 if ( t3.getNumberOfExternalNodes() != 0 ) {
3685 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3686 if ( t4.getNumberOfExternalNodes() != 6 ) {
3689 t4.deleteSubtree( t4.getNode( "B2" ), true );
3690 if ( t4.getNumberOfExternalNodes() != 5 ) {
3693 String s = w.toNewHampshire( t4, true ).toString();
3694 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3697 t4.deleteSubtree( t4.getNode( "B11" ), true );
3698 if ( t4.getNumberOfExternalNodes() != 4 ) {
3701 t4.deleteSubtree( t4.getNode( "C" ), true );
3702 if ( t4.getNumberOfExternalNodes() != 3 ) {
3705 n = t4.getNode( "A" );
3706 n = n.getNextExternalNode();
3707 if ( !n.getName().equals( "B12" ) ) {
3710 n = n.getNextExternalNode();
3711 if ( !n.getName().equals( "D" ) ) {
3714 s = w.toNewHampshire( t4, true ).toString();
3715 if ( !s.equals( "((A,B12),D);" ) ) {
3718 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3719 t5.deleteSubtree( t5.getNode( "A" ), true );
3720 if ( t5.getNumberOfExternalNodes() != 5 ) {
3723 s = w.toNewHampshire( t5, true ).toString();
3724 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3727 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3728 t6.deleteSubtree( t6.getNode( "B11" ), true );
3729 if ( t6.getNumberOfExternalNodes() != 5 ) {
3732 s = w.toNewHampshire( t6, false ).toString();
3733 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3736 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3737 t7.deleteSubtree( t7.getNode( "B12" ), true );
3738 if ( t7.getNumberOfExternalNodes() != 5 ) {
3741 s = w.toNewHampshire( t7, true ).toString();
3742 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3745 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3746 t8.deleteSubtree( t8.getNode( "B2" ), true );
3747 if ( t8.getNumberOfExternalNodes() != 5 ) {
3750 s = w.toNewHampshire( t8, false ).toString();
3751 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3754 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3755 t9.deleteSubtree( t9.getNode( "C" ), true );
3756 if ( t9.getNumberOfExternalNodes() != 5 ) {
3759 s = w.toNewHampshire( t9, true ).toString();
3760 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3763 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3764 t10.deleteSubtree( t10.getNode( "D" ), true );
3765 if ( t10.getNumberOfExternalNodes() != 5 ) {
3768 s = w.toNewHampshire( t10, true ).toString();
3769 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3772 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3773 t11.deleteSubtree( t11.getNode( "A" ), true );
3774 if ( t11.getNumberOfExternalNodes() != 2 ) {
3777 s = w.toNewHampshire( t11, true ).toString();
3778 if ( !s.equals( "(B,C);" ) ) {
3781 t11.deleteSubtree( t11.getNode( "C" ), true );
3782 if ( t11.getNumberOfExternalNodes() != 1 ) {
3785 s = w.toNewHampshire( t11, false ).toString();
3786 if ( !s.equals( "B;" ) ) {
3789 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3790 t12.deleteSubtree( t12.getNode( "B2" ), true );
3791 if ( t12.getNumberOfExternalNodes() != 8 ) {
3794 s = w.toNewHampshire( t12, true ).toString();
3795 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3798 t12.deleteSubtree( t12.getNode( "B3" ), true );
3799 if ( t12.getNumberOfExternalNodes() != 7 ) {
3802 s = w.toNewHampshire( t12, true ).toString();
3803 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3806 t12.deleteSubtree( t12.getNode( "C3" ), true );
3807 if ( t12.getNumberOfExternalNodes() != 6 ) {
3810 s = w.toNewHampshire( t12, true ).toString();
3811 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3814 t12.deleteSubtree( t12.getNode( "A1" ), true );
3815 if ( t12.getNumberOfExternalNodes() != 5 ) {
3818 s = w.toNewHampshire( t12, true ).toString();
3819 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3822 t12.deleteSubtree( t12.getNode( "B1" ), true );
3823 if ( t12.getNumberOfExternalNodes() != 4 ) {
3826 s = w.toNewHampshire( t12, true ).toString();
3827 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3830 t12.deleteSubtree( t12.getNode( "A3" ), true );
3831 if ( t12.getNumberOfExternalNodes() != 3 ) {
3834 s = w.toNewHampshire( t12, true ).toString();
3835 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3838 t12.deleteSubtree( t12.getNode( "A2" ), true );
3839 if ( t12.getNumberOfExternalNodes() != 2 ) {
3842 s = w.toNewHampshire( t12, true ).toString();
3843 if ( !s.equals( "(C1,C2);" ) ) {
3846 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3847 t13.deleteSubtree( t13.getNode( "D" ), true );
3848 if ( t13.getNumberOfExternalNodes() != 4 ) {
3851 s = w.toNewHampshire( t13, true ).toString();
3852 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3855 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3856 t14.deleteSubtree( t14.getNode( "E" ), true );
3857 if ( t14.getNumberOfExternalNodes() != 5 ) {
3860 s = w.toNewHampshire( t14, true ).toString();
3861 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3864 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3865 t15.deleteSubtree( t15.getNode( "B2" ), true );
3866 if ( t15.getNumberOfExternalNodes() != 11 ) {
3869 t15.deleteSubtree( t15.getNode( "B1" ), true );
3870 if ( t15.getNumberOfExternalNodes() != 10 ) {
3873 t15.deleteSubtree( t15.getNode( "B3" ), true );
3874 if ( t15.getNumberOfExternalNodes() != 9 ) {
3877 t15.deleteSubtree( t15.getNode( "B4" ), true );
3878 if ( t15.getNumberOfExternalNodes() != 8 ) {
3881 t15.deleteSubtree( t15.getNode( "A1" ), true );
3882 if ( t15.getNumberOfExternalNodes() != 7 ) {
3885 t15.deleteSubtree( t15.getNode( "C4" ), true );
3886 if ( t15.getNumberOfExternalNodes() != 6 ) {
3890 catch ( final Exception e ) {
3891 e.printStackTrace( System.out );
3897 private static boolean testDescriptiveStatistics() {
3899 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3900 dss1.addValue( 82 );
3901 dss1.addValue( 78 );
3902 dss1.addValue( 70 );
3903 dss1.addValue( 58 );
3904 dss1.addValue( 42 );
3905 if ( dss1.getN() != 5 ) {
3908 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3911 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3914 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3917 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3920 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3923 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3926 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3929 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3932 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3935 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3938 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3941 dss1.addValue( 123 );
3942 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3945 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3948 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3951 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3952 dss2.addValue( -1.85 );
3953 dss2.addValue( 57.5 );
3954 dss2.addValue( 92.78 );
3955 dss2.addValue( 57.78 );
3956 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3959 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3962 final double[] a = dss2.getDataAsDoubleArray();
3963 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3966 dss2.addValue( -100 );
3967 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3970 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3973 final double[] ds = new double[ 14 ];
3988 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3989 if ( bins.length != 4 ) {
3992 if ( bins[ 0 ] != 2 ) {
3995 if ( bins[ 1 ] != 3 ) {
3998 if ( bins[ 2 ] != 4 ) {
4001 if ( bins[ 3 ] != 5 ) {
4004 final double[] ds1 = new double[ 9 ];
4014 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4015 if ( bins1.length != 4 ) {
4018 if ( bins1[ 0 ] != 2 ) {
4021 if ( bins1[ 1 ] != 3 ) {
4024 if ( bins1[ 2 ] != 0 ) {
4027 if ( bins1[ 3 ] != 4 ) {
4030 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4031 if ( bins1_1.length != 3 ) {
4034 if ( bins1_1[ 0 ] != 3 ) {
4037 if ( bins1_1[ 1 ] != 2 ) {
4040 if ( bins1_1[ 2 ] != 4 ) {
4043 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4044 if ( bins1_2.length != 3 ) {
4047 if ( bins1_2[ 0 ] != 2 ) {
4050 if ( bins1_2[ 1 ] != 2 ) {
4053 if ( bins1_2[ 2 ] != 2 ) {
4056 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4070 dss3.addValue( 10 );
4071 dss3.addValue( 10 );
4072 dss3.addValue( 10 );
4073 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4074 histo.toStringBuffer( 10, '=', 40, 5 );
4075 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4077 catch ( final Exception e ) {
4078 e.printStackTrace( System.out );
4084 private static boolean testDir( final String file ) {
4086 final File f = new File( file );
4087 if ( !f.exists() ) {
4090 if ( !f.isDirectory() ) {
4093 if ( !f.canRead() ) {
4097 catch ( final Exception e ) {
4103 private static boolean testEbiEntryRetrieval() {
4105 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4106 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4107 System.out.println( entry.getAccession() );
4110 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4111 System.out.println( entry.getTaxonomyScientificName() );
4114 if ( !entry.getSequenceName()
4115 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4116 System.out.println( entry.getSequenceName() );
4119 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4120 System.out.println( entry.getGeneName() );
4123 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4124 System.out.println( entry.getTaxonomyIdentifier() );
4127 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4128 System.out.println( entry.getAnnotations().first().getRefValue() );
4131 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4132 System.out.println( entry.getAnnotations().first().getRefSource() );
4135 if ( entry.getCrossReferences().size() < 1 ) {
4138 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4139 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4142 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4143 System.out.println( entry1.getTaxonomyScientificName() );
4146 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4147 System.out.println( entry1.getSequenceName() );
4150 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4151 System.out.println( entry1.getTaxonomyIdentifier() );
4154 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4155 System.out.println( entry1.getGeneName() );
4158 if ( entry1.getCrossReferences().size() < 1 ) {
4161 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4162 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4165 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4166 System.out.println( entry2.getTaxonomyScientificName() );
4169 if ( !entry2.getSequenceName()
4170 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4171 System.out.println( entry2.getSequenceName() );
4174 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4175 System.out.println( entry2.getTaxonomyIdentifier() );
4178 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4179 System.out.println( entry2.getGeneName() );
4182 if ( entry2.getCrossReferences().size() < 1 ) {
4185 if ( !entry2.getChromosome().equals( "20" ) ) {
4188 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4191 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4192 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4195 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4196 System.out.println( entry3.getTaxonomyScientificName() );
4199 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4200 System.out.println( entry3.getSequenceName() );
4203 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4204 System.out.println( entry3.getTaxonomyIdentifier() );
4207 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4208 System.out.println( entry3.getSequenceSymbol() );
4211 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4214 if ( entry3.getCrossReferences().size() < 1 ) {
4217 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4218 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4221 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4222 System.out.println( entry4.getTaxonomyScientificName() );
4225 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4226 System.out.println( entry4.getSequenceName() );
4229 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4230 System.out.println( entry4.getTaxonomyIdentifier() );
4233 if ( !entry4.getGeneName().equals( "ras" ) ) {
4234 System.out.println( entry4.getGeneName() );
4237 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4238 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4241 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4242 System.out.println( entry5.getTaxonomyScientificName() );
4245 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4246 System.out.println( entry5.getSequenceName() );
4249 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4250 System.out.println( entry5.getTaxonomyIdentifier() );
4253 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4254 if ( !entry6.getAccession().equals( "M30539" ) ) {
4257 if ( !entry6.getGeneName().equals( "ras" ) ) {
4260 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4263 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4266 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4269 if ( entry6.getCrossReferences().size() < 1 ) {
4273 catch ( final IOException e ) {
4274 System.out.println();
4275 System.out.println( "the following might be due to absence internet connection:" );
4276 e.printStackTrace( System.out );
4279 catch ( final Exception e ) {
4280 e.printStackTrace();
4286 private static boolean testExternalNodeRelatedMethods() {
4288 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4289 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4290 PhylogenyNode n = t1.getNode( "A" );
4291 n = n.getNextExternalNode();
4292 if ( !n.getName().equals( "B" ) ) {
4295 n = n.getNextExternalNode();
4296 if ( !n.getName().equals( "C" ) ) {
4299 n = n.getNextExternalNode();
4300 if ( !n.getName().equals( "D" ) ) {
4303 n = t1.getNode( "B" );
4304 while ( !n.isLastExternalNode() ) {
4305 n = n.getNextExternalNode();
4307 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4308 n = t2.getNode( "A" );
4309 n = n.getNextExternalNode();
4310 if ( !n.getName().equals( "B" ) ) {
4313 n = n.getNextExternalNode();
4314 if ( !n.getName().equals( "C" ) ) {
4317 n = n.getNextExternalNode();
4318 if ( !n.getName().equals( "D" ) ) {
4321 n = t2.getNode( "B" );
4322 while ( !n.isLastExternalNode() ) {
4323 n = n.getNextExternalNode();
4325 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4326 n = t3.getNode( "A" );
4327 n = n.getNextExternalNode();
4328 if ( !n.getName().equals( "B" ) ) {
4331 n = n.getNextExternalNode();
4332 if ( !n.getName().equals( "C" ) ) {
4335 n = n.getNextExternalNode();
4336 if ( !n.getName().equals( "D" ) ) {
4339 n = n.getNextExternalNode();
4340 if ( !n.getName().equals( "E" ) ) {
4343 n = n.getNextExternalNode();
4344 if ( !n.getName().equals( "F" ) ) {
4347 n = n.getNextExternalNode();
4348 if ( !n.getName().equals( "G" ) ) {
4351 n = n.getNextExternalNode();
4352 if ( !n.getName().equals( "H" ) ) {
4355 n = t3.getNode( "B" );
4356 while ( !n.isLastExternalNode() ) {
4357 n = n.getNextExternalNode();
4359 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4360 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4361 final PhylogenyNode node = iter.next();
4363 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4364 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4365 final PhylogenyNode node = iter.next();
4367 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4368 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4369 if ( !iter.next().getName().equals( "A" ) ) {
4372 if ( !iter.next().getName().equals( "B" ) ) {
4375 if ( !iter.next().getName().equals( "C" ) ) {
4378 if ( !iter.next().getName().equals( "D" ) ) {
4381 if ( !iter.next().getName().equals( "E" ) ) {
4384 if ( !iter.next().getName().equals( "F" ) ) {
4387 if ( iter.hasNext() ) {
4391 catch ( final Exception e ) {
4392 e.printStackTrace( System.out );
4398 private static boolean testExtractSNFromNodeName() {
4400 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4403 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4406 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4409 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4410 .equals( "Mus musculus musculus" ) ) {
4413 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4414 .equals( "Mus musculus musculus" ) ) {
4417 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4418 .equals( "Mus musculus musculus" ) ) {
4421 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4422 .equals( "Mus musculus musculus" ) ) {
4425 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4428 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4429 .equals( "Mus musculus musculus" ) ) {
4432 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4433 .equals( "Mus musculus musculus" ) ) {
4436 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4439 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4442 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4445 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4448 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4449 .equals( "Mus musculus musculus" ) ) {
4452 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4455 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4458 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4461 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4464 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4467 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4470 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4473 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4476 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4477 .equals( "Mus musculus" ) ) {
4480 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4481 .equals( "Mus musculus" ) ) {
4484 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4487 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4488 .equals( "Mus musculus musculus" ) ) {
4491 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4492 .equals( "Mus musculus musculus" ) ) {
4495 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4496 .equals( "Mus musculus musculus" ) ) {
4499 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4502 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4503 .equals( "Pilostyles mexicana" ) ) {
4506 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4507 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4510 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4511 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4514 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4515 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4518 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4519 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4522 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4523 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4526 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4527 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4530 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4531 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4534 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4535 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4538 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4539 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4542 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4543 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4546 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4547 .equals( "Escherichia coli (strain K12)" ) ) {
4550 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4551 .equals( "Escherichia coli (strain K12)" ) ) {
4554 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4555 .equals( "Escherichia coli (str. K12)" ) ) {
4558 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4559 .equals( "Escherichia coli (str. K12)" ) ) {
4562 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4563 .equals( "Escherichia coli (str. K12)" ) ) {
4566 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4567 .equals( "Escherichia coli (var. K12)" ) ) {
4570 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4571 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4574 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4575 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4579 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4580 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4583 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4584 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4588 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4589 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4592 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4593 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4596 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4597 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4600 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4603 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4606 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4609 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4610 .equals( "Macrocera sp." ) ) {
4613 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4616 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4617 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4620 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4621 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4624 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4625 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4628 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4629 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4633 catch ( final Exception e ) {
4634 e.printStackTrace( System.out );
4640 private static boolean testExtractTaxonomyDataFromNodeName() {
4642 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4643 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4646 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4647 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4650 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4651 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4654 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4655 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4658 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4659 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4662 n = new PhylogenyNode( "HNRPR_HUMAN" );
4663 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4666 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
4667 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4671 catch ( final Exception e ) {
4672 e.printStackTrace( System.out );
4678 private static boolean testExtractTaxonomyCodeFromNodeName() {
4680 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4683 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4684 .equals( "SOYBN" ) ) {
4687 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4688 .equals( "ARATH" ) ) {
4691 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4692 .equals( "ARATH" ) ) {
4695 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4698 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4701 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4704 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4705 .equals( "SOYBN" ) ) {
4708 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4709 .equals( "SOYBN" ) ) {
4712 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4713 .equals( "SOYBN" ) ) {
4716 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4717 .equals( "SOYBN" ) ) {
4720 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4721 .equals( "SOYBN" ) ) {
4724 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4725 .equals( "SOYBN" ) ) {
4728 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4729 .equals( "SOYBN" ) ) {
4732 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4733 .equals( "SOYBN" ) ) {
4736 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4739 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4740 .equals( "SOYBN" ) ) {
4743 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4744 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4747 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4748 .equals( "9YX45" ) ) {
4751 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4752 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4753 .equals( "MOUSE" ) ) {
4756 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4757 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4758 .equals( "MOUSE" ) ) {
4761 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4762 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4763 .equals( "MOUSE" ) ) {
4766 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4767 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4770 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4771 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4774 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4775 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4778 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4779 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4782 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4783 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4786 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4787 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4790 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4791 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4794 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4795 .equals( "RAT" ) ) {
4798 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4799 .equals( "PIG" ) ) {
4803 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4804 .equals( "MOUSE" ) ) {
4807 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4808 .equals( "MOUSE" ) ) {
4811 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4815 catch ( final Exception e ) {
4816 e.printStackTrace( System.out );
4822 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4824 PhylogenyNode n = new PhylogenyNode();
4825 n.setName( "tr|B3RJ64" );
4826 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4829 n.setName( "tr.B3RJ64" );
4830 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4833 n.setName( "tr=B3RJ64" );
4834 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4837 n.setName( "tr-B3RJ64" );
4838 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4841 n.setName( "tr/B3RJ64" );
4842 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4845 n.setName( "tr\\B3RJ64" );
4846 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4849 n.setName( "tr_B3RJ64" );
4850 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4853 n.setName( " tr|B3RJ64 " );
4854 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4857 n.setName( "-tr|B3RJ64-" );
4858 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4861 n.setName( "-tr=B3RJ64-" );
4862 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4865 n.setName( "_tr=B3RJ64_" );
4866 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4869 n.setName( " tr_tr|B3RJ64_sp|123 " );
4870 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4873 n.setName( "B3RJ64" );
4874 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4877 n.setName( "sp|B3RJ64" );
4878 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4881 n.setName( "sp|B3RJ64C" );
4882 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4885 n.setName( "sp B3RJ64" );
4886 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4889 n.setName( "sp|B3RJ6X" );
4890 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4893 n.setName( "sp|B3RJ6" );
4894 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4897 n.setName( "K1PYK7_CRAGI" );
4898 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4901 n.setName( "K1PYK7_PEA" );
4902 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4905 n.setName( "K1PYK7_RAT" );
4906 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4909 n.setName( "K1PYK7_PIG" );
4910 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4913 n.setName( "~K1PYK7_PIG~" );
4914 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4917 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4918 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4921 n.setName( "K1PYKX_CRAGI" );
4922 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4925 n.setName( "XXXXX_CRAGI" );
4926 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4929 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4930 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4933 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4934 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4937 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4938 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4941 n = new PhylogenyNode();
4942 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4943 seq.setSymbol( "K1PYK7_CRAGI" );
4944 n.getNodeData().addSequence( seq );
4945 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4948 seq.setSymbol( "tr|B3RJ64" );
4949 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4952 n = new PhylogenyNode();
4953 seq = new org.forester.phylogeny.data.Sequence();
4954 seq.setName( "K1PYK7_CRAGI" );
4955 n.getNodeData().addSequence( seq );
4956 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4959 seq.setName( "tr|B3RJ64" );
4960 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4963 n = new PhylogenyNode();
4964 seq = new org.forester.phylogeny.data.Sequence();
4965 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4966 n.getNodeData().addSequence( seq );
4967 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4970 n = new PhylogenyNode();
4971 seq = new org.forester.phylogeny.data.Sequence();
4972 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4973 n.getNodeData().addSequence( seq );
4974 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4978 n = new PhylogenyNode();
4979 n.setName( "ACP19736" );
4980 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4983 n = new PhylogenyNode();
4984 n.setName( "|ACP19736|" );
4985 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4989 catch ( final Exception e ) {
4990 e.printStackTrace( System.out );
4996 private static boolean testFastaParser() {
4998 FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
4999 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5006 FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5007 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5014 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5015 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5018 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5021 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5024 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5027 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5030 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5034 catch ( final Exception e ) {
5035 e.printStackTrace();
5041 private static boolean testGenbankAccessorParsing() {
5042 //The format for GenBank Accession numbers are:
5043 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5044 //Protein: 3 letters + 5 numerals
5045 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5046 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5049 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5052 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
5055 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5058 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5061 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5064 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5067 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5070 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5073 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5076 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5079 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5082 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5085 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5091 private static boolean testGeneralMsaParser() {
5093 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5094 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5095 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5096 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5097 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5098 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5099 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5100 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5101 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5104 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5107 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5110 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5113 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5116 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5119 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5122 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5125 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5128 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5131 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5134 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5137 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5138 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5141 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5144 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5147 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5148 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5151 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5154 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5157 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5158 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5161 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5164 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5168 catch ( final Exception e ) {
5169 e.printStackTrace();
5175 private static boolean testGeneralTable() {
5177 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5178 t0.setValue( 3, 2, "23" );
5179 t0.setValue( 10, 1, "error" );
5180 t0.setValue( 10, 1, "110" );
5181 t0.setValue( 9, 1, "19" );
5182 t0.setValue( 1, 10, "101" );
5183 t0.setValue( 10, 10, "1010" );
5184 t0.setValue( 100, 10, "10100" );
5185 t0.setValue( 0, 0, "00" );
5186 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5189 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5192 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5195 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5198 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5201 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5204 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5207 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5210 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5213 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5214 t1.setValue( "3", "2", "23" );
5215 t1.setValue( "10", "1", "error" );
5216 t1.setValue( "10", "1", "110" );
5217 t1.setValue( "9", "1", "19" );
5218 t1.setValue( "1", "10", "101" );
5219 t1.setValue( "10", "10", "1010" );
5220 t1.setValue( "100", "10", "10100" );
5221 t1.setValue( "0", "0", "00" );
5222 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5223 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5226 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5229 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5232 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5235 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5238 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5241 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5244 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5247 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5250 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5254 catch ( final Exception e ) {
5255 e.printStackTrace( System.out );
5261 private static boolean testGetDistance() {
5263 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5264 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",
5265 new NHXParser() )[ 0 ];
5266 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5269 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5272 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5275 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5278 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5281 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5284 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5287 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5290 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5293 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5296 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5299 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5302 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5305 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5308 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5311 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5314 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5317 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5320 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5323 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5326 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5329 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5332 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5335 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5338 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5341 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5344 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5347 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5350 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5353 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5356 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5359 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",
5360 new NHXParser() )[ 0 ];
5361 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5364 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5367 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5370 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5373 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5376 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5379 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5382 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5385 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5388 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5391 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5395 catch ( final Exception e ) {
5396 e.printStackTrace( System.out );
5402 private static boolean testGetLCA() {
5404 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5405 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5406 new NHXParser() )[ 0 ];
5407 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5408 if ( !A.getName().equals( "A" ) ) {
5411 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5412 if ( !gh.getName().equals( "gh" ) ) {
5415 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5416 if ( !ab.getName().equals( "ab" ) ) {
5419 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5420 if ( !ab2.getName().equals( "ab" ) ) {
5423 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5424 if ( !gh2.getName().equals( "gh" ) ) {
5427 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5428 if ( !gh3.getName().equals( "gh" ) ) {
5431 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5432 if ( !abc.getName().equals( "abc" ) ) {
5435 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5436 if ( !abc2.getName().equals( "abc" ) ) {
5439 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5440 if ( !abcd.getName().equals( "abcd" ) ) {
5443 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5444 if ( !abcd2.getName().equals( "abcd" ) ) {
5447 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5448 if ( !abcdef.getName().equals( "abcdef" ) ) {
5451 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5452 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5455 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5456 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5459 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5460 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5463 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5464 if ( !abcde.getName().equals( "abcde" ) ) {
5467 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5468 if ( !abcde2.getName().equals( "abcde" ) ) {
5471 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5472 if ( !r.getName().equals( "abcdefgh" ) ) {
5475 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5476 if ( !r2.getName().equals( "abcdefgh" ) ) {
5479 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5480 if ( !r3.getName().equals( "abcdefgh" ) ) {
5483 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5484 if ( !abcde3.getName().equals( "abcde" ) ) {
5487 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5488 if ( !abcde4.getName().equals( "abcde" ) ) {
5491 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5492 if ( !ab3.getName().equals( "ab" ) ) {
5495 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5496 if ( !ab4.getName().equals( "ab" ) ) {
5499 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5500 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5501 if ( !cd.getName().equals( "cd" ) ) {
5504 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5505 if ( !cd2.getName().equals( "cd" ) ) {
5508 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5509 if ( !cde.getName().equals( "cde" ) ) {
5512 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5513 if ( !cde2.getName().equals( "cde" ) ) {
5516 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5517 if ( !cdef.getName().equals( "cdef" ) ) {
5520 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5521 if ( !cdef2.getName().equals( "cdef" ) ) {
5524 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5525 if ( !cdef3.getName().equals( "cdef" ) ) {
5528 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5529 if ( !rt.getName().equals( "r" ) ) {
5532 final Phylogeny p3 = factory
5533 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5534 new NHXParser() )[ 0 ];
5535 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5536 if ( !bc_3.getName().equals( "bc" ) ) {
5539 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5540 if ( !ac_3.getName().equals( "abc" ) ) {
5543 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5544 if ( !ad_3.getName().equals( "abcde" ) ) {
5547 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5548 if ( !af_3.getName().equals( "abcdef" ) ) {
5551 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5552 if ( !ag_3.getName().equals( "" ) ) {
5555 if ( !ag_3.isRoot() ) {
5558 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5559 if ( !al_3.getName().equals( "" ) ) {
5562 if ( !al_3.isRoot() ) {
5565 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5566 if ( !kl_3.getName().equals( "" ) ) {
5569 if ( !kl_3.isRoot() ) {
5572 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5573 if ( !fl_3.getName().equals( "" ) ) {
5576 if ( !fl_3.isRoot() ) {
5579 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5580 if ( !gk_3.getName().equals( "ghijk" ) ) {
5583 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5584 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5585 if ( !r_4.getName().equals( "r" ) ) {
5588 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5589 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5590 if ( !r_5.getName().equals( "root" ) ) {
5593 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5594 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5595 if ( !r_6.getName().equals( "rot" ) ) {
5598 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5599 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5600 if ( !r_7.getName().equals( "rott" ) ) {
5604 catch ( final Exception e ) {
5605 e.printStackTrace( System.out );
5611 private static boolean testGetLCA2() {
5613 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5614 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5615 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5616 PhylogenyMethods.preOrderReId( p_a );
5617 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5618 p_a.getNode( "a" ) );
5619 if ( !p_a_1.getName().equals( "a" ) ) {
5622 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5623 PhylogenyMethods.preOrderReId( p_b );
5624 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5625 p_b.getNode( "a" ) );
5626 if ( !p_b_1.getName().equals( "b" ) ) {
5629 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5630 p_b.getNode( "b" ) );
5631 if ( !p_b_2.getName().equals( "b" ) ) {
5634 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5635 PhylogenyMethods.preOrderReId( p_c );
5636 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5637 p_c.getNode( "a" ) );
5638 if ( !p_c_1.getName().equals( "b" ) ) {
5641 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5642 p_c.getNode( "c" ) );
5643 if ( !p_c_2.getName().equals( "c" ) ) {
5644 System.out.println( p_c_2.getName() );
5648 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5649 p_c.getNode( "b" ) );
5650 if ( !p_c_3.getName().equals( "b" ) ) {
5653 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5654 p_c.getNode( "a" ) );
5655 if ( !p_c_4.getName().equals( "c" ) ) {
5658 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5659 new NHXParser() )[ 0 ];
5660 PhylogenyMethods.preOrderReId( p1 );
5661 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5662 p1.getNode( "A" ) );
5663 if ( !A.getName().equals( "A" ) ) {
5666 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5667 p1.getNode( "gh" ) );
5668 if ( !gh.getName().equals( "gh" ) ) {
5671 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5672 p1.getNode( "B" ) );
5673 if ( !ab.getName().equals( "ab" ) ) {
5676 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5677 p1.getNode( "A" ) );
5678 if ( !ab2.getName().equals( "ab" ) ) {
5681 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5682 p1.getNode( "G" ) );
5683 if ( !gh2.getName().equals( "gh" ) ) {
5686 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5687 p1.getNode( "H" ) );
5688 if ( !gh3.getName().equals( "gh" ) ) {
5691 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5692 p1.getNode( "A" ) );
5693 if ( !abc.getName().equals( "abc" ) ) {
5696 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5697 p1.getNode( "C" ) );
5698 if ( !abc2.getName().equals( "abc" ) ) {
5701 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5702 p1.getNode( "D" ) );
5703 if ( !abcd.getName().equals( "abcd" ) ) {
5706 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5707 p1.getNode( "A" ) );
5708 if ( !abcd2.getName().equals( "abcd" ) ) {
5711 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5712 p1.getNode( "F" ) );
5713 if ( !abcdef.getName().equals( "abcdef" ) ) {
5716 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5717 p1.getNode( "A" ) );
5718 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5721 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5722 p1.getNode( "F" ) );
5723 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5726 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5727 p1.getNode( "ab" ) );
5728 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5731 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5732 p1.getNode( "E" ) );
5733 if ( !abcde.getName().equals( "abcde" ) ) {
5736 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5737 p1.getNode( "A" ) );
5738 if ( !abcde2.getName().equals( "abcde" ) ) {
5741 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5742 p1.getNode( "abcdefgh" ) );
5743 if ( !r.getName().equals( "abcdefgh" ) ) {
5746 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5747 p1.getNode( "H" ) );
5748 if ( !r2.getName().equals( "abcdefgh" ) ) {
5751 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5752 p1.getNode( "A" ) );
5753 if ( !r3.getName().equals( "abcdefgh" ) ) {
5756 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5757 p1.getNode( "abcde" ) );
5758 if ( !abcde3.getName().equals( "abcde" ) ) {
5761 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5762 p1.getNode( "E" ) );
5763 if ( !abcde4.getName().equals( "abcde" ) ) {
5766 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5767 p1.getNode( "B" ) );
5768 if ( !ab3.getName().equals( "ab" ) ) {
5771 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5772 p1.getNode( "ab" ) );
5773 if ( !ab4.getName().equals( "ab" ) ) {
5776 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5777 PhylogenyMethods.preOrderReId( p2 );
5778 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5779 p2.getNode( "d" ) );
5780 if ( !cd.getName().equals( "cd" ) ) {
5783 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5784 p2.getNode( "c" ) );
5785 if ( !cd2.getName().equals( "cd" ) ) {
5788 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5789 p2.getNode( "e" ) );
5790 if ( !cde.getName().equals( "cde" ) ) {
5793 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5794 p2.getNode( "c" ) );
5795 if ( !cde2.getName().equals( "cde" ) ) {
5798 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5799 p2.getNode( "f" ) );
5800 if ( !cdef.getName().equals( "cdef" ) ) {
5803 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5804 p2.getNode( "f" ) );
5805 if ( !cdef2.getName().equals( "cdef" ) ) {
5808 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5809 p2.getNode( "d" ) );
5810 if ( !cdef3.getName().equals( "cdef" ) ) {
5813 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5814 p2.getNode( "a" ) );
5815 if ( !rt.getName().equals( "r" ) ) {
5818 final Phylogeny p3 = factory
5819 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5820 new NHXParser() )[ 0 ];
5821 PhylogenyMethods.preOrderReId( p3 );
5822 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5823 p3.getNode( "c" ) );
5824 if ( !bc_3.getName().equals( "bc" ) ) {
5827 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5828 p3.getNode( "c" ) );
5829 if ( !ac_3.getName().equals( "abc" ) ) {
5832 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5833 p3.getNode( "d" ) );
5834 if ( !ad_3.getName().equals( "abcde" ) ) {
5837 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5838 p3.getNode( "f" ) );
5839 if ( !af_3.getName().equals( "abcdef" ) ) {
5842 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5843 p3.getNode( "g" ) );
5844 if ( !ag_3.getName().equals( "" ) ) {
5847 if ( !ag_3.isRoot() ) {
5850 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5851 p3.getNode( "l" ) );
5852 if ( !al_3.getName().equals( "" ) ) {
5855 if ( !al_3.isRoot() ) {
5858 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5859 p3.getNode( "l" ) );
5860 if ( !kl_3.getName().equals( "" ) ) {
5863 if ( !kl_3.isRoot() ) {
5866 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5867 p3.getNode( "l" ) );
5868 if ( !fl_3.getName().equals( "" ) ) {
5871 if ( !fl_3.isRoot() ) {
5874 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5875 p3.getNode( "k" ) );
5876 if ( !gk_3.getName().equals( "ghijk" ) ) {
5879 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5880 PhylogenyMethods.preOrderReId( p4 );
5881 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5882 p4.getNode( "c" ) );
5883 if ( !r_4.getName().equals( "r" ) ) {
5886 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5887 PhylogenyMethods.preOrderReId( p5 );
5888 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5889 p5.getNode( "c" ) );
5890 if ( !r_5.getName().equals( "root" ) ) {
5893 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5894 PhylogenyMethods.preOrderReId( p6 );
5895 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5896 p6.getNode( "a" ) );
5897 if ( !r_6.getName().equals( "rot" ) ) {
5900 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5901 PhylogenyMethods.preOrderReId( p7 );
5902 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5903 p7.getNode( "e" ) );
5904 if ( !r_7.getName().equals( "rott" ) ) {
5907 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5908 p7.getNode( "a" ) );
5909 if ( !r_71.getName().equals( "rott" ) ) {
5912 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5913 p7.getNode( "rott" ) );
5914 if ( !r_72.getName().equals( "rott" ) ) {
5917 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5918 p7.getNode( "a" ) );
5919 if ( !r_73.getName().equals( "rott" ) ) {
5922 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5923 p7.getNode( "rott" ) );
5924 if ( !r_74.getName().equals( "rott" ) ) {
5927 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5928 p7.getNode( "e" ) );
5929 if ( !r_75.getName().equals( "e" ) ) {
5933 catch ( final Exception e ) {
5934 e.printStackTrace( System.out );
5940 private static boolean testHmmscanOutputParser() {
5941 final String test_dir = Test.PATH_TO_TEST_DATA;
5943 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5944 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5946 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5947 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5948 final List<Protein> proteins = parser2.parse();
5949 if ( parser2.getProteinsEncountered() != 4 ) {
5952 if ( proteins.size() != 4 ) {
5955 if ( parser2.getDomainsEncountered() != 69 ) {
5958 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5961 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5964 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5967 final Protein p1 = proteins.get( 0 );
5968 if ( p1.getNumberOfProteinDomains() != 15 ) {
5971 if ( p1.getLength() != 850 ) {
5974 final Protein p2 = proteins.get( 1 );
5975 if ( p2.getNumberOfProteinDomains() != 51 ) {
5978 if ( p2.getLength() != 1291 ) {
5981 final Protein p3 = proteins.get( 2 );
5982 if ( p3.getNumberOfProteinDomains() != 2 ) {
5985 final Protein p4 = proteins.get( 3 );
5986 if ( p4.getNumberOfProteinDomains() != 1 ) {
5989 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5992 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5995 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5998 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6001 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6004 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6007 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6011 catch ( final Exception e ) {
6012 e.printStackTrace( System.out );
6018 private static boolean testLastExternalNodeMethods() {
6020 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6021 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6022 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6023 final PhylogenyNode n1 = t0.getNode( "A" );
6024 if ( n1.isLastExternalNode() ) {
6027 final PhylogenyNode n2 = t0.getNode( "B" );
6028 if ( n2.isLastExternalNode() ) {
6031 final PhylogenyNode n3 = t0.getNode( "C" );
6032 if ( n3.isLastExternalNode() ) {
6035 final PhylogenyNode n4 = t0.getNode( "D" );
6036 if ( !n4.isLastExternalNode() ) {
6040 catch ( final Exception e ) {
6041 e.printStackTrace( System.out );
6047 private static boolean testLevelOrderIterator() {
6049 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6050 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6051 PhylogenyNodeIterator it0;
6052 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6055 for( it0.reset(); it0.hasNext(); ) {
6058 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6059 if ( !it.next().getName().equals( "r" ) ) {
6062 if ( !it.next().getName().equals( "ab" ) ) {
6065 if ( !it.next().getName().equals( "cd" ) ) {
6068 if ( !it.next().getName().equals( "A" ) ) {
6071 if ( !it.next().getName().equals( "B" ) ) {
6074 if ( !it.next().getName().equals( "C" ) ) {
6077 if ( !it.next().getName().equals( "D" ) ) {
6080 if ( it.hasNext() ) {
6083 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",
6084 new NHXParser() )[ 0 ];
6085 PhylogenyNodeIterator it2;
6086 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6089 for( it2.reset(); it2.hasNext(); ) {
6092 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6093 if ( !it3.next().getName().equals( "r" ) ) {
6096 if ( !it3.next().getName().equals( "abc" ) ) {
6099 if ( !it3.next().getName().equals( "defg" ) ) {
6102 if ( !it3.next().getName().equals( "A" ) ) {
6105 if ( !it3.next().getName().equals( "B" ) ) {
6108 if ( !it3.next().getName().equals( "C" ) ) {
6111 if ( !it3.next().getName().equals( "D" ) ) {
6114 if ( !it3.next().getName().equals( "E" ) ) {
6117 if ( !it3.next().getName().equals( "F" ) ) {
6120 if ( !it3.next().getName().equals( "G" ) ) {
6123 if ( !it3.next().getName().equals( "1" ) ) {
6126 if ( !it3.next().getName().equals( "2" ) ) {
6129 if ( !it3.next().getName().equals( "3" ) ) {
6132 if ( !it3.next().getName().equals( "4" ) ) {
6135 if ( !it3.next().getName().equals( "5" ) ) {
6138 if ( !it3.next().getName().equals( "6" ) ) {
6141 if ( !it3.next().getName().equals( "f1" ) ) {
6144 if ( !it3.next().getName().equals( "f2" ) ) {
6147 if ( !it3.next().getName().equals( "f3" ) ) {
6150 if ( !it3.next().getName().equals( "a" ) ) {
6153 if ( !it3.next().getName().equals( "b" ) ) {
6156 if ( !it3.next().getName().equals( "f21" ) ) {
6159 if ( !it3.next().getName().equals( "X" ) ) {
6162 if ( !it3.next().getName().equals( "Y" ) ) {
6165 if ( !it3.next().getName().equals( "Z" ) ) {
6168 if ( it3.hasNext() ) {
6171 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6172 PhylogenyNodeIterator it4;
6173 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6176 for( it4.reset(); it4.hasNext(); ) {
6179 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6180 if ( !it5.next().getName().equals( "r" ) ) {
6183 if ( !it5.next().getName().equals( "A" ) ) {
6186 if ( !it5.next().getName().equals( "B" ) ) {
6189 if ( !it5.next().getName().equals( "C" ) ) {
6192 if ( !it5.next().getName().equals( "D" ) ) {
6195 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6196 PhylogenyNodeIterator it6;
6197 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6200 for( it6.reset(); it6.hasNext(); ) {
6203 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6204 if ( !it7.next().getName().equals( "A" ) ) {
6207 if ( it.hasNext() ) {
6211 catch ( final Exception e ) {
6212 e.printStackTrace( System.out );
6218 private static boolean testMafft( final String path ) {
6220 final List<String> opts = new ArrayList<String>();
6221 opts.add( "--maxiterate" );
6223 opts.add( "--localpair" );
6224 opts.add( "--quiet" );
6226 final MsaInferrer mafft = Mafft.createInstance( path );
6227 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6228 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6231 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6235 catch ( final Exception e ) {
6236 e.printStackTrace( System.out );
6242 private static boolean testMidpointrooting() {
6244 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6245 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6246 PhylogenyMethods.midpointRoot( t0 );
6247 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6250 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6253 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6257 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",
6258 new NHXParser() )[ 0 ];
6259 if ( !t1.isRooted() ) {
6262 PhylogenyMethods.midpointRoot( t1 );
6263 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6266 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6269 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6272 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6275 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6278 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6281 t1.reRoot( t1.getNode( "A" ) );
6282 PhylogenyMethods.midpointRoot( t1 );
6283 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6286 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6289 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6292 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6295 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6299 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6303 catch ( final Exception e ) {
6304 e.printStackTrace( System.out );
6310 private static boolean testMsaQualityMethod() {
6312 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6313 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6314 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6315 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6316 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6321 final Msa msa = BasicMsa.createInstance( l );
6322 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6325 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6328 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6331 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6334 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6337 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6340 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6344 catch ( final Exception e ) {
6345 e.printStackTrace( System.out );
6351 private static boolean testMsaEntropy() {
6353 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6354 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6355 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6356 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6357 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6362 final Msa msa = BasicMsa.createInstance( l );
6363 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6365 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6366 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6367 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6368 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6369 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6370 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6371 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6372 // System.out.println();
6373 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6374 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6375 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6376 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6377 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6378 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6379 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6380 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6381 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6382 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6383 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6384 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6385 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6386 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6387 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6388 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6389 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6390 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6391 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6392 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6393 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6394 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6395 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6396 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6397 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6398 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6399 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6400 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6401 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6402 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6403 final Msa msa2 = BasicMsa.createInstance( l2 );
6404 // System.out.println();
6405 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6406 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6407 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6409 catch ( final Exception e ) {
6410 e.printStackTrace( System.out );
6416 private static boolean testDeleteableMsa() {
6418 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6419 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6420 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6421 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6422 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6423 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6424 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6431 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6432 dmsa0.deleteRow( "b", false );
6433 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6436 dmsa0.deleteRow( "e", false );
6437 dmsa0.deleteRow( "a", false );
6438 dmsa0.deleteRow( "f", false );
6439 if ( dmsa0.getLength() != 4 ) {
6442 if ( dmsa0.getNumberOfSequences() != 2 ) {
6445 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6448 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6451 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6454 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6457 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6460 dmsa0.deleteRow( "c", false );
6461 dmsa0.deleteRow( "d", false );
6462 if ( dmsa0.getNumberOfSequences() != 0 ) {
6466 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6467 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6468 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6469 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6470 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6471 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6472 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6479 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6480 dmsa1.deleteGapOnlyColumns();
6481 dmsa1.deleteRow( "a", false );
6482 dmsa1.deleteRow( "f", false );
6483 dmsa1.deleteRow( "d", false );
6484 dmsa1.deleteGapOnlyColumns();
6485 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6488 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6491 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6494 dmsa1.deleteRow( "c", false );
6495 dmsa1.deleteGapOnlyColumns();
6496 final Writer w0 = new StringWriter();
6497 dmsa1.write( w0, MSA_FORMAT.FASTA );
6498 final Writer w1 = new StringWriter();
6499 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6500 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6503 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6506 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6507 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6508 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6509 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6510 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6511 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6512 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6519 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6520 dmsa2.deleteGapColumns( 0.5 );
6521 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6524 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6527 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6530 dmsa2.deleteGapColumns( 0.2 );
6531 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6534 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6537 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6540 dmsa2.deleteGapColumns( 0 );
6541 dmsa2.deleteRow( "a", false );
6542 dmsa2.deleteRow( "b", false );
6543 dmsa2.deleteRow( "f", false );
6544 dmsa2.deleteRow( "e", false );
6545 dmsa2.setIdentifier( 0, "new_c" );
6546 dmsa2.setIdentifier( 1, "new_d" );
6547 dmsa2.setResidueAt( 0, 0, 'x' );
6548 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6549 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6552 final Writer w = new StringWriter();
6553 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6554 final String phylip = w.toString();
6555 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6556 System.out.println( phylip );
6559 final Writer w2 = new StringWriter();
6560 dmsa2.write( w2, MSA_FORMAT.FASTA );
6561 final String fasta = w2.toString();
6562 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6563 System.out.println( fasta );
6567 catch ( final Exception e ) {
6568 e.printStackTrace( System.out );
6574 private static boolean testNextNodeWithCollapsing() {
6576 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6578 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6579 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6580 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6581 t0.getNode( "cd" ).setCollapse( true );
6582 t0.getNode( "cde" ).setCollapse( true );
6583 n = t0.getFirstExternalNode();
6584 while ( n != null ) {
6586 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6588 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6591 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6594 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6597 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6600 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6603 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6607 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6608 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6609 t1.getNode( "ab" ).setCollapse( true );
6610 t1.getNode( "cd" ).setCollapse( true );
6611 t1.getNode( "cde" ).setCollapse( true );
6612 n = t1.getNode( "ab" );
6613 ext = new ArrayList<PhylogenyNode>();
6614 while ( n != null ) {
6616 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6618 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6621 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6624 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6627 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6630 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6634 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6635 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6636 t2.getNode( "ab" ).setCollapse( true );
6637 t2.getNode( "cd" ).setCollapse( true );
6638 t2.getNode( "cde" ).setCollapse( true );
6639 t2.getNode( "c" ).setCollapse( true );
6640 t2.getNode( "d" ).setCollapse( true );
6641 t2.getNode( "e" ).setCollapse( true );
6642 t2.getNode( "gh" ).setCollapse( true );
6643 n = t2.getNode( "ab" );
6644 ext = new ArrayList<PhylogenyNode>();
6645 while ( n != null ) {
6647 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6649 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6652 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6655 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6658 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6662 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6663 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6664 t3.getNode( "ab" ).setCollapse( true );
6665 t3.getNode( "cd" ).setCollapse( true );
6666 t3.getNode( "cde" ).setCollapse( true );
6667 t3.getNode( "c" ).setCollapse( true );
6668 t3.getNode( "d" ).setCollapse( true );
6669 t3.getNode( "e" ).setCollapse( true );
6670 t3.getNode( "gh" ).setCollapse( true );
6671 t3.getNode( "fgh" ).setCollapse( true );
6672 n = t3.getNode( "ab" );
6673 ext = new ArrayList<PhylogenyNode>();
6674 while ( n != null ) {
6676 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6678 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6681 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6684 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6688 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6689 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6690 t4.getNode( "ab" ).setCollapse( true );
6691 t4.getNode( "cd" ).setCollapse( true );
6692 t4.getNode( "cde" ).setCollapse( true );
6693 t4.getNode( "c" ).setCollapse( true );
6694 t4.getNode( "d" ).setCollapse( true );
6695 t4.getNode( "e" ).setCollapse( true );
6696 t4.getNode( "gh" ).setCollapse( true );
6697 t4.getNode( "fgh" ).setCollapse( true );
6698 t4.getNode( "abcdefgh" ).setCollapse( true );
6699 n = t4.getNode( "abcdefgh" );
6700 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6703 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6704 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6706 n = t5.getFirstExternalNode();
6707 while ( n != null ) {
6709 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6711 if ( ext.size() != 8 ) {
6714 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6717 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6720 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6723 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6726 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6729 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6732 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6735 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6738 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6739 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6741 t6.getNode( "ab" ).setCollapse( true );
6742 n = t6.getNode( "ab" );
6743 while ( n != null ) {
6745 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6747 if ( ext.size() != 7 ) {
6750 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6753 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6756 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6759 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6762 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6765 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6768 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6771 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6772 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6774 t7.getNode( "cd" ).setCollapse( true );
6775 n = t7.getNode( "a" );
6776 while ( n != null ) {
6778 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6780 if ( ext.size() != 7 ) {
6783 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6786 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6789 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6792 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6795 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6798 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6801 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6804 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6805 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6807 t8.getNode( "cd" ).setCollapse( true );
6808 t8.getNode( "c" ).setCollapse( true );
6809 t8.getNode( "d" ).setCollapse( true );
6810 n = t8.getNode( "a" );
6811 while ( n != null ) {
6813 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6815 if ( ext.size() != 7 ) {
6818 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6821 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6824 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6825 System.out.println( "2 fail" );
6828 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6831 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6834 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6837 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6840 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6841 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6843 t9.getNode( "gh" ).setCollapse( true );
6844 n = t9.getNode( "a" );
6845 while ( n != null ) {
6847 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6849 if ( ext.size() != 7 ) {
6852 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6855 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6858 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6861 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6864 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6867 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6870 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6873 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6874 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6876 t10.getNode( "gh" ).setCollapse( true );
6877 t10.getNode( "g" ).setCollapse( true );
6878 t10.getNode( "h" ).setCollapse( true );
6879 n = t10.getNode( "a" );
6880 while ( n != null ) {
6882 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6884 if ( ext.size() != 7 ) {
6887 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6890 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6893 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6896 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6899 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6902 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6905 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6908 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6909 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6911 t11.getNode( "gh" ).setCollapse( true );
6912 t11.getNode( "fgh" ).setCollapse( true );
6913 n = t11.getNode( "a" );
6914 while ( n != null ) {
6916 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6918 if ( ext.size() != 6 ) {
6921 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6924 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6927 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6930 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6933 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6936 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6939 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6940 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6942 t12.getNode( "gh" ).setCollapse( true );
6943 t12.getNode( "fgh" ).setCollapse( true );
6944 t12.getNode( "g" ).setCollapse( true );
6945 t12.getNode( "h" ).setCollapse( true );
6946 t12.getNode( "f" ).setCollapse( true );
6947 n = t12.getNode( "a" );
6948 while ( n != null ) {
6950 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6952 if ( ext.size() != 6 ) {
6955 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6958 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6961 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6964 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6967 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6970 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6973 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6974 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6976 t13.getNode( "ab" ).setCollapse( true );
6977 t13.getNode( "b" ).setCollapse( true );
6978 t13.getNode( "fgh" ).setCollapse( true );
6979 t13.getNode( "gh" ).setCollapse( true );
6980 n = t13.getNode( "ab" );
6981 while ( n != null ) {
6983 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6985 if ( ext.size() != 5 ) {
6988 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6991 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6994 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6997 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7000 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7003 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7004 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
7006 t14.getNode( "ab" ).setCollapse( true );
7007 t14.getNode( "a" ).setCollapse( true );
7008 t14.getNode( "fgh" ).setCollapse( true );
7009 t14.getNode( "gh" ).setCollapse( true );
7010 n = t14.getNode( "ab" );
7011 while ( n != null ) {
7013 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7015 if ( ext.size() != 5 ) {
7018 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7021 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7024 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7027 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7030 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7033 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" );
7034 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
7036 t15.getNode( "ab" ).setCollapse( true );
7037 t15.getNode( "a" ).setCollapse( true );
7038 t15.getNode( "fgh" ).setCollapse( true );
7039 t15.getNode( "gh" ).setCollapse( true );
7040 n = t15.getNode( "ab" );
7041 while ( n != null ) {
7043 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7045 if ( ext.size() != 6 ) {
7048 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7051 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7054 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7057 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7060 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7063 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7068 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" );
7069 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
7071 t16.getNode( "ab" ).setCollapse( true );
7072 t16.getNode( "a" ).setCollapse( true );
7073 t16.getNode( "fgh" ).setCollapse( true );
7074 t16.getNode( "gh" ).setCollapse( true );
7075 t16.getNode( "cd" ).setCollapse( true );
7076 t16.getNode( "cde" ).setCollapse( true );
7077 t16.getNode( "d" ).setCollapse( true );
7078 t16.getNode( "x" ).setCollapse( true );
7079 n = t16.getNode( "ab" );
7080 while ( n != null ) {
7082 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7084 if ( ext.size() != 4 ) {
7087 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7090 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7093 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7096 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7100 catch ( final Exception e ) {
7101 e.printStackTrace( System.out );
7107 private static boolean testNexusCharactersParsing() {
7109 final NexusCharactersParser parser = new NexusCharactersParser();
7110 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7112 String[] labels = parser.getCharStateLabels();
7113 if ( labels.length != 7 ) {
7116 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7119 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7122 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7125 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7128 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7131 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7134 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7137 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7139 labels = parser.getCharStateLabels();
7140 if ( labels.length != 7 ) {
7143 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7146 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7149 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7152 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7155 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7158 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7161 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7165 catch ( final Exception e ) {
7166 e.printStackTrace( System.out );
7172 private static boolean testNexusMatrixParsing() {
7174 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7175 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7177 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7178 if ( m.getNumberOfCharacters() != 9 ) {
7181 if ( m.getNumberOfIdentifiers() != 5 ) {
7184 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7187 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7190 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7193 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7196 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7199 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7202 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7205 // if ( labels.length != 7 ) {
7208 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7211 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7214 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7217 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7220 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7223 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7226 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7229 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7231 // labels = parser.getCharStateLabels();
7232 // if ( labels.length != 7 ) {
7235 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7238 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7241 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7244 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7247 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7250 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7253 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7257 catch ( final Exception e ) {
7258 e.printStackTrace( System.out );
7264 private static boolean testNexusTreeParsing() {
7266 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7267 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7268 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7269 if ( phylogenies.length != 1 ) {
7272 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7275 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7279 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7280 if ( phylogenies.length != 1 ) {
7283 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7286 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7290 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7291 if ( phylogenies.length != 1 ) {
7294 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7297 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7300 if ( phylogenies[ 0 ].isRooted() ) {
7304 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7305 if ( phylogenies.length != 18 ) {
7308 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7311 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7314 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7317 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7320 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7323 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7326 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7329 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7332 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7335 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7338 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7341 if ( phylogenies[ 8 ].isRooted() ) {
7344 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7347 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7350 if ( !phylogenies[ 9 ].isRooted() ) {
7353 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7356 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7359 if ( !phylogenies[ 10 ].isRooted() ) {
7362 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7365 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7368 if ( phylogenies[ 11 ].isRooted() ) {
7371 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7374 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7377 if ( !phylogenies[ 12 ].isRooted() ) {
7380 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7383 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7386 if ( !phylogenies[ 13 ].isRooted() ) {
7389 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7392 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7395 if ( !phylogenies[ 14 ].isRooted() ) {
7398 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7401 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7404 if ( phylogenies[ 15 ].isRooted() ) {
7407 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7410 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7413 if ( !phylogenies[ 16 ].isRooted() ) {
7416 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7419 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7422 if ( phylogenies[ 17 ].isRooted() ) {
7425 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7428 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7430 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7431 if ( phylogenies.length != 9 ) {
7434 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7435 .getDistanceToParent() ) ) {
7438 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7439 .getDistanceToParent() ) ) {
7442 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7445 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7448 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7451 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7454 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7458 catch ( final Exception e ) {
7459 e.printStackTrace( System.out );
7465 private static boolean testNexusTreeParsingIterating() {
7467 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7468 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7469 if ( !p.hasNext() ) {
7472 Phylogeny phy = p.next();
7473 if ( phy == null ) {
7476 if ( phy.getNumberOfExternalNodes() != 25 ) {
7479 if ( !phy.getName().equals( "" ) ) {
7482 if ( p.hasNext() ) {
7486 if ( phy != null ) {
7490 if ( !p.hasNext() ) {
7494 if ( phy == null ) {
7497 if ( phy.getNumberOfExternalNodes() != 25 ) {
7500 if ( !phy.getName().equals( "" ) ) {
7503 if ( p.hasNext() ) {
7507 if ( phy != null ) {
7510 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7511 if ( !p.hasNext() ) {
7515 if ( phy == null ) {
7518 if ( phy.getNumberOfExternalNodes() != 10 ) {
7521 if ( !phy.getName().equals( "name" ) ) {
7524 if ( p.hasNext() ) {
7528 if ( phy != null ) {
7532 if ( !p.hasNext() ) {
7536 if ( phy == null ) {
7539 if ( phy.getNumberOfExternalNodes() != 10 ) {
7542 if ( !phy.getName().equals( "name" ) ) {
7545 if ( p.hasNext() ) {
7549 if ( phy != null ) {
7552 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7553 if ( !p.hasNext() ) {
7557 if ( phy == null ) {
7560 if ( phy.getNumberOfExternalNodes() != 3 ) {
7563 if ( !phy.getName().equals( "" ) ) {
7566 if ( phy.isRooted() ) {
7569 if ( p.hasNext() ) {
7573 if ( phy != null ) {
7578 if ( !p.hasNext() ) {
7582 if ( phy == null ) {
7585 if ( phy.getNumberOfExternalNodes() != 3 ) {
7588 if ( !phy.getName().equals( "" ) ) {
7591 if ( p.hasNext() ) {
7595 if ( phy != null ) {
7599 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7600 if ( !p.hasNext() ) {
7605 if ( phy == null ) {
7608 if ( phy.getNumberOfExternalNodes() != 10 ) {
7611 if ( !phy.getName().equals( "tree 0" ) ) {
7615 if ( !p.hasNext() ) {
7619 if ( phy == null ) {
7622 if ( phy.getNumberOfExternalNodes() != 10 ) {
7625 if ( !phy.getName().equals( "tree 1" ) ) {
7629 if ( !p.hasNext() ) {
7633 if ( phy == null ) {
7636 if ( phy.getNumberOfExternalNodes() != 3 ) {
7637 System.out.println( phy.toString() );
7640 if ( !phy.getName().equals( "" ) ) {
7643 if ( phy.isRooted() ) {
7647 if ( !p.hasNext() ) {
7651 if ( phy == null ) {
7654 if ( phy.getNumberOfExternalNodes() != 4 ) {
7657 if ( !phy.getName().equals( "" ) ) {
7660 if ( !phy.isRooted() ) {
7664 if ( !p.hasNext() ) {
7668 if ( phy == null ) {
7671 if ( phy.getNumberOfExternalNodes() != 5 ) {
7672 System.out.println( phy.getNumberOfExternalNodes() );
7675 if ( !phy.getName().equals( "" ) ) {
7678 if ( !phy.isRooted() ) {
7682 if ( !p.hasNext() ) {
7686 if ( phy == null ) {
7689 if ( phy.getNumberOfExternalNodes() != 3 ) {
7692 if ( !phy.getName().equals( "" ) ) {
7695 if ( phy.isRooted() ) {
7699 if ( !p.hasNext() ) {
7703 if ( phy == null ) {
7706 if ( phy.getNumberOfExternalNodes() != 2 ) {
7709 if ( !phy.getName().equals( "" ) ) {
7712 if ( !phy.isRooted() ) {
7716 if ( !p.hasNext() ) {
7720 if ( phy.getNumberOfExternalNodes() != 3 ) {
7723 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7726 if ( !phy.isRooted() ) {
7730 if ( !p.hasNext() ) {
7734 if ( phy.getNumberOfExternalNodes() != 3 ) {
7737 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7740 if ( !phy.getName().equals( "tree 8" ) ) {
7744 if ( !p.hasNext() ) {
7748 if ( phy.getNumberOfExternalNodes() != 3 ) {
7751 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7754 if ( !phy.getName().equals( "tree 9" ) ) {
7758 if ( !p.hasNext() ) {
7762 if ( phy.getNumberOfExternalNodes() != 3 ) {
7765 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7768 if ( !phy.getName().equals( "tree 10" ) ) {
7771 if ( !phy.isRooted() ) {
7775 if ( !p.hasNext() ) {
7779 if ( phy.getNumberOfExternalNodes() != 3 ) {
7782 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7785 if ( !phy.getName().equals( "tree 11" ) ) {
7788 if ( phy.isRooted() ) {
7792 if ( !p.hasNext() ) {
7796 if ( phy.getNumberOfExternalNodes() != 3 ) {
7799 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7802 if ( !phy.getName().equals( "tree 12" ) ) {
7805 if ( !phy.isRooted() ) {
7809 if ( !p.hasNext() ) {
7813 if ( phy.getNumberOfExternalNodes() != 3 ) {
7816 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7819 if ( !phy.getName().equals( "tree 13" ) ) {
7822 if ( !phy.isRooted() ) {
7826 if ( !p.hasNext() ) {
7830 if ( phy.getNumberOfExternalNodes() != 10 ) {
7831 System.out.println( phy.getNumberOfExternalNodes() );
7836 .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;" ) ) {
7837 System.out.println( phy.toNewHampshire() );
7840 if ( !phy.getName().equals( "tree 14" ) ) {
7843 if ( !phy.isRooted() ) {
7847 if ( !p.hasNext() ) {
7851 if ( phy.getNumberOfExternalNodes() != 10 ) {
7852 System.out.println( phy.getNumberOfExternalNodes() );
7857 .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;" ) ) {
7858 System.out.println( phy.toNewHampshire() );
7861 if ( !phy.getName().equals( "tree 15" ) ) {
7864 if ( phy.isRooted() ) {
7868 if ( !p.hasNext() ) {
7872 if ( phy.getNumberOfExternalNodes() != 10 ) {
7873 System.out.println( phy.getNumberOfExternalNodes() );
7878 .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;" ) ) {
7879 System.out.println( phy.toNewHampshire() );
7882 if ( !phy.getName().equals( "tree 16" ) ) {
7885 if ( !phy.isRooted() ) {
7889 if ( !p.hasNext() ) {
7893 if ( phy.getNumberOfExternalNodes() != 10 ) {
7894 System.out.println( phy.getNumberOfExternalNodes() );
7899 .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;" ) ) {
7900 System.out.println( phy.toNewHampshire() );
7903 if ( !phy.getName().equals( "tree 17" ) ) {
7906 if ( phy.isRooted() ) {
7910 if ( p.hasNext() ) {
7914 if ( phy != null ) {
7919 if ( !p.hasNext() ) {
7923 if ( phy == null ) {
7926 if ( phy.getNumberOfExternalNodes() != 10 ) {
7929 if ( !phy.getName().equals( "tree 0" ) ) {
7933 if ( !p.hasNext() ) {
7937 if ( phy == null ) {
7940 if ( phy.getNumberOfExternalNodes() != 10 ) {
7943 if ( !phy.getName().equals( "tree 1" ) ) {
7947 if ( !p.hasNext() ) {
7951 if ( phy == null ) {
7954 if ( phy.getNumberOfExternalNodes() != 3 ) {
7957 if ( !phy.getName().equals( "" ) ) {
7960 if ( phy.isRooted() ) {
7964 if ( !p.hasNext() ) {
7968 if ( phy == null ) {
7971 if ( phy.getNumberOfExternalNodes() != 4 ) {
7974 if ( !phy.getName().equals( "" ) ) {
7977 if ( !phy.isRooted() ) {
7981 if ( !p.hasNext() ) {
7985 if ( phy == null ) {
7988 if ( phy.getNumberOfExternalNodes() != 5 ) {
7989 System.out.println( phy.getNumberOfExternalNodes() );
7992 if ( !phy.getName().equals( "" ) ) {
7995 if ( !phy.isRooted() ) {
7999 if ( !p.hasNext() ) {
8003 if ( phy == null ) {
8006 if ( phy.getNumberOfExternalNodes() != 3 ) {
8009 if ( !phy.getName().equals( "" ) ) {
8012 if ( phy.isRooted() ) {
8016 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8017 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8019 if ( !p2.hasNext() ) {
8023 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8026 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8030 if ( !p2.hasNext() ) {
8035 if ( !p2.hasNext() ) {
8040 if ( !p2.hasNext() ) {
8045 if ( !p2.hasNext() ) {
8050 if ( !p2.hasNext() ) {
8055 if ( !p2.hasNext() ) {
8060 if ( !p2.hasNext() ) {
8065 if ( !p2.hasNext() ) {
8069 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8072 if ( p2.hasNext() ) {
8076 if ( phy != null ) {
8081 if ( !p2.hasNext() ) {
8085 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8088 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8092 catch ( final Exception e ) {
8093 e.printStackTrace( System.out );
8099 private static boolean testNexusTreeParsingTranslating() {
8101 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8102 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8103 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8104 if ( phylogenies.length != 1 ) {
8107 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8110 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8113 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8116 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8119 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8120 .equals( "Aranaeus" ) ) {
8124 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8125 if ( phylogenies.length != 3 ) {
8128 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8131 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8134 if ( phylogenies[ 0 ].isRooted() ) {
8137 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8140 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8143 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8144 .equals( "Aranaeus" ) ) {
8147 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8150 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8153 if ( phylogenies[ 1 ].isRooted() ) {
8156 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8159 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8162 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8163 .equals( "Aranaeus" ) ) {
8166 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8169 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8172 if ( !phylogenies[ 2 ].isRooted() ) {
8175 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8178 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8181 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8182 .equals( "Aranaeus" ) ) {
8186 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8187 if ( phylogenies.length != 3 ) {
8190 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8193 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8196 if ( phylogenies[ 0 ].isRooted() ) {
8199 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8202 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8205 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8206 .equals( "Aranaeus" ) ) {
8209 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8212 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8215 if ( phylogenies[ 1 ].isRooted() ) {
8218 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8221 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8224 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8225 .equals( "Aranaeus" ) ) {
8228 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8231 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8234 if ( !phylogenies[ 2 ].isRooted() ) {
8237 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8240 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8243 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8244 .equals( "Aranaeus" ) ) {
8247 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8248 if ( phylogenies.length != 3 ) {
8251 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8256 catch ( final Exception e ) {
8257 e.printStackTrace( System.out );
8263 private static boolean testNHParsing() {
8265 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8266 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8267 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8270 final NHXParser nhxp = new NHXParser();
8271 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8272 nhxp.setReplaceUnderscores( true );
8273 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8274 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8277 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8280 final Phylogeny p1b = factory
8281 .create( " \n \t \b \r \f ; ( \n \t \b \r \f; A ; \n \t \b \r \f, \n \t \b \r \f; B ; \n \t \b \r \f 1 \n \t \b \r \f ; \n \t \b \r \f );;;;; \n \t \b \r \f;;; \n \t \b \r \f ",
8282 new NHXParser() )[ 0 ];
8283 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8286 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8289 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
8290 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8291 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8292 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
8293 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8294 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8295 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8296 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8297 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8298 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8299 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8300 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8301 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8303 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8306 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8309 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8312 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8315 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8316 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8317 final String p16_S = "((A,B),C)";
8318 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8319 if ( p16.length != 1 ) {
8322 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8325 final String p17_S = "(C,(A,B))";
8326 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8327 if ( p17.length != 1 ) {
8330 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8333 final String p18_S = "((A,B),(C,D))";
8334 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8335 if ( p18.length != 1 ) {
8338 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8341 final String p19_S = "(((A,B),C),D)";
8342 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8343 if ( p19.length != 1 ) {
8346 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8349 final String p20_S = "(A,(B,(C,D)))";
8350 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8351 if ( p20.length != 1 ) {
8354 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8357 final String p21_S = "(A,(B,(C,(D,E))))";
8358 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8359 if ( p21.length != 1 ) {
8362 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8365 final String p22_S = "((((A,B),C),D),E)";
8366 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8367 if ( p22.length != 1 ) {
8370 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8373 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8374 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8375 if ( p23.length != 1 ) {
8376 System.out.println( "xl=" + p23.length );
8380 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8383 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8384 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8385 if ( p24.length != 1 ) {
8388 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8391 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8392 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8393 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8394 if ( p241.length != 2 ) {
8397 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8400 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8403 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8404 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8405 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8406 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8407 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8408 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8409 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8410 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8411 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8412 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8415 final String p26_S = "(A,B)ab";
8416 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8417 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8420 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8421 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8422 if ( p27s.length != 1 ) {
8423 System.out.println( "xxl=" + p27s.length );
8427 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8428 System.out.println( p27s[ 0 ].toNewHampshireX() );
8432 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8434 if ( p27.length != 1 ) {
8435 System.out.println( "yl=" + p27.length );
8439 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8440 System.out.println( p27[ 0 ].toNewHampshireX() );
8444 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8445 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8446 final String p28_S3 = "(A,B)ab";
8447 final String p28_S4 = "((((A,B),C),D),;E;)";
8448 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8450 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8453 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8456 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8459 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8462 if ( p28.length != 4 ) {
8465 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";
8466 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8467 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8470 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";
8471 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8472 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8475 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8476 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8477 if ( ( p32.length != 0 ) ) {
8480 final String p33_S = "A";
8481 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8482 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8485 final String p34_S = "B;";
8486 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8487 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8490 final String p35_S = "B:0.2";
8491 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8492 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8495 final String p36_S = "(A)";
8496 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8497 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8500 final String p37_S = "((A))";
8501 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8502 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8505 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8506 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8507 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8510 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8511 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8512 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8515 final String p40_S = "(A,B,C)";
8516 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8517 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8520 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8521 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8522 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8525 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8526 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8527 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8530 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)";
8531 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8532 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8535 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)))";
8536 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8537 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8540 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8541 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8542 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8545 final String p46_S = "";
8546 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8547 if ( p46.length != 0 ) {
8550 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8551 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8554 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8555 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8558 final Phylogeny p49 = factory
8559 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8560 new NHXParser() )[ 0 ];
8561 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8564 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8565 if ( p50.getNode( "A" ) == null ) {
8568 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8569 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8572 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8575 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8576 .equals( "((A,B)88:2.0,C);" ) ) {
8579 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8580 if ( p51.getNode( "A(A" ) == null ) {
8583 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8584 if ( p52.getNode( "A(A" ) == null ) {
8587 final Phylogeny p53 = factory
8588 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8589 new NHXParser() )[ 0 ];
8590 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8593 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8594 if ( p54.getNode( "A" ) == null ) {
8597 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8600 final Phylogeny p55 = factory
8601 .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);" ),
8602 new NHXParser() )[ 0 ];
8605 .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);" ) ) {
8606 System.out.println( p55.toNewHampshire() );
8609 final Phylogeny p56 = factory
8610 .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);" ),
8611 new NHXParser() )[ 0 ];
8614 .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);" ) ) {
8615 System.out.println( p56.toNewHampshire() );
8618 final Phylogeny p57 = factory
8619 .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);" ),
8620 new NHXParser() )[ 0 ];
8623 .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);" ) ) {
8624 System.out.println( p56.toNewHampshire() );
8627 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8628 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8629 if ( !p58.toNewHampshire().equals( s58 ) ) {
8630 System.out.println( p58.toNewHampshire() );
8633 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8634 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8635 if ( !p59.toNewHampshire().equals( s59 ) ) {
8636 System.out.println( p59.toNewHampshire() );
8639 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8640 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8641 if ( !p60.toNewHampshire().equals( s60 ) ) {
8642 System.out.println( p60.toNewHampshire() );
8645 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8646 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8647 if ( !p61.toNewHampshire()
8648 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8649 System.out.println( p61.toNewHampshire() );
8653 catch ( final Exception e ) {
8654 e.printStackTrace( System.out );
8660 private static boolean testNHParsingIter() {
8662 final String p0_str = "(A,B);";
8663 final NHXParser p = new NHXParser();
8664 p.setSource( p0_str );
8665 if ( !p.hasNext() ) {
8668 final Phylogeny p0 = p.next();
8669 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8670 System.out.println( p0.toNewHampshire() );
8673 if ( p.hasNext() ) {
8676 if ( p.next() != null ) {
8680 final String p00_str = "(A,B)root;";
8681 p.setSource( p00_str );
8682 final Phylogeny p00 = p.next();
8683 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8684 System.out.println( p00.toNewHampshire() );
8688 final String p000_str = "A;";
8689 p.setSource( p000_str );
8690 final Phylogeny p000 = p.next();
8691 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8692 System.out.println( p000.toNewHampshire() );
8696 final String p0000_str = "A";
8697 p.setSource( p0000_str );
8698 final Phylogeny p0000 = p.next();
8699 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8700 System.out.println( p0000.toNewHampshire() );
8704 p.setSource( "(A)" );
8705 final Phylogeny p00000 = p.next();
8706 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8707 System.out.println( p00000.toNewHampshire() );
8711 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8712 p.setSource( p1_str );
8713 if ( !p.hasNext() ) {
8716 final Phylogeny p1_0 = p.next();
8717 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8718 System.out.println( p1_0.toNewHampshire() );
8721 if ( !p.hasNext() ) {
8724 final Phylogeny p1_1 = p.next();
8725 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8726 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8729 if ( !p.hasNext() ) {
8732 final Phylogeny p1_2 = p.next();
8733 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8734 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8737 if ( !p.hasNext() ) {
8740 final Phylogeny p1_3 = p.next();
8741 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8742 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8745 if ( p.hasNext() ) {
8748 if ( p.next() != null ) {
8752 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8753 p.setSource( p2_str );
8754 if ( !p.hasNext() ) {
8757 Phylogeny p2_0 = p.next();
8758 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8759 System.out.println( p2_0.toNewHampshire() );
8762 if ( !p.hasNext() ) {
8765 Phylogeny p2_1 = p.next();
8766 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8767 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8770 if ( !p.hasNext() ) {
8773 Phylogeny p2_2 = p.next();
8774 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8775 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8778 if ( !p.hasNext() ) {
8781 Phylogeny p2_3 = p.next();
8782 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8783 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8786 if ( !p.hasNext() ) {
8789 Phylogeny p2_4 = p.next();
8790 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8791 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8794 if ( p.hasNext() ) {
8797 if ( p.next() != null ) {
8802 if ( !p.hasNext() ) {
8806 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8807 System.out.println( p2_0.toNewHampshire() );
8810 if ( !p.hasNext() ) {
8814 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8815 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8818 if ( !p.hasNext() ) {
8822 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8823 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8826 if ( !p.hasNext() ) {
8830 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8831 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8834 if ( !p.hasNext() ) {
8838 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8839 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8842 if ( p.hasNext() ) {
8845 if ( p.next() != null ) {
8849 final String p3_str = "((A,B),C)abc";
8850 p.setSource( p3_str );
8851 if ( !p.hasNext() ) {
8854 final Phylogeny p3_0 = p.next();
8855 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8858 if ( p.hasNext() ) {
8861 if ( p.next() != null ) {
8865 final String p4_str = "((A,B)ab,C)abc";
8866 p.setSource( p4_str );
8867 if ( !p.hasNext() ) {
8870 final Phylogeny p4_0 = p.next();
8871 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8874 if ( p.hasNext() ) {
8877 if ( p.next() != null ) {
8881 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8882 p.setSource( p5_str );
8883 if ( !p.hasNext() ) {
8886 final Phylogeny p5_0 = p.next();
8887 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8890 if ( p.hasNext() ) {
8893 if ( p.next() != null ) {
8897 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8898 p.setSource( p6_str );
8899 if ( !p.hasNext() ) {
8902 Phylogeny p6_0 = p.next();
8903 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8906 if ( p.hasNext() ) {
8909 if ( p.next() != null ) {
8913 if ( !p.hasNext() ) {
8917 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8920 if ( p.hasNext() ) {
8923 if ( p.next() != null ) {
8927 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8928 p.setSource( p7_str );
8929 if ( !p.hasNext() ) {
8932 Phylogeny p7_0 = p.next();
8933 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8936 if ( p.hasNext() ) {
8939 if ( p.next() != null ) {
8943 if ( !p.hasNext() ) {
8947 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8950 if ( p.hasNext() ) {
8953 if ( p.next() != null ) {
8957 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8958 p.setSource( p8_str );
8959 if ( !p.hasNext() ) {
8962 Phylogeny p8_0 = p.next();
8963 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8966 if ( !p.hasNext() ) {
8969 if ( !p.hasNext() ) {
8972 Phylogeny p8_1 = p.next();
8973 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8976 if ( p.hasNext() ) {
8979 if ( p.next() != null ) {
8983 if ( !p.hasNext() ) {
8987 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8990 if ( !p.hasNext() ) {
8994 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8997 if ( p.hasNext() ) {
9000 if ( p.next() != null ) {
9006 if ( p.hasNext() ) {
9010 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9011 if ( !p.hasNext() ) {
9014 Phylogeny p_27 = p.next();
9015 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9016 System.out.println( p_27.toNewHampshireX() );
9020 if ( p.hasNext() ) {
9023 if ( p.next() != null ) {
9027 if ( !p.hasNext() ) {
9031 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9032 System.out.println( p_27.toNewHampshireX() );
9036 if ( p.hasNext() ) {
9039 if ( p.next() != null ) {
9043 final String p30_str = "(A,B);(C,D)";
9044 final NHXParser p30 = new NHXParser();
9045 p30.setSource( p30_str );
9046 if ( !p30.hasNext() ) {
9049 Phylogeny phy30 = p30.next();
9050 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9051 System.out.println( phy30.toNewHampshire() );
9054 if ( !p30.hasNext() ) {
9057 Phylogeny phy301 = p30.next();
9058 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9059 System.out.println( phy301.toNewHampshire() );
9062 if ( p30.hasNext() ) {
9065 if ( p30.hasNext() ) {
9068 if ( p30.next() != null ) {
9071 if ( p30.next() != null ) {
9075 if ( !p30.hasNext() ) {
9079 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9080 System.out.println( phy30.toNewHampshire() );
9083 if ( !p30.hasNext() ) {
9086 phy301 = p30.next();
9087 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9088 System.out.println( phy301.toNewHampshire() );
9091 if ( p30.hasNext() ) {
9094 if ( p30.hasNext() ) {
9097 if ( p30.next() != null ) {
9100 if ( p30.next() != null ) {
9104 catch ( final Exception e ) {
9105 e.printStackTrace( System.out );
9111 private static boolean testNHXconversion() {
9113 final PhylogenyNode n1 = new PhylogenyNode();
9114 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9115 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9116 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9117 final PhylogenyNode n5 = PhylogenyNode
9118 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9119 final PhylogenyNode n6 = PhylogenyNode
9120 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9121 if ( !n1.toNewHampshireX().equals( "" ) ) {
9124 if ( !n2.toNewHampshireX().equals( "" ) ) {
9127 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9130 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9133 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9136 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9137 System.out.println( n6.toNewHampshireX() );
9140 final PhylogenyNode n7 = new PhylogenyNode();
9141 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9142 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9143 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9144 System.out.println( n7
9145 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9149 catch ( final Exception e ) {
9150 e.printStackTrace( System.out );
9156 private static boolean testNHXNodeParsing() {
9158 final PhylogenyNode n1 = new PhylogenyNode();
9159 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9160 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9161 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9162 final PhylogenyNode n5 = PhylogenyNode
9163 .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]" );
9164 if ( !n3.getName().equals( "n3" ) ) {
9167 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9170 if ( n3.isDuplication() ) {
9173 if ( n3.isHasAssignedEvent() ) {
9176 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9179 if ( !n4.getName().equals( "n4" ) ) {
9182 if ( n4.getDistanceToParent() != 0.01 ) {
9185 if ( !n5.getName().equals( "n5" ) ) {
9188 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9191 if ( n5.getDistanceToParent() != 0.1 ) {
9194 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9197 if ( !n5.isDuplication() ) {
9200 if ( !n5.isHasAssignedEvent() ) {
9203 final PhylogenyNode n8 = PhylogenyNode
9204 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9205 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9206 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9209 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9212 final PhylogenyNode n9 = PhylogenyNode
9213 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9214 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9215 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9218 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9221 final PhylogenyNode n10 = PhylogenyNode
9222 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9223 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9226 final PhylogenyNode n20 = PhylogenyNode
9227 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9228 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9231 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9234 final PhylogenyNode n20x = PhylogenyNode
9235 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9236 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9239 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9242 final PhylogenyNode n20xx = PhylogenyNode
9243 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9244 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9247 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9250 final PhylogenyNode n20xxx = PhylogenyNode
9251 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9252 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9255 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9258 final PhylogenyNode n20xxxx = PhylogenyNode
9259 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9260 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9263 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9266 final PhylogenyNode n21 = PhylogenyNode
9267 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9268 if ( !n21.getName().equals( "N21_PIG" ) ) {
9271 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9274 final PhylogenyNode n21x = PhylogenyNode
9275 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9276 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9279 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9282 final PhylogenyNode n22 = PhylogenyNode
9283 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9284 if ( !n22.getName().equals( "n22/PIG" ) ) {
9287 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9290 final PhylogenyNode n23 = PhylogenyNode
9291 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9292 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9295 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9298 final PhylogenyNode a = PhylogenyNode
9299 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9300 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9303 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9306 final PhylogenyNode c1 = PhylogenyNode
9307 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9308 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9309 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9312 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9315 final PhylogenyNode c2 = PhylogenyNode
9316 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9317 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9318 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9321 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9324 final PhylogenyNode e3 = PhylogenyNode
9325 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9326 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9329 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9332 final PhylogenyNode n11 = PhylogenyNode
9333 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9334 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9335 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9338 if ( n11.getDistanceToParent() != 0.4 ) {
9341 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9344 final PhylogenyNode n12 = PhylogenyNode
9345 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9346 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9347 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9350 if ( n12.getDistanceToParent() != 0.4 ) {
9353 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9356 final PhylogenyNode o = PhylogenyNode
9357 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9358 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9361 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9364 if ( n1.getName().compareTo( "" ) != 0 ) {
9367 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9370 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9373 if ( n2.getName().compareTo( "" ) != 0 ) {
9376 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9379 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9382 final PhylogenyNode n00 = PhylogenyNode
9383 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9384 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9387 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9390 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9391 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9394 final PhylogenyNode n13 = PhylogenyNode
9395 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9396 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9399 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9402 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9405 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9408 final PhylogenyNode n14 = PhylogenyNode
9409 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9410 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9413 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9416 final PhylogenyNode n15 = PhylogenyNode
9417 .createInstanceFromNhxString( "something_wicked[123]",
9418 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9419 if ( !n15.getName().equals( "something_wicked" ) ) {
9422 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9425 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9428 final PhylogenyNode n16 = PhylogenyNode
9429 .createInstanceFromNhxString( "something_wicked2[9]",
9430 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9431 if ( !n16.getName().equals( "something_wicked2" ) ) {
9434 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9437 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9440 final PhylogenyNode n17 = PhylogenyNode
9441 .createInstanceFromNhxString( "something_wicked3[a]",
9442 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9443 if ( !n17.getName().equals( "something_wicked3" ) ) {
9446 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9449 final PhylogenyNode n18 = PhylogenyNode
9450 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9451 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9454 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9457 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9460 final PhylogenyNode n19 = PhylogenyNode
9461 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9462 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9465 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9468 final PhylogenyNode n30 = PhylogenyNode
9469 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9470 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9471 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9474 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9477 final PhylogenyNode n31 = PhylogenyNode
9478 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9479 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9480 if ( n31.getNodeData().isHasTaxonomy() ) {
9483 final PhylogenyNode n32 = PhylogenyNode
9484 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9485 if ( n32.getNodeData().isHasTaxonomy() ) {
9488 final PhylogenyNode n40 = PhylogenyNode
9489 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9490 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9493 final PhylogenyNode n41 = PhylogenyNode
9494 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9495 if ( n41.getNodeData().isHasTaxonomy() ) {
9498 final PhylogenyNode n42 = PhylogenyNode
9499 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9500 if ( n42.getNodeData().isHasTaxonomy() ) {
9503 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9504 NHXParser.TAXONOMY_EXTRACTION.NO );
9505 if ( n43.getNodeData().isHasTaxonomy() ) {
9508 final PhylogenyNode n44 = PhylogenyNode
9509 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9510 if ( n44.getNodeData().isHasTaxonomy() ) {
9514 catch ( final Exception e ) {
9515 e.printStackTrace( System.out );
9521 private static boolean testNHXParsing() {
9523 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9524 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9525 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9528 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]";
9529 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9530 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9533 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]";
9534 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9535 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9538 final Phylogeny[] p3 = factory
9539 .create( "[ comment&&NHX,())))](((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]",
9541 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9544 final Phylogeny[] p4 = factory
9545 .create( "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(]",
9547 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9550 final Phylogeny[] p5 = factory
9551 .create( "[] ( [][ ][ ] ([((( &&NHXcomment only![[[[[[]([]((((A:0.2[&&NHX:S=q[comment )))]werty][,,,,))]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=a[comment,,))]sdf])[comment(((]:0.4[&&NHX:S=zxc][comment(((][comment(((]):0.5[&&NHX:S=a]):0.6[&&NHX:S=a[comment(((]sd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(((]",
9553 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9556 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)";
9557 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)";
9558 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9559 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9562 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)))";
9563 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)))";
9564 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9565 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9568 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]) ))[,,, ])))))))";
9569 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9570 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9571 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9574 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9575 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9578 final Phylogeny p10 = factory
9579 .create( " [79] ( (A [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
9580 new NHXParser() )[ 0 ];
9581 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9584 final Phylogeny p11 = factory
9585 .create( " [79] ( ('A: \" ' [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
9586 new NHXParser() )[ 0 ];
9587 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9590 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]",
9591 new NHXParser() )[ 0 ];
9592 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9596 catch ( final Exception e ) {
9597 e.printStackTrace( System.out );
9603 private static boolean testNHXParsingMB() {
9605 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9606 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9607 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9608 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9609 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9610 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9611 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9612 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9613 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9614 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9615 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9618 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9621 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9622 0.1100000000000000e+00 ) ) {
9625 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9628 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9631 final Phylogeny p2 = factory
9632 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9633 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9634 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9635 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9636 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9637 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9638 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9639 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9640 + "7.369400000000000e-02}])",
9641 new NHXParser() )[ 0 ];
9642 if ( p2.getNode( "1" ) == null ) {
9645 if ( p2.getNode( "2" ) == null ) {
9649 catch ( final Exception e ) {
9650 e.printStackTrace( System.out );
9657 private static boolean testNHXParsingQuotes() {
9659 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9660 final NHXParser p = new NHXParser();
9661 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9662 if ( phylogenies_0.length != 5 ) {
9665 final Phylogeny phy = phylogenies_0[ 4 ];
9666 if ( phy.getNumberOfExternalNodes() != 7 ) {
9669 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9672 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9675 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9676 .getScientificName().equals( "hsapiens" ) ) {
9679 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9682 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9685 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9688 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9691 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9694 final NHXParser p1p = new NHXParser();
9695 p1p.setIgnoreQuotes( true );
9696 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9697 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9700 final NHXParser p2p = new NHXParser();
9701 p1p.setIgnoreQuotes( false );
9702 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9703 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9706 final NHXParser p3p = new NHXParser();
9707 p3p.setIgnoreQuotes( false );
9708 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9709 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9712 final NHXParser p4p = new NHXParser();
9713 p4p.setIgnoreQuotes( false );
9714 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9715 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9718 final Phylogeny p10 = factory
9719 .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]",
9720 new NHXParser() )[ 0 ];
9721 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]";
9722 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9725 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9726 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9729 final Phylogeny p12 = factory
9730 .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]",
9731 new NHXParser() )[ 0 ];
9732 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]";
9733 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9736 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9737 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9740 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;";
9741 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9744 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9745 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9749 catch ( final Exception e ) {
9750 e.printStackTrace( System.out );
9756 private static boolean testNodeRemoval() {
9758 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9759 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9760 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9761 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9764 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9765 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9766 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9769 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9770 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9771 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9775 catch ( final Exception e ) {
9776 e.printStackTrace( System.out );
9782 private static boolean testPhylogenyBranch() {
9784 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9785 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9786 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9787 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9788 if ( !a1b1.equals( a1b1 ) ) {
9791 if ( !a1b1.equals( b1a1 ) ) {
9794 if ( !b1a1.equals( a1b1 ) ) {
9797 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9798 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9799 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9800 if ( a1_b1.equals( b1_a1 ) ) {
9803 if ( a1_b1.equals( a1_b1_ ) ) {
9806 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9807 if ( !a1_b1.equals( b1_a1_ ) ) {
9810 if ( a1_b1_.equals( b1_a1_ ) ) {
9813 if ( !a1_b1_.equals( b1_a1 ) ) {
9817 catch ( final Exception e ) {
9818 e.printStackTrace( System.out );
9824 private static boolean testPhyloXMLparsingOfDistributionElement() {
9826 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9827 PhyloXmlParser xml_parser = null;
9829 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9831 catch ( final Exception e ) {
9832 // Do nothing -- means were not running from jar.
9834 if ( xml_parser == null ) {
9835 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9836 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9837 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9840 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9843 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9845 if ( xml_parser.getErrorCount() > 0 ) {
9846 System.out.println( xml_parser.getErrorMessages().toString() );
9849 if ( phylogenies_0.length != 1 ) {
9852 final Phylogeny t1 = phylogenies_0[ 0 ];
9853 PhylogenyNode n = null;
9854 Distribution d = null;
9855 n = t1.getNode( "root node" );
9856 if ( !n.getNodeData().isHasDistribution() ) {
9859 if ( n.getNodeData().getDistributions().size() != 1 ) {
9862 d = n.getNodeData().getDistribution();
9863 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9866 if ( d.getPoints().size() != 1 ) {
9869 if ( d.getPolygons() != null ) {
9872 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9875 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9878 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9881 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9884 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9887 n = t1.getNode( "node a" );
9888 if ( !n.getNodeData().isHasDistribution() ) {
9891 if ( n.getNodeData().getDistributions().size() != 2 ) {
9894 d = n.getNodeData().getDistribution( 1 );
9895 if ( !d.getDesc().equals( "San Diego" ) ) {
9898 if ( d.getPoints().size() != 1 ) {
9901 if ( d.getPolygons() != null ) {
9904 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9907 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9910 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9913 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9916 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9919 n = t1.getNode( "node bb" );
9920 if ( !n.getNodeData().isHasDistribution() ) {
9923 if ( n.getNodeData().getDistributions().size() != 1 ) {
9926 d = n.getNodeData().getDistribution( 0 );
9927 if ( d.getPoints().size() != 3 ) {
9930 if ( d.getPolygons().size() != 2 ) {
9933 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9936 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9939 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9942 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9945 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9948 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9951 Polygon p = d.getPolygons().get( 0 );
9952 if ( p.getPoints().size() != 3 ) {
9955 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9958 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9961 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9964 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9967 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9970 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9973 p = d.getPolygons().get( 1 );
9974 if ( p.getPoints().size() != 3 ) {
9977 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9980 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9983 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9987 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9988 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9989 if ( rt.length != 1 ) {
9992 final Phylogeny t1_rt = rt[ 0 ];
9993 n = t1_rt.getNode( "root node" );
9994 if ( !n.getNodeData().isHasDistribution() ) {
9997 if ( n.getNodeData().getDistributions().size() != 1 ) {
10000 d = n.getNodeData().getDistribution();
10001 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10004 if ( d.getPoints().size() != 1 ) {
10007 if ( d.getPolygons() != null ) {
10010 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10013 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10016 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10019 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10022 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10025 n = t1_rt.getNode( "node a" );
10026 if ( !n.getNodeData().isHasDistribution() ) {
10029 if ( n.getNodeData().getDistributions().size() != 2 ) {
10032 d = n.getNodeData().getDistribution( 1 );
10033 if ( !d.getDesc().equals( "San Diego" ) ) {
10036 if ( d.getPoints().size() != 1 ) {
10039 if ( d.getPolygons() != null ) {
10042 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10045 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10048 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10051 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10054 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10057 n = t1_rt.getNode( "node bb" );
10058 if ( !n.getNodeData().isHasDistribution() ) {
10061 if ( n.getNodeData().getDistributions().size() != 1 ) {
10064 d = n.getNodeData().getDistribution( 0 );
10065 if ( d.getPoints().size() != 3 ) {
10068 if ( d.getPolygons().size() != 2 ) {
10071 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10074 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10077 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10080 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10083 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10086 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10089 p = d.getPolygons().get( 0 );
10090 if ( p.getPoints().size() != 3 ) {
10093 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10096 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10099 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10102 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10105 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10108 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10111 p = d.getPolygons().get( 1 );
10112 if ( p.getPoints().size() != 3 ) {
10115 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10118 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10121 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10125 catch ( final Exception e ) {
10126 e.printStackTrace( System.out );
10132 private static boolean testPostOrderIterator() {
10134 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10135 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10136 PhylogenyNodeIterator it0;
10137 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10140 for( it0.reset(); it0.hasNext(); ) {
10143 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10144 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10145 if ( !it.next().getName().equals( "A" ) ) {
10148 if ( !it.next().getName().equals( "B" ) ) {
10151 if ( !it.next().getName().equals( "ab" ) ) {
10154 if ( !it.next().getName().equals( "C" ) ) {
10157 if ( !it.next().getName().equals( "D" ) ) {
10160 if ( !it.next().getName().equals( "cd" ) ) {
10163 if ( !it.next().getName().equals( "abcd" ) ) {
10166 if ( !it.next().getName().equals( "E" ) ) {
10169 if ( !it.next().getName().equals( "F" ) ) {
10172 if ( !it.next().getName().equals( "ef" ) ) {
10175 if ( !it.next().getName().equals( "G" ) ) {
10178 if ( !it.next().getName().equals( "H" ) ) {
10181 if ( !it.next().getName().equals( "gh" ) ) {
10184 if ( !it.next().getName().equals( "efgh" ) ) {
10187 if ( !it.next().getName().equals( "r" ) ) {
10190 if ( it.hasNext() ) {
10194 catch ( final Exception e ) {
10195 e.printStackTrace( System.out );
10201 private static boolean testPreOrderIterator() {
10203 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10204 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10205 PhylogenyNodeIterator it0;
10206 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10209 for( it0.reset(); it0.hasNext(); ) {
10212 PhylogenyNodeIterator it = t0.iteratorPreorder();
10213 if ( !it.next().getName().equals( "r" ) ) {
10216 if ( !it.next().getName().equals( "ab" ) ) {
10219 if ( !it.next().getName().equals( "A" ) ) {
10222 if ( !it.next().getName().equals( "B" ) ) {
10225 if ( !it.next().getName().equals( "cd" ) ) {
10228 if ( !it.next().getName().equals( "C" ) ) {
10231 if ( !it.next().getName().equals( "D" ) ) {
10234 if ( it.hasNext() ) {
10237 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10238 it = t1.iteratorPreorder();
10239 if ( !it.next().getName().equals( "r" ) ) {
10242 if ( !it.next().getName().equals( "abcd" ) ) {
10245 if ( !it.next().getName().equals( "ab" ) ) {
10248 if ( !it.next().getName().equals( "A" ) ) {
10251 if ( !it.next().getName().equals( "B" ) ) {
10254 if ( !it.next().getName().equals( "cd" ) ) {
10257 if ( !it.next().getName().equals( "C" ) ) {
10260 if ( !it.next().getName().equals( "D" ) ) {
10263 if ( !it.next().getName().equals( "efgh" ) ) {
10266 if ( !it.next().getName().equals( "ef" ) ) {
10269 if ( !it.next().getName().equals( "E" ) ) {
10272 if ( !it.next().getName().equals( "F" ) ) {
10275 if ( !it.next().getName().equals( "gh" ) ) {
10278 if ( !it.next().getName().equals( "G" ) ) {
10281 if ( !it.next().getName().equals( "H" ) ) {
10284 if ( it.hasNext() ) {
10288 catch ( final Exception e ) {
10289 e.printStackTrace( System.out );
10295 private static boolean testPropertiesMap() {
10297 final PropertiesMap pm = new PropertiesMap();
10298 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10299 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10300 final Property p2 = new Property( "something:else",
10302 "improbable:research",
10305 pm.addProperty( p0 );
10306 pm.addProperty( p1 );
10307 pm.addProperty( p2 );
10308 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10311 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10314 if ( pm.getProperties().size() != 3 ) {
10317 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10320 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10323 if ( pm.getProperties().size() != 3 ) {
10326 pm.removeProperty( "dimensions:diameter" );
10327 if ( pm.getProperties().size() != 2 ) {
10330 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10333 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10337 catch ( final Exception e ) {
10338 e.printStackTrace( System.out );
10344 private static boolean testProteinId() {
10346 final ProteinId id1 = new ProteinId( "a" );
10347 final ProteinId id2 = new ProteinId( "a" );
10348 final ProteinId id3 = new ProteinId( "A" );
10349 final ProteinId id4 = new ProteinId( "b" );
10350 if ( !id1.equals( id1 ) ) {
10353 if ( id1.getId().equals( "x" ) ) {
10356 if ( id1.getId().equals( null ) ) {
10359 if ( !id1.equals( id2 ) ) {
10362 if ( id1.equals( id3 ) ) {
10365 if ( id1.hashCode() != id1.hashCode() ) {
10368 if ( id1.hashCode() != id2.hashCode() ) {
10371 if ( id1.hashCode() == id3.hashCode() ) {
10374 if ( id1.compareTo( id1 ) != 0 ) {
10377 if ( id1.compareTo( id2 ) != 0 ) {
10380 if ( id1.compareTo( id3 ) != 0 ) {
10383 if ( id1.compareTo( id4 ) >= 0 ) {
10386 if ( id4.compareTo( id1 ) <= 0 ) {
10389 if ( !id4.getId().equals( "b" ) ) {
10392 final ProteinId id5 = new ProteinId( " C " );
10393 if ( !id5.getId().equals( "C" ) ) {
10396 if ( id5.equals( id1 ) ) {
10400 catch ( final Exception e ) {
10401 e.printStackTrace( System.out );
10407 private static boolean testReIdMethods() {
10409 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10410 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10411 final long count = PhylogenyNode.getNodeCount();
10412 p.levelOrderReID();
10413 if ( p.getNode( "r" ).getId() != count ) {
10416 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10419 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10422 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10425 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10428 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10431 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10434 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10437 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10440 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10443 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10446 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10449 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10452 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10455 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10459 catch ( final Exception e ) {
10460 e.printStackTrace( System.out );
10466 private static boolean testRerooting() {
10468 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10469 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",
10470 new NHXParser() )[ 0 ];
10471 if ( !t1.isRooted() ) {
10474 t1.reRoot( t1.getNode( "D" ) );
10475 t1.reRoot( t1.getNode( "CD" ) );
10476 t1.reRoot( t1.getNode( "A" ) );
10477 t1.reRoot( t1.getNode( "B" ) );
10478 t1.reRoot( t1.getNode( "AB" ) );
10479 t1.reRoot( t1.getNode( "D" ) );
10480 t1.reRoot( t1.getNode( "C" ) );
10481 t1.reRoot( t1.getNode( "CD" ) );
10482 t1.reRoot( t1.getNode( "A" ) );
10483 t1.reRoot( t1.getNode( "B" ) );
10484 t1.reRoot( t1.getNode( "AB" ) );
10485 t1.reRoot( t1.getNode( "D" ) );
10486 t1.reRoot( t1.getNode( "D" ) );
10487 t1.reRoot( t1.getNode( "C" ) );
10488 t1.reRoot( t1.getNode( "A" ) );
10489 t1.reRoot( t1.getNode( "B" ) );
10490 t1.reRoot( t1.getNode( "AB" ) );
10491 t1.reRoot( t1.getNode( "C" ) );
10492 t1.reRoot( t1.getNode( "D" ) );
10493 t1.reRoot( t1.getNode( "CD" ) );
10494 t1.reRoot( t1.getNode( "D" ) );
10495 t1.reRoot( t1.getNode( "A" ) );
10496 t1.reRoot( t1.getNode( "B" ) );
10497 t1.reRoot( t1.getNode( "AB" ) );
10498 t1.reRoot( t1.getNode( "C" ) );
10499 t1.reRoot( t1.getNode( "D" ) );
10500 t1.reRoot( t1.getNode( "CD" ) );
10501 t1.reRoot( t1.getNode( "D" ) );
10502 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10505 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10508 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10511 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10514 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10517 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10520 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",
10521 new NHXParser() )[ 0 ];
10522 t2.reRoot( t2.getNode( "A" ) );
10523 t2.reRoot( t2.getNode( "D" ) );
10524 t2.reRoot( t2.getNode( "ABC" ) );
10525 t2.reRoot( t2.getNode( "A" ) );
10526 t2.reRoot( t2.getNode( "B" ) );
10527 t2.reRoot( t2.getNode( "D" ) );
10528 t2.reRoot( t2.getNode( "C" ) );
10529 t2.reRoot( t2.getNode( "ABC" ) );
10530 t2.reRoot( t2.getNode( "A" ) );
10531 t2.reRoot( t2.getNode( "B" ) );
10532 t2.reRoot( t2.getNode( "AB" ) );
10533 t2.reRoot( t2.getNode( "AB" ) );
10534 t2.reRoot( t2.getNode( "D" ) );
10535 t2.reRoot( t2.getNode( "C" ) );
10536 t2.reRoot( t2.getNode( "B" ) );
10537 t2.reRoot( t2.getNode( "AB" ) );
10538 t2.reRoot( t2.getNode( "D" ) );
10539 t2.reRoot( t2.getNode( "D" ) );
10540 t2.reRoot( t2.getNode( "ABC" ) );
10541 t2.reRoot( t2.getNode( "A" ) );
10542 t2.reRoot( t2.getNode( "B" ) );
10543 t2.reRoot( t2.getNode( "AB" ) );
10544 t2.reRoot( t2.getNode( "D" ) );
10545 t2.reRoot( t2.getNode( "C" ) );
10546 t2.reRoot( t2.getNode( "ABC" ) );
10547 t2.reRoot( t2.getNode( "A" ) );
10548 t2.reRoot( t2.getNode( "B" ) );
10549 t2.reRoot( t2.getNode( "AB" ) );
10550 t2.reRoot( t2.getNode( "D" ) );
10551 t2.reRoot( t2.getNode( "D" ) );
10552 t2.reRoot( t2.getNode( "C" ) );
10553 t2.reRoot( t2.getNode( "A" ) );
10554 t2.reRoot( t2.getNode( "B" ) );
10555 t2.reRoot( t2.getNode( "AB" ) );
10556 t2.reRoot( t2.getNode( "C" ) );
10557 t2.reRoot( t2.getNode( "D" ) );
10558 t2.reRoot( t2.getNode( "ABC" ) );
10559 t2.reRoot( t2.getNode( "D" ) );
10560 t2.reRoot( t2.getNode( "A" ) );
10561 t2.reRoot( t2.getNode( "B" ) );
10562 t2.reRoot( t2.getNode( "AB" ) );
10563 t2.reRoot( t2.getNode( "C" ) );
10564 t2.reRoot( t2.getNode( "D" ) );
10565 t2.reRoot( t2.getNode( "ABC" ) );
10566 t2.reRoot( t2.getNode( "D" ) );
10567 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10570 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10573 t2.reRoot( t2.getNode( "ABC" ) );
10574 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10577 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10580 t2.reRoot( t2.getNode( "AB" ) );
10581 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10584 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10587 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10590 t2.reRoot( t2.getNode( "AB" ) );
10591 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10594 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10597 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10600 t2.reRoot( t2.getNode( "D" ) );
10601 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10604 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10607 t2.reRoot( t2.getNode( "ABC" ) );
10608 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10611 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10614 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10615 new NHXParser() )[ 0 ];
10616 t3.reRoot( t3.getNode( "B" ) );
10617 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10620 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10623 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10626 t3.reRoot( t3.getNode( "B" ) );
10627 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10630 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10633 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10636 t3.reRoot( t3.getRoot() );
10637 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10640 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10643 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10647 catch ( final Exception e ) {
10648 e.printStackTrace( System.out );
10654 private static boolean testSDIse() {
10656 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10657 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10658 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10659 gene1.setRooted( true );
10660 species1.setRooted( true );
10661 final SDI sdi = new SDI( gene1, species1 );
10662 if ( !gene1.getRoot().isDuplication() ) {
10665 final Phylogeny species2 = factory
10666 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10667 new NHXParser() )[ 0 ];
10668 final Phylogeny gene2 = factory
10669 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10670 new NHXParser() )[ 0 ];
10671 species2.setRooted( true );
10672 gene2.setRooted( true );
10673 final SDI sdi2 = new SDI( gene2, species2 );
10674 if ( sdi2.getDuplicationsSum() != 0 ) {
10677 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10680 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10683 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10686 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10689 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10692 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10695 final Phylogeny species3 = factory
10696 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10697 new NHXParser() )[ 0 ];
10698 final Phylogeny gene3 = factory
10699 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10700 new NHXParser() )[ 0 ];
10701 species3.setRooted( true );
10702 gene3.setRooted( true );
10703 final SDI sdi3 = new SDI( gene3, species3 );
10704 if ( sdi3.getDuplicationsSum() != 1 ) {
10707 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10710 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10713 final Phylogeny species4 = factory
10714 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10715 new NHXParser() )[ 0 ];
10716 final Phylogeny gene4 = factory
10717 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10718 new NHXParser() )[ 0 ];
10719 species4.setRooted( true );
10720 gene4.setRooted( true );
10721 final SDI sdi4 = new SDI( gene4, species4 );
10722 if ( sdi4.getDuplicationsSum() != 1 ) {
10725 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10728 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10731 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10734 if ( species4.getNumberOfExternalNodes() != 6 ) {
10737 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10740 final Phylogeny species5 = factory
10741 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10742 new NHXParser() )[ 0 ];
10743 final Phylogeny gene5 = factory
10744 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10745 new NHXParser() )[ 0 ];
10746 species5.setRooted( true );
10747 gene5.setRooted( true );
10748 final SDI sdi5 = new SDI( gene5, species5 );
10749 if ( sdi5.getDuplicationsSum() != 2 ) {
10752 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10755 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10758 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10761 if ( species5.getNumberOfExternalNodes() != 6 ) {
10764 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10767 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10768 // Conjecture for Comparing Molecular Phylogenies"
10769 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10770 final Phylogeny species6 = factory
10771 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
10772 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10773 new NHXParser() )[ 0 ];
10774 final Phylogeny gene6 = factory
10775 .create( "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1,3:0.1[&&NHX:S=3])1-2-3:0.1,"
10776 + "((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,"
10777 + "(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;",
10778 new NHXParser() )[ 0 ];
10779 species6.setRooted( true );
10780 gene6.setRooted( true );
10781 final SDI sdi6 = new SDI( gene6, species6 );
10782 if ( sdi6.getDuplicationsSum() != 3 ) {
10785 if ( !gene6.getNode( "r" ).isDuplication() ) {
10788 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10791 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10794 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10797 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10800 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10803 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10806 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10809 sdi6.computeMappingCostL();
10810 if ( sdi6.computeMappingCostL() != 17 ) {
10813 if ( species6.getNumberOfExternalNodes() != 9 ) {
10816 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10819 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10820 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10821 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10822 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10823 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10824 species7.setRooted( true );
10825 final Phylogeny gene7_1 = Test
10826 .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])" );
10827 gene7_1.setRooted( true );
10828 final SDI sdi7 = new SDI( gene7_1, species7 );
10829 if ( sdi7.getDuplicationsSum() != 0 ) {
10832 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10835 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10838 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10841 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10844 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10847 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10850 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10853 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10856 final Phylogeny gene7_2 = Test
10857 .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])" );
10858 gene7_2.setRooted( true );
10859 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10860 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10863 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10866 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10869 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10872 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10875 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10878 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10881 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10884 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10887 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10891 catch ( final Exception e ) {
10897 private static boolean testSDIunrooted() {
10899 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10900 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10901 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10902 final Iterator<PhylogenyBranch> iter = l.iterator();
10903 PhylogenyBranch br = iter.next();
10904 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10907 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10911 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10914 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10918 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10921 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10925 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10928 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10932 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10935 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10939 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10942 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10946 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10949 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10953 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10956 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10960 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10963 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10967 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10970 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10974 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10977 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10981 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10984 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10988 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10991 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10995 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10998 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11002 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11005 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11008 if ( iter.hasNext() ) {
11011 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11012 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11013 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11015 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11018 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11022 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11025 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11029 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11032 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11035 if ( iter1.hasNext() ) {
11038 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11039 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11040 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11042 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11045 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11049 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11052 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11056 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11059 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11062 if ( iter2.hasNext() ) {
11065 final Phylogeny species0 = factory
11066 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11067 new NHXParser() )[ 0 ];
11068 final Phylogeny gene1 = factory
11069 .create( "(((((A:0.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
11070 new NHXParser() )[ 0 ];
11071 species0.setRooted( true );
11072 gene1.setRooted( true );
11073 final SDIR sdi_unrooted = new SDIR();
11074 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11075 if ( sdi_unrooted.getCount() != 1 ) {
11078 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11081 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11084 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11087 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11090 final Phylogeny gene2 = factory
11091 .create( "(((((A:2.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
11092 new NHXParser() )[ 0 ];
11093 gene2.setRooted( true );
11094 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11095 if ( sdi_unrooted.getCount() != 1 ) {
11098 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11101 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11104 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11107 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11110 final Phylogeny species6 = factory
11111 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11112 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11113 new NHXParser() )[ 0 ];
11114 final Phylogeny gene6 = factory
11115 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11116 + "(((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],"
11117 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11118 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11119 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11120 new NHXParser() )[ 0 ];
11121 species6.setRooted( true );
11122 gene6.setRooted( true );
11123 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11124 if ( sdi_unrooted.getCount() != 1 ) {
11127 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11130 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11133 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11136 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11139 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11142 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11145 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11148 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11151 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11154 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11157 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11160 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11164 final Phylogeny species7 = factory
11165 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11166 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11167 new NHXParser() )[ 0 ];
11168 final Phylogeny gene7 = factory
11169 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11170 + "(((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],"
11171 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11172 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11173 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11174 new NHXParser() )[ 0 ];
11175 species7.setRooted( true );
11176 gene7.setRooted( true );
11177 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11178 if ( sdi_unrooted.getCount() != 1 ) {
11181 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11184 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11187 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11190 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11193 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11196 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11199 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11202 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11205 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11208 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11211 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11214 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11218 final Phylogeny species8 = factory
11219 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11220 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11221 new NHXParser() )[ 0 ];
11222 final Phylogeny gene8 = factory
11223 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11224 + "(((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],"
11225 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11226 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11227 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11228 new NHXParser() )[ 0 ];
11229 species8.setRooted( true );
11230 gene8.setRooted( true );
11231 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11232 if ( sdi_unrooted.getCount() != 1 ) {
11235 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11238 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11241 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11244 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11247 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11250 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11253 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11256 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11259 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11262 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11265 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11268 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11273 catch ( final Exception e ) {
11274 e.printStackTrace( System.out );
11280 private static boolean testSequenceDbWsTools1() {
11282 final PhylogenyNode n = new PhylogenyNode();
11283 n.setName( "NP_001025424" );
11284 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11285 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11286 || !acc.getValue().equals( "NP_001025424" ) ) {
11289 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11290 acc = SequenceDbWsTools.obtainSeqAccession( n );
11291 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11292 || !acc.getValue().equals( "NP_001025424" ) ) {
11295 n.setName( "NP_001025424.1" );
11296 acc = SequenceDbWsTools.obtainSeqAccession( n );
11297 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11298 || !acc.getValue().equals( "NP_001025424" ) ) {
11301 n.setName( "NM_001030253" );
11302 acc = SequenceDbWsTools.obtainSeqAccession( n );
11303 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11304 || !acc.getValue().equals( "NM_001030253" ) ) {
11307 n.setName( "BCL2_HUMAN" );
11308 acc = SequenceDbWsTools.obtainSeqAccession( n );
11309 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11310 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11311 System.out.println( acc.toString() );
11314 n.setName( "P10415" );
11315 acc = SequenceDbWsTools.obtainSeqAccession( n );
11316 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11317 || !acc.getValue().equals( "P10415" ) ) {
11318 System.out.println( acc.toString() );
11321 n.setName( " P10415 " );
11322 acc = SequenceDbWsTools.obtainSeqAccession( n );
11323 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11324 || !acc.getValue().equals( "P10415" ) ) {
11325 System.out.println( acc.toString() );
11328 n.setName( "_P10415|" );
11329 acc = SequenceDbWsTools.obtainSeqAccession( n );
11330 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11331 || !acc.getValue().equals( "P10415" ) ) {
11332 System.out.println( acc.toString() );
11335 n.setName( "AY695820" );
11336 acc = SequenceDbWsTools.obtainSeqAccession( n );
11337 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11338 || !acc.getValue().equals( "AY695820" ) ) {
11339 System.out.println( acc.toString() );
11342 n.setName( "_AY695820_" );
11343 acc = SequenceDbWsTools.obtainSeqAccession( n );
11344 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11345 || !acc.getValue().equals( "AY695820" ) ) {
11346 System.out.println( acc.toString() );
11349 n.setName( "AAA59452" );
11350 acc = SequenceDbWsTools.obtainSeqAccession( n );
11351 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11352 || !acc.getValue().equals( "AAA59452" ) ) {
11353 System.out.println( acc.toString() );
11356 n.setName( "_AAA59452_" );
11357 acc = SequenceDbWsTools.obtainSeqAccession( n );
11358 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11359 || !acc.getValue().equals( "AAA59452" ) ) {
11360 System.out.println( acc.toString() );
11363 n.setName( "AAA59452.1" );
11364 acc = SequenceDbWsTools.obtainSeqAccession( n );
11365 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11366 || !acc.getValue().equals( "AAA59452.1" ) ) {
11367 System.out.println( acc.toString() );
11370 n.setName( "_AAA59452.1_" );
11371 acc = SequenceDbWsTools.obtainSeqAccession( n );
11372 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11373 || !acc.getValue().equals( "AAA59452.1" ) ) {
11374 System.out.println( acc.toString() );
11377 n.setName( "GI:94894583" );
11378 acc = SequenceDbWsTools.obtainSeqAccession( n );
11379 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11380 || !acc.getValue().equals( "94894583" ) ) {
11381 System.out.println( acc.toString() );
11384 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11385 acc = SequenceDbWsTools.obtainSeqAccession( n );
11386 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11387 || !acc.getValue().equals( "71845847" ) ) {
11388 System.out.println( acc.toString() );
11391 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11392 acc = SequenceDbWsTools.obtainSeqAccession( n );
11393 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11394 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11395 System.out.println( acc.toString() );
11399 catch ( final Exception e ) {
11405 private static boolean testSequenceDbWsTools2() {
11407 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11408 SequenceDbWsTools.obtainSeqInformation( n1 );
11409 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11412 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11415 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11418 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11421 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11422 SequenceDbWsTools.obtainSeqInformation( n2 );
11423 if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
11426 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11429 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11432 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11435 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11436 SequenceDbWsTools.obtainSeqInformation( n3 );
11437 if ( !n3.getNodeData().getSequence().getName()
11438 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11441 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11444 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11447 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11451 catch ( final IOException e ) {
11452 System.out.println();
11453 System.out.println( "the following might be due to absence internet connection:" );
11454 e.printStackTrace( System.out );
11457 catch ( final Exception e ) {
11458 e.printStackTrace();
11464 private static boolean testSequenceIdParsing() {
11466 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11467 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11468 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11469 if ( id != null ) {
11470 System.out.println( "value =" + id.getValue() );
11471 System.out.println( "provider=" + id.getSource() );
11475 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11476 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11477 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11478 if ( id != null ) {
11479 System.out.println( "value =" + id.getValue() );
11480 System.out.println( "provider=" + id.getSource() );
11484 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11485 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11486 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11487 if ( id != null ) {
11488 System.out.println( "value =" + id.getValue() );
11489 System.out.println( "provider=" + id.getSource() );
11493 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11494 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11495 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11496 if ( id != null ) {
11497 System.out.println( "value =" + id.getValue() );
11498 System.out.println( "provider=" + id.getSource() );
11502 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11503 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11504 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11505 if ( id != null ) {
11506 System.out.println( "value =" + id.getValue() );
11507 System.out.println( "provider=" + id.getSource() );
11511 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11512 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11513 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11514 if ( id != null ) {
11515 System.out.println( "value =" + id.getValue() );
11516 System.out.println( "provider=" + id.getSource() );
11520 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11521 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11522 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11523 if ( id != null ) {
11524 System.out.println( "value =" + id.getValue() );
11525 System.out.println( "provider=" + id.getSource() );
11529 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11530 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11531 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11532 if ( id != null ) {
11533 System.out.println( "value =" + id.getValue() );
11534 System.out.println( "provider=" + id.getSource() );
11538 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11539 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11540 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11541 if ( id != null ) {
11542 System.out.println( "value =" + id.getValue() );
11543 System.out.println( "provider=" + id.getSource() );
11547 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11548 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11549 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11550 if ( id != null ) {
11551 System.out.println( "value =" + id.getValue() );
11552 System.out.println( "provider=" + id.getSource() );
11556 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11557 if ( id != null ) {
11558 System.out.println( "value =" + id.getValue() );
11559 System.out.println( "provider=" + id.getSource() );
11562 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
11563 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11564 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
11565 if ( id != null ) {
11566 System.out.println( "value =" + id.getValue() );
11567 System.out.println( "provider=" + id.getSource() );
11571 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
11572 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11573 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11574 if ( id != null ) {
11575 System.out.println( "value =" + id.getValue() );
11576 System.out.println( "provider=" + id.getSource() );
11580 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
11581 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11582 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11583 if ( id != null ) {
11584 System.out.println( "value =" + id.getValue() );
11585 System.out.println( "provider=" + id.getSource() );
11589 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
11590 if ( id != null ) {
11591 System.out.println( "value =" + id.getValue() );
11592 System.out.println( "provider=" + id.getSource() );
11596 catch ( final Exception e ) {
11597 e.printStackTrace( System.out );
11603 private static boolean testSequenceWriter() {
11605 final String n = ForesterUtil.LINE_SEPARATOR;
11606 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11609 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11612 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11615 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11618 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11619 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11622 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11623 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11627 catch ( final Exception e ) {
11628 e.printStackTrace();
11634 private static boolean testSpecies() {
11636 final Species s1 = new BasicSpecies( "a" );
11637 final Species s2 = new BasicSpecies( "a" );
11638 final Species s3 = new BasicSpecies( "A" );
11639 final Species s4 = new BasicSpecies( "b" );
11640 if ( !s1.equals( s1 ) ) {
11643 if ( s1.getSpeciesId().equals( "x" ) ) {
11646 if ( s1.getSpeciesId().equals( null ) ) {
11649 if ( !s1.equals( s2 ) ) {
11652 if ( s1.equals( s3 ) ) {
11655 if ( s1.hashCode() != s1.hashCode() ) {
11658 if ( s1.hashCode() != s2.hashCode() ) {
11661 if ( s1.hashCode() == s3.hashCode() ) {
11664 if ( s1.compareTo( s1 ) != 0 ) {
11667 if ( s1.compareTo( s2 ) != 0 ) {
11670 if ( s1.compareTo( s3 ) != 0 ) {
11673 if ( s1.compareTo( s4 ) >= 0 ) {
11676 if ( s4.compareTo( s1 ) <= 0 ) {
11679 if ( !s4.getSpeciesId().equals( "b" ) ) {
11682 final Species s5 = new BasicSpecies( " C " );
11683 if ( !s5.getSpeciesId().equals( "C" ) ) {
11686 if ( s5.equals( s1 ) ) {
11690 catch ( final Exception e ) {
11691 e.printStackTrace( System.out );
11697 private static boolean testSplit() {
11699 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11700 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11701 //Archaeopteryx.createApplication( p0 );
11702 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11703 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11704 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11705 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11706 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11707 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11708 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11709 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11710 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11711 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11712 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11713 // System.out.println( s0.toString() );
11715 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11718 if ( s0.match( query_nodes ) ) {
11721 query_nodes = new HashSet<PhylogenyNode>();
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11726 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11729 if ( !s0.match( query_nodes ) ) {
11733 query_nodes = new HashSet<PhylogenyNode>();
11734 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11737 if ( !s0.match( query_nodes ) ) {
11741 query_nodes = new HashSet<PhylogenyNode>();
11742 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11746 if ( !s0.match( query_nodes ) ) {
11750 query_nodes = new HashSet<PhylogenyNode>();
11751 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11755 if ( !s0.match( query_nodes ) ) {
11759 query_nodes = new HashSet<PhylogenyNode>();
11760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11761 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11762 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11763 if ( !s0.match( query_nodes ) ) {
11766 query_nodes = new HashSet<PhylogenyNode>();
11767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11769 if ( !s0.match( query_nodes ) ) {
11772 query_nodes = new HashSet<PhylogenyNode>();
11773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11777 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11778 if ( !s0.match( query_nodes ) ) {
11781 query_nodes = new HashSet<PhylogenyNode>();
11782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11785 if ( !s0.match( query_nodes ) ) {
11788 query_nodes = new HashSet<PhylogenyNode>();
11789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11793 if ( !s0.match( query_nodes ) ) {
11796 query_nodes = new HashSet<PhylogenyNode>();
11797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11799 if ( s0.match( query_nodes ) ) {
11802 query_nodes = new HashSet<PhylogenyNode>();
11803 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11807 if ( s0.match( query_nodes ) ) {
11810 query_nodes = new HashSet<PhylogenyNode>();
11811 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11812 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11816 if ( s0.match( query_nodes ) ) {
11819 query_nodes = new HashSet<PhylogenyNode>();
11820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11823 if ( s0.match( query_nodes ) ) {
11826 query_nodes = new HashSet<PhylogenyNode>();
11827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11829 if ( s0.match( query_nodes ) ) {
11832 query_nodes = new HashSet<PhylogenyNode>();
11833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11834 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11835 if ( s0.match( query_nodes ) ) {
11838 query_nodes = new HashSet<PhylogenyNode>();
11839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11841 if ( s0.match( query_nodes ) ) {
11844 query_nodes = new HashSet<PhylogenyNode>();
11845 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11847 if ( s0.match( query_nodes ) ) {
11850 query_nodes = new HashSet<PhylogenyNode>();
11851 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11852 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11853 if ( s0.match( query_nodes ) ) {
11856 query_nodes = new HashSet<PhylogenyNode>();
11857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11858 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11859 if ( s0.match( query_nodes ) ) {
11862 query_nodes = new HashSet<PhylogenyNode>();
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11866 if ( s0.match( query_nodes ) ) {
11869 query_nodes = new HashSet<PhylogenyNode>();
11870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11873 if ( s0.match( query_nodes ) ) {
11876 query_nodes = new HashSet<PhylogenyNode>();
11877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11879 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11880 if ( s0.match( query_nodes ) ) {
11883 query_nodes = new HashSet<PhylogenyNode>();
11884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11886 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11887 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11888 if ( s0.match( query_nodes ) ) {
11892 // query_nodes = new HashSet<PhylogenyNode>();
11893 // query_nodes.add( new PhylogenyNode( "X" ) );
11894 // query_nodes.add( new PhylogenyNode( "Y" ) );
11895 // query_nodes.add( new PhylogenyNode( "A" ) );
11896 // query_nodes.add( new PhylogenyNode( "B" ) );
11897 // query_nodes.add( new PhylogenyNode( "C" ) );
11898 // query_nodes.add( new PhylogenyNode( "D" ) );
11899 // query_nodes.add( new PhylogenyNode( "E" ) );
11900 // query_nodes.add( new PhylogenyNode( "F" ) );
11901 // query_nodes.add( new PhylogenyNode( "G" ) );
11902 // if ( !s0.match( query_nodes ) ) {
11905 // query_nodes = new HashSet<PhylogenyNode>();
11906 // query_nodes.add( new PhylogenyNode( "X" ) );
11907 // query_nodes.add( new PhylogenyNode( "Y" ) );
11908 // query_nodes.add( new PhylogenyNode( "A" ) );
11909 // query_nodes.add( new PhylogenyNode( "B" ) );
11910 // query_nodes.add( new PhylogenyNode( "C" ) );
11911 // if ( !s0.match( query_nodes ) ) {
11915 // query_nodes = new HashSet<PhylogenyNode>();
11916 // query_nodes.add( new PhylogenyNode( "X" ) );
11917 // query_nodes.add( new PhylogenyNode( "Y" ) );
11918 // query_nodes.add( new PhylogenyNode( "D" ) );
11919 // query_nodes.add( new PhylogenyNode( "E" ) );
11920 // query_nodes.add( new PhylogenyNode( "F" ) );
11921 // query_nodes.add( new PhylogenyNode( "G" ) );
11922 // if ( !s0.match( query_nodes ) ) {
11926 // query_nodes = new HashSet<PhylogenyNode>();
11927 // query_nodes.add( new PhylogenyNode( "X" ) );
11928 // query_nodes.add( new PhylogenyNode( "Y" ) );
11929 // query_nodes.add( new PhylogenyNode( "A" ) );
11930 // query_nodes.add( new PhylogenyNode( "B" ) );
11931 // query_nodes.add( new PhylogenyNode( "C" ) );
11932 // query_nodes.add( new PhylogenyNode( "D" ) );
11933 // if ( !s0.match( query_nodes ) ) {
11937 // query_nodes = new HashSet<PhylogenyNode>();
11938 // query_nodes.add( new PhylogenyNode( "X" ) );
11939 // query_nodes.add( new PhylogenyNode( "Y" ) );
11940 // query_nodes.add( new PhylogenyNode( "E" ) );
11941 // query_nodes.add( new PhylogenyNode( "F" ) );
11942 // query_nodes.add( new PhylogenyNode( "G" ) );
11943 // if ( !s0.match( query_nodes ) ) {
11947 // query_nodes = new HashSet<PhylogenyNode>();
11948 // query_nodes.add( new PhylogenyNode( "X" ) );
11949 // query_nodes.add( new PhylogenyNode( "Y" ) );
11950 // query_nodes.add( new PhylogenyNode( "F" ) );
11951 // query_nodes.add( new PhylogenyNode( "G" ) );
11952 // if ( !s0.match( query_nodes ) ) {
11956 query_nodes = new HashSet<PhylogenyNode>();
11957 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11958 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11960 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11961 if ( s0.match( query_nodes ) ) {
11965 query_nodes = new HashSet<PhylogenyNode>();
11966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11970 if ( s0.match( query_nodes ) ) {
11973 ///////////////////////////
11975 query_nodes = new HashSet<PhylogenyNode>();
11976 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11978 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11980 if ( s0.match( query_nodes ) ) {
11984 query_nodes = new HashSet<PhylogenyNode>();
11985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11989 if ( s0.match( query_nodes ) ) {
11993 query_nodes = new HashSet<PhylogenyNode>();
11994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11998 if ( s0.match( query_nodes ) ) {
12002 query_nodes = new HashSet<PhylogenyNode>();
12003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12004 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12006 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12007 if ( s0.match( query_nodes ) ) {
12011 query_nodes = new HashSet<PhylogenyNode>();
12012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12013 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12014 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12015 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12016 if ( s0.match( query_nodes ) ) {
12020 query_nodes = new HashSet<PhylogenyNode>();
12021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12023 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12024 if ( s0.match( query_nodes ) ) {
12028 query_nodes = new HashSet<PhylogenyNode>();
12029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12031 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12032 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12033 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12034 if ( s0.match( query_nodes ) ) {
12038 query_nodes = new HashSet<PhylogenyNode>();
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12040 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12041 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12042 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12043 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12044 if ( s0.match( query_nodes ) ) {
12048 query_nodes = new HashSet<PhylogenyNode>();
12049 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12050 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12051 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12054 if ( s0.match( query_nodes ) ) {
12058 query_nodes = new HashSet<PhylogenyNode>();
12059 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12060 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12065 if ( s0.match( query_nodes ) ) {
12069 catch ( final Exception e ) {
12070 e.printStackTrace();
12076 private static boolean testSplitStrict() {
12078 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12079 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12080 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12081 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12082 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12083 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12084 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12085 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12086 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12087 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12088 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12089 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12090 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12091 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12092 if ( s0.match( query_nodes ) ) {
12095 query_nodes = new HashSet<PhylogenyNode>();
12096 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12099 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12100 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12101 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12102 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12103 if ( !s0.match( query_nodes ) ) {
12107 query_nodes = new HashSet<PhylogenyNode>();
12108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12110 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12111 if ( !s0.match( query_nodes ) ) {
12115 query_nodes = new HashSet<PhylogenyNode>();
12116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12117 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12118 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12119 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12120 if ( !s0.match( query_nodes ) ) {
12124 query_nodes = new HashSet<PhylogenyNode>();
12125 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12126 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12127 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12128 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12129 if ( !s0.match( query_nodes ) ) {
12133 query_nodes = new HashSet<PhylogenyNode>();
12134 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12135 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12136 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12137 if ( !s0.match( query_nodes ) ) {
12141 query_nodes = new HashSet<PhylogenyNode>();
12142 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12143 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12144 if ( !s0.match( query_nodes ) ) {
12148 query_nodes = new HashSet<PhylogenyNode>();
12149 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12150 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12153 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12154 if ( !s0.match( query_nodes ) ) {
12158 query_nodes = new HashSet<PhylogenyNode>();
12159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12160 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12161 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12162 if ( !s0.match( query_nodes ) ) {
12166 query_nodes = new HashSet<PhylogenyNode>();
12167 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12168 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12169 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12170 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12171 if ( !s0.match( query_nodes ) ) {
12175 query_nodes = new HashSet<PhylogenyNode>();
12176 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12177 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12178 if ( s0.match( query_nodes ) ) {
12182 query_nodes = new HashSet<PhylogenyNode>();
12183 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12184 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12187 if ( s0.match( query_nodes ) ) {
12191 query_nodes = new HashSet<PhylogenyNode>();
12192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12193 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12197 if ( s0.match( query_nodes ) ) {
12201 query_nodes = new HashSet<PhylogenyNode>();
12202 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12203 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12205 if ( s0.match( query_nodes ) ) {
12209 query_nodes = new HashSet<PhylogenyNode>();
12210 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12212 if ( s0.match( query_nodes ) ) {
12216 query_nodes = new HashSet<PhylogenyNode>();
12217 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12218 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12219 if ( s0.match( query_nodes ) ) {
12223 query_nodes = new HashSet<PhylogenyNode>();
12224 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12225 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12226 if ( s0.match( query_nodes ) ) {
12230 query_nodes = new HashSet<PhylogenyNode>();
12231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12232 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12233 if ( s0.match( query_nodes ) ) {
12237 query_nodes = new HashSet<PhylogenyNode>();
12238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12240 if ( s0.match( query_nodes ) ) {
12244 query_nodes = new HashSet<PhylogenyNode>();
12245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12247 if ( s0.match( query_nodes ) ) {
12251 query_nodes = new HashSet<PhylogenyNode>();
12252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12254 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12255 if ( s0.match( query_nodes ) ) {
12259 query_nodes = new HashSet<PhylogenyNode>();
12260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12263 if ( s0.match( query_nodes ) ) {
12267 query_nodes = new HashSet<PhylogenyNode>();
12268 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12269 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12270 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12271 if ( s0.match( query_nodes ) ) {
12275 query_nodes = new HashSet<PhylogenyNode>();
12276 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12277 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12278 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12280 if ( s0.match( query_nodes ) ) {
12284 catch ( final Exception e ) {
12285 e.printStackTrace();
12291 private static boolean testSubtreeDeletion() {
12293 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12294 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12295 t1.deleteSubtree( t1.getNode( "A" ), false );
12296 if ( t1.getNumberOfExternalNodes() != 5 ) {
12299 t1.toNewHampshireX();
12300 t1.deleteSubtree( t1.getNode( "E" ), false );
12301 if ( t1.getNumberOfExternalNodes() != 4 ) {
12304 t1.toNewHampshireX();
12305 t1.deleteSubtree( t1.getNode( "F" ), false );
12306 if ( t1.getNumberOfExternalNodes() != 3 ) {
12309 t1.toNewHampshireX();
12310 t1.deleteSubtree( t1.getNode( "D" ), false );
12311 t1.toNewHampshireX();
12312 if ( t1.getNumberOfExternalNodes() != 3 ) {
12315 t1.deleteSubtree( t1.getNode( "def" ), false );
12316 t1.toNewHampshireX();
12317 if ( t1.getNumberOfExternalNodes() != 2 ) {
12320 t1.deleteSubtree( t1.getNode( "B" ), false );
12321 t1.toNewHampshireX();
12322 if ( t1.getNumberOfExternalNodes() != 1 ) {
12325 t1.deleteSubtree( t1.getNode( "C" ), false );
12326 t1.toNewHampshireX();
12327 if ( t1.getNumberOfExternalNodes() != 1 ) {
12330 t1.deleteSubtree( t1.getNode( "abc" ), false );
12331 t1.toNewHampshireX();
12332 if ( t1.getNumberOfExternalNodes() != 1 ) {
12335 t1.deleteSubtree( t1.getNode( "r" ), false );
12336 if ( t1.getNumberOfExternalNodes() != 0 ) {
12339 if ( !t1.isEmpty() ) {
12342 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12343 t2.deleteSubtree( t2.getNode( "A" ), false );
12344 t2.toNewHampshireX();
12345 if ( t2.getNumberOfExternalNodes() != 5 ) {
12348 t2.deleteSubtree( t2.getNode( "abc" ), false );
12349 t2.toNewHampshireX();
12350 if ( t2.getNumberOfExternalNodes() != 3 ) {
12353 t2.deleteSubtree( t2.getNode( "def" ), false );
12354 t2.toNewHampshireX();
12355 if ( t2.getNumberOfExternalNodes() != 1 ) {
12359 catch ( final Exception e ) {
12360 e.printStackTrace( System.out );
12366 private static boolean testSupportCount() {
12368 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12369 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12370 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12371 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12372 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12373 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12374 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12376 SupportCount.count( t0_1, phylogenies_1, true, false );
12377 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12378 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12379 + "(((((A,B),C),D),E),((F,G),X))"
12380 + "(((((A,Y),B),C),D),((F,G),E))"
12381 + "(((((A,B),C),D),E),(F,G))"
12382 + "(((((A,B),C),D),E),(F,G))"
12383 + "(((((A,B),C),D),E),(F,G))"
12384 + "(((((A,B),C),D),E),(F,G),Z)"
12385 + "(((((A,B),C),D),E),(F,G))"
12386 + "((((((A,B),C),D),E),F),G)"
12387 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12389 SupportCount.count( t0_2, phylogenies_2, true, false );
12390 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12391 while ( it.hasNext() ) {
12392 final PhylogenyNode n = it.next();
12393 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12397 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12398 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12399 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12400 SupportCount.count( t0_3, phylogenies_3, true, false );
12401 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12402 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12405 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12408 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12411 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12414 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12417 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12420 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12423 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12426 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12429 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12432 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12433 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12434 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12435 SupportCount.count( t0_4, phylogenies_4, true, false );
12436 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12437 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12440 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12443 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12446 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12449 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12452 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12455 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12458 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12461 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12464 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12467 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12468 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12469 double d = SupportCount.compare( b1, a, true, true, true );
12470 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12473 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12474 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12475 d = SupportCount.compare( b2, a, true, true, true );
12476 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12479 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12480 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12481 d = SupportCount.compare( b3, a, true, true, true );
12482 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12485 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12486 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12487 d = SupportCount.compare( b4, a, true, true, false );
12488 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12492 catch ( final Exception e ) {
12493 e.printStackTrace( System.out );
12499 private static boolean testSupportTransfer() {
12501 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12502 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)",
12503 new NHXParser() )[ 0 ];
12504 final Phylogeny p2 = factory
12505 .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
12506 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12509 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12512 support_transfer.moveBranchLengthsToBootstrap( p1 );
12513 support_transfer.transferSupportValues( p1, p2 );
12514 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12517 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12520 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12523 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12526 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12529 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12532 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12535 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12539 catch ( final Exception e ) {
12540 e.printStackTrace( System.out );
12546 private static boolean testTaxonomyExtraction() {
12548 final PhylogenyNode n0 = PhylogenyNode
12549 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12550 if ( n0.getNodeData().isHasTaxonomy() ) {
12553 final PhylogenyNode n1 = PhylogenyNode
12554 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12555 if ( n1.getNodeData().isHasTaxonomy() ) {
12556 System.out.println( n1.toString() );
12559 final PhylogenyNode n2x = PhylogenyNode
12560 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12561 if ( n2x.getNodeData().isHasTaxonomy() ) {
12564 final PhylogenyNode n3 = PhylogenyNode
12565 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12566 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12567 System.out.println( n3.toString() );
12570 final PhylogenyNode n4 = PhylogenyNode
12571 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12572 if ( n4.getNodeData().isHasTaxonomy() ) {
12573 System.out.println( n4.toString() );
12576 final PhylogenyNode n5 = PhylogenyNode
12577 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12578 if ( n5.getNodeData().isHasTaxonomy() ) {
12579 System.out.println( n5.toString() );
12582 final PhylogenyNode n6 = PhylogenyNode
12583 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12584 if ( n6.getNodeData().isHasTaxonomy() ) {
12585 System.out.println( n6.toString() );
12588 final PhylogenyNode n7 = PhylogenyNode
12589 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12590 if ( n7.getNodeData().isHasTaxonomy() ) {
12591 System.out.println( n7.toString() );
12594 final PhylogenyNode n8 = PhylogenyNode
12595 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12596 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12597 System.out.println( n8.toString() );
12600 final PhylogenyNode n9 = PhylogenyNode
12601 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12602 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12603 System.out.println( n9.toString() );
12606 final PhylogenyNode n10x = PhylogenyNode
12607 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12608 if ( n10x.getNodeData().isHasTaxonomy() ) {
12609 System.out.println( n10x.toString() );
12612 final PhylogenyNode n10xx = PhylogenyNode
12613 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12614 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12615 System.out.println( n10xx.toString() );
12618 final PhylogenyNode n10 = PhylogenyNode
12619 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12620 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12621 System.out.println( n10.toString() );
12624 final PhylogenyNode n11 = PhylogenyNode
12625 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12626 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12627 System.out.println( n11.toString() );
12630 final PhylogenyNode n12 = PhylogenyNode
12631 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12632 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12633 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12634 System.out.println( n12.toString() );
12637 final PhylogenyNode n13 = PhylogenyNode
12638 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12639 if ( n13.getNodeData().isHasTaxonomy() ) {
12640 System.out.println( n13.toString() );
12643 final PhylogenyNode n14 = PhylogenyNode
12644 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12645 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12646 System.out.println( n14.toString() );
12649 final PhylogenyNode n15 = PhylogenyNode
12650 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12651 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12652 System.out.println( n15.toString() );
12655 final PhylogenyNode n16 = PhylogenyNode
12656 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12657 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12658 System.out.println( n16.toString() );
12661 final PhylogenyNode n17 = PhylogenyNode
12662 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12663 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12664 System.out.println( n17.toString() );
12667 final PhylogenyNode n18 = PhylogenyNode
12668 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12669 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12670 System.out.println( n18.toString() );
12673 final PhylogenyNode n19 = PhylogenyNode
12674 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12675 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12676 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12677 System.out.println( n19.toString() );
12680 final PhylogenyNode n20 = PhylogenyNode
12681 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12682 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12683 System.out.println( n20.toString() );
12686 final PhylogenyNode n21 = PhylogenyNode
12687 .createInstanceFromNhxString( "Mus musculus musculus K392",
12688 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12689 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12690 System.out.println( n21.toString() );
12693 final PhylogenyNode n23 = PhylogenyNode
12694 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12695 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12696 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12697 System.out.println( n23.toString() );
12700 final PhylogenyNode n24 = PhylogenyNode
12701 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12702 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12703 System.out.println( n24.toString() );
12707 final PhylogenyNode n25 = PhylogenyNode
12708 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12709 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12710 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12711 System.out.println( n25.toString() );
12714 final PhylogenyNode n26 = PhylogenyNode
12715 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12716 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12717 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12718 System.out.println( n26.toString() );
12721 final PhylogenyNode n27 = PhylogenyNode
12722 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12723 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12724 System.out.println( n27.toString() );
12728 catch ( final Exception e ) {
12729 e.printStackTrace( System.out );
12735 private static boolean testTreeCopy() {
12737 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12738 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12739 final Phylogeny t1 = t0.copy();
12740 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12743 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12746 t0.deleteSubtree( t0.getNode( "c" ), true );
12747 t0.deleteSubtree( t0.getNode( "a" ), true );
12748 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12749 t0.getNode( "b" ).setName( "Bee" );
12750 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12753 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12756 t0.deleteSubtree( t0.getNode( "e" ), true );
12757 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12758 t0.deleteSubtree( t0.getNode( "d" ), true );
12759 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12763 catch ( final Exception e ) {
12764 e.printStackTrace();
12770 private static boolean testTreeMethods() {
12772 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12773 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12774 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12775 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12776 System.out.println( t0.toNewHampshireX() );
12779 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12780 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12781 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12784 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12787 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12791 catch ( final Exception e ) {
12792 e.printStackTrace( System.out );
12798 private static boolean testUniprotEntryRetrieval() {
12800 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
12801 if ( !entry.getAccession().equals( "P12345" ) ) {
12804 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12807 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12810 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12813 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12816 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12819 if ( entry.getMolecularSequence() == null ) {
12823 .getMolecularSequence()
12824 .getMolecularSequenceAsString()
12825 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
12826 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
12827 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
12828 System.out.println( "expected something else." );
12832 catch ( final IOException e ) {
12833 System.out.println();
12834 System.out.println( "the following might be due to absence internet connection:" );
12835 e.printStackTrace( System.out );
12838 catch ( final NullPointerException f ) {
12839 f.printStackTrace( System.out );
12842 catch ( final Exception e ) {
12848 private static boolean testUniprotTaxonomySearch() {
12850 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12852 if ( results.size() != 1 ) {
12855 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12858 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12861 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12864 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12867 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12871 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12872 if ( results.size() != 1 ) {
12875 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12878 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12881 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12884 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12887 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12891 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12892 if ( results.size() != 1 ) {
12895 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12898 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12901 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12904 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12907 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12911 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12912 if ( results.size() != 1 ) {
12915 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12918 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12921 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12924 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12927 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12930 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12933 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12936 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12937 .equals( "Nematostella vectensis" ) ) {
12938 System.out.println( results.get( 0 ).getLineage() );
12943 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12944 if ( results.size() != 1 ) {
12947 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12950 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12953 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12956 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12959 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12962 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12963 .equals( "Xenopus tropicalis" ) ) {
12964 System.out.println( results.get( 0 ).getLineage() );
12969 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12970 if ( results.size() != 1 ) {
12973 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12976 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12979 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12982 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12985 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12988 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12989 .equals( "Xenopus tropicalis" ) ) {
12990 System.out.println( results.get( 0 ).getLineage() );
12995 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12996 if ( results.size() != 1 ) {
12999 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13002 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13005 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13008 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13011 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13014 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13015 .equals( "Xenopus tropicalis" ) ) {
13016 System.out.println( results.get( 0 ).getLineage() );
13020 catch ( final IOException e ) {
13021 System.out.println();
13022 System.out.println( "the following might be due to absence internet connection:" );
13023 e.printStackTrace( System.out );
13026 catch ( final Exception e ) {