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( "NH parsing - special chars: " );
366 if ( Test.testNHParsingSpecialChars() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "Conversion to NHX (node level): " );
375 if ( Test.testNHXconversion() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "NHX parsing: " );
384 if ( Test.testNHXParsing() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing with quotes: " );
393 if ( Test.testNHXParsingQuotes() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "NHX parsing (MrBayes): " );
402 if ( Test.testNHXParsingMB() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "Nexus characters parsing: " );
411 if ( Test.testNexusCharactersParsing() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus tree parsing iterating: " );
420 if ( Test.testNexusTreeParsingIterating() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing: " );
429 if ( Test.testNexusTreeParsing() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus tree parsing (translating): " );
438 if ( Test.testNexusTreeParsingTranslating() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Nexus matrix parsing: " );
447 if ( Test.testNexusMatrixParsing() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Basic phyloXML parsing: " );
456 if ( Test.testBasicPhyloXMLparsing() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Basic phyloXML parsing (validating against schema): " );
465 if ( testBasicPhyloXMLparsingValidating() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
474 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "phyloXML Distribution Element: " );
483 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
484 System.out.println( "OK." );
488 System.out.println( "failed." );
491 System.out.print( "Tol XML parsing: " );
492 if ( Test.testBasicTolXMLparsing() ) {
493 System.out.println( "OK." );
497 System.out.println( "failed." );
500 System.out.print( "UTF-8 parsing from file: " );
501 if ( Test.testUTF8ParsingFromFile() ) {
502 System.out.println( "OK." );
506 System.out.println( "failed." );
509 System.out.print( "Copying of node data: " );
510 if ( Test.testCopyOfNodeData() ) {
511 System.out.println( "OK." );
515 System.out.println( "failed." );
518 System.out.print( "Tree copy: " );
519 if ( Test.testTreeCopy() ) {
520 System.out.println( "OK." );
524 System.out.println( "failed." );
527 System.out.print( "Basic tree methods: " );
528 if ( Test.testBasicTreeMethods() ) {
529 System.out.println( "OK." );
533 System.out.println( "failed." );
536 System.out.print( "Tree methods: " );
537 if ( Test.testTreeMethods() ) {
538 System.out.println( "OK." );
542 System.out.println( "failed." );
545 System.out.print( "Postorder Iterator: " );
546 if ( Test.testPostOrderIterator() ) {
547 System.out.println( "OK." );
551 System.out.println( "failed." );
554 System.out.print( "Preorder Iterator: " );
555 if ( Test.testPreOrderIterator() ) {
556 System.out.println( "OK." );
560 System.out.println( "failed." );
563 System.out.print( "Levelorder Iterator: " );
564 if ( Test.testLevelOrderIterator() ) {
565 System.out.println( "OK." );
569 System.out.println( "failed." );
572 System.out.print( "Re-id methods: " );
573 if ( Test.testReIdMethods() ) {
574 System.out.println( "OK." );
578 System.out.println( "failed." );
581 System.out.print( "Methods on last external nodes: " );
582 if ( Test.testLastExternalNodeMethods() ) {
583 System.out.println( "OK." );
587 System.out.println( "failed." );
590 System.out.print( "Methods on external nodes: " );
591 if ( Test.testExternalNodeRelatedMethods() ) {
592 System.out.println( "OK." );
596 System.out.println( "failed." );
599 System.out.print( "Deletion of external nodes: " );
600 if ( Test.testDeletionOfExternalNodes() ) {
601 System.out.println( "OK." );
605 System.out.println( "failed." );
608 System.out.print( "Subtree deletion: " );
609 if ( Test.testSubtreeDeletion() ) {
610 System.out.println( "OK." );
614 System.out.println( "failed." );
617 System.out.print( "Phylogeny branch: " );
618 if ( Test.testPhylogenyBranch() ) {
619 System.out.println( "OK." );
623 System.out.println( "failed." );
626 System.out.print( "Rerooting: " );
627 if ( Test.testRerooting() ) {
628 System.out.println( "OK." );
632 System.out.println( "failed." );
635 System.out.print( "Mipoint rooting: " );
636 if ( Test.testMidpointrooting() ) {
637 System.out.println( "OK." );
641 System.out.println( "failed." );
644 System.out.print( "Node removal: " );
645 if ( Test.testNodeRemoval() ) {
646 System.out.println( "OK." );
650 System.out.println( "failed." );
653 System.out.print( "Support count: " );
654 if ( Test.testSupportCount() ) {
655 System.out.println( "OK." );
659 System.out.println( "failed." );
662 System.out.print( "Support transfer: " );
663 if ( Test.testSupportTransfer() ) {
664 System.out.println( "OK." );
668 System.out.println( "failed." );
671 System.out.print( "Finding of LCA: " );
672 if ( Test.testGetLCA() ) {
673 System.out.println( "OK." );
677 System.out.println( "failed." );
680 System.out.print( "Finding of LCA 2: " );
681 if ( Test.testGetLCA2() ) {
682 System.out.println( "OK." );
686 System.out.println( "failed." );
689 System.out.print( "Calculation of distance between nodes: " );
690 if ( Test.testGetDistance() ) {
691 System.out.println( "OK." );
695 System.out.println( "failed." );
698 System.out.print( "Descriptive statistics: " );
699 if ( Test.testDescriptiveStatistics() ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "Data objects and methods: " );
708 if ( Test.testDataObjects() ) {
709 System.out.println( "OK." );
713 System.out.println( "failed." );
716 System.out.print( "Properties map: " );
717 if ( Test.testPropertiesMap() ) {
718 System.out.println( "OK." );
722 System.out.println( "failed." );
725 System.out.print( "SDIse: " );
726 if ( Test.testSDIse() ) {
727 System.out.println( "OK." );
731 System.out.println( "failed." );
734 System.out.print( "SDIunrooted: " );
735 if ( Test.testSDIunrooted() ) {
736 System.out.println( "OK." );
740 System.out.println( "failed." );
743 System.out.print( "GSDI: " );
744 if ( TestGSDI.test() ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "RIO: " );
753 if ( TestRIO.test() ) {
754 System.out.println( "OK." );
758 System.out.println( "failed." );
761 System.out.print( "Phylogeny reconstruction:" );
762 System.out.println();
763 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
764 System.out.println( "OK." );
768 System.out.println( "failed." );
771 System.out.print( "Analysis of domain architectures: " );
772 System.out.println();
773 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "GO: " );
782 System.out.println();
783 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
784 System.out.println( "OK." );
788 System.out.println( "failed." );
791 System.out.print( "Modeling tools: " );
792 if ( TestPccx.test() ) {
793 System.out.println( "OK." );
797 System.out.println( "failed." );
800 System.out.print( "Split Matrix strict: " );
801 if ( Test.testSplitStrict() ) {
802 System.out.println( "OK." );
806 System.out.println( "failed." );
809 System.out.print( "Split Matrix: " );
810 if ( Test.testSplit() ) {
811 System.out.println( "OK." );
815 System.out.println( "failed." );
818 System.out.print( "Confidence Assessor: " );
819 if ( Test.testConfidenceAssessor() ) {
820 System.out.println( "OK." );
824 System.out.println( "failed." );
827 System.out.print( "Basic table: " );
828 if ( Test.testBasicTable() ) {
829 System.out.println( "OK." );
833 System.out.println( "failed." );
836 System.out.print( "General table: " );
837 if ( Test.testGeneralTable() ) {
838 System.out.println( "OK." );
842 System.out.println( "failed." );
845 System.out.print( "Amino acid sequence: " );
846 if ( Test.testAminoAcidSequence() ) {
847 System.out.println( "OK." );
851 System.out.println( "failed." );
854 System.out.print( "General MSA parser: " );
855 if ( Test.testGeneralMsaParser() ) {
856 System.out.println( "OK." );
860 System.out.println( "failed." );
863 System.out.print( "Fasta parser for msa: " );
864 if ( Test.testFastaParser() ) {
865 System.out.println( "OK." );
869 System.out.println( "failed." );
872 System.out.print( "Creation of balanced phylogeny: " );
873 if ( Test.testCreateBalancedPhylogeny() ) {
874 System.out.println( "OK." );
878 System.out.println( "failed." );
881 System.out.print( "Genbank accessor parsing: " );
882 if ( Test.testGenbankAccessorParsing() ) {
883 System.out.println( "OK." );
887 System.out.println( "failed." );
891 final String os = ForesterUtil.OS_NAME.toLowerCase();
892 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
893 path = "/usr/local/bin/mafft";
895 else if ( os.indexOf( "win" ) >= 0 ) {
896 path = "C:\\Program Files\\mafft-win\\mafft.bat";
900 if ( !MsaInferrer.isInstalled( path ) ) {
901 path = "/usr/bin/mafft";
903 if ( !MsaInferrer.isInstalled( path ) ) {
904 path = "/usr/local/bin/mafft";
907 if ( MsaInferrer.isInstalled( path ) ) {
908 System.out.print( "MAFFT (external program): " );
909 if ( Test.testMafft( path ) ) {
910 System.out.println( "OK." );
914 System.out.println( "failed [will not count towards failed tests]" );
917 System.out.print( "Next nodes with collapsed: " );
918 if ( Test.testNextNodeWithCollapsing() ) {
919 System.out.println( "OK." );
923 System.out.println( "failed." );
926 System.out.print( "Simple MSA quality: " );
927 if ( Test.testMsaQualityMethod() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Deleteable MSA: " );
936 if ( Test.testDeleteableMsa() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "MSA entropy: " );
945 if ( Test.testMsaEntropy() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
953 if ( PERFORM_DB_TESTS ) {
954 System.out.print( "Uniprot Entry Retrieval: " );
955 if ( Test.testUniprotEntryRetrieval() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
963 System.out.print( "Ebi Entry Retrieval: " );
964 if ( Test.testEbiEntryRetrieval() ) {
965 System.out.println( "OK." );
969 System.out.println( "failed." );
972 System.out.print( "Sequence DB tools 2: " );
973 if ( testSequenceDbWsTools2() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
982 System.out.print( "Uniprot Taxonomy Search: " );
983 if ( Test.testUniprotTaxonomySearch() ) {
984 System.out.println( "OK." );
988 System.out.println( "failed." );
992 if ( PERFORM_WEB_TREE_ACCESS ) {
993 System.out.print( "TreeBase acccess: " );
994 if ( Test.testTreeBaseReading() ) {
995 System.out.println( "OK." );
999 System.out.println( "failed." );
1002 System.out.print( "ToL access: " );
1003 if ( Test.testToLReading() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1011 System.out.print( "NHX parsing from URL: " );
1012 if ( Test.testNHXparsingFromURL() ) {
1013 System.out.println( "OK." );
1017 System.out.println( "failed." );
1020 System.out.print( "NHX parsing from URL 2: " );
1021 if ( Test.testNHXparsingFromURL2() ) {
1022 System.out.println( "OK." );
1026 System.out.println( "failed." );
1029 System.out.print( "phyloXML parsing from URL: " );
1030 if ( Test.testPhyloXMLparsingFromURL() ) {
1031 System.out.println( "OK." );
1035 System.out.println( "failed." );
1038 System.out.print( "TreeFam access: " );
1039 if ( Test.testTreeFamReading() ) {
1040 System.out.println( "OK." );
1044 System.out.println( "failed." );
1047 System.out.print( "Pfam tree access: " );
1048 if ( Test.testPfamTreeReading() ) {
1049 System.out.println( "OK." );
1053 System.out.println( "failed." );
1057 System.out.println();
1058 final Runtime rt = java.lang.Runtime.getRuntime();
1059 final long free_memory = rt.freeMemory() / 1000000;
1060 final long total_memory = rt.totalMemory() / 1000000;
1061 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1062 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1063 System.out.println();
1064 System.out.println( "Successful tests: " + succeeded );
1065 System.out.println( "Failed tests: " + failed );
1066 System.out.println();
1068 System.out.println( "OK." );
1071 System.out.println( "Not OK." );
1075 private static boolean testEngulfingOverlapRemoval() {
1077 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1078 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1079 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1080 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1081 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1082 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1083 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1084 final List<Boolean> covered = new ArrayList<Boolean>();
1085 covered.add( true ); // 0
1086 covered.add( false ); // 1
1087 covered.add( true ); // 2
1088 covered.add( false ); // 3
1089 covered.add( true ); // 4
1090 covered.add( true ); // 5
1091 covered.add( false ); // 6
1092 covered.add( true ); // 7
1093 covered.add( true ); // 8
1094 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1097 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1100 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1103 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1106 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1109 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1112 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1115 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1116 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1117 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1118 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1119 abc.addProteinDomain( a );
1120 abc.addProteinDomain( b );
1121 abc.addProteinDomain( c );
1122 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1123 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1124 if ( abc.getNumberOfProteinDomains() != 3 ) {
1127 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1130 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1133 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1136 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1139 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1140 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1141 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1142 final Protein def = new BasicProtein( "def", "nemve", 0 );
1143 def.addProteinDomain( d );
1144 def.addProteinDomain( e );
1145 def.addProteinDomain( f );
1146 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1147 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1148 if ( def.getNumberOfProteinDomains() != 3 ) {
1151 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1154 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1157 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1160 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1163 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1167 catch ( final Exception e ) {
1168 e.printStackTrace( System.out );
1174 private static final boolean testNHXparsingFromURL2() {
1176 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1177 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1181 TAXONOMY_EXTRACTION.NO,
1183 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1186 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1187 System.out.println( phys[ 0 ].toNewHampshire() );
1190 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1191 System.out.println( phys[ 1 ].toNewHampshire() );
1194 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1198 TAXONOMY_EXTRACTION.NO,
1200 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1203 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1204 System.out.println( phys2[ 0 ].toNewHampshire() );
1207 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1208 System.out.println( phys2[ 1 ].toNewHampshire() );
1211 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1212 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1213 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1218 .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))))));" ) ) {
1219 System.out.println( phys3[ 0 ].toNewHampshire() );
1222 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1223 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1224 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1229 .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))))));" ) ) {
1230 System.out.println( phys4[ 0 ].toNewHampshire() );
1234 catch ( final Exception e ) {
1235 e.printStackTrace();
1241 private static final boolean testNHXparsingFromURL() {
1243 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1244 final URL u = new URL( s );
1245 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1246 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1247 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1250 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1251 System.out.println( phys[ 0 ].toNewHampshire() );
1254 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1255 System.out.println( phys[ 1 ].toNewHampshire() );
1258 final URL u2 = new URL( s );
1259 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1260 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1263 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1264 System.out.println( phys2[ 0 ].toNewHampshire() );
1267 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1268 final NHXParser p = new NHXParser();
1269 final URL u3 = new URL( s );
1271 if ( !p.hasNext() ) {
1274 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1277 if ( !p.hasNext() ) {
1281 if ( !p.hasNext() ) {
1284 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1287 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1291 if ( !p.hasNext() ) {
1294 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1297 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1301 catch ( final Exception e ) {
1302 System.out.println( e.toString() );
1303 e.printStackTrace();
1309 private static boolean testOverlapRemoval() {
1311 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1312 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1313 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1314 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1315 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1316 final List<Boolean> covered = new ArrayList<Boolean>();
1317 covered.add( true ); // 0
1318 covered.add( false ); // 1
1319 covered.add( true ); // 2
1320 covered.add( false ); // 3
1321 covered.add( true ); // 4
1322 covered.add( true ); // 5
1323 covered.add( false ); // 6
1324 covered.add( true ); // 7
1325 covered.add( true ); // 8
1326 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1329 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1332 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1335 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1338 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1341 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1342 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1343 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1344 ab.addProteinDomain( a );
1345 ab.addProteinDomain( b );
1346 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1347 if ( ab.getNumberOfProteinDomains() != 2 ) {
1350 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1353 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1356 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1357 if ( ab.getNumberOfProteinDomains() != 2 ) {
1360 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1363 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1364 final Domain d = new BasicDomain( "d",
1371 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1372 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1373 cde.addProteinDomain( c );
1374 cde.addProteinDomain( d );
1375 cde.addProteinDomain( e );
1376 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1377 if ( cde.getNumberOfProteinDomains() != 3 ) {
1380 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1383 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1384 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1385 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1386 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1387 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1388 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1389 fghi.addProteinDomain( f );
1390 fghi.addProteinDomain( g );
1391 fghi.addProteinDomain( h );
1392 fghi.addProteinDomain( i );
1393 fghi.addProteinDomain( i );
1394 fghi.addProteinDomain( i );
1395 fghi.addProteinDomain( i2 );
1396 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1397 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1400 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1403 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1406 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1407 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1410 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1413 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1414 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1415 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1416 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1417 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1418 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1419 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1420 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1421 jklm.addProteinDomain( j );
1422 jklm.addProteinDomain( k );
1423 jklm.addProteinDomain( l );
1424 jklm.addProteinDomain( m );
1425 jklm.addProteinDomain( m0 );
1426 jklm.addProteinDomain( m1 );
1427 jklm.addProteinDomain( m2 );
1428 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1429 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1432 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1435 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1438 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1439 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1442 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1445 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1446 final Protein od = new BasicProtein( "od", "varanus", 0 );
1447 od.addProteinDomain( only );
1448 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1449 if ( od.getNumberOfProteinDomains() != 1 ) {
1452 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1456 catch ( final Exception e ) {
1457 e.printStackTrace( System.out );
1463 private static final boolean testPfamTreeReading() {
1465 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1466 final NHXParser parser = new NHXParser();
1467 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1468 parser.setReplaceUnderscores( false );
1469 parser.setGuessRootedness( true );
1470 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1471 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1474 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1477 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1478 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1481 if ( phys2[ 0 ].getNumberOfExternalNodes() != phys[ 0 ].getNumberOfExternalNodes() ) {
1485 catch ( final Exception e ) {
1486 e.printStackTrace();
1492 private static final boolean testPhyloXMLparsingFromURL() {
1494 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1495 final URL u = new URL( s );
1496 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1498 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1501 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1503 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1507 catch ( final Exception e ) {
1508 e.printStackTrace();
1514 private static final boolean testToLReading() {
1516 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1517 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1518 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1521 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1524 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1527 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1531 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1532 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1533 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1536 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1539 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1543 catch ( final Exception e ) {
1544 e.printStackTrace();
1550 private static final boolean testTreeBaseReading() {
1552 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1553 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1554 parser.setReplaceUnderscores( true );
1555 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1556 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1559 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1560 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1561 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1562 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1565 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1566 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1567 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1568 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1571 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1572 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1573 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1574 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1577 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1578 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1579 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1580 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1583 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1584 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1585 parser2.setReplaceUnderscores( true );
1586 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1587 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1590 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1591 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1592 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1593 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1596 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ),
1597 new NexusPhylogeniesParser() );
1598 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1601 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) ,
1602 new NexusPhylogeniesParser() );
1603 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1606 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) ,
1607 new NexusPhylogeniesParser() );
1608 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1611 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) ,
1612 new NexusPhylogeniesParser() );
1613 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1616 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) ,
1617 new NexusPhylogeniesParser() );
1618 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1621 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) ,
1622 new NexusPhylogeniesParser() );
1623 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1626 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) ,
1627 new NexusPhylogeniesParser() );
1628 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1631 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) ,
1632 new NexusPhylogeniesParser() );
1633 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1636 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) ,
1637 new NexusPhylogeniesParser() );
1638 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1641 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) ,
1642 new NexusPhylogeniesParser() );
1643 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1647 catch ( final Exception e ) {
1648 e.printStackTrace();
1654 private static final boolean testTreeFamReading() {
1656 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1657 final NHXParser parser = new NHXParser();
1658 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1659 parser.setReplaceUnderscores( false );
1660 parser.setGuessRootedness( true );
1661 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1662 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1665 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1669 catch ( final Exception e ) {
1670 e.printStackTrace();
1676 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1677 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1681 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1682 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1685 private static boolean testAminoAcidSequence() {
1687 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1688 if ( aa1.getLength() != 13 ) {
1691 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1694 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1697 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1700 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1701 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1704 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1705 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1708 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1709 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1713 catch ( final Exception e ) {
1714 e.printStackTrace();
1720 private static boolean testBasicDomain() {
1722 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1723 if ( !pd.getDomainId().equals( "id" ) ) {
1726 if ( pd.getNumber() != 1 ) {
1729 if ( pd.getTotalCount() != 4 ) {
1732 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1735 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1736 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1737 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1738 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1739 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1740 if ( !a1.equals( a1 ) ) {
1743 if ( !a1.equals( a1_copy ) ) {
1746 if ( !a1.equals( a1_equal ) ) {
1749 if ( !a1.equals( a2 ) ) {
1752 if ( a1.equals( a3 ) ) {
1755 if ( a1.compareTo( a1 ) != 0 ) {
1758 if ( a1.compareTo( a1_copy ) != 0 ) {
1761 if ( a1.compareTo( a1_equal ) != 0 ) {
1764 if ( a1.compareTo( a2 ) != 0 ) {
1767 if ( a1.compareTo( a3 ) == 0 ) {
1771 catch ( final Exception e ) {
1772 e.printStackTrace( System.out );
1778 private static boolean testBasicNodeMethods() {
1780 if ( PhylogenyNode.getNodeCount() != 0 ) {
1783 final PhylogenyNode n1 = new PhylogenyNode();
1784 final PhylogenyNode n2 = PhylogenyNode
1785 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1786 final PhylogenyNode n3 = PhylogenyNode
1787 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1788 final PhylogenyNode n4 = PhylogenyNode
1789 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1790 if ( n1.isHasAssignedEvent() ) {
1793 if ( PhylogenyNode.getNodeCount() != 4 ) {
1796 if ( n3.getIndicator() != 0 ) {
1799 if ( n3.getNumberOfExternalNodes() != 1 ) {
1802 if ( !n3.isExternal() ) {
1805 if ( !n3.isRoot() ) {
1808 if ( !n4.getName().equals( "n4" ) ) {
1812 catch ( final Exception e ) {
1813 e.printStackTrace( System.out );
1819 private static boolean testUTF8ParsingFromFile() {
1821 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1822 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ),
1824 if ( xml_parser.getErrorCount() > 0 ) {
1825 System.out.println( xml_parser.getErrorMessages().toString() );
1828 if ( phylogenies_xml.length != 1 ) {
1832 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance().create( new StringBuffer( phylogenies_xml[0].toPhyloXML( 0 )),
1835 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
1836 if ( phylogenies_nh.length != 1 ) {
1840 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
1841 if ( phylogenies_nex.length != 1 ) {
1845 final String[] xml_n = phylogenies_xml[0].getAllExternalNodeNames();
1846 final String[] xml_n2 = phylogenies_xml2[0].getAllExternalNodeNames();
1847 final String[] nh_n = phylogenies_nh[0].getAllExternalNodeNames();
1848 final String[] nex_n = phylogenies_nex[0].getAllExternalNodeNames();
1849 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
1850 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
1851 final String n2 = "漢字ひらがなカタカナ";
1852 final String n3 = "อักษรไทย";
1853 final String n4 = "繁體字";
1854 final String n5 = "한글";
1855 final String n6 = "देवनागरी";
1857 final String n7 = "chữ Quốc ngữ";
1858 final String n8 = "ру́сский язы́к";
1859 final String n9 = "អក្សរខ្មែរ";
1861 if ( !xml_n[0].equals( n0 ) ) {
1862 System.out.println( xml_n[0] );
1863 System.out.println( n0 );
1866 if ( !xml_n2[0].equals( n0 ) ) {
1867 System.out.println( xml_n2[0] );
1868 System.out.println( n0 );
1871 if ( !nh_n[0].equals( n0 ) ) {
1872 System.out.println( nh_n[0] );
1873 System.out.println( n0 );
1876 if ( !nex_n[0].equals( n0 ) ) {
1877 System.out.println( nex_n[0] );
1878 System.out.println( n0 );
1882 if ( !xml_n[1].equals( n1 ) ) {
1883 System.out.println( xml_n[1] );
1884 System.out.println( n1 );
1887 if ( !xml_n2[1].equals( n1 ) ) {
1888 System.out.println( xml_n2[1] );
1889 System.out.println( n1 );
1892 if ( !nh_n[1].equals( n1 ) ) {
1893 System.out.println( nh_n[1] );
1894 System.out.println( n1 );
1897 if ( !nex_n[1].equals( n1 ) ) {
1898 System.out.println( nex_n[1] );
1899 System.out.println( n1 );
1903 if ( !xml_n[2].equals( n2 ) ) {
1904 System.out.println( xml_n[2] );
1905 System.out.println( n2 );
1908 if ( !xml_n2[2].equals( n2 ) ) {
1909 System.out.println( xml_n2[2] );
1910 System.out.println( n2 );
1913 if ( !nh_n[2].equals( n2 ) ) {
1914 System.out.println( nh_n[2] );
1915 System.out.println( n2 );
1918 if ( !nex_n[2].equals( n2 ) ) {
1919 System.out.println( nex_n[2] );
1920 System.out.println( n2 );
1924 if ( !xml_n[3].equals( n3 ) ) {
1925 System.out.println( xml_n[3] );
1926 System.out.println( n3 );
1929 if ( !xml_n2[3].equals( n3 ) ) {
1930 System.out.println( xml_n2[3] );
1931 System.out.println( n3 );
1934 if ( !nh_n[3].equals( n3 ) ) {
1935 System.out.println( nh_n[3] );
1936 System.out.println( n3 );
1939 if ( !nex_n[3].equals( n3 ) ) {
1940 System.out.println( nex_n[3] );
1941 System.out.println( n3 );
1945 if ( !xml_n[4].equals( n4 ) ) {
1946 System.out.println( xml_n[4] );
1947 System.out.println( n4 );
1950 if ( !nh_n[4].equals( n4 ) ) {
1951 System.out.println( nh_n[4] );
1952 System.out.println( n4 );
1955 if ( !nex_n[4].equals( n4 ) ) {
1956 System.out.println( nex_n[4] );
1957 System.out.println( n4 );
1961 if ( !xml_n[5].equals( n5 ) ) {
1962 System.out.println( xml_n[5] );
1963 System.out.println( n5 );
1966 if ( !nh_n[5].equals( n5 ) ) {
1967 System.out.println( nh_n[5] );
1968 System.out.println( n5 );
1971 if ( !nex_n[5].equals( n5 ) ) {
1972 System.out.println( nex_n[5] );
1973 System.out.println( n5 );
1977 if ( !xml_n[6].equals( n6 ) ) {
1978 System.out.println( xml_n[6] );
1979 System.out.println( n6 );
1982 if ( !nh_n[6].equals( n6 ) ) {
1983 System.out.println( nh_n[6] );
1984 System.out.println( n6 );
1987 if ( !nex_n[6].equals( n6 ) ) {
1988 System.out.println( nex_n[6] );
1989 System.out.println( n6 );
1993 if ( !xml_n[7].equals( n7 ) ) {
1994 System.out.println( xml_n[7] );
1995 System.out.println( n7 );
1998 if ( !nh_n[7].equals( n7 ) ) {
1999 System.out.println( nh_n[7] );
2000 System.out.println( n7 );
2003 if ( !nex_n[7].equals( n7 ) ) {
2004 System.out.println( nex_n[7] );
2005 System.out.println( n7 );
2008 if ( !xml_n[8].equals( n8 ) ) {
2009 System.out.println( xml_n[8] );
2010 System.out.println( n8 );
2013 if ( !nh_n[8].equals( n8 ) ) {
2014 System.out.println( nh_n[8] );
2015 System.out.println( n8 );
2018 if ( !nex_n[8].equals( n8 ) ) {
2019 System.out.println( nex_n[8] );
2020 System.out.println( n8 );
2023 if ( !xml_n[9].equals( n9 ) ) {
2024 System.out.println( xml_n[9] );
2025 System.out.println( n9 );
2028 if ( !xml_n2[9].equals( n9 ) ) {
2029 System.out.println( xml_n2[9] );
2030 System.out.println( n9 );
2033 if ( !nh_n[9].equals( n9 ) ) {
2034 System.out.println( nh_n[9] );
2035 System.out.println( n9 );
2038 if ( !nex_n[9].equals( n9 ) ) {
2039 System.out.println( nex_n[9] );
2040 System.out.println( n9 );
2043 if (!phylogenies_xml[0].toNewHampshire().equals(
2044 phylogenies_nh[0].toNewHampshire() ) ) {
2045 System.out.println( phylogenies_xml[0].toNewHampshire() );
2046 System.out.println( phylogenies_nh[0].toNewHampshire() );
2049 if (!phylogenies_xml[0].toNewHampshire().equals(
2050 phylogenies_nex[0].toNewHampshire() ) ) {
2051 System.out.println( phylogenies_xml[0].toNewHampshire() );
2052 System.out.println( phylogenies_nex[0].toNewHampshire() );
2056 catch ( final Exception e ) {
2057 e.printStackTrace( System.out );
2065 private static boolean testBasicPhyloXMLparsing() {
2067 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2068 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2069 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2071 if ( xml_parser.getErrorCount() > 0 ) {
2072 System.out.println( xml_parser.getErrorMessages().toString() );
2075 if ( phylogenies_0.length != 4 ) {
2078 final Phylogeny t1 = phylogenies_0[ 0 ];
2079 final Phylogeny t2 = phylogenies_0[ 1 ];
2080 final Phylogeny t3 = phylogenies_0[ 2 ];
2081 final Phylogeny t4 = phylogenies_0[ 3 ];
2082 if ( t1.getNumberOfExternalNodes() != 1 ) {
2085 if ( !t1.isRooted() ) {
2088 if ( t1.isRerootable() ) {
2091 if ( !t1.getType().equals( "gene_tree" ) ) {
2094 if ( t2.getNumberOfExternalNodes() != 2 ) {
2097 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2100 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2103 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2106 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2109 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2112 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2115 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2116 .startsWith( "actgtgggggt" ) ) {
2119 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2120 .startsWith( "ctgtgatgcat" ) ) {
2123 if ( t3.getNumberOfExternalNodes() != 4 ) {
2126 if ( !t1.getName().equals( "t1" ) ) {
2129 if ( !t2.getName().equals( "t2" ) ) {
2132 if ( !t3.getName().equals( "t3" ) ) {
2135 if ( !t4.getName().equals( "t4" ) ) {
2138 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2141 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2144 if ( !t3.getNode( "root node" ).isDuplication() ) {
2147 if ( !t3.getNode( "node a" ).isDuplication() ) {
2150 if ( t3.getNode( "node a" ).isSpeciation() ) {
2153 if ( t3.getNode( "node bc" ).isDuplication() ) {
2156 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2159 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2162 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2163 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2166 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2169 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2172 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
2175 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2176 .equals( "apoptosis" ) ) {
2179 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2180 .equals( "GO:0006915" ) ) {
2183 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2184 .equals( "UniProtKB" ) ) {
2187 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2188 .equals( "experimental" ) ) {
2191 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2192 .equals( "function" ) ) {
2195 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2196 .getValue() != 1 ) {
2199 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2200 .getType().equals( "ml" ) ) {
2203 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2204 .equals( "apoptosis" ) ) {
2207 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2208 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2211 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2212 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2215 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2216 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2219 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2220 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2223 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2224 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2227 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2228 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2231 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2232 .equals( "GO:0005829" ) ) {
2235 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2236 .equals( "intracellular organelle" ) ) {
2239 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2242 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2243 .equals( "UniProt link" ) ) ) {
2246 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2249 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2250 if ( x.size() != 4 ) {
2254 for( final Accession acc : x ) {
2256 if ( !acc.getSource().equals( "KEGG" ) ) {
2259 if ( !acc.getValue().equals( "hsa:596" ) ) {
2266 catch ( final Exception e ) {
2267 e.printStackTrace( System.out );
2273 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2275 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2276 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2277 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2278 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2281 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2283 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2285 if ( xml_parser.getErrorCount() > 0 ) {
2286 System.out.println( xml_parser.getErrorMessages().toString() );
2289 if ( phylogenies_0.length != 4 ) {
2292 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2293 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2294 if ( phylogenies_t1.length != 1 ) {
2297 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2298 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2301 if ( !t1_rt.isRooted() ) {
2304 if ( t1_rt.isRerootable() ) {
2307 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2310 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2311 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2312 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2313 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2316 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2319 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2322 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2325 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2326 .startsWith( "actgtgggggt" ) ) {
2329 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2330 .startsWith( "ctgtgatgcat" ) ) {
2333 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2334 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2335 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2336 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2337 if ( phylogenies_1.length != 1 ) {
2340 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2341 if ( !t3_rt.getName().equals( "t3" ) ) {
2344 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2347 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2350 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2353 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2356 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2357 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2360 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2363 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2366 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2367 .equals( "UniProtKB" ) ) {
2370 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2371 .equals( "apoptosis" ) ) {
2374 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2375 .equals( "GO:0006915" ) ) {
2378 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2379 .equals( "UniProtKB" ) ) {
2382 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2383 .equals( "experimental" ) ) {
2386 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2387 .equals( "function" ) ) {
2390 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2391 .getValue() != 1 ) {
2394 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2395 .getType().equals( "ml" ) ) {
2398 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2399 .equals( "apoptosis" ) ) {
2402 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2403 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2406 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2407 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2410 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2411 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2414 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2415 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2418 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2419 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2422 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2423 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2426 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2427 .equals( "GO:0005829" ) ) {
2430 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2431 .equals( "intracellular organelle" ) ) {
2434 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2437 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2438 .equals( "UniProt link" ) ) ) {
2441 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2444 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2447 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2448 .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." ) ) ) {
2449 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2452 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2455 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2458 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2461 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2464 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2465 .equals( "ncbi" ) ) {
2468 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2471 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2472 .getName().equals( "B" ) ) {
2475 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2476 .getFrom() != 21 ) {
2479 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2482 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2483 .getLength() != 24 ) {
2486 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2487 .getConfidence() != 0 ) {
2490 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2491 .equals( "pfam" ) ) {
2494 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2497 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2500 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2503 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2506 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2507 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2510 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2513 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2516 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2519 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2522 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2525 if ( taxbb.getSynonyms().size() != 2 ) {
2528 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2531 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2534 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2537 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2540 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2543 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2544 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2547 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2550 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2553 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2556 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2559 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2562 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2565 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2568 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2571 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2572 .equalsIgnoreCase( "435" ) ) {
2575 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2578 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2579 .equalsIgnoreCase( "443.7" ) ) {
2582 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2585 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2588 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2589 .equalsIgnoreCase( "433" ) ) {
2592 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2593 .getCrossReferences();
2594 if ( x.size() != 4 ) {
2598 for( final Accession acc : x ) {
2600 if ( !acc.getSource().equals( "KEGG" ) ) {
2603 if ( !acc.getValue().equals( "hsa:596" ) ) {
2610 catch ( final Exception e ) {
2611 e.printStackTrace( System.out );
2617 private static boolean testBasicPhyloXMLparsingValidating() {
2619 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2620 PhyloXmlParser xml_parser = null;
2622 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2624 catch ( final Exception e ) {
2625 // Do nothing -- means were not running from jar.
2627 if ( xml_parser == null ) {
2628 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2629 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2630 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2633 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2636 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2638 if ( xml_parser.getErrorCount() > 0 ) {
2639 System.out.println( xml_parser.getErrorMessages().toString() );
2642 if ( phylogenies_0.length != 4 ) {
2645 final Phylogeny t1 = phylogenies_0[ 0 ];
2646 final Phylogeny t2 = phylogenies_0[ 1 ];
2647 final Phylogeny t3 = phylogenies_0[ 2 ];
2648 final Phylogeny t4 = phylogenies_0[ 3 ];
2649 if ( !t1.getName().equals( "t1" ) ) {
2652 if ( !t2.getName().equals( "t2" ) ) {
2655 if ( !t3.getName().equals( "t3" ) ) {
2658 if ( !t4.getName().equals( "t4" ) ) {
2661 if ( t1.getNumberOfExternalNodes() != 1 ) {
2664 if ( t2.getNumberOfExternalNodes() != 2 ) {
2667 if ( t3.getNumberOfExternalNodes() != 4 ) {
2670 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2671 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2672 if ( xml_parser.getErrorCount() > 0 ) {
2673 System.out.println( "errors:" );
2674 System.out.println( xml_parser.getErrorMessages().toString() );
2677 if ( phylogenies_1.length != 4 ) {
2680 final Phylogeny[] phylogenies_2 = factory.create( new File(Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ),
2682 if ( xml_parser.getErrorCount() > 0 ) {
2683 System.out.println( "errors:" );
2684 System.out.println( xml_parser.getErrorMessages().toString() );
2687 if ( phylogenies_2.length != 1 ) {
2690 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2693 final Phylogeny[] phylogenies_3 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ),
2695 if ( xml_parser.getErrorCount() > 0 ) {
2696 System.out.println( xml_parser.getErrorMessages().toString() );
2699 if ( phylogenies_3.length != 2 ) {
2702 final Phylogeny a = phylogenies_3[ 0 ];
2703 if ( !a.getName().equals( "tree 4" ) ) {
2706 if ( a.getNumberOfExternalNodes() != 3 ) {
2709 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2712 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2715 final Phylogeny[] phylogenies_4 = factory.create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml") ,
2717 if ( xml_parser.getErrorCount() > 0 ) {
2718 System.out.println( xml_parser.getErrorMessages().toString() );
2721 if ( phylogenies_4.length != 1 ) {
2724 final Phylogeny s = phylogenies_4[ 0 ];
2725 if ( s.getNumberOfExternalNodes() != 6 ) {
2728 s.getNode( "first" );
2730 s.getNode( "\"<a'b&c'd\">\"" );
2731 s.getNode( "'''\"" );
2732 s.getNode( "\"\"\"" );
2733 s.getNode( "dick & doof" );
2735 catch ( final Exception e ) {
2736 e.printStackTrace( System.out );
2742 private static boolean testBasicProtein() {
2744 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2745 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2746 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2747 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2748 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2749 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2750 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2751 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2752 p0.addProteinDomain( y );
2753 p0.addProteinDomain( e );
2754 p0.addProteinDomain( b );
2755 p0.addProteinDomain( c );
2756 p0.addProteinDomain( d );
2757 p0.addProteinDomain( a );
2758 p0.addProteinDomain( x );
2759 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2762 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2766 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2767 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2768 aa0.addProteinDomain( a1 );
2769 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2772 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2776 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2777 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2778 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2779 aa1.addProteinDomain( a11 );
2780 aa1.addProteinDomain( a12 );
2781 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2784 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2787 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2788 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2791 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2794 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2797 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2798 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2801 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2804 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2807 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2810 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2811 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2814 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2817 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2820 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2823 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2824 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2827 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2830 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2833 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2837 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2838 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2839 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2840 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2841 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2842 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2843 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2844 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2845 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2846 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2847 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2848 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2849 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2850 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2851 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2852 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2853 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2854 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2855 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2856 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2857 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2858 p00.addProteinDomain( y0 );
2859 p00.addProteinDomain( e0 );
2860 p00.addProteinDomain( b0 );
2861 p00.addProteinDomain( c0 );
2862 p00.addProteinDomain( d0 );
2863 p00.addProteinDomain( a0 );
2864 p00.addProteinDomain( x0 );
2865 p00.addProteinDomain( y1 );
2866 p00.addProteinDomain( y2 );
2867 p00.addProteinDomain( y3 );
2868 p00.addProteinDomain( e1 );
2869 p00.addProteinDomain( e2 );
2870 p00.addProteinDomain( e3 );
2871 p00.addProteinDomain( e4 );
2872 p00.addProteinDomain( e5 );
2873 p00.addProteinDomain( z0 );
2874 p00.addProteinDomain( z1 );
2875 p00.addProteinDomain( z2 );
2876 p00.addProteinDomain( zz0 );
2877 p00.addProteinDomain( zz1 );
2878 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2881 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2884 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2887 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2890 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" ) ) {
2893 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2894 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2895 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2896 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2897 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2898 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2899 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2900 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2901 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2902 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2903 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2904 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2905 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2906 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2907 p.addProteinDomain( B15 );
2908 p.addProteinDomain( C50 );
2909 p.addProteinDomain( A60 );
2910 p.addProteinDomain( A30 );
2911 p.addProteinDomain( C70 );
2912 p.addProteinDomain( B35 );
2913 p.addProteinDomain( B40 );
2914 p.addProteinDomain( A0 );
2915 p.addProteinDomain( A10 );
2916 p.addProteinDomain( A20 );
2917 p.addProteinDomain( B25 );
2918 p.addProteinDomain( D80 );
2919 List<String> domains_ids = new ArrayList<String>();
2920 domains_ids.add( "A" );
2921 domains_ids.add( "B" );
2922 domains_ids.add( "C" );
2923 if ( !p.contains( domains_ids, false ) ) {
2926 if ( !p.contains( domains_ids, true ) ) {
2929 domains_ids.add( "X" );
2930 if ( p.contains( domains_ids, false ) ) {
2933 if ( p.contains( domains_ids, true ) ) {
2936 domains_ids = new ArrayList<String>();
2937 domains_ids.add( "A" );
2938 domains_ids.add( "C" );
2939 domains_ids.add( "D" );
2940 if ( !p.contains( domains_ids, false ) ) {
2943 if ( !p.contains( domains_ids, true ) ) {
2946 domains_ids = new ArrayList<String>();
2947 domains_ids.add( "A" );
2948 domains_ids.add( "D" );
2949 domains_ids.add( "C" );
2950 if ( !p.contains( domains_ids, false ) ) {
2953 if ( p.contains( domains_ids, true ) ) {
2956 domains_ids = new ArrayList<String>();
2957 domains_ids.add( "A" );
2958 domains_ids.add( "A" );
2959 domains_ids.add( "B" );
2960 if ( !p.contains( domains_ids, false ) ) {
2963 if ( !p.contains( domains_ids, true ) ) {
2966 domains_ids = new ArrayList<String>();
2967 domains_ids.add( "A" );
2968 domains_ids.add( "A" );
2969 domains_ids.add( "A" );
2970 domains_ids.add( "B" );
2971 domains_ids.add( "B" );
2972 if ( !p.contains( domains_ids, false ) ) {
2975 if ( !p.contains( domains_ids, true ) ) {
2978 domains_ids = new ArrayList<String>();
2979 domains_ids.add( "A" );
2980 domains_ids.add( "A" );
2981 domains_ids.add( "B" );
2982 domains_ids.add( "A" );
2983 domains_ids.add( "B" );
2984 domains_ids.add( "B" );
2985 domains_ids.add( "A" );
2986 domains_ids.add( "B" );
2987 domains_ids.add( "C" );
2988 domains_ids.add( "A" );
2989 domains_ids.add( "C" );
2990 domains_ids.add( "D" );
2991 if ( !p.contains( domains_ids, false ) ) {
2994 if ( p.contains( domains_ids, true ) ) {
2998 catch ( final Exception e ) {
2999 e.printStackTrace( System.out );
3005 private static boolean testBasicTable() {
3007 final BasicTable<String> t0 = new BasicTable<String>();
3008 if ( t0.getNumberOfColumns() != 0 ) {
3011 if ( t0.getNumberOfRows() != 0 ) {
3014 t0.setValue( 3, 2, "23" );
3015 t0.setValue( 10, 1, "error" );
3016 t0.setValue( 10, 1, "110" );
3017 t0.setValue( 9, 1, "19" );
3018 t0.setValue( 1, 10, "101" );
3019 t0.setValue( 10, 10, "1010" );
3020 t0.setValue( 100, 10, "10100" );
3021 t0.setValue( 0, 0, "00" );
3022 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3025 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3028 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3031 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3034 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3037 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3040 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3043 if ( t0.getNumberOfColumns() != 101 ) {
3046 if ( t0.getNumberOfRows() != 11 ) {
3049 if ( t0.getValueAsString( 49, 4 ) != null ) {
3052 final String l = ForesterUtil.getLineSeparator();
3053 final StringBuffer source = new StringBuffer();
3054 source.append( "" + l );
3055 source.append( "# 1 1 1 1 1 1 1 1" + l );
3056 source.append( " 00 01 02 03" + l );
3057 source.append( " 10 11 12 13 " + l );
3058 source.append( "20 21 22 23 " + l );
3059 source.append( " 30 31 32 33" + l );
3060 source.append( "40 41 42 43" + l );
3061 source.append( " # 1 1 1 1 1 " + l );
3062 source.append( "50 51 52 53 54" + l );
3063 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3064 if ( t1.getNumberOfColumns() != 5 ) {
3067 if ( t1.getNumberOfRows() != 6 ) {
3070 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3073 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3076 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3079 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3082 final StringBuffer source1 = new StringBuffer();
3083 source1.append( "" + l );
3084 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3085 source1.append( " 00; 01 ;02;03" + l );
3086 source1.append( " 10; 11; 12; 13 " + l );
3087 source1.append( "20; 21; 22; 23 " + l );
3088 source1.append( " 30; 31; 32; 33" + l );
3089 source1.append( "40;41;42;43" + l );
3090 source1.append( " # 1 1 1 1 1 " + l );
3091 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3092 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3093 if ( t2.getNumberOfColumns() != 5 ) {
3096 if ( t2.getNumberOfRows() != 6 ) {
3099 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3102 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3105 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3108 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3111 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3114 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3117 final StringBuffer source2 = new StringBuffer();
3118 source2.append( "" + l );
3119 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3120 source2.append( " 00; 01 ;02;03" + l );
3121 source2.append( " 10; 11; 12; 13 " + l );
3122 source2.append( "20; 21; 22; 23 " + l );
3123 source2.append( " " + l );
3124 source2.append( " 30; 31; 32; 33" + l );
3125 source2.append( "40;41;42;43" + l );
3126 source2.append( " comment: 1 1 1 1 1 " + l );
3127 source2.append( ";;;50 ; 52; 53;;54 " + l );
3128 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3134 if ( tl.size() != 2 ) {
3137 final BasicTable<String> t3 = tl.get( 0 );
3138 final BasicTable<String> t4 = tl.get( 1 );
3139 if ( t3.getNumberOfColumns() != 4 ) {
3142 if ( t3.getNumberOfRows() != 3 ) {
3145 if ( t4.getNumberOfColumns() != 4 ) {
3148 if ( t4.getNumberOfRows() != 3 ) {
3151 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3154 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3158 catch ( final Exception e ) {
3159 e.printStackTrace( System.out );
3165 private static boolean testBasicTolXMLparsing() {
3167 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3168 final TolParser parser = new TolParser();
3169 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3170 if ( parser.getErrorCount() > 0 ) {
3171 System.out.println( parser.getErrorMessages().toString() );
3174 if ( phylogenies_0.length != 1 ) {
3177 final Phylogeny t1 = phylogenies_0[ 0 ];
3178 if ( t1.getNumberOfExternalNodes() != 5 ) {
3181 if ( !t1.isRooted() ) {
3184 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3187 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3190 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
3193 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3196 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3197 if ( parser.getErrorCount() > 0 ) {
3198 System.out.println( parser.getErrorMessages().toString() );
3201 if ( phylogenies_1.length != 1 ) {
3204 final Phylogeny t2 = phylogenies_1[ 0 ];
3205 if ( t2.getNumberOfExternalNodes() != 664 ) {
3208 if ( !t2.isRooted() ) {
3211 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3214 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3217 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3220 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3223 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
3226 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3227 .equals( "Aquifex" ) ) {
3230 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3231 if ( parser.getErrorCount() > 0 ) {
3232 System.out.println( parser.getErrorMessages().toString() );
3235 if ( phylogenies_2.length != 1 ) {
3238 final Phylogeny t3 = phylogenies_2[ 0 ];
3239 if ( t3.getNumberOfExternalNodes() != 184 ) {
3242 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3245 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3248 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3251 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3252 if ( parser.getErrorCount() > 0 ) {
3253 System.out.println( parser.getErrorMessages().toString() );
3256 if ( phylogenies_3.length != 1 ) {
3259 final Phylogeny t4 = phylogenies_3[ 0 ];
3260 if ( t4.getNumberOfExternalNodes() != 1 ) {
3263 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3266 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3269 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3272 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3273 if ( parser.getErrorCount() > 0 ) {
3274 System.out.println( parser.getErrorMessages().toString() );
3277 if ( phylogenies_4.length != 1 ) {
3280 final Phylogeny t5 = phylogenies_4[ 0 ];
3281 if ( t5.getNumberOfExternalNodes() != 13 ) {
3284 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3287 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3290 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3294 catch ( final Exception e ) {
3295 e.printStackTrace( System.out );
3301 private static boolean testBasicTreeMethods() {
3303 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3304 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3305 if ( t2.getNumberOfExternalNodes() != 4 ) {
3308 if ( t2.getHeight() != 8.5 ) {
3311 if ( !t2.isCompletelyBinary() ) {
3314 if ( t2.isEmpty() ) {
3317 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3318 if ( t3.getNumberOfExternalNodes() != 5 ) {
3321 if ( t3.getHeight() != 11 ) {
3324 if ( t3.isCompletelyBinary() ) {
3327 final PhylogenyNode n = t3.getNode( "ABC" );
3328 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 ];
3329 if ( t4.getNumberOfExternalNodes() != 9 ) {
3332 if ( t4.getHeight() != 11 ) {
3335 if ( t4.isCompletelyBinary() ) {
3338 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)" );
3339 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3340 if ( t5.getNumberOfExternalNodes() != 8 ) {
3343 if ( t5.getHeight() != 15 ) {
3346 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)" );
3347 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3348 if ( t6.getHeight() != 15 ) {
3351 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)" );
3352 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3353 if ( t7.getHeight() != 15 ) {
3356 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)" );
3357 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3358 if ( t8.getNumberOfExternalNodes() != 10 ) {
3361 if ( t8.getHeight() != 15 ) {
3364 final char[] a9 = new char[] { 'a' };
3365 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3366 if ( t9.getHeight() != 0 ) {
3369 final char[] a10 = new char[] { 'a', ':', '6' };
3370 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3371 if ( t10.getHeight() != 6 ) {
3375 catch ( final Exception e ) {
3376 e.printStackTrace( System.out );
3382 private static boolean testConfidenceAssessor() {
3384 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3385 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3386 final Phylogeny[] ev0 = factory
3387 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3389 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3390 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3393 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3396 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3397 final Phylogeny[] ev1 = factory
3398 .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)));",
3400 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3401 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3404 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3407 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3408 final Phylogeny[] ev_b = factory
3409 .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",
3411 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3412 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3415 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3419 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3420 final Phylogeny[] ev1x = factory
3421 .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)));",
3423 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3424 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3427 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3430 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3431 final Phylogeny[] ev_bx = factory
3432 .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",
3434 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3435 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3438 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3441 final Phylogeny[] t2 = factory
3442 .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);",
3444 final Phylogeny[] ev2 = factory
3445 .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);",
3447 for( final Phylogeny target : t2 ) {
3448 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3450 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3451 new NHXParser() )[ 0 ];
3452 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3453 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3454 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3457 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3460 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3464 catch ( final Exception e ) {
3465 e.printStackTrace();
3471 private static boolean testCopyOfNodeData() {
3473 final PhylogenyNode n1 = PhylogenyNode
3474 .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]" );
3475 final PhylogenyNode n2 = n1.copyNodeData();
3476 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3480 catch ( final Exception e ) {
3481 e.printStackTrace();
3487 private static boolean testCreateBalancedPhylogeny() {
3489 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3490 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3493 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3496 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3497 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3500 if ( p1.getNumberOfExternalNodes() != 100 ) {
3504 catch ( final Exception e ) {
3505 e.printStackTrace();
3511 private static boolean testCreateUriForSeqWeb() {
3513 final PhylogenyNode n = new PhylogenyNode();
3514 n.setName( "tr|B3RJ64" );
3515 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3518 n.setName( "B0LM41_HUMAN" );
3519 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3522 n.setName( "NP_001025424" );
3523 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3526 n.setName( "_NM_001030253-" );
3527 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3530 n.setName( "XM_002122186" );
3531 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3534 n.setName( "dgh_AAA34956_gdg" );
3535 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3538 n.setName( "AAA34956" );
3539 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3542 n.setName( "GI:394892" );
3543 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3544 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3547 n.setName( "gi_394892" );
3548 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3549 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3552 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3553 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3554 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3557 n.setName( "P12345" );
3558 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3559 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3562 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3563 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3564 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3568 catch ( final Exception e ) {
3569 e.printStackTrace( System.out );
3575 private static boolean testDataObjects() {
3577 final Confidence s0 = new Confidence();
3578 final Confidence s1 = new Confidence();
3579 if ( !s0.isEqual( s1 ) ) {
3582 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3583 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3584 if ( s2.isEqual( s1 ) ) {
3587 if ( !s2.isEqual( s3 ) ) {
3590 final Confidence s4 = ( Confidence ) s3.copy();
3591 if ( !s4.isEqual( s3 ) ) {
3598 final Taxonomy t1 = new Taxonomy();
3599 final Taxonomy t2 = new Taxonomy();
3600 final Taxonomy t3 = new Taxonomy();
3601 final Taxonomy t4 = new Taxonomy();
3602 final Taxonomy t5 = new Taxonomy();
3603 t1.setIdentifier( new Identifier( "ecoli" ) );
3604 t1.setTaxonomyCode( "ECOLI" );
3605 t1.setScientificName( "E. coli" );
3606 t1.setCommonName( "coli" );
3607 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3608 if ( !t1.isEqual( t0 ) ) {
3611 t2.setIdentifier( new Identifier( "ecoli" ) );
3612 t2.setTaxonomyCode( "OTHER" );
3613 t2.setScientificName( "what" );
3614 t2.setCommonName( "something" );
3615 if ( !t1.isEqual( t2 ) ) {
3618 t2.setIdentifier( new Identifier( "nemve" ) );
3619 if ( t1.isEqual( t2 ) ) {
3622 t1.setIdentifier( null );
3623 t3.setTaxonomyCode( "ECOLI" );
3624 t3.setScientificName( "what" );
3625 t3.setCommonName( "something" );
3626 if ( !t1.isEqual( t3 ) ) {
3629 t1.setIdentifier( null );
3630 t1.setTaxonomyCode( "" );
3631 t4.setScientificName( "E. ColI" );
3632 t4.setCommonName( "something" );
3633 if ( !t1.isEqual( t4 ) ) {
3636 t4.setScientificName( "B. subtilis" );
3637 t4.setCommonName( "something" );
3638 if ( t1.isEqual( t4 ) ) {
3641 t1.setIdentifier( null );
3642 t1.setTaxonomyCode( "" );
3643 t1.setScientificName( "" );
3644 t5.setCommonName( "COLI" );
3645 if ( !t1.isEqual( t5 ) ) {
3648 t5.setCommonName( "vibrio" );
3649 if ( t1.isEqual( t5 ) ) {
3654 final Identifier id0 = new Identifier( "123", "pfam" );
3655 final Identifier id1 = ( Identifier ) id0.copy();
3656 if ( !id1.isEqual( id1 ) ) {
3659 if ( !id1.isEqual( id0 ) ) {
3662 if ( !id0.isEqual( id1 ) ) {
3669 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3670 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3671 if ( !pd1.isEqual( pd1 ) ) {
3674 if ( !pd1.isEqual( pd0 ) ) {
3679 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3680 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3681 if ( !pd3.isEqual( pd3 ) ) {
3684 if ( !pd2.isEqual( pd3 ) ) {
3687 if ( !pd0.isEqual( pd3 ) ) {
3692 // DomainArchitecture
3693 // ------------------
3694 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3695 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3696 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3697 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3698 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3699 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3704 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3705 if ( ds0.getNumberOfDomains() != 4 ) {
3708 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3709 if ( !ds0.isEqual( ds0 ) ) {
3712 if ( !ds0.isEqual( ds1 ) ) {
3715 if ( ds1.getNumberOfDomains() != 4 ) {
3718 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3723 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3724 if ( ds0.isEqual( ds2 ) ) {
3730 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3731 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3732 System.out.println( ds3.toNHX() );
3735 if ( ds3.getNumberOfDomains() != 3 ) {
3740 final Event e1 = new Event( Event.EventType.fusion );
3741 if ( e1.isDuplication() ) {
3744 if ( !e1.isFusion() ) {
3747 if ( !e1.asText().toString().equals( "fusion" ) ) {
3750 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3753 final Event e11 = new Event( Event.EventType.fusion );
3754 if ( !e11.isEqual( e1 ) ) {
3757 if ( !e11.toNHX().toString().equals( "" ) ) {
3760 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3761 if ( e2.isDuplication() ) {
3764 if ( !e2.isSpeciationOrDuplication() ) {
3767 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3770 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3773 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3776 if ( e11.isEqual( e2 ) ) {
3779 final Event e2c = ( Event ) e2.copy();
3780 if ( !e2c.isEqual( e2 ) ) {
3783 Event e3 = new Event( 1, 2, 3 );
3784 if ( e3.isDuplication() ) {
3787 if ( e3.isSpeciation() ) {
3790 if ( e3.isGeneLoss() ) {
3793 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3796 final Event e3c = ( Event ) e3.copy();
3797 final Event e3cc = ( Event ) e3c.copy();
3798 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3802 if ( !e3c.isEqual( e3cc ) ) {
3805 Event e4 = new Event( 1, 2, 3 );
3806 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3809 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3812 final Event e4c = ( Event ) e4.copy();
3814 final Event e4cc = ( Event ) e4c.copy();
3815 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3818 if ( !e4c.isEqual( e4cc ) ) {
3821 final Event e5 = new Event();
3822 if ( !e5.isUnassigned() ) {
3825 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3828 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3831 final Event e6 = new Event( 1, 0, 0 );
3832 if ( !e6.asText().toString().equals( "duplication" ) ) {
3835 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3838 final Event e7 = new Event( 0, 1, 0 );
3839 if ( !e7.asText().toString().equals( "speciation" ) ) {
3842 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3845 final Event e8 = new Event( 0, 0, 1 );
3846 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3849 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3853 catch ( final Exception e ) {
3854 e.printStackTrace( System.out );
3860 private static boolean testDeletionOfExternalNodes() {
3862 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3863 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3864 final PhylogenyWriter w = new PhylogenyWriter();
3865 if ( t0.isEmpty() ) {
3868 if ( t0.getNumberOfExternalNodes() != 1 ) {
3871 t0.deleteSubtree( t0.getNode( "A" ), false );
3872 if ( t0.getNumberOfExternalNodes() != 0 ) {
3875 if ( !t0.isEmpty() ) {
3878 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3879 if ( t1.getNumberOfExternalNodes() != 2 ) {
3882 t1.deleteSubtree( t1.getNode( "A" ), false );
3883 if ( t1.getNumberOfExternalNodes() != 1 ) {
3886 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3889 t1.deleteSubtree( t1.getNode( "B" ), false );
3890 if ( t1.getNumberOfExternalNodes() != 1 ) {
3893 t1.deleteSubtree( t1.getNode( "r" ), false );
3894 if ( !t1.isEmpty() ) {
3897 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3898 if ( t2.getNumberOfExternalNodes() != 3 ) {
3901 t2.deleteSubtree( t2.getNode( "B" ), false );
3902 if ( t2.getNumberOfExternalNodes() != 2 ) {
3905 t2.toNewHampshireX();
3906 PhylogenyNode n = t2.getNode( "A" );
3907 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3910 t2.deleteSubtree( t2.getNode( "A" ), false );
3911 if ( t2.getNumberOfExternalNodes() != 2 ) {
3914 t2.deleteSubtree( t2.getNode( "C" ), true );
3915 if ( t2.getNumberOfExternalNodes() != 1 ) {
3918 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3919 if ( t3.getNumberOfExternalNodes() != 4 ) {
3922 t3.deleteSubtree( t3.getNode( "B" ), true );
3923 if ( t3.getNumberOfExternalNodes() != 3 ) {
3926 n = t3.getNode( "A" );
3927 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3930 n = n.getNextExternalNode();
3931 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3934 t3.deleteSubtree( t3.getNode( "A" ), true );
3935 if ( t3.getNumberOfExternalNodes() != 2 ) {
3938 n = t3.getNode( "C" );
3939 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3942 t3.deleteSubtree( t3.getNode( "C" ), true );
3943 if ( t3.getNumberOfExternalNodes() != 1 ) {
3946 t3.deleteSubtree( t3.getNode( "D" ), true );
3947 if ( t3.getNumberOfExternalNodes() != 0 ) {
3950 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3951 if ( t4.getNumberOfExternalNodes() != 6 ) {
3954 t4.deleteSubtree( t4.getNode( "B2" ), true );
3955 if ( t4.getNumberOfExternalNodes() != 5 ) {
3958 String s = w.toNewHampshire( t4, true ).toString();
3959 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3962 t4.deleteSubtree( t4.getNode( "B11" ), true );
3963 if ( t4.getNumberOfExternalNodes() != 4 ) {
3966 t4.deleteSubtree( t4.getNode( "C" ), true );
3967 if ( t4.getNumberOfExternalNodes() != 3 ) {
3970 n = t4.getNode( "A" );
3971 n = n.getNextExternalNode();
3972 if ( !n.getName().equals( "B12" ) ) {
3975 n = n.getNextExternalNode();
3976 if ( !n.getName().equals( "D" ) ) {
3979 s = w.toNewHampshire( t4, true ).toString();
3980 if ( !s.equals( "((A,B12),D);" ) ) {
3983 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3984 t5.deleteSubtree( t5.getNode( "A" ), true );
3985 if ( t5.getNumberOfExternalNodes() != 5 ) {
3988 s = w.toNewHampshire( t5, true ).toString();
3989 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3992 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3993 t6.deleteSubtree( t6.getNode( "B11" ), true );
3994 if ( t6.getNumberOfExternalNodes() != 5 ) {
3997 s = w.toNewHampshire( t6, false ).toString();
3998 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4001 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4002 t7.deleteSubtree( t7.getNode( "B12" ), true );
4003 if ( t7.getNumberOfExternalNodes() != 5 ) {
4006 s = w.toNewHampshire( t7, true ).toString();
4007 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4010 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4011 t8.deleteSubtree( t8.getNode( "B2" ), true );
4012 if ( t8.getNumberOfExternalNodes() != 5 ) {
4015 s = w.toNewHampshire( t8, false ).toString();
4016 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4019 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4020 t9.deleteSubtree( t9.getNode( "C" ), true );
4021 if ( t9.getNumberOfExternalNodes() != 5 ) {
4024 s = w.toNewHampshire( t9, true ).toString();
4025 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4028 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4029 t10.deleteSubtree( t10.getNode( "D" ), true );
4030 if ( t10.getNumberOfExternalNodes() != 5 ) {
4033 s = w.toNewHampshire( t10, true ).toString();
4034 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4037 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4038 t11.deleteSubtree( t11.getNode( "A" ), true );
4039 if ( t11.getNumberOfExternalNodes() != 2 ) {
4042 s = w.toNewHampshire( t11, true ).toString();
4043 if ( !s.equals( "(B,C);" ) ) {
4046 t11.deleteSubtree( t11.getNode( "C" ), true );
4047 if ( t11.getNumberOfExternalNodes() != 1 ) {
4050 s = w.toNewHampshire( t11, false ).toString();
4051 if ( !s.equals( "B;" ) ) {
4054 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4055 t12.deleteSubtree( t12.getNode( "B2" ), true );
4056 if ( t12.getNumberOfExternalNodes() != 8 ) {
4059 s = w.toNewHampshire( t12, true ).toString();
4060 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4063 t12.deleteSubtree( t12.getNode( "B3" ), true );
4064 if ( t12.getNumberOfExternalNodes() != 7 ) {
4067 s = w.toNewHampshire( t12, true ).toString();
4068 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4071 t12.deleteSubtree( t12.getNode( "C3" ), true );
4072 if ( t12.getNumberOfExternalNodes() != 6 ) {
4075 s = w.toNewHampshire( t12, true ).toString();
4076 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4079 t12.deleteSubtree( t12.getNode( "A1" ), true );
4080 if ( t12.getNumberOfExternalNodes() != 5 ) {
4083 s = w.toNewHampshire( t12, true ).toString();
4084 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4087 t12.deleteSubtree( t12.getNode( "B1" ), true );
4088 if ( t12.getNumberOfExternalNodes() != 4 ) {
4091 s = w.toNewHampshire( t12, true ).toString();
4092 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4095 t12.deleteSubtree( t12.getNode( "A3" ), true );
4096 if ( t12.getNumberOfExternalNodes() != 3 ) {
4099 s = w.toNewHampshire( t12, true ).toString();
4100 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4103 t12.deleteSubtree( t12.getNode( "A2" ), true );
4104 if ( t12.getNumberOfExternalNodes() != 2 ) {
4107 s = w.toNewHampshire( t12, true ).toString();
4108 if ( !s.equals( "(C1,C2);" ) ) {
4111 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4112 t13.deleteSubtree( t13.getNode( "D" ), true );
4113 if ( t13.getNumberOfExternalNodes() != 4 ) {
4116 s = w.toNewHampshire( t13, true ).toString();
4117 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4120 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4121 t14.deleteSubtree( t14.getNode( "E" ), true );
4122 if ( t14.getNumberOfExternalNodes() != 5 ) {
4125 s = w.toNewHampshire( t14, true ).toString();
4126 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4129 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4130 t15.deleteSubtree( t15.getNode( "B2" ), true );
4131 if ( t15.getNumberOfExternalNodes() != 11 ) {
4134 t15.deleteSubtree( t15.getNode( "B1" ), true );
4135 if ( t15.getNumberOfExternalNodes() != 10 ) {
4138 t15.deleteSubtree( t15.getNode( "B3" ), true );
4139 if ( t15.getNumberOfExternalNodes() != 9 ) {
4142 t15.deleteSubtree( t15.getNode( "B4" ), true );
4143 if ( t15.getNumberOfExternalNodes() != 8 ) {
4146 t15.deleteSubtree( t15.getNode( "A1" ), true );
4147 if ( t15.getNumberOfExternalNodes() != 7 ) {
4150 t15.deleteSubtree( t15.getNode( "C4" ), true );
4151 if ( t15.getNumberOfExternalNodes() != 6 ) {
4155 catch ( final Exception e ) {
4156 e.printStackTrace( System.out );
4162 private static boolean testDescriptiveStatistics() {
4164 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4165 dss1.addValue( 82 );
4166 dss1.addValue( 78 );
4167 dss1.addValue( 70 );
4168 dss1.addValue( 58 );
4169 dss1.addValue( 42 );
4170 if ( dss1.getN() != 5 ) {
4173 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4176 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4179 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4182 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4185 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4188 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4191 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4194 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4197 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4200 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4203 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4206 dss1.addValue( 123 );
4207 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4210 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4213 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4216 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4217 dss2.addValue( -1.85 );
4218 dss2.addValue( 57.5 );
4219 dss2.addValue( 92.78 );
4220 dss2.addValue( 57.78 );
4221 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4224 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4227 final double[] a = dss2.getDataAsDoubleArray();
4228 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4231 dss2.addValue( -100 );
4232 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4235 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4238 final double[] ds = new double[ 14 ];
4253 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4254 if ( bins.length != 4 ) {
4257 if ( bins[ 0 ] != 2 ) {
4260 if ( bins[ 1 ] != 3 ) {
4263 if ( bins[ 2 ] != 4 ) {
4266 if ( bins[ 3 ] != 5 ) {
4269 final double[] ds1 = new double[ 9 ];
4279 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4280 if ( bins1.length != 4 ) {
4283 if ( bins1[ 0 ] != 2 ) {
4286 if ( bins1[ 1 ] != 3 ) {
4289 if ( bins1[ 2 ] != 0 ) {
4292 if ( bins1[ 3 ] != 4 ) {
4295 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4296 if ( bins1_1.length != 3 ) {
4299 if ( bins1_1[ 0 ] != 3 ) {
4302 if ( bins1_1[ 1 ] != 2 ) {
4305 if ( bins1_1[ 2 ] != 4 ) {
4308 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4309 if ( bins1_2.length != 3 ) {
4312 if ( bins1_2[ 0 ] != 2 ) {
4315 if ( bins1_2[ 1 ] != 2 ) {
4318 if ( bins1_2[ 2 ] != 2 ) {
4321 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4335 dss3.addValue( 10 );
4336 dss3.addValue( 10 );
4337 dss3.addValue( 10 );
4338 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4339 histo.toStringBuffer( 10, '=', 40, 5 );
4340 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4342 catch ( final Exception e ) {
4343 e.printStackTrace( System.out );
4349 private static boolean testDir( final String file ) {
4351 final File f = new File( file );
4352 if ( !f.exists() ) {
4355 if ( !f.isDirectory() ) {
4358 if ( !f.canRead() ) {
4362 catch ( final Exception e ) {
4368 private static boolean testEbiEntryRetrieval() {
4370 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4371 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4372 System.out.println( entry.getAccession() );
4375 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4376 System.out.println( entry.getTaxonomyScientificName() );
4379 if ( !entry.getSequenceName()
4380 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4381 System.out.println( entry.getSequenceName() );
4384 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4385 System.out.println( entry.getGeneName() );
4388 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4389 System.out.println( entry.getTaxonomyIdentifier() );
4392 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4393 System.out.println( entry.getAnnotations().first().getRefValue() );
4396 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4397 System.out.println( entry.getAnnotations().first().getRefSource() );
4400 if ( entry.getCrossReferences().size() < 1 ) {
4403 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4404 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4407 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4408 System.out.println( entry1.getTaxonomyScientificName() );
4411 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4412 System.out.println( entry1.getSequenceName() );
4415 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4416 System.out.println( entry1.getTaxonomyIdentifier() );
4419 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4420 System.out.println( entry1.getGeneName() );
4423 if ( entry1.getCrossReferences().size() < 1 ) {
4426 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4427 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4430 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4431 System.out.println( entry2.getTaxonomyScientificName() );
4434 if ( !entry2.getSequenceName()
4435 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4436 System.out.println( entry2.getSequenceName() );
4439 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4440 System.out.println( entry2.getTaxonomyIdentifier() );
4443 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4444 System.out.println( entry2.getGeneName() );
4447 if ( entry2.getCrossReferences().size() < 1 ) {
4450 if ( !entry2.getChromosome().equals( "20" ) ) {
4453 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4456 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4457 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4460 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4461 System.out.println( entry3.getTaxonomyScientificName() );
4464 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4465 System.out.println( entry3.getSequenceName() );
4468 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4469 System.out.println( entry3.getTaxonomyIdentifier() );
4472 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4473 System.out.println( entry3.getSequenceSymbol() );
4476 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4479 if ( entry3.getCrossReferences().size() < 1 ) {
4482 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4483 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4486 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4487 System.out.println( entry4.getTaxonomyScientificName() );
4490 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4491 System.out.println( entry4.getSequenceName() );
4494 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4495 System.out.println( entry4.getTaxonomyIdentifier() );
4498 if ( !entry4.getGeneName().equals( "ras" ) ) {
4499 System.out.println( entry4.getGeneName() );
4502 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4503 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4506 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4507 System.out.println( entry5.getTaxonomyScientificName() );
4510 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4511 System.out.println( entry5.getSequenceName() );
4514 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4515 System.out.println( entry5.getTaxonomyIdentifier() );
4518 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4519 if ( !entry6.getAccession().equals( "M30539" ) ) {
4522 if ( !entry6.getGeneName().equals( "ras" ) ) {
4525 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4528 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4531 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4534 if ( entry6.getCrossReferences().size() < 1 ) {
4538 catch ( final IOException e ) {
4539 System.out.println();
4540 System.out.println( "the following might be due to absence internet connection:" );
4541 e.printStackTrace( System.out );
4544 catch ( final Exception e ) {
4545 e.printStackTrace();
4551 private static boolean testExternalNodeRelatedMethods() {
4553 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4554 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4555 PhylogenyNode n = t1.getNode( "A" );
4556 n = n.getNextExternalNode();
4557 if ( !n.getName().equals( "B" ) ) {
4560 n = n.getNextExternalNode();
4561 if ( !n.getName().equals( "C" ) ) {
4564 n = n.getNextExternalNode();
4565 if ( !n.getName().equals( "D" ) ) {
4568 n = t1.getNode( "B" );
4569 while ( !n.isLastExternalNode() ) {
4570 n = n.getNextExternalNode();
4572 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4573 n = t2.getNode( "A" );
4574 n = n.getNextExternalNode();
4575 if ( !n.getName().equals( "B" ) ) {
4578 n = n.getNextExternalNode();
4579 if ( !n.getName().equals( "C" ) ) {
4582 n = n.getNextExternalNode();
4583 if ( !n.getName().equals( "D" ) ) {
4586 n = t2.getNode( "B" );
4587 while ( !n.isLastExternalNode() ) {
4588 n = n.getNextExternalNode();
4590 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4591 n = t3.getNode( "A" );
4592 n = n.getNextExternalNode();
4593 if ( !n.getName().equals( "B" ) ) {
4596 n = n.getNextExternalNode();
4597 if ( !n.getName().equals( "C" ) ) {
4600 n = n.getNextExternalNode();
4601 if ( !n.getName().equals( "D" ) ) {
4604 n = n.getNextExternalNode();
4605 if ( !n.getName().equals( "E" ) ) {
4608 n = n.getNextExternalNode();
4609 if ( !n.getName().equals( "F" ) ) {
4612 n = n.getNextExternalNode();
4613 if ( !n.getName().equals( "G" ) ) {
4616 n = n.getNextExternalNode();
4617 if ( !n.getName().equals( "H" ) ) {
4620 n = t3.getNode( "B" );
4621 while ( !n.isLastExternalNode() ) {
4622 n = n.getNextExternalNode();
4624 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4625 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4626 final PhylogenyNode node = iter.next();
4628 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4629 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4630 final PhylogenyNode node = iter.next();
4632 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4633 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4634 if ( !iter.next().getName().equals( "A" ) ) {
4637 if ( !iter.next().getName().equals( "B" ) ) {
4640 if ( !iter.next().getName().equals( "C" ) ) {
4643 if ( !iter.next().getName().equals( "D" ) ) {
4646 if ( !iter.next().getName().equals( "E" ) ) {
4649 if ( !iter.next().getName().equals( "F" ) ) {
4652 if ( iter.hasNext() ) {
4656 catch ( final Exception e ) {
4657 e.printStackTrace( System.out );
4663 private static boolean testExtractSNFromNodeName() {
4665 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4668 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4671 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4674 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4675 .equals( "Mus musculus musculus" ) ) {
4678 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4679 .equals( "Mus musculus musculus" ) ) {
4682 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4683 .equals( "Mus musculus musculus" ) ) {
4686 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4687 .equals( "Mus musculus musculus" ) ) {
4690 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4693 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4694 .equals( "Mus musculus musculus" ) ) {
4697 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4698 .equals( "Mus musculus musculus" ) ) {
4701 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4704 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4707 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4710 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4713 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4714 .equals( "Mus musculus musculus" ) ) {
4717 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4720 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4723 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4726 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4729 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4732 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4735 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4738 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4741 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4742 .equals( "Mus musculus" ) ) {
4745 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4746 .equals( "Mus musculus" ) ) {
4749 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4752 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4753 .equals( "Mus musculus musculus" ) ) {
4756 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4757 .equals( "Mus musculus musculus" ) ) {
4760 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4761 .equals( "Mus musculus musculus" ) ) {
4764 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4767 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4768 .equals( "Pilostyles mexicana" ) ) {
4771 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4772 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4775 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4776 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4779 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4780 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4783 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4784 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4787 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4788 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4791 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4792 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4795 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4796 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4799 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4800 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4803 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4804 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4807 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4808 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4811 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4812 .equals( "Escherichia coli (strain K12)" ) ) {
4815 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4816 .equals( "Escherichia coli (strain K12)" ) ) {
4819 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4820 .equals( "Escherichia coli (str. K12)" ) ) {
4823 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4824 .equals( "Escherichia coli (str. K12)" ) ) {
4827 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4828 .equals( "Escherichia coli (str. K12)" ) ) {
4831 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4832 .equals( "Escherichia coli (var. K12)" ) ) {
4835 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4836 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4839 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4840 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4844 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4845 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4848 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4849 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4853 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4854 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4857 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4858 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4861 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4862 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4865 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4868 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4871 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4874 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4875 .equals( "Macrocera sp." ) ) {
4878 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4881 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4882 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4885 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4886 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4889 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4890 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4893 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4894 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4898 catch ( final Exception e ) {
4899 e.printStackTrace( System.out );
4905 private static boolean testExtractTaxonomyDataFromNodeName() {
4907 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4908 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4911 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4912 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4915 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4916 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4919 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4920 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4923 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4924 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4927 n = new PhylogenyNode( "HNRPR_HUMAN" );
4928 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4931 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
4932 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4936 catch ( final Exception e ) {
4937 e.printStackTrace( System.out );
4943 private static boolean testExtractTaxonomyCodeFromNodeName() {
4945 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4948 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4949 .equals( "SOYBN" ) ) {
4952 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4953 .equals( "ARATH" ) ) {
4956 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4957 .equals( "ARATH" ) ) {
4960 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4963 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4966 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4969 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4970 .equals( "SOYBN" ) ) {
4973 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4974 .equals( "SOYBN" ) ) {
4977 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4978 .equals( "SOYBN" ) ) {
4981 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4982 .equals( "SOYBN" ) ) {
4985 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4986 .equals( "SOYBN" ) ) {
4989 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4990 .equals( "SOYBN" ) ) {
4993 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4994 .equals( "SOYBN" ) ) {
4997 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4998 .equals( "SOYBN" ) ) {
5001 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5004 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5005 .equals( "SOYBN" ) ) {
5008 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
5009 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
5012 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5013 .equals( "9YX45" ) ) {
5016 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5017 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5018 .equals( "MOUSE" ) ) {
5021 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5022 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5023 .equals( "MOUSE" ) ) {
5026 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5027 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5028 .equals( "MOUSE" ) ) {
5031 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5032 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5035 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5036 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5039 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5040 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5043 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5044 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5047 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5048 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5051 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5052 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5055 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5056 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5059 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5060 .equals( "RAT" ) ) {
5063 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5064 .equals( "PIG" ) ) {
5068 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5069 .equals( "MOUSE" ) ) {
5072 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5073 .equals( "MOUSE" ) ) {
5076 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5080 catch ( final Exception e ) {
5081 e.printStackTrace( System.out );
5087 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5089 PhylogenyNode n = new PhylogenyNode();
5090 n.setName( "tr|B3RJ64" );
5091 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5094 n.setName( "tr.B3RJ64" );
5095 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5098 n.setName( "tr=B3RJ64" );
5099 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5102 n.setName( "tr-B3RJ64" );
5103 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5106 n.setName( "tr/B3RJ64" );
5107 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5110 n.setName( "tr\\B3RJ64" );
5111 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5114 n.setName( "tr_B3RJ64" );
5115 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5118 n.setName( " tr|B3RJ64 " );
5119 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5122 n.setName( "-tr|B3RJ64-" );
5123 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5126 n.setName( "-tr=B3RJ64-" );
5127 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5130 n.setName( "_tr=B3RJ64_" );
5131 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5134 n.setName( " tr_tr|B3RJ64_sp|123 " );
5135 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5138 n.setName( "B3RJ64" );
5139 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5142 n.setName( "sp|B3RJ64" );
5143 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5146 n.setName( "sp|B3RJ64C" );
5147 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5150 n.setName( "sp B3RJ64" );
5151 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5154 n.setName( "sp|B3RJ6X" );
5155 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5158 n.setName( "sp|B3RJ6" );
5159 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5162 n.setName( "K1PYK7_CRAGI" );
5163 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5166 n.setName( "K1PYK7_PEA" );
5167 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5170 n.setName( "K1PYK7_RAT" );
5171 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5174 n.setName( "K1PYK7_PIG" );
5175 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5178 n.setName( "~K1PYK7_PIG~" );
5179 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5182 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5183 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5186 n.setName( "K1PYKX_CRAGI" );
5187 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5190 n.setName( "XXXXX_CRAGI" );
5191 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5194 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5195 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5198 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5199 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5202 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5203 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5206 n = new PhylogenyNode();
5207 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5208 seq.setSymbol( "K1PYK7_CRAGI" );
5209 n.getNodeData().addSequence( seq );
5210 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5213 seq.setSymbol( "tr|B3RJ64" );
5214 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5217 n = new PhylogenyNode();
5218 seq = new org.forester.phylogeny.data.Sequence();
5219 seq.setName( "K1PYK7_CRAGI" );
5220 n.getNodeData().addSequence( seq );
5221 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5224 seq.setName( "tr|B3RJ64" );
5225 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5228 n = new PhylogenyNode();
5229 seq = new org.forester.phylogeny.data.Sequence();
5230 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5231 n.getNodeData().addSequence( seq );
5232 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5235 n = new PhylogenyNode();
5236 seq = new org.forester.phylogeny.data.Sequence();
5237 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5238 n.getNodeData().addSequence( seq );
5239 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5243 n = new PhylogenyNode();
5244 n.setName( "ACP19736" );
5245 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5248 n = new PhylogenyNode();
5249 n.setName( "|ACP19736|" );
5250 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5254 catch ( final Exception e ) {
5255 e.printStackTrace( System.out );
5261 private static boolean testFastaParser() {
5263 FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5264 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5271 FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5272 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5279 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5280 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5283 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5286 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5289 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5292 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5295 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5299 catch ( final Exception e ) {
5300 e.printStackTrace();
5306 private static boolean testGenbankAccessorParsing() {
5307 //The format for GenBank Accession numbers are:
5308 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5309 //Protein: 3 letters + 5 numerals
5310 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5311 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5314 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5317 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
5320 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5323 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5326 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5329 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5332 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5335 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5338 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5341 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5344 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5347 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5350 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5356 private static boolean testGeneralMsaParser() {
5358 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5359 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5360 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5361 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5362 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5363 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5364 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5365 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5366 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5369 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5372 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5375 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5378 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5381 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5384 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5387 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5390 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5393 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5396 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5399 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5402 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5403 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5406 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5409 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5412 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5413 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5416 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5419 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5422 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5423 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5426 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5429 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5433 catch ( final Exception e ) {
5434 e.printStackTrace();
5440 private static boolean testGeneralTable() {
5442 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5443 t0.setValue( 3, 2, "23" );
5444 t0.setValue( 10, 1, "error" );
5445 t0.setValue( 10, 1, "110" );
5446 t0.setValue( 9, 1, "19" );
5447 t0.setValue( 1, 10, "101" );
5448 t0.setValue( 10, 10, "1010" );
5449 t0.setValue( 100, 10, "10100" );
5450 t0.setValue( 0, 0, "00" );
5451 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5454 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5457 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5460 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5463 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5466 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5469 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5472 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5475 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5478 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5479 t1.setValue( "3", "2", "23" );
5480 t1.setValue( "10", "1", "error" );
5481 t1.setValue( "10", "1", "110" );
5482 t1.setValue( "9", "1", "19" );
5483 t1.setValue( "1", "10", "101" );
5484 t1.setValue( "10", "10", "1010" );
5485 t1.setValue( "100", "10", "10100" );
5486 t1.setValue( "0", "0", "00" );
5487 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5488 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5491 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5494 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5497 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5500 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5503 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5506 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5509 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5512 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5515 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5519 catch ( final Exception e ) {
5520 e.printStackTrace( System.out );
5526 private static boolean testGetDistance() {
5528 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5529 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",
5530 new NHXParser() )[ 0 ];
5531 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5534 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5537 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5540 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5543 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5546 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5549 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5552 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5555 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5558 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5561 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5564 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5567 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5570 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5573 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5576 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5579 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5582 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5585 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5588 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5591 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5594 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5597 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5600 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5603 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5606 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5609 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5612 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5615 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5618 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5621 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5624 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",
5625 new NHXParser() )[ 0 ];
5626 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5629 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5632 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5635 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5638 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5641 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5644 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5647 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5650 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5653 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5656 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5660 catch ( final Exception e ) {
5661 e.printStackTrace( System.out );
5667 private static boolean testGetLCA() {
5669 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5670 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5671 new NHXParser() )[ 0 ];
5672 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5673 if ( !A.getName().equals( "A" ) ) {
5676 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5677 if ( !gh.getName().equals( "gh" ) ) {
5680 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5681 if ( !ab.getName().equals( "ab" ) ) {
5684 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5685 if ( !ab2.getName().equals( "ab" ) ) {
5688 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5689 if ( !gh2.getName().equals( "gh" ) ) {
5692 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5693 if ( !gh3.getName().equals( "gh" ) ) {
5696 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5697 if ( !abc.getName().equals( "abc" ) ) {
5700 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5701 if ( !abc2.getName().equals( "abc" ) ) {
5704 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5705 if ( !abcd.getName().equals( "abcd" ) ) {
5708 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5709 if ( !abcd2.getName().equals( "abcd" ) ) {
5712 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5713 if ( !abcdef.getName().equals( "abcdef" ) ) {
5716 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5717 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5720 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5721 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5724 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5725 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5728 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5729 if ( !abcde.getName().equals( "abcde" ) ) {
5732 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5733 if ( !abcde2.getName().equals( "abcde" ) ) {
5736 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5737 if ( !r.getName().equals( "abcdefgh" ) ) {
5740 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5741 if ( !r2.getName().equals( "abcdefgh" ) ) {
5744 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5745 if ( !r3.getName().equals( "abcdefgh" ) ) {
5748 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5749 if ( !abcde3.getName().equals( "abcde" ) ) {
5752 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5753 if ( !abcde4.getName().equals( "abcde" ) ) {
5756 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5757 if ( !ab3.getName().equals( "ab" ) ) {
5760 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5761 if ( !ab4.getName().equals( "ab" ) ) {
5764 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5765 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5766 if ( !cd.getName().equals( "cd" ) ) {
5769 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5770 if ( !cd2.getName().equals( "cd" ) ) {
5773 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5774 if ( !cde.getName().equals( "cde" ) ) {
5777 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5778 if ( !cde2.getName().equals( "cde" ) ) {
5781 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5782 if ( !cdef.getName().equals( "cdef" ) ) {
5785 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5786 if ( !cdef2.getName().equals( "cdef" ) ) {
5789 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5790 if ( !cdef3.getName().equals( "cdef" ) ) {
5793 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5794 if ( !rt.getName().equals( "r" ) ) {
5797 final Phylogeny p3 = factory
5798 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5799 new NHXParser() )[ 0 ];
5800 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5801 if ( !bc_3.getName().equals( "bc" ) ) {
5804 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5805 if ( !ac_3.getName().equals( "abc" ) ) {
5808 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5809 if ( !ad_3.getName().equals( "abcde" ) ) {
5812 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5813 if ( !af_3.getName().equals( "abcdef" ) ) {
5816 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5817 if ( !ag_3.getName().equals( "" ) ) {
5820 if ( !ag_3.isRoot() ) {
5823 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5824 if ( !al_3.getName().equals( "" ) ) {
5827 if ( !al_3.isRoot() ) {
5830 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5831 if ( !kl_3.getName().equals( "" ) ) {
5834 if ( !kl_3.isRoot() ) {
5837 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5838 if ( !fl_3.getName().equals( "" ) ) {
5841 if ( !fl_3.isRoot() ) {
5844 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5845 if ( !gk_3.getName().equals( "ghijk" ) ) {
5848 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5849 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5850 if ( !r_4.getName().equals( "r" ) ) {
5853 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5854 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5855 if ( !r_5.getName().equals( "root" ) ) {
5858 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5859 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5860 if ( !r_6.getName().equals( "rot" ) ) {
5863 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5864 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5865 if ( !r_7.getName().equals( "rott" ) ) {
5869 catch ( final Exception e ) {
5870 e.printStackTrace( System.out );
5876 private static boolean testGetLCA2() {
5878 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5879 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5880 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5881 PhylogenyMethods.preOrderReId( p_a );
5882 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5883 p_a.getNode( "a" ) );
5884 if ( !p_a_1.getName().equals( "a" ) ) {
5887 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5888 PhylogenyMethods.preOrderReId( p_b );
5889 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5890 p_b.getNode( "a" ) );
5891 if ( !p_b_1.getName().equals( "b" ) ) {
5894 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5895 p_b.getNode( "b" ) );
5896 if ( !p_b_2.getName().equals( "b" ) ) {
5899 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5900 PhylogenyMethods.preOrderReId( p_c );
5901 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5902 p_c.getNode( "a" ) );
5903 if ( !p_c_1.getName().equals( "b" ) ) {
5906 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5907 p_c.getNode( "c" ) );
5908 if ( !p_c_2.getName().equals( "c" ) ) {
5909 System.out.println( p_c_2.getName() );
5913 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5914 p_c.getNode( "b" ) );
5915 if ( !p_c_3.getName().equals( "b" ) ) {
5918 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5919 p_c.getNode( "a" ) );
5920 if ( !p_c_4.getName().equals( "c" ) ) {
5923 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5924 new NHXParser() )[ 0 ];
5925 PhylogenyMethods.preOrderReId( p1 );
5926 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5927 p1.getNode( "A" ) );
5928 if ( !A.getName().equals( "A" ) ) {
5931 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5932 p1.getNode( "gh" ) );
5933 if ( !gh.getName().equals( "gh" ) ) {
5936 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5937 p1.getNode( "B" ) );
5938 if ( !ab.getName().equals( "ab" ) ) {
5941 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5942 p1.getNode( "A" ) );
5943 if ( !ab2.getName().equals( "ab" ) ) {
5946 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5947 p1.getNode( "G" ) );
5948 if ( !gh2.getName().equals( "gh" ) ) {
5951 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5952 p1.getNode( "H" ) );
5953 if ( !gh3.getName().equals( "gh" ) ) {
5956 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5957 p1.getNode( "A" ) );
5958 if ( !abc.getName().equals( "abc" ) ) {
5961 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5962 p1.getNode( "C" ) );
5963 if ( !abc2.getName().equals( "abc" ) ) {
5966 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5967 p1.getNode( "D" ) );
5968 if ( !abcd.getName().equals( "abcd" ) ) {
5971 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5972 p1.getNode( "A" ) );
5973 if ( !abcd2.getName().equals( "abcd" ) ) {
5976 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5977 p1.getNode( "F" ) );
5978 if ( !abcdef.getName().equals( "abcdef" ) ) {
5981 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5982 p1.getNode( "A" ) );
5983 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5986 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5987 p1.getNode( "F" ) );
5988 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5991 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5992 p1.getNode( "ab" ) );
5993 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5996 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5997 p1.getNode( "E" ) );
5998 if ( !abcde.getName().equals( "abcde" ) ) {
6001 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6002 p1.getNode( "A" ) );
6003 if ( !abcde2.getName().equals( "abcde" ) ) {
6006 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6007 p1.getNode( "abcdefgh" ) );
6008 if ( !r.getName().equals( "abcdefgh" ) ) {
6011 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6012 p1.getNode( "H" ) );
6013 if ( !r2.getName().equals( "abcdefgh" ) ) {
6016 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6017 p1.getNode( "A" ) );
6018 if ( !r3.getName().equals( "abcdefgh" ) ) {
6021 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6022 p1.getNode( "abcde" ) );
6023 if ( !abcde3.getName().equals( "abcde" ) ) {
6026 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6027 p1.getNode( "E" ) );
6028 if ( !abcde4.getName().equals( "abcde" ) ) {
6031 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6032 p1.getNode( "B" ) );
6033 if ( !ab3.getName().equals( "ab" ) ) {
6036 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6037 p1.getNode( "ab" ) );
6038 if ( !ab4.getName().equals( "ab" ) ) {
6041 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6042 PhylogenyMethods.preOrderReId( p2 );
6043 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6044 p2.getNode( "d" ) );
6045 if ( !cd.getName().equals( "cd" ) ) {
6048 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6049 p2.getNode( "c" ) );
6050 if ( !cd2.getName().equals( "cd" ) ) {
6053 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6054 p2.getNode( "e" ) );
6055 if ( !cde.getName().equals( "cde" ) ) {
6058 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6059 p2.getNode( "c" ) );
6060 if ( !cde2.getName().equals( "cde" ) ) {
6063 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6064 p2.getNode( "f" ) );
6065 if ( !cdef.getName().equals( "cdef" ) ) {
6068 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6069 p2.getNode( "f" ) );
6070 if ( !cdef2.getName().equals( "cdef" ) ) {
6073 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6074 p2.getNode( "d" ) );
6075 if ( !cdef3.getName().equals( "cdef" ) ) {
6078 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6079 p2.getNode( "a" ) );
6080 if ( !rt.getName().equals( "r" ) ) {
6083 final Phylogeny p3 = factory
6084 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6085 new NHXParser() )[ 0 ];
6086 PhylogenyMethods.preOrderReId( p3 );
6087 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6088 p3.getNode( "c" ) );
6089 if ( !bc_3.getName().equals( "bc" ) ) {
6092 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6093 p3.getNode( "c" ) );
6094 if ( !ac_3.getName().equals( "abc" ) ) {
6097 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6098 p3.getNode( "d" ) );
6099 if ( !ad_3.getName().equals( "abcde" ) ) {
6102 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6103 p3.getNode( "f" ) );
6104 if ( !af_3.getName().equals( "abcdef" ) ) {
6107 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6108 p3.getNode( "g" ) );
6109 if ( !ag_3.getName().equals( "" ) ) {
6112 if ( !ag_3.isRoot() ) {
6115 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6116 p3.getNode( "l" ) );
6117 if ( !al_3.getName().equals( "" ) ) {
6120 if ( !al_3.isRoot() ) {
6123 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6124 p3.getNode( "l" ) );
6125 if ( !kl_3.getName().equals( "" ) ) {
6128 if ( !kl_3.isRoot() ) {
6131 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6132 p3.getNode( "l" ) );
6133 if ( !fl_3.getName().equals( "" ) ) {
6136 if ( !fl_3.isRoot() ) {
6139 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6140 p3.getNode( "k" ) );
6141 if ( !gk_3.getName().equals( "ghijk" ) ) {
6144 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6145 PhylogenyMethods.preOrderReId( p4 );
6146 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6147 p4.getNode( "c" ) );
6148 if ( !r_4.getName().equals( "r" ) ) {
6151 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6152 PhylogenyMethods.preOrderReId( p5 );
6153 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6154 p5.getNode( "c" ) );
6155 if ( !r_5.getName().equals( "root" ) ) {
6158 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6159 PhylogenyMethods.preOrderReId( p6 );
6160 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6161 p6.getNode( "a" ) );
6162 if ( !r_6.getName().equals( "rot" ) ) {
6165 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6166 PhylogenyMethods.preOrderReId( p7 );
6167 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6168 p7.getNode( "e" ) );
6169 if ( !r_7.getName().equals( "rott" ) ) {
6172 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6173 p7.getNode( "a" ) );
6174 if ( !r_71.getName().equals( "rott" ) ) {
6177 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6178 p7.getNode( "rott" ) );
6179 if ( !r_72.getName().equals( "rott" ) ) {
6182 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6183 p7.getNode( "a" ) );
6184 if ( !r_73.getName().equals( "rott" ) ) {
6187 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6188 p7.getNode( "rott" ) );
6189 if ( !r_74.getName().equals( "rott" ) ) {
6192 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6193 p7.getNode( "e" ) );
6194 if ( !r_75.getName().equals( "e" ) ) {
6198 catch ( final Exception e ) {
6199 e.printStackTrace( System.out );
6205 private static boolean testHmmscanOutputParser() {
6206 final String test_dir = Test.PATH_TO_TEST_DATA;
6208 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6209 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6211 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6212 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6213 final List<Protein> proteins = parser2.parse();
6214 if ( parser2.getProteinsEncountered() != 4 ) {
6217 if ( proteins.size() != 4 ) {
6220 if ( parser2.getDomainsEncountered() != 69 ) {
6223 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6226 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6229 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6232 final Protein p1 = proteins.get( 0 );
6233 if ( p1.getNumberOfProteinDomains() != 15 ) {
6236 if ( p1.getLength() != 850 ) {
6239 final Protein p2 = proteins.get( 1 );
6240 if ( p2.getNumberOfProteinDomains() != 51 ) {
6243 if ( p2.getLength() != 1291 ) {
6246 final Protein p3 = proteins.get( 2 );
6247 if ( p3.getNumberOfProteinDomains() != 2 ) {
6250 final Protein p4 = proteins.get( 3 );
6251 if ( p4.getNumberOfProteinDomains() != 1 ) {
6254 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6257 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6260 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6263 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6266 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6269 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6272 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6276 catch ( final Exception e ) {
6277 e.printStackTrace( System.out );
6283 private static boolean testLastExternalNodeMethods() {
6285 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6286 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6287 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6288 final PhylogenyNode n1 = t0.getNode( "A" );
6289 if ( n1.isLastExternalNode() ) {
6292 final PhylogenyNode n2 = t0.getNode( "B" );
6293 if ( n2.isLastExternalNode() ) {
6296 final PhylogenyNode n3 = t0.getNode( "C" );
6297 if ( n3.isLastExternalNode() ) {
6300 final PhylogenyNode n4 = t0.getNode( "D" );
6301 if ( !n4.isLastExternalNode() ) {
6305 catch ( final Exception e ) {
6306 e.printStackTrace( System.out );
6312 private static boolean testLevelOrderIterator() {
6314 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6315 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6316 PhylogenyNodeIterator it0;
6317 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6320 for( it0.reset(); it0.hasNext(); ) {
6323 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6324 if ( !it.next().getName().equals( "r" ) ) {
6327 if ( !it.next().getName().equals( "ab" ) ) {
6330 if ( !it.next().getName().equals( "cd" ) ) {
6333 if ( !it.next().getName().equals( "A" ) ) {
6336 if ( !it.next().getName().equals( "B" ) ) {
6339 if ( !it.next().getName().equals( "C" ) ) {
6342 if ( !it.next().getName().equals( "D" ) ) {
6345 if ( it.hasNext() ) {
6348 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",
6349 new NHXParser() )[ 0 ];
6350 PhylogenyNodeIterator it2;
6351 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6354 for( it2.reset(); it2.hasNext(); ) {
6357 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6358 if ( !it3.next().getName().equals( "r" ) ) {
6361 if ( !it3.next().getName().equals( "abc" ) ) {
6364 if ( !it3.next().getName().equals( "defg" ) ) {
6367 if ( !it3.next().getName().equals( "A" ) ) {
6370 if ( !it3.next().getName().equals( "B" ) ) {
6373 if ( !it3.next().getName().equals( "C" ) ) {
6376 if ( !it3.next().getName().equals( "D" ) ) {
6379 if ( !it3.next().getName().equals( "E" ) ) {
6382 if ( !it3.next().getName().equals( "F" ) ) {
6385 if ( !it3.next().getName().equals( "G" ) ) {
6388 if ( !it3.next().getName().equals( "1" ) ) {
6391 if ( !it3.next().getName().equals( "2" ) ) {
6394 if ( !it3.next().getName().equals( "3" ) ) {
6397 if ( !it3.next().getName().equals( "4" ) ) {
6400 if ( !it3.next().getName().equals( "5" ) ) {
6403 if ( !it3.next().getName().equals( "6" ) ) {
6406 if ( !it3.next().getName().equals( "f1" ) ) {
6409 if ( !it3.next().getName().equals( "f2" ) ) {
6412 if ( !it3.next().getName().equals( "f3" ) ) {
6415 if ( !it3.next().getName().equals( "a" ) ) {
6418 if ( !it3.next().getName().equals( "b" ) ) {
6421 if ( !it3.next().getName().equals( "f21" ) ) {
6424 if ( !it3.next().getName().equals( "X" ) ) {
6427 if ( !it3.next().getName().equals( "Y" ) ) {
6430 if ( !it3.next().getName().equals( "Z" ) ) {
6433 if ( it3.hasNext() ) {
6436 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6437 PhylogenyNodeIterator it4;
6438 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6441 for( it4.reset(); it4.hasNext(); ) {
6444 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6445 if ( !it5.next().getName().equals( "r" ) ) {
6448 if ( !it5.next().getName().equals( "A" ) ) {
6451 if ( !it5.next().getName().equals( "B" ) ) {
6454 if ( !it5.next().getName().equals( "C" ) ) {
6457 if ( !it5.next().getName().equals( "D" ) ) {
6460 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6461 PhylogenyNodeIterator it6;
6462 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6465 for( it6.reset(); it6.hasNext(); ) {
6468 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6469 if ( !it7.next().getName().equals( "A" ) ) {
6472 if ( it.hasNext() ) {
6476 catch ( final Exception e ) {
6477 e.printStackTrace( System.out );
6483 private static boolean testMafft( final String path ) {
6485 final List<String> opts = new ArrayList<String>();
6486 opts.add( "--maxiterate" );
6488 opts.add( "--localpair" );
6489 opts.add( "--quiet" );
6491 final MsaInferrer mafft = Mafft.createInstance( path );
6492 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6493 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6496 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6500 catch ( final Exception e ) {
6501 e.printStackTrace( System.out );
6507 private static boolean testMidpointrooting() {
6509 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6510 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6511 PhylogenyMethods.midpointRoot( t0 );
6512 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6515 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6518 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6522 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",
6523 new NHXParser() )[ 0 ];
6524 if ( !t1.isRooted() ) {
6527 PhylogenyMethods.midpointRoot( t1 );
6528 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6531 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6534 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6537 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6540 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6543 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6546 t1.reRoot( t1.getNode( "A" ) );
6547 PhylogenyMethods.midpointRoot( t1 );
6548 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6551 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6554 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6557 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6560 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6564 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6568 catch ( final Exception e ) {
6569 e.printStackTrace( System.out );
6575 private static boolean testMsaQualityMethod() {
6577 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6578 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6579 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6580 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6581 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6586 final Msa msa = BasicMsa.createInstance( l );
6587 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6590 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6593 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6596 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6599 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6602 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6605 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6609 catch ( final Exception e ) {
6610 e.printStackTrace( System.out );
6616 private static boolean testMsaEntropy() {
6618 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6619 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6620 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6621 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6622 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6627 final Msa msa = BasicMsa.createInstance( l );
6628 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6630 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6631 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6632 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6633 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6634 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6635 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6636 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6637 // System.out.println();
6638 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6639 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6640 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6641 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6642 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6643 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6644 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6645 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6646 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6647 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6648 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6649 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6650 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6651 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6652 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6653 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6654 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6655 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6656 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6657 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6658 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6659 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6660 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6661 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6662 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6663 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6664 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6665 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6666 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6667 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6668 final Msa msa2 = BasicMsa.createInstance( l2 );
6669 // System.out.println();
6670 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6671 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6672 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6674 catch ( final Exception e ) {
6675 e.printStackTrace( System.out );
6681 private static boolean testDeleteableMsa() {
6683 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6684 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6685 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6686 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6687 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6688 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6689 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6696 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6697 dmsa0.deleteRow( "b", false );
6698 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6701 dmsa0.deleteRow( "e", false );
6702 dmsa0.deleteRow( "a", false );
6703 dmsa0.deleteRow( "f", false );
6704 if ( dmsa0.getLength() != 4 ) {
6707 if ( dmsa0.getNumberOfSequences() != 2 ) {
6710 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6713 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6716 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6719 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6722 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6725 dmsa0.deleteRow( "c", false );
6726 dmsa0.deleteRow( "d", false );
6727 if ( dmsa0.getNumberOfSequences() != 0 ) {
6731 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6732 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6733 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6734 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6735 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6736 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6737 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6744 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6745 dmsa1.deleteGapOnlyColumns();
6746 dmsa1.deleteRow( "a", false );
6747 dmsa1.deleteRow( "f", false );
6748 dmsa1.deleteRow( "d", false );
6749 dmsa1.deleteGapOnlyColumns();
6750 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6753 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6756 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6759 dmsa1.deleteRow( "c", false );
6760 dmsa1.deleteGapOnlyColumns();
6761 final Writer w0 = new StringWriter();
6762 dmsa1.write( w0, MSA_FORMAT.FASTA );
6763 final Writer w1 = new StringWriter();
6764 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6765 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6768 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6771 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6772 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6773 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6774 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6775 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6776 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6777 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6784 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6785 dmsa2.deleteGapColumns( 0.5 );
6786 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6789 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6792 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6795 dmsa2.deleteGapColumns( 0.2 );
6796 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6799 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6802 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6805 dmsa2.deleteGapColumns( 0 );
6806 dmsa2.deleteRow( "a", false );
6807 dmsa2.deleteRow( "b", false );
6808 dmsa2.deleteRow( "f", false );
6809 dmsa2.deleteRow( "e", false );
6810 dmsa2.setIdentifier( 0, "new_c" );
6811 dmsa2.setIdentifier( 1, "new_d" );
6812 dmsa2.setResidueAt( 0, 0, 'x' );
6813 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6814 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6817 final Writer w = new StringWriter();
6818 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6819 final String phylip = w.toString();
6820 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6821 System.out.println( phylip );
6824 final Writer w2 = new StringWriter();
6825 dmsa2.write( w2, MSA_FORMAT.FASTA );
6826 final String fasta = w2.toString();
6827 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6828 System.out.println( fasta );
6832 catch ( final Exception e ) {
6833 e.printStackTrace( System.out );
6839 private static boolean testNextNodeWithCollapsing() {
6841 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6843 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6844 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6845 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
6846 t0.getNode( "cd" ).setCollapse( true );
6847 t0.getNode( "cde" ).setCollapse( true );
6848 n = t0.getFirstExternalNode();
6849 while ( n != null ) {
6851 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6853 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6856 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6859 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6862 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6865 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6868 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6872 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6873 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
6874 t1.getNode( "ab" ).setCollapse( true );
6875 t1.getNode( "cd" ).setCollapse( true );
6876 t1.getNode( "cde" ).setCollapse( true );
6877 n = t1.getNode( "ab" );
6878 ext = new ArrayList<PhylogenyNode>();
6879 while ( n != null ) {
6881 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6883 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6886 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6889 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6892 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6895 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6899 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6900 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
6901 t2.getNode( "ab" ).setCollapse( true );
6902 t2.getNode( "cd" ).setCollapse( true );
6903 t2.getNode( "cde" ).setCollapse( true );
6904 t2.getNode( "c" ).setCollapse( true );
6905 t2.getNode( "d" ).setCollapse( true );
6906 t2.getNode( "e" ).setCollapse( true );
6907 t2.getNode( "gh" ).setCollapse( true );
6908 n = t2.getNode( "ab" );
6909 ext = new ArrayList<PhylogenyNode>();
6910 while ( n != null ) {
6912 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6914 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6917 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6920 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6923 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6927 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6928 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
6929 t3.getNode( "ab" ).setCollapse( true );
6930 t3.getNode( "cd" ).setCollapse( true );
6931 t3.getNode( "cde" ).setCollapse( true );
6932 t3.getNode( "c" ).setCollapse( true );
6933 t3.getNode( "d" ).setCollapse( true );
6934 t3.getNode( "e" ).setCollapse( true );
6935 t3.getNode( "gh" ).setCollapse( true );
6936 t3.getNode( "fgh" ).setCollapse( true );
6937 n = t3.getNode( "ab" );
6938 ext = new ArrayList<PhylogenyNode>();
6939 while ( n != null ) {
6941 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6943 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6946 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6949 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6953 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6954 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
6955 t4.getNode( "ab" ).setCollapse( true );
6956 t4.getNode( "cd" ).setCollapse( true );
6957 t4.getNode( "cde" ).setCollapse( true );
6958 t4.getNode( "c" ).setCollapse( true );
6959 t4.getNode( "d" ).setCollapse( true );
6960 t4.getNode( "e" ).setCollapse( true );
6961 t4.getNode( "gh" ).setCollapse( true );
6962 t4.getNode( "fgh" ).setCollapse( true );
6963 t4.getNode( "abcdefgh" ).setCollapse( true );
6964 n = t4.getNode( "abcdefgh" );
6965 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6968 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6969 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
6971 n = t5.getFirstExternalNode();
6972 while ( n != null ) {
6974 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6976 if ( ext.size() != 8 ) {
6979 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6982 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6985 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6988 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6991 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6994 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6997 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7000 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7003 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7004 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7006 t6.getNode( "ab" ).setCollapse( true );
7007 n = t6.getNode( "ab" );
7008 while ( n != null ) {
7010 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7012 if ( ext.size() != 7 ) {
7015 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7018 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7021 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7024 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7027 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7030 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7033 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7036 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7037 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7039 t7.getNode( "cd" ).setCollapse( true );
7040 n = t7.getNode( "a" );
7041 while ( n != null ) {
7043 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7045 if ( ext.size() != 7 ) {
7048 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7051 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7054 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7057 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7060 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7063 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7066 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7069 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7070 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7072 t8.getNode( "cd" ).setCollapse( true );
7073 t8.getNode( "c" ).setCollapse( true );
7074 t8.getNode( "d" ).setCollapse( true );
7075 n = t8.getNode( "a" );
7076 while ( n != null ) {
7078 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7080 if ( ext.size() != 7 ) {
7083 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7086 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7089 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7090 System.out.println( "2 fail" );
7093 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7096 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7099 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7102 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7105 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7106 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7108 t9.getNode( "gh" ).setCollapse( true );
7109 n = t9.getNode( "a" );
7110 while ( n != null ) {
7112 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7114 if ( ext.size() != 7 ) {
7117 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7120 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7123 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7126 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7129 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7132 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7135 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7138 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7139 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7141 t10.getNode( "gh" ).setCollapse( true );
7142 t10.getNode( "g" ).setCollapse( true );
7143 t10.getNode( "h" ).setCollapse( true );
7144 n = t10.getNode( "a" );
7145 while ( n != null ) {
7147 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7149 if ( ext.size() != 7 ) {
7152 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7155 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7158 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7161 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7164 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7167 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7170 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7173 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7174 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7176 t11.getNode( "gh" ).setCollapse( true );
7177 t11.getNode( "fgh" ).setCollapse( true );
7178 n = t11.getNode( "a" );
7179 while ( n != null ) {
7181 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7183 if ( ext.size() != 6 ) {
7186 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7189 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7192 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7195 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7198 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7201 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7204 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7205 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7207 t12.getNode( "gh" ).setCollapse( true );
7208 t12.getNode( "fgh" ).setCollapse( true );
7209 t12.getNode( "g" ).setCollapse( true );
7210 t12.getNode( "h" ).setCollapse( true );
7211 t12.getNode( "f" ).setCollapse( true );
7212 n = t12.getNode( "a" );
7213 while ( n != null ) {
7215 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7217 if ( ext.size() != 6 ) {
7220 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7223 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7226 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7229 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7232 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7235 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7238 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7239 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7241 t13.getNode( "ab" ).setCollapse( true );
7242 t13.getNode( "b" ).setCollapse( true );
7243 t13.getNode( "fgh" ).setCollapse( true );
7244 t13.getNode( "gh" ).setCollapse( true );
7245 n = t13.getNode( "ab" );
7246 while ( n != null ) {
7248 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7250 if ( ext.size() != 5 ) {
7253 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7256 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7259 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7262 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7265 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7268 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7269 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7271 t14.getNode( "ab" ).setCollapse( true );
7272 t14.getNode( "a" ).setCollapse( true );
7273 t14.getNode( "fgh" ).setCollapse( true );
7274 t14.getNode( "gh" ).setCollapse( true );
7275 n = t14.getNode( "ab" );
7276 while ( n != null ) {
7278 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7280 if ( ext.size() != 5 ) {
7283 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7286 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7289 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7292 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7295 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7298 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" );
7299 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7301 t15.getNode( "ab" ).setCollapse( true );
7302 t15.getNode( "a" ).setCollapse( true );
7303 t15.getNode( "fgh" ).setCollapse( true );
7304 t15.getNode( "gh" ).setCollapse( true );
7305 n = t15.getNode( "ab" );
7306 while ( n != null ) {
7308 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7310 if ( ext.size() != 6 ) {
7313 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7316 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7319 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7322 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7325 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7328 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7333 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" );
7334 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7336 t16.getNode( "ab" ).setCollapse( true );
7337 t16.getNode( "a" ).setCollapse( true );
7338 t16.getNode( "fgh" ).setCollapse( true );
7339 t16.getNode( "gh" ).setCollapse( true );
7340 t16.getNode( "cd" ).setCollapse( true );
7341 t16.getNode( "cde" ).setCollapse( true );
7342 t16.getNode( "d" ).setCollapse( true );
7343 t16.getNode( "x" ).setCollapse( true );
7344 n = t16.getNode( "ab" );
7345 while ( n != null ) {
7347 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7349 if ( ext.size() != 4 ) {
7352 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7355 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7358 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7361 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7365 catch ( final Exception e ) {
7366 e.printStackTrace( System.out );
7372 private static boolean testNexusCharactersParsing() {
7374 final NexusCharactersParser parser = new NexusCharactersParser();
7375 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7377 String[] labels = parser.getCharStateLabels();
7378 if ( labels.length != 7 ) {
7381 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7384 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7387 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7390 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7393 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7396 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7399 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7402 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7404 labels = parser.getCharStateLabels();
7405 if ( labels.length != 7 ) {
7408 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7411 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7414 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7417 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7420 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7423 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7426 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7430 catch ( final Exception e ) {
7431 e.printStackTrace( System.out );
7437 private static boolean testNexusMatrixParsing() {
7439 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7440 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7442 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7443 if ( m.getNumberOfCharacters() != 9 ) {
7446 if ( m.getNumberOfIdentifiers() != 5 ) {
7449 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7452 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7455 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7458 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7461 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7464 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7467 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7470 // if ( labels.length != 7 ) {
7473 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7476 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7479 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7482 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7485 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7488 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7491 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7494 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7496 // labels = parser.getCharStateLabels();
7497 // if ( labels.length != 7 ) {
7500 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7503 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7506 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7509 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7512 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7515 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7518 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7522 catch ( final Exception e ) {
7523 e.printStackTrace( System.out );
7529 private static boolean testNexusTreeParsing() {
7531 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7532 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7533 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7534 if ( phylogenies.length != 1 ) {
7537 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7540 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7544 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7545 if ( phylogenies.length != 1 ) {
7548 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7551 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7555 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7556 if ( phylogenies.length != 1 ) {
7559 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7562 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7565 if ( phylogenies[ 0 ].isRooted() ) {
7569 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7570 if ( phylogenies.length != 18 ) {
7573 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7576 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7579 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7582 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7585 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7588 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7591 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7594 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7597 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7600 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7603 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7606 if ( phylogenies[ 8 ].isRooted() ) {
7609 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7612 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7615 if ( !phylogenies[ 9 ].isRooted() ) {
7618 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7621 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7624 if ( !phylogenies[ 10 ].isRooted() ) {
7627 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7630 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7633 if ( phylogenies[ 11 ].isRooted() ) {
7636 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7639 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7642 if ( !phylogenies[ 12 ].isRooted() ) {
7645 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7648 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7651 if ( !phylogenies[ 13 ].isRooted() ) {
7654 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7657 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7660 if ( !phylogenies[ 14 ].isRooted() ) {
7663 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7666 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7669 if ( phylogenies[ 15 ].isRooted() ) {
7672 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7675 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7678 if ( !phylogenies[ 16 ].isRooted() ) {
7681 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7684 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7687 if ( phylogenies[ 17 ].isRooted() ) {
7690 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7693 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7695 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7696 if ( phylogenies.length != 9 ) {
7699 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7700 .getDistanceToParent() ) ) {
7703 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7704 .getDistanceToParent() ) ) {
7707 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7710 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7713 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7716 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7719 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7723 catch ( final Exception e ) {
7724 e.printStackTrace( System.out );
7730 private static boolean testNexusTreeParsingIterating() {
7732 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7733 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7734 if ( !p.hasNext() ) {
7737 Phylogeny phy = p.next();
7738 if ( phy == null ) {
7741 if ( phy.getNumberOfExternalNodes() != 25 ) {
7744 if ( !phy.getName().equals( "" ) ) {
7747 if ( p.hasNext() ) {
7751 if ( phy != null ) {
7755 if ( !p.hasNext() ) {
7759 if ( phy == null ) {
7762 if ( phy.getNumberOfExternalNodes() != 25 ) {
7765 if ( !phy.getName().equals( "" ) ) {
7768 if ( p.hasNext() ) {
7772 if ( phy != null ) {
7775 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7776 if ( !p.hasNext() ) {
7780 if ( phy == null ) {
7783 if ( phy.getNumberOfExternalNodes() != 10 ) {
7786 if ( !phy.getName().equals( "name" ) ) {
7789 if ( p.hasNext() ) {
7793 if ( phy != null ) {
7797 if ( !p.hasNext() ) {
7801 if ( phy == null ) {
7804 if ( phy.getNumberOfExternalNodes() != 10 ) {
7807 if ( !phy.getName().equals( "name" ) ) {
7810 if ( p.hasNext() ) {
7814 if ( phy != null ) {
7817 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7818 if ( !p.hasNext() ) {
7822 if ( phy == null ) {
7825 if ( phy.getNumberOfExternalNodes() != 3 ) {
7828 if ( !phy.getName().equals( "" ) ) {
7831 if ( phy.isRooted() ) {
7834 if ( p.hasNext() ) {
7838 if ( phy != null ) {
7843 if ( !p.hasNext() ) {
7847 if ( phy == null ) {
7850 if ( phy.getNumberOfExternalNodes() != 3 ) {
7853 if ( !phy.getName().equals( "" ) ) {
7856 if ( p.hasNext() ) {
7860 if ( phy != null ) {
7864 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7865 if ( !p.hasNext() ) {
7870 if ( phy == null ) {
7873 if ( phy.getNumberOfExternalNodes() != 10 ) {
7876 if ( !phy.getName().equals( "tree 0" ) ) {
7880 if ( !p.hasNext() ) {
7884 if ( phy == null ) {
7887 if ( phy.getNumberOfExternalNodes() != 10 ) {
7890 if ( !phy.getName().equals( "tree 1" ) ) {
7894 if ( !p.hasNext() ) {
7898 if ( phy == null ) {
7901 if ( phy.getNumberOfExternalNodes() != 3 ) {
7902 System.out.println( phy.toString() );
7905 if ( !phy.getName().equals( "" ) ) {
7908 if ( phy.isRooted() ) {
7912 if ( !p.hasNext() ) {
7916 if ( phy == null ) {
7919 if ( phy.getNumberOfExternalNodes() != 4 ) {
7922 if ( !phy.getName().equals( "" ) ) {
7925 if ( !phy.isRooted() ) {
7929 if ( !p.hasNext() ) {
7933 if ( phy == null ) {
7936 if ( phy.getNumberOfExternalNodes() != 5 ) {
7937 System.out.println( phy.getNumberOfExternalNodes() );
7940 if ( !phy.getName().equals( "" ) ) {
7943 if ( !phy.isRooted() ) {
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() != 2 ) {
7974 if ( !phy.getName().equals( "" ) ) {
7977 if ( !phy.isRooted() ) {
7981 if ( !p.hasNext() ) {
7985 if ( phy.getNumberOfExternalNodes() != 3 ) {
7988 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7991 if ( !phy.isRooted() ) {
7995 if ( !p.hasNext() ) {
7999 if ( phy.getNumberOfExternalNodes() != 3 ) {
8002 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8005 if ( !phy.getName().equals( "tree 8" ) ) {
8009 if ( !p.hasNext() ) {
8013 if ( phy.getNumberOfExternalNodes() != 3 ) {
8016 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8019 if ( !phy.getName().equals( "tree 9" ) ) {
8023 if ( !p.hasNext() ) {
8027 if ( phy.getNumberOfExternalNodes() != 3 ) {
8030 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8033 if ( !phy.getName().equals( "tree 10" ) ) {
8036 if ( !phy.isRooted() ) {
8040 if ( !p.hasNext() ) {
8044 if ( phy.getNumberOfExternalNodes() != 3 ) {
8047 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8050 if ( !phy.getName().equals( "tree 11" ) ) {
8053 if ( phy.isRooted() ) {
8057 if ( !p.hasNext() ) {
8061 if ( phy.getNumberOfExternalNodes() != 3 ) {
8064 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8067 if ( !phy.getName().equals( "tree 12" ) ) {
8070 if ( !phy.isRooted() ) {
8074 if ( !p.hasNext() ) {
8078 if ( phy.getNumberOfExternalNodes() != 3 ) {
8081 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8084 if ( !phy.getName().equals( "tree 13" ) ) {
8087 if ( !phy.isRooted() ) {
8091 if ( !p.hasNext() ) {
8095 if ( phy.getNumberOfExternalNodes() != 10 ) {
8096 System.out.println( phy.getNumberOfExternalNodes() );
8101 .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;" ) ) {
8102 System.out.println( phy.toNewHampshire() );
8105 if ( !phy.getName().equals( "tree 14" ) ) {
8108 if ( !phy.isRooted() ) {
8112 if ( !p.hasNext() ) {
8116 if ( phy.getNumberOfExternalNodes() != 10 ) {
8117 System.out.println( phy.getNumberOfExternalNodes() );
8122 .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;" ) ) {
8123 System.out.println( phy.toNewHampshire() );
8126 if ( !phy.getName().equals( "tree 15" ) ) {
8129 if ( phy.isRooted() ) {
8133 if ( !p.hasNext() ) {
8137 if ( phy.getNumberOfExternalNodes() != 10 ) {
8138 System.out.println( phy.getNumberOfExternalNodes() );
8143 .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;" ) ) {
8144 System.out.println( phy.toNewHampshire() );
8147 if ( !phy.getName().equals( "tree 16" ) ) {
8150 if ( !phy.isRooted() ) {
8154 if ( !p.hasNext() ) {
8158 if ( phy.getNumberOfExternalNodes() != 10 ) {
8159 System.out.println( phy.getNumberOfExternalNodes() );
8164 .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;" ) ) {
8165 System.out.println( phy.toNewHampshire() );
8168 if ( !phy.getName().equals( "tree 17" ) ) {
8171 if ( phy.isRooted() ) {
8175 if ( p.hasNext() ) {
8179 if ( phy != null ) {
8184 if ( !p.hasNext() ) {
8188 if ( phy == null ) {
8191 if ( phy.getNumberOfExternalNodes() != 10 ) {
8194 if ( !phy.getName().equals( "tree 0" ) ) {
8198 if ( !p.hasNext() ) {
8202 if ( phy == null ) {
8205 if ( phy.getNumberOfExternalNodes() != 10 ) {
8208 if ( !phy.getName().equals( "tree 1" ) ) {
8212 if ( !p.hasNext() ) {
8216 if ( phy == null ) {
8219 if ( phy.getNumberOfExternalNodes() != 3 ) {
8222 if ( !phy.getName().equals( "" ) ) {
8225 if ( phy.isRooted() ) {
8229 if ( !p.hasNext() ) {
8233 if ( phy == null ) {
8236 if ( phy.getNumberOfExternalNodes() != 4 ) {
8239 if ( !phy.getName().equals( "" ) ) {
8242 if ( !phy.isRooted() ) {
8246 if ( !p.hasNext() ) {
8250 if ( phy == null ) {
8253 if ( phy.getNumberOfExternalNodes() != 5 ) {
8254 System.out.println( phy.getNumberOfExternalNodes() );
8257 if ( !phy.getName().equals( "" ) ) {
8260 if ( !phy.isRooted() ) {
8264 if ( !p.hasNext() ) {
8268 if ( phy == null ) {
8271 if ( phy.getNumberOfExternalNodes() != 3 ) {
8274 if ( !phy.getName().equals( "" ) ) {
8277 if ( phy.isRooted() ) {
8281 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8282 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8284 if ( !p2.hasNext() ) {
8288 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8291 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8295 if ( !p2.hasNext() ) {
8300 if ( !p2.hasNext() ) {
8305 if ( !p2.hasNext() ) {
8310 if ( !p2.hasNext() ) {
8315 if ( !p2.hasNext() ) {
8320 if ( !p2.hasNext() ) {
8325 if ( !p2.hasNext() ) {
8330 if ( !p2.hasNext() ) {
8334 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8337 if ( p2.hasNext() ) {
8341 if ( phy != null ) {
8346 if ( !p2.hasNext() ) {
8350 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8353 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8357 catch ( final Exception e ) {
8358 e.printStackTrace( System.out );
8364 private static boolean testNexusTreeParsingTranslating() {
8366 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8367 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8368 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8369 if ( phylogenies.length != 1 ) {
8372 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8375 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8378 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8381 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8384 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8385 .equals( "Aranaeus" ) ) {
8389 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8390 if ( phylogenies.length != 3 ) {
8393 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8396 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8399 if ( phylogenies[ 0 ].isRooted() ) {
8402 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8405 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8408 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8409 .equals( "Aranaeus" ) ) {
8412 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8415 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8418 if ( phylogenies[ 1 ].isRooted() ) {
8421 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8424 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8427 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8428 .equals( "Aranaeus" ) ) {
8431 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8434 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8437 if ( !phylogenies[ 2 ].isRooted() ) {
8440 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8443 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8446 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8447 .equals( "Aranaeus" ) ) {
8451 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8452 if ( phylogenies.length != 3 ) {
8455 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8458 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8461 if ( phylogenies[ 0 ].isRooted() ) {
8464 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8467 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8470 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8471 .equals( "Aranaeus" ) ) {
8474 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8477 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8480 if ( phylogenies[ 1 ].isRooted() ) {
8483 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8486 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8489 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8490 .equals( "Aranaeus" ) ) {
8493 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8496 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8499 if ( !phylogenies[ 2 ].isRooted() ) {
8502 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8505 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8508 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8509 .equals( "Aranaeus" ) ) {
8512 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8513 if ( phylogenies.length != 3 ) {
8516 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8521 catch ( final Exception e ) {
8522 e.printStackTrace( System.out );
8528 private static boolean testNHParsing() {
8530 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8531 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8532 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8535 final NHXParser nhxp = new NHXParser();
8536 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8537 nhxp.setReplaceUnderscores( true );
8538 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8539 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8542 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8545 final Phylogeny p1b = factory
8546 .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 ",
8547 new NHXParser() )[ 0 ];
8548 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8551 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8554 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8555 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8556 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8557 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8558 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8559 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8560 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8561 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8562 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8563 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8564 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8565 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8566 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8568 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8571 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8574 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8577 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8580 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8581 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8582 final String p16_S = "((A,B),C)";
8583 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8584 if ( p16.length != 1 ) {
8587 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8590 final String p17_S = "(C,(A,B))";
8591 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8592 if ( p17.length != 1 ) {
8595 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8598 final String p18_S = "((A,B),(C,D))";
8599 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8600 if ( p18.length != 1 ) {
8603 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8606 final String p19_S = "(((A,B),C),D)";
8607 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8608 if ( p19.length != 1 ) {
8611 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8614 final String p20_S = "(A,(B,(C,D)))";
8615 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8616 if ( p20.length != 1 ) {
8619 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8622 final String p21_S = "(A,(B,(C,(D,E))))";
8623 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8624 if ( p21.length != 1 ) {
8627 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8630 final String p22_S = "((((A,B),C),D),E)";
8631 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8632 if ( p22.length != 1 ) {
8635 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8638 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8639 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8640 if ( p23.length != 1 ) {
8641 System.out.println( "xl=" + p23.length );
8645 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8648 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8649 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8650 if ( p24.length != 1 ) {
8653 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8656 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8657 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8658 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8659 if ( p241.length != 2 ) {
8662 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8665 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8668 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8669 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8670 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8671 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8672 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8673 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8674 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8675 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8676 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8677 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8680 final String p26_S = "(A,B)ab";
8681 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8682 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8685 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8686 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8687 if ( p27s.length != 1 ) {
8688 System.out.println( "xxl=" + p27s.length );
8692 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8693 System.out.println( p27s[ 0 ].toNewHampshireX() );
8697 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8699 if ( p27.length != 1 ) {
8700 System.out.println( "yl=" + p27.length );
8704 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8705 System.out.println( p27[ 0 ].toNewHampshireX() );
8709 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8710 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8711 final String p28_S3 = "(A,B)ab";
8712 final String p28_S4 = "((((A,B),C),D),;E;)";
8713 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8715 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8718 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8721 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8724 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8727 if ( p28.length != 4 ) {
8730 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";
8731 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8732 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8735 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";
8736 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8737 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8740 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8741 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8742 if ( ( p32.length != 0 ) ) {
8745 final String p33_S = "A";
8746 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8747 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8750 final String p34_S = "B;";
8751 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8752 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8755 final String p35_S = "B:0.2";
8756 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8757 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8760 final String p36_S = "(A)";
8761 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8762 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8765 final String p37_S = "((A))";
8766 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8767 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8770 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8771 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8772 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8775 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8776 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8777 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8780 final String p40_S = "(A,B,C)";
8781 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8782 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8785 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8786 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8787 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8790 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8791 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8792 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8795 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)";
8796 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8797 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8800 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)))";
8801 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8802 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8805 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8806 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8807 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8810 final String p46_S = "";
8811 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8812 if ( p46.length != 0 ) {
8815 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(), new NHXParser() )[ 0 ];
8816 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8819 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8820 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8823 final Phylogeny p49 = factory
8824 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
8825 new NHXParser() )[ 0 ];
8826 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8829 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8830 if ( p50.getNode( "A" ) == null ) {
8833 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8834 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8837 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8840 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8841 .equals( "((A,B)88:2.0,C);" ) ) {
8844 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8845 if ( p51.getNode( "A(A" ) == null ) {
8848 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8849 if ( p52.getNode( "A(A" ) == null ) {
8852 final Phylogeny p53 = factory
8853 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
8854 new NHXParser() )[ 0 ];
8855 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8858 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(), new NHXParser() )[ 0 ];
8859 if ( p54.getNode( "A" ) == null ) {
8862 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8865 final Phylogeny p55 = factory
8866 .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);" ).toString(),
8867 new NHXParser() )[ 0 ];
8870 .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);" ) ) {
8871 System.out.println( p55.toNewHampshire() );
8874 final Phylogeny p56 = factory
8875 .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);" ).toString(),
8876 new NHXParser() )[ 0 ];
8879 .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);" ) ) {
8880 System.out.println( p56.toNewHampshire() );
8883 final Phylogeny p57 = factory
8884 .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);" ).toString(),
8885 new NHXParser() )[ 0 ];
8888 .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);" ) ) {
8889 System.out.println( p56.toNewHampshire() );
8892 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8893 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
8894 if ( !p58.toNewHampshire().equals( s58 ) ) {
8895 System.out.println( p58.toNewHampshire() );
8898 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8899 final Phylogeny p59 = factory.create( s59 , new NHXParser() )[ 0 ];
8900 if ( !p59.toNewHampshire().equals( s59 ) ) {
8901 System.out.println( p59.toNewHampshire() );
8904 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8905 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
8906 if ( !p60.toNewHampshire().equals( s60 ) ) {
8907 System.out.println( p60.toNewHampshire() );
8910 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8911 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
8912 if ( !p61.toNewHampshire()
8913 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8914 System.out.println( p61.toNewHampshire() );
8918 catch ( final Exception e ) {
8919 e.printStackTrace( System.out );
8925 private static boolean testNHParsingSpecialChars() {
8927 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8928 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
8929 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
8930 if ( !p0.toNewHampshireX().equals( i0 ) ) {
8931 System.out.println();
8932 System.out.println( p0.toNewHampshireX() );
8933 System.out.println( i0 );
8936 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
8937 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
8938 if ( !p1.toNewHampshireX().equals( i1 ) ) {
8939 System.out.println();
8940 System.out.println( p1.toNewHampshireX() );
8941 System.out.println( i1 );
8945 catch ( final Exception e ) {
8946 e.printStackTrace( System.out );
8954 private static boolean testNHParsingIter() {
8956 final String p0_str = "(A,B);";
8957 final NHXParser p = new NHXParser();
8958 p.setSource( p0_str );
8959 if ( !p.hasNext() ) {
8962 final Phylogeny p0 = p.next();
8963 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8964 System.out.println( p0.toNewHampshire() );
8967 if ( p.hasNext() ) {
8970 if ( p.next() != null ) {
8974 final String p00_str = "(A,B)root;";
8975 p.setSource( p00_str );
8976 final Phylogeny p00 = p.next();
8977 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8978 System.out.println( p00.toNewHampshire() );
8982 final String p000_str = "A;";
8983 p.setSource( p000_str );
8984 final Phylogeny p000 = p.next();
8985 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8986 System.out.println( p000.toNewHampshire() );
8990 final String p0000_str = "A";
8991 p.setSource( p0000_str );
8992 final Phylogeny p0000 = p.next();
8993 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8994 System.out.println( p0000.toNewHampshire() );
8998 p.setSource( "(A)" );
8999 final Phylogeny p00000 = p.next();
9000 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9001 System.out.println( p00000.toNewHampshire() );
9005 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9006 p.setSource( p1_str );
9007 if ( !p.hasNext() ) {
9010 final Phylogeny p1_0 = p.next();
9011 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9012 System.out.println( p1_0.toNewHampshire() );
9015 if ( !p.hasNext() ) {
9018 final Phylogeny p1_1 = p.next();
9019 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9020 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9023 if ( !p.hasNext() ) {
9026 final Phylogeny p1_2 = p.next();
9027 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9028 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9031 if ( !p.hasNext() ) {
9034 final Phylogeny p1_3 = p.next();
9035 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9036 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9039 if ( p.hasNext() ) {
9042 if ( p.next() != null ) {
9046 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9047 p.setSource( p2_str );
9048 if ( !p.hasNext() ) {
9051 Phylogeny p2_0 = p.next();
9052 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9053 System.out.println( p2_0.toNewHampshire() );
9056 if ( !p.hasNext() ) {
9059 Phylogeny p2_1 = p.next();
9060 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9061 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9064 if ( !p.hasNext() ) {
9067 Phylogeny p2_2 = p.next();
9068 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9069 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9072 if ( !p.hasNext() ) {
9075 Phylogeny p2_3 = p.next();
9076 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9077 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9080 if ( !p.hasNext() ) {
9083 Phylogeny p2_4 = p.next();
9084 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9085 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9088 if ( p.hasNext() ) {
9091 if ( p.next() != null ) {
9096 if ( !p.hasNext() ) {
9100 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9101 System.out.println( p2_0.toNewHampshire() );
9104 if ( !p.hasNext() ) {
9108 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9109 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9112 if ( !p.hasNext() ) {
9116 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9117 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9120 if ( !p.hasNext() ) {
9124 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9125 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9128 if ( !p.hasNext() ) {
9132 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9133 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9136 if ( p.hasNext() ) {
9139 if ( p.next() != null ) {
9143 final String p3_str = "((A,B),C)abc";
9144 p.setSource( p3_str );
9145 if ( !p.hasNext() ) {
9148 final Phylogeny p3_0 = p.next();
9149 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9152 if ( p.hasNext() ) {
9155 if ( p.next() != null ) {
9159 final String p4_str = "((A,B)ab,C)abc";
9160 p.setSource( p4_str );
9161 if ( !p.hasNext() ) {
9164 final Phylogeny p4_0 = p.next();
9165 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9168 if ( p.hasNext() ) {
9171 if ( p.next() != null ) {
9175 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9176 p.setSource( p5_str );
9177 if ( !p.hasNext() ) {
9180 final Phylogeny p5_0 = p.next();
9181 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9184 if ( p.hasNext() ) {
9187 if ( p.next() != null ) {
9191 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9192 p.setSource( p6_str );
9193 if ( !p.hasNext() ) {
9196 Phylogeny p6_0 = p.next();
9197 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9200 if ( p.hasNext() ) {
9203 if ( p.next() != null ) {
9207 if ( !p.hasNext() ) {
9211 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9214 if ( p.hasNext() ) {
9217 if ( p.next() != null ) {
9221 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9222 p.setSource( p7_str );
9223 if ( !p.hasNext() ) {
9226 Phylogeny p7_0 = p.next();
9227 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9230 if ( p.hasNext() ) {
9233 if ( p.next() != null ) {
9237 if ( !p.hasNext() ) {
9241 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9244 if ( p.hasNext() ) {
9247 if ( p.next() != null ) {
9251 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9252 p.setSource( p8_str );
9253 if ( !p.hasNext() ) {
9256 Phylogeny p8_0 = p.next();
9257 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9260 if ( !p.hasNext() ) {
9263 if ( !p.hasNext() ) {
9266 Phylogeny p8_1 = p.next();
9267 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9270 if ( p.hasNext() ) {
9273 if ( p.next() != null ) {
9277 if ( !p.hasNext() ) {
9281 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9284 if ( !p.hasNext() ) {
9288 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9291 if ( p.hasNext() ) {
9294 if ( p.next() != null ) {
9300 if ( p.hasNext() ) {
9304 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9305 if ( !p.hasNext() ) {
9308 Phylogeny p_27 = p.next();
9309 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9310 System.out.println( p_27.toNewHampshireX() );
9314 if ( p.hasNext() ) {
9317 if ( p.next() != null ) {
9321 if ( !p.hasNext() ) {
9325 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9326 System.out.println( p_27.toNewHampshireX() );
9330 if ( p.hasNext() ) {
9333 if ( p.next() != null ) {
9337 final String p30_str = "(A,B);(C,D)";
9338 final NHXParser p30 = new NHXParser();
9339 p30.setSource( p30_str );
9340 if ( !p30.hasNext() ) {
9343 Phylogeny phy30 = p30.next();
9344 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9345 System.out.println( phy30.toNewHampshire() );
9348 if ( !p30.hasNext() ) {
9351 Phylogeny phy301 = p30.next();
9352 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9353 System.out.println( phy301.toNewHampshire() );
9356 if ( p30.hasNext() ) {
9359 if ( p30.hasNext() ) {
9362 if ( p30.next() != null ) {
9365 if ( p30.next() != null ) {
9369 if ( !p30.hasNext() ) {
9373 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9374 System.out.println( phy30.toNewHampshire() );
9377 if ( !p30.hasNext() ) {
9380 phy301 = p30.next();
9381 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9382 System.out.println( phy301.toNewHampshire() );
9385 if ( p30.hasNext() ) {
9388 if ( p30.hasNext() ) {
9391 if ( p30.next() != null ) {
9394 if ( p30.next() != null ) {
9398 catch ( final Exception e ) {
9399 e.printStackTrace( System.out );
9405 private static boolean testNHXconversion() {
9407 final PhylogenyNode n1 = new PhylogenyNode();
9408 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9409 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9410 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9411 final PhylogenyNode n5 = PhylogenyNode
9412 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9413 final PhylogenyNode n6 = PhylogenyNode
9414 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9415 if ( !n1.toNewHampshireX().equals( "" ) ) {
9418 if ( !n2.toNewHampshireX().equals( "" ) ) {
9421 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9424 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9427 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9430 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9431 System.out.println( n6.toNewHampshireX() );
9434 final PhylogenyNode n7 = new PhylogenyNode();
9435 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9436 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9437 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9438 System.out.println( n7
9439 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9443 catch ( final Exception e ) {
9444 e.printStackTrace( System.out );
9450 private static boolean testNHXNodeParsing() {
9452 final PhylogenyNode n1 = new PhylogenyNode();
9453 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9454 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9455 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9456 final PhylogenyNode n5 = PhylogenyNode
9457 .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]" );
9458 if ( !n3.getName().equals( "n3" ) ) {
9461 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9464 if ( n3.isDuplication() ) {
9467 if ( n3.isHasAssignedEvent() ) {
9470 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9473 if ( !n4.getName().equals( "n4" ) ) {
9476 if ( n4.getDistanceToParent() != 0.01 ) {
9479 if ( !n5.getName().equals( "n5" ) ) {
9482 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9485 if ( n5.getDistanceToParent() != 0.1 ) {
9488 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9491 if ( !n5.isDuplication() ) {
9494 if ( !n5.isHasAssignedEvent() ) {
9497 final PhylogenyNode n8 = PhylogenyNode
9498 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9499 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9500 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9503 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9506 final PhylogenyNode n9 = PhylogenyNode
9507 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9508 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9509 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9512 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9515 final PhylogenyNode n10 = PhylogenyNode
9516 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9517 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9520 final PhylogenyNode n20 = PhylogenyNode
9521 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9522 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9525 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9528 final PhylogenyNode n20x = PhylogenyNode
9529 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9530 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9533 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9536 final PhylogenyNode n20xx = PhylogenyNode
9537 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9538 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9541 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9544 final PhylogenyNode n20xxx = PhylogenyNode
9545 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9546 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9549 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9552 final PhylogenyNode n20xxxx = PhylogenyNode
9553 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9554 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9557 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9560 final PhylogenyNode n21 = PhylogenyNode
9561 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9562 if ( !n21.getName().equals( "N21_PIG" ) ) {
9565 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9568 final PhylogenyNode n21x = PhylogenyNode
9569 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9570 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9573 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9576 final PhylogenyNode n22 = PhylogenyNode
9577 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9578 if ( !n22.getName().equals( "n22/PIG" ) ) {
9581 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9584 final PhylogenyNode n23 = PhylogenyNode
9585 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9586 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9589 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9592 final PhylogenyNode a = PhylogenyNode
9593 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9594 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9597 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9600 final PhylogenyNode c1 = PhylogenyNode
9601 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9602 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9603 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9606 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9609 final PhylogenyNode c2 = PhylogenyNode
9610 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9611 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9612 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9615 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9618 final PhylogenyNode e3 = PhylogenyNode
9619 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9620 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9623 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9626 final PhylogenyNode n11 = PhylogenyNode
9627 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9628 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9629 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9632 if ( n11.getDistanceToParent() != 0.4 ) {
9635 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9638 final PhylogenyNode n12 = PhylogenyNode
9639 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9640 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9641 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9644 if ( n12.getDistanceToParent() != 0.4 ) {
9647 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9650 final PhylogenyNode o = PhylogenyNode
9651 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9652 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9655 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9658 if ( n1.getName().compareTo( "" ) != 0 ) {
9661 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9664 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9667 if ( n2.getName().compareTo( "" ) != 0 ) {
9670 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9673 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9676 final PhylogenyNode n00 = PhylogenyNode
9677 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9678 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9681 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9684 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9685 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9688 final PhylogenyNode n13 = PhylogenyNode
9689 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9690 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9693 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9696 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9699 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9702 final PhylogenyNode n14 = PhylogenyNode
9703 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9704 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9707 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9710 final PhylogenyNode n15 = PhylogenyNode
9711 .createInstanceFromNhxString( "something_wicked[123]",
9712 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9713 if ( !n15.getName().equals( "something_wicked" ) ) {
9716 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9719 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9722 final PhylogenyNode n16 = PhylogenyNode
9723 .createInstanceFromNhxString( "something_wicked2[9]",
9724 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9725 if ( !n16.getName().equals( "something_wicked2" ) ) {
9728 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9731 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9734 final PhylogenyNode n17 = PhylogenyNode
9735 .createInstanceFromNhxString( "something_wicked3[a]",
9736 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9737 if ( !n17.getName().equals( "something_wicked3" ) ) {
9740 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9743 final PhylogenyNode n18 = PhylogenyNode
9744 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9745 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9748 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9751 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9754 final PhylogenyNode n19 = PhylogenyNode
9755 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9756 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9759 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9762 final PhylogenyNode n30 = PhylogenyNode
9763 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9764 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9765 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9768 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9771 final PhylogenyNode n31 = PhylogenyNode
9772 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9773 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9774 if ( n31.getNodeData().isHasTaxonomy() ) {
9777 final PhylogenyNode n32 = PhylogenyNode
9778 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9779 if ( n32.getNodeData().isHasTaxonomy() ) {
9782 final PhylogenyNode n40 = PhylogenyNode
9783 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9784 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9787 final PhylogenyNode n41 = PhylogenyNode
9788 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9789 if ( n41.getNodeData().isHasTaxonomy() ) {
9792 final PhylogenyNode n42 = PhylogenyNode
9793 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9794 if ( n42.getNodeData().isHasTaxonomy() ) {
9797 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9798 NHXParser.TAXONOMY_EXTRACTION.NO );
9799 if ( n43.getNodeData().isHasTaxonomy() ) {
9802 final PhylogenyNode n44 = PhylogenyNode
9803 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9804 if ( n44.getNodeData().isHasTaxonomy() ) {
9808 catch ( final Exception e ) {
9809 e.printStackTrace( System.out );
9815 private static boolean testNHXParsing() {
9817 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9818 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9819 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9822 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]";
9823 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9824 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9827 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]";
9828 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9829 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9832 final Phylogeny[] p3 = factory
9833 .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]",
9835 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9838 final Phylogeny[] p4 = factory
9839 .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(]",
9841 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9844 final Phylogeny[] p5 = factory
9845 .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(((]",
9847 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9850 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)";
9851 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)";
9852 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9853 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9856 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)))";
9857 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)))";
9858 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9859 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9862 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]) ))[,,, ])))))))";
9863 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9864 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9865 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9868 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9869 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9872 final Phylogeny p10 = factory
9873 .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]",
9874 new NHXParser() )[ 0 ];
9875 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9878 final Phylogeny p11 = factory
9879 .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]",
9880 new NHXParser() )[ 0 ];
9881 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9884 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]",
9885 new NHXParser() )[ 0 ];
9886 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9890 catch ( final Exception e ) {
9891 e.printStackTrace( System.out );
9897 private static boolean testNHXParsingMB() {
9899 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9900 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9901 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9902 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9903 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9904 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9905 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9906 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9907 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9908 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9909 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9912 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9915 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9916 0.1100000000000000e+00 ) ) {
9919 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9922 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9925 final Phylogeny p2 = factory
9926 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9927 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9928 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9929 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9930 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9931 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9932 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9933 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9934 + "7.369400000000000e-02}])",
9935 new NHXParser() )[ 0 ];
9936 if ( p2.getNode( "1" ) == null ) {
9939 if ( p2.getNode( "2" ) == null ) {
9943 catch ( final Exception e ) {
9944 e.printStackTrace( System.out );
9951 private static boolean testNHXParsingQuotes() {
9953 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9954 final NHXParser p = new NHXParser();
9955 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9956 if ( phylogenies_0.length != 5 ) {
9959 final Phylogeny phy = phylogenies_0[ 4 ];
9960 if ( phy.getNumberOfExternalNodes() != 7 ) {
9963 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9966 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9969 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9970 .getScientificName().equals( "hsapiens" ) ) {
9973 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9976 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9979 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9982 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9985 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9988 final NHXParser p1p = new NHXParser();
9989 p1p.setIgnoreQuotes( true );
9990 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9991 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9994 final NHXParser p2p = new NHXParser();
9995 p1p.setIgnoreQuotes( false );
9996 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9997 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10000 final NHXParser p3p = new NHXParser();
10001 p3p.setIgnoreQuotes( false );
10002 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10003 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10006 final NHXParser p4p = new NHXParser();
10007 p4p.setIgnoreQuotes( false );
10008 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10009 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10012 final Phylogeny p10 = factory
10013 .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]",
10014 new NHXParser() )[ 0 ];
10015 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]";
10016 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10019 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10020 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10023 final Phylogeny p12 = factory
10024 .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]",
10025 new NHXParser() )[ 0 ];
10026 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]";
10027 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10030 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10031 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10034 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;";
10035 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10038 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10039 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10043 catch ( final Exception e ) {
10044 e.printStackTrace( System.out );
10050 private static boolean testNodeRemoval() {
10052 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10053 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10054 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10055 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10058 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10059 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10060 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10063 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10064 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10065 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10069 catch ( final Exception e ) {
10070 e.printStackTrace( System.out );
10076 private static boolean testPhylogenyBranch() {
10078 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10079 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10080 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10081 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10082 if ( !a1b1.equals( a1b1 ) ) {
10085 if ( !a1b1.equals( b1a1 ) ) {
10088 if ( !b1a1.equals( a1b1 ) ) {
10091 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10092 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10093 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10094 if ( a1_b1.equals( b1_a1 ) ) {
10097 if ( a1_b1.equals( a1_b1_ ) ) {
10100 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10101 if ( !a1_b1.equals( b1_a1_ ) ) {
10104 if ( a1_b1_.equals( b1_a1_ ) ) {
10107 if ( !a1_b1_.equals( b1_a1 ) ) {
10111 catch ( final Exception e ) {
10112 e.printStackTrace( System.out );
10118 private static boolean testPhyloXMLparsingOfDistributionElement() {
10120 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10121 PhyloXmlParser xml_parser = null;
10123 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10125 catch ( final Exception e ) {
10126 // Do nothing -- means were not running from jar.
10128 if ( xml_parser == null ) {
10129 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10130 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10131 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10134 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10137 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ),
10139 if ( xml_parser.getErrorCount() > 0 ) {
10140 System.out.println( xml_parser.getErrorMessages().toString() );
10143 if ( phylogenies_0.length != 1 ) {
10146 final Phylogeny t1 = phylogenies_0[ 0 ];
10147 PhylogenyNode n = null;
10148 Distribution d = null;
10149 n = t1.getNode( "root node" );
10150 if ( !n.getNodeData().isHasDistribution() ) {
10153 if ( n.getNodeData().getDistributions().size() != 1 ) {
10156 d = n.getNodeData().getDistribution();
10157 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10160 if ( d.getPoints().size() != 1 ) {
10163 if ( d.getPolygons() != null ) {
10166 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10169 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10172 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10175 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10178 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10181 n = t1.getNode( "node a" );
10182 if ( !n.getNodeData().isHasDistribution() ) {
10185 if ( n.getNodeData().getDistributions().size() != 2 ) {
10188 d = n.getNodeData().getDistribution( 1 );
10189 if ( !d.getDesc().equals( "San Diego" ) ) {
10192 if ( d.getPoints().size() != 1 ) {
10195 if ( d.getPolygons() != null ) {
10198 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10201 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10204 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10207 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10210 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10213 n = t1.getNode( "node bb" );
10214 if ( !n.getNodeData().isHasDistribution() ) {
10217 if ( n.getNodeData().getDistributions().size() != 1 ) {
10220 d = n.getNodeData().getDistribution( 0 );
10221 if ( d.getPoints().size() != 3 ) {
10224 if ( d.getPolygons().size() != 2 ) {
10227 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10230 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10233 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10236 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10239 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10242 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10245 Polygon p = d.getPolygons().get( 0 );
10246 if ( p.getPoints().size() != 3 ) {
10249 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10252 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10255 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10258 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10261 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10264 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10267 p = d.getPolygons().get( 1 );
10268 if ( p.getPoints().size() != 3 ) {
10271 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10274 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10277 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10281 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10282 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10283 if ( rt.length != 1 ) {
10286 final Phylogeny t1_rt = rt[ 0 ];
10287 n = t1_rt.getNode( "root node" );
10288 if ( !n.getNodeData().isHasDistribution() ) {
10291 if ( n.getNodeData().getDistributions().size() != 1 ) {
10294 d = n.getNodeData().getDistribution();
10295 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10298 if ( d.getPoints().size() != 1 ) {
10301 if ( d.getPolygons() != null ) {
10304 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10307 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10310 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10313 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10316 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10319 n = t1_rt.getNode( "node a" );
10320 if ( !n.getNodeData().isHasDistribution() ) {
10323 if ( n.getNodeData().getDistributions().size() != 2 ) {
10326 d = n.getNodeData().getDistribution( 1 );
10327 if ( !d.getDesc().equals( "San Diego" ) ) {
10330 if ( d.getPoints().size() != 1 ) {
10333 if ( d.getPolygons() != null ) {
10336 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10339 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10342 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10345 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10348 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10351 n = t1_rt.getNode( "node bb" );
10352 if ( !n.getNodeData().isHasDistribution() ) {
10355 if ( n.getNodeData().getDistributions().size() != 1 ) {
10358 d = n.getNodeData().getDistribution( 0 );
10359 if ( d.getPoints().size() != 3 ) {
10362 if ( d.getPolygons().size() != 2 ) {
10365 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10368 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10371 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10374 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10377 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10380 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10383 p = d.getPolygons().get( 0 );
10384 if ( p.getPoints().size() != 3 ) {
10387 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10390 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10393 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10396 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10399 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10402 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10405 p = d.getPolygons().get( 1 );
10406 if ( p.getPoints().size() != 3 ) {
10409 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10412 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10415 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10419 catch ( final Exception e ) {
10420 e.printStackTrace( System.out );
10426 private static boolean testPostOrderIterator() {
10428 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10429 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10430 PhylogenyNodeIterator it0;
10431 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10434 for( it0.reset(); it0.hasNext(); ) {
10437 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10438 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10439 if ( !it.next().getName().equals( "A" ) ) {
10442 if ( !it.next().getName().equals( "B" ) ) {
10445 if ( !it.next().getName().equals( "ab" ) ) {
10448 if ( !it.next().getName().equals( "C" ) ) {
10451 if ( !it.next().getName().equals( "D" ) ) {
10454 if ( !it.next().getName().equals( "cd" ) ) {
10457 if ( !it.next().getName().equals( "abcd" ) ) {
10460 if ( !it.next().getName().equals( "E" ) ) {
10463 if ( !it.next().getName().equals( "F" ) ) {
10466 if ( !it.next().getName().equals( "ef" ) ) {
10469 if ( !it.next().getName().equals( "G" ) ) {
10472 if ( !it.next().getName().equals( "H" ) ) {
10475 if ( !it.next().getName().equals( "gh" ) ) {
10478 if ( !it.next().getName().equals( "efgh" ) ) {
10481 if ( !it.next().getName().equals( "r" ) ) {
10484 if ( it.hasNext() ) {
10488 catch ( final Exception e ) {
10489 e.printStackTrace( System.out );
10495 private static boolean testPreOrderIterator() {
10497 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10498 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10499 PhylogenyNodeIterator it0;
10500 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10503 for( it0.reset(); it0.hasNext(); ) {
10506 PhylogenyNodeIterator it = t0.iteratorPreorder();
10507 if ( !it.next().getName().equals( "r" ) ) {
10510 if ( !it.next().getName().equals( "ab" ) ) {
10513 if ( !it.next().getName().equals( "A" ) ) {
10516 if ( !it.next().getName().equals( "B" ) ) {
10519 if ( !it.next().getName().equals( "cd" ) ) {
10522 if ( !it.next().getName().equals( "C" ) ) {
10525 if ( !it.next().getName().equals( "D" ) ) {
10528 if ( it.hasNext() ) {
10531 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10532 it = t1.iteratorPreorder();
10533 if ( !it.next().getName().equals( "r" ) ) {
10536 if ( !it.next().getName().equals( "abcd" ) ) {
10539 if ( !it.next().getName().equals( "ab" ) ) {
10542 if ( !it.next().getName().equals( "A" ) ) {
10545 if ( !it.next().getName().equals( "B" ) ) {
10548 if ( !it.next().getName().equals( "cd" ) ) {
10551 if ( !it.next().getName().equals( "C" ) ) {
10554 if ( !it.next().getName().equals( "D" ) ) {
10557 if ( !it.next().getName().equals( "efgh" ) ) {
10560 if ( !it.next().getName().equals( "ef" ) ) {
10563 if ( !it.next().getName().equals( "E" ) ) {
10566 if ( !it.next().getName().equals( "F" ) ) {
10569 if ( !it.next().getName().equals( "gh" ) ) {
10572 if ( !it.next().getName().equals( "G" ) ) {
10575 if ( !it.next().getName().equals( "H" ) ) {
10578 if ( it.hasNext() ) {
10582 catch ( final Exception e ) {
10583 e.printStackTrace( System.out );
10589 private static boolean testPropertiesMap() {
10591 final PropertiesMap pm = new PropertiesMap();
10592 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10593 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10594 final Property p2 = new Property( "something:else",
10596 "improbable:research",
10599 pm.addProperty( p0 );
10600 pm.addProperty( p1 );
10601 pm.addProperty( p2 );
10602 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10605 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10608 if ( pm.getProperties().size() != 3 ) {
10611 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10614 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10617 if ( pm.getProperties().size() != 3 ) {
10620 pm.removeProperty( "dimensions:diameter" );
10621 if ( pm.getProperties().size() != 2 ) {
10624 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10627 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10631 catch ( final Exception e ) {
10632 e.printStackTrace( System.out );
10638 private static boolean testProteinId() {
10640 final ProteinId id1 = new ProteinId( "a" );
10641 final ProteinId id2 = new ProteinId( "a" );
10642 final ProteinId id3 = new ProteinId( "A" );
10643 final ProteinId id4 = new ProteinId( "b" );
10644 if ( !id1.equals( id1 ) ) {
10647 if ( id1.getId().equals( "x" ) ) {
10650 if ( id1.getId().equals( null ) ) {
10653 if ( !id1.equals( id2 ) ) {
10656 if ( id1.equals( id3 ) ) {
10659 if ( id1.hashCode() != id1.hashCode() ) {
10662 if ( id1.hashCode() != id2.hashCode() ) {
10665 if ( id1.hashCode() == id3.hashCode() ) {
10668 if ( id1.compareTo( id1 ) != 0 ) {
10671 if ( id1.compareTo( id2 ) != 0 ) {
10674 if ( id1.compareTo( id3 ) != 0 ) {
10677 if ( id1.compareTo( id4 ) >= 0 ) {
10680 if ( id4.compareTo( id1 ) <= 0 ) {
10683 if ( !id4.getId().equals( "b" ) ) {
10686 final ProteinId id5 = new ProteinId( " C " );
10687 if ( !id5.getId().equals( "C" ) ) {
10690 if ( id5.equals( id1 ) ) {
10694 catch ( final Exception e ) {
10695 e.printStackTrace( System.out );
10701 private static boolean testReIdMethods() {
10703 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10704 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10705 final long count = PhylogenyNode.getNodeCount();
10706 p.levelOrderReID();
10707 if ( p.getNode( "r" ).getId() != count ) {
10710 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10713 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10716 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10719 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10722 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10725 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10728 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10731 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10734 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10737 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10740 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10743 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10746 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10749 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10753 catch ( final Exception e ) {
10754 e.printStackTrace( System.out );
10760 private static boolean testRerooting() {
10762 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10763 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",
10764 new NHXParser() )[ 0 ];
10765 if ( !t1.isRooted() ) {
10768 t1.reRoot( t1.getNode( "D" ) );
10769 t1.reRoot( t1.getNode( "CD" ) );
10770 t1.reRoot( t1.getNode( "A" ) );
10771 t1.reRoot( t1.getNode( "B" ) );
10772 t1.reRoot( t1.getNode( "AB" ) );
10773 t1.reRoot( t1.getNode( "D" ) );
10774 t1.reRoot( t1.getNode( "C" ) );
10775 t1.reRoot( t1.getNode( "CD" ) );
10776 t1.reRoot( t1.getNode( "A" ) );
10777 t1.reRoot( t1.getNode( "B" ) );
10778 t1.reRoot( t1.getNode( "AB" ) );
10779 t1.reRoot( t1.getNode( "D" ) );
10780 t1.reRoot( t1.getNode( "D" ) );
10781 t1.reRoot( t1.getNode( "C" ) );
10782 t1.reRoot( t1.getNode( "A" ) );
10783 t1.reRoot( t1.getNode( "B" ) );
10784 t1.reRoot( t1.getNode( "AB" ) );
10785 t1.reRoot( t1.getNode( "C" ) );
10786 t1.reRoot( t1.getNode( "D" ) );
10787 t1.reRoot( t1.getNode( "CD" ) );
10788 t1.reRoot( t1.getNode( "D" ) );
10789 t1.reRoot( t1.getNode( "A" ) );
10790 t1.reRoot( t1.getNode( "B" ) );
10791 t1.reRoot( t1.getNode( "AB" ) );
10792 t1.reRoot( t1.getNode( "C" ) );
10793 t1.reRoot( t1.getNode( "D" ) );
10794 t1.reRoot( t1.getNode( "CD" ) );
10795 t1.reRoot( t1.getNode( "D" ) );
10796 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10799 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10802 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10805 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10808 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10811 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10814 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",
10815 new NHXParser() )[ 0 ];
10816 t2.reRoot( t2.getNode( "A" ) );
10817 t2.reRoot( t2.getNode( "D" ) );
10818 t2.reRoot( t2.getNode( "ABC" ) );
10819 t2.reRoot( t2.getNode( "A" ) );
10820 t2.reRoot( t2.getNode( "B" ) );
10821 t2.reRoot( t2.getNode( "D" ) );
10822 t2.reRoot( t2.getNode( "C" ) );
10823 t2.reRoot( t2.getNode( "ABC" ) );
10824 t2.reRoot( t2.getNode( "A" ) );
10825 t2.reRoot( t2.getNode( "B" ) );
10826 t2.reRoot( t2.getNode( "AB" ) );
10827 t2.reRoot( t2.getNode( "AB" ) );
10828 t2.reRoot( t2.getNode( "D" ) );
10829 t2.reRoot( t2.getNode( "C" ) );
10830 t2.reRoot( t2.getNode( "B" ) );
10831 t2.reRoot( t2.getNode( "AB" ) );
10832 t2.reRoot( t2.getNode( "D" ) );
10833 t2.reRoot( t2.getNode( "D" ) );
10834 t2.reRoot( t2.getNode( "ABC" ) );
10835 t2.reRoot( t2.getNode( "A" ) );
10836 t2.reRoot( t2.getNode( "B" ) );
10837 t2.reRoot( t2.getNode( "AB" ) );
10838 t2.reRoot( t2.getNode( "D" ) );
10839 t2.reRoot( t2.getNode( "C" ) );
10840 t2.reRoot( t2.getNode( "ABC" ) );
10841 t2.reRoot( t2.getNode( "A" ) );
10842 t2.reRoot( t2.getNode( "B" ) );
10843 t2.reRoot( t2.getNode( "AB" ) );
10844 t2.reRoot( t2.getNode( "D" ) );
10845 t2.reRoot( t2.getNode( "D" ) );
10846 t2.reRoot( t2.getNode( "C" ) );
10847 t2.reRoot( t2.getNode( "A" ) );
10848 t2.reRoot( t2.getNode( "B" ) );
10849 t2.reRoot( t2.getNode( "AB" ) );
10850 t2.reRoot( t2.getNode( "C" ) );
10851 t2.reRoot( t2.getNode( "D" ) );
10852 t2.reRoot( t2.getNode( "ABC" ) );
10853 t2.reRoot( t2.getNode( "D" ) );
10854 t2.reRoot( t2.getNode( "A" ) );
10855 t2.reRoot( t2.getNode( "B" ) );
10856 t2.reRoot( t2.getNode( "AB" ) );
10857 t2.reRoot( t2.getNode( "C" ) );
10858 t2.reRoot( t2.getNode( "D" ) );
10859 t2.reRoot( t2.getNode( "ABC" ) );
10860 t2.reRoot( t2.getNode( "D" ) );
10861 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10864 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10867 t2.reRoot( t2.getNode( "ABC" ) );
10868 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10871 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10874 t2.reRoot( t2.getNode( "AB" ) );
10875 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10878 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10881 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10884 t2.reRoot( t2.getNode( "AB" ) );
10885 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10888 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10891 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10894 t2.reRoot( t2.getNode( "D" ) );
10895 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10898 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10901 t2.reRoot( t2.getNode( "ABC" ) );
10902 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10905 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10908 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10909 new NHXParser() )[ 0 ];
10910 t3.reRoot( t3.getNode( "B" ) );
10911 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10914 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10917 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10920 t3.reRoot( t3.getNode( "B" ) );
10921 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10924 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10927 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10930 t3.reRoot( t3.getRoot() );
10931 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10934 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10937 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10941 catch ( final Exception e ) {
10942 e.printStackTrace( System.out );
10948 private static boolean testSDIse() {
10950 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10951 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10952 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10953 gene1.setRooted( true );
10954 species1.setRooted( true );
10955 final SDI sdi = new SDI( gene1, species1 );
10956 if ( !gene1.getRoot().isDuplication() ) {
10959 final Phylogeny species2 = factory
10960 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10961 new NHXParser() )[ 0 ];
10962 final Phylogeny gene2 = factory
10963 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10964 new NHXParser() )[ 0 ];
10965 species2.setRooted( true );
10966 gene2.setRooted( true );
10967 final SDI sdi2 = new SDI( gene2, species2 );
10968 if ( sdi2.getDuplicationsSum() != 0 ) {
10971 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10974 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10977 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10980 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10983 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10986 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10989 final Phylogeny species3 = factory
10990 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10991 new NHXParser() )[ 0 ];
10992 final Phylogeny gene3 = factory
10993 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10994 new NHXParser() )[ 0 ];
10995 species3.setRooted( true );
10996 gene3.setRooted( true );
10997 final SDI sdi3 = new SDI( gene3, species3 );
10998 if ( sdi3.getDuplicationsSum() != 1 ) {
11001 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11004 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11007 final Phylogeny species4 = factory
11008 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11009 new NHXParser() )[ 0 ];
11010 final Phylogeny gene4 = factory
11011 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11012 new NHXParser() )[ 0 ];
11013 species4.setRooted( true );
11014 gene4.setRooted( true );
11015 final SDI sdi4 = new SDI( gene4, species4 );
11016 if ( sdi4.getDuplicationsSum() != 1 ) {
11019 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11022 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11025 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11028 if ( species4.getNumberOfExternalNodes() != 6 ) {
11031 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11034 final Phylogeny species5 = factory
11035 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11036 new NHXParser() )[ 0 ];
11037 final Phylogeny gene5 = factory
11038 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11039 new NHXParser() )[ 0 ];
11040 species5.setRooted( true );
11041 gene5.setRooted( true );
11042 final SDI sdi5 = new SDI( gene5, species5 );
11043 if ( sdi5.getDuplicationsSum() != 2 ) {
11046 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11049 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11052 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11055 if ( species5.getNumberOfExternalNodes() != 6 ) {
11058 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11061 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11062 // Conjecture for Comparing Molecular Phylogenies"
11063 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11064 final Phylogeny species6 = factory
11065 .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,"
11066 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11067 new NHXParser() )[ 0 ];
11068 final Phylogeny gene6 = factory
11069 .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,"
11070 + "((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,"
11071 + "(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;",
11072 new NHXParser() )[ 0 ];
11073 species6.setRooted( true );
11074 gene6.setRooted( true );
11075 final SDI sdi6 = new SDI( gene6, species6 );
11076 if ( sdi6.getDuplicationsSum() != 3 ) {
11079 if ( !gene6.getNode( "r" ).isDuplication() ) {
11082 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11085 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11088 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11091 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11094 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11097 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11100 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11103 sdi6.computeMappingCostL();
11104 if ( sdi6.computeMappingCostL() != 17 ) {
11107 if ( species6.getNumberOfExternalNodes() != 9 ) {
11110 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11113 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11114 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11115 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11116 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11117 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11118 species7.setRooted( true );
11119 final Phylogeny gene7_1 = Test
11120 .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])" );
11121 gene7_1.setRooted( true );
11122 final SDI sdi7 = new SDI( gene7_1, species7 );
11123 if ( sdi7.getDuplicationsSum() != 0 ) {
11126 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11129 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11132 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11135 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11138 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11141 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11144 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11147 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11150 final Phylogeny gene7_2 = Test
11151 .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])" );
11152 gene7_2.setRooted( true );
11153 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11154 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11157 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11160 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11163 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11166 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11169 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11172 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11175 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11178 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11181 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11185 catch ( final Exception e ) {
11191 private static boolean testSDIunrooted() {
11193 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11194 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
11195 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11196 final Iterator<PhylogenyBranch> iter = l.iterator();
11197 PhylogenyBranch br = iter.next();
11198 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11201 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11205 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11208 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11212 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11215 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11219 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11222 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11226 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11229 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11233 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11236 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11240 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11243 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11247 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11250 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11254 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11257 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11261 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11264 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11268 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11271 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11275 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11278 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11282 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11285 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11289 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11292 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11296 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11299 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11302 if ( iter.hasNext() ) {
11305 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11306 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11307 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11309 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11312 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11316 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11319 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11323 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11326 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11329 if ( iter1.hasNext() ) {
11332 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11333 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11334 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11336 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11339 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11343 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11346 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11350 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11353 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11356 if ( iter2.hasNext() ) {
11359 final Phylogeny species0 = factory
11360 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11361 new NHXParser() )[ 0 ];
11362 final Phylogeny gene1 = factory
11363 .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])",
11364 new NHXParser() )[ 0 ];
11365 species0.setRooted( true );
11366 gene1.setRooted( true );
11367 final SDIR sdi_unrooted = new SDIR();
11368 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11369 if ( sdi_unrooted.getCount() != 1 ) {
11372 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11375 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11378 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11381 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11384 final Phylogeny gene2 = factory
11385 .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])",
11386 new NHXParser() )[ 0 ];
11387 gene2.setRooted( true );
11388 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11389 if ( sdi_unrooted.getCount() != 1 ) {
11392 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11395 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11398 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11401 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11404 final Phylogeny species6 = factory
11405 .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,"
11406 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11407 new NHXParser() )[ 0 ];
11408 final Phylogeny gene6 = factory
11409 .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],"
11410 + "(((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],"
11411 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11412 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11413 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11414 new NHXParser() )[ 0 ];
11415 species6.setRooted( true );
11416 gene6.setRooted( true );
11417 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11418 if ( sdi_unrooted.getCount() != 1 ) {
11421 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11424 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11427 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11430 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11433 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11436 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11439 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11442 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11445 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11448 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11451 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11454 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11458 final Phylogeny species7 = factory
11459 .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,"
11460 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11461 new NHXParser() )[ 0 ];
11462 final Phylogeny gene7 = factory
11463 .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],"
11464 + "(((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],"
11465 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11466 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11467 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11468 new NHXParser() )[ 0 ];
11469 species7.setRooted( true );
11470 gene7.setRooted( true );
11471 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11472 if ( sdi_unrooted.getCount() != 1 ) {
11475 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11478 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11481 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11484 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11487 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11490 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11493 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11496 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11499 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11502 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11505 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11508 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11512 final Phylogeny species8 = factory
11513 .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,"
11514 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11515 new NHXParser() )[ 0 ];
11516 final Phylogeny gene8 = factory
11517 .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],"
11518 + "(((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],"
11519 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11520 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11521 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11522 new NHXParser() )[ 0 ];
11523 species8.setRooted( true );
11524 gene8.setRooted( true );
11525 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11526 if ( sdi_unrooted.getCount() != 1 ) {
11529 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11532 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11535 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11538 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11541 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11544 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11547 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11550 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11553 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11556 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11559 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11562 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11567 catch ( final Exception e ) {
11568 e.printStackTrace( System.out );
11574 private static boolean testSequenceDbWsTools1() {
11576 final PhylogenyNode n = new PhylogenyNode();
11577 n.setName( "NP_001025424" );
11578 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11579 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11580 || !acc.getValue().equals( "NP_001025424" ) ) {
11583 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11584 acc = SequenceDbWsTools.obtainSeqAccession( n );
11585 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11586 || !acc.getValue().equals( "NP_001025424" ) ) {
11589 n.setName( "NP_001025424.1" );
11590 acc = SequenceDbWsTools.obtainSeqAccession( n );
11591 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11592 || !acc.getValue().equals( "NP_001025424" ) ) {
11595 n.setName( "NM_001030253" );
11596 acc = SequenceDbWsTools.obtainSeqAccession( n );
11597 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11598 || !acc.getValue().equals( "NM_001030253" ) ) {
11601 n.setName( "BCL2_HUMAN" );
11602 acc = SequenceDbWsTools.obtainSeqAccession( n );
11603 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11604 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11605 System.out.println( acc.toString() );
11608 n.setName( "P10415" );
11609 acc = SequenceDbWsTools.obtainSeqAccession( n );
11610 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11611 || !acc.getValue().equals( "P10415" ) ) {
11612 System.out.println( acc.toString() );
11615 n.setName( " P10415 " );
11616 acc = SequenceDbWsTools.obtainSeqAccession( n );
11617 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11618 || !acc.getValue().equals( "P10415" ) ) {
11619 System.out.println( acc.toString() );
11622 n.setName( "_P10415|" );
11623 acc = SequenceDbWsTools.obtainSeqAccession( n );
11624 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11625 || !acc.getValue().equals( "P10415" ) ) {
11626 System.out.println( acc.toString() );
11629 n.setName( "AY695820" );
11630 acc = SequenceDbWsTools.obtainSeqAccession( n );
11631 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11632 || !acc.getValue().equals( "AY695820" ) ) {
11633 System.out.println( acc.toString() );
11636 n.setName( "_AY695820_" );
11637 acc = SequenceDbWsTools.obtainSeqAccession( n );
11638 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11639 || !acc.getValue().equals( "AY695820" ) ) {
11640 System.out.println( acc.toString() );
11643 n.setName( "AAA59452" );
11644 acc = SequenceDbWsTools.obtainSeqAccession( n );
11645 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11646 || !acc.getValue().equals( "AAA59452" ) ) {
11647 System.out.println( acc.toString() );
11650 n.setName( "_AAA59452_" );
11651 acc = SequenceDbWsTools.obtainSeqAccession( n );
11652 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11653 || !acc.getValue().equals( "AAA59452" ) ) {
11654 System.out.println( acc.toString() );
11657 n.setName( "AAA59452.1" );
11658 acc = SequenceDbWsTools.obtainSeqAccession( n );
11659 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11660 || !acc.getValue().equals( "AAA59452.1" ) ) {
11661 System.out.println( acc.toString() );
11664 n.setName( "_AAA59452.1_" );
11665 acc = SequenceDbWsTools.obtainSeqAccession( n );
11666 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11667 || !acc.getValue().equals( "AAA59452.1" ) ) {
11668 System.out.println( acc.toString() );
11671 n.setName( "GI:94894583" );
11672 acc = SequenceDbWsTools.obtainSeqAccession( n );
11673 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11674 || !acc.getValue().equals( "94894583" ) ) {
11675 System.out.println( acc.toString() );
11678 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11679 acc = SequenceDbWsTools.obtainSeqAccession( n );
11680 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11681 || !acc.getValue().equals( "71845847" ) ) {
11682 System.out.println( acc.toString() );
11685 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11686 acc = SequenceDbWsTools.obtainSeqAccession( n );
11687 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11688 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11689 System.out.println( acc.toString() );
11693 catch ( final Exception e ) {
11699 private static boolean testSequenceDbWsTools2() {
11701 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11702 SequenceDbWsTools.obtainSeqInformation( n1 );
11703 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11706 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11709 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11712 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11715 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11716 SequenceDbWsTools.obtainSeqInformation( n2 );
11717 if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
11720 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11723 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11726 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11729 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11730 SequenceDbWsTools.obtainSeqInformation( n3 );
11731 if ( !n3.getNodeData().getSequence().getName()
11732 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11735 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11738 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11741 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11745 catch ( final IOException e ) {
11746 System.out.println();
11747 System.out.println( "the following might be due to absence internet connection:" );
11748 e.printStackTrace( System.out );
11751 catch ( final Exception e ) {
11752 e.printStackTrace();
11758 private static boolean testSequenceIdParsing() {
11760 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11761 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11762 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11763 if ( id != null ) {
11764 System.out.println( "value =" + id.getValue() );
11765 System.out.println( "provider=" + id.getSource() );
11769 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11770 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11771 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11772 if ( id != null ) {
11773 System.out.println( "value =" + id.getValue() );
11774 System.out.println( "provider=" + id.getSource() );
11778 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11779 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11780 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11781 if ( id != null ) {
11782 System.out.println( "value =" + id.getValue() );
11783 System.out.println( "provider=" + id.getSource() );
11787 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11788 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11789 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11790 if ( id != null ) {
11791 System.out.println( "value =" + id.getValue() );
11792 System.out.println( "provider=" + id.getSource() );
11796 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11797 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11798 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11799 if ( id != null ) {
11800 System.out.println( "value =" + id.getValue() );
11801 System.out.println( "provider=" + id.getSource() );
11805 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11806 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11807 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11808 if ( id != null ) {
11809 System.out.println( "value =" + id.getValue() );
11810 System.out.println( "provider=" + id.getSource() );
11814 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11815 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11816 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11817 if ( id != null ) {
11818 System.out.println( "value =" + id.getValue() );
11819 System.out.println( "provider=" + id.getSource() );
11823 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11824 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11825 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11826 if ( id != null ) {
11827 System.out.println( "value =" + id.getValue() );
11828 System.out.println( "provider=" + id.getSource() );
11832 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11833 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11834 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11835 if ( id != null ) {
11836 System.out.println( "value =" + id.getValue() );
11837 System.out.println( "provider=" + id.getSource() );
11841 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11842 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11843 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11844 if ( id != null ) {
11845 System.out.println( "value =" + id.getValue() );
11846 System.out.println( "provider=" + id.getSource() );
11850 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11851 if ( id != null ) {
11852 System.out.println( "value =" + id.getValue() );
11853 System.out.println( "provider=" + id.getSource() );
11856 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
11857 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11858 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
11859 if ( id != null ) {
11860 System.out.println( "value =" + id.getValue() );
11861 System.out.println( "provider=" + id.getSource() );
11865 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
11866 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11867 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11868 if ( id != null ) {
11869 System.out.println( "value =" + id.getValue() );
11870 System.out.println( "provider=" + id.getSource() );
11874 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
11875 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11876 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11877 if ( id != null ) {
11878 System.out.println( "value =" + id.getValue() );
11879 System.out.println( "provider=" + id.getSource() );
11883 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
11884 if ( id != null ) {
11885 System.out.println( "value =" + id.getValue() );
11886 System.out.println( "provider=" + id.getSource() );
11890 catch ( final Exception e ) {
11891 e.printStackTrace( System.out );
11897 private static boolean testSequenceWriter() {
11899 final String n = ForesterUtil.LINE_SEPARATOR;
11900 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11903 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11906 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11909 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11912 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11913 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11916 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11917 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11921 catch ( final Exception e ) {
11922 e.printStackTrace();
11928 private static boolean testSpecies() {
11930 final Species s1 = new BasicSpecies( "a" );
11931 final Species s2 = new BasicSpecies( "a" );
11932 final Species s3 = new BasicSpecies( "A" );
11933 final Species s4 = new BasicSpecies( "b" );
11934 if ( !s1.equals( s1 ) ) {
11937 if ( s1.getSpeciesId().equals( "x" ) ) {
11940 if ( s1.getSpeciesId().equals( null ) ) {
11943 if ( !s1.equals( s2 ) ) {
11946 if ( s1.equals( s3 ) ) {
11949 if ( s1.hashCode() != s1.hashCode() ) {
11952 if ( s1.hashCode() != s2.hashCode() ) {
11955 if ( s1.hashCode() == s3.hashCode() ) {
11958 if ( s1.compareTo( s1 ) != 0 ) {
11961 if ( s1.compareTo( s2 ) != 0 ) {
11964 if ( s1.compareTo( s3 ) != 0 ) {
11967 if ( s1.compareTo( s4 ) >= 0 ) {
11970 if ( s4.compareTo( s1 ) <= 0 ) {
11973 if ( !s4.getSpeciesId().equals( "b" ) ) {
11976 final Species s5 = new BasicSpecies( " C " );
11977 if ( !s5.getSpeciesId().equals( "C" ) ) {
11980 if ( s5.equals( s1 ) ) {
11984 catch ( final Exception e ) {
11985 e.printStackTrace( System.out );
11991 private static boolean testSplit() {
11993 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11994 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11995 //Archaeopteryx.createApplication( p0 );
11996 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11997 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11998 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11999 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12000 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12001 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12002 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12003 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12004 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12005 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12006 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12007 // System.out.println( s0.toString() );
12009 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12010 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12012 if ( s0.match( query_nodes ) ) {
12015 query_nodes = new HashSet<PhylogenyNode>();
12016 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12017 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12023 if ( !s0.match( query_nodes ) ) {
12027 query_nodes = new HashSet<PhylogenyNode>();
12028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12031 if ( !s0.match( query_nodes ) ) {
12035 query_nodes = new HashSet<PhylogenyNode>();
12036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12040 if ( !s0.match( query_nodes ) ) {
12044 query_nodes = new HashSet<PhylogenyNode>();
12045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12046 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12047 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12048 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12049 if ( !s0.match( query_nodes ) ) {
12053 query_nodes = new HashSet<PhylogenyNode>();
12054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12056 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12057 if ( !s0.match( query_nodes ) ) {
12060 query_nodes = new HashSet<PhylogenyNode>();
12061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12063 if ( !s0.match( query_nodes ) ) {
12066 query_nodes = new HashSet<PhylogenyNode>();
12067 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12068 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12069 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12070 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12071 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12072 if ( !s0.match( query_nodes ) ) {
12075 query_nodes = new HashSet<PhylogenyNode>();
12076 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12077 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12078 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12079 if ( !s0.match( query_nodes ) ) {
12082 query_nodes = new HashSet<PhylogenyNode>();
12083 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12084 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12085 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12087 if ( !s0.match( query_nodes ) ) {
12090 query_nodes = new HashSet<PhylogenyNode>();
12091 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12092 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12093 if ( s0.match( query_nodes ) ) {
12096 query_nodes = new HashSet<PhylogenyNode>();
12097 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12098 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12099 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12100 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12101 if ( s0.match( query_nodes ) ) {
12104 query_nodes = new HashSet<PhylogenyNode>();
12105 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12106 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12107 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12109 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12110 if ( s0.match( query_nodes ) ) {
12113 query_nodes = new HashSet<PhylogenyNode>();
12114 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12115 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12116 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12117 if ( s0.match( query_nodes ) ) {
12120 query_nodes = new HashSet<PhylogenyNode>();
12121 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12122 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12123 if ( s0.match( query_nodes ) ) {
12126 query_nodes = new HashSet<PhylogenyNode>();
12127 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12128 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12129 if ( s0.match( query_nodes ) ) {
12132 query_nodes = new HashSet<PhylogenyNode>();
12133 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12134 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12135 if ( s0.match( query_nodes ) ) {
12138 query_nodes = new HashSet<PhylogenyNode>();
12139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12140 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12141 if ( s0.match( query_nodes ) ) {
12144 query_nodes = new HashSet<PhylogenyNode>();
12145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12146 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12147 if ( s0.match( query_nodes ) ) {
12150 query_nodes = new HashSet<PhylogenyNode>();
12151 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12152 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12153 if ( s0.match( query_nodes ) ) {
12156 query_nodes = new HashSet<PhylogenyNode>();
12157 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12158 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12159 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12160 if ( s0.match( query_nodes ) ) {
12163 query_nodes = new HashSet<PhylogenyNode>();
12164 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12165 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12166 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12167 if ( s0.match( query_nodes ) ) {
12170 query_nodes = new HashSet<PhylogenyNode>();
12171 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12172 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12173 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12174 if ( s0.match( query_nodes ) ) {
12177 query_nodes = new HashSet<PhylogenyNode>();
12178 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12179 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12180 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12181 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12182 if ( s0.match( query_nodes ) ) {
12186 // query_nodes = new HashSet<PhylogenyNode>();
12187 // query_nodes.add( new PhylogenyNode( "X" ) );
12188 // query_nodes.add( new PhylogenyNode( "Y" ) );
12189 // query_nodes.add( new PhylogenyNode( "A" ) );
12190 // query_nodes.add( new PhylogenyNode( "B" ) );
12191 // query_nodes.add( new PhylogenyNode( "C" ) );
12192 // query_nodes.add( new PhylogenyNode( "D" ) );
12193 // query_nodes.add( new PhylogenyNode( "E" ) );
12194 // query_nodes.add( new PhylogenyNode( "F" ) );
12195 // query_nodes.add( new PhylogenyNode( "G" ) );
12196 // if ( !s0.match( query_nodes ) ) {
12199 // query_nodes = new HashSet<PhylogenyNode>();
12200 // query_nodes.add( new PhylogenyNode( "X" ) );
12201 // query_nodes.add( new PhylogenyNode( "Y" ) );
12202 // query_nodes.add( new PhylogenyNode( "A" ) );
12203 // query_nodes.add( new PhylogenyNode( "B" ) );
12204 // query_nodes.add( new PhylogenyNode( "C" ) );
12205 // if ( !s0.match( query_nodes ) ) {
12209 // query_nodes = new HashSet<PhylogenyNode>();
12210 // query_nodes.add( new PhylogenyNode( "X" ) );
12211 // query_nodes.add( new PhylogenyNode( "Y" ) );
12212 // query_nodes.add( new PhylogenyNode( "D" ) );
12213 // query_nodes.add( new PhylogenyNode( "E" ) );
12214 // query_nodes.add( new PhylogenyNode( "F" ) );
12215 // query_nodes.add( new PhylogenyNode( "G" ) );
12216 // if ( !s0.match( query_nodes ) ) {
12220 // query_nodes = new HashSet<PhylogenyNode>();
12221 // query_nodes.add( new PhylogenyNode( "X" ) );
12222 // query_nodes.add( new PhylogenyNode( "Y" ) );
12223 // query_nodes.add( new PhylogenyNode( "A" ) );
12224 // query_nodes.add( new PhylogenyNode( "B" ) );
12225 // query_nodes.add( new PhylogenyNode( "C" ) );
12226 // query_nodes.add( new PhylogenyNode( "D" ) );
12227 // if ( !s0.match( query_nodes ) ) {
12231 // query_nodes = new HashSet<PhylogenyNode>();
12232 // query_nodes.add( new PhylogenyNode( "X" ) );
12233 // query_nodes.add( new PhylogenyNode( "Y" ) );
12234 // query_nodes.add( new PhylogenyNode( "E" ) );
12235 // query_nodes.add( new PhylogenyNode( "F" ) );
12236 // query_nodes.add( new PhylogenyNode( "G" ) );
12237 // if ( !s0.match( query_nodes ) ) {
12241 // query_nodes = new HashSet<PhylogenyNode>();
12242 // query_nodes.add( new PhylogenyNode( "X" ) );
12243 // query_nodes.add( new PhylogenyNode( "Y" ) );
12244 // query_nodes.add( new PhylogenyNode( "F" ) );
12245 // query_nodes.add( new PhylogenyNode( "G" ) );
12246 // if ( !s0.match( query_nodes ) ) {
12250 query_nodes = new HashSet<PhylogenyNode>();
12251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
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( "X" ) );
12261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12262 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12263 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12264 if ( s0.match( query_nodes ) ) {
12267 ///////////////////////////
12269 query_nodes = new HashSet<PhylogenyNode>();
12270 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12271 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12274 if ( s0.match( query_nodes ) ) {
12278 query_nodes = new HashSet<PhylogenyNode>();
12279 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12283 if ( s0.match( query_nodes ) ) {
12287 query_nodes = new HashSet<PhylogenyNode>();
12288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12292 if ( s0.match( query_nodes ) ) {
12296 query_nodes = new HashSet<PhylogenyNode>();
12297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12299 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12300 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12301 if ( s0.match( query_nodes ) ) {
12305 query_nodes = new HashSet<PhylogenyNode>();
12306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12307 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12310 if ( s0.match( query_nodes ) ) {
12314 query_nodes = new HashSet<PhylogenyNode>();
12315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12316 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12318 if ( s0.match( query_nodes ) ) {
12322 query_nodes = new HashSet<PhylogenyNode>();
12323 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12324 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12328 if ( s0.match( query_nodes ) ) {
12332 query_nodes = new HashSet<PhylogenyNode>();
12333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12337 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12338 if ( s0.match( query_nodes ) ) {
12342 query_nodes = new HashSet<PhylogenyNode>();
12343 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12344 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12345 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12346 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12348 if ( s0.match( query_nodes ) ) {
12352 query_nodes = new HashSet<PhylogenyNode>();
12353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12357 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12358 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12359 if ( s0.match( query_nodes ) ) {
12363 catch ( final Exception e ) {
12364 e.printStackTrace();
12370 private static boolean testSplitStrict() {
12372 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12373 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12374 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12375 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12376 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12377 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12378 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12379 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12380 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12381 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12382 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12383 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12386 if ( s0.match( query_nodes ) ) {
12389 query_nodes = new HashSet<PhylogenyNode>();
12390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12394 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12395 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12396 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12397 if ( !s0.match( query_nodes ) ) {
12401 query_nodes = new HashSet<PhylogenyNode>();
12402 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12403 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12405 if ( !s0.match( query_nodes ) ) {
12409 query_nodes = new HashSet<PhylogenyNode>();
12410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12414 if ( !s0.match( query_nodes ) ) {
12418 query_nodes = new HashSet<PhylogenyNode>();
12419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12423 if ( !s0.match( query_nodes ) ) {
12427 query_nodes = new HashSet<PhylogenyNode>();
12428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12430 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12431 if ( !s0.match( query_nodes ) ) {
12435 query_nodes = new HashSet<PhylogenyNode>();
12436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12438 if ( !s0.match( query_nodes ) ) {
12442 query_nodes = new HashSet<PhylogenyNode>();
12443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12446 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12447 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12448 if ( !s0.match( query_nodes ) ) {
12452 query_nodes = new HashSet<PhylogenyNode>();
12453 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12455 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12456 if ( !s0.match( query_nodes ) ) {
12460 query_nodes = new HashSet<PhylogenyNode>();
12461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12462 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12463 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12465 if ( !s0.match( query_nodes ) ) {
12469 query_nodes = new HashSet<PhylogenyNode>();
12470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12472 if ( s0.match( query_nodes ) ) {
12476 query_nodes = new HashSet<PhylogenyNode>();
12477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12478 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12481 if ( s0.match( query_nodes ) ) {
12485 query_nodes = new HashSet<PhylogenyNode>();
12486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12487 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12491 if ( s0.match( query_nodes ) ) {
12495 query_nodes = new HashSet<PhylogenyNode>();
12496 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12499 if ( s0.match( query_nodes ) ) {
12503 query_nodes = new HashSet<PhylogenyNode>();
12504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12505 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12506 if ( s0.match( query_nodes ) ) {
12510 query_nodes = new HashSet<PhylogenyNode>();
12511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12513 if ( s0.match( query_nodes ) ) {
12517 query_nodes = new HashSet<PhylogenyNode>();
12518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12520 if ( s0.match( query_nodes ) ) {
12524 query_nodes = new HashSet<PhylogenyNode>();
12525 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12527 if ( s0.match( query_nodes ) ) {
12531 query_nodes = new HashSet<PhylogenyNode>();
12532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12533 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12534 if ( s0.match( query_nodes ) ) {
12538 query_nodes = new HashSet<PhylogenyNode>();
12539 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12540 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12541 if ( s0.match( query_nodes ) ) {
12545 query_nodes = new HashSet<PhylogenyNode>();
12546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12548 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12549 if ( s0.match( query_nodes ) ) {
12553 query_nodes = new HashSet<PhylogenyNode>();
12554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12557 if ( s0.match( query_nodes ) ) {
12561 query_nodes = new HashSet<PhylogenyNode>();
12562 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12565 if ( s0.match( query_nodes ) ) {
12569 query_nodes = new HashSet<PhylogenyNode>();
12570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12572 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12574 if ( s0.match( query_nodes ) ) {
12578 catch ( final Exception e ) {
12579 e.printStackTrace();
12585 private static boolean testSubtreeDeletion() {
12587 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12588 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12589 t1.deleteSubtree( t1.getNode( "A" ), false );
12590 if ( t1.getNumberOfExternalNodes() != 5 ) {
12593 t1.toNewHampshireX();
12594 t1.deleteSubtree( t1.getNode( "E" ), false );
12595 if ( t1.getNumberOfExternalNodes() != 4 ) {
12598 t1.toNewHampshireX();
12599 t1.deleteSubtree( t1.getNode( "F" ), false );
12600 if ( t1.getNumberOfExternalNodes() != 3 ) {
12603 t1.toNewHampshireX();
12604 t1.deleteSubtree( t1.getNode( "D" ), false );
12605 t1.toNewHampshireX();
12606 if ( t1.getNumberOfExternalNodes() != 3 ) {
12609 t1.deleteSubtree( t1.getNode( "def" ), false );
12610 t1.toNewHampshireX();
12611 if ( t1.getNumberOfExternalNodes() != 2 ) {
12614 t1.deleteSubtree( t1.getNode( "B" ), false );
12615 t1.toNewHampshireX();
12616 if ( t1.getNumberOfExternalNodes() != 1 ) {
12619 t1.deleteSubtree( t1.getNode( "C" ), false );
12620 t1.toNewHampshireX();
12621 if ( t1.getNumberOfExternalNodes() != 1 ) {
12624 t1.deleteSubtree( t1.getNode( "abc" ), false );
12625 t1.toNewHampshireX();
12626 if ( t1.getNumberOfExternalNodes() != 1 ) {
12629 t1.deleteSubtree( t1.getNode( "r" ), false );
12630 if ( t1.getNumberOfExternalNodes() != 0 ) {
12633 if ( !t1.isEmpty() ) {
12636 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12637 t2.deleteSubtree( t2.getNode( "A" ), false );
12638 t2.toNewHampshireX();
12639 if ( t2.getNumberOfExternalNodes() != 5 ) {
12642 t2.deleteSubtree( t2.getNode( "abc" ), false );
12643 t2.toNewHampshireX();
12644 if ( t2.getNumberOfExternalNodes() != 3 ) {
12647 t2.deleteSubtree( t2.getNode( "def" ), false );
12648 t2.toNewHampshireX();
12649 if ( t2.getNumberOfExternalNodes() != 1 ) {
12653 catch ( final Exception e ) {
12654 e.printStackTrace( System.out );
12660 private static boolean testSupportCount() {
12662 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12663 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12664 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12665 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12666 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12667 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12668 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12670 SupportCount.count( t0_1, phylogenies_1, true, false );
12671 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12672 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12673 + "(((((A,B),C),D),E),((F,G),X))"
12674 + "(((((A,Y),B),C),D),((F,G),E))"
12675 + "(((((A,B),C),D),E),(F,G))"
12676 + "(((((A,B),C),D),E),(F,G))"
12677 + "(((((A,B),C),D),E),(F,G))"
12678 + "(((((A,B),C),D),E),(F,G),Z)"
12679 + "(((((A,B),C),D),E),(F,G))"
12680 + "((((((A,B),C),D),E),F),G)"
12681 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12683 SupportCount.count( t0_2, phylogenies_2, true, false );
12684 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12685 while ( it.hasNext() ) {
12686 final PhylogenyNode n = it.next();
12687 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12691 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12692 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12693 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12694 SupportCount.count( t0_3, phylogenies_3, true, false );
12695 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12696 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12699 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12702 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12705 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12708 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12711 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12714 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12717 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12720 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12723 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12726 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12727 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12728 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12729 SupportCount.count( t0_4, phylogenies_4, true, false );
12730 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12731 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12734 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12737 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12740 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12743 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12746 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12749 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12752 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12755 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12758 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12761 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12762 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12763 double d = SupportCount.compare( b1, a, true, true, true );
12764 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12767 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12768 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12769 d = SupportCount.compare( b2, a, true, true, true );
12770 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12773 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12774 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12775 d = SupportCount.compare( b3, a, true, true, true );
12776 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12779 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12780 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12781 d = SupportCount.compare( b4, a, true, true, false );
12782 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12786 catch ( final Exception e ) {
12787 e.printStackTrace( System.out );
12793 private static boolean testSupportTransfer() {
12795 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12796 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)",
12797 new NHXParser() )[ 0 ];
12798 final Phylogeny p2 = factory
12799 .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 ];
12800 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12803 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12806 support_transfer.moveBranchLengthsToBootstrap( p1 );
12807 support_transfer.transferSupportValues( p1, p2 );
12808 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12811 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12814 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12817 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12820 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12823 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12826 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12829 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12833 catch ( final Exception e ) {
12834 e.printStackTrace( System.out );
12840 private static boolean testTaxonomyExtraction() {
12842 final PhylogenyNode n0 = PhylogenyNode
12843 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12844 if ( n0.getNodeData().isHasTaxonomy() ) {
12847 final PhylogenyNode n1 = PhylogenyNode
12848 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12849 if ( n1.getNodeData().isHasTaxonomy() ) {
12850 System.out.println( n1.toString() );
12853 final PhylogenyNode n2x = PhylogenyNode
12854 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12855 if ( n2x.getNodeData().isHasTaxonomy() ) {
12858 final PhylogenyNode n3 = PhylogenyNode
12859 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12860 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12861 System.out.println( n3.toString() );
12864 final PhylogenyNode n4 = PhylogenyNode
12865 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12866 if ( n4.getNodeData().isHasTaxonomy() ) {
12867 System.out.println( n4.toString() );
12870 final PhylogenyNode n5 = PhylogenyNode
12871 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12872 if ( n5.getNodeData().isHasTaxonomy() ) {
12873 System.out.println( n5.toString() );
12876 final PhylogenyNode n6 = PhylogenyNode
12877 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12878 if ( n6.getNodeData().isHasTaxonomy() ) {
12879 System.out.println( n6.toString() );
12882 final PhylogenyNode n7 = PhylogenyNode
12883 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12884 if ( n7.getNodeData().isHasTaxonomy() ) {
12885 System.out.println( n7.toString() );
12888 final PhylogenyNode n8 = PhylogenyNode
12889 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12890 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12891 System.out.println( n8.toString() );
12894 final PhylogenyNode n9 = PhylogenyNode
12895 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12896 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12897 System.out.println( n9.toString() );
12900 final PhylogenyNode n10x = PhylogenyNode
12901 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12902 if ( n10x.getNodeData().isHasTaxonomy() ) {
12903 System.out.println( n10x.toString() );
12906 final PhylogenyNode n10xx = PhylogenyNode
12907 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12908 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12909 System.out.println( n10xx.toString() );
12912 final PhylogenyNode n10 = PhylogenyNode
12913 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12914 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12915 System.out.println( n10.toString() );
12918 final PhylogenyNode n11 = PhylogenyNode
12919 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12920 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12921 System.out.println( n11.toString() );
12924 final PhylogenyNode n12 = PhylogenyNode
12925 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12926 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12927 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12928 System.out.println( n12.toString() );
12931 final PhylogenyNode n13 = PhylogenyNode
12932 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12933 if ( n13.getNodeData().isHasTaxonomy() ) {
12934 System.out.println( n13.toString() );
12937 final PhylogenyNode n14 = PhylogenyNode
12938 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12939 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12940 System.out.println( n14.toString() );
12943 final PhylogenyNode n15 = PhylogenyNode
12944 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12945 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12946 System.out.println( n15.toString() );
12949 final PhylogenyNode n16 = PhylogenyNode
12950 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12951 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12952 System.out.println( n16.toString() );
12955 final PhylogenyNode n17 = PhylogenyNode
12956 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12957 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12958 System.out.println( n17.toString() );
12961 final PhylogenyNode n18 = PhylogenyNode
12962 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12963 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12964 System.out.println( n18.toString() );
12967 final PhylogenyNode n19 = PhylogenyNode
12968 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12969 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12970 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12971 System.out.println( n19.toString() );
12974 final PhylogenyNode n20 = PhylogenyNode
12975 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12976 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12977 System.out.println( n20.toString() );
12980 final PhylogenyNode n21 = PhylogenyNode
12981 .createInstanceFromNhxString( "Mus musculus musculus K392",
12982 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12983 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12984 System.out.println( n21.toString() );
12987 final PhylogenyNode n23 = PhylogenyNode
12988 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12989 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12990 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12991 System.out.println( n23.toString() );
12994 final PhylogenyNode n24 = PhylogenyNode
12995 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12996 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12997 System.out.println( n24.toString() );
13001 final PhylogenyNode n25 = PhylogenyNode
13002 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13003 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13004 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13005 System.out.println( n25.toString() );
13008 final PhylogenyNode n26 = PhylogenyNode
13009 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13010 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13011 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13012 System.out.println( n26.toString() );
13015 final PhylogenyNode n27 = PhylogenyNode
13016 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13017 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13018 System.out.println( n27.toString() );
13022 catch ( final Exception e ) {
13023 e.printStackTrace( System.out );
13029 private static boolean testTreeCopy() {
13031 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13032 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13033 final Phylogeny t1 = t0.copy();
13034 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13037 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13040 t0.deleteSubtree( t0.getNode( "c" ), true );
13041 t0.deleteSubtree( t0.getNode( "a" ), true );
13042 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13043 t0.getNode( "b" ).setName( "Bee" );
13044 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13047 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13050 t0.deleteSubtree( t0.getNode( "e" ), true );
13051 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13052 t0.deleteSubtree( t0.getNode( "d" ), true );
13053 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13057 catch ( final Exception e ) {
13058 e.printStackTrace();
13064 private static boolean testTreeMethods() {
13066 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13067 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13068 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13069 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13070 System.out.println( t0.toNewHampshireX() );
13073 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13074 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13075 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13078 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13081 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13085 catch ( final Exception e ) {
13086 e.printStackTrace( System.out );
13092 private static boolean testUniprotEntryRetrieval() {
13094 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13095 if ( !entry.getAccession().equals( "P12345" ) ) {
13098 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13101 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13104 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13107 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13110 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13113 if ( entry.getMolecularSequence() == null ) {
13117 .getMolecularSequence()
13118 .getMolecularSequenceAsString()
13119 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13120 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13121 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13122 System.out.println( "expected something else." );
13126 catch ( final IOException e ) {
13127 System.out.println();
13128 System.out.println( "the following might be due to absence internet connection:" );
13129 e.printStackTrace( System.out );
13132 catch ( final NullPointerException f ) {
13133 f.printStackTrace( System.out );
13136 catch ( final Exception e ) {
13142 private static boolean testUniprotTaxonomySearch() {
13144 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13146 if ( results.size() != 1 ) {
13149 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13152 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13155 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13158 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13161 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13165 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13166 if ( results.size() != 1 ) {
13169 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13172 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13175 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13178 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13181 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13185 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13186 if ( results.size() != 1 ) {
13189 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13192 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13195 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13198 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13201 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13205 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13206 if ( results.size() != 1 ) {
13209 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13212 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13215 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13218 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13221 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13224 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13227 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13230 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13231 .equals( "Nematostella vectensis" ) ) {
13232 System.out.println( results.get( 0 ).getLineage() );
13237 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13238 if ( results.size() != 1 ) {
13241 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13244 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13247 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13250 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13253 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13256 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13257 .equals( "Xenopus tropicalis" ) ) {
13258 System.out.println( results.get( 0 ).getLineage() );
13263 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13264 if ( results.size() != 1 ) {
13267 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13270 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13273 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13276 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13279 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13282 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13283 .equals( "Xenopus tropicalis" ) ) {
13284 System.out.println( results.get( 0 ).getLineage() );
13289 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13290 if ( results.size() != 1 ) {
13293 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13296 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13299 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13302 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13305 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13308 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13309 .equals( "Xenopus tropicalis" ) ) {
13310 System.out.println( results.get( 0 ).getLineage() );
13314 catch ( final IOException e ) {
13315 System.out.println();
13316 System.out.println( "the following might be due to absence internet connection:" );
13317 e.printStackTrace( System.out );
13320 catch ( final Exception e ) {