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( "Node construction and parsing of NHX (node level): " );
348 if ( Test.testNHXNodeParsing2() ) {
349 System.out.println( "OK." );
353 System.out.println( "failed." );
356 System.out.print( "NHX parsing iterating: " );
357 if ( Test.testNHParsingIter() ) {
358 System.out.println( "OK." );
362 System.out.println( "failed." );
365 System.out.print( "NH parsing: " );
366 if ( Test.testNHParsing() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "NH parsing - special chars: " );
375 if ( Test.testNHParsingSpecialChars() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "Conversion to NHX (node level): " );
384 if ( Test.testNHXconversion() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing: " );
393 if ( Test.testNHXParsing() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "NHX parsing with quotes: " );
402 if ( Test.testNHXParsingQuotes() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "NHX parsing (MrBayes): " );
411 if ( Test.testNHXParsingMB() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus characters parsing: " );
420 if ( Test.testNexusCharactersParsing() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing iterating: " );
429 if ( Test.testNexusTreeParsingIterating() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus tree parsing: " );
438 if ( Test.testNexusTreeParsing() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Nexus tree parsing (translating): " );
447 if ( Test.testNexusTreeParsingTranslating() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Nexus matrix parsing: " );
456 if ( Test.testNexusMatrixParsing() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Basic phyloXML parsing: " );
465 if ( Test.testBasicPhyloXMLparsing() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "Basic phyloXML parsing (validating against schema): " );
474 if ( testBasicPhyloXMLparsingValidating() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "phyloXML parsing (validating against schema): " );
483 if ( testPhyloXMLparsingValidating() ) {
484 System.out.println( "OK." );
488 System.out.println( "failed." );
491 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
492 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
493 System.out.println( "OK." );
497 System.out.println( "failed." );
500 System.out.print( "phyloXML Distribution Element: " );
501 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
502 System.out.println( "OK." );
506 System.out.println( "failed." );
509 System.out.print( "Tol XML parsing: " );
510 if ( Test.testBasicTolXMLparsing() ) {
511 System.out.println( "OK." );
515 System.out.println( "failed." );
518 System.out.print( "UTF-8 parsing from file: " );
519 if ( Test.testUTF8ParsingFromFile() ) {
520 System.out.println( "OK." );
524 System.out.println( "failed." );
527 System.out.print( "Copying of node data: " );
528 if ( Test.testCopyOfNodeData() ) {
529 System.out.println( "OK." );
533 System.out.println( "failed." );
536 System.out.print( "Tree copy: " );
537 if ( Test.testTreeCopy() ) {
538 System.out.println( "OK." );
542 System.out.println( "failed." );
545 System.out.print( "Basic tree methods: " );
546 if ( Test.testBasicTreeMethods() ) {
547 System.out.println( "OK." );
551 System.out.println( "failed." );
554 System.out.print( "Tree methods: " );
555 if ( Test.testTreeMethods() ) {
556 System.out.println( "OK." );
560 System.out.println( "failed." );
563 System.out.print( "Postorder Iterator: " );
564 if ( Test.testPostOrderIterator() ) {
565 System.out.println( "OK." );
569 System.out.println( "failed." );
572 System.out.print( "Preorder Iterator: " );
573 if ( Test.testPreOrderIterator() ) {
574 System.out.println( "OK." );
578 System.out.println( "failed." );
581 System.out.print( "Levelorder Iterator: " );
582 if ( Test.testLevelOrderIterator() ) {
583 System.out.println( "OK." );
587 System.out.println( "failed." );
590 System.out.print( "Re-id methods: " );
591 if ( Test.testReIdMethods() ) {
592 System.out.println( "OK." );
596 System.out.println( "failed." );
599 System.out.print( "Methods on last external nodes: " );
600 if ( Test.testLastExternalNodeMethods() ) {
601 System.out.println( "OK." );
605 System.out.println( "failed." );
608 System.out.print( "Methods on external nodes: " );
609 if ( Test.testExternalNodeRelatedMethods() ) {
610 System.out.println( "OK." );
614 System.out.println( "failed." );
617 System.out.print( "Deletion of external nodes: " );
618 if ( Test.testDeletionOfExternalNodes() ) {
619 System.out.println( "OK." );
623 System.out.println( "failed." );
626 System.out.print( "Subtree deletion: " );
627 if ( Test.testSubtreeDeletion() ) {
628 System.out.println( "OK." );
632 System.out.println( "failed." );
635 System.out.print( "Phylogeny branch: " );
636 if ( Test.testPhylogenyBranch() ) {
637 System.out.println( "OK." );
641 System.out.println( "failed." );
644 System.out.print( "Rerooting: " );
645 if ( Test.testRerooting() ) {
646 System.out.println( "OK." );
650 System.out.println( "failed." );
653 System.out.print( "Mipoint rooting: " );
654 if ( Test.testMidpointrooting() ) {
655 System.out.println( "OK." );
659 System.out.println( "failed." );
662 System.out.print( "Node removal: " );
663 if ( Test.testNodeRemoval() ) {
664 System.out.println( "OK." );
668 System.out.println( "failed." );
671 System.out.print( "Support count: " );
672 if ( Test.testSupportCount() ) {
673 System.out.println( "OK." );
677 System.out.println( "failed." );
680 System.out.print( "Support transfer: " );
681 if ( Test.testSupportTransfer() ) {
682 System.out.println( "OK." );
686 System.out.println( "failed." );
689 System.out.print( "Finding of LCA: " );
690 if ( Test.testGetLCA() ) {
691 System.out.println( "OK." );
695 System.out.println( "failed." );
698 System.out.print( "Finding of LCA 2: " );
699 if ( Test.testGetLCA2() ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "Calculation of distance between nodes: " );
708 if ( Test.testGetDistance() ) {
709 System.out.println( "OK." );
713 System.out.println( "failed." );
716 System.out.print( "Descriptive statistics: " );
717 if ( Test.testDescriptiveStatistics() ) {
718 System.out.println( "OK." );
722 System.out.println( "failed." );
725 System.out.print( "Data objects and methods: " );
726 if ( Test.testDataObjects() ) {
727 System.out.println( "OK." );
731 System.out.println( "failed." );
734 System.out.print( "Properties map: " );
735 if ( Test.testPropertiesMap() ) {
736 System.out.println( "OK." );
740 System.out.println( "failed." );
743 System.out.print( "SDIse: " );
744 if ( Test.testSDIse() ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "SDIunrooted: " );
753 if ( Test.testSDIunrooted() ) {
754 System.out.println( "OK." );
758 System.out.println( "failed." );
761 System.out.print( "GSDI: " );
762 if ( TestGSDI.test() ) {
763 System.out.println( "OK." );
767 System.out.println( "failed." );
770 System.out.print( "RIO: " );
771 if ( TestRIO.test() ) {
772 System.out.println( "OK." );
776 System.out.println( "failed." );
779 System.out.print( "Phylogeny reconstruction:" );
780 System.out.println();
781 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
782 System.out.println( "OK." );
786 System.out.println( "failed." );
789 System.out.print( "Analysis of domain architectures: " );
790 System.out.println();
791 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "GO: " );
800 System.out.println();
801 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
802 System.out.println( "OK." );
806 System.out.println( "failed." );
809 System.out.print( "Modeling tools: " );
810 if ( TestPccx.test() ) {
811 System.out.println( "OK." );
815 System.out.println( "failed." );
818 System.out.print( "Split Matrix strict: " );
819 if ( Test.testSplitStrict() ) {
820 System.out.println( "OK." );
824 System.out.println( "failed." );
827 System.out.print( "Split Matrix: " );
828 if ( Test.testSplit() ) {
829 System.out.println( "OK." );
833 System.out.println( "failed." );
836 System.out.print( "Confidence Assessor: " );
837 if ( Test.testConfidenceAssessor() ) {
838 System.out.println( "OK." );
842 System.out.println( "failed." );
845 System.out.print( "Basic table: " );
846 if ( Test.testBasicTable() ) {
847 System.out.println( "OK." );
851 System.out.println( "failed." );
854 System.out.print( "General table: " );
855 if ( Test.testGeneralTable() ) {
856 System.out.println( "OK." );
860 System.out.println( "failed." );
863 System.out.print( "Amino acid sequence: " );
864 if ( Test.testAminoAcidSequence() ) {
865 System.out.println( "OK." );
869 System.out.println( "failed." );
872 System.out.print( "General MSA parser: " );
873 if ( Test.testGeneralMsaParser() ) {
874 System.out.println( "OK." );
878 System.out.println( "failed." );
881 System.out.print( "Fasta parser for msa: " );
882 if ( Test.testFastaParser() ) {
883 System.out.println( "OK." );
887 System.out.println( "failed." );
890 System.out.print( "Creation of balanced phylogeny: " );
891 if ( Test.testCreateBalancedPhylogeny() ) {
892 System.out.println( "OK." );
896 System.out.println( "failed." );
899 System.out.print( "Genbank accessor parsing: " );
900 if ( Test.testGenbankAccessorParsing() ) {
901 System.out.println( "OK." );
905 System.out.println( "failed." );
909 final String os = ForesterUtil.OS_NAME.toLowerCase();
910 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
911 path = "/usr/local/bin/mafft";
913 else if ( os.indexOf( "win" ) >= 0 ) {
914 path = "C:\\Program Files\\mafft-win\\mafft.bat";
918 if ( !MsaInferrer.isInstalled( path ) ) {
919 path = "/usr/bin/mafft";
921 if ( !MsaInferrer.isInstalled( path ) ) {
922 path = "/usr/local/bin/mafft";
925 if ( MsaInferrer.isInstalled( path ) ) {
926 System.out.print( "MAFFT (external program): " );
927 if ( Test.testMafft( path ) ) {
928 System.out.println( "OK." );
932 System.out.println( "failed [will not count towards failed tests]" );
935 System.out.print( "Next nodes with collapsed: " );
936 if ( Test.testNextNodeWithCollapsing() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Simple MSA quality: " );
945 if ( Test.testMsaQualityMethod() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
953 System.out.print( "Deleteable MSA: " );
954 if ( Test.testDeleteableMsa() ) {
955 System.out.println( "OK." );
959 System.out.println( "failed." );
962 System.out.print( "MSA entropy: " );
963 if ( Test.testMsaEntropy() ) {
964 System.out.println( "OK." );
968 System.out.println( "failed." );
971 if ( PERFORM_DB_TESTS ) {
972 System.out.print( "Uniprot Entry Retrieval: " );
973 if ( Test.testUniprotEntryRetrieval() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
981 System.out.print( "Ebi Entry Retrieval: " );
982 if ( Test.testEbiEntryRetrieval() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
990 System.out.print( "Sequence DB tools 2: " );
991 if ( testSequenceDbWsTools2() ) {
992 System.out.println( "OK." );
996 System.out.println( "failed." );
1000 System.out.print( "Uniprot Taxonomy Search: " );
1001 if ( Test.testUniprotTaxonomySearch() ) {
1002 System.out.println( "OK." );
1006 System.out.println( "failed." );
1010 if ( PERFORM_WEB_TREE_ACCESS ) {
1011 System.out.print( "TreeBase acccess: " );
1012 if ( Test.testTreeBaseReading() ) {
1013 System.out.println( "OK." );
1017 System.out.println( "failed." );
1020 System.out.print( "ToL access: " );
1021 if ( Test.testToLReading() ) {
1022 System.out.println( "OK." );
1026 System.out.println( "failed." );
1029 System.out.print( "NHX parsing from URL: " );
1030 if ( Test.testNHXparsingFromURL() ) {
1031 System.out.println( "OK." );
1035 System.out.println( "failed." );
1038 System.out.print( "NHX parsing from URL 2: " );
1039 if ( Test.testNHXparsingFromURL2() ) {
1040 System.out.println( "OK." );
1044 System.out.println( "failed." );
1047 System.out.print( "phyloXML parsing from URL: " );
1048 if ( Test.testPhyloXMLparsingFromURL() ) {
1049 System.out.println( "OK." );
1053 System.out.println( "failed." );
1056 System.out.print( "TreeFam access: " );
1057 if ( Test.testTreeFamReading() ) {
1058 System.out.println( "OK." );
1062 System.out.println( "failed." );
1065 System.out.print( "Pfam tree access: " );
1066 if ( Test.testPfamTreeReading() ) {
1067 System.out.println( "OK." );
1071 System.out.println( "failed." );
1075 System.out.println();
1076 final Runtime rt = java.lang.Runtime.getRuntime();
1077 final long free_memory = rt.freeMemory() / 1000000;
1078 final long total_memory = rt.totalMemory() / 1000000;
1079 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1080 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1081 System.out.println();
1082 System.out.println( "Successful tests: " + succeeded );
1083 System.out.println( "Failed tests: " + failed );
1084 System.out.println();
1086 System.out.println( "OK." );
1089 System.out.println( "Not OK." );
1093 private static boolean testEngulfingOverlapRemoval() {
1095 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1096 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1097 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1098 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1099 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1100 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1101 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1102 final List<Boolean> covered = new ArrayList<Boolean>();
1103 covered.add( true ); // 0
1104 covered.add( false ); // 1
1105 covered.add( true ); // 2
1106 covered.add( false ); // 3
1107 covered.add( true ); // 4
1108 covered.add( true ); // 5
1109 covered.add( false ); // 6
1110 covered.add( true ); // 7
1111 covered.add( true ); // 8
1112 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1115 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1118 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1121 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1124 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1127 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1130 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1133 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1134 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1135 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1136 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1137 abc.addProteinDomain( a );
1138 abc.addProteinDomain( b );
1139 abc.addProteinDomain( c );
1140 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1141 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1142 if ( abc.getNumberOfProteinDomains() != 3 ) {
1145 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1148 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1151 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1154 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1157 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1158 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1159 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1160 final Protein def = new BasicProtein( "def", "nemve", 0 );
1161 def.addProteinDomain( d );
1162 def.addProteinDomain( e );
1163 def.addProteinDomain( f );
1164 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1165 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1166 if ( def.getNumberOfProteinDomains() != 3 ) {
1169 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1172 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1175 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1178 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1181 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1185 catch ( final Exception e ) {
1186 e.printStackTrace( System.out );
1192 private static final boolean testNHXparsingFromURL2() {
1194 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1195 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1199 TAXONOMY_EXTRACTION.NO,
1201 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1204 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1205 System.out.println( phys[ 0 ].toNewHampshire() );
1208 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1209 System.out.println( phys[ 1 ].toNewHampshire() );
1212 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1216 TAXONOMY_EXTRACTION.NO,
1218 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1221 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1222 System.out.println( phys2[ 0 ].toNewHampshire() );
1225 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1226 System.out.println( phys2[ 1 ].toNewHampshire() );
1229 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1230 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1231 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1236 .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))))));" ) ) {
1237 System.out.println( phys3[ 0 ].toNewHampshire() );
1240 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1241 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1242 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1247 .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))))));" ) ) {
1248 System.out.println( phys4[ 0 ].toNewHampshire() );
1252 catch ( final Exception e ) {
1253 e.printStackTrace();
1259 private static final boolean testNHXparsingFromURL() {
1261 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1262 final URL u = new URL( s );
1263 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1264 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1265 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1268 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1269 System.out.println( phys[ 0 ].toNewHampshire() );
1272 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1273 System.out.println( phys[ 1 ].toNewHampshire() );
1276 final URL u2 = new URL( s );
1277 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1278 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1281 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1282 System.out.println( phys2[ 0 ].toNewHampshire() );
1285 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1286 final NHXParser p = new NHXParser();
1287 final URL u3 = new URL( s );
1289 if ( !p.hasNext() ) {
1292 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1295 if ( !p.hasNext() ) {
1299 if ( !p.hasNext() ) {
1302 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1305 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1309 if ( !p.hasNext() ) {
1312 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1315 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1319 catch ( final Exception e ) {
1320 System.out.println( e.toString() );
1321 e.printStackTrace();
1327 private static boolean testOverlapRemoval() {
1329 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1330 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1331 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1332 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1333 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1334 final List<Boolean> covered = new ArrayList<Boolean>();
1335 covered.add( true ); // 0
1336 covered.add( false ); // 1
1337 covered.add( true ); // 2
1338 covered.add( false ); // 3
1339 covered.add( true ); // 4
1340 covered.add( true ); // 5
1341 covered.add( false ); // 6
1342 covered.add( true ); // 7
1343 covered.add( true ); // 8
1344 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1347 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1350 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1353 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1356 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1359 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1360 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1361 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1362 ab.addProteinDomain( a );
1363 ab.addProteinDomain( b );
1364 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1365 if ( ab.getNumberOfProteinDomains() != 2 ) {
1368 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1371 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1374 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1375 if ( ab.getNumberOfProteinDomains() != 2 ) {
1378 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1381 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1382 final Domain d = new BasicDomain( "d",
1389 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1390 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1391 cde.addProteinDomain( c );
1392 cde.addProteinDomain( d );
1393 cde.addProteinDomain( e );
1394 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1395 if ( cde.getNumberOfProteinDomains() != 3 ) {
1398 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1401 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1402 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1403 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1404 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1405 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1406 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1407 fghi.addProteinDomain( f );
1408 fghi.addProteinDomain( g );
1409 fghi.addProteinDomain( h );
1410 fghi.addProteinDomain( i );
1411 fghi.addProteinDomain( i );
1412 fghi.addProteinDomain( i );
1413 fghi.addProteinDomain( i2 );
1414 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1415 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1418 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1421 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1424 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1425 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1428 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1431 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1432 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1433 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1434 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1435 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1436 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1437 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1438 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1439 jklm.addProteinDomain( j );
1440 jklm.addProteinDomain( k );
1441 jklm.addProteinDomain( l );
1442 jklm.addProteinDomain( m );
1443 jklm.addProteinDomain( m0 );
1444 jklm.addProteinDomain( m1 );
1445 jklm.addProteinDomain( m2 );
1446 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1447 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1450 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1453 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1456 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1457 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1460 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1463 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1464 final Protein od = new BasicProtein( "od", "varanus", 0 );
1465 od.addProteinDomain( only );
1466 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1467 if ( od.getNumberOfProteinDomains() != 1 ) {
1470 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1474 catch ( final Exception e ) {
1475 e.printStackTrace( System.out );
1481 private static final boolean testPfamTreeReading() {
1483 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1484 final NHXParser parser = new NHXParser();
1485 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1486 parser.setReplaceUnderscores( false );
1487 parser.setGuessRootedness( true );
1488 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1489 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1492 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1496 catch ( final Exception e ) {
1497 e.printStackTrace();
1503 private static final boolean testPhyloXMLparsingFromURL() {
1505 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1506 final URL u = new URL( s );
1507 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1509 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1512 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1514 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1518 catch ( final Exception e ) {
1519 e.printStackTrace();
1525 private static final boolean testToLReading() {
1527 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1528 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1529 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1532 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1535 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1538 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1542 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1543 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1544 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1547 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1550 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1554 catch ( final Exception e ) {
1555 e.printStackTrace();
1561 private static final boolean testTreeBaseReading() {
1563 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1564 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1565 parser.setReplaceUnderscores( true );
1566 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1567 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1570 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1571 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1572 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1573 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1576 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1577 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1578 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1579 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1582 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1583 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1584 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1585 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1588 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1589 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1590 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1591 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1594 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1595 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1596 parser2.setReplaceUnderscores( true );
1597 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1598 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1601 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1602 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1603 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1604 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1607 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ),
1608 new NexusPhylogeniesParser() );
1609 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1612 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) ,
1613 new NexusPhylogeniesParser() );
1614 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1617 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) ,
1618 new NexusPhylogeniesParser() );
1619 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1622 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) ,
1623 new NexusPhylogeniesParser() );
1624 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1627 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) ,
1628 new NexusPhylogeniesParser() );
1629 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1632 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) ,
1633 new NexusPhylogeniesParser() );
1634 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1637 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) ,
1638 new NexusPhylogeniesParser() );
1639 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1642 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) ,
1643 new NexusPhylogeniesParser() );
1644 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1647 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) ,
1648 new NexusPhylogeniesParser() );
1649 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1652 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) ,
1653 new NexusPhylogeniesParser() );
1654 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1658 catch ( final Exception e ) {
1659 e.printStackTrace();
1665 private static final boolean testTreeFamReading() {
1667 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1668 final NHXParser parser = new NHXParser();
1669 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1670 parser.setReplaceUnderscores( false );
1671 parser.setGuessRootedness( true );
1672 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1673 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1676 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1680 catch ( final Exception e ) {
1681 e.printStackTrace();
1687 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1688 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1692 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1693 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1696 private static boolean testAminoAcidSequence() {
1698 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1699 if ( aa1.getLength() != 13 ) {
1702 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1705 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1708 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1711 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1712 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1715 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1716 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1719 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1720 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1724 catch ( final Exception e ) {
1725 e.printStackTrace();
1731 private static boolean testBasicDomain() {
1733 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1734 if ( !pd.getDomainId().equals( "id" ) ) {
1737 if ( pd.getNumber() != 1 ) {
1740 if ( pd.getTotalCount() != 4 ) {
1743 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1746 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1747 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1748 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1749 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1750 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1751 if ( !a1.equals( a1 ) ) {
1754 if ( !a1.equals( a1_copy ) ) {
1757 if ( !a1.equals( a1_equal ) ) {
1760 if ( !a1.equals( a2 ) ) {
1763 if ( a1.equals( a3 ) ) {
1766 if ( a1.compareTo( a1 ) != 0 ) {
1769 if ( a1.compareTo( a1_copy ) != 0 ) {
1772 if ( a1.compareTo( a1_equal ) != 0 ) {
1775 if ( a1.compareTo( a2 ) != 0 ) {
1778 if ( a1.compareTo( a3 ) == 0 ) {
1782 catch ( final Exception e ) {
1783 e.printStackTrace( System.out );
1789 private static boolean testBasicNodeMethods() {
1791 if ( PhylogenyNode.getNodeCount() != 0 ) {
1794 final PhylogenyNode n1 = new PhylogenyNode();
1795 final PhylogenyNode n2 = PhylogenyNode
1796 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1797 final PhylogenyNode n3 = PhylogenyNode
1798 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1799 final PhylogenyNode n4 = PhylogenyNode
1800 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1801 if ( n1.isHasAssignedEvent() ) {
1804 if ( PhylogenyNode.getNodeCount() != 4 ) {
1807 if ( n3.getIndicator() != 0 ) {
1810 if ( n3.getNumberOfExternalNodes() != 1 ) {
1813 if ( !n3.isExternal() ) {
1816 if ( !n3.isRoot() ) {
1819 if ( !n4.getName().equals( "n4" ) ) {
1823 catch ( final Exception e ) {
1824 e.printStackTrace( System.out );
1830 private static boolean testUTF8ParsingFromFile() {
1832 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1833 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ),
1835 if ( xml_parser.getErrorCount() > 0 ) {
1836 System.out.println( xml_parser.getErrorMessages().toString() );
1839 if ( phylogenies_xml.length != 1 ) {
1843 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance().create( new StringBuffer( phylogenies_xml[0].toPhyloXML( 0 )),
1846 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
1847 if ( phylogenies_nh.length != 1 ) {
1851 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
1852 if ( phylogenies_nex.length != 1 ) {
1856 final String[] xml_n = phylogenies_xml[0].getAllExternalNodeNames();
1857 final String[] xml_n2 = phylogenies_xml2[0].getAllExternalNodeNames();
1858 final String[] nh_n = phylogenies_nh[0].getAllExternalNodeNames();
1859 final String[] nex_n = phylogenies_nex[0].getAllExternalNodeNames();
1860 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
1861 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
1862 final String n2 = "漢字ひらがなカタカナ";
1863 final String n3 = "อักษรไทย";
1864 final String n4 = "繁體字";
1865 final String n5 = "한글";
1866 final String n6 = "देवनागरी";
1868 final String n7 = "chữ Quốc ngữ";
1869 final String n8 = "ру́сский язы́к";
1870 final String n9 = "អក្សរខ្មែរ";
1872 if ( !xml_n[0].equals( n0 ) ) {
1873 System.out.println( xml_n[0] );
1874 System.out.println( n0 );
1877 if ( !xml_n2[0].equals( n0 ) ) {
1878 System.out.println( xml_n2[0] );
1879 System.out.println( n0 );
1882 if ( !nh_n[0].equals( n0 ) ) {
1883 System.out.println( nh_n[0] );
1884 System.out.println( n0 );
1887 if ( !nex_n[0].equals( n0 ) ) {
1888 System.out.println( nex_n[0] );
1889 System.out.println( n0 );
1893 if ( !xml_n[1].equals( n1 ) ) {
1894 System.out.println( xml_n[1] );
1895 System.out.println( n1 );
1898 if ( !xml_n2[1].equals( n1 ) ) {
1899 System.out.println( xml_n2[1] );
1900 System.out.println( n1 );
1903 if ( !nh_n[1].equals( n1 ) ) {
1904 System.out.println( nh_n[1] );
1905 System.out.println( n1 );
1908 if ( !nex_n[1].equals( n1 ) ) {
1909 System.out.println( nex_n[1] );
1910 System.out.println( n1 );
1914 if ( !xml_n[2].equals( n2 ) ) {
1915 System.out.println( xml_n[2] );
1916 System.out.println( n2 );
1919 if ( !xml_n2[2].equals( n2 ) ) {
1920 System.out.println( xml_n2[2] );
1921 System.out.println( n2 );
1924 if ( !nh_n[2].equals( n2 ) ) {
1925 System.out.println( nh_n[2] );
1926 System.out.println( n2 );
1929 if ( !nex_n[2].equals( n2 ) ) {
1930 System.out.println( nex_n[2] );
1931 System.out.println( n2 );
1935 if ( !xml_n[3].equals( n3 ) ) {
1936 System.out.println( xml_n[3] );
1937 System.out.println( n3 );
1940 if ( !xml_n2[3].equals( n3 ) ) {
1941 System.out.println( xml_n2[3] );
1942 System.out.println( n3 );
1945 if ( !nh_n[3].equals( n3 ) ) {
1946 System.out.println( nh_n[3] );
1947 System.out.println( n3 );
1950 if ( !nex_n[3].equals( n3 ) ) {
1951 System.out.println( nex_n[3] );
1952 System.out.println( n3 );
1956 if ( !xml_n[4].equals( n4 ) ) {
1957 System.out.println( xml_n[4] );
1958 System.out.println( n4 );
1961 if ( !nh_n[4].equals( n4 ) ) {
1962 System.out.println( nh_n[4] );
1963 System.out.println( n4 );
1966 if ( !nex_n[4].equals( n4 ) ) {
1967 System.out.println( nex_n[4] );
1968 System.out.println( n4 );
1972 if ( !xml_n[5].equals( n5 ) ) {
1973 System.out.println( xml_n[5] );
1974 System.out.println( n5 );
1977 if ( !nh_n[5].equals( n5 ) ) {
1978 System.out.println( nh_n[5] );
1979 System.out.println( n5 );
1982 if ( !nex_n[5].equals( n5 ) ) {
1983 System.out.println( nex_n[5] );
1984 System.out.println( n5 );
1988 if ( !xml_n[6].equals( n6 ) ) {
1989 System.out.println( xml_n[6] );
1990 System.out.println( n6 );
1993 if ( !nh_n[6].equals( n6 ) ) {
1994 System.out.println( nh_n[6] );
1995 System.out.println( n6 );
1998 if ( !nex_n[6].equals( n6 ) ) {
1999 System.out.println( nex_n[6] );
2000 System.out.println( n6 );
2004 if ( !xml_n[7].equals( n7 ) ) {
2005 System.out.println( xml_n[7] );
2006 System.out.println( n7 );
2009 if ( !nh_n[7].equals( n7 ) ) {
2010 System.out.println( nh_n[7] );
2011 System.out.println( n7 );
2014 if ( !nex_n[7].equals( n7 ) ) {
2015 System.out.println( nex_n[7] );
2016 System.out.println( n7 );
2019 if ( !xml_n[8].equals( n8 ) ) {
2020 System.out.println( xml_n[8] );
2021 System.out.println( n8 );
2024 if ( !nh_n[8].equals( n8 ) ) {
2025 System.out.println( nh_n[8] );
2026 System.out.println( n8 );
2029 if ( !nex_n[8].equals( n8 ) ) {
2030 System.out.println( nex_n[8] );
2031 System.out.println( n8 );
2034 if ( !xml_n[9].equals( n9 ) ) {
2035 System.out.println( xml_n[9] );
2036 System.out.println( n9 );
2039 if ( !xml_n2[9].equals( n9 ) ) {
2040 System.out.println( xml_n2[9] );
2041 System.out.println( n9 );
2044 if ( !nh_n[9].equals( n9 ) ) {
2045 System.out.println( nh_n[9] );
2046 System.out.println( n9 );
2049 if ( !nex_n[9].equals( n9 ) ) {
2050 System.out.println( nex_n[9] );
2051 System.out.println( n9 );
2054 if (!phylogenies_xml[0].toNewHampshire().equals(
2055 phylogenies_nh[0].toNewHampshire() ) ) {
2056 System.out.println( phylogenies_xml[0].toNewHampshire() );
2057 System.out.println( phylogenies_nh[0].toNewHampshire() );
2060 if (!phylogenies_xml[0].toNewHampshire().equals(
2061 phylogenies_nex[0].toNewHampshire() ) ) {
2062 System.out.println( phylogenies_xml[0].toNewHampshire() );
2063 System.out.println( phylogenies_nex[0].toNewHampshire() );
2067 catch ( final Exception e ) {
2068 e.printStackTrace( System.out );
2076 private static boolean testBasicPhyloXMLparsing() {
2078 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2079 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2080 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2082 if ( xml_parser.getErrorCount() > 0 ) {
2083 System.out.println( xml_parser.getErrorMessages().toString() );
2086 if ( phylogenies_0.length != 4 ) {
2089 final Phylogeny t1 = phylogenies_0[ 0 ];
2090 final Phylogeny t2 = phylogenies_0[ 1 ];
2091 final Phylogeny t3 = phylogenies_0[ 2 ];
2092 final Phylogeny t4 = phylogenies_0[ 3 ];
2093 if ( t1.getNumberOfExternalNodes() != 1 ) {
2096 if ( !t1.isRooted() ) {
2099 if ( t1.isRerootable() ) {
2102 if ( !t1.getType().equals( "gene_tree" ) ) {
2105 if ( t2.getNumberOfExternalNodes() != 2 ) {
2108 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2111 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2114 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2117 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2120 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2123 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2126 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2127 .startsWith( "actgtgggggt" ) ) {
2130 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2131 .startsWith( "ctgtgatgcat" ) ) {
2134 if ( t3.getNumberOfExternalNodes() != 4 ) {
2137 if ( !t1.getName().equals( "t1" ) ) {
2140 if ( !t2.getName().equals( "t2" ) ) {
2143 if ( !t3.getName().equals( "t3" ) ) {
2146 if ( !t4.getName().equals( "t4" ) ) {
2149 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2152 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2155 if ( !t3.getNode( "root node" ).isDuplication() ) {
2158 if ( !t3.getNode( "node a" ).isDuplication() ) {
2161 if ( t3.getNode( "node a" ).isSpeciation() ) {
2164 if ( t3.getNode( "node bc" ).isDuplication() ) {
2167 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2170 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2173 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2174 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2177 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2180 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2183 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
2186 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2187 .equals( "apoptosis" ) ) {
2190 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2191 .equals( "GO:0006915" ) ) {
2194 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2195 .equals( "UniProtKB" ) ) {
2198 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2199 .equals( "experimental" ) ) {
2202 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2203 .equals( "function" ) ) {
2206 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2207 .getValue() != 1 ) {
2210 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2211 .getType().equals( "ml" ) ) {
2214 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2215 .equals( "apoptosis" ) ) {
2218 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2219 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2222 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2223 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2226 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2227 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2230 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2231 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2234 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2235 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2238 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2239 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2242 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2243 .equals( "GO:0005829" ) ) {
2246 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2247 .equals( "intracellular organelle" ) ) {
2250 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2253 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2254 .equals( "UniProt link" ) ) ) {
2257 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2260 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2261 if ( x.size() != 4 ) {
2265 for( final Accession acc : x ) {
2267 if ( !acc.getSource().equals( "KEGG" ) ) {
2270 if ( !acc.getValue().equals( "hsa:596" ) ) {
2277 catch ( final Exception e ) {
2278 e.printStackTrace( System.out );
2284 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2286 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2287 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2288 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2289 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2292 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2294 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2296 if ( xml_parser.getErrorCount() > 0 ) {
2297 System.out.println( xml_parser.getErrorMessages().toString() );
2300 if ( phylogenies_0.length != 4 ) {
2303 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2304 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2305 if ( phylogenies_t1.length != 1 ) {
2308 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2309 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2312 if ( !t1_rt.isRooted() ) {
2315 if ( t1_rt.isRerootable() ) {
2318 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2321 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2322 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2323 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2324 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2327 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2330 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2333 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2336 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2337 .startsWith( "actgtgggggt" ) ) {
2340 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2341 .startsWith( "ctgtgatgcat" ) ) {
2344 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2345 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2346 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2347 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2348 if ( phylogenies_1.length != 1 ) {
2351 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2352 if ( !t3_rt.getName().equals( "t3" ) ) {
2355 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2358 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2361 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2364 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2367 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2368 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2371 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2374 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2377 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2378 .equals( "UniProtKB" ) ) {
2381 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2382 .equals( "apoptosis" ) ) {
2385 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2386 .equals( "GO:0006915" ) ) {
2389 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2390 .equals( "UniProtKB" ) ) {
2393 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2394 .equals( "experimental" ) ) {
2397 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2398 .equals( "function" ) ) {
2401 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2402 .getValue() != 1 ) {
2405 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2406 .getType().equals( "ml" ) ) {
2409 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2410 .equals( "apoptosis" ) ) {
2413 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2414 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2417 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2418 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2421 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2422 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2425 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2426 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2429 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2430 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2433 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2434 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2437 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2438 .equals( "GO:0005829" ) ) {
2441 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2442 .equals( "intracellular organelle" ) ) {
2445 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2448 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2449 .equals( "UniProt link" ) ) ) {
2452 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2455 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2458 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2459 .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." ) ) ) {
2460 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2463 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2466 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2469 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2472 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2475 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2476 .equals( "ncbi" ) ) {
2479 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2482 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2483 .getName().equals( "B" ) ) {
2486 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2487 .getFrom() != 21 ) {
2490 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2493 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2494 .getLength() != 24 ) {
2497 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2498 .getConfidence() != 0 ) {
2501 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2502 .equals( "pfam" ) ) {
2505 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2508 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2511 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2514 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2517 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2518 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2521 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2524 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2527 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2530 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2533 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2536 if ( taxbb.getSynonyms().size() != 2 ) {
2539 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2542 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2545 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2548 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2551 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2554 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2555 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2558 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2561 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2564 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2567 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2570 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2573 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2576 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2579 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2582 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2583 .equalsIgnoreCase( "435" ) ) {
2586 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2589 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2590 .equalsIgnoreCase( "443.7" ) ) {
2593 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2596 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2599 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2600 .equalsIgnoreCase( "433" ) ) {
2603 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2604 .getCrossReferences();
2605 if ( x.size() != 4 ) {
2609 for( final Accession acc : x ) {
2611 if ( !acc.getSource().equals( "KEGG" ) ) {
2614 if ( !acc.getValue().equals( "hsa:596" ) ) {
2621 catch ( final Exception e ) {
2622 e.printStackTrace( System.out );
2628 private static boolean testBasicPhyloXMLparsingValidating() {
2630 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2631 PhyloXmlParser xml_parser = null;
2633 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2635 catch ( final Exception e ) {
2636 // Do nothing -- means were not running from jar.
2638 if ( xml_parser == null ) {
2639 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2640 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2641 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2644 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2647 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2649 if ( xml_parser.getErrorCount() > 0 ) {
2650 System.out.println( xml_parser.getErrorMessages().toString() );
2653 if ( phylogenies_0.length != 4 ) {
2656 final Phylogeny t1 = phylogenies_0[ 0 ];
2657 final Phylogeny t2 = phylogenies_0[ 1 ];
2658 final Phylogeny t3 = phylogenies_0[ 2 ];
2659 final Phylogeny t4 = phylogenies_0[ 3 ];
2660 if ( !t1.getName().equals( "t1" ) ) {
2663 if ( !t2.getName().equals( "t2" ) ) {
2666 if ( !t3.getName().equals( "t3" ) ) {
2669 if ( !t4.getName().equals( "t4" ) ) {
2672 if ( t1.getNumberOfExternalNodes() != 1 ) {
2675 if ( t2.getNumberOfExternalNodes() != 2 ) {
2678 if ( t3.getNumberOfExternalNodes() != 4 ) {
2681 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2682 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2683 if ( xml_parser.getErrorCount() > 0 ) {
2684 System.out.println( "errors:" );
2685 System.out.println( xml_parser.getErrorMessages().toString() );
2688 if ( phylogenies_1.length != 4 ) {
2691 final Phylogeny[] phylogenies_2 = factory.create( new File(Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ),
2693 if ( xml_parser.getErrorCount() > 0 ) {
2694 System.out.println( "errors:" );
2695 System.out.println( xml_parser.getErrorMessages().toString() );
2698 if ( phylogenies_2.length != 1 ) {
2701 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2704 final Phylogeny[] phylogenies_3 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ),
2706 if ( xml_parser.getErrorCount() > 0 ) {
2707 System.out.println( xml_parser.getErrorMessages().toString() );
2710 if ( phylogenies_3.length != 2 ) {
2713 final Phylogeny a = phylogenies_3[ 0 ];
2714 if ( !a.getName().equals( "tree 4" ) ) {
2717 if ( a.getNumberOfExternalNodes() != 3 ) {
2720 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2723 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2726 final Phylogeny[] phylogenies_4 = factory.create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml") ,
2728 if ( xml_parser.getErrorCount() > 0 ) {
2729 System.out.println( xml_parser.getErrorMessages().toString() );
2732 if ( phylogenies_4.length != 1 ) {
2735 final Phylogeny s = phylogenies_4[ 0 ];
2736 if ( s.getNumberOfExternalNodes() != 6 ) {
2739 s.getNode( "first" );
2741 s.getNode( "\"<a'b&c'd\">\"" );
2742 s.getNode( "'''\"" );
2743 s.getNode( "\"\"\"" );
2744 s.getNode( "dick & doof" );
2746 catch ( final Exception e ) {
2747 e.printStackTrace( System.out );
2753 private static boolean testPhyloXMLparsingValidating() {
2755 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2756 PhyloXmlParser xml_parser = null;
2758 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2760 catch ( final Exception e ) {
2761 // Do nothing -- means were not running from jar.
2763 if ( xml_parser == null ) {
2764 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2765 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2766 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2769 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2772 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ),
2774 if ( xml_parser.getErrorCount() > 0 ) {
2775 System.out.println( xml_parser.getErrorMessages().toString() );
2778 if ( phylogenies_0.length != 3 ) {
2782 catch ( final Exception e ) {
2783 e.printStackTrace( System.out );
2789 private static boolean testBasicProtein() {
2791 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2792 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2793 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2794 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2795 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2796 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2797 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2798 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2799 p0.addProteinDomain( y );
2800 p0.addProteinDomain( e );
2801 p0.addProteinDomain( b );
2802 p0.addProteinDomain( c );
2803 p0.addProteinDomain( d );
2804 p0.addProteinDomain( a );
2805 p0.addProteinDomain( x );
2806 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2809 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2813 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2814 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2815 aa0.addProteinDomain( a1 );
2816 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2819 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2823 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2824 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2825 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2826 aa1.addProteinDomain( a11 );
2827 aa1.addProteinDomain( a12 );
2828 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2831 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2834 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2835 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2838 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2841 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2844 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2845 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2848 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2851 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2854 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2857 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2858 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2861 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2864 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2867 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2870 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2871 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2874 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2877 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2880 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2884 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2885 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2886 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2887 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2888 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2889 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2890 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2891 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2892 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2893 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2894 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2895 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2896 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2897 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2898 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2899 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2900 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2901 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2902 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2903 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2904 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2905 p00.addProteinDomain( y0 );
2906 p00.addProteinDomain( e0 );
2907 p00.addProteinDomain( b0 );
2908 p00.addProteinDomain( c0 );
2909 p00.addProteinDomain( d0 );
2910 p00.addProteinDomain( a0 );
2911 p00.addProteinDomain( x0 );
2912 p00.addProteinDomain( y1 );
2913 p00.addProteinDomain( y2 );
2914 p00.addProteinDomain( y3 );
2915 p00.addProteinDomain( e1 );
2916 p00.addProteinDomain( e2 );
2917 p00.addProteinDomain( e3 );
2918 p00.addProteinDomain( e4 );
2919 p00.addProteinDomain( e5 );
2920 p00.addProteinDomain( z0 );
2921 p00.addProteinDomain( z1 );
2922 p00.addProteinDomain( z2 );
2923 p00.addProteinDomain( zz0 );
2924 p00.addProteinDomain( zz1 );
2925 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2928 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2931 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2934 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2937 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" ) ) {
2940 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2941 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2942 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2943 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2944 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2945 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2946 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2947 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2948 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2949 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2950 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2951 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2952 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2953 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2954 p.addProteinDomain( B15 );
2955 p.addProteinDomain( C50 );
2956 p.addProteinDomain( A60 );
2957 p.addProteinDomain( A30 );
2958 p.addProteinDomain( C70 );
2959 p.addProteinDomain( B35 );
2960 p.addProteinDomain( B40 );
2961 p.addProteinDomain( A0 );
2962 p.addProteinDomain( A10 );
2963 p.addProteinDomain( A20 );
2964 p.addProteinDomain( B25 );
2965 p.addProteinDomain( D80 );
2966 List<String> domains_ids = new ArrayList<String>();
2967 domains_ids.add( "A" );
2968 domains_ids.add( "B" );
2969 domains_ids.add( "C" );
2970 if ( !p.contains( domains_ids, false ) ) {
2973 if ( !p.contains( domains_ids, true ) ) {
2976 domains_ids.add( "X" );
2977 if ( p.contains( domains_ids, false ) ) {
2980 if ( p.contains( domains_ids, true ) ) {
2983 domains_ids = new ArrayList<String>();
2984 domains_ids.add( "A" );
2985 domains_ids.add( "C" );
2986 domains_ids.add( "D" );
2987 if ( !p.contains( domains_ids, false ) ) {
2990 if ( !p.contains( domains_ids, true ) ) {
2993 domains_ids = new ArrayList<String>();
2994 domains_ids.add( "A" );
2995 domains_ids.add( "D" );
2996 domains_ids.add( "C" );
2997 if ( !p.contains( domains_ids, false ) ) {
3000 if ( p.contains( domains_ids, true ) ) {
3003 domains_ids = new ArrayList<String>();
3004 domains_ids.add( "A" );
3005 domains_ids.add( "A" );
3006 domains_ids.add( "B" );
3007 if ( !p.contains( domains_ids, false ) ) {
3010 if ( !p.contains( domains_ids, true ) ) {
3013 domains_ids = new ArrayList<String>();
3014 domains_ids.add( "A" );
3015 domains_ids.add( "A" );
3016 domains_ids.add( "A" );
3017 domains_ids.add( "B" );
3018 domains_ids.add( "B" );
3019 if ( !p.contains( domains_ids, false ) ) {
3022 if ( !p.contains( domains_ids, true ) ) {
3025 domains_ids = new ArrayList<String>();
3026 domains_ids.add( "A" );
3027 domains_ids.add( "A" );
3028 domains_ids.add( "B" );
3029 domains_ids.add( "A" );
3030 domains_ids.add( "B" );
3031 domains_ids.add( "B" );
3032 domains_ids.add( "A" );
3033 domains_ids.add( "B" );
3034 domains_ids.add( "C" );
3035 domains_ids.add( "A" );
3036 domains_ids.add( "C" );
3037 domains_ids.add( "D" );
3038 if ( !p.contains( domains_ids, false ) ) {
3041 if ( p.contains( domains_ids, true ) ) {
3045 catch ( final Exception e ) {
3046 e.printStackTrace( System.out );
3052 private static boolean testBasicTable() {
3054 final BasicTable<String> t0 = new BasicTable<String>();
3055 if ( t0.getNumberOfColumns() != 0 ) {
3058 if ( t0.getNumberOfRows() != 0 ) {
3061 t0.setValue( 3, 2, "23" );
3062 t0.setValue( 10, 1, "error" );
3063 t0.setValue( 10, 1, "110" );
3064 t0.setValue( 9, 1, "19" );
3065 t0.setValue( 1, 10, "101" );
3066 t0.setValue( 10, 10, "1010" );
3067 t0.setValue( 100, 10, "10100" );
3068 t0.setValue( 0, 0, "00" );
3069 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3072 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3075 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3078 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3081 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3084 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3087 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3090 if ( t0.getNumberOfColumns() != 101 ) {
3093 if ( t0.getNumberOfRows() != 11 ) {
3096 if ( t0.getValueAsString( 49, 4 ) != null ) {
3099 final String l = ForesterUtil.getLineSeparator();
3100 final StringBuffer source = new StringBuffer();
3101 source.append( "" + l );
3102 source.append( "# 1 1 1 1 1 1 1 1" + l );
3103 source.append( " 00 01 02 03" + l );
3104 source.append( " 10 11 12 13 " + l );
3105 source.append( "20 21 22 23 " + l );
3106 source.append( " 30 31 32 33" + l );
3107 source.append( "40 41 42 43" + l );
3108 source.append( " # 1 1 1 1 1 " + l );
3109 source.append( "50 51 52 53 54" + l );
3110 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3111 if ( t1.getNumberOfColumns() != 5 ) {
3114 if ( t1.getNumberOfRows() != 6 ) {
3117 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3120 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3123 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3126 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3129 final StringBuffer source1 = new StringBuffer();
3130 source1.append( "" + l );
3131 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3132 source1.append( " 00; 01 ;02;03" + l );
3133 source1.append( " 10; 11; 12; 13 " + l );
3134 source1.append( "20; 21; 22; 23 " + l );
3135 source1.append( " 30; 31; 32; 33" + l );
3136 source1.append( "40;41;42;43" + l );
3137 source1.append( " # 1 1 1 1 1 " + l );
3138 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3139 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3140 if ( t2.getNumberOfColumns() != 5 ) {
3143 if ( t2.getNumberOfRows() != 6 ) {
3146 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3149 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3152 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3155 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3158 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3161 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3164 final StringBuffer source2 = new StringBuffer();
3165 source2.append( "" + l );
3166 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3167 source2.append( " 00; 01 ;02;03" + l );
3168 source2.append( " 10; 11; 12; 13 " + l );
3169 source2.append( "20; 21; 22; 23 " + l );
3170 source2.append( " " + l );
3171 source2.append( " 30; 31; 32; 33" + l );
3172 source2.append( "40;41;42;43" + l );
3173 source2.append( " comment: 1 1 1 1 1 " + l );
3174 source2.append( ";;;50 ; 52; 53;;54 " + l );
3175 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3181 if ( tl.size() != 2 ) {
3184 final BasicTable<String> t3 = tl.get( 0 );
3185 final BasicTable<String> t4 = tl.get( 1 );
3186 if ( t3.getNumberOfColumns() != 4 ) {
3189 if ( t3.getNumberOfRows() != 3 ) {
3192 if ( t4.getNumberOfColumns() != 4 ) {
3195 if ( t4.getNumberOfRows() != 3 ) {
3198 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3201 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3205 catch ( final Exception e ) {
3206 e.printStackTrace( System.out );
3212 private static boolean testBasicTolXMLparsing() {
3214 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3215 final TolParser parser = new TolParser();
3216 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3217 if ( parser.getErrorCount() > 0 ) {
3218 System.out.println( parser.getErrorMessages().toString() );
3221 if ( phylogenies_0.length != 1 ) {
3224 final Phylogeny t1 = phylogenies_0[ 0 ];
3225 if ( t1.getNumberOfExternalNodes() != 5 ) {
3228 if ( !t1.isRooted() ) {
3231 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3234 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3237 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
3240 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3243 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3244 if ( parser.getErrorCount() > 0 ) {
3245 System.out.println( parser.getErrorMessages().toString() );
3248 if ( phylogenies_1.length != 1 ) {
3251 final Phylogeny t2 = phylogenies_1[ 0 ];
3252 if ( t2.getNumberOfExternalNodes() != 664 ) {
3255 if ( !t2.isRooted() ) {
3258 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3261 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3264 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3267 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3270 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
3273 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3274 .equals( "Aquifex" ) ) {
3277 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3278 if ( parser.getErrorCount() > 0 ) {
3279 System.out.println( parser.getErrorMessages().toString() );
3282 if ( phylogenies_2.length != 1 ) {
3285 final Phylogeny t3 = phylogenies_2[ 0 ];
3286 if ( t3.getNumberOfExternalNodes() != 184 ) {
3289 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3292 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3295 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3298 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3299 if ( parser.getErrorCount() > 0 ) {
3300 System.out.println( parser.getErrorMessages().toString() );
3303 if ( phylogenies_3.length != 1 ) {
3306 final Phylogeny t4 = phylogenies_3[ 0 ];
3307 if ( t4.getNumberOfExternalNodes() != 1 ) {
3310 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3313 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3316 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3319 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3320 if ( parser.getErrorCount() > 0 ) {
3321 System.out.println( parser.getErrorMessages().toString() );
3324 if ( phylogenies_4.length != 1 ) {
3327 final Phylogeny t5 = phylogenies_4[ 0 ];
3328 if ( t5.getNumberOfExternalNodes() != 13 ) {
3331 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3334 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3337 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3341 catch ( final Exception e ) {
3342 e.printStackTrace( System.out );
3348 private static boolean testBasicTreeMethods() {
3350 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3351 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3352 if ( t2.getNumberOfExternalNodes() != 4 ) {
3355 if ( t2.calculateHeight(false) != 8.5 ) {
3358 if ( !t2.isCompletelyBinary() ) {
3361 if ( t2.isEmpty() ) {
3364 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3365 if ( t3.getNumberOfExternalNodes() != 5 ) {
3368 if ( t3.calculateHeight(true) != 11 ) {
3371 if ( t3.isCompletelyBinary() ) {
3374 final PhylogenyNode n = t3.getNode( "ABC" );
3375 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 ];
3376 if ( t4.getNumberOfExternalNodes() != 9 ) {
3379 if ( t4.calculateHeight(false) != 11 ) {
3382 if ( t4.isCompletelyBinary() ) {
3385 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)" );
3386 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3387 if ( t5.getNumberOfExternalNodes() != 8 ) {
3390 if ( t5.calculateHeight(false) != 15 ) {
3393 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)" );
3394 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3395 if ( t6.calculateHeight(true) != 15 ) {
3398 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)" );
3399 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3400 if ( t7.calculateHeight(true) != 15 ) {
3403 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)" );
3404 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3405 if ( t8.getNumberOfExternalNodes() != 10 ) {
3408 if ( t8.calculateHeight(true) != 15 ) {
3411 final char[] a9 = new char[] { 'a' };
3412 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3413 if ( t9.calculateHeight(true) != 0 ) {
3416 final char[] a10 = new char[] { 'a', ':', '6' };
3417 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3418 if ( t10.calculateHeight(true) != 6 ) {
3422 catch ( final Exception e ) {
3423 e.printStackTrace( System.out );
3429 private static boolean testConfidenceAssessor() {
3431 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3432 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3433 final Phylogeny[] ev0 = factory
3434 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3436 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3437 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3440 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3443 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3444 final Phylogeny[] ev1 = factory
3445 .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)));",
3447 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3448 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3451 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3454 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3455 final Phylogeny[] ev_b = factory
3456 .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",
3458 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3459 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3462 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3466 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3467 final Phylogeny[] ev1x = factory
3468 .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)));",
3470 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3471 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3474 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3477 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3478 final Phylogeny[] ev_bx = factory
3479 .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",
3481 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3482 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3485 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3488 final Phylogeny[] t2 = factory
3489 .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);",
3491 final Phylogeny[] ev2 = factory
3492 .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);",
3494 for( final Phylogeny target : t2 ) {
3495 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3497 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3498 new NHXParser() )[ 0 ];
3499 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3500 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3501 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3504 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3507 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3511 catch ( final Exception e ) {
3512 e.printStackTrace();
3518 private static boolean testCopyOfNodeData() {
3520 final PhylogenyNode n1 = PhylogenyNode
3521 .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]" );
3522 final PhylogenyNode n2 = n1.copyNodeData();
3523 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3527 catch ( final Exception e ) {
3528 e.printStackTrace();
3534 private static boolean testCreateBalancedPhylogeny() {
3536 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3537 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3540 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3543 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3544 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3547 if ( p1.getNumberOfExternalNodes() != 100 ) {
3551 catch ( final Exception e ) {
3552 e.printStackTrace();
3558 private static boolean testCreateUriForSeqWeb() {
3560 final PhylogenyNode n = new PhylogenyNode();
3561 n.setName( "tr|B3RJ64" );
3562 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3565 n.setName( "B0LM41_HUMAN" );
3566 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3569 n.setName( "NP_001025424" );
3570 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3573 n.setName( "_NM_001030253-" );
3574 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3577 n.setName( "XM_002122186" );
3578 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3581 n.setName( "dgh_AAA34956_gdg" );
3582 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3585 n.setName( "AAA34956" );
3586 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3589 n.setName( "GI:394892" );
3590 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3591 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3594 n.setName( "gi_394892" );
3595 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3596 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3599 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3600 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3601 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3604 n.setName( "P12345" );
3605 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3606 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3609 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3610 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3611 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3615 catch ( final Exception e ) {
3616 e.printStackTrace( System.out );
3622 private static boolean testDataObjects() {
3624 final Confidence s0 = new Confidence();
3625 final Confidence s1 = new Confidence();
3626 if ( !s0.isEqual( s1 ) ) {
3629 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3630 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3631 if ( s2.isEqual( s1 ) ) {
3634 if ( !s2.isEqual( s3 ) ) {
3637 final Confidence s4 = ( Confidence ) s3.copy();
3638 if ( !s4.isEqual( s3 ) ) {
3645 final Taxonomy t1 = new Taxonomy();
3646 final Taxonomy t2 = new Taxonomy();
3647 final Taxonomy t3 = new Taxonomy();
3648 final Taxonomy t4 = new Taxonomy();
3649 final Taxonomy t5 = new Taxonomy();
3650 t1.setIdentifier( new Identifier( "ecoli" ) );
3651 t1.setTaxonomyCode( "ECOLI" );
3652 t1.setScientificName( "E. coli" );
3653 t1.setCommonName( "coli" );
3654 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3655 if ( !t1.isEqual( t0 ) ) {
3658 t2.setIdentifier( new Identifier( "ecoli" ) );
3659 t2.setTaxonomyCode( "OTHER" );
3660 t2.setScientificName( "what" );
3661 t2.setCommonName( "something" );
3662 if ( !t1.isEqual( t2 ) ) {
3665 t2.setIdentifier( new Identifier( "nemve" ) );
3666 if ( t1.isEqual( t2 ) ) {
3669 t1.setIdentifier( null );
3670 t3.setTaxonomyCode( "ECOLI" );
3671 t3.setScientificName( "what" );
3672 t3.setCommonName( "something" );
3673 if ( !t1.isEqual( t3 ) ) {
3676 t1.setIdentifier( null );
3677 t1.setTaxonomyCode( "" );
3678 t4.setScientificName( "E. ColI" );
3679 t4.setCommonName( "something" );
3680 if ( !t1.isEqual( t4 ) ) {
3683 t4.setScientificName( "B. subtilis" );
3684 t4.setCommonName( "something" );
3685 if ( t1.isEqual( t4 ) ) {
3688 t1.setIdentifier( null );
3689 t1.setTaxonomyCode( "" );
3690 t1.setScientificName( "" );
3691 t5.setCommonName( "COLI" );
3692 if ( !t1.isEqual( t5 ) ) {
3695 t5.setCommonName( "vibrio" );
3696 if ( t1.isEqual( t5 ) ) {
3701 final Identifier id0 = new Identifier( "123", "pfam" );
3702 final Identifier id1 = ( Identifier ) id0.copy();
3703 if ( !id1.isEqual( id1 ) ) {
3706 if ( !id1.isEqual( id0 ) ) {
3709 if ( !id0.isEqual( id1 ) ) {
3716 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3717 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3718 if ( !pd1.isEqual( pd1 ) ) {
3721 if ( !pd1.isEqual( pd0 ) ) {
3726 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3727 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3728 if ( !pd3.isEqual( pd3 ) ) {
3731 if ( !pd2.isEqual( pd3 ) ) {
3734 if ( !pd0.isEqual( pd3 ) ) {
3739 // DomainArchitecture
3740 // ------------------
3741 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3742 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3743 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3744 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3745 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3746 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3751 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3752 if ( ds0.getNumberOfDomains() != 4 ) {
3755 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3756 if ( !ds0.isEqual( ds0 ) ) {
3759 if ( !ds0.isEqual( ds1 ) ) {
3762 if ( ds1.getNumberOfDomains() != 4 ) {
3765 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3770 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3771 if ( ds0.isEqual( ds2 ) ) {
3777 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3778 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3779 System.out.println( ds3.toNHX() );
3782 if ( ds3.getNumberOfDomains() != 3 ) {
3787 final Event e1 = new Event( Event.EventType.fusion );
3788 if ( e1.isDuplication() ) {
3791 if ( !e1.isFusion() ) {
3794 if ( !e1.asText().toString().equals( "fusion" ) ) {
3797 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3800 final Event e11 = new Event( Event.EventType.fusion );
3801 if ( !e11.isEqual( e1 ) ) {
3804 if ( !e11.toNHX().toString().equals( "" ) ) {
3807 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3808 if ( e2.isDuplication() ) {
3811 if ( !e2.isSpeciationOrDuplication() ) {
3814 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3817 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3820 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3823 if ( e11.isEqual( e2 ) ) {
3826 final Event e2c = ( Event ) e2.copy();
3827 if ( !e2c.isEqual( e2 ) ) {
3830 Event e3 = new Event( 1, 2, 3 );
3831 if ( e3.isDuplication() ) {
3834 if ( e3.isSpeciation() ) {
3837 if ( e3.isGeneLoss() ) {
3840 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3843 final Event e3c = ( Event ) e3.copy();
3844 final Event e3cc = ( Event ) e3c.copy();
3845 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3849 if ( !e3c.isEqual( e3cc ) ) {
3852 Event e4 = new Event( 1, 2, 3 );
3853 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3856 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3859 final Event e4c = ( Event ) e4.copy();
3861 final Event e4cc = ( Event ) e4c.copy();
3862 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3865 if ( !e4c.isEqual( e4cc ) ) {
3868 final Event e5 = new Event();
3869 if ( !e5.isUnassigned() ) {
3872 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3875 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3878 final Event e6 = new Event( 1, 0, 0 );
3879 if ( !e6.asText().toString().equals( "duplication" ) ) {
3882 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3885 final Event e7 = new Event( 0, 1, 0 );
3886 if ( !e7.asText().toString().equals( "speciation" ) ) {
3889 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3892 final Event e8 = new Event( 0, 0, 1 );
3893 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3896 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3900 catch ( final Exception e ) {
3901 e.printStackTrace( System.out );
3907 private static boolean testDeletionOfExternalNodes() {
3909 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3910 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3911 final PhylogenyWriter w = new PhylogenyWriter();
3912 if ( t0.isEmpty() ) {
3915 if ( t0.getNumberOfExternalNodes() != 1 ) {
3918 t0.deleteSubtree( t0.getNode( "A" ), false );
3919 if ( t0.getNumberOfExternalNodes() != 0 ) {
3922 if ( !t0.isEmpty() ) {
3925 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3926 if ( t1.getNumberOfExternalNodes() != 2 ) {
3929 t1.deleteSubtree( t1.getNode( "A" ), false );
3930 if ( t1.getNumberOfExternalNodes() != 1 ) {
3933 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3936 t1.deleteSubtree( t1.getNode( "B" ), false );
3937 if ( t1.getNumberOfExternalNodes() != 1 ) {
3940 t1.deleteSubtree( t1.getNode( "r" ), false );
3941 if ( !t1.isEmpty() ) {
3944 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3945 if ( t2.getNumberOfExternalNodes() != 3 ) {
3948 t2.deleteSubtree( t2.getNode( "B" ), false );
3949 if ( t2.getNumberOfExternalNodes() != 2 ) {
3952 t2.toNewHampshireX();
3953 PhylogenyNode n = t2.getNode( "A" );
3954 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3957 t2.deleteSubtree( t2.getNode( "A" ), false );
3958 if ( t2.getNumberOfExternalNodes() != 2 ) {
3961 t2.deleteSubtree( t2.getNode( "C" ), true );
3962 if ( t2.getNumberOfExternalNodes() != 1 ) {
3965 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3966 if ( t3.getNumberOfExternalNodes() != 4 ) {
3969 t3.deleteSubtree( t3.getNode( "B" ), true );
3970 if ( t3.getNumberOfExternalNodes() != 3 ) {
3973 n = t3.getNode( "A" );
3974 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3977 n = n.getNextExternalNode();
3978 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3981 t3.deleteSubtree( t3.getNode( "A" ), true );
3982 if ( t3.getNumberOfExternalNodes() != 2 ) {
3985 n = t3.getNode( "C" );
3986 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3989 t3.deleteSubtree( t3.getNode( "C" ), true );
3990 if ( t3.getNumberOfExternalNodes() != 1 ) {
3993 t3.deleteSubtree( t3.getNode( "D" ), true );
3994 if ( t3.getNumberOfExternalNodes() != 0 ) {
3997 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3998 if ( t4.getNumberOfExternalNodes() != 6 ) {
4001 t4.deleteSubtree( t4.getNode( "B2" ), true );
4002 if ( t4.getNumberOfExternalNodes() != 5 ) {
4005 String s = w.toNewHampshire( t4, true ).toString();
4006 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4009 t4.deleteSubtree( t4.getNode( "B11" ), true );
4010 if ( t4.getNumberOfExternalNodes() != 4 ) {
4013 t4.deleteSubtree( t4.getNode( "C" ), true );
4014 if ( t4.getNumberOfExternalNodes() != 3 ) {
4017 n = t4.getNode( "A" );
4018 n = n.getNextExternalNode();
4019 if ( !n.getName().equals( "B12" ) ) {
4022 n = n.getNextExternalNode();
4023 if ( !n.getName().equals( "D" ) ) {
4026 s = w.toNewHampshire( t4, true ).toString();
4027 if ( !s.equals( "((A,B12),D);" ) ) {
4030 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4031 t5.deleteSubtree( t5.getNode( "A" ), true );
4032 if ( t5.getNumberOfExternalNodes() != 5 ) {
4035 s = w.toNewHampshire( t5, true ).toString();
4036 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
4039 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4040 t6.deleteSubtree( t6.getNode( "B11" ), true );
4041 if ( t6.getNumberOfExternalNodes() != 5 ) {
4044 s = w.toNewHampshire( t6, false ).toString();
4045 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4048 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4049 t7.deleteSubtree( t7.getNode( "B12" ), true );
4050 if ( t7.getNumberOfExternalNodes() != 5 ) {
4053 s = w.toNewHampshire( t7, true ).toString();
4054 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4057 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4058 t8.deleteSubtree( t8.getNode( "B2" ), true );
4059 if ( t8.getNumberOfExternalNodes() != 5 ) {
4062 s = w.toNewHampshire( t8, false ).toString();
4063 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4066 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4067 t9.deleteSubtree( t9.getNode( "C" ), true );
4068 if ( t9.getNumberOfExternalNodes() != 5 ) {
4071 s = w.toNewHampshire( t9, true ).toString();
4072 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4075 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4076 t10.deleteSubtree( t10.getNode( "D" ), true );
4077 if ( t10.getNumberOfExternalNodes() != 5 ) {
4080 s = w.toNewHampshire( t10, true ).toString();
4081 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4084 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4085 t11.deleteSubtree( t11.getNode( "A" ), true );
4086 if ( t11.getNumberOfExternalNodes() != 2 ) {
4089 s = w.toNewHampshire( t11, true ).toString();
4090 if ( !s.equals( "(B,C);" ) ) {
4093 t11.deleteSubtree( t11.getNode( "C" ), true );
4094 if ( t11.getNumberOfExternalNodes() != 1 ) {
4097 s = w.toNewHampshire( t11, false ).toString();
4098 if ( !s.equals( "B;" ) ) {
4101 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4102 t12.deleteSubtree( t12.getNode( "B2" ), true );
4103 if ( t12.getNumberOfExternalNodes() != 8 ) {
4106 s = w.toNewHampshire( t12, true ).toString();
4107 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4110 t12.deleteSubtree( t12.getNode( "B3" ), true );
4111 if ( t12.getNumberOfExternalNodes() != 7 ) {
4114 s = w.toNewHampshire( t12, true ).toString();
4115 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4118 t12.deleteSubtree( t12.getNode( "C3" ), true );
4119 if ( t12.getNumberOfExternalNodes() != 6 ) {
4122 s = w.toNewHampshire( t12, true ).toString();
4123 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4126 t12.deleteSubtree( t12.getNode( "A1" ), true );
4127 if ( t12.getNumberOfExternalNodes() != 5 ) {
4130 s = w.toNewHampshire( t12, true ).toString();
4131 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4134 t12.deleteSubtree( t12.getNode( "B1" ), true );
4135 if ( t12.getNumberOfExternalNodes() != 4 ) {
4138 s = w.toNewHampshire( t12, true ).toString();
4139 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4142 t12.deleteSubtree( t12.getNode( "A3" ), true );
4143 if ( t12.getNumberOfExternalNodes() != 3 ) {
4146 s = w.toNewHampshire( t12, true ).toString();
4147 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4150 t12.deleteSubtree( t12.getNode( "A2" ), true );
4151 if ( t12.getNumberOfExternalNodes() != 2 ) {
4154 s = w.toNewHampshire( t12, true ).toString();
4155 if ( !s.equals( "(C1,C2);" ) ) {
4158 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4159 t13.deleteSubtree( t13.getNode( "D" ), true );
4160 if ( t13.getNumberOfExternalNodes() != 4 ) {
4163 s = w.toNewHampshire( t13, true ).toString();
4164 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4167 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4168 t14.deleteSubtree( t14.getNode( "E" ), true );
4169 if ( t14.getNumberOfExternalNodes() != 5 ) {
4172 s = w.toNewHampshire( t14, true ).toString();
4173 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4176 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4177 t15.deleteSubtree( t15.getNode( "B2" ), true );
4178 if ( t15.getNumberOfExternalNodes() != 11 ) {
4181 t15.deleteSubtree( t15.getNode( "B1" ), true );
4182 if ( t15.getNumberOfExternalNodes() != 10 ) {
4185 t15.deleteSubtree( t15.getNode( "B3" ), true );
4186 if ( t15.getNumberOfExternalNodes() != 9 ) {
4189 t15.deleteSubtree( t15.getNode( "B4" ), true );
4190 if ( t15.getNumberOfExternalNodes() != 8 ) {
4193 t15.deleteSubtree( t15.getNode( "A1" ), true );
4194 if ( t15.getNumberOfExternalNodes() != 7 ) {
4197 t15.deleteSubtree( t15.getNode( "C4" ), true );
4198 if ( t15.getNumberOfExternalNodes() != 6 ) {
4202 catch ( final Exception e ) {
4203 e.printStackTrace( System.out );
4209 private static boolean testDescriptiveStatistics() {
4211 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4212 dss1.addValue( 82 );
4213 dss1.addValue( 78 );
4214 dss1.addValue( 70 );
4215 dss1.addValue( 58 );
4216 dss1.addValue( 42 );
4217 if ( dss1.getN() != 5 ) {
4220 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4223 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4226 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4229 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4232 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4235 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4238 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4241 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4244 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4247 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4250 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4253 dss1.addValue( 123 );
4254 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4257 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4260 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4263 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4264 dss2.addValue( -1.85 );
4265 dss2.addValue( 57.5 );
4266 dss2.addValue( 92.78 );
4267 dss2.addValue( 57.78 );
4268 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4271 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4274 final double[] a = dss2.getDataAsDoubleArray();
4275 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4278 dss2.addValue( -100 );
4279 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4282 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4285 final double[] ds = new double[ 14 ];
4300 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4301 if ( bins.length != 4 ) {
4304 if ( bins[ 0 ] != 2 ) {
4307 if ( bins[ 1 ] != 3 ) {
4310 if ( bins[ 2 ] != 4 ) {
4313 if ( bins[ 3 ] != 5 ) {
4316 final double[] ds1 = new double[ 9 ];
4326 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4327 if ( bins1.length != 4 ) {
4330 if ( bins1[ 0 ] != 2 ) {
4333 if ( bins1[ 1 ] != 3 ) {
4336 if ( bins1[ 2 ] != 0 ) {
4339 if ( bins1[ 3 ] != 4 ) {
4342 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4343 if ( bins1_1.length != 3 ) {
4346 if ( bins1_1[ 0 ] != 3 ) {
4349 if ( bins1_1[ 1 ] != 2 ) {
4352 if ( bins1_1[ 2 ] != 4 ) {
4355 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4356 if ( bins1_2.length != 3 ) {
4359 if ( bins1_2[ 0 ] != 2 ) {
4362 if ( bins1_2[ 1 ] != 2 ) {
4365 if ( bins1_2[ 2 ] != 2 ) {
4368 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4382 dss3.addValue( 10 );
4383 dss3.addValue( 10 );
4384 dss3.addValue( 10 );
4385 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4386 histo.toStringBuffer( 10, '=', 40, 5 );
4387 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4389 catch ( final Exception e ) {
4390 e.printStackTrace( System.out );
4396 private static boolean testDir( final String file ) {
4398 final File f = new File( file );
4399 if ( !f.exists() ) {
4402 if ( !f.isDirectory() ) {
4405 if ( !f.canRead() ) {
4409 catch ( final Exception e ) {
4415 private static boolean testEbiEntryRetrieval() {
4417 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4418 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4419 System.out.println( entry.getAccession() );
4422 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4423 System.out.println( entry.getTaxonomyScientificName() );
4426 if ( !entry.getSequenceName()
4427 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4428 System.out.println( entry.getSequenceName() );
4431 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4432 System.out.println( entry.getGeneName() );
4435 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4436 System.out.println( entry.getTaxonomyIdentifier() );
4439 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4440 System.out.println( entry.getAnnotations().first().getRefValue() );
4443 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4444 System.out.println( entry.getAnnotations().first().getRefSource() );
4447 if ( entry.getCrossReferences().size() < 1 ) {
4450 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4451 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4454 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4455 System.out.println( entry1.getTaxonomyScientificName() );
4458 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4459 System.out.println( entry1.getSequenceName() );
4462 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4463 System.out.println( entry1.getTaxonomyIdentifier() );
4466 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4467 System.out.println( entry1.getGeneName() );
4470 if ( entry1.getCrossReferences().size() < 1 ) {
4473 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4474 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4477 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4478 System.out.println( entry2.getTaxonomyScientificName() );
4481 if ( !entry2.getSequenceName()
4482 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4483 System.out.println( entry2.getSequenceName() );
4486 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4487 System.out.println( entry2.getTaxonomyIdentifier() );
4490 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4491 System.out.println( entry2.getGeneName() );
4494 if ( entry2.getCrossReferences().size() < 1 ) {
4497 if ( !entry2.getChromosome().equals( "20" ) ) {
4500 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4503 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4504 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4507 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4508 System.out.println( entry3.getTaxonomyScientificName() );
4511 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4512 System.out.println( entry3.getSequenceName() );
4515 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4516 System.out.println( entry3.getTaxonomyIdentifier() );
4519 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4520 System.out.println( entry3.getSequenceSymbol() );
4523 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4526 if ( entry3.getCrossReferences().size() < 1 ) {
4529 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4530 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4533 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4534 System.out.println( entry4.getTaxonomyScientificName() );
4537 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4538 System.out.println( entry4.getSequenceName() );
4541 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4542 System.out.println( entry4.getTaxonomyIdentifier() );
4545 if ( !entry4.getGeneName().equals( "ras" ) ) {
4546 System.out.println( entry4.getGeneName() );
4549 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4550 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4553 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4554 System.out.println( entry5.getTaxonomyScientificName() );
4557 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4558 System.out.println( entry5.getSequenceName() );
4561 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4562 System.out.println( entry5.getTaxonomyIdentifier() );
4565 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4566 if ( !entry6.getAccession().equals( "M30539" ) ) {
4569 if ( !entry6.getGeneName().equals( "ras" ) ) {
4572 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4575 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4578 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4581 if ( entry6.getCrossReferences().size() < 1 ) {
4585 catch ( final IOException e ) {
4586 System.out.println();
4587 System.out.println( "the following might be due to absence internet connection:" );
4588 e.printStackTrace( System.out );
4591 catch ( final Exception e ) {
4592 e.printStackTrace();
4598 private static boolean testExternalNodeRelatedMethods() {
4600 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4601 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4602 PhylogenyNode n = t1.getNode( "A" );
4603 n = n.getNextExternalNode();
4604 if ( !n.getName().equals( "B" ) ) {
4607 n = n.getNextExternalNode();
4608 if ( !n.getName().equals( "C" ) ) {
4611 n = n.getNextExternalNode();
4612 if ( !n.getName().equals( "D" ) ) {
4615 n = t1.getNode( "B" );
4616 while ( !n.isLastExternalNode() ) {
4617 n = n.getNextExternalNode();
4619 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4620 n = t2.getNode( "A" );
4621 n = n.getNextExternalNode();
4622 if ( !n.getName().equals( "B" ) ) {
4625 n = n.getNextExternalNode();
4626 if ( !n.getName().equals( "C" ) ) {
4629 n = n.getNextExternalNode();
4630 if ( !n.getName().equals( "D" ) ) {
4633 n = t2.getNode( "B" );
4634 while ( !n.isLastExternalNode() ) {
4635 n = n.getNextExternalNode();
4637 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4638 n = t3.getNode( "A" );
4639 n = n.getNextExternalNode();
4640 if ( !n.getName().equals( "B" ) ) {
4643 n = n.getNextExternalNode();
4644 if ( !n.getName().equals( "C" ) ) {
4647 n = n.getNextExternalNode();
4648 if ( !n.getName().equals( "D" ) ) {
4651 n = n.getNextExternalNode();
4652 if ( !n.getName().equals( "E" ) ) {
4655 n = n.getNextExternalNode();
4656 if ( !n.getName().equals( "F" ) ) {
4659 n = n.getNextExternalNode();
4660 if ( !n.getName().equals( "G" ) ) {
4663 n = n.getNextExternalNode();
4664 if ( !n.getName().equals( "H" ) ) {
4667 n = t3.getNode( "B" );
4668 while ( !n.isLastExternalNode() ) {
4669 n = n.getNextExternalNode();
4671 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4672 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4673 final PhylogenyNode node = iter.next();
4675 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4676 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4677 final PhylogenyNode node = iter.next();
4679 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4680 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4681 if ( !iter.next().getName().equals( "A" ) ) {
4684 if ( !iter.next().getName().equals( "B" ) ) {
4687 if ( !iter.next().getName().equals( "C" ) ) {
4690 if ( !iter.next().getName().equals( "D" ) ) {
4693 if ( !iter.next().getName().equals( "E" ) ) {
4696 if ( !iter.next().getName().equals( "F" ) ) {
4699 if ( iter.hasNext() ) {
4703 catch ( final Exception e ) {
4704 e.printStackTrace( System.out );
4710 private static boolean testExtractSNFromNodeName() {
4712 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4715 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4718 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4721 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4722 .equals( "Mus musculus musculus" ) ) {
4725 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4726 .equals( "Mus musculus musculus" ) ) {
4729 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4730 .equals( "Mus musculus musculus" ) ) {
4733 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4734 .equals( "Mus musculus musculus" ) ) {
4737 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4740 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4741 .equals( "Mus musculus musculus" ) ) {
4744 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4745 .equals( "Mus musculus musculus" ) ) {
4748 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4751 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4754 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4757 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4760 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4761 .equals( "Mus musculus musculus" ) ) {
4764 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4767 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4770 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4773 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4776 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4779 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4782 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4785 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4788 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4789 .equals( "Mus musculus" ) ) {
4792 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4793 .equals( "Mus musculus" ) ) {
4796 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4799 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4800 .equals( "Mus musculus musculus" ) ) {
4803 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4804 .equals( "Mus musculus musculus" ) ) {
4807 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4808 .equals( "Mus musculus musculus" ) ) {
4811 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4814 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4815 .equals( "Pilostyles mexicana" ) ) {
4818 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4819 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4822 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4823 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4826 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4827 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4830 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4831 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4834 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4835 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4838 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4839 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4842 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4843 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4846 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4847 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4850 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4851 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4854 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4855 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4858 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4859 .equals( "Escherichia coli (strain K12)" ) ) {
4862 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4863 .equals( "Escherichia coli (strain K12)" ) ) {
4866 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4867 .equals( "Escherichia coli (str. K12)" ) ) {
4870 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4871 .equals( "Escherichia coli (str. K12)" ) ) {
4874 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4875 .equals( "Escherichia coli (str. K12)" ) ) {
4878 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4879 .equals( "Escherichia coli (var. K12)" ) ) {
4882 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4883 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4886 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4887 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4891 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4892 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4895 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4896 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4900 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4901 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4904 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4905 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4908 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4909 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4912 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4915 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4918 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4921 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4922 .equals( "Macrocera sp." ) ) {
4925 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4928 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4929 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4932 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4933 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4936 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4937 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4940 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4941 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4945 catch ( final Exception e ) {
4946 e.printStackTrace( System.out );
4952 private static boolean testExtractTaxonomyDataFromNodeName() {
4954 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4955 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4958 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4959 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4962 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4963 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4966 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4967 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4970 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4971 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4974 n = new PhylogenyNode( "HNRPR_HUMAN" );
4975 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4978 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
4979 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4983 catch ( final Exception e ) {
4984 e.printStackTrace( System.out );
4990 private static boolean testExtractTaxonomyCodeFromNodeName() {
4992 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4995 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4996 .equals( "SOYBN" ) ) {
4999 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5000 .equals( "ARATH" ) ) {
5003 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5004 .equals( "ARATH" ) ) {
5007 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
5010 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
5013 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5016 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5017 .equals( "SOYBN" ) ) {
5020 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5021 .equals( "SOYBN" ) ) {
5024 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5025 .equals( "SOYBN" ) ) {
5028 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5029 .equals( "SOYBN" ) ) {
5032 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5033 .equals( "SOYBN" ) ) {
5036 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5037 .equals( "SOYBN" ) ) {
5040 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
5041 .equals( "SOYBN" ) ) {
5044 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5045 .equals( "SOYBN" ) ) {
5048 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5051 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5052 .equals( "SOYBN" ) ) {
5055 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
5056 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
5059 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5060 .equals( "9YX45" ) ) {
5063 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5064 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5065 .equals( "MOUSE" ) ) {
5068 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5069 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5070 .equals( "MOUSE" ) ) {
5073 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5074 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5075 .equals( "MOUSE" ) ) {
5078 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5079 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5082 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5083 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5086 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5087 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5090 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5091 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5094 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5095 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5098 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5099 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5102 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5103 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5106 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5107 .equals( "RAT" ) ) {
5110 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5111 .equals( "PIG" ) ) {
5115 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5116 .equals( "MOUSE" ) ) {
5119 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5120 .equals( "MOUSE" ) ) {
5123 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5127 catch ( final Exception e ) {
5128 e.printStackTrace( System.out );
5134 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5136 PhylogenyNode n = new PhylogenyNode();
5137 n.setName( "tr|B3RJ64" );
5138 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5141 n.setName( "tr.B3RJ64" );
5142 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5145 n.setName( "tr=B3RJ64" );
5146 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5149 n.setName( "tr-B3RJ64" );
5150 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5153 n.setName( "tr/B3RJ64" );
5154 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5157 n.setName( "tr\\B3RJ64" );
5158 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5161 n.setName( "tr_B3RJ64" );
5162 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5165 n.setName( " tr|B3RJ64 " );
5166 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5169 n.setName( "-tr|B3RJ64-" );
5170 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5173 n.setName( "-tr=B3RJ64-" );
5174 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5177 n.setName( "_tr=B3RJ64_" );
5178 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5181 n.setName( " tr_tr|B3RJ64_sp|123 " );
5182 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5185 n.setName( "B3RJ64" );
5186 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5189 n.setName( "sp|B3RJ64" );
5190 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5193 n.setName( "sp|B3RJ64C" );
5194 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5197 n.setName( "sp B3RJ64" );
5198 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5201 n.setName( "sp|B3RJ6X" );
5202 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5205 n.setName( "sp|B3RJ6" );
5206 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5209 n.setName( "K1PYK7_CRAGI" );
5210 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5213 n.setName( "K1PYK7_PEA" );
5214 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5217 n.setName( "K1PYK7_RAT" );
5218 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5221 n.setName( "K1PYK7_PIG" );
5222 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5225 n.setName( "~K1PYK7_PIG~" );
5226 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5229 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5230 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5233 n.setName( "K1PYKX_CRAGI" );
5234 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5237 n.setName( "XXXXX_CRAGI" );
5238 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5241 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5242 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5245 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5246 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5249 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5250 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5253 n = new PhylogenyNode();
5254 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5255 seq.setSymbol( "K1PYK7_CRAGI" );
5256 n.getNodeData().addSequence( seq );
5257 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5260 seq.setSymbol( "tr|B3RJ64" );
5261 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5264 n = new PhylogenyNode();
5265 seq = new org.forester.phylogeny.data.Sequence();
5266 seq.setName( "K1PYK7_CRAGI" );
5267 n.getNodeData().addSequence( seq );
5268 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5271 seq.setName( "tr|B3RJ64" );
5272 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5275 n = new PhylogenyNode();
5276 seq = new org.forester.phylogeny.data.Sequence();
5277 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5278 n.getNodeData().addSequence( seq );
5279 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5282 n = new PhylogenyNode();
5283 seq = new org.forester.phylogeny.data.Sequence();
5284 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5285 n.getNodeData().addSequence( seq );
5286 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5290 n = new PhylogenyNode();
5291 n.setName( "ACP19736" );
5292 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5295 n = new PhylogenyNode();
5296 n.setName( "|ACP19736|" );
5297 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5301 catch ( final Exception e ) {
5302 e.printStackTrace( System.out );
5308 private static boolean testFastaParser() {
5310 FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5311 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5318 FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5319 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5326 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5327 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5330 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5333 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5336 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5339 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5342 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5346 catch ( final Exception e ) {
5347 e.printStackTrace();
5353 private static boolean testGenbankAccessorParsing() {
5354 //The format for GenBank Accession numbers are:
5355 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5356 //Protein: 3 letters + 5 numerals
5357 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5358 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5361 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5364 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
5367 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5370 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5373 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5376 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5379 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5382 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5385 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5388 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5391 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5394 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5397 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5403 private static boolean testGeneralMsaParser() {
5405 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5406 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5407 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5408 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5409 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5410 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5411 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5412 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5413 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5416 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5419 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5422 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5425 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5428 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5431 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5434 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5437 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5440 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5443 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5446 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5449 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5450 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5453 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5456 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5459 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5460 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5463 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5466 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5469 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5470 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5473 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5476 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5480 catch ( final Exception e ) {
5481 e.printStackTrace();
5487 private static boolean testGeneralTable() {
5489 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5490 t0.setValue( 3, 2, "23" );
5491 t0.setValue( 10, 1, "error" );
5492 t0.setValue( 10, 1, "110" );
5493 t0.setValue( 9, 1, "19" );
5494 t0.setValue( 1, 10, "101" );
5495 t0.setValue( 10, 10, "1010" );
5496 t0.setValue( 100, 10, "10100" );
5497 t0.setValue( 0, 0, "00" );
5498 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5501 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5504 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5507 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5510 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5513 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5516 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5519 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5522 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5525 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5526 t1.setValue( "3", "2", "23" );
5527 t1.setValue( "10", "1", "error" );
5528 t1.setValue( "10", "1", "110" );
5529 t1.setValue( "9", "1", "19" );
5530 t1.setValue( "1", "10", "101" );
5531 t1.setValue( "10", "10", "1010" );
5532 t1.setValue( "100", "10", "10100" );
5533 t1.setValue( "0", "0", "00" );
5534 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5535 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5538 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5541 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5544 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5547 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5550 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5553 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5556 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5559 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5562 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5566 catch ( final Exception e ) {
5567 e.printStackTrace( System.out );
5573 private static boolean testGetDistance() {
5575 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5576 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",
5577 new NHXParser() )[ 0 ];
5578 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5581 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5584 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5587 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5590 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5593 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5596 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5599 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5602 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5605 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5608 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5611 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5614 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5617 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5620 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5623 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5626 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5629 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5632 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5635 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5638 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5641 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5644 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5647 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5650 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5653 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5656 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5659 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5662 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5665 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5668 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5671 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",
5672 new NHXParser() )[ 0 ];
5673 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5676 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5679 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5682 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5685 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5688 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5691 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5694 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5697 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5700 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5703 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5707 catch ( final Exception e ) {
5708 e.printStackTrace( System.out );
5714 private static boolean testGetLCA() {
5716 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5717 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5718 new NHXParser() )[ 0 ];
5719 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5720 if ( !A.getName().equals( "A" ) ) {
5723 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5724 if ( !gh.getName().equals( "gh" ) ) {
5727 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5728 if ( !ab.getName().equals( "ab" ) ) {
5731 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5732 if ( !ab2.getName().equals( "ab" ) ) {
5735 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5736 if ( !gh2.getName().equals( "gh" ) ) {
5739 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5740 if ( !gh3.getName().equals( "gh" ) ) {
5743 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5744 if ( !abc.getName().equals( "abc" ) ) {
5747 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5748 if ( !abc2.getName().equals( "abc" ) ) {
5751 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5752 if ( !abcd.getName().equals( "abcd" ) ) {
5755 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5756 if ( !abcd2.getName().equals( "abcd" ) ) {
5759 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5760 if ( !abcdef.getName().equals( "abcdef" ) ) {
5763 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5764 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5767 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5768 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5771 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5772 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5775 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5776 if ( !abcde.getName().equals( "abcde" ) ) {
5779 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5780 if ( !abcde2.getName().equals( "abcde" ) ) {
5783 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5784 if ( !r.getName().equals( "abcdefgh" ) ) {
5787 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5788 if ( !r2.getName().equals( "abcdefgh" ) ) {
5791 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5792 if ( !r3.getName().equals( "abcdefgh" ) ) {
5795 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5796 if ( !abcde3.getName().equals( "abcde" ) ) {
5799 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5800 if ( !abcde4.getName().equals( "abcde" ) ) {
5803 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5804 if ( !ab3.getName().equals( "ab" ) ) {
5807 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5808 if ( !ab4.getName().equals( "ab" ) ) {
5811 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5812 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5813 if ( !cd.getName().equals( "cd" ) ) {
5816 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5817 if ( !cd2.getName().equals( "cd" ) ) {
5820 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5821 if ( !cde.getName().equals( "cde" ) ) {
5824 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5825 if ( !cde2.getName().equals( "cde" ) ) {
5828 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5829 if ( !cdef.getName().equals( "cdef" ) ) {
5832 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5833 if ( !cdef2.getName().equals( "cdef" ) ) {
5836 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5837 if ( !cdef3.getName().equals( "cdef" ) ) {
5840 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5841 if ( !rt.getName().equals( "r" ) ) {
5844 final Phylogeny p3 = factory
5845 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5846 new NHXParser() )[ 0 ];
5847 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5848 if ( !bc_3.getName().equals( "bc" ) ) {
5851 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5852 if ( !ac_3.getName().equals( "abc" ) ) {
5855 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5856 if ( !ad_3.getName().equals( "abcde" ) ) {
5859 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5860 if ( !af_3.getName().equals( "abcdef" ) ) {
5863 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5864 if ( !ag_3.getName().equals( "" ) ) {
5867 if ( !ag_3.isRoot() ) {
5870 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5871 if ( !al_3.getName().equals( "" ) ) {
5874 if ( !al_3.isRoot() ) {
5877 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5878 if ( !kl_3.getName().equals( "" ) ) {
5881 if ( !kl_3.isRoot() ) {
5884 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5885 if ( !fl_3.getName().equals( "" ) ) {
5888 if ( !fl_3.isRoot() ) {
5891 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5892 if ( !gk_3.getName().equals( "ghijk" ) ) {
5895 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5896 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5897 if ( !r_4.getName().equals( "r" ) ) {
5900 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5901 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5902 if ( !r_5.getName().equals( "root" ) ) {
5905 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5906 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5907 if ( !r_6.getName().equals( "rot" ) ) {
5910 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5911 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5912 if ( !r_7.getName().equals( "rott" ) ) {
5916 catch ( final Exception e ) {
5917 e.printStackTrace( System.out );
5923 private static boolean testGetLCA2() {
5925 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5926 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5927 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5928 PhylogenyMethods.preOrderReId( p_a );
5929 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5930 p_a.getNode( "a" ) );
5931 if ( !p_a_1.getName().equals( "a" ) ) {
5934 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5935 PhylogenyMethods.preOrderReId( p_b );
5936 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5937 p_b.getNode( "a" ) );
5938 if ( !p_b_1.getName().equals( "b" ) ) {
5941 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5942 p_b.getNode( "b" ) );
5943 if ( !p_b_2.getName().equals( "b" ) ) {
5946 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5947 PhylogenyMethods.preOrderReId( p_c );
5948 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5949 p_c.getNode( "a" ) );
5950 if ( !p_c_1.getName().equals( "b" ) ) {
5953 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5954 p_c.getNode( "c" ) );
5955 if ( !p_c_2.getName().equals( "c" ) ) {
5956 System.out.println( p_c_2.getName() );
5960 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5961 p_c.getNode( "b" ) );
5962 if ( !p_c_3.getName().equals( "b" ) ) {
5965 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5966 p_c.getNode( "a" ) );
5967 if ( !p_c_4.getName().equals( "c" ) ) {
5970 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5971 new NHXParser() )[ 0 ];
5972 PhylogenyMethods.preOrderReId( p1 );
5973 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5974 p1.getNode( "A" ) );
5975 if ( !A.getName().equals( "A" ) ) {
5978 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5979 p1.getNode( "gh" ) );
5980 if ( !gh.getName().equals( "gh" ) ) {
5983 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5984 p1.getNode( "B" ) );
5985 if ( !ab.getName().equals( "ab" ) ) {
5988 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5989 p1.getNode( "A" ) );
5990 if ( !ab2.getName().equals( "ab" ) ) {
5993 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5994 p1.getNode( "G" ) );
5995 if ( !gh2.getName().equals( "gh" ) ) {
5998 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5999 p1.getNode( "H" ) );
6000 if ( !gh3.getName().equals( "gh" ) ) {
6003 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
6004 p1.getNode( "A" ) );
6005 if ( !abc.getName().equals( "abc" ) ) {
6008 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6009 p1.getNode( "C" ) );
6010 if ( !abc2.getName().equals( "abc" ) ) {
6013 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6014 p1.getNode( "D" ) );
6015 if ( !abcd.getName().equals( "abcd" ) ) {
6018 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
6019 p1.getNode( "A" ) );
6020 if ( !abcd2.getName().equals( "abcd" ) ) {
6023 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6024 p1.getNode( "F" ) );
6025 if ( !abcdef.getName().equals( "abcdef" ) ) {
6028 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6029 p1.getNode( "A" ) );
6030 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6033 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6034 p1.getNode( "F" ) );
6035 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6038 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6039 p1.getNode( "ab" ) );
6040 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6043 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6044 p1.getNode( "E" ) );
6045 if ( !abcde.getName().equals( "abcde" ) ) {
6048 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6049 p1.getNode( "A" ) );
6050 if ( !abcde2.getName().equals( "abcde" ) ) {
6053 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6054 p1.getNode( "abcdefgh" ) );
6055 if ( !r.getName().equals( "abcdefgh" ) ) {
6058 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6059 p1.getNode( "H" ) );
6060 if ( !r2.getName().equals( "abcdefgh" ) ) {
6063 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6064 p1.getNode( "A" ) );
6065 if ( !r3.getName().equals( "abcdefgh" ) ) {
6068 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6069 p1.getNode( "abcde" ) );
6070 if ( !abcde3.getName().equals( "abcde" ) ) {
6073 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6074 p1.getNode( "E" ) );
6075 if ( !abcde4.getName().equals( "abcde" ) ) {
6078 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6079 p1.getNode( "B" ) );
6080 if ( !ab3.getName().equals( "ab" ) ) {
6083 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6084 p1.getNode( "ab" ) );
6085 if ( !ab4.getName().equals( "ab" ) ) {
6088 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6089 PhylogenyMethods.preOrderReId( p2 );
6090 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6091 p2.getNode( "d" ) );
6092 if ( !cd.getName().equals( "cd" ) ) {
6095 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6096 p2.getNode( "c" ) );
6097 if ( !cd2.getName().equals( "cd" ) ) {
6100 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6101 p2.getNode( "e" ) );
6102 if ( !cde.getName().equals( "cde" ) ) {
6105 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6106 p2.getNode( "c" ) );
6107 if ( !cde2.getName().equals( "cde" ) ) {
6110 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6111 p2.getNode( "f" ) );
6112 if ( !cdef.getName().equals( "cdef" ) ) {
6115 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6116 p2.getNode( "f" ) );
6117 if ( !cdef2.getName().equals( "cdef" ) ) {
6120 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6121 p2.getNode( "d" ) );
6122 if ( !cdef3.getName().equals( "cdef" ) ) {
6125 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6126 p2.getNode( "a" ) );
6127 if ( !rt.getName().equals( "r" ) ) {
6130 final Phylogeny p3 = factory
6131 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6132 new NHXParser() )[ 0 ];
6133 PhylogenyMethods.preOrderReId( p3 );
6134 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6135 p3.getNode( "c" ) );
6136 if ( !bc_3.getName().equals( "bc" ) ) {
6139 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6140 p3.getNode( "c" ) );
6141 if ( !ac_3.getName().equals( "abc" ) ) {
6144 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6145 p3.getNode( "d" ) );
6146 if ( !ad_3.getName().equals( "abcde" ) ) {
6149 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6150 p3.getNode( "f" ) );
6151 if ( !af_3.getName().equals( "abcdef" ) ) {
6154 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6155 p3.getNode( "g" ) );
6156 if ( !ag_3.getName().equals( "" ) ) {
6159 if ( !ag_3.isRoot() ) {
6162 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6163 p3.getNode( "l" ) );
6164 if ( !al_3.getName().equals( "" ) ) {
6167 if ( !al_3.isRoot() ) {
6170 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6171 p3.getNode( "l" ) );
6172 if ( !kl_3.getName().equals( "" ) ) {
6175 if ( !kl_3.isRoot() ) {
6178 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6179 p3.getNode( "l" ) );
6180 if ( !fl_3.getName().equals( "" ) ) {
6183 if ( !fl_3.isRoot() ) {
6186 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6187 p3.getNode( "k" ) );
6188 if ( !gk_3.getName().equals( "ghijk" ) ) {
6191 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6192 PhylogenyMethods.preOrderReId( p4 );
6193 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6194 p4.getNode( "c" ) );
6195 if ( !r_4.getName().equals( "r" ) ) {
6198 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6199 PhylogenyMethods.preOrderReId( p5 );
6200 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6201 p5.getNode( "c" ) );
6202 if ( !r_5.getName().equals( "root" ) ) {
6205 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6206 PhylogenyMethods.preOrderReId( p6 );
6207 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6208 p6.getNode( "a" ) );
6209 if ( !r_6.getName().equals( "rot" ) ) {
6212 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6213 PhylogenyMethods.preOrderReId( p7 );
6214 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6215 p7.getNode( "e" ) );
6216 if ( !r_7.getName().equals( "rott" ) ) {
6219 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6220 p7.getNode( "a" ) );
6221 if ( !r_71.getName().equals( "rott" ) ) {
6224 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6225 p7.getNode( "rott" ) );
6226 if ( !r_72.getName().equals( "rott" ) ) {
6229 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6230 p7.getNode( "a" ) );
6231 if ( !r_73.getName().equals( "rott" ) ) {
6234 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6235 p7.getNode( "rott" ) );
6236 if ( !r_74.getName().equals( "rott" ) ) {
6239 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6240 p7.getNode( "e" ) );
6241 if ( !r_75.getName().equals( "e" ) ) {
6245 catch ( final Exception e ) {
6246 e.printStackTrace( System.out );
6252 private static boolean testHmmscanOutputParser() {
6253 final String test_dir = Test.PATH_TO_TEST_DATA;
6255 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6256 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6258 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6259 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6260 final List<Protein> proteins = parser2.parse();
6261 if ( parser2.getProteinsEncountered() != 4 ) {
6264 if ( proteins.size() != 4 ) {
6267 if ( parser2.getDomainsEncountered() != 69 ) {
6270 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6273 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6276 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6279 final Protein p1 = proteins.get( 0 );
6280 if ( p1.getNumberOfProteinDomains() != 15 ) {
6283 if ( p1.getLength() != 850 ) {
6286 final Protein p2 = proteins.get( 1 );
6287 if ( p2.getNumberOfProteinDomains() != 51 ) {
6290 if ( p2.getLength() != 1291 ) {
6293 final Protein p3 = proteins.get( 2 );
6294 if ( p3.getNumberOfProteinDomains() != 2 ) {
6297 final Protein p4 = proteins.get( 3 );
6298 if ( p4.getNumberOfProteinDomains() != 1 ) {
6301 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6304 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6307 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6310 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6313 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6316 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6319 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6323 catch ( final Exception e ) {
6324 e.printStackTrace( System.out );
6330 private static boolean testLastExternalNodeMethods() {
6332 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6333 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6334 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6335 final PhylogenyNode n1 = t0.getNode( "A" );
6336 if ( n1.isLastExternalNode() ) {
6339 final PhylogenyNode n2 = t0.getNode( "B" );
6340 if ( n2.isLastExternalNode() ) {
6343 final PhylogenyNode n3 = t0.getNode( "C" );
6344 if ( n3.isLastExternalNode() ) {
6347 final PhylogenyNode n4 = t0.getNode( "D" );
6348 if ( !n4.isLastExternalNode() ) {
6352 catch ( final Exception e ) {
6353 e.printStackTrace( System.out );
6359 private static boolean testLevelOrderIterator() {
6361 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6362 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6363 PhylogenyNodeIterator it0;
6364 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6367 for( it0.reset(); it0.hasNext(); ) {
6370 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6371 if ( !it.next().getName().equals( "r" ) ) {
6374 if ( !it.next().getName().equals( "ab" ) ) {
6377 if ( !it.next().getName().equals( "cd" ) ) {
6380 if ( !it.next().getName().equals( "A" ) ) {
6383 if ( !it.next().getName().equals( "B" ) ) {
6386 if ( !it.next().getName().equals( "C" ) ) {
6389 if ( !it.next().getName().equals( "D" ) ) {
6392 if ( it.hasNext() ) {
6395 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",
6396 new NHXParser() )[ 0 ];
6397 PhylogenyNodeIterator it2;
6398 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6401 for( it2.reset(); it2.hasNext(); ) {
6404 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6405 if ( !it3.next().getName().equals( "r" ) ) {
6408 if ( !it3.next().getName().equals( "abc" ) ) {
6411 if ( !it3.next().getName().equals( "defg" ) ) {
6414 if ( !it3.next().getName().equals( "A" ) ) {
6417 if ( !it3.next().getName().equals( "B" ) ) {
6420 if ( !it3.next().getName().equals( "C" ) ) {
6423 if ( !it3.next().getName().equals( "D" ) ) {
6426 if ( !it3.next().getName().equals( "E" ) ) {
6429 if ( !it3.next().getName().equals( "F" ) ) {
6432 if ( !it3.next().getName().equals( "G" ) ) {
6435 if ( !it3.next().getName().equals( "1" ) ) {
6438 if ( !it3.next().getName().equals( "2" ) ) {
6441 if ( !it3.next().getName().equals( "3" ) ) {
6444 if ( !it3.next().getName().equals( "4" ) ) {
6447 if ( !it3.next().getName().equals( "5" ) ) {
6450 if ( !it3.next().getName().equals( "6" ) ) {
6453 if ( !it3.next().getName().equals( "f1" ) ) {
6456 if ( !it3.next().getName().equals( "f2" ) ) {
6459 if ( !it3.next().getName().equals( "f3" ) ) {
6462 if ( !it3.next().getName().equals( "a" ) ) {
6465 if ( !it3.next().getName().equals( "b" ) ) {
6468 if ( !it3.next().getName().equals( "f21" ) ) {
6471 if ( !it3.next().getName().equals( "X" ) ) {
6474 if ( !it3.next().getName().equals( "Y" ) ) {
6477 if ( !it3.next().getName().equals( "Z" ) ) {
6480 if ( it3.hasNext() ) {
6483 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6484 PhylogenyNodeIterator it4;
6485 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6488 for( it4.reset(); it4.hasNext(); ) {
6491 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6492 if ( !it5.next().getName().equals( "r" ) ) {
6495 if ( !it5.next().getName().equals( "A" ) ) {
6498 if ( !it5.next().getName().equals( "B" ) ) {
6501 if ( !it5.next().getName().equals( "C" ) ) {
6504 if ( !it5.next().getName().equals( "D" ) ) {
6507 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6508 PhylogenyNodeIterator it6;
6509 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6512 for( it6.reset(); it6.hasNext(); ) {
6515 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6516 if ( !it7.next().getName().equals( "A" ) ) {
6519 if ( it.hasNext() ) {
6523 catch ( final Exception e ) {
6524 e.printStackTrace( System.out );
6530 private static boolean testMafft( final String path ) {
6532 final List<String> opts = new ArrayList<String>();
6533 opts.add( "--maxiterate" );
6535 opts.add( "--localpair" );
6536 opts.add( "--quiet" );
6538 final MsaInferrer mafft = Mafft.createInstance( path );
6539 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6540 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6543 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6547 catch ( final Exception e ) {
6548 e.printStackTrace( System.out );
6554 private static boolean testMidpointrooting() {
6556 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6557 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6558 PhylogenyMethods.midpointRoot( t0 );
6559 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6562 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6565 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6569 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",
6570 new NHXParser() )[ 0 ];
6571 if ( !t1.isRooted() ) {
6574 PhylogenyMethods.midpointRoot( t1 );
6575 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6578 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6581 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6584 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6587 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6590 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6593 t1.reRoot( t1.getNode( "A" ) );
6594 PhylogenyMethods.midpointRoot( t1 );
6595 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6598 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6601 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6604 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6607 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6611 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6615 catch ( final Exception e ) {
6616 e.printStackTrace( System.out );
6622 private static boolean testMsaQualityMethod() {
6624 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6625 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6626 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6627 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6628 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6633 final Msa msa = BasicMsa.createInstance( l );
6634 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6637 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6640 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6643 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6646 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6649 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6652 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6656 catch ( final Exception e ) {
6657 e.printStackTrace( System.out );
6663 private static boolean testMsaEntropy() {
6665 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6666 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6667 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6668 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6669 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6674 final Msa msa = BasicMsa.createInstance( l );
6675 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6677 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6678 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6679 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6680 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6681 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6682 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6683 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6684 // System.out.println();
6685 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6686 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6687 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6688 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6689 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6690 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6691 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6692 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6693 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6694 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6695 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6696 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6697 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6698 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6699 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6700 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6701 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6702 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6703 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6704 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6705 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6706 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6707 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6708 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6709 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6710 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6711 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6712 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6713 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6714 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6715 final Msa msa2 = BasicMsa.createInstance( l2 );
6716 // System.out.println();
6717 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6718 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6719 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6721 catch ( final Exception e ) {
6722 e.printStackTrace( System.out );
6728 private static boolean testDeleteableMsa() {
6730 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6731 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6732 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6733 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6734 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6735 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6736 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6743 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6744 dmsa0.deleteRow( "b", false );
6745 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6748 dmsa0.deleteRow( "e", false );
6749 dmsa0.deleteRow( "a", false );
6750 dmsa0.deleteRow( "f", false );
6751 if ( dmsa0.getLength() != 4 ) {
6754 if ( dmsa0.getNumberOfSequences() != 2 ) {
6757 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6760 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6763 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6766 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6769 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6772 dmsa0.deleteRow( "c", false );
6773 dmsa0.deleteRow( "d", false );
6774 if ( dmsa0.getNumberOfSequences() != 0 ) {
6778 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6779 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6780 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6781 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6782 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6783 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6784 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6791 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6792 dmsa1.deleteGapOnlyColumns();
6793 dmsa1.deleteRow( "a", false );
6794 dmsa1.deleteRow( "f", false );
6795 dmsa1.deleteRow( "d", false );
6796 dmsa1.deleteGapOnlyColumns();
6797 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6800 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6803 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6806 dmsa1.deleteRow( "c", false );
6807 dmsa1.deleteGapOnlyColumns();
6808 final Writer w0 = new StringWriter();
6809 dmsa1.write( w0, MSA_FORMAT.FASTA );
6810 final Writer w1 = new StringWriter();
6811 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6812 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6815 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6818 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6819 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6820 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6821 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6822 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6823 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6824 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6831 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6832 dmsa2.deleteGapColumns( 0.5 );
6833 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6836 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6839 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6842 dmsa2.deleteGapColumns( 0.2 );
6843 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6846 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6849 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6852 dmsa2.deleteGapColumns( 0 );
6853 dmsa2.deleteRow( "a", false );
6854 dmsa2.deleteRow( "b", false );
6855 dmsa2.deleteRow( "f", false );
6856 dmsa2.deleteRow( "e", false );
6857 dmsa2.setIdentifier( 0, "new_c" );
6858 dmsa2.setIdentifier( 1, "new_d" );
6859 dmsa2.setResidueAt( 0, 0, 'x' );
6860 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6861 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6864 final Writer w = new StringWriter();
6865 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6866 final String phylip = w.toString();
6867 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6868 System.out.println( phylip );
6871 final Writer w2 = new StringWriter();
6872 dmsa2.write( w2, MSA_FORMAT.FASTA );
6873 final String fasta = w2.toString();
6874 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6875 System.out.println( fasta );
6879 catch ( final Exception e ) {
6880 e.printStackTrace( System.out );
6886 private static boolean testNextNodeWithCollapsing() {
6888 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6890 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6891 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6892 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
6893 t0.getNode( "cd" ).setCollapse( true );
6894 t0.getNode( "cde" ).setCollapse( true );
6895 n = t0.getFirstExternalNode();
6896 while ( n != null ) {
6898 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6900 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6903 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6906 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6909 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6912 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6915 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6919 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6920 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
6921 t1.getNode( "ab" ).setCollapse( true );
6922 t1.getNode( "cd" ).setCollapse( true );
6923 t1.getNode( "cde" ).setCollapse( true );
6924 n = t1.getNode( "ab" );
6925 ext = new ArrayList<PhylogenyNode>();
6926 while ( n != null ) {
6928 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6930 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6933 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6936 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6939 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6942 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6946 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6947 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
6948 t2.getNode( "ab" ).setCollapse( true );
6949 t2.getNode( "cd" ).setCollapse( true );
6950 t2.getNode( "cde" ).setCollapse( true );
6951 t2.getNode( "c" ).setCollapse( true );
6952 t2.getNode( "d" ).setCollapse( true );
6953 t2.getNode( "e" ).setCollapse( true );
6954 t2.getNode( "gh" ).setCollapse( true );
6955 n = t2.getNode( "ab" );
6956 ext = new ArrayList<PhylogenyNode>();
6957 while ( n != null ) {
6959 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6961 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6964 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6967 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6970 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6974 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6975 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
6976 t3.getNode( "ab" ).setCollapse( true );
6977 t3.getNode( "cd" ).setCollapse( true );
6978 t3.getNode( "cde" ).setCollapse( true );
6979 t3.getNode( "c" ).setCollapse( true );
6980 t3.getNode( "d" ).setCollapse( true );
6981 t3.getNode( "e" ).setCollapse( true );
6982 t3.getNode( "gh" ).setCollapse( true );
6983 t3.getNode( "fgh" ).setCollapse( true );
6984 n = t3.getNode( "ab" );
6985 ext = new ArrayList<PhylogenyNode>();
6986 while ( n != null ) {
6988 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6990 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6993 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6996 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
7000 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7001 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
7002 t4.getNode( "ab" ).setCollapse( true );
7003 t4.getNode( "cd" ).setCollapse( true );
7004 t4.getNode( "cde" ).setCollapse( true );
7005 t4.getNode( "c" ).setCollapse( true );
7006 t4.getNode( "d" ).setCollapse( true );
7007 t4.getNode( "e" ).setCollapse( true );
7008 t4.getNode( "gh" ).setCollapse( true );
7009 t4.getNode( "fgh" ).setCollapse( true );
7010 t4.getNode( "abcdefgh" ).setCollapse( true );
7011 n = t4.getNode( "abcdefgh" );
7012 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
7015 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7016 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
7018 n = t5.getFirstExternalNode();
7019 while ( n != null ) {
7021 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7023 if ( ext.size() != 8 ) {
7026 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7029 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7032 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7035 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7038 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7041 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7044 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7047 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7050 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7051 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7053 t6.getNode( "ab" ).setCollapse( true );
7054 n = t6.getNode( "ab" );
7055 while ( n != null ) {
7057 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7059 if ( ext.size() != 7 ) {
7062 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7065 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7068 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7071 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7074 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7077 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7080 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7083 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7084 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7086 t7.getNode( "cd" ).setCollapse( true );
7087 n = t7.getNode( "a" );
7088 while ( n != null ) {
7090 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7092 if ( ext.size() != 7 ) {
7095 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7098 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7101 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7104 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7107 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7110 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7113 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7116 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7117 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7119 t8.getNode( "cd" ).setCollapse( true );
7120 t8.getNode( "c" ).setCollapse( true );
7121 t8.getNode( "d" ).setCollapse( true );
7122 n = t8.getNode( "a" );
7123 while ( n != null ) {
7125 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7127 if ( ext.size() != 7 ) {
7130 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7133 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7136 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7137 System.out.println( "2 fail" );
7140 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7143 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7146 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7149 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7152 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7153 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7155 t9.getNode( "gh" ).setCollapse( true );
7156 n = t9.getNode( "a" );
7157 while ( n != null ) {
7159 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7161 if ( ext.size() != 7 ) {
7164 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7167 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7170 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7173 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7176 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7179 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7182 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7185 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7186 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7188 t10.getNode( "gh" ).setCollapse( true );
7189 t10.getNode( "g" ).setCollapse( true );
7190 t10.getNode( "h" ).setCollapse( true );
7191 n = t10.getNode( "a" );
7192 while ( n != null ) {
7194 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7196 if ( ext.size() != 7 ) {
7199 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7202 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7205 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7208 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7211 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7214 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7217 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7220 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7221 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7223 t11.getNode( "gh" ).setCollapse( true );
7224 t11.getNode( "fgh" ).setCollapse( true );
7225 n = t11.getNode( "a" );
7226 while ( n != null ) {
7228 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7230 if ( ext.size() != 6 ) {
7233 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7236 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7239 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7242 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7245 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7248 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7251 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7252 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7254 t12.getNode( "gh" ).setCollapse( true );
7255 t12.getNode( "fgh" ).setCollapse( true );
7256 t12.getNode( "g" ).setCollapse( true );
7257 t12.getNode( "h" ).setCollapse( true );
7258 t12.getNode( "f" ).setCollapse( true );
7259 n = t12.getNode( "a" );
7260 while ( n != null ) {
7262 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7264 if ( ext.size() != 6 ) {
7267 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7270 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7273 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7276 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7279 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7282 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7285 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7286 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7288 t13.getNode( "ab" ).setCollapse( true );
7289 t13.getNode( "b" ).setCollapse( true );
7290 t13.getNode( "fgh" ).setCollapse( true );
7291 t13.getNode( "gh" ).setCollapse( true );
7292 n = t13.getNode( "ab" );
7293 while ( n != null ) {
7295 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7297 if ( ext.size() != 5 ) {
7300 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7303 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7306 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7309 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7312 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7315 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7316 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7318 t14.getNode( "ab" ).setCollapse( true );
7319 t14.getNode( "a" ).setCollapse( true );
7320 t14.getNode( "fgh" ).setCollapse( true );
7321 t14.getNode( "gh" ).setCollapse( true );
7322 n = t14.getNode( "ab" );
7323 while ( n != null ) {
7325 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7327 if ( ext.size() != 5 ) {
7330 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7333 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7336 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7339 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7342 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7345 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" );
7346 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7348 t15.getNode( "ab" ).setCollapse( true );
7349 t15.getNode( "a" ).setCollapse( true );
7350 t15.getNode( "fgh" ).setCollapse( true );
7351 t15.getNode( "gh" ).setCollapse( true );
7352 n = t15.getNode( "ab" );
7353 while ( n != null ) {
7355 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7357 if ( ext.size() != 6 ) {
7360 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7363 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7366 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7369 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7372 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7375 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7380 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" );
7381 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7383 t16.getNode( "ab" ).setCollapse( true );
7384 t16.getNode( "a" ).setCollapse( true );
7385 t16.getNode( "fgh" ).setCollapse( true );
7386 t16.getNode( "gh" ).setCollapse( true );
7387 t16.getNode( "cd" ).setCollapse( true );
7388 t16.getNode( "cde" ).setCollapse( true );
7389 t16.getNode( "d" ).setCollapse( true );
7390 t16.getNode( "x" ).setCollapse( true );
7391 n = t16.getNode( "ab" );
7392 while ( n != null ) {
7394 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7396 if ( ext.size() != 4 ) {
7399 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7402 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7405 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7408 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7412 catch ( final Exception e ) {
7413 e.printStackTrace( System.out );
7419 private static boolean testNexusCharactersParsing() {
7421 final NexusCharactersParser parser = new NexusCharactersParser();
7422 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7424 String[] labels = parser.getCharStateLabels();
7425 if ( labels.length != 7 ) {
7428 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7431 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7434 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7437 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7440 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7443 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7446 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7449 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7451 labels = parser.getCharStateLabels();
7452 if ( labels.length != 7 ) {
7455 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7458 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7461 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7464 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7467 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7470 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7473 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7477 catch ( final Exception e ) {
7478 e.printStackTrace( System.out );
7484 private static boolean testNexusMatrixParsing() {
7486 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7487 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7489 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7490 if ( m.getNumberOfCharacters() != 9 ) {
7493 if ( m.getNumberOfIdentifiers() != 5 ) {
7496 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7499 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7502 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7505 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7508 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7511 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7514 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7517 // if ( labels.length != 7 ) {
7520 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7523 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7526 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7529 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7532 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7535 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7538 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7541 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7543 // labels = parser.getCharStateLabels();
7544 // if ( labels.length != 7 ) {
7547 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7550 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7553 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7556 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7559 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7562 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7565 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7569 catch ( final Exception e ) {
7570 e.printStackTrace( System.out );
7576 private static boolean testNexusTreeParsing() {
7578 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7579 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7580 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7581 if ( phylogenies.length != 1 ) {
7584 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7587 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7591 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7592 if ( phylogenies.length != 1 ) {
7595 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7598 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7602 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7603 if ( phylogenies.length != 1 ) {
7606 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7609 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7612 if ( phylogenies[ 0 ].isRooted() ) {
7616 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7617 if ( phylogenies.length != 18 ) {
7620 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7623 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7626 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7629 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7632 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7635 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7638 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7641 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7644 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7647 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7650 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7653 if ( phylogenies[ 8 ].isRooted() ) {
7656 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7659 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7662 if ( !phylogenies[ 9 ].isRooted() ) {
7665 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7668 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7671 if ( !phylogenies[ 10 ].isRooted() ) {
7674 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7677 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7680 if ( phylogenies[ 11 ].isRooted() ) {
7683 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7686 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7689 if ( !phylogenies[ 12 ].isRooted() ) {
7692 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7695 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7698 if ( !phylogenies[ 13 ].isRooted() ) {
7701 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7704 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7707 if ( !phylogenies[ 14 ].isRooted() ) {
7710 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7713 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7716 if ( phylogenies[ 15 ].isRooted() ) {
7719 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7722 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7725 if ( !phylogenies[ 16 ].isRooted() ) {
7728 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7731 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7734 if ( phylogenies[ 17 ].isRooted() ) {
7737 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7740 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7742 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7743 if ( phylogenies.length != 9 ) {
7746 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7747 .getDistanceToParent() ) ) {
7750 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7751 .getDistanceToParent() ) ) {
7754 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7757 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7760 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7763 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7766 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7770 catch ( final Exception e ) {
7771 e.printStackTrace( System.out );
7777 private static boolean testNexusTreeParsingIterating() {
7779 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7780 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7781 if ( !p.hasNext() ) {
7784 Phylogeny phy = p.next();
7785 if ( phy == null ) {
7788 if ( phy.getNumberOfExternalNodes() != 25 ) {
7791 if ( !phy.getName().equals( "" ) ) {
7794 if ( p.hasNext() ) {
7798 if ( phy != null ) {
7802 if ( !p.hasNext() ) {
7806 if ( phy == null ) {
7809 if ( phy.getNumberOfExternalNodes() != 25 ) {
7812 if ( !phy.getName().equals( "" ) ) {
7815 if ( p.hasNext() ) {
7819 if ( phy != null ) {
7822 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7823 if ( !p.hasNext() ) {
7827 if ( phy == null ) {
7830 if ( phy.getNumberOfExternalNodes() != 10 ) {
7833 if ( !phy.getName().equals( "name" ) ) {
7836 if ( p.hasNext() ) {
7840 if ( phy != null ) {
7844 if ( !p.hasNext() ) {
7848 if ( phy == null ) {
7851 if ( phy.getNumberOfExternalNodes() != 10 ) {
7854 if ( !phy.getName().equals( "name" ) ) {
7857 if ( p.hasNext() ) {
7861 if ( phy != null ) {
7864 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7865 if ( !p.hasNext() ) {
7869 if ( phy == null ) {
7872 if ( phy.getNumberOfExternalNodes() != 3 ) {
7875 if ( !phy.getName().equals( "" ) ) {
7878 if ( phy.isRooted() ) {
7881 if ( p.hasNext() ) {
7885 if ( phy != null ) {
7890 if ( !p.hasNext() ) {
7894 if ( phy == null ) {
7897 if ( phy.getNumberOfExternalNodes() != 3 ) {
7900 if ( !phy.getName().equals( "" ) ) {
7903 if ( p.hasNext() ) {
7907 if ( phy != null ) {
7911 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7912 if ( !p.hasNext() ) {
7917 if ( phy == null ) {
7920 if ( phy.getNumberOfExternalNodes() != 10 ) {
7923 if ( !phy.getName().equals( "tree 0" ) ) {
7927 if ( !p.hasNext() ) {
7931 if ( phy == null ) {
7934 if ( phy.getNumberOfExternalNodes() != 10 ) {
7937 if ( !phy.getName().equals( "tree 1" ) ) {
7941 if ( !p.hasNext() ) {
7945 if ( phy == null ) {
7948 if ( phy.getNumberOfExternalNodes() != 3 ) {
7949 System.out.println( phy.toString() );
7952 if ( !phy.getName().equals( "" ) ) {
7955 if ( phy.isRooted() ) {
7959 if ( !p.hasNext() ) {
7963 if ( phy == null ) {
7966 if ( phy.getNumberOfExternalNodes() != 4 ) {
7969 if ( !phy.getName().equals( "" ) ) {
7972 if ( !phy.isRooted() ) {
7976 if ( !p.hasNext() ) {
7980 if ( phy == null ) {
7983 if ( phy.getNumberOfExternalNodes() != 5 ) {
7984 System.out.println( phy.getNumberOfExternalNodes() );
7987 if ( !phy.getName().equals( "" ) ) {
7990 if ( !phy.isRooted() ) {
7994 if ( !p.hasNext() ) {
7998 if ( phy == null ) {
8001 if ( phy.getNumberOfExternalNodes() != 3 ) {
8004 if ( !phy.getName().equals( "" ) ) {
8007 if ( phy.isRooted() ) {
8011 if ( !p.hasNext() ) {
8015 if ( phy == null ) {
8018 if ( phy.getNumberOfExternalNodes() != 2 ) {
8021 if ( !phy.getName().equals( "" ) ) {
8024 if ( !phy.isRooted() ) {
8028 if ( !p.hasNext() ) {
8032 if ( phy.getNumberOfExternalNodes() != 3 ) {
8035 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8038 if ( !phy.isRooted() ) {
8042 if ( !p.hasNext() ) {
8046 if ( phy.getNumberOfExternalNodes() != 3 ) {
8049 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8052 if ( !phy.getName().equals( "tree 8" ) ) {
8056 if ( !p.hasNext() ) {
8060 if ( phy.getNumberOfExternalNodes() != 3 ) {
8063 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8066 if ( !phy.getName().equals( "tree 9" ) ) {
8070 if ( !p.hasNext() ) {
8074 if ( phy.getNumberOfExternalNodes() != 3 ) {
8077 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8080 if ( !phy.getName().equals( "tree 10" ) ) {
8083 if ( !phy.isRooted() ) {
8087 if ( !p.hasNext() ) {
8091 if ( phy.getNumberOfExternalNodes() != 3 ) {
8094 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8097 if ( !phy.getName().equals( "tree 11" ) ) {
8100 if ( phy.isRooted() ) {
8104 if ( !p.hasNext() ) {
8108 if ( phy.getNumberOfExternalNodes() != 3 ) {
8111 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8114 if ( !phy.getName().equals( "tree 12" ) ) {
8117 if ( !phy.isRooted() ) {
8121 if ( !p.hasNext() ) {
8125 if ( phy.getNumberOfExternalNodes() != 3 ) {
8128 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8131 if ( !phy.getName().equals( "tree 13" ) ) {
8134 if ( !phy.isRooted() ) {
8138 if ( !p.hasNext() ) {
8142 if ( phy.getNumberOfExternalNodes() != 10 ) {
8143 System.out.println( phy.getNumberOfExternalNodes() );
8148 .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;" ) ) {
8149 System.out.println( phy.toNewHampshire() );
8152 if ( !phy.getName().equals( "tree 14" ) ) {
8155 if ( !phy.isRooted() ) {
8159 if ( !p.hasNext() ) {
8163 if ( phy.getNumberOfExternalNodes() != 10 ) {
8164 System.out.println( phy.getNumberOfExternalNodes() );
8169 .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;" ) ) {
8170 System.out.println( phy.toNewHampshire() );
8173 if ( !phy.getName().equals( "tree 15" ) ) {
8176 if ( phy.isRooted() ) {
8180 if ( !p.hasNext() ) {
8184 if ( phy.getNumberOfExternalNodes() != 10 ) {
8185 System.out.println( phy.getNumberOfExternalNodes() );
8190 .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;" ) ) {
8191 System.out.println( phy.toNewHampshire() );
8194 if ( !phy.getName().equals( "tree 16" ) ) {
8197 if ( !phy.isRooted() ) {
8201 if ( !p.hasNext() ) {
8205 if ( phy.getNumberOfExternalNodes() != 10 ) {
8206 System.out.println( phy.getNumberOfExternalNodes() );
8211 .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;" ) ) {
8212 System.out.println( phy.toNewHampshire() );
8215 if ( !phy.getName().equals( "tree 17" ) ) {
8218 if ( phy.isRooted() ) {
8222 if ( p.hasNext() ) {
8226 if ( phy != null ) {
8231 if ( !p.hasNext() ) {
8235 if ( phy == null ) {
8238 if ( phy.getNumberOfExternalNodes() != 10 ) {
8241 if ( !phy.getName().equals( "tree 0" ) ) {
8245 if ( !p.hasNext() ) {
8249 if ( phy == null ) {
8252 if ( phy.getNumberOfExternalNodes() != 10 ) {
8255 if ( !phy.getName().equals( "tree 1" ) ) {
8259 if ( !p.hasNext() ) {
8263 if ( phy == null ) {
8266 if ( phy.getNumberOfExternalNodes() != 3 ) {
8269 if ( !phy.getName().equals( "" ) ) {
8272 if ( phy.isRooted() ) {
8276 if ( !p.hasNext() ) {
8280 if ( phy == null ) {
8283 if ( phy.getNumberOfExternalNodes() != 4 ) {
8286 if ( !phy.getName().equals( "" ) ) {
8289 if ( !phy.isRooted() ) {
8293 if ( !p.hasNext() ) {
8297 if ( phy == null ) {
8300 if ( phy.getNumberOfExternalNodes() != 5 ) {
8301 System.out.println( phy.getNumberOfExternalNodes() );
8304 if ( !phy.getName().equals( "" ) ) {
8307 if ( !phy.isRooted() ) {
8311 if ( !p.hasNext() ) {
8315 if ( phy == null ) {
8318 if ( phy.getNumberOfExternalNodes() != 3 ) {
8321 if ( !phy.getName().equals( "" ) ) {
8324 if ( phy.isRooted() ) {
8328 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8329 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8331 if ( !p2.hasNext() ) {
8335 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8338 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8342 if ( !p2.hasNext() ) {
8347 if ( !p2.hasNext() ) {
8352 if ( !p2.hasNext() ) {
8357 if ( !p2.hasNext() ) {
8362 if ( !p2.hasNext() ) {
8367 if ( !p2.hasNext() ) {
8372 if ( !p2.hasNext() ) {
8377 if ( !p2.hasNext() ) {
8381 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8384 if ( p2.hasNext() ) {
8388 if ( phy != null ) {
8393 if ( !p2.hasNext() ) {
8397 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8400 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8404 catch ( final Exception e ) {
8405 e.printStackTrace( System.out );
8411 private static boolean testNexusTreeParsingTranslating() {
8413 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8414 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8415 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8416 if ( phylogenies.length != 1 ) {
8419 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8422 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8425 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8428 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8431 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8432 .equals( "Aranaeus" ) ) {
8436 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8437 if ( phylogenies.length != 3 ) {
8440 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8443 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8446 if ( phylogenies[ 0 ].isRooted() ) {
8449 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8452 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8455 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8456 .equals( "Aranaeus" ) ) {
8459 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8462 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8465 if ( phylogenies[ 1 ].isRooted() ) {
8468 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8471 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8474 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8475 .equals( "Aranaeus" ) ) {
8478 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8481 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8484 if ( !phylogenies[ 2 ].isRooted() ) {
8487 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8490 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8493 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8494 .equals( "Aranaeus" ) ) {
8498 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8499 if ( phylogenies.length != 3 ) {
8502 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8505 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8508 if ( phylogenies[ 0 ].isRooted() ) {
8511 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8514 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8517 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8518 .equals( "Aranaeus" ) ) {
8521 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8524 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8527 if ( phylogenies[ 1 ].isRooted() ) {
8530 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8533 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8536 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8537 .equals( "Aranaeus" ) ) {
8540 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8543 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8546 if ( !phylogenies[ 2 ].isRooted() ) {
8549 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8552 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8555 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8556 .equals( "Aranaeus" ) ) {
8559 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8560 if ( phylogenies.length != 3 ) {
8563 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8568 catch ( final Exception e ) {
8569 e.printStackTrace( System.out );
8575 private static boolean testNHParsing() {
8577 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8578 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8579 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8582 final NHXParser nhxp = new NHXParser();
8583 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8584 nhxp.setReplaceUnderscores( true );
8585 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8586 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8589 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8592 final Phylogeny p1b = factory
8593 .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 ",
8594 new NHXParser() )[ 0 ];
8595 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8598 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8601 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8602 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8603 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8604 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8605 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8606 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8607 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8608 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8609 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8610 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8611 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8612 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8613 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8615 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8618 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8621 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8624 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8627 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8628 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8629 final String p16_S = "((A,B),C)";
8630 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8631 if ( p16.length != 1 ) {
8634 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8637 final String p17_S = "(C,(A,B))";
8638 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8639 if ( p17.length != 1 ) {
8642 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8645 final String p18_S = "((A,B),(C,D))";
8646 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8647 if ( p18.length != 1 ) {
8650 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8653 final String p19_S = "(((A,B),C),D)";
8654 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8655 if ( p19.length != 1 ) {
8658 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8661 final String p20_S = "(A,(B,(C,D)))";
8662 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8663 if ( p20.length != 1 ) {
8666 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8669 final String p21_S = "(A,(B,(C,(D,E))))";
8670 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8671 if ( p21.length != 1 ) {
8674 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8677 final String p22_S = "((((A,B),C),D),E)";
8678 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8679 if ( p22.length != 1 ) {
8682 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8685 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8686 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8687 if ( p23.length != 1 ) {
8688 System.out.println( "xl=" + p23.length );
8692 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8695 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8696 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8697 if ( p24.length != 1 ) {
8700 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8703 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8704 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8705 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8706 if ( p241.length != 2 ) {
8709 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8712 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8715 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8716 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8717 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8718 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8719 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8720 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8721 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8722 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8723 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8724 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8727 final String p26_S = "(A,B)ab";
8728 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8729 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8732 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8733 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8734 if ( p27s.length != 1 ) {
8735 System.out.println( "xxl=" + p27s.length );
8739 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8740 System.out.println( p27s[ 0 ].toNewHampshireX() );
8744 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8746 if ( p27.length != 1 ) {
8747 System.out.println( "yl=" + p27.length );
8751 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8752 System.out.println( p27[ 0 ].toNewHampshireX() );
8756 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8757 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8758 final String p28_S3 = "(A,B)ab";
8759 final String p28_S4 = "((((A,B),C),D),;E;)";
8760 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8762 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8765 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8768 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8771 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8774 if ( p28.length != 4 ) {
8777 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";
8778 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8779 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8782 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";
8783 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8784 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8787 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8788 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8789 if ( ( p32.length != 0 ) ) {
8792 final String p33_S = "A";
8793 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8794 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8797 final String p34_S = "B;";
8798 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8799 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8802 final String p35_S = "B:0.2";
8803 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8804 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8807 final String p36_S = "(A)";
8808 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8809 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8812 final String p37_S = "((A))";
8813 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8814 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8817 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8818 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8819 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8822 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8823 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8824 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8827 final String p40_S = "(A,B,C)";
8828 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8829 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8832 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8833 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8834 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8837 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8838 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8839 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8842 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)";
8843 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8844 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8847 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)))";
8848 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8849 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8852 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8853 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8854 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8857 final String p46_S = "";
8858 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8859 if ( p46.length != 0 ) {
8862 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(), new NHXParser() )[ 0 ];
8863 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8866 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8867 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8870 final Phylogeny p49 = factory
8871 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
8872 new NHXParser() )[ 0 ];
8873 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8876 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8877 if ( p50.getNode( "A" ) == null ) {
8880 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8881 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8884 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8887 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8888 .equals( "((A,B)88:2.0,C);" ) ) {
8891 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8892 if ( p51.getNode( "A(A" ) == null ) {
8895 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8896 if ( p52.getNode( "A(A" ) == null ) {
8899 final Phylogeny p53 = factory
8900 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
8901 new NHXParser() )[ 0 ];
8902 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8905 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(), new NHXParser() )[ 0 ];
8906 if ( p54.getNode( "A" ) == null ) {
8909 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8912 final Phylogeny p55 = factory
8913 .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(),
8914 new NHXParser() )[ 0 ];
8917 .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);" ) ) {
8918 System.out.println( p55.toNewHampshire() );
8921 final Phylogeny p56 = factory
8922 .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(),
8923 new NHXParser() )[ 0 ];
8926 .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);" ) ) {
8927 System.out.println( p56.toNewHampshire() );
8930 final Phylogeny p57 = factory
8931 .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(),
8932 new NHXParser() )[ 0 ];
8935 .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);" ) ) {
8936 System.out.println( p56.toNewHampshire() );
8939 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8940 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
8941 if ( !p58.toNewHampshire().equals( s58 ) ) {
8942 System.out.println( p58.toNewHampshire() );
8945 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8946 final Phylogeny p59 = factory.create( s59 , new NHXParser() )[ 0 ];
8947 if ( !p59.toNewHampshire().equals( s59 ) ) {
8948 System.out.println( p59.toNewHampshire() );
8951 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8952 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
8953 if ( !p60.toNewHampshire().equals( s60 ) ) {
8954 System.out.println( p60.toNewHampshire() );
8957 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8958 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
8959 if ( !p61.toNewHampshire()
8960 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8961 System.out.println( p61.toNewHampshire() );
8964 final String s62 = "(1[&type=\"X\",size=123,subtree=(1,2);]:0.003,2[&type=\"(X,Y:3)\"]:0.004)[&type=\"(X,Y)\"]:0.0;";
8965 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
8966 if ( !p62.toNewHampshire()
8967 .equals( "(1:0.003,2:0.004):0.0;" ) ) {
8968 System.out.println( p62.toNewHampshire() );
8971 final String s63 = "(1:0.003[&type=\"X\",size=123,subtree=(1,2);],2:0.004[&type=\"(X,Y:3)\"]):0.0[&type=\"(X,Y)\"];";
8972 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
8973 if ( !p63.toNewHampshire()
8974 .equals( "(1:0.003,2:0.004):0.0;" ) ) {
8975 System.out.println( p63.toNewHampshire() );
8978 final String s64 = "((1,2):[95.5],3);";
8979 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
8980 if ( !p64.toNewHampshireX()
8981 .equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
8982 System.out.println( p64.toNewHampshireX() );
8985 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
8986 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
8987 if ( !p65.toNewHampshireX()
8988 .equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
8989 System.out.println( p65.toNewHampshireX() );
8993 catch ( final Exception e ) {
8994 e.printStackTrace( System.out );
9000 private static boolean testNHParsingSpecialChars() {
9002 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9003 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
9004 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
9005 if ( !p0.toNewHampshireX().equals( i0 ) ) {
9006 System.out.println();
9007 System.out.println( p0.toNewHampshireX() );
9008 System.out.println( i0 );
9011 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
9012 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
9013 if ( !p1.toNewHampshireX().equals( i1 ) ) {
9014 System.out.println();
9015 System.out.println( p1.toNewHampshireX() );
9016 System.out.println( i1 );
9020 catch ( final Exception e ) {
9021 e.printStackTrace( System.out );
9029 private static boolean testNHParsingIter() {
9031 final String p0_str = "(A,B);";
9032 final NHXParser p = new NHXParser();
9033 p.setSource( p0_str );
9034 if ( !p.hasNext() ) {
9037 final Phylogeny p0 = p.next();
9038 if ( !p0.toNewHampshire().equals( p0_str ) ) {
9039 System.out.println( p0.toNewHampshire() );
9042 if ( p.hasNext() ) {
9045 if ( p.next() != null ) {
9049 final String p00_str = "(A,B)root;";
9050 p.setSource( p00_str );
9051 final Phylogeny p00 = p.next();
9052 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9053 System.out.println( p00.toNewHampshire() );
9057 final String p000_str = "A;";
9058 p.setSource( p000_str );
9059 final Phylogeny p000 = p.next();
9060 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9061 System.out.println( p000.toNewHampshire() );
9065 final String p0000_str = "A";
9066 p.setSource( p0000_str );
9067 final Phylogeny p0000 = p.next();
9068 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9069 System.out.println( p0000.toNewHampshire() );
9073 p.setSource( "(A)" );
9074 final Phylogeny p00000 = p.next();
9075 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9076 System.out.println( p00000.toNewHampshire() );
9080 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9081 p.setSource( p1_str );
9082 if ( !p.hasNext() ) {
9085 final Phylogeny p1_0 = p.next();
9086 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9087 System.out.println( p1_0.toNewHampshire() );
9090 if ( !p.hasNext() ) {
9093 final Phylogeny p1_1 = p.next();
9094 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9095 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9098 if ( !p.hasNext() ) {
9101 final Phylogeny p1_2 = p.next();
9102 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9103 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9106 if ( !p.hasNext() ) {
9109 final Phylogeny p1_3 = p.next();
9110 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9111 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9114 if ( p.hasNext() ) {
9117 if ( p.next() != null ) {
9121 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9122 p.setSource( p2_str );
9123 if ( !p.hasNext() ) {
9126 Phylogeny p2_0 = p.next();
9127 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9128 System.out.println( p2_0.toNewHampshire() );
9131 if ( !p.hasNext() ) {
9134 Phylogeny p2_1 = p.next();
9135 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9136 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9139 if ( !p.hasNext() ) {
9142 Phylogeny p2_2 = p.next();
9143 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9144 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9147 if ( !p.hasNext() ) {
9150 Phylogeny p2_3 = p.next();
9151 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9152 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9155 if ( !p.hasNext() ) {
9158 Phylogeny p2_4 = p.next();
9159 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9160 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9163 if ( p.hasNext() ) {
9166 if ( p.next() != null ) {
9171 if ( !p.hasNext() ) {
9175 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9176 System.out.println( p2_0.toNewHampshire() );
9179 if ( !p.hasNext() ) {
9183 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9184 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9187 if ( !p.hasNext() ) {
9191 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9192 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9195 if ( !p.hasNext() ) {
9199 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9200 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9203 if ( !p.hasNext() ) {
9207 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9208 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9211 if ( p.hasNext() ) {
9214 if ( p.next() != null ) {
9218 final String p3_str = "((A,B),C)abc";
9219 p.setSource( p3_str );
9220 if ( !p.hasNext() ) {
9223 final Phylogeny p3_0 = p.next();
9224 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9227 if ( p.hasNext() ) {
9230 if ( p.next() != null ) {
9234 final String p4_str = "((A,B)ab,C)abc";
9235 p.setSource( p4_str );
9236 if ( !p.hasNext() ) {
9239 final Phylogeny p4_0 = p.next();
9240 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9243 if ( p.hasNext() ) {
9246 if ( p.next() != null ) {
9250 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9251 p.setSource( p5_str );
9252 if ( !p.hasNext() ) {
9255 final Phylogeny p5_0 = p.next();
9256 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9259 if ( p.hasNext() ) {
9262 if ( p.next() != null ) {
9266 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9267 p.setSource( p6_str );
9268 if ( !p.hasNext() ) {
9271 Phylogeny p6_0 = p.next();
9272 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9275 if ( p.hasNext() ) {
9278 if ( p.next() != null ) {
9282 if ( !p.hasNext() ) {
9286 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9289 if ( p.hasNext() ) {
9292 if ( p.next() != null ) {
9296 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9297 p.setSource( p7_str );
9298 if ( !p.hasNext() ) {
9301 Phylogeny p7_0 = p.next();
9302 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9305 if ( p.hasNext() ) {
9308 if ( p.next() != null ) {
9312 if ( !p.hasNext() ) {
9316 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9319 if ( p.hasNext() ) {
9322 if ( p.next() != null ) {
9326 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9327 p.setSource( p8_str );
9328 if ( !p.hasNext() ) {
9331 Phylogeny p8_0 = p.next();
9332 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9335 if ( !p.hasNext() ) {
9338 if ( !p.hasNext() ) {
9341 Phylogeny p8_1 = p.next();
9342 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9345 if ( p.hasNext() ) {
9348 if ( p.next() != null ) {
9352 if ( !p.hasNext() ) {
9356 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9359 if ( !p.hasNext() ) {
9363 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9366 if ( p.hasNext() ) {
9369 if ( p.next() != null ) {
9375 if ( p.hasNext() ) {
9379 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9380 if ( !p.hasNext() ) {
9383 Phylogeny p_27 = p.next();
9384 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9385 System.out.println( p_27.toNewHampshireX() );
9389 if ( p.hasNext() ) {
9392 if ( p.next() != null ) {
9396 if ( !p.hasNext() ) {
9400 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9401 System.out.println( p_27.toNewHampshireX() );
9405 if ( p.hasNext() ) {
9408 if ( p.next() != null ) {
9412 final String p30_str = "(A,B);(C,D)";
9413 final NHXParser p30 = new NHXParser();
9414 p30.setSource( p30_str );
9415 if ( !p30.hasNext() ) {
9418 Phylogeny phy30 = p30.next();
9419 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9420 System.out.println( phy30.toNewHampshire() );
9423 if ( !p30.hasNext() ) {
9426 Phylogeny phy301 = p30.next();
9427 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9428 System.out.println( phy301.toNewHampshire() );
9431 if ( p30.hasNext() ) {
9434 if ( p30.hasNext() ) {
9437 if ( p30.next() != null ) {
9440 if ( p30.next() != null ) {
9444 if ( !p30.hasNext() ) {
9448 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9449 System.out.println( phy30.toNewHampshire() );
9452 if ( !p30.hasNext() ) {
9455 phy301 = p30.next();
9456 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9457 System.out.println( phy301.toNewHampshire() );
9460 if ( p30.hasNext() ) {
9463 if ( p30.hasNext() ) {
9466 if ( p30.next() != null ) {
9469 if ( p30.next() != null ) {
9473 catch ( final Exception e ) {
9474 e.printStackTrace( System.out );
9480 private static boolean testNHXconversion() {
9482 final PhylogenyNode n1 = new PhylogenyNode();
9483 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9484 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9485 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9486 final PhylogenyNode n5 = PhylogenyNode
9487 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9488 final PhylogenyNode n6 = PhylogenyNode
9489 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9490 if ( !n1.toNewHampshireX().equals( "" ) ) {
9493 if ( !n2.toNewHampshireX().equals( "" ) ) {
9496 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9499 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9502 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9505 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9506 System.out.println( n6.toNewHampshireX() );
9509 final PhylogenyNode n7 = new PhylogenyNode();
9510 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9511 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9512 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9513 System.out.println( n7
9514 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9518 catch ( final Exception e ) {
9519 e.printStackTrace( System.out );
9525 private static boolean testNHXNodeParsing() {
9527 final PhylogenyNode n1 = new PhylogenyNode();
9528 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9529 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9530 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9531 final PhylogenyNode n5 = PhylogenyNode
9532 .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]" );
9533 if ( !n3.getName().equals( "n3" ) ) {
9536 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9539 if ( n3.isDuplication() ) {
9542 if ( n3.isHasAssignedEvent() ) {
9545 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9548 if ( !n4.getName().equals( "n4" ) ) {
9551 if ( n4.getDistanceToParent() != 0.01 ) {
9554 if ( !n5.getName().equals( "n5" ) ) {
9557 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9560 if ( n5.getDistanceToParent() != 0.1 ) {
9563 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9566 if ( !n5.isDuplication() ) {
9569 if ( !n5.isHasAssignedEvent() ) {
9572 final PhylogenyNode n8 = PhylogenyNode
9573 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9574 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9575 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9578 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9581 final PhylogenyNode n9 = PhylogenyNode
9582 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9583 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9584 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9587 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9590 final PhylogenyNode n10 = PhylogenyNode
9591 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9592 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9595 final PhylogenyNode n20 = PhylogenyNode
9596 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9597 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9600 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9603 final PhylogenyNode n20x = PhylogenyNode
9604 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9605 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9608 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9611 final PhylogenyNode n20xx = PhylogenyNode
9612 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9613 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9616 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9619 final PhylogenyNode n20xxx = PhylogenyNode
9620 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9621 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9624 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9627 final PhylogenyNode n20xxxx = PhylogenyNode
9628 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9629 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9632 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9635 final PhylogenyNode n21 = PhylogenyNode
9636 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9637 if ( !n21.getName().equals( "N21_PIG" ) ) {
9640 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9643 final PhylogenyNode n21x = PhylogenyNode
9644 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9645 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9648 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9651 final PhylogenyNode n22 = PhylogenyNode
9652 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9653 if ( !n22.getName().equals( "n22/PIG" ) ) {
9656 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9659 final PhylogenyNode n23 = PhylogenyNode
9660 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9661 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9664 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9667 final PhylogenyNode a = PhylogenyNode
9668 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9669 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9672 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9675 final PhylogenyNode c1 = PhylogenyNode
9676 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9677 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9678 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9681 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9684 final PhylogenyNode c2 = PhylogenyNode
9685 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9686 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9687 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9690 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9693 final PhylogenyNode e3 = PhylogenyNode
9694 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9695 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9698 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9701 final PhylogenyNode n11 = PhylogenyNode
9702 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9703 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9704 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9707 if ( n11.getDistanceToParent() != 0.4 ) {
9710 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9713 final PhylogenyNode n12 = PhylogenyNode
9714 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9715 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9716 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9719 if ( n12.getDistanceToParent() != 0.4 ) {
9722 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9725 final PhylogenyNode o = PhylogenyNode
9726 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9727 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9730 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9733 if ( n1.getName().compareTo( "" ) != 0 ) {
9736 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9739 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9742 if ( n2.getName().compareTo( "" ) != 0 ) {
9745 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9748 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9751 final PhylogenyNode n00 = PhylogenyNode
9752 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9753 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9756 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9759 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9760 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9763 final PhylogenyNode n13 = PhylogenyNode
9764 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9765 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9768 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9771 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9774 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9777 final PhylogenyNode n14 = PhylogenyNode
9778 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9779 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9782 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9785 final PhylogenyNode n15 = PhylogenyNode
9786 .createInstanceFromNhxString( "something_wicked[123]",
9787 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9788 if ( !n15.getName().equals( "something_wicked" ) ) {
9791 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9794 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9797 final PhylogenyNode n16 = PhylogenyNode
9798 .createInstanceFromNhxString( "something_wicked2[9]",
9799 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9800 if ( !n16.getName().equals( "something_wicked2" ) ) {
9803 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9806 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9809 final PhylogenyNode n17 = PhylogenyNode
9810 .createInstanceFromNhxString( "something_wicked3[a]",
9811 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9812 if ( !n17.getName().equals( "something_wicked3" ) ) {
9815 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9818 final PhylogenyNode n18 = PhylogenyNode
9819 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9820 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9823 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9826 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9829 final PhylogenyNode n19 = PhylogenyNode
9830 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9831 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9834 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9837 final PhylogenyNode n30 = PhylogenyNode
9838 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9839 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9840 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9843 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9846 final PhylogenyNode n31 = PhylogenyNode
9847 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9848 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9849 if ( n31.getNodeData().isHasTaxonomy() ) {
9852 final PhylogenyNode n32 = PhylogenyNode
9853 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9854 if ( n32.getNodeData().isHasTaxonomy() ) {
9857 final PhylogenyNode n40 = PhylogenyNode
9858 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9859 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9862 final PhylogenyNode n41 = PhylogenyNode
9863 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9864 if ( n41.getNodeData().isHasTaxonomy() ) {
9867 final PhylogenyNode n42 = PhylogenyNode
9868 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9869 if ( n42.getNodeData().isHasTaxonomy() ) {
9872 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9873 NHXParser.TAXONOMY_EXTRACTION.NO );
9874 if ( n43.getNodeData().isHasTaxonomy() ) {
9877 final PhylogenyNode n44 = PhylogenyNode
9878 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9879 if ( n44.getNodeData().isHasTaxonomy() ) {
9883 catch ( final Exception e ) {
9884 e.printStackTrace( System.out );
9891 private static boolean testNHXNodeParsing2() {
9894 final PhylogenyNode n0_0 = PhylogenyNode
9895 .createInstanceFromNhxString( "n0:[ignore me 123]:1E-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9896 if ( !n0_0.getName().equals( "n0" ) ) {
9899 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
9902 final PhylogenyNode n0_1 = PhylogenyNode
9903 .createInstanceFromNhxString( "n0[ignore me 123]:1E-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9904 if ( !n0_1.getName().equals( "n0" ) ) {
9907 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
9910 final PhylogenyNode n0_2 = PhylogenyNode
9911 .createInstanceFromNhxString( "n0:1E-3[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9912 if ( !n0_2.getName().equals( "n0" ) ) {
9915 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
9918 final PhylogenyNode n0_3 = PhylogenyNode
9919 .createInstanceFromNhxString( "n0:1E-3:[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9920 if ( !n0_3.getName().equals( "n0" ) ) {
9923 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
9926 final PhylogenyNode n0_4 = PhylogenyNode
9927 .createInstanceFromNhxString( "n0:0.001:[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9928 if ( !n0_4.getName().equals( "n0" ) ) {
9931 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
9934 final PhylogenyNode n1_0 = PhylogenyNode
9935 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9936 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9939 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9942 final PhylogenyNode n1_1 = PhylogenyNode
9943 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9944 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9947 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9950 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
9953 final PhylogenyNode n1_2 = PhylogenyNode
9954 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9955 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9958 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9961 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
9964 final PhylogenyNode n1_3 = PhylogenyNode
9965 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9966 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9969 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9972 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
9975 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
9978 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
9981 final PhylogenyNode n1_4 = PhylogenyNode
9982 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9983 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9986 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9989 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
9992 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
9995 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
9998 final PhylogenyNode n1_5 = PhylogenyNode
9999 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
10000 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10003 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
10006 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10009 final PhylogenyNode n1_6 = PhylogenyNode
10010 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
10011 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10015 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
10018 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
10021 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
10024 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
10028 catch ( final Exception e ) {
10029 e.printStackTrace( System.out );
10035 private static boolean testNHXParsing() {
10037 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10038 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
10039 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
10042 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]";
10043 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
10044 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10047 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]";
10048 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10049 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10052 final Phylogeny[] p3 = factory
10053 .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]",
10055 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10058 final Phylogeny[] p4 = factory
10059 .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(]",
10061 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10064 final Phylogeny[] p5 = factory
10065 .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(((]",
10067 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10070 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)";
10071 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)";
10072 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10073 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10076 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)))";
10077 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)))";
10078 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10079 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10082 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]) ))[,,, ])))))))";
10083 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10084 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10085 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10088 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10089 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10092 final Phylogeny p10 = factory
10093 .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]",
10094 new NHXParser() )[ 0 ];
10095 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10098 final Phylogeny p11 = factory
10099 .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]",
10100 new NHXParser() )[ 0 ];
10101 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10104 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]",
10105 new NHXParser() )[ 0 ];
10106 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10110 catch ( final Exception e ) {
10111 e.printStackTrace( System.out );
10117 private static boolean testNHXParsingMB() {
10119 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10120 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10121 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10122 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10123 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10124 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10125 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10126 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10127 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10128 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10129 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10132 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10135 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10136 0.1100000000000000e+00 ) ) {
10139 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10142 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10145 final Phylogeny p2 = factory
10146 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10147 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10148 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10149 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10150 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10151 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10152 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10153 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10154 + "7.369400000000000e-02}])",
10155 new NHXParser() )[ 0 ];
10156 if ( p2.getNode( "1" ) == null ) {
10159 if ( p2.getNode( "2" ) == null ) {
10163 catch ( final Exception e ) {
10164 e.printStackTrace( System.out );
10171 private static boolean testNHXParsingQuotes() {
10173 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10174 final NHXParser p = new NHXParser();
10175 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10176 if ( phylogenies_0.length != 5 ) {
10179 final Phylogeny phy = phylogenies_0[ 4 ];
10180 if ( phy.getNumberOfExternalNodes() != 7 ) {
10183 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10186 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10189 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10190 .getScientificName().equals( "hsapiens" ) ) {
10193 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10196 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10199 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10202 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10205 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10208 final NHXParser p1p = new NHXParser();
10209 p1p.setIgnoreQuotes( true );
10210 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10211 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10214 final NHXParser p2p = new NHXParser();
10215 p1p.setIgnoreQuotes( false );
10216 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10217 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10220 final NHXParser p3p = new NHXParser();
10221 p3p.setIgnoreQuotes( false );
10222 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10223 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10226 final NHXParser p4p = new NHXParser();
10227 p4p.setIgnoreQuotes( false );
10228 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10229 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10232 final Phylogeny p10 = factory
10233 .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]",
10234 new NHXParser() )[ 0 ];
10235 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]";
10236 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10239 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10240 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10243 final Phylogeny p12 = factory
10244 .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]",
10245 new NHXParser() )[ 0 ];
10246 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]";
10247 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10250 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10251 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10254 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;";
10255 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10258 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10259 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10263 catch ( final Exception e ) {
10264 e.printStackTrace( System.out );
10270 private static boolean testNodeRemoval() {
10272 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10273 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10274 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10275 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10278 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10279 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10280 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10283 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10284 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10285 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10289 catch ( final Exception e ) {
10290 e.printStackTrace( System.out );
10296 private static boolean testPhylogenyBranch() {
10298 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10299 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10300 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10301 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10302 if ( !a1b1.equals( a1b1 ) ) {
10305 if ( !a1b1.equals( b1a1 ) ) {
10308 if ( !b1a1.equals( a1b1 ) ) {
10311 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10312 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10313 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10314 if ( a1_b1.equals( b1_a1 ) ) {
10317 if ( a1_b1.equals( a1_b1_ ) ) {
10320 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10321 if ( !a1_b1.equals( b1_a1_ ) ) {
10324 if ( a1_b1_.equals( b1_a1_ ) ) {
10327 if ( !a1_b1_.equals( b1_a1 ) ) {
10331 catch ( final Exception e ) {
10332 e.printStackTrace( System.out );
10338 private static boolean testPhyloXMLparsingOfDistributionElement() {
10340 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10341 PhyloXmlParser xml_parser = null;
10343 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10345 catch ( final Exception e ) {
10346 // Do nothing -- means were not running from jar.
10348 if ( xml_parser == null ) {
10349 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10350 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10351 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10354 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10357 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ),
10359 if ( xml_parser.getErrorCount() > 0 ) {
10360 System.out.println( xml_parser.getErrorMessages().toString() );
10363 if ( phylogenies_0.length != 1 ) {
10366 final Phylogeny t1 = phylogenies_0[ 0 ];
10367 PhylogenyNode n = null;
10368 Distribution d = null;
10369 n = t1.getNode( "root node" );
10370 if ( !n.getNodeData().isHasDistribution() ) {
10373 if ( n.getNodeData().getDistributions().size() != 1 ) {
10376 d = n.getNodeData().getDistribution();
10377 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10380 if ( d.getPoints().size() != 1 ) {
10383 if ( d.getPolygons() != null ) {
10386 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10389 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10392 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10395 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10398 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10401 n = t1.getNode( "node a" );
10402 if ( !n.getNodeData().isHasDistribution() ) {
10405 if ( n.getNodeData().getDistributions().size() != 2 ) {
10408 d = n.getNodeData().getDistribution( 1 );
10409 if ( !d.getDesc().equals( "San Diego" ) ) {
10412 if ( d.getPoints().size() != 1 ) {
10415 if ( d.getPolygons() != null ) {
10418 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10421 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10424 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10427 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10430 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10433 n = t1.getNode( "node bb" );
10434 if ( !n.getNodeData().isHasDistribution() ) {
10437 if ( n.getNodeData().getDistributions().size() != 1 ) {
10440 d = n.getNodeData().getDistribution( 0 );
10441 if ( d.getPoints().size() != 3 ) {
10444 if ( d.getPolygons().size() != 2 ) {
10447 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10450 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10453 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10456 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10459 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10462 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10465 Polygon p = d.getPolygons().get( 0 );
10466 if ( p.getPoints().size() != 3 ) {
10469 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10472 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10475 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10478 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10481 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10484 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10487 p = d.getPolygons().get( 1 );
10488 if ( p.getPoints().size() != 3 ) {
10491 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10494 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10497 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10501 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10502 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10503 if ( rt.length != 1 ) {
10506 final Phylogeny t1_rt = rt[ 0 ];
10507 n = t1_rt.getNode( "root node" );
10508 if ( !n.getNodeData().isHasDistribution() ) {
10511 if ( n.getNodeData().getDistributions().size() != 1 ) {
10514 d = n.getNodeData().getDistribution();
10515 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10518 if ( d.getPoints().size() != 1 ) {
10521 if ( d.getPolygons() != null ) {
10524 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10527 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10530 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10533 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10536 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10539 n = t1_rt.getNode( "node a" );
10540 if ( !n.getNodeData().isHasDistribution() ) {
10543 if ( n.getNodeData().getDistributions().size() != 2 ) {
10546 d = n.getNodeData().getDistribution( 1 );
10547 if ( !d.getDesc().equals( "San Diego" ) ) {
10550 if ( d.getPoints().size() != 1 ) {
10553 if ( d.getPolygons() != null ) {
10556 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10559 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10562 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10565 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10568 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10571 n = t1_rt.getNode( "node bb" );
10572 if ( !n.getNodeData().isHasDistribution() ) {
10575 if ( n.getNodeData().getDistributions().size() != 1 ) {
10578 d = n.getNodeData().getDistribution( 0 );
10579 if ( d.getPoints().size() != 3 ) {
10582 if ( d.getPolygons().size() != 2 ) {
10585 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10588 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10591 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10594 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10597 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10600 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10603 p = d.getPolygons().get( 0 );
10604 if ( p.getPoints().size() != 3 ) {
10607 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10610 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10613 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10616 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10619 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10622 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10625 p = d.getPolygons().get( 1 );
10626 if ( p.getPoints().size() != 3 ) {
10629 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10632 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10635 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10639 catch ( final Exception e ) {
10640 e.printStackTrace( System.out );
10646 private static boolean testPostOrderIterator() {
10648 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10649 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10650 PhylogenyNodeIterator it0;
10651 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10654 for( it0.reset(); it0.hasNext(); ) {
10657 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10658 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10659 if ( !it.next().getName().equals( "A" ) ) {
10662 if ( !it.next().getName().equals( "B" ) ) {
10665 if ( !it.next().getName().equals( "ab" ) ) {
10668 if ( !it.next().getName().equals( "C" ) ) {
10671 if ( !it.next().getName().equals( "D" ) ) {
10674 if ( !it.next().getName().equals( "cd" ) ) {
10677 if ( !it.next().getName().equals( "abcd" ) ) {
10680 if ( !it.next().getName().equals( "E" ) ) {
10683 if ( !it.next().getName().equals( "F" ) ) {
10686 if ( !it.next().getName().equals( "ef" ) ) {
10689 if ( !it.next().getName().equals( "G" ) ) {
10692 if ( !it.next().getName().equals( "H" ) ) {
10695 if ( !it.next().getName().equals( "gh" ) ) {
10698 if ( !it.next().getName().equals( "efgh" ) ) {
10701 if ( !it.next().getName().equals( "r" ) ) {
10704 if ( it.hasNext() ) {
10708 catch ( final Exception e ) {
10709 e.printStackTrace( System.out );
10715 private static boolean testPreOrderIterator() {
10717 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10718 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10719 PhylogenyNodeIterator it0;
10720 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10723 for( it0.reset(); it0.hasNext(); ) {
10726 PhylogenyNodeIterator it = t0.iteratorPreorder();
10727 if ( !it.next().getName().equals( "r" ) ) {
10730 if ( !it.next().getName().equals( "ab" ) ) {
10733 if ( !it.next().getName().equals( "A" ) ) {
10736 if ( !it.next().getName().equals( "B" ) ) {
10739 if ( !it.next().getName().equals( "cd" ) ) {
10742 if ( !it.next().getName().equals( "C" ) ) {
10745 if ( !it.next().getName().equals( "D" ) ) {
10748 if ( it.hasNext() ) {
10751 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10752 it = t1.iteratorPreorder();
10753 if ( !it.next().getName().equals( "r" ) ) {
10756 if ( !it.next().getName().equals( "abcd" ) ) {
10759 if ( !it.next().getName().equals( "ab" ) ) {
10762 if ( !it.next().getName().equals( "A" ) ) {
10765 if ( !it.next().getName().equals( "B" ) ) {
10768 if ( !it.next().getName().equals( "cd" ) ) {
10771 if ( !it.next().getName().equals( "C" ) ) {
10774 if ( !it.next().getName().equals( "D" ) ) {
10777 if ( !it.next().getName().equals( "efgh" ) ) {
10780 if ( !it.next().getName().equals( "ef" ) ) {
10783 if ( !it.next().getName().equals( "E" ) ) {
10786 if ( !it.next().getName().equals( "F" ) ) {
10789 if ( !it.next().getName().equals( "gh" ) ) {
10792 if ( !it.next().getName().equals( "G" ) ) {
10795 if ( !it.next().getName().equals( "H" ) ) {
10798 if ( it.hasNext() ) {
10802 catch ( final Exception e ) {
10803 e.printStackTrace( System.out );
10809 private static boolean testPropertiesMap() {
10811 final PropertiesMap pm = new PropertiesMap();
10812 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10813 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10814 final Property p2 = new Property( "something:else",
10816 "improbable:research",
10819 pm.addProperty( p0 );
10820 pm.addProperty( p1 );
10821 pm.addProperty( p2 );
10822 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10825 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10828 if ( pm.getProperties().size() != 3 ) {
10831 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10834 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10837 if ( pm.getProperties().size() != 3 ) {
10840 pm.removeProperty( "dimensions:diameter" );
10841 if ( pm.getProperties().size() != 2 ) {
10844 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10847 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10851 catch ( final Exception e ) {
10852 e.printStackTrace( System.out );
10858 private static boolean testProteinId() {
10860 final ProteinId id1 = new ProteinId( "a" );
10861 final ProteinId id2 = new ProteinId( "a" );
10862 final ProteinId id3 = new ProteinId( "A" );
10863 final ProteinId id4 = new ProteinId( "b" );
10864 if ( !id1.equals( id1 ) ) {
10867 if ( id1.getId().equals( "x" ) ) {
10870 if ( id1.getId().equals( null ) ) {
10873 if ( !id1.equals( id2 ) ) {
10876 if ( id1.equals( id3 ) ) {
10879 if ( id1.hashCode() != id1.hashCode() ) {
10882 if ( id1.hashCode() != id2.hashCode() ) {
10885 if ( id1.hashCode() == id3.hashCode() ) {
10888 if ( id1.compareTo( id1 ) != 0 ) {
10891 if ( id1.compareTo( id2 ) != 0 ) {
10894 if ( id1.compareTo( id3 ) != 0 ) {
10897 if ( id1.compareTo( id4 ) >= 0 ) {
10900 if ( id4.compareTo( id1 ) <= 0 ) {
10903 if ( !id4.getId().equals( "b" ) ) {
10906 final ProteinId id5 = new ProteinId( " C " );
10907 if ( !id5.getId().equals( "C" ) ) {
10910 if ( id5.equals( id1 ) ) {
10914 catch ( final Exception e ) {
10915 e.printStackTrace( System.out );
10921 private static boolean testReIdMethods() {
10923 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10924 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10925 final long count = PhylogenyNode.getNodeCount();
10926 p.levelOrderReID();
10927 if ( p.getNode( "r" ).getId() != count ) {
10930 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10933 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10936 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10939 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10942 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10945 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10948 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10951 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10954 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10957 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10960 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10963 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10966 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10969 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10973 catch ( final Exception e ) {
10974 e.printStackTrace( System.out );
10980 private static boolean testRerooting() {
10982 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10983 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",
10984 new NHXParser() )[ 0 ];
10985 if ( !t1.isRooted() ) {
10988 t1.reRoot( t1.getNode( "D" ) );
10989 t1.reRoot( t1.getNode( "CD" ) );
10990 t1.reRoot( t1.getNode( "A" ) );
10991 t1.reRoot( t1.getNode( "B" ) );
10992 t1.reRoot( t1.getNode( "AB" ) );
10993 t1.reRoot( t1.getNode( "D" ) );
10994 t1.reRoot( t1.getNode( "C" ) );
10995 t1.reRoot( t1.getNode( "CD" ) );
10996 t1.reRoot( t1.getNode( "A" ) );
10997 t1.reRoot( t1.getNode( "B" ) );
10998 t1.reRoot( t1.getNode( "AB" ) );
10999 t1.reRoot( t1.getNode( "D" ) );
11000 t1.reRoot( t1.getNode( "D" ) );
11001 t1.reRoot( t1.getNode( "C" ) );
11002 t1.reRoot( t1.getNode( "A" ) );
11003 t1.reRoot( t1.getNode( "B" ) );
11004 t1.reRoot( t1.getNode( "AB" ) );
11005 t1.reRoot( t1.getNode( "C" ) );
11006 t1.reRoot( t1.getNode( "D" ) );
11007 t1.reRoot( t1.getNode( "CD" ) );
11008 t1.reRoot( t1.getNode( "D" ) );
11009 t1.reRoot( t1.getNode( "A" ) );
11010 t1.reRoot( t1.getNode( "B" ) );
11011 t1.reRoot( t1.getNode( "AB" ) );
11012 t1.reRoot( t1.getNode( "C" ) );
11013 t1.reRoot( t1.getNode( "D" ) );
11014 t1.reRoot( t1.getNode( "CD" ) );
11015 t1.reRoot( t1.getNode( "D" ) );
11016 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
11019 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
11022 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
11025 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
11028 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
11031 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
11034 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",
11035 new NHXParser() )[ 0 ];
11036 t2.reRoot( t2.getNode( "A" ) );
11037 t2.reRoot( t2.getNode( "D" ) );
11038 t2.reRoot( t2.getNode( "ABC" ) );
11039 t2.reRoot( t2.getNode( "A" ) );
11040 t2.reRoot( t2.getNode( "B" ) );
11041 t2.reRoot( t2.getNode( "D" ) );
11042 t2.reRoot( t2.getNode( "C" ) );
11043 t2.reRoot( t2.getNode( "ABC" ) );
11044 t2.reRoot( t2.getNode( "A" ) );
11045 t2.reRoot( t2.getNode( "B" ) );
11046 t2.reRoot( t2.getNode( "AB" ) );
11047 t2.reRoot( t2.getNode( "AB" ) );
11048 t2.reRoot( t2.getNode( "D" ) );
11049 t2.reRoot( t2.getNode( "C" ) );
11050 t2.reRoot( t2.getNode( "B" ) );
11051 t2.reRoot( t2.getNode( "AB" ) );
11052 t2.reRoot( t2.getNode( "D" ) );
11053 t2.reRoot( t2.getNode( "D" ) );
11054 t2.reRoot( t2.getNode( "ABC" ) );
11055 t2.reRoot( t2.getNode( "A" ) );
11056 t2.reRoot( t2.getNode( "B" ) );
11057 t2.reRoot( t2.getNode( "AB" ) );
11058 t2.reRoot( t2.getNode( "D" ) );
11059 t2.reRoot( t2.getNode( "C" ) );
11060 t2.reRoot( t2.getNode( "ABC" ) );
11061 t2.reRoot( t2.getNode( "A" ) );
11062 t2.reRoot( t2.getNode( "B" ) );
11063 t2.reRoot( t2.getNode( "AB" ) );
11064 t2.reRoot( t2.getNode( "D" ) );
11065 t2.reRoot( t2.getNode( "D" ) );
11066 t2.reRoot( t2.getNode( "C" ) );
11067 t2.reRoot( t2.getNode( "A" ) );
11068 t2.reRoot( t2.getNode( "B" ) );
11069 t2.reRoot( t2.getNode( "AB" ) );
11070 t2.reRoot( t2.getNode( "C" ) );
11071 t2.reRoot( t2.getNode( "D" ) );
11072 t2.reRoot( t2.getNode( "ABC" ) );
11073 t2.reRoot( t2.getNode( "D" ) );
11074 t2.reRoot( t2.getNode( "A" ) );
11075 t2.reRoot( t2.getNode( "B" ) );
11076 t2.reRoot( t2.getNode( "AB" ) );
11077 t2.reRoot( t2.getNode( "C" ) );
11078 t2.reRoot( t2.getNode( "D" ) );
11079 t2.reRoot( t2.getNode( "ABC" ) );
11080 t2.reRoot( t2.getNode( "D" ) );
11081 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11084 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11087 t2.reRoot( t2.getNode( "ABC" ) );
11088 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11091 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11094 t2.reRoot( t2.getNode( "AB" ) );
11095 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11098 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11101 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11104 t2.reRoot( t2.getNode( "AB" ) );
11105 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11108 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11111 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11114 t2.reRoot( t2.getNode( "D" ) );
11115 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11118 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11121 t2.reRoot( t2.getNode( "ABC" ) );
11122 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11125 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11128 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11129 new NHXParser() )[ 0 ];
11130 t3.reRoot( t3.getNode( "B" ) );
11131 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11134 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11137 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11140 t3.reRoot( t3.getNode( "B" ) );
11141 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11144 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11147 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11150 t3.reRoot( t3.getRoot() );
11151 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11154 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11157 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11161 catch ( final Exception e ) {
11162 e.printStackTrace( System.out );
11168 private static boolean testSDIse() {
11170 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11171 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11172 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11173 gene1.setRooted( true );
11174 species1.setRooted( true );
11175 final SDI sdi = new SDI( gene1, species1 );
11176 if ( !gene1.getRoot().isDuplication() ) {
11179 final Phylogeny species2 = factory
11180 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11181 new NHXParser() )[ 0 ];
11182 final Phylogeny gene2 = factory
11183 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11184 new NHXParser() )[ 0 ];
11185 species2.setRooted( true );
11186 gene2.setRooted( true );
11187 final SDI sdi2 = new SDI( gene2, species2 );
11188 if ( sdi2.getDuplicationsSum() != 0 ) {
11191 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11194 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11197 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11200 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11203 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11206 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11209 final Phylogeny species3 = factory
11210 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11211 new NHXParser() )[ 0 ];
11212 final Phylogeny gene3 = factory
11213 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11214 new NHXParser() )[ 0 ];
11215 species3.setRooted( true );
11216 gene3.setRooted( true );
11217 final SDI sdi3 = new SDI( gene3, species3 );
11218 if ( sdi3.getDuplicationsSum() != 1 ) {
11221 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11224 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11227 final Phylogeny species4 = factory
11228 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11229 new NHXParser() )[ 0 ];
11230 final Phylogeny gene4 = factory
11231 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11232 new NHXParser() )[ 0 ];
11233 species4.setRooted( true );
11234 gene4.setRooted( true );
11235 final SDI sdi4 = new SDI( gene4, species4 );
11236 if ( sdi4.getDuplicationsSum() != 1 ) {
11239 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11242 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11245 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11248 if ( species4.getNumberOfExternalNodes() != 6 ) {
11251 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11254 final Phylogeny species5 = factory
11255 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11256 new NHXParser() )[ 0 ];
11257 final Phylogeny gene5 = factory
11258 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11259 new NHXParser() )[ 0 ];
11260 species5.setRooted( true );
11261 gene5.setRooted( true );
11262 final SDI sdi5 = new SDI( gene5, species5 );
11263 if ( sdi5.getDuplicationsSum() != 2 ) {
11266 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11269 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11272 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11275 if ( species5.getNumberOfExternalNodes() != 6 ) {
11278 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11281 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11282 // Conjecture for Comparing Molecular Phylogenies"
11283 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11284 final Phylogeny species6 = factory
11285 .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,"
11286 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11287 new NHXParser() )[ 0 ];
11288 final Phylogeny gene6 = factory
11289 .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,"
11290 + "((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,"
11291 + "(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;",
11292 new NHXParser() )[ 0 ];
11293 species6.setRooted( true );
11294 gene6.setRooted( true );
11295 final SDI sdi6 = new SDI( gene6, species6 );
11296 if ( sdi6.getDuplicationsSum() != 3 ) {
11299 if ( !gene6.getNode( "r" ).isDuplication() ) {
11302 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11305 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11308 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11311 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11314 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11317 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11320 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11323 sdi6.computeMappingCostL();
11324 if ( sdi6.computeMappingCostL() != 17 ) {
11327 if ( species6.getNumberOfExternalNodes() != 9 ) {
11330 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11333 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11334 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11335 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11336 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11337 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11338 species7.setRooted( true );
11339 final Phylogeny gene7_1 = Test
11340 .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])" );
11341 gene7_1.setRooted( true );
11342 final SDI sdi7 = new SDI( gene7_1, species7 );
11343 if ( sdi7.getDuplicationsSum() != 0 ) {
11346 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11349 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11352 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11355 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11358 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11361 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11364 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11367 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11370 final Phylogeny gene7_2 = Test
11371 .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])" );
11372 gene7_2.setRooted( true );
11373 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11374 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11377 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11380 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11383 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11386 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11389 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11392 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11395 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11398 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11401 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11405 catch ( final Exception e ) {
11411 private static boolean testSDIunrooted() {
11413 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11414 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
11415 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11416 final Iterator<PhylogenyBranch> iter = l.iterator();
11417 PhylogenyBranch br = iter.next();
11418 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11421 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11425 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11428 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11432 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11435 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11439 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11442 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11446 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11449 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11453 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11456 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11460 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11463 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11467 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11470 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11474 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11477 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11481 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11484 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11488 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11491 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11495 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11498 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11502 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11505 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11509 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11512 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11516 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11519 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11522 if ( iter.hasNext() ) {
11525 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11526 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11527 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11529 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11532 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11536 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11539 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11543 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11546 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11549 if ( iter1.hasNext() ) {
11552 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11553 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11554 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11556 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11559 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11563 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11566 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11570 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11573 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11576 if ( iter2.hasNext() ) {
11579 final Phylogeny species0 = factory
11580 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11581 new NHXParser() )[ 0 ];
11582 final Phylogeny gene1 = factory
11583 .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])",
11584 new NHXParser() )[ 0 ];
11585 species0.setRooted( true );
11586 gene1.setRooted( true );
11587 final SDIR sdi_unrooted = new SDIR();
11588 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11589 if ( sdi_unrooted.getCount() != 1 ) {
11592 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11595 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11598 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11601 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11604 final Phylogeny gene2 = factory
11605 .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])",
11606 new NHXParser() )[ 0 ];
11607 gene2.setRooted( true );
11608 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11609 if ( sdi_unrooted.getCount() != 1 ) {
11612 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11615 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11618 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11621 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11624 final Phylogeny species6 = factory
11625 .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,"
11626 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11627 new NHXParser() )[ 0 ];
11628 final Phylogeny gene6 = factory
11629 .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],"
11630 + "(((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],"
11631 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11632 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11633 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11634 new NHXParser() )[ 0 ];
11635 species6.setRooted( true );
11636 gene6.setRooted( true );
11637 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11638 if ( sdi_unrooted.getCount() != 1 ) {
11641 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11644 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11647 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11650 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11653 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11656 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11659 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11662 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11665 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11668 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11671 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11674 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11678 final Phylogeny species7 = factory
11679 .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,"
11680 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11681 new NHXParser() )[ 0 ];
11682 final Phylogeny gene7 = factory
11683 .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],"
11684 + "(((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],"
11685 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11686 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11687 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11688 new NHXParser() )[ 0 ];
11689 species7.setRooted( true );
11690 gene7.setRooted( true );
11691 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11692 if ( sdi_unrooted.getCount() != 1 ) {
11695 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11698 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11701 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11704 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11707 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11710 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11713 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11716 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11719 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11722 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11725 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11728 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11732 final Phylogeny species8 = factory
11733 .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,"
11734 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11735 new NHXParser() )[ 0 ];
11736 final Phylogeny gene8 = factory
11737 .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],"
11738 + "(((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],"
11739 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11740 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11741 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11742 new NHXParser() )[ 0 ];
11743 species8.setRooted( true );
11744 gene8.setRooted( true );
11745 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11746 if ( sdi_unrooted.getCount() != 1 ) {
11749 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11752 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11755 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11758 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11761 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11764 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11767 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11770 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11773 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11776 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11779 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11782 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11787 catch ( final Exception e ) {
11788 e.printStackTrace( System.out );
11794 private static boolean testSequenceDbWsTools1() {
11796 final PhylogenyNode n = new PhylogenyNode();
11797 n.setName( "NP_001025424" );
11798 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11799 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11800 || !acc.getValue().equals( "NP_001025424" ) ) {
11803 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11804 acc = SequenceDbWsTools.obtainSeqAccession( n );
11805 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11806 || !acc.getValue().equals( "NP_001025424" ) ) {
11809 n.setName( "NP_001025424.1" );
11810 acc = SequenceDbWsTools.obtainSeqAccession( n );
11811 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11812 || !acc.getValue().equals( "NP_001025424" ) ) {
11815 n.setName( "NM_001030253" );
11816 acc = SequenceDbWsTools.obtainSeqAccession( n );
11817 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11818 || !acc.getValue().equals( "NM_001030253" ) ) {
11821 n.setName( "BCL2_HUMAN" );
11822 acc = SequenceDbWsTools.obtainSeqAccession( n );
11823 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11824 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11825 System.out.println( acc.toString() );
11828 n.setName( "P10415" );
11829 acc = SequenceDbWsTools.obtainSeqAccession( n );
11830 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11831 || !acc.getValue().equals( "P10415" ) ) {
11832 System.out.println( acc.toString() );
11835 n.setName( " P10415 " );
11836 acc = SequenceDbWsTools.obtainSeqAccession( n );
11837 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11838 || !acc.getValue().equals( "P10415" ) ) {
11839 System.out.println( acc.toString() );
11842 n.setName( "_P10415|" );
11843 acc = SequenceDbWsTools.obtainSeqAccession( n );
11844 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11845 || !acc.getValue().equals( "P10415" ) ) {
11846 System.out.println( acc.toString() );
11849 n.setName( "AY695820" );
11850 acc = SequenceDbWsTools.obtainSeqAccession( n );
11851 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11852 || !acc.getValue().equals( "AY695820" ) ) {
11853 System.out.println( acc.toString() );
11856 n.setName( "_AY695820_" );
11857 acc = SequenceDbWsTools.obtainSeqAccession( n );
11858 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11859 || !acc.getValue().equals( "AY695820" ) ) {
11860 System.out.println( acc.toString() );
11863 n.setName( "AAA59452" );
11864 acc = SequenceDbWsTools.obtainSeqAccession( n );
11865 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11866 || !acc.getValue().equals( "AAA59452" ) ) {
11867 System.out.println( acc.toString() );
11870 n.setName( "_AAA59452_" );
11871 acc = SequenceDbWsTools.obtainSeqAccession( n );
11872 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11873 || !acc.getValue().equals( "AAA59452" ) ) {
11874 System.out.println( acc.toString() );
11877 n.setName( "AAA59452.1" );
11878 acc = SequenceDbWsTools.obtainSeqAccession( n );
11879 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11880 || !acc.getValue().equals( "AAA59452.1" ) ) {
11881 System.out.println( acc.toString() );
11884 n.setName( "_AAA59452.1_" );
11885 acc = SequenceDbWsTools.obtainSeqAccession( n );
11886 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11887 || !acc.getValue().equals( "AAA59452.1" ) ) {
11888 System.out.println( acc.toString() );
11891 n.setName( "GI:94894583" );
11892 acc = SequenceDbWsTools.obtainSeqAccession( n );
11893 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11894 || !acc.getValue().equals( "94894583" ) ) {
11895 System.out.println( acc.toString() );
11898 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11899 acc = SequenceDbWsTools.obtainSeqAccession( n );
11900 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11901 || !acc.getValue().equals( "71845847" ) ) {
11902 System.out.println( acc.toString() );
11905 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11906 acc = SequenceDbWsTools.obtainSeqAccession( n );
11907 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11908 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11909 System.out.println( acc.toString() );
11913 catch ( final Exception e ) {
11919 private static boolean testSequenceDbWsTools2() {
11921 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11922 SequenceDbWsTools.obtainSeqInformation( n1 );
11923 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11926 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11929 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11932 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11935 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11936 SequenceDbWsTools.obtainSeqInformation( n2 );
11937 if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
11940 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11943 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11946 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11949 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11950 SequenceDbWsTools.obtainSeqInformation( n3 );
11951 if ( !n3.getNodeData().getSequence().getName()
11952 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11955 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11958 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11961 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11965 catch ( final IOException e ) {
11966 System.out.println();
11967 System.out.println( "the following might be due to absence internet connection:" );
11968 e.printStackTrace( System.out );
11971 catch ( final Exception e ) {
11972 e.printStackTrace();
11978 private static boolean testSequenceIdParsing() {
11980 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11981 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11982 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11983 if ( id != null ) {
11984 System.out.println( "value =" + id.getValue() );
11985 System.out.println( "provider=" + id.getSource() );
11989 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11990 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11991 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11992 if ( id != null ) {
11993 System.out.println( "value =" + id.getValue() );
11994 System.out.println( "provider=" + id.getSource() );
11998 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11999 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12000 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12001 if ( id != null ) {
12002 System.out.println( "value =" + id.getValue() );
12003 System.out.println( "provider=" + id.getSource() );
12007 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
12008 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12009 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
12010 if ( id != null ) {
12011 System.out.println( "value =" + id.getValue() );
12012 System.out.println( "provider=" + id.getSource() );
12016 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
12017 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12018 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
12019 if ( id != null ) {
12020 System.out.println( "value =" + id.getValue() );
12021 System.out.println( "provider=" + id.getSource() );
12025 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
12026 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12027 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
12028 if ( id != null ) {
12029 System.out.println( "value =" + id.getValue() );
12030 System.out.println( "provider=" + id.getSource() );
12034 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
12035 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12036 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
12037 if ( id != null ) {
12038 System.out.println( "value =" + id.getValue() );
12039 System.out.println( "provider=" + id.getSource() );
12043 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
12044 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12045 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12046 if ( id != null ) {
12047 System.out.println( "value =" + id.getValue() );
12048 System.out.println( "provider=" + id.getSource() );
12052 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12053 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12054 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12055 if ( id != null ) {
12056 System.out.println( "value =" + id.getValue() );
12057 System.out.println( "provider=" + id.getSource() );
12061 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12062 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12063 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12064 if ( id != null ) {
12065 System.out.println( "value =" + id.getValue() );
12066 System.out.println( "provider=" + id.getSource() );
12070 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12071 if ( id != null ) {
12072 System.out.println( "value =" + id.getValue() );
12073 System.out.println( "provider=" + id.getSource() );
12076 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12077 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12078 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12079 if ( id != null ) {
12080 System.out.println( "value =" + id.getValue() );
12081 System.out.println( "provider=" + id.getSource() );
12085 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12086 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12087 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12088 if ( id != null ) {
12089 System.out.println( "value =" + id.getValue() );
12090 System.out.println( "provider=" + id.getSource() );
12094 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12095 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12096 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12097 if ( id != null ) {
12098 System.out.println( "value =" + id.getValue() );
12099 System.out.println( "provider=" + id.getSource() );
12103 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12104 if ( id != null ) {
12105 System.out.println( "value =" + id.getValue() );
12106 System.out.println( "provider=" + id.getSource() );
12110 catch ( final Exception e ) {
12111 e.printStackTrace( System.out );
12117 private static boolean testSequenceWriter() {
12119 final String n = ForesterUtil.LINE_SEPARATOR;
12120 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12123 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12126 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12129 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12132 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12133 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12136 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12137 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12141 catch ( final Exception e ) {
12142 e.printStackTrace();
12148 private static boolean testSpecies() {
12150 final Species s1 = new BasicSpecies( "a" );
12151 final Species s2 = new BasicSpecies( "a" );
12152 final Species s3 = new BasicSpecies( "A" );
12153 final Species s4 = new BasicSpecies( "b" );
12154 if ( !s1.equals( s1 ) ) {
12157 if ( s1.getSpeciesId().equals( "x" ) ) {
12160 if ( s1.getSpeciesId().equals( null ) ) {
12163 if ( !s1.equals( s2 ) ) {
12166 if ( s1.equals( s3 ) ) {
12169 if ( s1.hashCode() != s1.hashCode() ) {
12172 if ( s1.hashCode() != s2.hashCode() ) {
12175 if ( s1.hashCode() == s3.hashCode() ) {
12178 if ( s1.compareTo( s1 ) != 0 ) {
12181 if ( s1.compareTo( s2 ) != 0 ) {
12184 if ( s1.compareTo( s3 ) != 0 ) {
12187 if ( s1.compareTo( s4 ) >= 0 ) {
12190 if ( s4.compareTo( s1 ) <= 0 ) {
12193 if ( !s4.getSpeciesId().equals( "b" ) ) {
12196 final Species s5 = new BasicSpecies( " C " );
12197 if ( !s5.getSpeciesId().equals( "C" ) ) {
12200 if ( s5.equals( s1 ) ) {
12204 catch ( final Exception e ) {
12205 e.printStackTrace( System.out );
12211 private static boolean testSplit() {
12213 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12214 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12215 //Archaeopteryx.createApplication( p0 );
12216 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12217 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12218 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12219 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12220 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12221 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12222 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12223 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12224 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12225 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12226 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12227 // System.out.println( s0.toString() );
12229 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12232 if ( s0.match( query_nodes ) ) {
12235 query_nodes = new HashSet<PhylogenyNode>();
12236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12238 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12239 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12240 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12241 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12243 if ( !s0.match( query_nodes ) ) {
12247 query_nodes = new HashSet<PhylogenyNode>();
12248 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12249 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12250 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12251 if ( !s0.match( query_nodes ) ) {
12255 query_nodes = new HashSet<PhylogenyNode>();
12256 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12257 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12258 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12260 if ( !s0.match( query_nodes ) ) {
12264 query_nodes = new HashSet<PhylogenyNode>();
12265 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12267 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12268 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12269 if ( !s0.match( query_nodes ) ) {
12273 query_nodes = new HashSet<PhylogenyNode>();
12274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12276 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12277 if ( !s0.match( query_nodes ) ) {
12280 query_nodes = new HashSet<PhylogenyNode>();
12281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12283 if ( !s0.match( query_nodes ) ) {
12286 query_nodes = new HashSet<PhylogenyNode>();
12287 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12288 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12292 if ( !s0.match( query_nodes ) ) {
12295 query_nodes = new HashSet<PhylogenyNode>();
12296 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12298 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12299 if ( !s0.match( query_nodes ) ) {
12302 query_nodes = new HashSet<PhylogenyNode>();
12303 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12304 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12305 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12306 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12307 if ( !s0.match( query_nodes ) ) {
12310 query_nodes = new HashSet<PhylogenyNode>();
12311 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12312 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12313 if ( s0.match( query_nodes ) ) {
12316 query_nodes = new HashSet<PhylogenyNode>();
12317 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12318 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12319 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12320 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12321 if ( s0.match( query_nodes ) ) {
12324 query_nodes = new HashSet<PhylogenyNode>();
12325 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12328 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12329 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12330 if ( s0.match( query_nodes ) ) {
12333 query_nodes = new HashSet<PhylogenyNode>();
12334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12335 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12336 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12337 if ( s0.match( query_nodes ) ) {
12340 query_nodes = new HashSet<PhylogenyNode>();
12341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12342 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12343 if ( s0.match( query_nodes ) ) {
12346 query_nodes = new HashSet<PhylogenyNode>();
12347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12349 if ( s0.match( query_nodes ) ) {
12352 query_nodes = new HashSet<PhylogenyNode>();
12353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12355 if ( s0.match( query_nodes ) ) {
12358 query_nodes = new HashSet<PhylogenyNode>();
12359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12361 if ( s0.match( query_nodes ) ) {
12364 query_nodes = new HashSet<PhylogenyNode>();
12365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12366 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12367 if ( s0.match( query_nodes ) ) {
12370 query_nodes = new HashSet<PhylogenyNode>();
12371 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12373 if ( s0.match( query_nodes ) ) {
12376 query_nodes = new HashSet<PhylogenyNode>();
12377 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12378 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12380 if ( s0.match( query_nodes ) ) {
12383 query_nodes = new HashSet<PhylogenyNode>();
12384 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12385 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12386 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12387 if ( s0.match( query_nodes ) ) {
12390 query_nodes = new HashSet<PhylogenyNode>();
12391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12392 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12393 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12394 if ( s0.match( query_nodes ) ) {
12397 query_nodes = new HashSet<PhylogenyNode>();
12398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12401 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12402 if ( s0.match( query_nodes ) ) {
12406 // query_nodes = new HashSet<PhylogenyNode>();
12407 // query_nodes.add( new PhylogenyNode( "X" ) );
12408 // query_nodes.add( new PhylogenyNode( "Y" ) );
12409 // query_nodes.add( new PhylogenyNode( "A" ) );
12410 // query_nodes.add( new PhylogenyNode( "B" ) );
12411 // query_nodes.add( new PhylogenyNode( "C" ) );
12412 // query_nodes.add( new PhylogenyNode( "D" ) );
12413 // query_nodes.add( new PhylogenyNode( "E" ) );
12414 // query_nodes.add( new PhylogenyNode( "F" ) );
12415 // query_nodes.add( new PhylogenyNode( "G" ) );
12416 // if ( !s0.match( query_nodes ) ) {
12419 // query_nodes = new HashSet<PhylogenyNode>();
12420 // query_nodes.add( new PhylogenyNode( "X" ) );
12421 // query_nodes.add( new PhylogenyNode( "Y" ) );
12422 // query_nodes.add( new PhylogenyNode( "A" ) );
12423 // query_nodes.add( new PhylogenyNode( "B" ) );
12424 // query_nodes.add( new PhylogenyNode( "C" ) );
12425 // if ( !s0.match( query_nodes ) ) {
12429 // query_nodes = new HashSet<PhylogenyNode>();
12430 // query_nodes.add( new PhylogenyNode( "X" ) );
12431 // query_nodes.add( new PhylogenyNode( "Y" ) );
12432 // query_nodes.add( new PhylogenyNode( "D" ) );
12433 // query_nodes.add( new PhylogenyNode( "E" ) );
12434 // query_nodes.add( new PhylogenyNode( "F" ) );
12435 // query_nodes.add( new PhylogenyNode( "G" ) );
12436 // if ( !s0.match( query_nodes ) ) {
12440 // query_nodes = new HashSet<PhylogenyNode>();
12441 // query_nodes.add( new PhylogenyNode( "X" ) );
12442 // query_nodes.add( new PhylogenyNode( "Y" ) );
12443 // query_nodes.add( new PhylogenyNode( "A" ) );
12444 // query_nodes.add( new PhylogenyNode( "B" ) );
12445 // query_nodes.add( new PhylogenyNode( "C" ) );
12446 // query_nodes.add( new PhylogenyNode( "D" ) );
12447 // if ( !s0.match( query_nodes ) ) {
12451 // query_nodes = new HashSet<PhylogenyNode>();
12452 // query_nodes.add( new PhylogenyNode( "X" ) );
12453 // query_nodes.add( new PhylogenyNode( "Y" ) );
12454 // query_nodes.add( new PhylogenyNode( "E" ) );
12455 // query_nodes.add( new PhylogenyNode( "F" ) );
12456 // query_nodes.add( new PhylogenyNode( "G" ) );
12457 // if ( !s0.match( query_nodes ) ) {
12461 // query_nodes = new HashSet<PhylogenyNode>();
12462 // query_nodes.add( new PhylogenyNode( "X" ) );
12463 // query_nodes.add( new PhylogenyNode( "Y" ) );
12464 // query_nodes.add( new PhylogenyNode( "F" ) );
12465 // query_nodes.add( new PhylogenyNode( "G" ) );
12466 // if ( !s0.match( query_nodes ) ) {
12470 query_nodes = new HashSet<PhylogenyNode>();
12471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12475 if ( s0.match( query_nodes ) ) {
12479 query_nodes = new HashSet<PhylogenyNode>();
12480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12482 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12483 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12484 if ( s0.match( query_nodes ) ) {
12487 ///////////////////////////
12489 query_nodes = new HashSet<PhylogenyNode>();
12490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12491 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12493 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12494 if ( s0.match( query_nodes ) ) {
12498 query_nodes = new HashSet<PhylogenyNode>();
12499 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12503 if ( s0.match( query_nodes ) ) {
12507 query_nodes = new HashSet<PhylogenyNode>();
12508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12512 if ( s0.match( query_nodes ) ) {
12516 query_nodes = new HashSet<PhylogenyNode>();
12517 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12521 if ( s0.match( query_nodes ) ) {
12525 query_nodes = new HashSet<PhylogenyNode>();
12526 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12527 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12530 if ( s0.match( query_nodes ) ) {
12534 query_nodes = new HashSet<PhylogenyNode>();
12535 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12536 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12537 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12538 if ( s0.match( query_nodes ) ) {
12542 query_nodes = new HashSet<PhylogenyNode>();
12543 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12544 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12545 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12546 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12547 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12548 if ( s0.match( query_nodes ) ) {
12552 query_nodes = new HashSet<PhylogenyNode>();
12553 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12554 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12555 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12556 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12557 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12558 if ( s0.match( query_nodes ) ) {
12562 query_nodes = new HashSet<PhylogenyNode>();
12563 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12564 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12568 if ( s0.match( query_nodes ) ) {
12572 query_nodes = new HashSet<PhylogenyNode>();
12573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12579 if ( s0.match( query_nodes ) ) {
12583 catch ( final Exception e ) {
12584 e.printStackTrace();
12590 private static boolean testSplitStrict() {
12592 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12593 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12594 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12595 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12596 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12597 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12598 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12599 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12600 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12601 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12602 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12603 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12606 if ( s0.match( query_nodes ) ) {
12609 query_nodes = new HashSet<PhylogenyNode>();
12610 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12617 if ( !s0.match( query_nodes ) ) {
12621 query_nodes = new HashSet<PhylogenyNode>();
12622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12625 if ( !s0.match( query_nodes ) ) {
12629 query_nodes = new HashSet<PhylogenyNode>();
12630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12634 if ( !s0.match( query_nodes ) ) {
12638 query_nodes = new HashSet<PhylogenyNode>();
12639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12643 if ( !s0.match( query_nodes ) ) {
12647 query_nodes = new HashSet<PhylogenyNode>();
12648 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12651 if ( !s0.match( query_nodes ) ) {
12655 query_nodes = new HashSet<PhylogenyNode>();
12656 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12657 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12658 if ( !s0.match( query_nodes ) ) {
12662 query_nodes = new HashSet<PhylogenyNode>();
12663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12668 if ( !s0.match( query_nodes ) ) {
12672 query_nodes = new HashSet<PhylogenyNode>();
12673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12674 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12676 if ( !s0.match( query_nodes ) ) {
12680 query_nodes = new HashSet<PhylogenyNode>();
12681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12682 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12683 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12684 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12685 if ( !s0.match( query_nodes ) ) {
12689 query_nodes = new HashSet<PhylogenyNode>();
12690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12691 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12692 if ( s0.match( query_nodes ) ) {
12696 query_nodes = new HashSet<PhylogenyNode>();
12697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12701 if ( s0.match( query_nodes ) ) {
12705 query_nodes = new HashSet<PhylogenyNode>();
12706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12711 if ( s0.match( query_nodes ) ) {
12715 query_nodes = new HashSet<PhylogenyNode>();
12716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12717 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12718 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12719 if ( s0.match( query_nodes ) ) {
12723 query_nodes = new HashSet<PhylogenyNode>();
12724 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12725 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12726 if ( s0.match( query_nodes ) ) {
12730 query_nodes = new HashSet<PhylogenyNode>();
12731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12732 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12733 if ( s0.match( query_nodes ) ) {
12737 query_nodes = new HashSet<PhylogenyNode>();
12738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12740 if ( s0.match( query_nodes ) ) {
12744 query_nodes = new HashSet<PhylogenyNode>();
12745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12747 if ( s0.match( query_nodes ) ) {
12751 query_nodes = new HashSet<PhylogenyNode>();
12752 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12754 if ( s0.match( query_nodes ) ) {
12758 query_nodes = new HashSet<PhylogenyNode>();
12759 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12760 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12761 if ( s0.match( query_nodes ) ) {
12765 query_nodes = new HashSet<PhylogenyNode>();
12766 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12767 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12768 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12769 if ( s0.match( query_nodes ) ) {
12773 query_nodes = new HashSet<PhylogenyNode>();
12774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12775 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12776 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12777 if ( s0.match( query_nodes ) ) {
12781 query_nodes = new HashSet<PhylogenyNode>();
12782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12783 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12784 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12785 if ( s0.match( query_nodes ) ) {
12789 query_nodes = new HashSet<PhylogenyNode>();
12790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12791 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12792 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12793 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12794 if ( s0.match( query_nodes ) ) {
12798 catch ( final Exception e ) {
12799 e.printStackTrace();
12805 private static boolean testSubtreeDeletion() {
12807 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12808 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12809 t1.deleteSubtree( t1.getNode( "A" ), false );
12810 if ( t1.getNumberOfExternalNodes() != 5 ) {
12813 t1.toNewHampshireX();
12814 t1.deleteSubtree( t1.getNode( "E" ), false );
12815 if ( t1.getNumberOfExternalNodes() != 4 ) {
12818 t1.toNewHampshireX();
12819 t1.deleteSubtree( t1.getNode( "F" ), false );
12820 if ( t1.getNumberOfExternalNodes() != 3 ) {
12823 t1.toNewHampshireX();
12824 t1.deleteSubtree( t1.getNode( "D" ), false );
12825 t1.toNewHampshireX();
12826 if ( t1.getNumberOfExternalNodes() != 3 ) {
12829 t1.deleteSubtree( t1.getNode( "def" ), false );
12830 t1.toNewHampshireX();
12831 if ( t1.getNumberOfExternalNodes() != 2 ) {
12834 t1.deleteSubtree( t1.getNode( "B" ), false );
12835 t1.toNewHampshireX();
12836 if ( t1.getNumberOfExternalNodes() != 1 ) {
12839 t1.deleteSubtree( t1.getNode( "C" ), false );
12840 t1.toNewHampshireX();
12841 if ( t1.getNumberOfExternalNodes() != 1 ) {
12844 t1.deleteSubtree( t1.getNode( "abc" ), false );
12845 t1.toNewHampshireX();
12846 if ( t1.getNumberOfExternalNodes() != 1 ) {
12849 t1.deleteSubtree( t1.getNode( "r" ), false );
12850 if ( t1.getNumberOfExternalNodes() != 0 ) {
12853 if ( !t1.isEmpty() ) {
12856 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12857 t2.deleteSubtree( t2.getNode( "A" ), false );
12858 t2.toNewHampshireX();
12859 if ( t2.getNumberOfExternalNodes() != 5 ) {
12862 t2.deleteSubtree( t2.getNode( "abc" ), false );
12863 t2.toNewHampshireX();
12864 if ( t2.getNumberOfExternalNodes() != 3 ) {
12867 t2.deleteSubtree( t2.getNode( "def" ), false );
12868 t2.toNewHampshireX();
12869 if ( t2.getNumberOfExternalNodes() != 1 ) {
12873 catch ( final Exception e ) {
12874 e.printStackTrace( System.out );
12880 private static boolean testSupportCount() {
12882 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12883 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12884 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12885 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12886 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12887 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12888 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12890 SupportCount.count( t0_1, phylogenies_1, true, false );
12891 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12892 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12893 + "(((((A,B),C),D),E),((F,G),X))"
12894 + "(((((A,Y),B),C),D),((F,G),E))"
12895 + "(((((A,B),C),D),E),(F,G))"
12896 + "(((((A,B),C),D),E),(F,G))"
12897 + "(((((A,B),C),D),E),(F,G))"
12898 + "(((((A,B),C),D),E),(F,G),Z)"
12899 + "(((((A,B),C),D),E),(F,G))"
12900 + "((((((A,B),C),D),E),F),G)"
12901 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12903 SupportCount.count( t0_2, phylogenies_2, true, false );
12904 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12905 while ( it.hasNext() ) {
12906 final PhylogenyNode n = it.next();
12907 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12911 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12912 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12913 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12914 SupportCount.count( t0_3, phylogenies_3, true, false );
12915 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12916 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12919 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12922 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12925 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12928 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12931 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12934 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12937 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12940 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12943 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12946 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12947 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12948 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12949 SupportCount.count( t0_4, phylogenies_4, true, false );
12950 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12951 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12954 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12957 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12960 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12963 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12966 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12969 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12972 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12975 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12978 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12981 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12982 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12983 double d = SupportCount.compare( b1, a, true, true, true );
12984 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12987 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12988 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12989 d = SupportCount.compare( b2, a, true, true, true );
12990 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12993 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12994 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12995 d = SupportCount.compare( b3, a, true, true, true );
12996 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12999 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
13000 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
13001 d = SupportCount.compare( b4, a, true, true, false );
13002 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
13006 catch ( final Exception e ) {
13007 e.printStackTrace( System.out );
13013 private static boolean testSupportTransfer() {
13015 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13016 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)",
13017 new NHXParser() )[ 0 ];
13018 final Phylogeny p2 = factory
13019 .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 ];
13020 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
13023 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
13026 support_transfer.moveBranchLengthsToBootstrap( p1 );
13027 support_transfer.transferSupportValues( p1, p2 );
13028 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
13031 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
13034 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
13037 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
13040 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
13043 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13046 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13049 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13053 catch ( final Exception e ) {
13054 e.printStackTrace( System.out );
13060 private static boolean testTaxonomyExtraction() {
13062 final PhylogenyNode n0 = PhylogenyNode
13063 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13064 if ( n0.getNodeData().isHasTaxonomy() ) {
13067 final PhylogenyNode n1 = PhylogenyNode
13068 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13069 if ( n1.getNodeData().isHasTaxonomy() ) {
13070 System.out.println( n1.toString() );
13073 final PhylogenyNode n2x = PhylogenyNode
13074 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13075 if ( n2x.getNodeData().isHasTaxonomy() ) {
13078 final PhylogenyNode n3 = PhylogenyNode
13079 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13080 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13081 System.out.println( n3.toString() );
13084 final PhylogenyNode n4 = PhylogenyNode
13085 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13086 if ( n4.getNodeData().isHasTaxonomy() ) {
13087 System.out.println( n4.toString() );
13090 final PhylogenyNode n5 = PhylogenyNode
13091 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13092 if ( n5.getNodeData().isHasTaxonomy() ) {
13093 System.out.println( n5.toString() );
13096 final PhylogenyNode n6 = PhylogenyNode
13097 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13098 if ( n6.getNodeData().isHasTaxonomy() ) {
13099 System.out.println( n6.toString() );
13102 final PhylogenyNode n7 = PhylogenyNode
13103 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13104 if ( n7.getNodeData().isHasTaxonomy() ) {
13105 System.out.println( n7.toString() );
13108 final PhylogenyNode n8 = PhylogenyNode
13109 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13110 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13111 System.out.println( n8.toString() );
13114 final PhylogenyNode n9 = PhylogenyNode
13115 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13116 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13117 System.out.println( n9.toString() );
13120 final PhylogenyNode n10x = PhylogenyNode
13121 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13122 if ( n10x.getNodeData().isHasTaxonomy() ) {
13123 System.out.println( n10x.toString() );
13126 final PhylogenyNode n10xx = PhylogenyNode
13127 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13128 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13129 System.out.println( n10xx.toString() );
13132 final PhylogenyNode n10 = PhylogenyNode
13133 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13134 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13135 System.out.println( n10.toString() );
13138 final PhylogenyNode n11 = PhylogenyNode
13139 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13140 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13141 System.out.println( n11.toString() );
13144 final PhylogenyNode n12 = PhylogenyNode
13145 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
13146 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13147 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13148 System.out.println( n12.toString() );
13151 final PhylogenyNode n13 = PhylogenyNode
13152 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13153 if ( n13.getNodeData().isHasTaxonomy() ) {
13154 System.out.println( n13.toString() );
13157 final PhylogenyNode n14 = PhylogenyNode
13158 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13159 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13160 System.out.println( n14.toString() );
13163 final PhylogenyNode n15 = PhylogenyNode
13164 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13165 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13166 System.out.println( n15.toString() );
13169 final PhylogenyNode n16 = PhylogenyNode
13170 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13171 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13172 System.out.println( n16.toString() );
13175 final PhylogenyNode n17 = PhylogenyNode
13176 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13177 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13178 System.out.println( n17.toString() );
13181 final PhylogenyNode n18 = PhylogenyNode
13182 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13183 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13184 System.out.println( n18.toString() );
13187 final PhylogenyNode n19 = PhylogenyNode
13188 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13189 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13190 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13191 System.out.println( n19.toString() );
13194 final PhylogenyNode n20 = PhylogenyNode
13195 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13196 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13197 System.out.println( n20.toString() );
13200 final PhylogenyNode n21 = PhylogenyNode
13201 .createInstanceFromNhxString( "Mus musculus musculus K392",
13202 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13203 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13204 System.out.println( n21.toString() );
13207 final PhylogenyNode n23 = PhylogenyNode
13208 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13209 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13210 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13211 System.out.println( n23.toString() );
13214 final PhylogenyNode n24 = PhylogenyNode
13215 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13216 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13217 System.out.println( n24.toString() );
13221 final PhylogenyNode n25 = PhylogenyNode
13222 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13223 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13224 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13225 System.out.println( n25.toString() );
13228 final PhylogenyNode n26 = PhylogenyNode
13229 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13230 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13231 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13232 System.out.println( n26.toString() );
13235 final PhylogenyNode n27 = PhylogenyNode
13236 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13237 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13238 System.out.println( n27.toString() );
13242 catch ( final Exception e ) {
13243 e.printStackTrace( System.out );
13249 private static boolean testTreeCopy() {
13251 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13252 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13253 final Phylogeny t1 = t0.copy();
13254 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13257 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13260 t0.deleteSubtree( t0.getNode( "c" ), true );
13261 t0.deleteSubtree( t0.getNode( "a" ), true );
13262 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13263 t0.getNode( "b" ).setName( "Bee" );
13264 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13267 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13270 t0.deleteSubtree( t0.getNode( "e" ), true );
13271 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13272 t0.deleteSubtree( t0.getNode( "d" ), true );
13273 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13277 catch ( final Exception e ) {
13278 e.printStackTrace();
13284 private static boolean testTreeMethods() {
13286 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13287 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13288 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13289 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13290 System.out.println( t0.toNewHampshireX() );
13293 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13294 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13295 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13298 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13301 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13305 catch ( final Exception e ) {
13306 e.printStackTrace( System.out );
13312 private static boolean testUniprotEntryRetrieval() {
13314 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13315 if ( !entry.getAccession().equals( "P12345" ) ) {
13318 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13321 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13324 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13327 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13330 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13333 if ( entry.getMolecularSequence() == null ) {
13337 .getMolecularSequence()
13338 .getMolecularSequenceAsString()
13339 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13340 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13341 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13342 System.out.println( "expected something else." );
13346 catch ( final IOException e ) {
13347 System.out.println();
13348 System.out.println( "the following might be due to absence internet connection:" );
13349 e.printStackTrace( System.out );
13352 catch ( final NullPointerException f ) {
13353 f.printStackTrace( System.out );
13356 catch ( final Exception e ) {
13362 private static boolean testUniprotTaxonomySearch() {
13364 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13366 if ( results.size() != 1 ) {
13369 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13372 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13375 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13378 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13381 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13385 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13386 if ( results.size() != 1 ) {
13389 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13392 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13395 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13398 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13401 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13405 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13406 if ( results.size() != 1 ) {
13409 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13412 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13415 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13418 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13421 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13425 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13426 if ( results.size() != 1 ) {
13429 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13432 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13435 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13438 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13441 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13444 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13447 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13450 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13451 .equals( "Nematostella vectensis" ) ) {
13452 System.out.println( results.get( 0 ).getLineage() );
13457 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13458 if ( results.size() != 1 ) {
13461 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13464 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13467 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13470 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13473 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13476 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13477 .equals( "Xenopus tropicalis" ) ) {
13478 System.out.println( results.get( 0 ).getLineage() );
13483 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13484 if ( results.size() != 1 ) {
13487 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13490 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13493 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13496 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13499 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13502 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13503 .equals( "Xenopus tropicalis" ) ) {
13504 System.out.println( results.get( 0 ).getLineage() );
13509 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13510 if ( results.size() != 1 ) {
13513 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13516 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13519 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13522 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13525 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13528 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13529 .equals( "Xenopus tropicalis" ) ) {
13530 System.out.println( results.get( 0 ).getLineage() );
13534 catch ( final IOException e ) {
13535 System.out.println();
13536 System.out.println( "the following might be due to absence internet connection:" );
13537 e.printStackTrace( System.out );
13540 catch ( final Exception e ) {