2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.AptxUtil;
45 import org.forester.archaeopteryx.TreePanelUtil;
46 import org.forester.archaeopteryx.webservices.WebserviceUtil;
47 import org.forester.development.DevelopmentTools;
48 import org.forester.evoinference.TestPhylogenyReconstruction;
49 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
50 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
51 import org.forester.go.TestGo;
52 import org.forester.io.parsers.FastaParser;
53 import org.forester.io.parsers.GeneralMsaParser;
54 import org.forester.io.parsers.HmmscanPerDomainTableParser;
55 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
56 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
57 import org.forester.io.parsers.nexus.NexusCharactersParser;
58 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
59 import org.forester.io.parsers.nhx.NHXParser;
60 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
61 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
62 import org.forester.io.parsers.tol.TolParser;
63 import org.forester.io.parsers.util.ParserUtils;
64 import org.forester.io.writers.PhylogenyWriter;
65 import org.forester.io.writers.SequenceWriter;
66 import org.forester.msa.BasicMsa;
67 import org.forester.msa.DeleteableMsa;
68 import org.forester.msa.Mafft;
69 import org.forester.msa.Msa;
70 import org.forester.msa.Msa.MSA_FORMAT;
71 import org.forester.msa.MsaInferrer;
72 import org.forester.msa.MsaMethods;
73 import org.forester.pccx.TestPccx;
74 import org.forester.phylogeny.Phylogeny;
75 import org.forester.phylogeny.PhylogenyBranch;
76 import org.forester.phylogeny.PhylogenyMethods;
77 import org.forester.phylogeny.PhylogenyNode;
78 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
79 import org.forester.phylogeny.data.Accession;
80 import org.forester.phylogeny.data.Accession.Source;
81 import org.forester.phylogeny.data.BinaryCharacters;
82 import org.forester.phylogeny.data.BranchWidth;
83 import org.forester.phylogeny.data.Confidence;
84 import org.forester.phylogeny.data.Distribution;
85 import org.forester.phylogeny.data.DomainArchitecture;
86 import org.forester.phylogeny.data.Event;
87 import org.forester.phylogeny.data.Identifier;
88 import org.forester.phylogeny.data.PhylogenyData;
89 import org.forester.phylogeny.data.PhylogenyDataUtil;
90 import org.forester.phylogeny.data.Polygon;
91 import org.forester.phylogeny.data.PropertiesList;
92 import org.forester.phylogeny.data.Property;
93 import org.forester.phylogeny.data.Property.AppliesTo;
94 import org.forester.phylogeny.data.ProteinDomain;
95 import org.forester.phylogeny.data.Taxonomy;
96 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
97 import org.forester.phylogeny.factories.PhylogenyFactory;
98 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
99 import org.forester.protein.BasicDomain;
100 import org.forester.protein.BasicProtein;
101 import org.forester.protein.Domain;
102 import org.forester.protein.Protein;
103 import org.forester.protein.ProteinId;
104 import org.forester.rio.TestRIO;
105 import org.forester.sdi.SDI;
106 import org.forester.sdi.SDIR;
107 import org.forester.sdi.TestGSDI;
108 import org.forester.sequence.BasicSequence;
109 import org.forester.sequence.MolecularSequence;
110 import org.forester.species.BasicSpecies;
111 import org.forester.species.Species;
112 import org.forester.surfacing.TestSurfacing;
113 import org.forester.tools.ConfidenceAssessor;
114 import org.forester.tools.SupportCount;
115 import org.forester.tools.TreeSplitMatrix;
116 import org.forester.util.AsciiHistogram;
117 import org.forester.util.BasicDescriptiveStatistics;
118 import org.forester.util.BasicTable;
119 import org.forester.util.BasicTableParser;
120 import org.forester.util.DescriptiveStatistics;
121 import org.forester.util.ForesterConstants;
122 import org.forester.util.ForesterUtil;
123 import org.forester.util.GeneralTable;
124 import org.forester.util.SequenceAccessionTools;
125 import org.forester.ws.seqdb.SequenceDatabaseEntry;
126 import org.forester.ws.seqdb.SequenceDbWsTools;
127 import org.forester.ws.seqdb.UniProtTaxonomy;
129 @SuppressWarnings( "unused")
130 public final class Test {
132 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "resources" + ForesterUtil.getFileSeparator();
134 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
135 + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator();
136 private final static boolean PERFORM_DB_TESTS = false;
137 private static final boolean PERFORM_WEB_TREE_ACCESS = false;
138 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
139 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
140 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
142 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
143 private final static double ZERO_DIFF = 1.0E-9;
145 private static boolean isEqual( final double a, final double b ) {
146 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
149 public static void main( final String[] args ) {
150 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
151 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
153 Locale.setDefault( Locale.US );
154 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
157 System.out.print( "[Test if directory with files for testing exists/is readable: " );
158 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
159 System.out.println( "OK.]" );
162 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
163 System.out.println( "Testing aborted." );
166 System.out.print( "[Test if resources directory exists/is readable: " );
167 if ( testDir( PATH_TO_RESOURCES ) ) {
168 System.out.println( "OK.]" );
171 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
172 System.out.println( "Testing aborted." );
175 final long start_time = new Date().getTime();
176 System.out.print( "Basic node methods: " );
177 if ( Test.testBasicNodeMethods() ) {
178 System.out.println( "OK." );
182 System.out.println( "failed." );
185 System.out.print( "Protein id: " );
186 if ( !testProteinId() ) {
187 System.out.println( "failed." );
193 System.out.println( "OK." );
194 System.out.print( "Species: " );
195 if ( !testSpecies() ) {
196 System.out.println( "failed." );
202 System.out.println( "OK." );
203 System.out.print( "Basic domain: " );
204 if ( !testBasicDomain() ) {
205 System.out.println( "failed." );
211 System.out.println( "OK." );
212 System.out.print( "Basic protein: " );
213 if ( !testBasicProtein() ) {
214 System.out.println( "failed." );
220 System.out.println( "OK." );
221 System.out.print( "Sequence writer: " );
222 if ( testSequenceWriter() ) {
223 System.out.println( "OK." );
227 System.out.println( "failed." );
230 System.out.print( "Sequence id parsing: " );
231 if ( testSequenceIdParsing() ) {
232 System.out.println( "OK." );
236 System.out.println( "failed." );
239 System.out.print( "UniProtKB id extraction: " );
240 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
241 System.out.println( "OK." );
245 System.out.println( "failed." );
248 System.out.print( "Sequence DB tools 1: " );
249 if ( testSequenceDbWsTools1() ) {
250 System.out.println( "OK." );
254 System.out.println( "failed." );
257 System.out.print( "Hmmscan output parser: " );
258 if ( testHmmscanOutputParser() ) {
259 System.out.println( "OK." );
263 System.out.println( "failed." );
266 System.out.print( "Overlap removal: " );
267 if ( !org.forester.test.Test.testOverlapRemoval() ) {
268 System.out.println( "failed." );
274 System.out.println( "OK." );
275 System.out.print( "Engulfing overlap removal: " );
276 if ( !Test.testEngulfingOverlapRemoval() ) {
277 System.out.println( "failed." );
283 System.out.println( "OK." );
284 System.out.print( "Taxonomy data extraction: " );
285 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
286 System.out.println( "OK." );
290 System.out.println( "failed." );
293 System.out.print( "Taxonomy code extraction: " );
294 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
295 System.out.println( "OK." );
299 System.out.println( "failed." );
302 System.out.print( "SN extraction: " );
303 if ( Test.testExtractSNFromNodeName() ) {
304 System.out.println( "OK." );
308 System.out.println( "failed." );
311 System.out.print( "Taxonomy extraction (general): " );
312 if ( Test.testTaxonomyExtraction() ) {
313 System.out.println( "OK." );
317 System.out.println( "failed." );
320 System.out.print( "Uri for Aptx web sequence accession: " );
321 if ( Test.testCreateUriForSeqWeb() ) {
322 System.out.println( "OK." );
326 System.out.println( "failed." );
329 System.out.print( "Basic node construction and parsing of NHX (node level): " );
330 if ( Test.testNHXNodeParsing() ) {
331 System.out.println( "OK." );
335 System.out.println( "failed." );
338 System.out.print( "Node construction and parsing of NHX (node level): " );
339 if ( Test.testNHXNodeParsing2() ) {
340 System.out.println( "OK." );
344 System.out.println( "failed." );
347 System.out.print( "NHX parsing iterating: " );
348 if ( Test.testNHParsingIter() ) {
349 System.out.println( "OK." );
353 System.out.println( "failed." );
356 System.out.print( "NH parsing: " );
357 if ( Test.testNHParsing() ) {
358 System.out.println( "OK." );
362 System.out.println( "failed." );
365 System.out.print( "NH parsing - special chars: " );
366 if ( Test.testNHParsingSpecialChars() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "Conversion to NHX (node level): " );
375 if ( Test.testNHXconversion() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "NHX parsing: " );
384 if ( Test.testNHXParsing() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing with quotes: " );
393 if ( Test.testNHXParsingQuotes() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "NHX parsing (MrBayes): " );
402 if ( Test.testNHXParsingMB() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "Nexus characters parsing: " );
411 if ( Test.testNexusCharactersParsing() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus tree parsing iterating: " );
420 if ( Test.testNexusTreeParsingIterating() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing: " );
429 if ( Test.testNexusTreeParsing() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus tree parsing (translating): " );
438 if ( Test.testNexusTreeParsingTranslating() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Nexus matrix parsing: " );
447 if ( Test.testNexusMatrixParsing() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Basic phyloXML parsing: " );
456 if ( Test.testBasicPhyloXMLparsing() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Basic phyloXML parsing (validating against schema): " );
465 if ( testBasicPhyloXMLparsingValidating() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "phyloXML parsing (validating against schema): " );
474 if ( testPhyloXMLparsingValidating() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
483 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
484 System.out.println( "OK." );
488 System.out.println( "failed." );
491 System.out.print( "phyloXML Distribution Element: " );
492 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
493 System.out.println( "OK." );
497 System.out.println( "failed." );
500 System.out.print( "Tol XML parsing: " );
501 if ( Test.testBasicTolXMLparsing() ) {
502 System.out.println( "OK." );
506 System.out.println( "failed." );
509 System.out.print( "UTF-8 parsing from file: " );
510 if ( Test.testUTF8ParsingFromFile() ) {
511 System.out.println( "OK." );
515 System.out.println( "failed." );
518 System.out.print( "Copying of node data: " );
519 if ( Test.testCopyOfNodeData() ) {
520 System.out.println( "OK." );
524 System.out.println( "failed." );
527 System.out.print( "Tree copy: " );
528 if ( Test.testTreeCopy() ) {
529 System.out.println( "OK." );
533 System.out.println( "failed." );
536 System.out.print( "Basic tree methods: " );
537 if ( Test.testBasicTreeMethods() ) {
538 System.out.println( "OK." );
542 System.out.println( "failed." );
545 System.out.print( "Tree methods: " );
546 if ( Test.testTreeMethods() ) {
547 System.out.println( "OK." );
551 System.out.println( "failed." );
554 System.out.print( "Phylogeny methods:" );
555 if ( Test.testPhylogenyMethods() ) {
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
1196 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1197 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1200 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1201 System.out.println( phys[ 0 ].toNewHampshire() );
1204 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1205 System.out.println( phys[ 1 ].toNewHampshire() );
1208 final Phylogeny phys2[] = AptxUtil
1209 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1210 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1213 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1214 System.out.println( phys2[ 0 ].toNewHampshire() );
1217 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1218 System.out.println( phys2[ 1 ].toNewHampshire() );
1221 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1222 + "SwissTree/ST001/consensus_tree.nhx" ),
1226 TAXONOMY_EXTRACTION.NO,
1228 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1231 if ( !phys3[ 0 ].toNewHampshire()
1232 .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))))));" ) ) {
1233 System.out.println( phys3[ 0 ].toNewHampshire() );
1236 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1237 + "SwissTree/ST001/consensus_tree.nhx" ),
1241 TAXONOMY_EXTRACTION.NO,
1243 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1246 if ( !phys4[ 0 ].toNewHampshire()
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",
1396 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1397 cde.addProteinDomain( c );
1398 cde.addProteinDomain( d );
1399 cde.addProteinDomain( e );
1400 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1401 if ( cde.getNumberOfProteinDomains() != 3 ) {
1404 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1407 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1408 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1409 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1410 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1411 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1412 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1413 fghi.addProteinDomain( f );
1414 fghi.addProteinDomain( g );
1415 fghi.addProteinDomain( h );
1416 fghi.addProteinDomain( i );
1417 fghi.addProteinDomain( i );
1418 fghi.addProteinDomain( i );
1419 fghi.addProteinDomain( i2 );
1420 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1421 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1424 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1427 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1430 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1431 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1434 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1437 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1438 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1439 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1440 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1441 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1442 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1443 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1444 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1445 jklm.addProteinDomain( j );
1446 jklm.addProteinDomain( k );
1447 jklm.addProteinDomain( l );
1448 jklm.addProteinDomain( m );
1449 jklm.addProteinDomain( m0 );
1450 jklm.addProteinDomain( m1 );
1451 jklm.addProteinDomain( m2 );
1452 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1453 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1456 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1459 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1462 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1463 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1466 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1469 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1470 final Protein od = new BasicProtein( "od", "varanus", 0 );
1471 od.addProteinDomain( only );
1472 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1473 if ( od.getNumberOfProteinDomains() != 1 ) {
1476 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1480 catch ( final Exception e ) {
1481 e.printStackTrace( System.out );
1487 private static final boolean testPfamTreeReading() {
1489 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1490 final NHXParser parser = new NHXParser();
1491 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1492 parser.setReplaceUnderscores( false );
1493 parser.setGuessRootedness( true );
1494 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1495 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1498 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1502 catch ( final Exception e ) {
1503 e.printStackTrace();
1509 private static final boolean testPhyloXMLparsingFromURL() {
1511 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1512 final URL u = new URL( s );
1513 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1514 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1517 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1518 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1522 catch ( final Exception e ) {
1523 e.printStackTrace();
1529 private static final boolean testToLReading() {
1531 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1532 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1533 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1536 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1539 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName()
1540 .equals( "Protacanthopterygii" ) ) {
1543 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1547 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1548 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1549 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1552 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1555 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1559 catch ( final Exception e ) {
1560 e.printStackTrace();
1566 private static final boolean testTreeBaseReading() {
1568 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1569 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1570 parser.setReplaceUnderscores( true );
1571 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1572 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1575 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1576 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1577 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1578 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1581 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1582 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1583 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1584 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1587 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1588 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1589 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1590 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1593 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1594 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1595 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1596 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1599 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1600 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1601 parser2.setReplaceUnderscores( true );
1602 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1603 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1606 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1607 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1608 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1609 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1612 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl(
1613 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1614 + "14525?format=nexus" ),
1615 new NexusPhylogeniesParser() );
1616 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1619 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl(
1620 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1621 + "15632?format=nexus" ),
1622 new NexusPhylogeniesParser() );
1623 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1626 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl(
1627 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1628 + "10190?format=nexus" ),
1629 new NexusPhylogeniesParser() );
1630 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1633 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl(
1634 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1635 + "13246?format=nexus" ),
1636 new NexusPhylogeniesParser() );
1637 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1640 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl(
1641 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1642 + "11662?format=nexus" ),
1643 new NexusPhylogeniesParser() );
1644 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1647 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl(
1648 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1649 + "562?format=nexus" ),
1650 new NexusPhylogeniesParser() );
1651 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1654 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl(
1655 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1656 + "16424?format=nexus" ),
1657 new NexusPhylogeniesParser() );
1658 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1661 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl(
1662 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1663 + "17878?format=nexus" ),
1664 new NexusPhylogeniesParser() );
1665 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1668 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl(
1669 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1670 + "18804?format=nexus" ),
1671 new NexusPhylogeniesParser() );
1672 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1675 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl(
1676 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1677 + "346?format=nexus" ),
1678 new NexusPhylogeniesParser() );
1679 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1683 catch ( final Exception e ) {
1684 e.printStackTrace();
1690 private static final boolean testTreeFamReading() {
1692 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1693 final NHXParser parser = new NHXParser();
1694 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1695 parser.setReplaceUnderscores( false );
1696 parser.setGuessRootedness( true );
1697 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1698 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1701 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1705 catch ( final Exception e ) {
1706 e.printStackTrace();
1712 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1713 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1717 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1718 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1721 private static boolean testAminoAcidSequence() {
1723 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1724 if ( aa1.getLength() != 13 ) {
1727 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1730 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1733 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1736 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1737 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1740 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1741 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1744 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1745 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1749 catch ( final Exception e ) {
1750 e.printStackTrace();
1756 private static boolean testBasicDomain() {
1758 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1759 if ( !pd.getDomainId().equals( "id" ) ) {
1762 if ( pd.getNumber() != 1 ) {
1765 if ( pd.getTotalCount() != 4 ) {
1768 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1771 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1772 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1773 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1774 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1775 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1776 if ( !a1.equals( a1 ) ) {
1779 if ( !a1.equals( a1_copy ) ) {
1782 if ( !a1.equals( a1_equal ) ) {
1785 if ( !a1.equals( a2 ) ) {
1788 if ( a1.equals( a3 ) ) {
1791 if ( a1.compareTo( a1 ) != 0 ) {
1794 if ( a1.compareTo( a1_copy ) != 0 ) {
1797 if ( a1.compareTo( a1_equal ) != 0 ) {
1800 if ( a1.compareTo( a2 ) != 0 ) {
1803 if ( a1.compareTo( a3 ) == 0 ) {
1807 catch ( final Exception e ) {
1808 e.printStackTrace( System.out );
1814 private static boolean testBasicNodeMethods() {
1816 if ( PhylogenyNode.getNodeCount() != 0 ) {
1819 final PhylogenyNode n1 = new PhylogenyNode();
1820 final PhylogenyNode n2 = PhylogenyNode
1821 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1822 final PhylogenyNode n3 = PhylogenyNode
1823 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1824 final PhylogenyNode n4 = PhylogenyNode
1825 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1826 if ( n1.isHasAssignedEvent() ) {
1829 if ( PhylogenyNode.getNodeCount() != 4 ) {
1832 if ( n3.getIndicator() != 0 ) {
1835 if ( n3.getNumberOfExternalNodes() != 1 ) {
1838 if ( !n3.isExternal() ) {
1841 if ( !n3.isRoot() ) {
1844 if ( !n4.getName().equals( "n4" ) ) {
1848 catch ( final Exception e ) {
1849 e.printStackTrace( System.out );
1855 private static boolean testUTF8ParsingFromFile() {
1857 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1858 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance()
1859 .create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ), xml_parser );
1860 if ( xml_parser.getErrorCount() > 0 ) {
1861 System.out.println( xml_parser.getErrorMessages().toString() );
1864 if ( phylogenies_xml.length != 1 ) {
1867 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance()
1868 .create( new StringBuffer( phylogenies_xml[ 0 ].toPhyloXML( 0 ) ), xml_parser );
1869 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance()
1870 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
1871 if ( phylogenies_nh.length != 1 ) {
1874 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance()
1875 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
1876 if ( phylogenies_nex.length != 1 ) {
1879 final String[] xml_n = phylogenies_xml[ 0 ].getAllExternalNodeNames();
1880 final String[] xml_n2 = phylogenies_xml2[ 0 ].getAllExternalNodeNames();
1881 final String[] nh_n = phylogenies_nh[ 0 ].getAllExternalNodeNames();
1882 final String[] nex_n = phylogenies_nex[ 0 ].getAllExternalNodeNames();
1883 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
1884 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
1885 final String n2 = "漢字ひらがなカタカナ";
1886 final String n3 = "อักษรไทย";
1887 final String n4 = "繁體字";
1888 final String n5 = "한글";
1889 final String n6 = "देवनागरी";
1890 final String n7 = "chữ Quốc ngữ";
1891 final String n8 = "ру́сский язы́к";
1892 final String n9 = "អក្សរខ្មែរ";
1893 if ( !xml_n[ 0 ].equals( n0 ) ) {
1894 System.out.println( xml_n[ 0 ] );
1895 System.out.println( n0 );
1898 if ( !xml_n2[ 0 ].equals( n0 ) ) {
1899 System.out.println( xml_n2[ 0 ] );
1900 System.out.println( n0 );
1903 if ( !nh_n[ 0 ].equals( n0 ) ) {
1904 System.out.println( nh_n[ 0 ] );
1905 System.out.println( n0 );
1908 if ( !nex_n[ 0 ].equals( n0 ) ) {
1909 System.out.println( nex_n[ 0 ] );
1910 System.out.println( n0 );
1913 if ( !xml_n[ 1 ].equals( n1 ) ) {
1914 System.out.println( xml_n[ 1 ] );
1915 System.out.println( n1 );
1918 if ( !xml_n2[ 1 ].equals( n1 ) ) {
1919 System.out.println( xml_n2[ 1 ] );
1920 System.out.println( n1 );
1923 if ( !nh_n[ 1 ].equals( n1 ) ) {
1924 System.out.println( nh_n[ 1 ] );
1925 System.out.println( n1 );
1928 if ( !nex_n[ 1 ].equals( n1 ) ) {
1929 System.out.println( nex_n[ 1 ] );
1930 System.out.println( n1 );
1933 if ( !xml_n[ 2 ].equals( n2 ) ) {
1934 System.out.println( xml_n[ 2 ] );
1935 System.out.println( n2 );
1938 if ( !xml_n2[ 2 ].equals( n2 ) ) {
1939 System.out.println( xml_n2[ 2 ] );
1940 System.out.println( n2 );
1943 if ( !nh_n[ 2 ].equals( n2 ) ) {
1944 System.out.println( nh_n[ 2 ] );
1945 System.out.println( n2 );
1948 if ( !nex_n[ 2 ].equals( n2 ) ) {
1949 System.out.println( nex_n[ 2 ] );
1950 System.out.println( n2 );
1954 if ( !xml_n[ 3 ].equals( n3 ) ) {
1955 System.out.println( xml_n[ 3 ] );
1956 System.out.println( n3 );
1959 if ( !xml_n2[ 3 ].equals( n3 ) ) {
1960 System.out.println( xml_n2[ 3 ] );
1961 System.out.println( n3 );
1964 if ( !nh_n[ 3 ].equals( n3 ) ) {
1965 System.out.println( nh_n[ 3 ] );
1966 System.out.println( n3 );
1969 if ( !nex_n[ 3 ].equals( n3 ) ) {
1970 System.out.println( nex_n[ 3 ] );
1971 System.out.println( n3 );
1975 if ( !xml_n[ 4 ].equals( n4 ) ) {
1976 System.out.println( xml_n[ 4 ] );
1977 System.out.println( n4 );
1980 if ( !nh_n[ 4 ].equals( n4 ) ) {
1981 System.out.println( nh_n[ 4 ] );
1982 System.out.println( n4 );
1985 if ( !nex_n[ 4 ].equals( n4 ) ) {
1986 System.out.println( nex_n[ 4 ] );
1987 System.out.println( n4 );
1991 if ( !xml_n[ 5 ].equals( n5 ) ) {
1992 System.out.println( xml_n[ 5 ] );
1993 System.out.println( n5 );
1996 if ( !nh_n[ 5 ].equals( n5 ) ) {
1997 System.out.println( nh_n[ 5 ] );
1998 System.out.println( n5 );
2001 if ( !nex_n[ 5 ].equals( n5 ) ) {
2002 System.out.println( nex_n[ 5 ] );
2003 System.out.println( n5 );
2007 if ( !xml_n[ 6 ].equals( n6 ) ) {
2008 System.out.println( xml_n[ 6 ] );
2009 System.out.println( n6 );
2012 if ( !nh_n[ 6 ].equals( n6 ) ) {
2013 System.out.println( nh_n[ 6 ] );
2014 System.out.println( n6 );
2017 if ( !nex_n[ 6 ].equals( n6 ) ) {
2018 System.out.println( nex_n[ 6 ] );
2019 System.out.println( n6 );
2023 if ( !xml_n[ 7 ].equals( n7 ) ) {
2024 System.out.println( xml_n[ 7 ] );
2025 System.out.println( n7 );
2028 if ( !nh_n[ 7 ].equals( n7 ) ) {
2029 System.out.println( nh_n[ 7 ] );
2030 System.out.println( n7 );
2033 if ( !nex_n[ 7 ].equals( n7 ) ) {
2034 System.out.println( nex_n[ 7 ] );
2035 System.out.println( n7 );
2038 if ( !xml_n[ 8 ].equals( n8 ) ) {
2039 System.out.println( xml_n[ 8 ] );
2040 System.out.println( n8 );
2043 if ( !nh_n[ 8 ].equals( n8 ) ) {
2044 System.out.println( nh_n[ 8 ] );
2045 System.out.println( n8 );
2048 if ( !nex_n[ 8 ].equals( n8 ) ) {
2049 System.out.println( nex_n[ 8 ] );
2050 System.out.println( n8 );
2053 if ( !xml_n[ 9 ].equals( n9 ) ) {
2054 System.out.println( xml_n[ 9 ] );
2055 System.out.println( n9 );
2058 if ( !xml_n2[ 9 ].equals( n9 ) ) {
2059 System.out.println( xml_n2[ 9 ] );
2060 System.out.println( n9 );
2063 if ( !nh_n[ 9 ].equals( n9 ) ) {
2064 System.out.println( nh_n[ 9 ] );
2065 System.out.println( n9 );
2068 if ( !nex_n[ 9 ].equals( n9 ) ) {
2069 System.out.println( nex_n[ 9 ] );
2070 System.out.println( n9 );
2073 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nh[ 0 ].toNewHampshire() ) ) {
2074 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2075 System.out.println( phylogenies_nh[ 0 ].toNewHampshire() );
2078 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nex[ 0 ].toNewHampshire() ) ) {
2079 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2080 System.out.println( phylogenies_nex[ 0 ].toNewHampshire() );
2084 catch ( final Exception e ) {
2085 e.printStackTrace( System.out );
2091 private static boolean testBasicPhyloXMLparsing() {
2093 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2094 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2095 final Phylogeny[] phylogenies_0 = factory
2096 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2097 if ( xml_parser.getErrorCount() > 0 ) {
2098 System.out.println( xml_parser.getErrorMessages().toString() );
2101 if ( phylogenies_0.length != 4 ) {
2104 final Phylogeny t1 = phylogenies_0[ 0 ];
2105 final Phylogeny t2 = phylogenies_0[ 1 ];
2106 final Phylogeny t3 = phylogenies_0[ 2 ];
2107 final Phylogeny t4 = phylogenies_0[ 3 ];
2108 if ( t1.getNumberOfExternalNodes() != 1 ) {
2111 if ( !t1.isRooted() ) {
2114 if ( t1.isRerootable() ) {
2117 if ( !t1.getType().equals( "gene_tree" ) ) {
2120 if ( t2.getNumberOfExternalNodes() != 2 ) {
2123 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2126 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2129 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2132 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2135 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2138 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2141 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2142 .startsWith( "actgtgggggt" ) ) {
2145 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2146 .startsWith( "ctgtgatgcat" ) ) {
2149 if ( t3.getNumberOfExternalNodes() != 4 ) {
2152 if ( !t1.getName().equals( "t1" ) ) {
2155 if ( !t2.getName().equals( "t2" ) ) {
2158 if ( !t3.getName().equals( "t3" ) ) {
2161 if ( !t4.getName().equals( "t4" ) ) {
2164 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2167 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2170 if ( !t3.getNode( "root node" ).isDuplication() ) {
2173 if ( !t3.getNode( "node a" ).isDuplication() ) {
2176 if ( t3.getNode( "node a" ).isSpeciation() ) {
2179 if ( t3.getNode( "node bc" ).isDuplication() ) {
2182 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2185 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2188 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2189 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2192 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2195 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2198 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2199 .equals( "UniProtKB" ) ) {
2202 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2203 .equals( "apoptosis" ) ) {
2206 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2207 .equals( "GO:0006915" ) ) {
2210 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2211 .equals( "UniProtKB" ) ) {
2214 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2215 .equals( "experimental" ) ) {
2218 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2219 .equals( "function" ) ) {
2222 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2223 .getValue() != 1 ) {
2226 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence().getType()
2230 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2231 .equals( "apoptosis" ) ) {
2234 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2235 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2238 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2239 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2242 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2243 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2246 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2247 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2250 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2251 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2254 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2255 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2258 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2259 .equals( "GO:0005829" ) ) {
2262 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2263 .equals( "intracellular organelle" ) ) {
2266 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2269 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2270 .equals( "UniProt link" ) ) ) {
2273 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2276 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2277 if ( x.size() != 4 ) {
2281 for( final Accession acc : x ) {
2283 if ( !acc.getSource().equals( "KEGG" ) ) {
2286 if ( !acc.getValue().equals( "hsa:596" ) ) {
2293 catch ( final Exception e ) {
2294 e.printStackTrace( System.out );
2300 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2302 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2303 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2304 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2305 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2308 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2310 final Phylogeny[] phylogenies_0 = factory
2311 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2312 if ( xml_parser.getErrorCount() > 0 ) {
2313 System.out.println( xml_parser.getErrorMessages().toString() );
2316 if ( phylogenies_0.length != 4 ) {
2319 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2320 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2321 if ( phylogenies_t1.length != 1 ) {
2324 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2325 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2328 if ( !t1_rt.isRooted() ) {
2331 if ( t1_rt.isRerootable() ) {
2334 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2337 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2338 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2339 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2340 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2343 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2346 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2349 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2352 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2353 .startsWith( "actgtgggggt" ) ) {
2356 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2357 .startsWith( "ctgtgatgcat" ) ) {
2360 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2361 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2362 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2363 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2364 if ( phylogenies_1.length != 1 ) {
2367 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2368 if ( !t3_rt.getName().equals( "t3" ) ) {
2371 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2374 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2377 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2380 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2383 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2384 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2387 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2390 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue()
2391 .equals( "Q9BZR8" ) ) {
2394 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2395 .equals( "UniProtKB" ) ) {
2398 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2399 .equals( "apoptosis" ) ) {
2402 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2403 .equals( "GO:0006915" ) ) {
2406 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2407 .equals( "UniProtKB" ) ) {
2410 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2411 .equals( "experimental" ) ) {
2414 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2415 .equals( "function" ) ) {
2418 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2419 .getValue() != 1 ) {
2422 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2423 .getType().equals( "ml" ) ) {
2426 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2427 .equals( "apoptosis" ) ) {
2430 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2431 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2434 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2435 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2438 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2439 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2442 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2443 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2446 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2447 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2450 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2451 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2454 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2455 .equals( "GO:0005829" ) ) {
2458 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2459 .equals( "intracellular organelle" ) ) {
2462 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType()
2463 .equals( "source" ) ) ) {
2466 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2467 .equals( "UniProt link" ) ) ) {
2470 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2473 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi()
2474 .equals( "10.1038/387489a0" ) ) ) {
2477 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2478 .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." ) ) ) {
2479 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2482 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2485 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2488 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName()
2489 .equals( "molting animals" ) ) {
2492 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2495 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2496 .equals( "ncbi" ) ) {
2499 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture()
2500 .getTotalLength() != 124 ) {
2503 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2504 .getName().equals( "B" ) ) {
2507 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2508 .getFrom() != 21 ) {
2511 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2515 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2516 .getLength() != 24 ) {
2519 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2520 .getConfidence() != 0 ) {
2523 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2524 .equals( "pfam" ) ) {
2527 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2530 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2533 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2536 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2539 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2540 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2543 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2546 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2549 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2552 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2555 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2558 if ( taxbb.getSynonyms().size() != 2 ) {
2561 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2564 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2567 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2570 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2573 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2576 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2577 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2580 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2583 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2586 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2589 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2592 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2595 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2598 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2601 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2604 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2605 .equalsIgnoreCase( "435" ) ) {
2608 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString()
2609 .equalsIgnoreCase( "416" ) ) {
2612 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2613 .equalsIgnoreCase( "443.7" ) ) {
2616 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2619 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2622 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2623 .equalsIgnoreCase( "433" ) ) {
2626 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2627 .getCrossReferences();
2628 if ( x.size() != 4 ) {
2632 for( final Accession acc : x ) {
2634 if ( !acc.getSource().equals( "KEGG" ) ) {
2637 if ( !acc.getValue().equals( "hsa:596" ) ) {
2644 catch ( final Exception e ) {
2645 e.printStackTrace( System.out );
2651 private static boolean testBasicPhyloXMLparsingValidating() {
2653 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2654 PhyloXmlParser xml_parser = null;
2656 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2658 catch ( final Exception e ) {
2659 // Do nothing -- means were not running from jar.
2661 if ( xml_parser == null ) {
2662 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2663 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2664 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2667 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2670 final Phylogeny[] phylogenies_0 = factory
2671 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2672 if ( xml_parser.getErrorCount() > 0 ) {
2673 System.out.println( xml_parser.getErrorMessages().toString() );
2676 if ( phylogenies_0.length != 4 ) {
2679 final Phylogeny t1 = phylogenies_0[ 0 ];
2680 final Phylogeny t2 = phylogenies_0[ 1 ];
2681 final Phylogeny t3 = phylogenies_0[ 2 ];
2682 final Phylogeny t4 = phylogenies_0[ 3 ];
2683 if ( !t1.getName().equals( "t1" ) ) {
2686 if ( !t2.getName().equals( "t2" ) ) {
2689 if ( !t3.getName().equals( "t3" ) ) {
2692 if ( !t4.getName().equals( "t4" ) ) {
2695 if ( t1.getNumberOfExternalNodes() != 1 ) {
2698 if ( t2.getNumberOfExternalNodes() != 2 ) {
2701 if ( t3.getNumberOfExternalNodes() != 4 ) {
2704 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2705 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2706 if ( xml_parser.getErrorCount() > 0 ) {
2707 System.out.println( "errors:" );
2708 System.out.println( xml_parser.getErrorMessages().toString() );
2711 if ( phylogenies_1.length != 4 ) {
2714 final Phylogeny[] phylogenies_2 = factory
2715 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ), xml_parser );
2716 if ( xml_parser.getErrorCount() > 0 ) {
2717 System.out.println( "errors:" );
2718 System.out.println( xml_parser.getErrorMessages().toString() );
2721 if ( phylogenies_2.length != 1 ) {
2724 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2727 final Phylogeny[] phylogenies_3 = factory
2728 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ), xml_parser );
2729 if ( xml_parser.getErrorCount() > 0 ) {
2730 System.out.println( xml_parser.getErrorMessages().toString() );
2733 if ( phylogenies_3.length != 2 ) {
2736 final Phylogeny a = phylogenies_3[ 0 ];
2737 if ( !a.getName().equals( "tree 4" ) ) {
2740 if ( a.getNumberOfExternalNodes() != 3 ) {
2743 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2746 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2749 final Phylogeny[] phylogenies_4 = factory
2750 .create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml" ), xml_parser );
2751 if ( xml_parser.getErrorCount() > 0 ) {
2752 System.out.println( xml_parser.getErrorMessages().toString() );
2755 if ( phylogenies_4.length != 1 ) {
2758 final Phylogeny s = phylogenies_4[ 0 ];
2759 if ( s.getNumberOfExternalNodes() != 6 ) {
2762 s.getNode( "first" );
2764 s.getNode( "\"<a'b&c'd\">\"" );
2765 s.getNode( "'''\"" );
2766 s.getNode( "\"\"\"" );
2767 s.getNode( "dick & doof" );
2769 catch ( final Exception e ) {
2770 e.printStackTrace( System.out );
2776 private static boolean testPhyloXMLparsingValidating() {
2778 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2779 PhyloXmlParser xml_parser = null;
2781 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2783 catch ( final Exception e ) {
2784 // Do nothing -- means were not running from jar.
2786 if ( xml_parser == null ) {
2787 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2788 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2789 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2792 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2795 final Phylogeny[] phylogenies_0 = factory
2796 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ), xml_parser );
2797 if ( xml_parser.getErrorCount() > 0 ) {
2798 System.out.println( xml_parser.getErrorMessages().toString() );
2801 if ( phylogenies_0.length != 3 ) {
2805 catch ( final Exception e ) {
2806 e.printStackTrace( System.out );
2812 private static boolean testBasicProtein() {
2814 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2815 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2816 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2817 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2818 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2819 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2820 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2821 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2822 p0.addProteinDomain( y );
2823 p0.addProteinDomain( e );
2824 p0.addProteinDomain( b );
2825 p0.addProteinDomain( c );
2826 p0.addProteinDomain( d );
2827 p0.addProteinDomain( a );
2828 p0.addProteinDomain( x );
2829 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2832 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2836 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2837 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2838 aa0.addProteinDomain( a1 );
2839 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2842 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2846 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2847 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2848 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2849 aa1.addProteinDomain( a11 );
2850 aa1.addProteinDomain( a12 );
2851 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2854 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2857 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2858 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2861 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2864 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2867 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2868 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2871 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2874 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2877 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2880 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2881 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2884 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2887 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2890 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2893 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2894 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2897 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2900 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2903 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2907 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2908 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2909 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2910 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2911 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2912 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2913 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2914 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2915 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2916 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2917 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2918 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2919 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2920 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2921 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2922 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2923 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2924 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2925 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2926 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2927 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2928 p00.addProteinDomain( y0 );
2929 p00.addProteinDomain( e0 );
2930 p00.addProteinDomain( b0 );
2931 p00.addProteinDomain( c0 );
2932 p00.addProteinDomain( d0 );
2933 p00.addProteinDomain( a0 );
2934 p00.addProteinDomain( x0 );
2935 p00.addProteinDomain( y1 );
2936 p00.addProteinDomain( y2 );
2937 p00.addProteinDomain( y3 );
2938 p00.addProteinDomain( e1 );
2939 p00.addProteinDomain( e2 );
2940 p00.addProteinDomain( e3 );
2941 p00.addProteinDomain( e4 );
2942 p00.addProteinDomain( e5 );
2943 p00.addProteinDomain( z0 );
2944 p00.addProteinDomain( z1 );
2945 p00.addProteinDomain( z2 );
2946 p00.addProteinDomain( zz0 );
2947 p00.addProteinDomain( zz1 );
2948 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2951 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2954 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2957 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2960 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" ) ) {
2963 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2964 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2965 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2966 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2967 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2968 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2969 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2970 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2971 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2972 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2973 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2974 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2975 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2976 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2977 p.addProteinDomain( B15 );
2978 p.addProteinDomain( C50 );
2979 p.addProteinDomain( A60 );
2980 p.addProteinDomain( A30 );
2981 p.addProteinDomain( C70 );
2982 p.addProteinDomain( B35 );
2983 p.addProteinDomain( B40 );
2984 p.addProteinDomain( A0 );
2985 p.addProteinDomain( A10 );
2986 p.addProteinDomain( A20 );
2987 p.addProteinDomain( B25 );
2988 p.addProteinDomain( D80 );
2989 List<String> domains_ids = new ArrayList<String>();
2990 domains_ids.add( "A" );
2991 domains_ids.add( "B" );
2992 domains_ids.add( "C" );
2993 if ( !p.contains( domains_ids, false ) ) {
2996 if ( !p.contains( domains_ids, true ) ) {
2999 domains_ids.add( "X" );
3000 if ( p.contains( domains_ids, false ) ) {
3003 if ( p.contains( domains_ids, true ) ) {
3006 domains_ids = new ArrayList<String>();
3007 domains_ids.add( "A" );
3008 domains_ids.add( "C" );
3009 domains_ids.add( "D" );
3010 if ( !p.contains( domains_ids, false ) ) {
3013 if ( !p.contains( domains_ids, true ) ) {
3016 domains_ids = new ArrayList<String>();
3017 domains_ids.add( "A" );
3018 domains_ids.add( "D" );
3019 domains_ids.add( "C" );
3020 if ( !p.contains( domains_ids, false ) ) {
3023 if ( p.contains( domains_ids, true ) ) {
3026 domains_ids = new ArrayList<String>();
3027 domains_ids.add( "A" );
3028 domains_ids.add( "A" );
3029 domains_ids.add( "B" );
3030 if ( !p.contains( domains_ids, false ) ) {
3033 if ( !p.contains( domains_ids, true ) ) {
3036 domains_ids = new ArrayList<String>();
3037 domains_ids.add( "A" );
3038 domains_ids.add( "A" );
3039 domains_ids.add( "A" );
3040 domains_ids.add( "B" );
3041 domains_ids.add( "B" );
3042 if ( !p.contains( domains_ids, false ) ) {
3045 if ( !p.contains( domains_ids, true ) ) {
3048 domains_ids = new ArrayList<String>();
3049 domains_ids.add( "A" );
3050 domains_ids.add( "A" );
3051 domains_ids.add( "B" );
3052 domains_ids.add( "A" );
3053 domains_ids.add( "B" );
3054 domains_ids.add( "B" );
3055 domains_ids.add( "A" );
3056 domains_ids.add( "B" );
3057 domains_ids.add( "C" );
3058 domains_ids.add( "A" );
3059 domains_ids.add( "C" );
3060 domains_ids.add( "D" );
3061 if ( !p.contains( domains_ids, false ) ) {
3064 if ( p.contains( domains_ids, true ) ) {
3068 catch ( final Exception e ) {
3069 e.printStackTrace( System.out );
3075 private static boolean testBasicTable() {
3077 final BasicTable<String> t0 = new BasicTable<String>();
3078 if ( t0.getNumberOfColumns() != 0 ) {
3081 if ( t0.getNumberOfRows() != 0 ) {
3084 t0.setValue( 3, 2, "23" );
3085 t0.setValue( 10, 1, "error" );
3086 t0.setValue( 10, 1, "110" );
3087 t0.setValue( 9, 1, "19" );
3088 t0.setValue( 1, 10, "101" );
3089 t0.setValue( 10, 10, "1010" );
3090 t0.setValue( 100, 10, "10100" );
3091 t0.setValue( 0, 0, "00" );
3092 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3095 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3098 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3101 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3104 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3107 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3110 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3113 if ( t0.getNumberOfColumns() != 101 ) {
3116 if ( t0.getNumberOfRows() != 11 ) {
3119 if ( t0.getValueAsString( 49, 4 ) != null ) {
3122 final String l = ForesterUtil.getLineSeparator();
3123 final StringBuffer source = new StringBuffer();
3124 source.append( "" + l );
3125 source.append( "# 1 1 1 1 1 1 1 1" + l );
3126 source.append( " 00 01 02 03" + l );
3127 source.append( " 10 11 12 13 " + l );
3128 source.append( "20 21 22 23 " + l );
3129 source.append( " 30 31 32 33" + l );
3130 source.append( "40 41 42 43" + l );
3131 source.append( " # 1 1 1 1 1 " + l );
3132 source.append( "50 51 52 53 54" + l );
3133 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3134 if ( t1.getNumberOfColumns() != 5 ) {
3137 if ( t1.getNumberOfRows() != 6 ) {
3140 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3143 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3146 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3149 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3152 final StringBuffer source1 = new StringBuffer();
3153 source1.append( "" + l );
3154 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3155 source1.append( " 00; 01 ;02;03" + l );
3156 source1.append( " 10; 11; 12; 13 " + l );
3157 source1.append( "20; 21; 22; 23 " + l );
3158 source1.append( " 30; 31; 32; 33" + l );
3159 source1.append( "40;41;42;43" + l );
3160 source1.append( " # 1 1 1 1 1 " + l );
3161 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3162 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3163 if ( t2.getNumberOfColumns() != 5 ) {
3166 if ( t2.getNumberOfRows() != 6 ) {
3169 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3172 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3175 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3178 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3181 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3184 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3187 final StringBuffer source2 = new StringBuffer();
3188 source2.append( "" + l );
3189 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3190 source2.append( " 00; 01 ;02;03" + l );
3191 source2.append( " 10; 11; 12; 13 " + l );
3192 source2.append( "20; 21; 22; 23 " + l );
3193 source2.append( " " + l );
3194 source2.append( " 30; 31; 32; 33" + l );
3195 source2.append( "40;41;42;43" + l );
3196 source2.append( " comment: 1 1 1 1 1 " + l );
3197 source2.append( ";;;50 ; 52; 53;;54 " + l );
3198 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3204 if ( tl.size() != 2 ) {
3207 final BasicTable<String> t3 = tl.get( 0 );
3208 final BasicTable<String> t4 = tl.get( 1 );
3209 if ( t3.getNumberOfColumns() != 4 ) {
3212 if ( t3.getNumberOfRows() != 3 ) {
3215 if ( t4.getNumberOfColumns() != 4 ) {
3218 if ( t4.getNumberOfRows() != 3 ) {
3221 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3224 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3228 catch ( final Exception e ) {
3229 e.printStackTrace( System.out );
3235 private static boolean testBasicTolXMLparsing() {
3237 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3238 final TolParser parser = new TolParser();
3239 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3240 if ( parser.getErrorCount() > 0 ) {
3241 System.out.println( parser.getErrorMessages().toString() );
3244 if ( phylogenies_0.length != 1 ) {
3247 final Phylogeny t1 = phylogenies_0[ 0 ];
3248 if ( t1.getNumberOfExternalNodes() != 5 ) {
3251 if ( !t1.isRooted() ) {
3254 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3257 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3260 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3261 .equals( "Rhombozoa" ) ) {
3264 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3267 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3268 if ( parser.getErrorCount() > 0 ) {
3269 System.out.println( parser.getErrorMessages().toString() );
3272 if ( phylogenies_1.length != 1 ) {
3275 final Phylogeny t2 = phylogenies_1[ 0 ];
3276 if ( t2.getNumberOfExternalNodes() != 664 ) {
3279 if ( !t2.isRooted() ) {
3282 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3285 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3288 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3291 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3294 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3295 .equals( "Aquificae" ) ) {
3298 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3299 .equals( "Aquifex" ) ) {
3302 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3303 if ( parser.getErrorCount() > 0 ) {
3304 System.out.println( parser.getErrorMessages().toString() );
3307 if ( phylogenies_2.length != 1 ) {
3310 final Phylogeny t3 = phylogenies_2[ 0 ];
3311 if ( t3.getNumberOfExternalNodes() != 184 ) {
3314 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3317 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3320 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3323 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3324 if ( parser.getErrorCount() > 0 ) {
3325 System.out.println( parser.getErrorMessages().toString() );
3328 if ( phylogenies_3.length != 1 ) {
3331 final Phylogeny t4 = phylogenies_3[ 0 ];
3332 if ( t4.getNumberOfExternalNodes() != 1 ) {
3335 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3338 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3341 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3344 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3345 if ( parser.getErrorCount() > 0 ) {
3346 System.out.println( parser.getErrorMessages().toString() );
3349 if ( phylogenies_4.length != 1 ) {
3352 final Phylogeny t5 = phylogenies_4[ 0 ];
3353 if ( t5.getNumberOfExternalNodes() != 13 ) {
3356 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3359 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3362 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3366 catch ( final Exception e ) {
3367 e.printStackTrace( System.out );
3373 private static boolean testBasicTreeMethods() {
3375 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3376 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3377 if ( t2.getNumberOfExternalNodes() != 4 ) {
3380 if ( t2.calculateHeight( false ) != 8.5 ) {
3383 if ( !t2.isCompletelyBinary() ) {
3386 if ( t2.isEmpty() ) {
3389 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3390 if ( t3.getNumberOfExternalNodes() != 5 ) {
3393 if ( t3.calculateHeight( true ) != 11 ) {
3396 if ( t3.isCompletelyBinary() ) {
3399 final PhylogenyNode n = t3.getNode( "ABC" );
3400 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))",
3401 new NHXParser() )[ 0 ];
3402 if ( t4.getNumberOfExternalNodes() != 9 ) {
3405 if ( t4.calculateHeight( false ) != 11 ) {
3408 if ( t4.isCompletelyBinary() ) {
3411 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)" );
3412 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3413 if ( t5.getNumberOfExternalNodes() != 8 ) {
3416 if ( t5.calculateHeight( false ) != 15 ) {
3419 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)" );
3420 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3421 if ( t6.calculateHeight( true ) != 15 ) {
3424 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)" );
3425 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3426 if ( t7.calculateHeight( true ) != 15 ) {
3429 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)" );
3430 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3431 if ( t8.getNumberOfExternalNodes() != 10 ) {
3434 if ( t8.calculateHeight( true ) != 15 ) {
3437 final char[] a9 = new char[] { 'a' };
3438 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3439 if ( t9.calculateHeight( true ) != 0 ) {
3442 final char[] a10 = new char[] { 'a', ':', '6' };
3443 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3444 if ( t10.calculateHeight( true ) != 6 ) {
3448 catch ( final Exception e ) {
3449 e.printStackTrace( System.out );
3455 private static boolean testConfidenceAssessor() {
3457 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3458 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3459 final Phylogeny[] ev0 = factory.create(
3460 "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3462 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3463 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3466 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3469 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3470 final Phylogeny[] ev1 = factory.create(
3471 "((((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)));",
3473 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3474 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3477 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3480 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3481 final Phylogeny[] ev_b = factory.create(
3482 "((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",
3484 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3485 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3488 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3492 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3493 final Phylogeny[] ev1x = factory.create(
3494 "((((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)));",
3496 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3497 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3500 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3503 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3504 final Phylogeny[] ev_bx = factory.create(
3505 "((((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",
3507 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3508 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3511 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3514 final Phylogeny[] t2 = factory.create(
3515 "((((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);",
3517 final Phylogeny[] ev2 = factory.create(
3518 "((((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);",
3520 for( final Phylogeny target : t2 ) {
3521 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3523 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3524 new NHXParser() )[ 0 ];
3525 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3526 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3527 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3530 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3533 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3537 catch ( final Exception e ) {
3538 e.printStackTrace();
3544 private static boolean testCopyOfNodeData() {
3546 final PhylogenyNode n1 = PhylogenyNode
3547 .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]" );
3548 final PhylogenyNode n2 = n1.copyNodeData();
3549 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3553 catch ( final Exception e ) {
3554 e.printStackTrace();
3560 private static boolean testCreateBalancedPhylogeny() {
3562 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3563 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3566 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3569 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3570 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3573 if ( p1.getNumberOfExternalNodes() != 100 ) {
3577 catch ( final Exception e ) {
3578 e.printStackTrace();
3584 private static boolean testCreateUriForSeqWeb() {
3586 final PhylogenyNode n = new PhylogenyNode();
3587 n.setName( "tr|B3RJ64" );
3588 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3591 n.setName( "B0LM41_HUMAN" );
3592 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3593 .equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3596 n.setName( "NP_001025424" );
3597 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3598 .equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3601 n.setName( "_NM_001030253-" );
3602 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3603 .equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3606 n.setName( "XM_002122186" );
3607 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3608 .equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3611 n.setName( "dgh_AAA34956_gdg" );
3612 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3615 n.setName( "AAA34956" );
3616 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3619 n.setName( "GI:394892" );
3620 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3621 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3624 n.setName( "gi_394892" );
3625 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3626 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3629 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3630 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3631 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3634 n.setName( "P12345" );
3635 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3636 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3639 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3640 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3641 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3645 catch ( final Exception e ) {
3646 e.printStackTrace( System.out );
3652 private static boolean testDataObjects() {
3654 final Confidence s0 = new Confidence();
3655 final Confidence s1 = new Confidence();
3656 if ( !s0.isEqual( s1 ) ) {
3659 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3660 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3661 if ( s2.isEqual( s1 ) ) {
3664 if ( !s2.isEqual( s3 ) ) {
3667 final Confidence s4 = ( Confidence ) s3.copy();
3668 if ( !s4.isEqual( s3 ) ) {
3675 final Taxonomy t1 = new Taxonomy();
3676 final Taxonomy t2 = new Taxonomy();
3677 final Taxonomy t3 = new Taxonomy();
3678 final Taxonomy t4 = new Taxonomy();
3679 final Taxonomy t5 = new Taxonomy();
3680 t1.setIdentifier( new Identifier( "ecoli" ) );
3681 t1.setTaxonomyCode( "ECOLI" );
3682 t1.setScientificName( "E. coli" );
3683 t1.setCommonName( "coli" );
3684 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3685 if ( !t1.isEqual( t0 ) ) {
3688 t2.setIdentifier( new Identifier( "ecoli" ) );
3689 t2.setTaxonomyCode( "OTHER" );
3690 t2.setScientificName( "what" );
3691 t2.setCommonName( "something" );
3692 if ( !t1.isEqual( t2 ) ) {
3695 t2.setIdentifier( new Identifier( "nemve" ) );
3696 if ( t1.isEqual( t2 ) ) {
3699 t1.setIdentifier( null );
3700 t3.setTaxonomyCode( "ECOLI" );
3701 t3.setScientificName( "what" );
3702 t3.setCommonName( "something" );
3703 if ( !t1.isEqual( t3 ) ) {
3706 t1.setIdentifier( null );
3707 t1.setTaxonomyCode( "" );
3708 t4.setScientificName( "E. ColI" );
3709 t4.setCommonName( "something" );
3710 if ( !t1.isEqual( t4 ) ) {
3713 t4.setScientificName( "B. subtilis" );
3714 t4.setCommonName( "something" );
3715 if ( t1.isEqual( t4 ) ) {
3718 t1.setIdentifier( null );
3719 t1.setTaxonomyCode( "" );
3720 t1.setScientificName( "" );
3721 t5.setCommonName( "COLI" );
3722 if ( !t1.isEqual( t5 ) ) {
3725 t5.setCommonName( "vibrio" );
3726 if ( t1.isEqual( t5 ) ) {
3731 final Identifier id0 = new Identifier( "123", "pfam" );
3732 final Identifier id1 = ( Identifier ) id0.copy();
3733 if ( !id1.isEqual( id1 ) ) {
3736 if ( !id1.isEqual( id0 ) ) {
3739 if ( !id0.isEqual( id1 ) ) {
3746 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3747 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3748 if ( !pd1.isEqual( pd1 ) ) {
3751 if ( !pd1.isEqual( pd0 ) ) {
3756 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3757 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3758 if ( !pd3.isEqual( pd3 ) ) {
3761 if ( !pd2.isEqual( pd3 ) ) {
3764 if ( !pd0.isEqual( pd3 ) ) {
3769 // DomainArchitecture
3770 // ------------------
3771 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3772 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3773 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3774 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3775 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3776 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3781 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3782 if ( ds0.getNumberOfDomains() != 4 ) {
3785 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3786 if ( !ds0.isEqual( ds0 ) ) {
3789 if ( !ds0.isEqual( ds1 ) ) {
3792 if ( ds1.getNumberOfDomains() != 4 ) {
3795 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3800 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3801 if ( ds0.isEqual( ds2 ) ) {
3807 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3808 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3809 System.out.println( ds3.toNHX() );
3812 if ( ds3.getNumberOfDomains() != 3 ) {
3817 final Event e1 = new Event( Event.EventType.fusion );
3818 if ( e1.isDuplication() ) {
3821 if ( !e1.isFusion() ) {
3824 if ( !e1.asText().toString().equals( "fusion" ) ) {
3827 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3830 final Event e11 = new Event( Event.EventType.fusion );
3831 if ( !e11.isEqual( e1 ) ) {
3834 if ( !e11.toNHX().toString().equals( "" ) ) {
3837 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3838 if ( e2.isDuplication() ) {
3841 if ( !e2.isSpeciationOrDuplication() ) {
3844 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3847 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3850 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3853 if ( e11.isEqual( e2 ) ) {
3856 final Event e2c = ( Event ) e2.copy();
3857 if ( !e2c.isEqual( e2 ) ) {
3860 Event e3 = new Event( 1, 2, 3 );
3861 if ( e3.isDuplication() ) {
3864 if ( e3.isSpeciation() ) {
3867 if ( e3.isGeneLoss() ) {
3870 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3873 final Event e3c = ( Event ) e3.copy();
3874 final Event e3cc = ( Event ) e3c.copy();
3875 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3879 if ( !e3c.isEqual( e3cc ) ) {
3882 Event e4 = new Event( 1, 2, 3 );
3883 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3886 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3889 final Event e4c = ( Event ) e4.copy();
3891 final Event e4cc = ( Event ) e4c.copy();
3892 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3895 if ( !e4c.isEqual( e4cc ) ) {
3898 final Event e5 = new Event();
3899 if ( !e5.isUnassigned() ) {
3902 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3905 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3908 final Event e6 = new Event( 1, 0, 0 );
3909 if ( !e6.asText().toString().equals( "duplication" ) ) {
3912 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3915 final Event e7 = new Event( 0, 1, 0 );
3916 if ( !e7.asText().toString().equals( "speciation" ) ) {
3919 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3922 final Event e8 = new Event( 0, 0, 1 );
3923 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3926 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3930 catch ( final Exception e ) {
3931 e.printStackTrace( System.out );
3937 private static boolean testDeletionOfExternalNodes() {
3939 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3940 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3941 final PhylogenyWriter w = new PhylogenyWriter();
3942 if ( t0.isEmpty() ) {
3945 if ( t0.getNumberOfExternalNodes() != 1 ) {
3948 t0.deleteSubtree( t0.getNode( "A" ), false );
3949 if ( t0.getNumberOfExternalNodes() != 0 ) {
3952 if ( !t0.isEmpty() ) {
3955 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3956 if ( t1.getNumberOfExternalNodes() != 2 ) {
3959 t1.deleteSubtree( t1.getNode( "A" ), false );
3960 if ( t1.getNumberOfExternalNodes() != 1 ) {
3963 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3966 t1.deleteSubtree( t1.getNode( "B" ), false );
3967 if ( t1.getNumberOfExternalNodes() != 1 ) {
3970 t1.deleteSubtree( t1.getNode( "r" ), false );
3971 if ( !t1.isEmpty() ) {
3974 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3975 if ( t2.getNumberOfExternalNodes() != 3 ) {
3978 t2.deleteSubtree( t2.getNode( "B" ), false );
3979 if ( t2.getNumberOfExternalNodes() != 2 ) {
3982 t2.toNewHampshireX();
3983 PhylogenyNode n = t2.getNode( "A" );
3984 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3987 t2.deleteSubtree( t2.getNode( "A" ), false );
3988 if ( t2.getNumberOfExternalNodes() != 2 ) {
3991 t2.deleteSubtree( t2.getNode( "C" ), true );
3992 if ( t2.getNumberOfExternalNodes() != 1 ) {
3995 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3996 if ( t3.getNumberOfExternalNodes() != 4 ) {
3999 t3.deleteSubtree( t3.getNode( "B" ), true );
4000 if ( t3.getNumberOfExternalNodes() != 3 ) {
4003 n = t3.getNode( "A" );
4004 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
4007 n = n.getNextExternalNode();
4008 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4011 t3.deleteSubtree( t3.getNode( "A" ), true );
4012 if ( t3.getNumberOfExternalNodes() != 2 ) {
4015 n = t3.getNode( "C" );
4016 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4019 t3.deleteSubtree( t3.getNode( "C" ), true );
4020 if ( t3.getNumberOfExternalNodes() != 1 ) {
4023 t3.deleteSubtree( t3.getNode( "D" ), true );
4024 if ( t3.getNumberOfExternalNodes() != 0 ) {
4027 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4028 if ( t4.getNumberOfExternalNodes() != 6 ) {
4031 t4.deleteSubtree( t4.getNode( "B2" ), true );
4032 if ( t4.getNumberOfExternalNodes() != 5 ) {
4035 String s = w.toNewHampshire( t4, true ).toString();
4036 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4039 t4.deleteSubtree( t4.getNode( "B11" ), true );
4040 if ( t4.getNumberOfExternalNodes() != 4 ) {
4043 t4.deleteSubtree( t4.getNode( "C" ), true );
4044 if ( t4.getNumberOfExternalNodes() != 3 ) {
4047 n = t4.getNode( "A" );
4048 n = n.getNextExternalNode();
4049 if ( !n.getName().equals( "B12" ) ) {
4052 n = n.getNextExternalNode();
4053 if ( !n.getName().equals( "D" ) ) {
4056 s = w.toNewHampshire( t4, true ).toString();
4057 if ( !s.equals( "((A,B12),D);" ) ) {
4060 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4061 t5.deleteSubtree( t5.getNode( "A" ), true );
4062 if ( t5.getNumberOfExternalNodes() != 5 ) {
4065 s = w.toNewHampshire( t5, true ).toString();
4066 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
4069 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4070 t6.deleteSubtree( t6.getNode( "B11" ), true );
4071 if ( t6.getNumberOfExternalNodes() != 5 ) {
4074 s = w.toNewHampshire( t6, false ).toString();
4075 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4078 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4079 t7.deleteSubtree( t7.getNode( "B12" ), true );
4080 if ( t7.getNumberOfExternalNodes() != 5 ) {
4083 s = w.toNewHampshire( t7, true ).toString();
4084 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4087 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4088 t8.deleteSubtree( t8.getNode( "B2" ), true );
4089 if ( t8.getNumberOfExternalNodes() != 5 ) {
4092 s = w.toNewHampshire( t8, false ).toString();
4093 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4096 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4097 t9.deleteSubtree( t9.getNode( "C" ), true );
4098 if ( t9.getNumberOfExternalNodes() != 5 ) {
4101 s = w.toNewHampshire( t9, true ).toString();
4102 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4105 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4106 t10.deleteSubtree( t10.getNode( "D" ), true );
4107 if ( t10.getNumberOfExternalNodes() != 5 ) {
4110 s = w.toNewHampshire( t10, true ).toString();
4111 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4114 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4115 t11.deleteSubtree( t11.getNode( "A" ), true );
4116 if ( t11.getNumberOfExternalNodes() != 2 ) {
4119 s = w.toNewHampshire( t11, true ).toString();
4120 if ( !s.equals( "(B,C);" ) ) {
4123 t11.deleteSubtree( t11.getNode( "C" ), true );
4124 if ( t11.getNumberOfExternalNodes() != 1 ) {
4127 s = w.toNewHampshire( t11, false ).toString();
4128 if ( !s.equals( "B;" ) ) {
4131 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4132 t12.deleteSubtree( t12.getNode( "B2" ), true );
4133 if ( t12.getNumberOfExternalNodes() != 8 ) {
4136 s = w.toNewHampshire( t12, true ).toString();
4137 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4140 t12.deleteSubtree( t12.getNode( "B3" ), true );
4141 if ( t12.getNumberOfExternalNodes() != 7 ) {
4144 s = w.toNewHampshire( t12, true ).toString();
4145 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4148 t12.deleteSubtree( t12.getNode( "C3" ), true );
4149 if ( t12.getNumberOfExternalNodes() != 6 ) {
4152 s = w.toNewHampshire( t12, true ).toString();
4153 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4156 t12.deleteSubtree( t12.getNode( "A1" ), true );
4157 if ( t12.getNumberOfExternalNodes() != 5 ) {
4160 s = w.toNewHampshire( t12, true ).toString();
4161 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4164 t12.deleteSubtree( t12.getNode( "B1" ), true );
4165 if ( t12.getNumberOfExternalNodes() != 4 ) {
4168 s = w.toNewHampshire( t12, true ).toString();
4169 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4172 t12.deleteSubtree( t12.getNode( "A3" ), true );
4173 if ( t12.getNumberOfExternalNodes() != 3 ) {
4176 s = w.toNewHampshire( t12, true ).toString();
4177 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4180 t12.deleteSubtree( t12.getNode( "A2" ), true );
4181 if ( t12.getNumberOfExternalNodes() != 2 ) {
4184 s = w.toNewHampshire( t12, true ).toString();
4185 if ( !s.equals( "(C1,C2);" ) ) {
4188 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4189 t13.deleteSubtree( t13.getNode( "D" ), true );
4190 if ( t13.getNumberOfExternalNodes() != 4 ) {
4193 s = w.toNewHampshire( t13, true ).toString();
4194 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4197 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4198 t14.deleteSubtree( t14.getNode( "E" ), true );
4199 if ( t14.getNumberOfExternalNodes() != 5 ) {
4202 s = w.toNewHampshire( t14, true ).toString();
4203 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4206 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4207 t15.deleteSubtree( t15.getNode( "B2" ), true );
4208 if ( t15.getNumberOfExternalNodes() != 11 ) {
4211 t15.deleteSubtree( t15.getNode( "B1" ), true );
4212 if ( t15.getNumberOfExternalNodes() != 10 ) {
4215 t15.deleteSubtree( t15.getNode( "B3" ), true );
4216 if ( t15.getNumberOfExternalNodes() != 9 ) {
4219 t15.deleteSubtree( t15.getNode( "B4" ), true );
4220 if ( t15.getNumberOfExternalNodes() != 8 ) {
4223 t15.deleteSubtree( t15.getNode( "A1" ), true );
4224 if ( t15.getNumberOfExternalNodes() != 7 ) {
4227 t15.deleteSubtree( t15.getNode( "C4" ), true );
4228 if ( t15.getNumberOfExternalNodes() != 6 ) {
4232 catch ( final Exception e ) {
4233 e.printStackTrace( System.out );
4239 private static boolean testDescriptiveStatistics() {
4241 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4242 dss1.addValue( 82 );
4243 dss1.addValue( 78 );
4244 dss1.addValue( 70 );
4245 dss1.addValue( 58 );
4246 dss1.addValue( 42 );
4247 if ( dss1.getN() != 5 ) {
4250 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4253 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4256 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4259 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4262 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4265 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4268 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4271 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4274 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4277 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4280 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4283 dss1.addValue( 123 );
4284 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4287 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4290 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4293 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4294 dss2.addValue( -1.85 );
4295 dss2.addValue( 57.5 );
4296 dss2.addValue( 92.78 );
4297 dss2.addValue( 57.78 );
4298 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4301 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4304 final double[] a = dss2.getDataAsDoubleArray();
4305 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4308 dss2.addValue( -100 );
4309 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4312 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4315 final double[] ds = new double[ 14 ];
4330 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4331 if ( bins.length != 4 ) {
4334 if ( bins[ 0 ] != 2 ) {
4337 if ( bins[ 1 ] != 3 ) {
4340 if ( bins[ 2 ] != 4 ) {
4343 if ( bins[ 3 ] != 5 ) {
4346 final double[] ds1 = new double[ 9 ];
4356 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4357 if ( bins1.length != 4 ) {
4360 if ( bins1[ 0 ] != 2 ) {
4363 if ( bins1[ 1 ] != 3 ) {
4366 if ( bins1[ 2 ] != 0 ) {
4369 if ( bins1[ 3 ] != 4 ) {
4372 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4373 if ( bins1_1.length != 3 ) {
4376 if ( bins1_1[ 0 ] != 3 ) {
4379 if ( bins1_1[ 1 ] != 2 ) {
4382 if ( bins1_1[ 2 ] != 4 ) {
4385 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4386 if ( bins1_2.length != 3 ) {
4389 if ( bins1_2[ 0 ] != 2 ) {
4392 if ( bins1_2[ 1 ] != 2 ) {
4395 if ( bins1_2[ 2 ] != 2 ) {
4398 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4412 dss3.addValue( 10 );
4413 dss3.addValue( 10 );
4414 dss3.addValue( 10 );
4415 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4416 histo.toStringBuffer( 10, '=', 40, 5 );
4417 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4419 catch ( final Exception e ) {
4420 e.printStackTrace( System.out );
4426 private static boolean testDir( final String file ) {
4428 final File f = new File( file );
4429 if ( !f.exists() ) {
4432 if ( !f.isDirectory() ) {
4435 if ( !f.canRead() ) {
4439 catch ( final Exception e ) {
4445 private static boolean testEbiEntryRetrieval() {
4447 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4448 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4449 System.out.println( entry.getAccession() );
4452 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4453 System.out.println( entry.getTaxonomyScientificName() );
4456 if ( !entry.getSequenceName()
4457 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4458 System.out.println( entry.getSequenceName() );
4461 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4462 System.out.println( entry.getGeneName() );
4465 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4466 System.out.println( entry.getTaxonomyIdentifier() );
4469 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4470 System.out.println( entry.getAnnotations().first().getRefValue() );
4473 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4474 System.out.println( entry.getAnnotations().first().getRefSource() );
4477 if ( entry.getCrossReferences().size() < 1 ) {
4480 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4481 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4484 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4485 System.out.println( entry1.getTaxonomyScientificName() );
4488 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4489 System.out.println( entry1.getSequenceName() );
4492 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4493 System.out.println( entry1.getTaxonomyIdentifier() );
4496 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4497 System.out.println( entry1.getGeneName() );
4500 if ( entry1.getCrossReferences().size() < 1 ) {
4503 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4504 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4507 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4508 System.out.println( entry2.getTaxonomyScientificName() );
4511 if ( !entry2.getSequenceName()
4512 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4513 System.out.println( entry2.getSequenceName() );
4516 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4517 System.out.println( entry2.getTaxonomyIdentifier() );
4520 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4521 System.out.println( entry2.getGeneName() );
4524 if ( entry2.getCrossReferences().size() < 1 ) {
4527 if ( !entry2.getChromosome().equals( "20" ) ) {
4530 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4533 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4534 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4537 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4538 System.out.println( entry3.getTaxonomyScientificName() );
4541 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4542 System.out.println( entry3.getSequenceName() );
4545 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4546 System.out.println( entry3.getTaxonomyIdentifier() );
4549 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4550 System.out.println( entry3.getSequenceSymbol() );
4553 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4556 if ( entry3.getCrossReferences().size() < 1 ) {
4559 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4560 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4563 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4564 System.out.println( entry4.getTaxonomyScientificName() );
4567 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4568 System.out.println( entry4.getSequenceName() );
4571 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4572 System.out.println( entry4.getTaxonomyIdentifier() );
4575 if ( !entry4.getGeneName().equals( "ras" ) ) {
4576 System.out.println( entry4.getGeneName() );
4579 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4580 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4583 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4584 System.out.println( entry5.getTaxonomyScientificName() );
4587 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4588 System.out.println( entry5.getSequenceName() );
4591 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4592 System.out.println( entry5.getTaxonomyIdentifier() );
4595 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4596 if ( !entry6.getAccession().equals( "M30539" ) ) {
4599 if ( !entry6.getGeneName().equals( "ras" ) ) {
4602 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4605 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4608 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4611 if ( entry6.getCrossReferences().size() < 1 ) {
4615 catch ( final IOException e ) {
4616 System.out.println();
4617 System.out.println( "the following might be due to absence internet connection:" );
4618 e.printStackTrace( System.out );
4621 catch ( final Exception e ) {
4622 e.printStackTrace();
4628 private static boolean testExternalNodeRelatedMethods() {
4630 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4631 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4632 PhylogenyNode n = t1.getNode( "A" );
4633 n = n.getNextExternalNode();
4634 if ( !n.getName().equals( "B" ) ) {
4637 n = n.getNextExternalNode();
4638 if ( !n.getName().equals( "C" ) ) {
4641 n = n.getNextExternalNode();
4642 if ( !n.getName().equals( "D" ) ) {
4645 n = t1.getNode( "B" );
4646 while ( !n.isLastExternalNode() ) {
4647 n = n.getNextExternalNode();
4649 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4650 n = t2.getNode( "A" );
4651 n = n.getNextExternalNode();
4652 if ( !n.getName().equals( "B" ) ) {
4655 n = n.getNextExternalNode();
4656 if ( !n.getName().equals( "C" ) ) {
4659 n = n.getNextExternalNode();
4660 if ( !n.getName().equals( "D" ) ) {
4663 n = t2.getNode( "B" );
4664 while ( !n.isLastExternalNode() ) {
4665 n = n.getNextExternalNode();
4667 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4668 n = t3.getNode( "A" );
4669 n = n.getNextExternalNode();
4670 if ( !n.getName().equals( "B" ) ) {
4673 n = n.getNextExternalNode();
4674 if ( !n.getName().equals( "C" ) ) {
4677 n = n.getNextExternalNode();
4678 if ( !n.getName().equals( "D" ) ) {
4681 n = n.getNextExternalNode();
4682 if ( !n.getName().equals( "E" ) ) {
4685 n = n.getNextExternalNode();
4686 if ( !n.getName().equals( "F" ) ) {
4689 n = n.getNextExternalNode();
4690 if ( !n.getName().equals( "G" ) ) {
4693 n = n.getNextExternalNode();
4694 if ( !n.getName().equals( "H" ) ) {
4697 n = t3.getNode( "B" );
4698 while ( !n.isLastExternalNode() ) {
4699 n = n.getNextExternalNode();
4701 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4702 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4703 final PhylogenyNode node = iter.next();
4705 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4706 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4707 final PhylogenyNode node = iter.next();
4709 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))",
4710 new NHXParser() )[ 0 ];
4711 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4712 if ( !iter.next().getName().equals( "A" ) ) {
4715 if ( !iter.next().getName().equals( "B" ) ) {
4718 if ( !iter.next().getName().equals( "C" ) ) {
4721 if ( !iter.next().getName().equals( "D" ) ) {
4724 if ( !iter.next().getName().equals( "E" ) ) {
4727 if ( !iter.next().getName().equals( "F" ) ) {
4730 if ( iter.hasNext() ) {
4734 catch ( final Exception e ) {
4735 e.printStackTrace( System.out );
4741 private static boolean testExtractSNFromNodeName() {
4743 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4746 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4749 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4752 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4753 .equals( "Mus musculus musculus" ) ) {
4756 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4757 .equals( "Mus musculus musculus" ) ) {
4760 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4761 .equals( "Mus musculus musculus" ) ) {
4764 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4765 .equals( "Mus musculus musculus" ) ) {
4768 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4771 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4772 .equals( "Mus musculus musculus" ) ) {
4775 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4776 .equals( "Mus musculus musculus" ) ) {
4780 .extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4783 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4786 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4789 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4792 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4793 .equals( "Mus musculus musculus" ) ) {
4796 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4799 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4802 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4805 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4808 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4811 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4814 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4817 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4820 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4821 .equals( "Mus musculus" ) ) {
4824 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4825 .equals( "Mus musculus" ) ) {
4828 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4831 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4832 .equals( "Mus musculus musculus" ) ) {
4835 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4836 .equals( "Mus musculus musculus" ) ) {
4839 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4840 .equals( "Mus musculus musculus" ) ) {
4843 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4846 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4847 .equals( "Pilostyles mexicana" ) ) {
4850 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4851 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4854 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4855 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4858 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4859 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4862 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4863 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4866 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4867 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4870 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4871 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4874 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4875 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4878 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4879 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4882 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4883 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4886 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4887 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4890 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4891 .equals( "Escherichia coli (strain K12)" ) ) {
4894 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4895 .equals( "Escherichia coli (strain K12)" ) ) {
4898 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4899 .equals( "Escherichia coli (str. K12)" ) ) {
4902 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4903 .equals( "Escherichia coli (str. K12)" ) ) {
4906 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4907 .equals( "Escherichia coli (str. K12)" ) ) {
4910 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4911 .equals( "Escherichia coli (var. K12)" ) ) {
4914 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4915 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4918 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4919 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4923 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4924 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4927 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4928 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4932 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4933 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4936 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4937 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4940 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4941 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4944 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4947 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4950 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4953 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4954 .equals( "Macrocera sp." ) ) {
4957 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4960 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4961 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4964 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4965 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4968 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4969 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4972 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4973 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4977 catch ( final Exception e ) {
4978 e.printStackTrace( System.out );
4984 private static boolean testExtractTaxonomyDataFromNodeName() {
4986 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4987 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4990 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4991 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4994 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4995 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4998 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4999 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5002 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
5003 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5006 n = new PhylogenyNode( "HNRPR_HUMAN" );
5007 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5010 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
5011 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5015 catch ( final Exception e ) {
5016 e.printStackTrace( System.out );
5022 private static boolean testExtractTaxonomyCodeFromNodeName() {
5024 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE",
5025 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5028 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5029 .equals( "SOYBN" ) ) {
5032 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5033 .equals( "ARATH" ) ) {
5036 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5037 .equals( "ARATH" ) ) {
5040 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5041 .equals( "RAT" ) ) {
5044 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5045 .equals( "RAT" ) ) {
5048 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1",
5049 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5052 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5053 .equals( "SOYBN" ) ) {
5056 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5057 .equals( "SOYBN" ) ) {
5060 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5061 .equals( "SOYBN" ) ) {
5064 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5065 .equals( "SOYBN" ) ) {
5068 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5069 .equals( "SOYBN" ) ) {
5072 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5073 .equals( "SOYBN" ) ) {
5076 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
5077 .equals( "SOYBN" ) ) {
5080 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5081 .equals( "SOYBN" ) ) {
5084 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx",
5085 TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5088 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5089 .equals( "SOYBN" ) ) {
5093 .extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5094 .equals( "ECOLI" ) ) {
5097 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blagg_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5098 .equals( "9YX45" ) ) {
5101 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5102 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5103 .equals( "MOUSE" ) ) {
5106 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5107 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5108 .equals( "MOUSE" ) ) {
5111 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5112 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5113 .equals( "MOUSE" ) ) {
5116 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5117 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5120 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5121 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5124 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5125 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5126 .equals( "RAT" ) ) {
5129 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5130 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5131 .equals( "RAT" ) ) {
5134 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5135 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5136 .equals( "RAT" ) ) {
5139 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5140 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5143 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5144 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5147 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5148 .equals( "RAT" ) ) {
5151 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5152 .equals( "PIG" ) ) {
5156 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5157 .equals( "MOUSE" ) ) {
5160 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5161 .equals( "MOUSE" ) ) {
5164 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ",
5165 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5169 catch ( final Exception e ) {
5170 e.printStackTrace( System.out );
5176 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5178 PhylogenyNode n = new PhylogenyNode();
5179 n.setName( "tr|B3RJ64" );
5180 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5183 n.setName( "tr.B3RJ64" );
5184 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5187 n.setName( "tr=B3RJ64" );
5188 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5191 n.setName( "tr-B3RJ64" );
5192 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5195 n.setName( "tr/B3RJ64" );
5196 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5199 n.setName( "tr\\B3RJ64" );
5200 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5203 n.setName( "tr_B3RJ64" );
5204 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5207 n.setName( " tr|B3RJ64 " );
5208 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5211 n.setName( "-tr|B3RJ64-" );
5212 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5215 n.setName( "-tr=B3RJ64-" );
5216 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5219 n.setName( "_tr=B3RJ64_" );
5220 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5223 n.setName( " tr_tr|B3RJ64_sp|123 " );
5224 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5227 n.setName( "B3RJ64" );
5228 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5231 n.setName( "sp|B3RJ64" );
5232 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5235 n.setName( "sp|B3RJ64C" );
5236 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5239 n.setName( "sp B3RJ64" );
5240 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5243 n.setName( "sp|B3RJ6X" );
5244 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5247 n.setName( "sp|B3RJ6" );
5248 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5251 n.setName( "K1PYK7_CRAGI" );
5252 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5255 n.setName( "K1PYK7_PEA" );
5256 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5259 n.setName( "K1PYK7_RAT" );
5260 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5263 n.setName( "K1PYK7_PIG" );
5264 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5267 n.setName( "~K1PYK7_PIG~" );
5268 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5271 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5272 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5275 n.setName( "K1PYKX_CRAGI" );
5276 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5279 n.setName( "XXXXX_CRAGI" );
5280 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5283 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5284 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5287 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5288 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5291 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5292 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5295 n = new PhylogenyNode();
5296 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5297 seq.setSymbol( "K1PYK7_CRAGI" );
5298 n.getNodeData().addSequence( seq );
5299 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5302 seq.setSymbol( "tr|B3RJ64" );
5303 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5306 n = new PhylogenyNode();
5307 seq = new org.forester.phylogeny.data.Sequence();
5308 seq.setName( "K1PYK7_CRAGI" );
5309 n.getNodeData().addSequence( seq );
5310 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5313 seq.setName( "tr|B3RJ64" );
5314 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5317 n = new PhylogenyNode();
5318 seq = new org.forester.phylogeny.data.Sequence();
5319 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5320 n.getNodeData().addSequence( seq );
5321 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5324 n = new PhylogenyNode();
5325 seq = new org.forester.phylogeny.data.Sequence();
5326 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5327 n.getNodeData().addSequence( seq );
5328 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5332 n = new PhylogenyNode();
5333 n.setName( "ACP19736" );
5334 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5337 n = new PhylogenyNode();
5338 n.setName( "|ACP19736|" );
5339 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5343 catch ( final Exception e ) {
5344 e.printStackTrace( System.out );
5350 private static boolean testFastaParser() {
5352 final FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5353 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5360 final FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5361 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5368 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5369 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5372 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5375 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5378 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5381 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5384 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5388 catch ( final Exception e ) {
5389 e.printStackTrace();
5395 private static boolean testGenbankAccessorParsing() {
5396 //The format for GenBank Accession numbers are:
5397 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5398 //Protein: 3 letters + 5 numerals
5399 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5400 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5403 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5406 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" )
5407 .equals( "AY423861.24" ) ) {
5410 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5413 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5416 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5419 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5422 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5425 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5428 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5431 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5434 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5437 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5440 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5446 private static boolean testGeneralMsaParser() {
5448 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5449 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5450 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5451 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5452 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5453 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5454 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5455 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5456 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5459 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5462 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5465 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5468 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5471 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5474 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5477 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5480 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5483 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5486 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5489 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5492 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5493 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5496 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5499 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5502 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5503 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5506 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5509 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5512 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5513 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5516 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5519 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5523 catch ( final Exception e ) {
5524 e.printStackTrace();
5530 private static boolean testGeneralTable() {
5532 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5533 t0.setValue( 3, 2, "23" );
5534 t0.setValue( 10, 1, "error" );
5535 t0.setValue( 10, 1, "110" );
5536 t0.setValue( 9, 1, "19" );
5537 t0.setValue( 1, 10, "101" );
5538 t0.setValue( 10, 10, "1010" );
5539 t0.setValue( 100, 10, "10100" );
5540 t0.setValue( 0, 0, "00" );
5541 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5544 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5547 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5550 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5553 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5556 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5559 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5562 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5565 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5568 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5569 t1.setValue( "3", "2", "23" );
5570 t1.setValue( "10", "1", "error" );
5571 t1.setValue( "10", "1", "110" );
5572 t1.setValue( "9", "1", "19" );
5573 t1.setValue( "1", "10", "101" );
5574 t1.setValue( "10", "10", "1010" );
5575 t1.setValue( "100", "10", "10100" );
5576 t1.setValue( "0", "0", "00" );
5577 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5578 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5581 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5584 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5587 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5590 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5593 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5596 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5599 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5602 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5605 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5609 catch ( final Exception e ) {
5610 e.printStackTrace( System.out );
5616 private static boolean testGetDistance() {
5618 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5619 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",
5620 new NHXParser() )[ 0 ];
5621 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5624 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5627 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5630 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5633 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5636 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5639 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5642 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5645 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5648 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5651 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5654 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5657 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5660 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5663 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5666 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5669 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5672 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5675 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5678 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5681 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5684 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5687 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5690 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5693 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5696 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5699 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5702 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5705 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5708 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5711 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5714 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",
5715 new NHXParser() )[ 0 ];
5716 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5719 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5722 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5725 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5728 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5731 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5734 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5737 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5740 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5743 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5746 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5750 catch ( final Exception e ) {
5751 e.printStackTrace( System.out );
5757 private static boolean testGetLCA() {
5759 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5760 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5761 new NHXParser() )[ 0 ];
5762 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5763 if ( !A.getName().equals( "A" ) ) {
5766 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5767 if ( !gh.getName().equals( "gh" ) ) {
5770 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5771 if ( !ab.getName().equals( "ab" ) ) {
5774 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5775 if ( !ab2.getName().equals( "ab" ) ) {
5778 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5779 if ( !gh2.getName().equals( "gh" ) ) {
5782 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5783 if ( !gh3.getName().equals( "gh" ) ) {
5786 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5787 if ( !abc.getName().equals( "abc" ) ) {
5790 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5791 if ( !abc2.getName().equals( "abc" ) ) {
5794 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5795 if ( !abcd.getName().equals( "abcd" ) ) {
5798 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5799 if ( !abcd2.getName().equals( "abcd" ) ) {
5802 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5803 if ( !abcdef.getName().equals( "abcdef" ) ) {
5806 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5807 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5810 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5811 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5814 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5815 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5818 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5819 if ( !abcde.getName().equals( "abcde" ) ) {
5822 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5823 if ( !abcde2.getName().equals( "abcde" ) ) {
5826 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5827 if ( !r.getName().equals( "abcdefgh" ) ) {
5830 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5831 if ( !r2.getName().equals( "abcdefgh" ) ) {
5834 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5835 if ( !r3.getName().equals( "abcdefgh" ) ) {
5838 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5839 if ( !abcde3.getName().equals( "abcde" ) ) {
5842 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5843 if ( !abcde4.getName().equals( "abcde" ) ) {
5846 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5847 if ( !ab3.getName().equals( "ab" ) ) {
5850 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5851 if ( !ab4.getName().equals( "ab" ) ) {
5854 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5855 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5856 if ( !cd.getName().equals( "cd" ) ) {
5859 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5860 if ( !cd2.getName().equals( "cd" ) ) {
5863 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5864 if ( !cde.getName().equals( "cde" ) ) {
5867 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5868 if ( !cde2.getName().equals( "cde" ) ) {
5871 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5872 if ( !cdef.getName().equals( "cdef" ) ) {
5875 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5876 if ( !cdef2.getName().equals( "cdef" ) ) {
5879 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5880 if ( !cdef3.getName().equals( "cdef" ) ) {
5883 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5884 if ( !rt.getName().equals( "r" ) ) {
5887 final Phylogeny p3 = factory.create(
5888 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5889 new NHXParser() )[ 0 ];
5890 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5891 if ( !bc_3.getName().equals( "bc" ) ) {
5894 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5895 if ( !ac_3.getName().equals( "abc" ) ) {
5898 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5899 if ( !ad_3.getName().equals( "abcde" ) ) {
5902 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5903 if ( !af_3.getName().equals( "abcdef" ) ) {
5906 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5907 if ( !ag_3.getName().equals( "" ) ) {
5910 if ( !ag_3.isRoot() ) {
5913 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5914 if ( !al_3.getName().equals( "" ) ) {
5917 if ( !al_3.isRoot() ) {
5920 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5921 if ( !kl_3.getName().equals( "" ) ) {
5924 if ( !kl_3.isRoot() ) {
5927 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5928 if ( !fl_3.getName().equals( "" ) ) {
5931 if ( !fl_3.isRoot() ) {
5934 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5935 if ( !gk_3.getName().equals( "ghijk" ) ) {
5938 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5939 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5940 if ( !r_4.getName().equals( "r" ) ) {
5943 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5944 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5945 if ( !r_5.getName().equals( "root" ) ) {
5948 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5949 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5950 if ( !r_6.getName().equals( "rot" ) ) {
5953 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5954 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5955 if ( !r_7.getName().equals( "rott" ) ) {
5959 catch ( final Exception e ) {
5960 e.printStackTrace( System.out );
5966 private static boolean testGetLCA2() {
5968 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5969 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5970 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5971 PhylogenyMethods.preOrderReId( p_a );
5972 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5973 p_a.getNode( "a" ) );
5974 if ( !p_a_1.getName().equals( "a" ) ) {
5977 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5978 PhylogenyMethods.preOrderReId( p_b );
5979 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5980 p_b.getNode( "a" ) );
5981 if ( !p_b_1.getName().equals( "b" ) ) {
5984 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5985 p_b.getNode( "b" ) );
5986 if ( !p_b_2.getName().equals( "b" ) ) {
5989 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5990 PhylogenyMethods.preOrderReId( p_c );
5991 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5992 p_c.getNode( "a" ) );
5993 if ( !p_c_1.getName().equals( "b" ) ) {
5996 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5997 p_c.getNode( "c" ) );
5998 if ( !p_c_2.getName().equals( "c" ) ) {
5999 System.out.println( p_c_2.getName() );
6003 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
6004 p_c.getNode( "b" ) );
6005 if ( !p_c_3.getName().equals( "b" ) ) {
6008 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
6009 p_c.getNode( "a" ) );
6010 if ( !p_c_4.getName().equals( "c" ) ) {
6013 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
6014 new NHXParser() )[ 0 ];
6015 PhylogenyMethods.preOrderReId( p1 );
6016 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6017 p1.getNode( "A" ) );
6018 if ( !A.getName().equals( "A" ) ) {
6021 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
6022 p1.getNode( "gh" ) );
6023 if ( !gh.getName().equals( "gh" ) ) {
6026 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6027 p1.getNode( "B" ) );
6028 if ( !ab.getName().equals( "ab" ) ) {
6031 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6032 p1.getNode( "A" ) );
6033 if ( !ab2.getName().equals( "ab" ) ) {
6036 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6037 p1.getNode( "G" ) );
6038 if ( !gh2.getName().equals( "gh" ) ) {
6041 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
6042 p1.getNode( "H" ) );
6043 if ( !gh3.getName().equals( "gh" ) ) {
6046 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
6047 p1.getNode( "A" ) );
6048 if ( !abc.getName().equals( "abc" ) ) {
6051 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6052 p1.getNode( "C" ) );
6053 if ( !abc2.getName().equals( "abc" ) ) {
6056 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6057 p1.getNode( "D" ) );
6058 if ( !abcd.getName().equals( "abcd" ) ) {
6061 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
6062 p1.getNode( "A" ) );
6063 if ( !abcd2.getName().equals( "abcd" ) ) {
6066 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6067 p1.getNode( "F" ) );
6068 if ( !abcdef.getName().equals( "abcdef" ) ) {
6071 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6072 p1.getNode( "A" ) );
6073 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6076 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6077 p1.getNode( "F" ) );
6078 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6081 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6082 p1.getNode( "ab" ) );
6083 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6086 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6087 p1.getNode( "E" ) );
6088 if ( !abcde.getName().equals( "abcde" ) ) {
6091 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6092 p1.getNode( "A" ) );
6093 if ( !abcde2.getName().equals( "abcde" ) ) {
6096 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6097 p1.getNode( "abcdefgh" ) );
6098 if ( !r.getName().equals( "abcdefgh" ) ) {
6101 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6102 p1.getNode( "H" ) );
6103 if ( !r2.getName().equals( "abcdefgh" ) ) {
6106 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6107 p1.getNode( "A" ) );
6108 if ( !r3.getName().equals( "abcdefgh" ) ) {
6111 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6112 p1.getNode( "abcde" ) );
6113 if ( !abcde3.getName().equals( "abcde" ) ) {
6116 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6117 p1.getNode( "E" ) );
6118 if ( !abcde4.getName().equals( "abcde" ) ) {
6121 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6122 p1.getNode( "B" ) );
6123 if ( !ab3.getName().equals( "ab" ) ) {
6126 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6127 p1.getNode( "ab" ) );
6128 if ( !ab4.getName().equals( "ab" ) ) {
6131 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6132 PhylogenyMethods.preOrderReId( p2 );
6133 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6134 p2.getNode( "d" ) );
6135 if ( !cd.getName().equals( "cd" ) ) {
6138 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6139 p2.getNode( "c" ) );
6140 if ( !cd2.getName().equals( "cd" ) ) {
6143 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6144 p2.getNode( "e" ) );
6145 if ( !cde.getName().equals( "cde" ) ) {
6148 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6149 p2.getNode( "c" ) );
6150 if ( !cde2.getName().equals( "cde" ) ) {
6153 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6154 p2.getNode( "f" ) );
6155 if ( !cdef.getName().equals( "cdef" ) ) {
6158 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6159 p2.getNode( "f" ) );
6160 if ( !cdef2.getName().equals( "cdef" ) ) {
6163 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6164 p2.getNode( "d" ) );
6165 if ( !cdef3.getName().equals( "cdef" ) ) {
6168 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6169 p2.getNode( "a" ) );
6170 if ( !rt.getName().equals( "r" ) ) {
6173 final Phylogeny p3 = factory.create(
6174 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6175 new NHXParser() )[ 0 ];
6176 PhylogenyMethods.preOrderReId( p3 );
6177 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6178 p3.getNode( "c" ) );
6179 if ( !bc_3.getName().equals( "bc" ) ) {
6182 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6183 p3.getNode( "c" ) );
6184 if ( !ac_3.getName().equals( "abc" ) ) {
6187 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6188 p3.getNode( "d" ) );
6189 if ( !ad_3.getName().equals( "abcde" ) ) {
6192 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6193 p3.getNode( "f" ) );
6194 if ( !af_3.getName().equals( "abcdef" ) ) {
6197 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6198 p3.getNode( "g" ) );
6199 if ( !ag_3.getName().equals( "" ) ) {
6202 if ( !ag_3.isRoot() ) {
6205 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6206 p3.getNode( "l" ) );
6207 if ( !al_3.getName().equals( "" ) ) {
6210 if ( !al_3.isRoot() ) {
6213 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6214 p3.getNode( "l" ) );
6215 if ( !kl_3.getName().equals( "" ) ) {
6218 if ( !kl_3.isRoot() ) {
6221 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6222 p3.getNode( "l" ) );
6223 if ( !fl_3.getName().equals( "" ) ) {
6226 if ( !fl_3.isRoot() ) {
6229 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6230 p3.getNode( "k" ) );
6231 if ( !gk_3.getName().equals( "ghijk" ) ) {
6234 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6235 PhylogenyMethods.preOrderReId( p4 );
6236 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6237 p4.getNode( "c" ) );
6238 if ( !r_4.getName().equals( "r" ) ) {
6241 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6242 PhylogenyMethods.preOrderReId( p5 );
6243 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6244 p5.getNode( "c" ) );
6245 if ( !r_5.getName().equals( "root" ) ) {
6248 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6249 PhylogenyMethods.preOrderReId( p6 );
6250 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6251 p6.getNode( "a" ) );
6252 if ( !r_6.getName().equals( "rot" ) ) {
6255 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6256 PhylogenyMethods.preOrderReId( p7 );
6257 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6258 p7.getNode( "e" ) );
6259 if ( !r_7.getName().equals( "rott" ) ) {
6262 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6263 p7.getNode( "a" ) );
6264 if ( !r_71.getName().equals( "rott" ) ) {
6267 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6268 p7.getNode( "rott" ) );
6269 if ( !r_72.getName().equals( "rott" ) ) {
6272 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6273 p7.getNode( "a" ) );
6274 if ( !r_73.getName().equals( "rott" ) ) {
6277 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6278 p7.getNode( "rott" ) );
6279 if ( !r_74.getName().equals( "rott" ) ) {
6282 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6283 p7.getNode( "e" ) );
6284 if ( !r_75.getName().equals( "e" ) ) {
6288 catch ( final Exception e ) {
6289 e.printStackTrace( System.out );
6295 private static boolean testHmmscanOutputParser() {
6296 final String test_dir = Test.PATH_TO_TEST_DATA;
6298 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6299 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ),
6301 INDIVIDUAL_SCORE_CUTOFF.NONE );
6303 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6304 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ),
6306 INDIVIDUAL_SCORE_CUTOFF.NONE );
6307 final List<Protein> proteins = parser2.parse();
6308 if ( parser2.getProteinsEncountered() != 4 ) {
6311 if ( proteins.size() != 4 ) {
6314 if ( parser2.getDomainsEncountered() != 69 ) {
6317 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6320 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6323 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6326 final Protein p1 = proteins.get( 0 );
6327 if ( p1.getNumberOfProteinDomains() != 15 ) {
6330 if ( p1.getLength() != 850 ) {
6333 final Protein p2 = proteins.get( 1 );
6334 if ( p2.getNumberOfProteinDomains() != 51 ) {
6337 if ( p2.getLength() != 1291 ) {
6340 final Protein p3 = proteins.get( 2 );
6341 if ( p3.getNumberOfProteinDomains() != 2 ) {
6344 final Protein p4 = proteins.get( 3 );
6345 if ( p4.getNumberOfProteinDomains() != 1 ) {
6348 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6351 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6354 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6357 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6360 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6363 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6366 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6370 catch ( final Exception e ) {
6371 e.printStackTrace( System.out );
6377 private static boolean testLastExternalNodeMethods() {
6379 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6380 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6381 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6382 final PhylogenyNode n1 = t0.getNode( "A" );
6383 if ( n1.isLastExternalNode() ) {
6386 final PhylogenyNode n2 = t0.getNode( "B" );
6387 if ( n2.isLastExternalNode() ) {
6390 final PhylogenyNode n3 = t0.getNode( "C" );
6391 if ( n3.isLastExternalNode() ) {
6394 final PhylogenyNode n4 = t0.getNode( "D" );
6395 if ( !n4.isLastExternalNode() ) {
6399 catch ( final Exception e ) {
6400 e.printStackTrace( System.out );
6406 private static boolean testLevelOrderIterator() {
6408 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6409 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6410 PhylogenyNodeIterator it0;
6411 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6414 for( it0.reset(); it0.hasNext(); ) {
6417 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6418 if ( !it.next().getName().equals( "r" ) ) {
6421 if ( !it.next().getName().equals( "ab" ) ) {
6424 if ( !it.next().getName().equals( "cd" ) ) {
6427 if ( !it.next().getName().equals( "A" ) ) {
6430 if ( !it.next().getName().equals( "B" ) ) {
6433 if ( !it.next().getName().equals( "C" ) ) {
6436 if ( !it.next().getName().equals( "D" ) ) {
6439 if ( it.hasNext() ) {
6442 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",
6443 new NHXParser() )[ 0 ];
6444 PhylogenyNodeIterator it2;
6445 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6448 for( it2.reset(); it2.hasNext(); ) {
6451 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6452 if ( !it3.next().getName().equals( "r" ) ) {
6455 if ( !it3.next().getName().equals( "abc" ) ) {
6458 if ( !it3.next().getName().equals( "defg" ) ) {
6461 if ( !it3.next().getName().equals( "A" ) ) {
6464 if ( !it3.next().getName().equals( "B" ) ) {
6467 if ( !it3.next().getName().equals( "C" ) ) {
6470 if ( !it3.next().getName().equals( "D" ) ) {
6473 if ( !it3.next().getName().equals( "E" ) ) {
6476 if ( !it3.next().getName().equals( "F" ) ) {
6479 if ( !it3.next().getName().equals( "G" ) ) {
6482 if ( !it3.next().getName().equals( "1" ) ) {
6485 if ( !it3.next().getName().equals( "2" ) ) {
6488 if ( !it3.next().getName().equals( "3" ) ) {
6491 if ( !it3.next().getName().equals( "4" ) ) {
6494 if ( !it3.next().getName().equals( "5" ) ) {
6497 if ( !it3.next().getName().equals( "6" ) ) {
6500 if ( !it3.next().getName().equals( "f1" ) ) {
6503 if ( !it3.next().getName().equals( "f2" ) ) {
6506 if ( !it3.next().getName().equals( "f3" ) ) {
6509 if ( !it3.next().getName().equals( "a" ) ) {
6512 if ( !it3.next().getName().equals( "b" ) ) {
6515 if ( !it3.next().getName().equals( "f21" ) ) {
6518 if ( !it3.next().getName().equals( "X" ) ) {
6521 if ( !it3.next().getName().equals( "Y" ) ) {
6524 if ( !it3.next().getName().equals( "Z" ) ) {
6527 if ( it3.hasNext() ) {
6530 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6531 PhylogenyNodeIterator it4;
6532 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6535 for( it4.reset(); it4.hasNext(); ) {
6538 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6539 if ( !it5.next().getName().equals( "r" ) ) {
6542 if ( !it5.next().getName().equals( "A" ) ) {
6545 if ( !it5.next().getName().equals( "B" ) ) {
6548 if ( !it5.next().getName().equals( "C" ) ) {
6551 if ( !it5.next().getName().equals( "D" ) ) {
6554 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6555 PhylogenyNodeIterator it6;
6556 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6559 for( it6.reset(); it6.hasNext(); ) {
6562 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6563 if ( !it7.next().getName().equals( "A" ) ) {
6566 if ( it.hasNext() ) {
6570 catch ( final Exception e ) {
6571 e.printStackTrace( System.out );
6577 private static boolean testMafft( final String path ) {
6579 final List<String> opts = new ArrayList<String>();
6580 opts.add( "--maxiterate" );
6582 opts.add( "--localpair" );
6583 opts.add( "--quiet" );
6585 final MsaInferrer mafft = Mafft.createInstance( path );
6586 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6587 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6590 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6594 catch ( final Exception e ) {
6595 e.printStackTrace( System.out );
6601 private static boolean testMidpointrooting() {
6603 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6604 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6605 PhylogenyMethods.midpointRoot( t0 );
6606 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6609 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6612 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6616 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",
6617 new NHXParser() )[ 0 ];
6618 if ( !t1.isRooted() ) {
6621 PhylogenyMethods.midpointRoot( t1 );
6622 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6625 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6628 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6631 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6634 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6637 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6640 t1.reRoot( t1.getNode( "A" ) );
6641 PhylogenyMethods.midpointRoot( t1 );
6642 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6645 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6648 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6651 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6654 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6658 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6662 catch ( final Exception e ) {
6663 e.printStackTrace( System.out );
6669 private static boolean testMsaQualityMethod() {
6671 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6672 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6673 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6674 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6675 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6680 final Msa msa = BasicMsa.createInstance( l );
6681 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6684 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6687 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6690 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6693 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6696 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6699 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6703 catch ( final Exception e ) {
6704 e.printStackTrace( System.out );
6710 private static boolean testMsaEntropy() {
6712 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6713 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6714 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6715 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6716 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6721 final Msa msa = BasicMsa.createInstance( l );
6722 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6724 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6725 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6726 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6727 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6728 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6729 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6730 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6731 // System.out.println();
6732 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6733 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6734 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6735 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6736 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6737 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6738 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6739 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6740 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6741 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6742 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6743 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6744 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6745 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6746 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6747 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6748 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6749 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6750 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6751 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6752 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6753 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6754 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6755 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6756 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6757 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6758 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6759 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6760 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6761 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6762 final Msa msa2 = BasicMsa.createInstance( l2 );
6763 // System.out.println();
6764 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6765 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6766 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6768 catch ( final Exception e ) {
6769 e.printStackTrace( System.out );
6775 private static boolean testDeleteableMsa() {
6777 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6778 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6779 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6780 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6781 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6782 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6783 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6790 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6791 dmsa0.deleteRow( "b", false );
6792 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6795 dmsa0.deleteRow( "e", false );
6796 dmsa0.deleteRow( "a", false );
6797 dmsa0.deleteRow( "f", false );
6798 if ( dmsa0.getLength() != 4 ) {
6801 if ( dmsa0.getNumberOfSequences() != 2 ) {
6804 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6807 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6810 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6813 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6816 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6819 dmsa0.deleteRow( "c", false );
6820 dmsa0.deleteRow( "d", false );
6821 if ( dmsa0.getNumberOfSequences() != 0 ) {
6825 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6826 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6827 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6828 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6829 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6830 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6831 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6838 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6839 dmsa1.deleteGapOnlyColumns();
6840 dmsa1.deleteRow( "a", false );
6841 dmsa1.deleteRow( "f", false );
6842 dmsa1.deleteRow( "d", false );
6843 dmsa1.deleteGapOnlyColumns();
6844 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6847 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6850 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6853 dmsa1.deleteRow( "c", false );
6854 dmsa1.deleteGapOnlyColumns();
6855 final Writer w0 = new StringWriter();
6856 dmsa1.write( w0, MSA_FORMAT.FASTA );
6857 final Writer w1 = new StringWriter();
6858 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6859 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6862 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6865 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6866 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6867 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6868 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6869 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6870 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6871 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6878 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6879 dmsa2.deleteGapColumns( 0.5 );
6880 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6883 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6886 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6889 dmsa2.deleteGapColumns( 0.2 );
6890 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6893 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6896 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6899 dmsa2.deleteGapColumns( 0 );
6900 dmsa2.deleteRow( "a", false );
6901 dmsa2.deleteRow( "b", false );
6902 dmsa2.deleteRow( "f", false );
6903 dmsa2.deleteRow( "e", false );
6904 dmsa2.setIdentifier( 0, "new_c" );
6905 dmsa2.setIdentifier( 1, "new_d" );
6906 dmsa2.setResidueAt( 0, 0, 'x' );
6907 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6908 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6911 final Writer w = new StringWriter();
6912 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6913 final String phylip = w.toString();
6914 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6915 System.out.println( phylip );
6918 final Writer w2 = new StringWriter();
6919 dmsa2.write( w2, MSA_FORMAT.FASTA );
6920 final String fasta = w2.toString();
6921 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6922 System.out.println( fasta );
6926 catch ( final Exception e ) {
6927 e.printStackTrace( System.out );
6933 private static boolean testNextNodeWithCollapsing() {
6935 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6937 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6938 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6939 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
6940 t0.getNode( "cd" ).setCollapse( true );
6941 t0.getNode( "cde" ).setCollapse( true );
6942 n = t0.getFirstExternalNode();
6943 while ( n != null ) {
6945 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6947 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6950 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6953 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6956 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6959 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6962 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6966 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6967 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
6968 t1.getNode( "ab" ).setCollapse( true );
6969 t1.getNode( "cd" ).setCollapse( true );
6970 t1.getNode( "cde" ).setCollapse( true );
6971 n = t1.getNode( "ab" );
6972 ext = new ArrayList<PhylogenyNode>();
6973 while ( n != null ) {
6975 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6977 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6980 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6983 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6986 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6989 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6993 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6994 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
6995 t2.getNode( "ab" ).setCollapse( true );
6996 t2.getNode( "cd" ).setCollapse( true );
6997 t2.getNode( "cde" ).setCollapse( true );
6998 t2.getNode( "c" ).setCollapse( true );
6999 t2.getNode( "d" ).setCollapse( true );
7000 t2.getNode( "e" ).setCollapse( true );
7001 t2.getNode( "gh" ).setCollapse( true );
7002 n = t2.getNode( "ab" );
7003 ext = new ArrayList<PhylogenyNode>();
7004 while ( n != null ) {
7006 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7008 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7011 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7014 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7017 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
7021 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7022 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
7023 t3.getNode( "ab" ).setCollapse( true );
7024 t3.getNode( "cd" ).setCollapse( true );
7025 t3.getNode( "cde" ).setCollapse( true );
7026 t3.getNode( "c" ).setCollapse( true );
7027 t3.getNode( "d" ).setCollapse( true );
7028 t3.getNode( "e" ).setCollapse( true );
7029 t3.getNode( "gh" ).setCollapse( true );
7030 t3.getNode( "fgh" ).setCollapse( true );
7031 n = t3.getNode( "ab" );
7032 ext = new ArrayList<PhylogenyNode>();
7033 while ( n != null ) {
7035 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7037 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7040 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7043 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
7047 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7048 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
7049 t4.getNode( "ab" ).setCollapse( true );
7050 t4.getNode( "cd" ).setCollapse( true );
7051 t4.getNode( "cde" ).setCollapse( true );
7052 t4.getNode( "c" ).setCollapse( true );
7053 t4.getNode( "d" ).setCollapse( true );
7054 t4.getNode( "e" ).setCollapse( true );
7055 t4.getNode( "gh" ).setCollapse( true );
7056 t4.getNode( "fgh" ).setCollapse( true );
7057 t4.getNode( "abcdefgh" ).setCollapse( true );
7058 n = t4.getNode( "abcdefgh" );
7059 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
7062 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7063 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
7065 n = t5.getFirstExternalNode();
7066 while ( n != null ) {
7068 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7070 if ( ext.size() != 8 ) {
7073 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7076 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7079 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7082 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7085 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7088 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7091 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7094 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7097 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7098 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7100 t6.getNode( "ab" ).setCollapse( true );
7101 n = t6.getNode( "ab" );
7102 while ( n != null ) {
7104 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7106 if ( ext.size() != 7 ) {
7109 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7112 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7115 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7118 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7121 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7124 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7127 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7130 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7131 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7133 t7.getNode( "cd" ).setCollapse( true );
7134 n = t7.getNode( "a" );
7135 while ( n != null ) {
7137 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7139 if ( ext.size() != 7 ) {
7142 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7145 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7148 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7151 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7154 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7157 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7160 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7163 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7164 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7166 t8.getNode( "cd" ).setCollapse( true );
7167 t8.getNode( "c" ).setCollapse( true );
7168 t8.getNode( "d" ).setCollapse( true );
7169 n = t8.getNode( "a" );
7170 while ( n != null ) {
7172 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7174 if ( ext.size() != 7 ) {
7177 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7180 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7183 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7184 System.out.println( "2 fail" );
7187 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7190 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7193 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7196 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7199 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7200 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7202 t9.getNode( "gh" ).setCollapse( true );
7203 n = t9.getNode( "a" );
7204 while ( n != null ) {
7206 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7208 if ( ext.size() != 7 ) {
7211 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7214 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7217 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7220 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7223 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7226 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7229 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7232 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7233 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7235 t10.getNode( "gh" ).setCollapse( true );
7236 t10.getNode( "g" ).setCollapse( true );
7237 t10.getNode( "h" ).setCollapse( true );
7238 n = t10.getNode( "a" );
7239 while ( n != null ) {
7241 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7243 if ( ext.size() != 7 ) {
7246 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7249 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7252 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7255 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7258 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7261 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7264 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7267 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7268 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7270 t11.getNode( "gh" ).setCollapse( true );
7271 t11.getNode( "fgh" ).setCollapse( true );
7272 n = t11.getNode( "a" );
7273 while ( n != null ) {
7275 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7277 if ( ext.size() != 6 ) {
7280 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7283 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7286 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7289 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7292 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7295 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7298 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7299 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7301 t12.getNode( "gh" ).setCollapse( true );
7302 t12.getNode( "fgh" ).setCollapse( true );
7303 t12.getNode( "g" ).setCollapse( true );
7304 t12.getNode( "h" ).setCollapse( true );
7305 t12.getNode( "f" ).setCollapse( true );
7306 n = t12.getNode( "a" );
7307 while ( n != null ) {
7309 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7311 if ( ext.size() != 6 ) {
7314 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7317 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7320 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7323 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7326 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7329 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7332 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7333 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7335 t13.getNode( "ab" ).setCollapse( true );
7336 t13.getNode( "b" ).setCollapse( true );
7337 t13.getNode( "fgh" ).setCollapse( true );
7338 t13.getNode( "gh" ).setCollapse( true );
7339 n = t13.getNode( "ab" );
7340 while ( n != null ) {
7342 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7344 if ( ext.size() != 5 ) {
7347 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7350 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7353 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7356 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7359 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7362 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7363 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7365 t14.getNode( "ab" ).setCollapse( true );
7366 t14.getNode( "a" ).setCollapse( true );
7367 t14.getNode( "fgh" ).setCollapse( true );
7368 t14.getNode( "gh" ).setCollapse( true );
7369 n = t14.getNode( "ab" );
7370 while ( n != null ) {
7372 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7374 if ( ext.size() != 5 ) {
7377 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7380 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7383 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7386 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7389 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7392 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" );
7393 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7395 t15.getNode( "ab" ).setCollapse( true );
7396 t15.getNode( "a" ).setCollapse( true );
7397 t15.getNode( "fgh" ).setCollapse( true );
7398 t15.getNode( "gh" ).setCollapse( true );
7399 n = t15.getNode( "ab" );
7400 while ( n != null ) {
7402 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7404 if ( ext.size() != 6 ) {
7407 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7410 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7413 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7416 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7419 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7422 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7427 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" );
7428 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7430 t16.getNode( "ab" ).setCollapse( true );
7431 t16.getNode( "a" ).setCollapse( true );
7432 t16.getNode( "fgh" ).setCollapse( true );
7433 t16.getNode( "gh" ).setCollapse( true );
7434 t16.getNode( "cd" ).setCollapse( true );
7435 t16.getNode( "cde" ).setCollapse( true );
7436 t16.getNode( "d" ).setCollapse( true );
7437 t16.getNode( "x" ).setCollapse( true );
7438 n = t16.getNode( "ab" );
7439 while ( n != null ) {
7441 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7443 if ( ext.size() != 4 ) {
7446 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7449 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7452 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7455 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7459 catch ( final Exception e ) {
7460 e.printStackTrace( System.out );
7466 private static boolean testNexusCharactersParsing() {
7468 final NexusCharactersParser parser = new NexusCharactersParser();
7469 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7471 String[] labels = parser.getCharStateLabels();
7472 if ( labels.length != 7 ) {
7475 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7478 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7481 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7484 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7487 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7490 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7493 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7496 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7498 labels = parser.getCharStateLabels();
7499 if ( labels.length != 7 ) {
7502 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7505 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7508 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7511 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7514 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7517 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7520 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7524 catch ( final Exception e ) {
7525 e.printStackTrace( System.out );
7531 private static boolean testNexusMatrixParsing() {
7533 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7534 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7536 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7537 if ( m.getNumberOfCharacters() != 9 ) {
7540 if ( m.getNumberOfIdentifiers() != 5 ) {
7543 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7546 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7549 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7552 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7555 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7558 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7561 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7564 // if ( labels.length != 7 ) {
7567 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7570 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7573 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7576 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7579 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7582 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7585 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7588 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7590 // labels = parser.getCharStateLabels();
7591 // if ( labels.length != 7 ) {
7594 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7597 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7600 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7603 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7606 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7609 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7612 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7616 catch ( final Exception e ) {
7617 e.printStackTrace( System.out );
7623 private static boolean testNexusTreeParsing() {
7625 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7626 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7627 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7628 if ( phylogenies.length != 1 ) {
7631 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7634 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7638 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7639 if ( phylogenies.length != 1 ) {
7642 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7645 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7649 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7650 if ( phylogenies.length != 1 ) {
7653 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7656 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7659 if ( phylogenies[ 0 ].isRooted() ) {
7663 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7664 if ( phylogenies.length != 18 ) {
7667 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7670 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7673 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7676 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7679 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7682 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7685 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7688 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7691 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7694 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7697 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7700 if ( phylogenies[ 8 ].isRooted() ) {
7703 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7706 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7709 if ( !phylogenies[ 9 ].isRooted() ) {
7712 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7715 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7718 if ( !phylogenies[ 10 ].isRooted() ) {
7721 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7724 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7727 if ( phylogenies[ 11 ].isRooted() ) {
7730 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7733 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7736 if ( !phylogenies[ 12 ].isRooted() ) {
7739 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7742 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7745 if ( !phylogenies[ 13 ].isRooted() ) {
7748 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7751 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7754 if ( !phylogenies[ 14 ].isRooted() ) {
7757 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7760 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7763 if ( phylogenies[ 15 ].isRooted() ) {
7766 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7769 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7772 if ( !phylogenies[ 16 ].isRooted() ) {
7775 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7778 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7781 if ( phylogenies[ 17 ].isRooted() ) {
7784 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7787 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7789 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7790 if ( phylogenies.length != 9 ) {
7793 if ( !isEqual( 0.48039661496919533,
7794 phylogenies[ 0 ].getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7797 if ( !isEqual( 0.3959796191512233,
7798 phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7801 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7804 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7807 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7810 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7813 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7817 catch ( final Exception e ) {
7818 e.printStackTrace( System.out );
7824 private static boolean testNexusTreeParsingIterating() {
7826 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7827 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7828 if ( !p.hasNext() ) {
7831 Phylogeny phy = p.next();
7832 if ( phy == null ) {
7835 if ( phy.getNumberOfExternalNodes() != 25 ) {
7838 if ( !phy.getName().equals( "" ) ) {
7841 if ( p.hasNext() ) {
7845 if ( phy != null ) {
7849 if ( !p.hasNext() ) {
7853 if ( phy == null ) {
7856 if ( phy.getNumberOfExternalNodes() != 25 ) {
7859 if ( !phy.getName().equals( "" ) ) {
7862 if ( p.hasNext() ) {
7866 if ( phy != null ) {
7869 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7870 if ( !p.hasNext() ) {
7874 if ( phy == null ) {
7877 if ( phy.getNumberOfExternalNodes() != 10 ) {
7880 if ( !phy.getName().equals( "name" ) ) {
7883 if ( p.hasNext() ) {
7887 if ( phy != null ) {
7891 if ( !p.hasNext() ) {
7895 if ( phy == null ) {
7898 if ( phy.getNumberOfExternalNodes() != 10 ) {
7901 if ( !phy.getName().equals( "name" ) ) {
7904 if ( p.hasNext() ) {
7908 if ( phy != null ) {
7911 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7912 if ( !p.hasNext() ) {
7916 if ( phy == null ) {
7919 if ( phy.getNumberOfExternalNodes() != 3 ) {
7922 if ( !phy.getName().equals( "" ) ) {
7925 if ( phy.isRooted() ) {
7928 if ( p.hasNext() ) {
7932 if ( phy != null ) {
7937 if ( !p.hasNext() ) {
7941 if ( phy == null ) {
7944 if ( phy.getNumberOfExternalNodes() != 3 ) {
7947 if ( !phy.getName().equals( "" ) ) {
7950 if ( p.hasNext() ) {
7954 if ( phy != null ) {
7958 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7959 if ( !p.hasNext() ) {
7964 if ( phy == null ) {
7967 if ( phy.getNumberOfExternalNodes() != 10 ) {
7970 if ( !phy.getName().equals( "tree 0" ) ) {
7974 if ( !p.hasNext() ) {
7978 if ( phy == null ) {
7981 if ( phy.getNumberOfExternalNodes() != 10 ) {
7984 if ( !phy.getName().equals( "tree 1" ) ) {
7988 if ( !p.hasNext() ) {
7992 if ( phy == null ) {
7995 if ( phy.getNumberOfExternalNodes() != 3 ) {
7996 System.out.println( phy.toString() );
7999 if ( !phy.getName().equals( "" ) ) {
8002 if ( phy.isRooted() ) {
8006 if ( !p.hasNext() ) {
8010 if ( phy == null ) {
8013 if ( phy.getNumberOfExternalNodes() != 4 ) {
8016 if ( !phy.getName().equals( "" ) ) {
8019 if ( !phy.isRooted() ) {
8023 if ( !p.hasNext() ) {
8027 if ( phy == null ) {
8030 if ( phy.getNumberOfExternalNodes() != 5 ) {
8031 System.out.println( phy.getNumberOfExternalNodes() );
8034 if ( !phy.getName().equals( "" ) ) {
8037 if ( !phy.isRooted() ) {
8041 if ( !p.hasNext() ) {
8045 if ( phy == null ) {
8048 if ( phy.getNumberOfExternalNodes() != 3 ) {
8051 if ( !phy.getName().equals( "" ) ) {
8054 if ( phy.isRooted() ) {
8058 if ( !p.hasNext() ) {
8062 if ( phy == null ) {
8065 if ( phy.getNumberOfExternalNodes() != 2 ) {
8068 if ( !phy.getName().equals( "" ) ) {
8071 if ( !phy.isRooted() ) {
8075 if ( !p.hasNext() ) {
8079 if ( phy.getNumberOfExternalNodes() != 3 ) {
8082 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8085 if ( !phy.isRooted() ) {
8089 if ( !p.hasNext() ) {
8093 if ( phy.getNumberOfExternalNodes() != 3 ) {
8096 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8099 if ( !phy.getName().equals( "tree 8" ) ) {
8103 if ( !p.hasNext() ) {
8107 if ( phy.getNumberOfExternalNodes() != 3 ) {
8110 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8113 if ( !phy.getName().equals( "tree 9" ) ) {
8117 if ( !p.hasNext() ) {
8121 if ( phy.getNumberOfExternalNodes() != 3 ) {
8124 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8127 if ( !phy.getName().equals( "tree 10" ) ) {
8130 if ( !phy.isRooted() ) {
8134 if ( !p.hasNext() ) {
8138 if ( phy.getNumberOfExternalNodes() != 3 ) {
8141 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8144 if ( !phy.getName().equals( "tree 11" ) ) {
8147 if ( phy.isRooted() ) {
8151 if ( !p.hasNext() ) {
8155 if ( phy.getNumberOfExternalNodes() != 3 ) {
8158 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8161 if ( !phy.getName().equals( "tree 12" ) ) {
8164 if ( !phy.isRooted() ) {
8168 if ( !p.hasNext() ) {
8172 if ( phy.getNumberOfExternalNodes() != 3 ) {
8175 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8178 if ( !phy.getName().equals( "tree 13" ) ) {
8181 if ( !phy.isRooted() ) {
8185 if ( !p.hasNext() ) {
8189 if ( phy.getNumberOfExternalNodes() != 10 ) {
8190 System.out.println( phy.getNumberOfExternalNodes() );
8193 if ( !phy.toNewHampshire()
8194 .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;" ) ) {
8195 System.out.println( phy.toNewHampshire() );
8198 if ( !phy.getName().equals( "tree 14" ) ) {
8201 if ( !phy.isRooted() ) {
8205 if ( !p.hasNext() ) {
8209 if ( phy.getNumberOfExternalNodes() != 10 ) {
8210 System.out.println( phy.getNumberOfExternalNodes() );
8213 if ( !phy.toNewHampshire()
8214 .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;" ) ) {
8215 System.out.println( phy.toNewHampshire() );
8218 if ( !phy.getName().equals( "tree 15" ) ) {
8221 if ( phy.isRooted() ) {
8225 if ( !p.hasNext() ) {
8229 if ( phy.getNumberOfExternalNodes() != 10 ) {
8230 System.out.println( phy.getNumberOfExternalNodes() );
8233 if ( !phy.toNewHampshire()
8234 .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;" ) ) {
8235 System.out.println( phy.toNewHampshire() );
8238 if ( !phy.getName().equals( "tree 16" ) ) {
8241 if ( !phy.isRooted() ) {
8245 if ( !p.hasNext() ) {
8249 if ( phy.getNumberOfExternalNodes() != 10 ) {
8250 System.out.println( phy.getNumberOfExternalNodes() );
8253 if ( !phy.toNewHampshire()
8254 .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;" ) ) {
8255 System.out.println( phy.toNewHampshire() );
8258 if ( !phy.getName().equals( "tree 17" ) ) {
8261 if ( phy.isRooted() ) {
8265 if ( p.hasNext() ) {
8269 if ( phy != null ) {
8274 if ( !p.hasNext() ) {
8278 if ( phy == null ) {
8281 if ( phy.getNumberOfExternalNodes() != 10 ) {
8284 if ( !phy.getName().equals( "tree 0" ) ) {
8288 if ( !p.hasNext() ) {
8292 if ( phy == null ) {
8295 if ( phy.getNumberOfExternalNodes() != 10 ) {
8298 if ( !phy.getName().equals( "tree 1" ) ) {
8302 if ( !p.hasNext() ) {
8306 if ( phy == null ) {
8309 if ( phy.getNumberOfExternalNodes() != 3 ) {
8312 if ( !phy.getName().equals( "" ) ) {
8315 if ( phy.isRooted() ) {
8319 if ( !p.hasNext() ) {
8323 if ( phy == null ) {
8326 if ( phy.getNumberOfExternalNodes() != 4 ) {
8329 if ( !phy.getName().equals( "" ) ) {
8332 if ( !phy.isRooted() ) {
8336 if ( !p.hasNext() ) {
8340 if ( phy == null ) {
8343 if ( phy.getNumberOfExternalNodes() != 5 ) {
8344 System.out.println( phy.getNumberOfExternalNodes() );
8347 if ( !phy.getName().equals( "" ) ) {
8350 if ( !phy.isRooted() ) {
8354 if ( !p.hasNext() ) {
8358 if ( phy == null ) {
8361 if ( phy.getNumberOfExternalNodes() != 3 ) {
8364 if ( !phy.getName().equals( "" ) ) {
8367 if ( phy.isRooted() ) {
8371 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8372 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8374 if ( !p2.hasNext() ) {
8378 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8381 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8385 if ( !p2.hasNext() ) {
8390 if ( !p2.hasNext() ) {
8395 if ( !p2.hasNext() ) {
8400 if ( !p2.hasNext() ) {
8405 if ( !p2.hasNext() ) {
8410 if ( !p2.hasNext() ) {
8415 if ( !p2.hasNext() ) {
8420 if ( !p2.hasNext() ) {
8424 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8427 if ( p2.hasNext() ) {
8431 if ( phy != null ) {
8436 if ( !p2.hasNext() ) {
8440 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8443 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8447 catch ( final Exception e ) {
8448 e.printStackTrace( System.out );
8454 private static boolean testNexusTreeParsingTranslating() {
8456 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8457 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8458 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8459 if ( phylogenies.length != 1 ) {
8462 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8465 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8468 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8471 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8474 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8475 .equals( "Aranaeus" ) ) {
8479 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8480 if ( phylogenies.length != 3 ) {
8483 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8486 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8489 if ( phylogenies[ 0 ].isRooted() ) {
8492 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8495 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8498 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8499 .equals( "Aranaeus" ) ) {
8502 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8505 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8508 if ( phylogenies[ 1 ].isRooted() ) {
8511 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8514 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8517 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8518 .equals( "Aranaeus" ) ) {
8521 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8524 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8527 if ( !phylogenies[ 2 ].isRooted() ) {
8530 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8533 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8536 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8537 .equals( "Aranaeus" ) ) {
8541 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8542 if ( phylogenies.length != 3 ) {
8545 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8548 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8551 if ( phylogenies[ 0 ].isRooted() ) {
8554 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8557 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8560 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8561 .equals( "Aranaeus" ) ) {
8564 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8567 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8570 if ( phylogenies[ 1 ].isRooted() ) {
8573 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8576 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8579 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8580 .equals( "Aranaeus" ) ) {
8583 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8586 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8589 if ( !phylogenies[ 2 ].isRooted() ) {
8592 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8595 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8598 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8599 .equals( "Aranaeus" ) ) {
8602 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8603 if ( phylogenies.length != 3 ) {
8606 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8611 catch ( final Exception e ) {
8612 e.printStackTrace( System.out );
8618 private static boolean testNHParsing() {
8620 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8621 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8622 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8625 final NHXParser nhxp = new NHXParser();
8626 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8627 nhxp.setReplaceUnderscores( true );
8628 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8629 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8632 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8635 final Phylogeny p1b = factory.create(
8636 " \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 ",
8637 new NHXParser() )[ 0 ];
8638 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8641 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8644 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8645 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8646 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8647 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8648 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8649 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8650 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8651 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8652 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8653 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8654 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8655 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; " + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8657 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8660 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8663 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8666 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8669 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8670 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8671 final String p16_S = "((A,B),C)";
8672 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8673 if ( p16.length != 1 ) {
8676 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8679 final String p17_S = "(C,(A,B))";
8680 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8681 if ( p17.length != 1 ) {
8684 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8687 final String p18_S = "((A,B),(C,D))";
8688 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8689 if ( p18.length != 1 ) {
8692 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8695 final String p19_S = "(((A,B),C),D)";
8696 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8697 if ( p19.length != 1 ) {
8700 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8703 final String p20_S = "(A,(B,(C,D)))";
8704 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8705 if ( p20.length != 1 ) {
8708 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8711 final String p21_S = "(A,(B,(C,(D,E))))";
8712 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8713 if ( p21.length != 1 ) {
8716 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8719 final String p22_S = "((((A,B),C),D),E)";
8720 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8721 if ( p22.length != 1 ) {
8724 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8727 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8728 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8729 if ( p23.length != 1 ) {
8730 System.out.println( "xl=" + p23.length );
8734 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8737 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8738 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8739 if ( p24.length != 1 ) {
8742 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8745 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8746 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8747 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8748 if ( p241.length != 2 ) {
8751 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8754 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8757 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8758 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8759 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8760 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8761 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8762 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8763 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8764 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8765 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8766 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8769 final String p26_S = "(A,B)ab";
8770 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8771 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8774 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8775 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8776 if ( p27s.length != 1 ) {
8777 System.out.println( "xxl=" + p27s.length );
8781 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8782 System.out.println( p27s[ 0 ].toNewHampshireX() );
8786 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8788 if ( p27.length != 1 ) {
8789 System.out.println( "yl=" + p27.length );
8793 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8794 System.out.println( p27[ 0 ].toNewHampshireX() );
8798 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8799 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8800 final String p28_S3 = "(A,B)ab";
8801 final String p28_S4 = "((((A,B),C),D),;E;)";
8802 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8804 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8807 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8810 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8813 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8816 if ( p28.length != 4 ) {
8819 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";
8820 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8821 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8824 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";
8825 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8826 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8829 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8830 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8831 if ( ( p32.length != 0 ) ) {
8834 final String p33_S = "A";
8835 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8836 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8839 final String p34_S = "B;";
8840 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8841 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8844 final String p35_S = "B:0.2";
8845 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8846 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8849 final String p36_S = "(A)";
8850 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8851 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8854 final String p37_S = "((A))";
8855 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8856 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8859 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8860 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8861 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8864 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8865 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8866 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8869 final String p40_S = "(A,B,C)";
8870 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8871 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8874 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8875 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8876 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8879 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8880 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8881 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8884 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)";
8885 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8886 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8889 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)))";
8890 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8891 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8894 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8895 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8896 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8899 final String p46_S = "";
8900 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8901 if ( p46.length != 0 ) {
8904 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(),
8905 new NHXParser() )[ 0 ];
8906 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8909 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(),
8910 new NHXParser() )[ 0 ];
8911 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8914 final Phylogeny p49 = factory
8915 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
8916 new NHXParser() )[ 0 ];
8917 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8920 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(),
8921 new NHXParser() )[ 0 ];
8922 if ( p50.getNode( "A" ) == null ) {
8925 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8926 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8929 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8932 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8933 .equals( "((A,B)88:2.0,C);" ) ) {
8936 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(),
8937 new NHXParser() )[ 0 ];
8938 if ( p51.getNode( "A(A" ) == null ) {
8941 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(),
8942 new NHXParser() )[ 0 ];
8943 if ( p52.getNode( "A(A" ) == null ) {
8946 final Phylogeny p53 = factory
8947 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
8948 new NHXParser() )[ 0 ];
8949 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8952 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(),
8953 new NHXParser() )[ 0 ];
8954 if ( p54.getNode( "A" ) == null ) {
8957 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8958 .equals( "((A,B)[88],C);" ) ) {
8961 final Phylogeny p55 = factory
8962 .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);" )
8963 .toString(), new NHXParser() )[ 0 ];
8964 if ( !p55.toNewHampshire()
8965 .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);" ) ) {
8966 System.out.println( p55.toNewHampshire() );
8969 final Phylogeny p56 = factory
8970 .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);" )
8971 .toString(), new NHXParser() )[ 0 ];
8972 if ( !p56.toNewHampshire()
8973 .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);" ) ) {
8974 System.out.println( p56.toNewHampshire() );
8977 final Phylogeny p57 = factory
8978 .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);" )
8979 .toString(), new NHXParser() )[ 0 ];
8980 if ( !p57.toNewHampshire()
8981 .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);" ) ) {
8982 System.out.println( p56.toNewHampshire() );
8985 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8986 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
8987 if ( !p58.toNewHampshire().equals( s58 ) ) {
8988 System.out.println( p58.toNewHampshire() );
8991 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8992 final Phylogeny p59 = factory.create( s59, new NHXParser() )[ 0 ];
8993 if ( !p59.toNewHampshire().equals( s59 ) ) {
8994 System.out.println( p59.toNewHampshire() );
8997 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8998 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
8999 if ( !p60.toNewHampshire().equals( s60 ) ) {
9000 System.out.println( p60.toNewHampshire() );
9003 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
9004 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
9005 if ( !p61.toNewHampshire()
9006 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
9007 System.out.println( p61.toNewHampshire() );
9010 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;";
9011 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
9012 if ( !p62.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9013 System.out.println( p62.toNewHampshire() );
9016 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)\"];";
9017 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
9018 if ( !p63.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9019 System.out.println( p63.toNewHampshire() );
9022 final String s64 = "((1,2):[95.5],3);";
9023 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
9024 if ( !p64.toNewHampshireX().equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
9025 System.out.println( p64.toNewHampshireX() );
9028 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
9029 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
9030 if ( !p65.toNewHampshireX().equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
9031 System.out.println( p65.toNewHampshireX() );
9034 final Phylogeny p66 = factory.create( "((A,B)ab:2[0.44],C)", new NHXParser() )[ 0 ];
9035 if ( !isEqual( 0.44, p66.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9038 final Phylogeny p67 = factory.create( "((A,B):2[0.67],C)", new NHXParser() )[ 0 ];
9039 if ( !isEqual( 0.67, p67.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9042 final Phylogeny p68 = factory.create( "((A,B):[0.68],C)", new NHXParser() )[ 0 ];
9043 if ( !isEqual( 0.68, p68.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9046 final Phylogeny p69 = factory.create( "((A,B)[0.69],C)", new NHXParser() )[ 0 ];
9047 if ( !isEqual( 0.69, p69.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9050 final Phylogeny p70 = factory.create( "((A,B)[+0.7],C)", new NHXParser() )[ 0 ];
9051 if ( !isEqual( 0.7, p70.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9054 final Phylogeny p71 = factory.create( "((A,B)[-0.71],C)", new NHXParser() )[ 0 ];
9055 if ( !isEqual( -0.71, p71.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9058 final Phylogeny p72 = factory.create( "((A,B)[],C)", new NHXParser() )[ 0 ];
9059 if ( !p72.toNewHampshireX().equals( "((A,B),C)" ) ) {
9062 final Phylogeny p73 = factory.create( "((A,B)[12x],C)", new NHXParser() )[ 0 ];
9063 if ( !p73.toNewHampshireX().equals( "((A,B),C)" ) ) {
9066 final Phylogeny p74 = factory.create( "((A,B)[12+],C)", new NHXParser() )[ 0 ];
9067 if ( !p74.toNewHampshireX().equals( "((A,B),C)" ) ) {
9070 final Phylogeny p75 = factory.create( "((A,B)ab[222]:3,C)", new NHXParser() )[ 0 ];
9071 if ( !isEqual( 222, p75.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9074 final Phylogeny p76 = factory.create( "((A,B)[100]:12,C)", new NHXParser() )[ 0 ];
9075 if ( !isEqual( 100, p76.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9078 final Phylogeny p77 = factory.create( "((A,B)abcde:13[77],C)", new NHXParser() )[ 0 ];
9079 if ( !isEqual( 77, p77.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9082 final Phylogeny p78 = factory.create( "((A,B):14[0],C)", new NHXParser() )[ 0 ];
9083 if ( !isEqual( 0, p78.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9086 final String the_one = "((((((a,b)ab:3.0[2],c):12.0[100],(d,e)de)abcde:13.0[2],f):14.0[0]):0.0[0]):0.0[0];";
9087 final Phylogeny p79 = factory.create(
9088 "((((((a,b)ab[2]:3,c)[100]:12,(d,e)de)abcde:13[2],f):14[0]):0[0])[0]:0;",
9089 new NHXParser() )[ 0 ];
9090 final String str79 = p79.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9091 if ( !str79.equals( the_one ) ) {
9092 System.out.println( str79 );
9095 final Phylogeny p80 = factory.create(
9096 "((((((a[a)],b[12])ab[2]:3,c)[+100]:12,(d,e)de[12d,)])ab[]c[]de:13[2],f):14[0]):0[0])[0]:0;",
9097 new NHXParser() )[ 0 ];
9098 final String str80 = p80.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9099 if ( !str80.equals( the_one ) ) {
9100 System.out.println( str80 );
9104 catch ( final Exception e ) {
9105 e.printStackTrace( System.out );
9111 private static boolean testNHParsingSpecialChars() {
9113 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9114 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
9115 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
9116 if ( !p0.toNewHampshireX().equals( i0 ) ) {
9117 System.out.println();
9118 System.out.println( p0.toNewHampshireX() );
9119 System.out.println( i0 );
9122 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
9123 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
9124 if ( !p1.toNewHampshireX().equals( i1 ) ) {
9125 System.out.println();
9126 System.out.println( p1.toNewHampshireX() );
9127 System.out.println( i1 );
9131 catch ( final Exception e ) {
9132 e.printStackTrace( System.out );
9138 private static boolean testNHParsingIter() {
9140 final String p0_str = "(A,B);";
9141 final NHXParser p = new NHXParser();
9142 p.setSource( p0_str );
9143 if ( !p.hasNext() ) {
9146 final Phylogeny p0 = p.next();
9147 if ( !p0.toNewHampshire().equals( p0_str ) ) {
9148 System.out.println( p0.toNewHampshire() );
9151 if ( p.hasNext() ) {
9154 if ( p.next() != null ) {
9158 final String p00_str = "(A,B)root;";
9159 p.setSource( p00_str );
9160 final Phylogeny p00 = p.next();
9161 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9162 System.out.println( p00.toNewHampshire() );
9166 final String p000_str = "A;";
9167 p.setSource( p000_str );
9168 final Phylogeny p000 = p.next();
9169 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9170 System.out.println( p000.toNewHampshire() );
9174 final String p0000_str = "A";
9175 p.setSource( p0000_str );
9176 final Phylogeny p0000 = p.next();
9177 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9178 System.out.println( p0000.toNewHampshire() );
9182 p.setSource( "(A)" );
9183 final Phylogeny p00000 = p.next();
9184 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9185 System.out.println( p00000.toNewHampshire() );
9189 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9190 p.setSource( p1_str );
9191 if ( !p.hasNext() ) {
9194 final Phylogeny p1_0 = p.next();
9195 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9196 System.out.println( p1_0.toNewHampshire() );
9199 if ( !p.hasNext() ) {
9202 final Phylogeny p1_1 = p.next();
9203 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9204 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9207 if ( !p.hasNext() ) {
9210 final Phylogeny p1_2 = p.next();
9211 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9212 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9215 if ( !p.hasNext() ) {
9218 final Phylogeny p1_3 = p.next();
9219 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9220 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9223 if ( p.hasNext() ) {
9226 if ( p.next() != null ) {
9230 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9231 p.setSource( p2_str );
9232 if ( !p.hasNext() ) {
9235 Phylogeny p2_0 = p.next();
9236 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9237 System.out.println( p2_0.toNewHampshire() );
9240 if ( !p.hasNext() ) {
9243 Phylogeny p2_1 = p.next();
9244 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9245 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9248 if ( !p.hasNext() ) {
9251 Phylogeny p2_2 = p.next();
9252 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9253 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9256 if ( !p.hasNext() ) {
9259 Phylogeny p2_3 = p.next();
9260 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9261 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9264 if ( !p.hasNext() ) {
9267 Phylogeny p2_4 = p.next();
9268 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9269 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9272 if ( p.hasNext() ) {
9275 if ( p.next() != null ) {
9280 if ( !p.hasNext() ) {
9284 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9285 System.out.println( p2_0.toNewHampshire() );
9288 if ( !p.hasNext() ) {
9292 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9293 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9296 if ( !p.hasNext() ) {
9300 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9301 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9304 if ( !p.hasNext() ) {
9308 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9309 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9312 if ( !p.hasNext() ) {
9316 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9317 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9320 if ( p.hasNext() ) {
9323 if ( p.next() != null ) {
9327 final String p3_str = "((A,B),C)abc";
9328 p.setSource( p3_str );
9329 if ( !p.hasNext() ) {
9332 final Phylogeny p3_0 = p.next();
9333 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9336 if ( p.hasNext() ) {
9339 if ( p.next() != null ) {
9343 final String p4_str = "((A,B)ab,C)abc";
9344 p.setSource( p4_str );
9345 if ( !p.hasNext() ) {
9348 final Phylogeny p4_0 = p.next();
9349 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9352 if ( p.hasNext() ) {
9355 if ( p.next() != null ) {
9359 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9360 p.setSource( p5_str );
9361 if ( !p.hasNext() ) {
9364 final Phylogeny p5_0 = p.next();
9365 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9368 if ( p.hasNext() ) {
9371 if ( p.next() != null ) {
9375 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9376 p.setSource( p6_str );
9377 if ( !p.hasNext() ) {
9380 Phylogeny p6_0 = p.next();
9381 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9384 if ( p.hasNext() ) {
9387 if ( p.next() != null ) {
9391 if ( !p.hasNext() ) {
9395 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9398 if ( p.hasNext() ) {
9401 if ( p.next() != null ) {
9405 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9406 p.setSource( p7_str );
9407 if ( !p.hasNext() ) {
9410 Phylogeny p7_0 = p.next();
9411 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9414 if ( p.hasNext() ) {
9417 if ( p.next() != null ) {
9421 if ( !p.hasNext() ) {
9425 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9428 if ( p.hasNext() ) {
9431 if ( p.next() != null ) {
9435 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9436 p.setSource( p8_str );
9437 if ( !p.hasNext() ) {
9440 Phylogeny p8_0 = p.next();
9441 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9444 if ( !p.hasNext() ) {
9447 if ( !p.hasNext() ) {
9450 Phylogeny p8_1 = p.next();
9451 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9454 if ( p.hasNext() ) {
9457 if ( p.next() != null ) {
9461 if ( !p.hasNext() ) {
9465 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9468 if ( !p.hasNext() ) {
9472 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9475 if ( p.hasNext() ) {
9478 if ( p.next() != null ) {
9484 if ( p.hasNext() ) {
9488 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9489 if ( !p.hasNext() ) {
9492 Phylogeny p_27 = p.next();
9493 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9494 System.out.println( p_27.toNewHampshireX() );
9498 if ( p.hasNext() ) {
9501 if ( p.next() != null ) {
9505 if ( !p.hasNext() ) {
9509 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9510 System.out.println( p_27.toNewHampshireX() );
9514 if ( p.hasNext() ) {
9517 if ( p.next() != null ) {
9521 final String p30_str = "(A,B);(C,D)";
9522 final NHXParser p30 = new NHXParser();
9523 p30.setSource( p30_str );
9524 if ( !p30.hasNext() ) {
9527 Phylogeny phy30 = p30.next();
9528 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9529 System.out.println( phy30.toNewHampshire() );
9532 if ( !p30.hasNext() ) {
9535 Phylogeny phy301 = p30.next();
9536 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9537 System.out.println( phy301.toNewHampshire() );
9540 if ( p30.hasNext() ) {
9543 if ( p30.hasNext() ) {
9546 if ( p30.next() != null ) {
9549 if ( p30.next() != null ) {
9553 if ( !p30.hasNext() ) {
9557 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9558 System.out.println( phy30.toNewHampshire() );
9561 if ( !p30.hasNext() ) {
9564 phy301 = p30.next();
9565 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9566 System.out.println( phy301.toNewHampshire() );
9569 if ( p30.hasNext() ) {
9572 if ( p30.hasNext() ) {
9575 if ( p30.next() != null ) {
9578 if ( p30.next() != null ) {
9582 catch ( final Exception e ) {
9583 e.printStackTrace( System.out );
9589 private static boolean testNHXconversion() {
9591 final PhylogenyNode n1 = new PhylogenyNode();
9592 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9593 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9594 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9595 final PhylogenyNode n5 = PhylogenyNode
9596 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9597 final PhylogenyNode n6 = PhylogenyNode
9598 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9599 if ( !n1.toNewHampshireX().equals( "" ) ) {
9602 if ( !n2.toNewHampshireX().equals( "" ) ) {
9605 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9608 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9611 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9614 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9615 System.out.println( n6.toNewHampshireX() );
9618 final PhylogenyNode n7 = new PhylogenyNode();
9619 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9620 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9621 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9622 System.out.println( n7
9623 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9627 catch ( final Exception e ) {
9628 e.printStackTrace( System.out );
9634 private static boolean testNHXNodeParsing() {
9636 final PhylogenyNode n1 = new PhylogenyNode();
9637 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9638 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9639 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9640 final PhylogenyNode n5 = PhylogenyNode
9641 .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]" );
9642 if ( !n3.getName().equals( "n3" ) ) {
9645 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9648 if ( n3.isDuplication() ) {
9651 if ( n3.isHasAssignedEvent() ) {
9654 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9657 if ( !n4.getName().equals( "n4" ) ) {
9660 if ( n4.getDistanceToParent() != 0.01 ) {
9663 if ( !n5.getName().equals( "n5" ) ) {
9666 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9669 if ( n5.getDistanceToParent() != 0.1 ) {
9672 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9675 if ( !n5.isDuplication() ) {
9678 if ( !n5.isHasAssignedEvent() ) {
9681 final PhylogenyNode n8 = PhylogenyNode
9682 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9683 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9684 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9687 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9690 final PhylogenyNode n9 = PhylogenyNode
9691 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9692 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9693 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9696 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9699 final PhylogenyNode n10 = PhylogenyNode
9700 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9701 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9704 final PhylogenyNode n20 = PhylogenyNode
9705 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9706 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9709 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9712 final PhylogenyNode n20x = PhylogenyNode
9713 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9714 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9717 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9720 final PhylogenyNode n20xx = PhylogenyNode
9721 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9722 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9725 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9728 final PhylogenyNode n20xxx = PhylogenyNode
9729 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9730 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9733 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9736 final PhylogenyNode n20xxxx = PhylogenyNode
9737 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9738 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9741 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9744 final PhylogenyNode n21 = PhylogenyNode
9745 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9746 if ( !n21.getName().equals( "N21_PIG" ) ) {
9749 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9752 final PhylogenyNode n21x = PhylogenyNode
9753 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9754 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9757 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9760 final PhylogenyNode n22 = PhylogenyNode
9761 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9762 if ( !n22.getName().equals( "n22/PIG" ) ) {
9765 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9768 final PhylogenyNode n23 = PhylogenyNode
9769 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9770 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9773 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9776 final PhylogenyNode a = PhylogenyNode
9777 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9778 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9781 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9784 final PhylogenyNode c1 = PhylogenyNode
9785 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9786 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9787 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9790 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9793 final PhylogenyNode c2 = PhylogenyNode
9794 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9795 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9796 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9799 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9802 final PhylogenyNode e3 = PhylogenyNode
9803 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9804 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9807 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9810 final PhylogenyNode n11 = PhylogenyNode
9811 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9812 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9813 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9816 if ( n11.getDistanceToParent() != 0.4 ) {
9819 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9822 final PhylogenyNode n12 = PhylogenyNode
9823 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9824 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9825 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9828 if ( n12.getDistanceToParent() != 0.4 ) {
9831 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9834 final PhylogenyNode o = PhylogenyNode
9835 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9836 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9839 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9842 if ( n1.getName().compareTo( "" ) != 0 ) {
9845 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9848 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9851 if ( n2.getName().compareTo( "" ) != 0 ) {
9854 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9857 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9860 final PhylogenyNode n00 = PhylogenyNode
9861 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9862 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9865 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9868 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9869 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9872 final PhylogenyNode n13 = PhylogenyNode
9873 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9874 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9877 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9880 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9883 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9886 final PhylogenyNode n14 = PhylogenyNode
9887 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9888 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9891 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9894 final PhylogenyNode n15 = PhylogenyNode
9895 .createInstanceFromNhxString( "something_wicked[123]",
9896 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9897 if ( !n15.getName().equals( "something_wicked" ) ) {
9900 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9903 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9906 final PhylogenyNode n16 = PhylogenyNode
9907 .createInstanceFromNhxString( "something_wicked2[9]",
9908 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9909 if ( !n16.getName().equals( "something_wicked2" ) ) {
9912 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9915 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9918 final PhylogenyNode n17 = PhylogenyNode
9919 .createInstanceFromNhxString( "something_wicked3[a]",
9920 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9921 if ( !n17.getName().equals( "something_wicked3" ) ) {
9924 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9927 final PhylogenyNode n18 = PhylogenyNode
9928 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9929 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9932 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9935 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9938 final PhylogenyNode n19 = PhylogenyNode
9939 .createInstanceFromNhxString( "BLAH_1-roejojoej",
9940 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9941 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9944 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9947 final PhylogenyNode n30 = PhylogenyNode
9948 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9949 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9950 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9953 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9956 final PhylogenyNode n31 = PhylogenyNode
9957 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9958 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9959 if ( n31.getNodeData().isHasTaxonomy() ) {
9962 final PhylogenyNode n32 = PhylogenyNode
9963 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9964 if ( n32.getNodeData().isHasTaxonomy() ) {
9967 final PhylogenyNode n40 = PhylogenyNode
9968 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9969 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9972 final PhylogenyNode n41 = PhylogenyNode
9973 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9974 if ( n41.getNodeData().isHasTaxonomy() ) {
9977 final PhylogenyNode n42 = PhylogenyNode
9978 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9979 if ( n42.getNodeData().isHasTaxonomy() ) {
9982 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9983 NHXParser.TAXONOMY_EXTRACTION.NO );
9984 if ( n43.getNodeData().isHasTaxonomy() ) {
9987 final PhylogenyNode n44 = PhylogenyNode
9988 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9989 if ( n44.getNodeData().isHasTaxonomy() ) {
9993 catch ( final Exception e ) {
9994 e.printStackTrace( System.out );
10000 private static boolean testNHXNodeParsing2() {
10002 final PhylogenyNode n0_0 = PhylogenyNode.createInstanceFromNhxString( "n0:[ignore me 123]:1E-3",
10003 NHXParser.TAXONOMY_EXTRACTION.NO,
10006 if ( !n0_0.getName().equals( "n0" ) ) {
10009 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
10012 final PhylogenyNode n0_1 = PhylogenyNode.createInstanceFromNhxString( "n0[ignore me 123]:1E-3",
10013 NHXParser.TAXONOMY_EXTRACTION.NO,
10016 if ( !n0_1.getName().equals( "n0" ) ) {
10019 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
10022 final PhylogenyNode n0_2 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3[ignore me 123]",
10023 NHXParser.TAXONOMY_EXTRACTION.NO,
10026 if ( !n0_2.getName().equals( "n0" ) ) {
10029 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
10032 final PhylogenyNode n0_3 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3:[ignore me 123]",
10033 NHXParser.TAXONOMY_EXTRACTION.NO,
10036 if ( !n0_3.getName().equals( "n0" ) ) {
10039 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
10042 final PhylogenyNode n0_4 = PhylogenyNode.createInstanceFromNhxString( "n0:0.001:[ignore me 123]",
10043 NHXParser.TAXONOMY_EXTRACTION.NO,
10046 if ( !n0_4.getName().equals( "n0" ) ) {
10049 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
10052 final PhylogenyNode n1_0 = PhylogenyNode
10053 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]",
10054 NHXParser.TAXONOMY_EXTRACTION.NO,
10057 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10060 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10063 final PhylogenyNode n1_1 = PhylogenyNode
10064 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001",
10065 NHXParser.TAXONOMY_EXTRACTION.NO,
10068 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10071 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10074 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
10077 final PhylogenyNode n1_2 = PhylogenyNode
10078 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]",
10079 NHXParser.TAXONOMY_EXTRACTION.NO,
10082 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10085 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10088 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
10091 final PhylogenyNode n1_3 = PhylogenyNode
10092 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]",
10093 NHXParser.TAXONOMY_EXTRACTION.NO,
10096 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10099 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10102 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
10105 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10108 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10111 final PhylogenyNode n1_4 = PhylogenyNode
10112 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3",
10113 NHXParser.TAXONOMY_EXTRACTION.NO,
10116 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10119 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10122 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
10125 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10128 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10131 final PhylogenyNode n1_5 = PhylogenyNode
10132 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]",
10133 NHXParser.TAXONOMY_EXTRACTION.NO,
10136 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10139 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
10142 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10145 final PhylogenyNode n1_6 = PhylogenyNode
10146 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3",
10147 NHXParser.TAXONOMY_EXTRACTION.NO,
10150 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10153 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
10156 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
10159 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
10162 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
10166 catch ( final Exception e ) {
10167 e.printStackTrace( System.out );
10173 private static boolean testNHXParsing() {
10175 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10176 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])",
10177 new NHXParser() )[ 0 ];
10178 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
10181 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]";
10182 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
10183 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10186 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]";
10187 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10188 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10191 final Phylogeny[] p3 = factory.create(
10192 "[ 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]",
10194 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10197 final Phylogeny[] p4 = factory.create(
10198 "(((((((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(]",
10200 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10203 final Phylogeny[] p5 = factory.create(
10204 "[] ( [][ ][ ] ([((( &&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(((]",
10206 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10209 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)";
10210 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)";
10211 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10212 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10215 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)))";
10216 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)))";
10217 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10218 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10221 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]) ))[,,, ])))))))";
10222 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10223 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10224 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10227 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10228 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10231 final Phylogeny p10 = factory.create(
10232 " [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]",
10233 new NHXParser() )[ 0 ];
10234 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10237 final Phylogeny p11 = factory.create(
10238 " [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]",
10239 new NHXParser() )[ 0 ];
10240 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10243 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]",
10244 new NHXParser() )[ 0 ];
10245 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10249 catch ( final Exception e ) {
10250 e.printStackTrace( System.out );
10256 private static boolean testNHXParsingMB() {
10258 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10259 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10260 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10261 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10262 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10263 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10264 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10265 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10266 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10267 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10268 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10271 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10274 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10275 0.1100000000000000e+00 ) ) {
10278 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10281 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10284 final Phylogeny p2 = factory
10285 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10286 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10287 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10288 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10289 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10290 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10291 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10292 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10293 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10294 if ( p2.getNode( "1" ) == null ) {
10297 if ( p2.getNode( "2" ) == null ) {
10301 catch ( final Exception e ) {
10302 e.printStackTrace( System.out );
10309 private static boolean testNHXParsingQuotes() {
10311 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10312 final NHXParser p = new NHXParser();
10313 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10314 if ( phylogenies_0.length != 5 ) {
10317 final Phylogeny phy = phylogenies_0[ 4 ];
10318 if ( phy.getNumberOfExternalNodes() != 7 ) {
10321 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10324 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10327 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10328 .getScientificName().equals( "hsapiens" ) ) {
10331 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10334 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10337 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10340 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10343 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10346 final NHXParser p1p = new NHXParser();
10347 p1p.setIgnoreQuotes( true );
10348 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10349 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10352 final NHXParser p2p = new NHXParser();
10353 p1p.setIgnoreQuotes( false );
10354 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10355 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10358 final NHXParser p3p = new NHXParser();
10359 p3p.setIgnoreQuotes( false );
10360 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10361 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10364 final NHXParser p4p = new NHXParser();
10365 p4p.setIgnoreQuotes( false );
10366 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10367 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10370 final Phylogeny p10 = factory.create(
10371 " [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]",
10372 new NHXParser() )[ 0 ];
10373 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]";
10374 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10377 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10378 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10381 final Phylogeny p12 = factory.create(
10382 " [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]",
10383 new NHXParser() )[ 0 ];
10384 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]";
10385 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10388 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10389 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10392 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;";
10393 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10396 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10397 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10401 catch ( final Exception e ) {
10402 e.printStackTrace( System.out );
10408 private static boolean testNodeRemoval() {
10410 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10411 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10412 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10413 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10416 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10417 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10418 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10421 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10422 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10423 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10427 catch ( final Exception e ) {
10428 e.printStackTrace( System.out );
10434 private static boolean testPhylogenyBranch() {
10436 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10437 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10438 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10439 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10440 if ( !a1b1.equals( a1b1 ) ) {
10443 if ( !a1b1.equals( b1a1 ) ) {
10446 if ( !b1a1.equals( a1b1 ) ) {
10449 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10450 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10451 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10452 if ( a1_b1.equals( b1_a1 ) ) {
10455 if ( a1_b1.equals( a1_b1_ ) ) {
10458 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10459 if ( !a1_b1.equals( b1_a1_ ) ) {
10462 if ( a1_b1_.equals( b1_a1_ ) ) {
10465 if ( !a1_b1_.equals( b1_a1 ) ) {
10469 catch ( final Exception e ) {
10470 e.printStackTrace( System.out );
10476 private static boolean testPhyloXMLparsingOfDistributionElement() {
10478 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10479 PhyloXmlParser xml_parser = null;
10481 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10483 catch ( final Exception e ) {
10484 // Do nothing -- means were not running from jar.
10486 if ( xml_parser == null ) {
10487 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10488 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10489 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10492 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10495 final Phylogeny[] phylogenies_0 = factory
10496 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ), xml_parser );
10497 if ( xml_parser.getErrorCount() > 0 ) {
10498 System.out.println( xml_parser.getErrorMessages().toString() );
10501 if ( phylogenies_0.length != 1 ) {
10504 final Phylogeny t1 = phylogenies_0[ 0 ];
10505 PhylogenyNode n = null;
10506 Distribution d = null;
10507 n = t1.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.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.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 Polygon 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 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10640 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10641 if ( rt.length != 1 ) {
10644 final Phylogeny t1_rt = rt[ 0 ];
10645 n = t1_rt.getNode( "root node" );
10646 if ( !n.getNodeData().isHasDistribution() ) {
10649 if ( n.getNodeData().getDistributions().size() != 1 ) {
10652 d = n.getNodeData().getDistribution();
10653 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10656 if ( d.getPoints().size() != 1 ) {
10659 if ( d.getPolygons() != null ) {
10662 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10665 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10668 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10671 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10674 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10677 n = t1_rt.getNode( "node a" );
10678 if ( !n.getNodeData().isHasDistribution() ) {
10681 if ( n.getNodeData().getDistributions().size() != 2 ) {
10684 d = n.getNodeData().getDistribution( 1 );
10685 if ( !d.getDesc().equals( "San Diego" ) ) {
10688 if ( d.getPoints().size() != 1 ) {
10691 if ( d.getPolygons() != null ) {
10694 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10697 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10700 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10703 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10706 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10709 n = t1_rt.getNode( "node bb" );
10710 if ( !n.getNodeData().isHasDistribution() ) {
10713 if ( n.getNodeData().getDistributions().size() != 1 ) {
10716 d = n.getNodeData().getDistribution( 0 );
10717 if ( d.getPoints().size() != 3 ) {
10720 if ( d.getPolygons().size() != 2 ) {
10723 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10726 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10729 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10732 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10735 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10738 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10741 p = d.getPolygons().get( 0 );
10742 if ( p.getPoints().size() != 3 ) {
10745 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10748 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10751 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10754 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10757 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10760 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10763 p = d.getPolygons().get( 1 );
10764 if ( p.getPoints().size() != 3 ) {
10767 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10770 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10773 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10777 catch ( final Exception e ) {
10778 e.printStackTrace( System.out );
10784 private static boolean testPostOrderIterator() {
10786 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10787 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10788 PhylogenyNodeIterator it0;
10789 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10792 for( it0.reset(); it0.hasNext(); ) {
10795 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
10796 new NHXParser() )[ 0 ];
10797 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10798 if ( !it.next().getName().equals( "A" ) ) {
10801 if ( !it.next().getName().equals( "B" ) ) {
10804 if ( !it.next().getName().equals( "ab" ) ) {
10807 if ( !it.next().getName().equals( "C" ) ) {
10810 if ( !it.next().getName().equals( "D" ) ) {
10813 if ( !it.next().getName().equals( "cd" ) ) {
10816 if ( !it.next().getName().equals( "abcd" ) ) {
10819 if ( !it.next().getName().equals( "E" ) ) {
10822 if ( !it.next().getName().equals( "F" ) ) {
10825 if ( !it.next().getName().equals( "ef" ) ) {
10828 if ( !it.next().getName().equals( "G" ) ) {
10831 if ( !it.next().getName().equals( "H" ) ) {
10834 if ( !it.next().getName().equals( "gh" ) ) {
10837 if ( !it.next().getName().equals( "efgh" ) ) {
10840 if ( !it.next().getName().equals( "r" ) ) {
10843 if ( it.hasNext() ) {
10847 catch ( final Exception e ) {
10848 e.printStackTrace( System.out );
10854 private static boolean testPreOrderIterator() {
10856 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10857 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10858 PhylogenyNodeIterator it0;
10859 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10862 for( it0.reset(); it0.hasNext(); ) {
10865 PhylogenyNodeIterator it = t0.iteratorPreorder();
10866 if ( !it.next().getName().equals( "r" ) ) {
10869 if ( !it.next().getName().equals( "ab" ) ) {
10872 if ( !it.next().getName().equals( "A" ) ) {
10875 if ( !it.next().getName().equals( "B" ) ) {
10878 if ( !it.next().getName().equals( "cd" ) ) {
10881 if ( !it.next().getName().equals( "C" ) ) {
10884 if ( !it.next().getName().equals( "D" ) ) {
10887 if ( it.hasNext() ) {
10890 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
10891 new NHXParser() )[ 0 ];
10892 it = t1.iteratorPreorder();
10893 if ( !it.next().getName().equals( "r" ) ) {
10896 if ( !it.next().getName().equals( "abcd" ) ) {
10899 if ( !it.next().getName().equals( "ab" ) ) {
10902 if ( !it.next().getName().equals( "A" ) ) {
10905 if ( !it.next().getName().equals( "B" ) ) {
10908 if ( !it.next().getName().equals( "cd" ) ) {
10911 if ( !it.next().getName().equals( "C" ) ) {
10914 if ( !it.next().getName().equals( "D" ) ) {
10917 if ( !it.next().getName().equals( "efgh" ) ) {
10920 if ( !it.next().getName().equals( "ef" ) ) {
10923 if ( !it.next().getName().equals( "E" ) ) {
10926 if ( !it.next().getName().equals( "F" ) ) {
10929 if ( !it.next().getName().equals( "gh" ) ) {
10932 if ( !it.next().getName().equals( "G" ) ) {
10935 if ( !it.next().getName().equals( "H" ) ) {
10938 if ( it.hasNext() ) {
10942 catch ( final Exception e ) {
10943 e.printStackTrace( System.out );
10949 private static boolean testPropertiesMap() {
10951 final PropertiesList pm = new PropertiesList();
10952 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10953 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10954 final Property p2 = new Property( "something:else",
10956 "improbable:research",
10959 pm.addProperty( p0 );
10960 pm.addProperty( p1 );
10961 pm.addProperty( p2 );
10962 if ( !pm.getProperties( "dimensions:diameter" ).get( 0 ).getValue().equals( "1" ) ) {
10965 if ( !pm.getProperties( "dimensions:length" ).get( 0 ).getValue().equals( "2" ) ) {
10968 if ( pm.getProperties().size() != 3 ) {
10971 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10974 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10977 if ( pm.getProperties().size() != 3 ) {
10981 catch ( final Exception e ) {
10982 e.printStackTrace( System.out );
10988 private static boolean testProteinId() {
10990 final ProteinId id1 = new ProteinId( "a" );
10991 final ProteinId id2 = new ProteinId( "a" );
10992 final ProteinId id3 = new ProteinId( "A" );
10993 final ProteinId id4 = new ProteinId( "b" );
10994 if ( !id1.equals( id1 ) ) {
10997 if ( id1.getId().equals( "x" ) ) {
11000 if ( id1.getId().equals( null ) ) {
11003 if ( !id1.equals( id2 ) ) {
11006 if ( id1.equals( id3 ) ) {
11009 if ( id1.hashCode() != id1.hashCode() ) {
11012 if ( id1.hashCode() != id2.hashCode() ) {
11015 if ( id1.hashCode() == id3.hashCode() ) {
11018 if ( id1.compareTo( id1 ) != 0 ) {
11021 if ( id1.compareTo( id2 ) != 0 ) {
11024 if ( id1.compareTo( id3 ) != 0 ) {
11027 if ( id1.compareTo( id4 ) >= 0 ) {
11030 if ( id4.compareTo( id1 ) <= 0 ) {
11033 if ( !id4.getId().equals( "b" ) ) {
11036 final ProteinId id5 = new ProteinId( " C " );
11037 if ( !id5.getId().equals( "C" ) ) {
11040 if ( id5.equals( id1 ) ) {
11044 catch ( final Exception e ) {
11045 e.printStackTrace( System.out );
11051 private static boolean testReIdMethods() {
11053 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11054 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
11055 final long count = PhylogenyNode.getNodeCount();
11056 p.levelOrderReID();
11057 if ( p.getNode( "r" ).getId() != count ) {
11060 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
11063 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
11066 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
11069 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
11072 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
11075 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
11078 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
11081 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
11084 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
11087 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
11090 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
11093 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
11096 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
11099 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
11103 catch ( final Exception e ) {
11104 e.printStackTrace( System.out );
11110 private static boolean testRerooting() {
11112 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11113 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",
11114 new NHXParser() )[ 0 ];
11115 if ( !t1.isRooted() ) {
11118 t1.reRoot( t1.getNode( "D" ) );
11119 t1.reRoot( t1.getNode( "CD" ) );
11120 t1.reRoot( t1.getNode( "A" ) );
11121 t1.reRoot( t1.getNode( "B" ) );
11122 t1.reRoot( t1.getNode( "AB" ) );
11123 t1.reRoot( t1.getNode( "D" ) );
11124 t1.reRoot( t1.getNode( "C" ) );
11125 t1.reRoot( t1.getNode( "CD" ) );
11126 t1.reRoot( t1.getNode( "A" ) );
11127 t1.reRoot( t1.getNode( "B" ) );
11128 t1.reRoot( t1.getNode( "AB" ) );
11129 t1.reRoot( t1.getNode( "D" ) );
11130 t1.reRoot( t1.getNode( "D" ) );
11131 t1.reRoot( t1.getNode( "C" ) );
11132 t1.reRoot( t1.getNode( "A" ) );
11133 t1.reRoot( t1.getNode( "B" ) );
11134 t1.reRoot( t1.getNode( "AB" ) );
11135 t1.reRoot( t1.getNode( "C" ) );
11136 t1.reRoot( t1.getNode( "D" ) );
11137 t1.reRoot( t1.getNode( "CD" ) );
11138 t1.reRoot( t1.getNode( "D" ) );
11139 t1.reRoot( t1.getNode( "A" ) );
11140 t1.reRoot( t1.getNode( "B" ) );
11141 t1.reRoot( t1.getNode( "AB" ) );
11142 t1.reRoot( t1.getNode( "C" ) );
11143 t1.reRoot( t1.getNode( "D" ) );
11144 t1.reRoot( t1.getNode( "CD" ) );
11145 t1.reRoot( t1.getNode( "D" ) );
11146 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
11149 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
11152 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
11155 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
11158 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
11161 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
11164 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",
11165 new NHXParser() )[ 0 ];
11166 t2.reRoot( t2.getNode( "A" ) );
11167 t2.reRoot( t2.getNode( "D" ) );
11168 t2.reRoot( t2.getNode( "ABC" ) );
11169 t2.reRoot( t2.getNode( "A" ) );
11170 t2.reRoot( t2.getNode( "B" ) );
11171 t2.reRoot( t2.getNode( "D" ) );
11172 t2.reRoot( t2.getNode( "C" ) );
11173 t2.reRoot( t2.getNode( "ABC" ) );
11174 t2.reRoot( t2.getNode( "A" ) );
11175 t2.reRoot( t2.getNode( "B" ) );
11176 t2.reRoot( t2.getNode( "AB" ) );
11177 t2.reRoot( t2.getNode( "AB" ) );
11178 t2.reRoot( t2.getNode( "D" ) );
11179 t2.reRoot( t2.getNode( "C" ) );
11180 t2.reRoot( t2.getNode( "B" ) );
11181 t2.reRoot( t2.getNode( "AB" ) );
11182 t2.reRoot( t2.getNode( "D" ) );
11183 t2.reRoot( t2.getNode( "D" ) );
11184 t2.reRoot( t2.getNode( "ABC" ) );
11185 t2.reRoot( t2.getNode( "A" ) );
11186 t2.reRoot( t2.getNode( "B" ) );
11187 t2.reRoot( t2.getNode( "AB" ) );
11188 t2.reRoot( t2.getNode( "D" ) );
11189 t2.reRoot( t2.getNode( "C" ) );
11190 t2.reRoot( t2.getNode( "ABC" ) );
11191 t2.reRoot( t2.getNode( "A" ) );
11192 t2.reRoot( t2.getNode( "B" ) );
11193 t2.reRoot( t2.getNode( "AB" ) );
11194 t2.reRoot( t2.getNode( "D" ) );
11195 t2.reRoot( t2.getNode( "D" ) );
11196 t2.reRoot( t2.getNode( "C" ) );
11197 t2.reRoot( t2.getNode( "A" ) );
11198 t2.reRoot( t2.getNode( "B" ) );
11199 t2.reRoot( t2.getNode( "AB" ) );
11200 t2.reRoot( t2.getNode( "C" ) );
11201 t2.reRoot( t2.getNode( "D" ) );
11202 t2.reRoot( t2.getNode( "ABC" ) );
11203 t2.reRoot( t2.getNode( "D" ) );
11204 t2.reRoot( t2.getNode( "A" ) );
11205 t2.reRoot( t2.getNode( "B" ) );
11206 t2.reRoot( t2.getNode( "AB" ) );
11207 t2.reRoot( t2.getNode( "C" ) );
11208 t2.reRoot( t2.getNode( "D" ) );
11209 t2.reRoot( t2.getNode( "ABC" ) );
11210 t2.reRoot( t2.getNode( "D" ) );
11211 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11214 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11217 t2.reRoot( t2.getNode( "ABC" ) );
11218 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11221 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11224 t2.reRoot( t2.getNode( "AB" ) );
11225 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11228 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11231 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11234 t2.reRoot( t2.getNode( "AB" ) );
11235 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11238 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11241 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11244 t2.reRoot( t2.getNode( "D" ) );
11245 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11248 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11251 t2.reRoot( t2.getNode( "ABC" ) );
11252 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11255 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11258 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11259 new NHXParser() )[ 0 ];
11260 t3.reRoot( t3.getNode( "B" ) );
11261 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11264 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11267 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11270 t3.reRoot( t3.getNode( "B" ) );
11271 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11274 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11277 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11280 t3.reRoot( t3.getRoot() );
11281 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11284 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11287 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11291 catch ( final Exception e ) {
11292 e.printStackTrace( System.out );
11298 private static boolean testSDIse() {
11300 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11301 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11302 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11303 gene1.setRooted( true );
11304 species1.setRooted( true );
11305 final SDI sdi = new SDI( gene1, species1 );
11306 if ( !gene1.getRoot().isDuplication() ) {
11309 final Phylogeny species2 = factory.create(
11310 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11311 new NHXParser() )[ 0 ];
11312 final Phylogeny gene2 = factory.create(
11313 "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11314 new NHXParser() )[ 0 ];
11315 species2.setRooted( true );
11316 gene2.setRooted( true );
11317 final SDI sdi2 = new SDI( gene2, species2 );
11318 if ( sdi2.getDuplicationsSum() != 0 ) {
11321 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11324 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11327 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11330 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11333 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11336 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11339 final Phylogeny species3 = factory.create(
11340 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11341 new NHXParser() )[ 0 ];
11342 final Phylogeny gene3 = factory.create(
11343 "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11344 new NHXParser() )[ 0 ];
11345 species3.setRooted( true );
11346 gene3.setRooted( true );
11347 final SDI sdi3 = new SDI( gene3, species3 );
11348 if ( sdi3.getDuplicationsSum() != 1 ) {
11351 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11354 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11357 final Phylogeny species4 = factory.create(
11358 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11359 new NHXParser() )[ 0 ];
11360 final Phylogeny gene4 = factory.create(
11361 "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11362 new NHXParser() )[ 0 ];
11363 species4.setRooted( true );
11364 gene4.setRooted( true );
11365 final SDI sdi4 = new SDI( gene4, species4 );
11366 if ( sdi4.getDuplicationsSum() != 1 ) {
11369 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11372 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11375 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11378 if ( species4.getNumberOfExternalNodes() != 6 ) {
11381 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11384 final Phylogeny species5 = factory.create(
11385 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11386 new NHXParser() )[ 0 ];
11387 final Phylogeny gene5 = factory.create(
11388 "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11389 new NHXParser() )[ 0 ];
11390 species5.setRooted( true );
11391 gene5.setRooted( true );
11392 final SDI sdi5 = new SDI( gene5, species5 );
11393 if ( sdi5.getDuplicationsSum() != 2 ) {
11396 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11399 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11402 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11405 if ( species5.getNumberOfExternalNodes() != 6 ) {
11408 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11411 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11412 // Conjecture for Comparing Molecular Phylogenies"
11413 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11414 final Phylogeny species6 = factory.create(
11415 "(((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,"
11416 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11417 new NHXParser() )[ 0 ];
11418 final Phylogeny gene6 = factory.create(
11419 "(((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,"
11420 + "((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,"
11421 + "(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;",
11422 new NHXParser() )[ 0 ];
11423 species6.setRooted( true );
11424 gene6.setRooted( true );
11425 final SDI sdi6 = new SDI( gene6, species6 );
11426 if ( sdi6.getDuplicationsSum() != 3 ) {
11429 if ( !gene6.getNode( "r" ).isDuplication() ) {
11432 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11435 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11438 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11441 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11444 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11447 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11450 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11453 sdi6.computeMappingCostL();
11454 if ( sdi6.computeMappingCostL() != 17 ) {
11457 if ( species6.getNumberOfExternalNodes() != 9 ) {
11460 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11463 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11464 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11465 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11466 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11467 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11468 species7.setRooted( true );
11469 final Phylogeny gene7_1 = Test
11470 .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])" );
11471 gene7_1.setRooted( true );
11472 final SDI sdi7 = new SDI( gene7_1, species7 );
11473 if ( sdi7.getDuplicationsSum() != 0 ) {
11476 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11479 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11482 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11485 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11488 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11491 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11494 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11497 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11500 final Phylogeny gene7_2 = Test
11501 .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])" );
11502 gene7_2.setRooted( true );
11503 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11504 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11507 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11510 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11513 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11516 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11519 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11522 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11525 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11528 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11531 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11535 catch ( final Exception e ) {
11541 private static boolean testSDIunrooted() {
11543 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11544 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef",
11545 new NHXParser() )[ 0 ];
11546 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11547 final Iterator<PhylogenyBranch> iter = l.iterator();
11548 PhylogenyBranch br = iter.next();
11549 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11552 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11556 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11559 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11563 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11566 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11570 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11573 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11577 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11580 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11584 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11587 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11591 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11594 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11598 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11601 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11605 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11608 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11612 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11615 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11619 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11622 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11626 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11629 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11633 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11636 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11640 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11643 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11647 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11650 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11653 if ( iter.hasNext() ) {
11656 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11657 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11658 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11660 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11663 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11667 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11670 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11674 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11677 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11680 if ( iter1.hasNext() ) {
11683 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11684 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11685 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11687 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11690 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11694 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11697 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11701 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11704 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11707 if ( iter2.hasNext() ) {
11710 final Phylogeny species0 = factory.create(
11711 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11712 new NHXParser() )[ 0 ];
11713 final Phylogeny gene1 = factory.create(
11714 "(((((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])",
11715 new NHXParser() )[ 0 ];
11716 species0.setRooted( true );
11717 gene1.setRooted( true );
11718 final SDIR sdi_unrooted = new SDIR();
11719 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11720 if ( sdi_unrooted.getCount() != 1 ) {
11723 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11726 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11729 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11732 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11735 final Phylogeny gene2 = factory.create(
11736 "(((((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])",
11737 new NHXParser() )[ 0 ];
11738 gene2.setRooted( true );
11739 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11740 if ( sdi_unrooted.getCount() != 1 ) {
11743 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11746 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11749 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11752 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11755 final Phylogeny species6 = factory.create(
11756 "(((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,"
11757 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11758 new NHXParser() )[ 0 ];
11759 final Phylogeny gene6 = factory.create(
11760 "((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],"
11761 + "(((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],"
11762 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11763 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11764 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11765 new NHXParser() )[ 0 ];
11766 species6.setRooted( true );
11767 gene6.setRooted( true );
11768 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11769 if ( sdi_unrooted.getCount() != 1 ) {
11772 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11775 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11778 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11781 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11784 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11787 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11790 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11793 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11796 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11799 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11802 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11805 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11809 final Phylogeny species7 = factory.create(
11810 "(((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,"
11811 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11812 new NHXParser() )[ 0 ];
11813 final Phylogeny gene7 = factory.create(
11814 "((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],"
11815 + "(((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],"
11816 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11817 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11818 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11819 new NHXParser() )[ 0 ];
11820 species7.setRooted( true );
11821 gene7.setRooted( true );
11822 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11823 if ( sdi_unrooted.getCount() != 1 ) {
11826 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11829 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11832 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11835 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11838 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11841 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11844 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11847 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11850 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11853 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11856 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11859 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11863 final Phylogeny species8 = factory.create(
11864 "(((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,"
11865 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11866 new NHXParser() )[ 0 ];
11867 final Phylogeny gene8 = factory.create(
11868 "((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],"
11869 + "(((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],"
11870 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11871 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11872 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11873 new NHXParser() )[ 0 ];
11874 species8.setRooted( true );
11875 gene8.setRooted( true );
11876 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11877 if ( sdi_unrooted.getCount() != 1 ) {
11880 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11883 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11886 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11889 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11892 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11895 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11898 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11901 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11904 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11907 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11910 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11913 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11918 catch ( final Exception e ) {
11919 e.printStackTrace( System.out );
11925 private static boolean testSequenceDbWsTools1() {
11927 final PhylogenyNode n = new PhylogenyNode();
11928 n.setName( "NP_001025424" );
11929 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11930 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11931 || !acc.getValue().equals( "NP_001025424" ) ) {
11934 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11935 acc = SequenceDbWsTools.obtainSeqAccession( n );
11936 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11937 || !acc.getValue().equals( "NP_001025424" ) ) {
11940 n.setName( "NP_001025424.1" );
11941 acc = SequenceDbWsTools.obtainSeqAccession( n );
11942 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11943 || !acc.getValue().equals( "NP_001025424" ) ) {
11946 n.setName( "NM_001030253" );
11947 acc = SequenceDbWsTools.obtainSeqAccession( n );
11948 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11949 || !acc.getValue().equals( "NM_001030253" ) ) {
11952 n.setName( "BCL2_HUMAN" );
11953 acc = SequenceDbWsTools.obtainSeqAccession( n );
11954 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11955 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11956 System.out.println( acc.toString() );
11959 n.setName( "P10415" );
11960 acc = SequenceDbWsTools.obtainSeqAccession( n );
11961 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11962 || !acc.getValue().equals( "P10415" ) ) {
11963 System.out.println( acc.toString() );
11966 n.setName( " P10415 " );
11967 acc = SequenceDbWsTools.obtainSeqAccession( n );
11968 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11969 || !acc.getValue().equals( "P10415" ) ) {
11970 System.out.println( acc.toString() );
11973 n.setName( "_P10415|" );
11974 acc = SequenceDbWsTools.obtainSeqAccession( n );
11975 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11976 || !acc.getValue().equals( "P10415" ) ) {
11977 System.out.println( acc.toString() );
11980 n.setName( "AY695820" );
11981 acc = SequenceDbWsTools.obtainSeqAccession( n );
11982 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11983 || !acc.getValue().equals( "AY695820" ) ) {
11984 System.out.println( acc.toString() );
11987 n.setName( "_AY695820_" );
11988 acc = SequenceDbWsTools.obtainSeqAccession( n );
11989 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11990 || !acc.getValue().equals( "AY695820" ) ) {
11991 System.out.println( acc.toString() );
11994 n.setName( "AAA59452" );
11995 acc = SequenceDbWsTools.obtainSeqAccession( n );
11996 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11997 || !acc.getValue().equals( "AAA59452" ) ) {
11998 System.out.println( acc.toString() );
12001 n.setName( "_AAA59452_" );
12002 acc = SequenceDbWsTools.obtainSeqAccession( n );
12003 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12004 || !acc.getValue().equals( "AAA59452" ) ) {
12005 System.out.println( acc.toString() );
12008 n.setName( "AAA59452.1" );
12009 acc = SequenceDbWsTools.obtainSeqAccession( n );
12010 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12011 || !acc.getValue().equals( "AAA59452.1" ) ) {
12012 System.out.println( acc.toString() );
12015 n.setName( "_AAA59452.1_" );
12016 acc = SequenceDbWsTools.obtainSeqAccession( n );
12017 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12018 || !acc.getValue().equals( "AAA59452.1" ) ) {
12019 System.out.println( acc.toString() );
12022 n.setName( "GI:94894583" );
12023 acc = SequenceDbWsTools.obtainSeqAccession( n );
12024 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12025 || !acc.getValue().equals( "94894583" ) ) {
12026 System.out.println( acc.toString() );
12029 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12030 acc = SequenceDbWsTools.obtainSeqAccession( n );
12031 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12032 || !acc.getValue().equals( "71845847" ) ) {
12033 System.out.println( acc.toString() );
12036 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12037 acc = SequenceDbWsTools.obtainSeqAccession( n );
12038 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12039 || !acc.getValue().equals( "AAZ45343.1" ) ) {
12040 System.out.println( acc.toString() );
12044 catch ( final Exception e ) {
12050 private static boolean testSequenceDbWsTools2() {
12052 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
12053 SequenceDbWsTools.obtainSeqInformation( n1 );
12054 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
12057 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12060 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12063 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
12066 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
12067 SequenceDbWsTools.obtainSeqInformation( n2 );
12068 if ( !n2.getNodeData().getSequence().getName()
12069 .equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
12072 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12075 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12078 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
12081 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
12082 SequenceDbWsTools.obtainSeqInformation( n3 );
12083 if ( !n3.getNodeData().getSequence().getName()
12084 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
12087 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
12090 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12093 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
12097 catch ( final IOException e ) {
12098 System.out.println();
12099 System.out.println( "the following might be due to absence internet connection:" );
12100 e.printStackTrace( System.out );
12103 catch ( final Exception e ) {
12104 e.printStackTrace();
12110 private static boolean testSequenceIdParsing() {
12112 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
12113 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12114 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12115 if ( id != null ) {
12116 System.out.println( "value =" + id.getValue() );
12117 System.out.println( "provider=" + id.getSource() );
12121 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
12122 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12123 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12124 if ( id != null ) {
12125 System.out.println( "value =" + id.getValue() );
12126 System.out.println( "provider=" + id.getSource() );
12130 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
12131 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12132 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12133 if ( id != null ) {
12134 System.out.println( "value =" + id.getValue() );
12135 System.out.println( "provider=" + id.getSource() );
12139 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
12140 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12141 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
12142 if ( id != null ) {
12143 System.out.println( "value =" + id.getValue() );
12144 System.out.println( "provider=" + id.getSource() );
12148 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
12149 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12150 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
12151 if ( id != null ) {
12152 System.out.println( "value =" + id.getValue() );
12153 System.out.println( "provider=" + id.getSource() );
12157 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
12158 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12159 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
12160 if ( id != null ) {
12161 System.out.println( "value =" + id.getValue() );
12162 System.out.println( "provider=" + id.getSource() );
12166 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
12167 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12168 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
12169 if ( id != null ) {
12170 System.out.println( "value =" + id.getValue() );
12171 System.out.println( "provider=" + id.getSource() );
12175 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
12176 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12177 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12178 if ( id != null ) {
12179 System.out.println( "value =" + id.getValue() );
12180 System.out.println( "provider=" + id.getSource() );
12184 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12185 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12186 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12187 if ( id != null ) {
12188 System.out.println( "value =" + id.getValue() );
12189 System.out.println( "provider=" + id.getSource() );
12193 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12194 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12195 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12196 if ( id != null ) {
12197 System.out.println( "value =" + id.getValue() );
12198 System.out.println( "provider=" + id.getSource() );
12202 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12203 if ( id != null ) {
12204 System.out.println( "value =" + id.getValue() );
12205 System.out.println( "provider=" + id.getSource() );
12208 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12209 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12210 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12211 if ( id != null ) {
12212 System.out.println( "value =" + id.getValue() );
12213 System.out.println( "provider=" + id.getSource() );
12217 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12218 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12219 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12220 if ( id != null ) {
12221 System.out.println( "value =" + id.getValue() );
12222 System.out.println( "provider=" + id.getSource() );
12226 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12227 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12228 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12229 if ( id != null ) {
12230 System.out.println( "value =" + id.getValue() );
12231 System.out.println( "provider=" + id.getSource() );
12235 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12236 if ( id != null ) {
12237 System.out.println( "value =" + id.getValue() );
12238 System.out.println( "provider=" + id.getSource() );
12242 catch ( final Exception e ) {
12243 e.printStackTrace( System.out );
12249 private static boolean testSequenceWriter() {
12251 final String n = ForesterUtil.LINE_SEPARATOR;
12252 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12255 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12258 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12261 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12264 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12265 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12268 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12269 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12273 catch ( final Exception e ) {
12274 e.printStackTrace();
12280 private static boolean testSpecies() {
12282 final Species s1 = new BasicSpecies( "a" );
12283 final Species s2 = new BasicSpecies( "a" );
12284 final Species s3 = new BasicSpecies( "A" );
12285 final Species s4 = new BasicSpecies( "b" );
12286 if ( !s1.equals( s1 ) ) {
12289 if ( s1.getSpeciesId().equals( "x" ) ) {
12292 if ( s1.getSpeciesId().equals( null ) ) {
12295 if ( !s1.equals( s2 ) ) {
12298 if ( s1.equals( s3 ) ) {
12301 if ( s1.hashCode() != s1.hashCode() ) {
12304 if ( s1.hashCode() != s2.hashCode() ) {
12307 if ( s1.hashCode() == s3.hashCode() ) {
12310 if ( s1.compareTo( s1 ) != 0 ) {
12313 if ( s1.compareTo( s2 ) != 0 ) {
12316 if ( s1.compareTo( s3 ) != 0 ) {
12319 if ( s1.compareTo( s4 ) >= 0 ) {
12322 if ( s4.compareTo( s1 ) <= 0 ) {
12325 if ( !s4.getSpeciesId().equals( "b" ) ) {
12328 final Species s5 = new BasicSpecies( " C " );
12329 if ( !s5.getSpeciesId().equals( "C" ) ) {
12332 if ( s5.equals( s1 ) ) {
12336 catch ( final Exception e ) {
12337 e.printStackTrace( System.out );
12343 private static boolean testSplit() {
12345 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12346 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12347 //Archaeopteryx.createApplication( p0 );
12348 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12349 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12350 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12351 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12352 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12353 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12354 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12355 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12356 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12357 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12358 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12359 // System.out.println( s0.toString() );
12361 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12362 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12363 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12364 if ( s0.match( query_nodes ) ) {
12367 query_nodes = new HashSet<PhylogenyNode>();
12368 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12369 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12370 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12371 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12374 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12375 if ( !s0.match( query_nodes ) ) {
12379 query_nodes = new HashSet<PhylogenyNode>();
12380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12383 if ( !s0.match( query_nodes ) ) {
12387 query_nodes = new HashSet<PhylogenyNode>();
12388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12389 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12392 if ( !s0.match( query_nodes ) ) {
12396 query_nodes = new HashSet<PhylogenyNode>();
12397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12400 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12401 if ( !s0.match( query_nodes ) ) {
12405 query_nodes = new HashSet<PhylogenyNode>();
12406 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12407 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12408 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12409 if ( !s0.match( query_nodes ) ) {
12412 query_nodes = new HashSet<PhylogenyNode>();
12413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12415 if ( !s0.match( query_nodes ) ) {
12418 query_nodes = new HashSet<PhylogenyNode>();
12419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12422 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12423 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12424 if ( !s0.match( query_nodes ) ) {
12427 query_nodes = new HashSet<PhylogenyNode>();
12428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12430 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12431 if ( !s0.match( query_nodes ) ) {
12434 query_nodes = new HashSet<PhylogenyNode>();
12435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12438 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12439 if ( !s0.match( query_nodes ) ) {
12442 query_nodes = new HashSet<PhylogenyNode>();
12443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12444 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12445 if ( s0.match( query_nodes ) ) {
12448 query_nodes = new HashSet<PhylogenyNode>();
12449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12453 if ( s0.match( query_nodes ) ) {
12456 query_nodes = new HashSet<PhylogenyNode>();
12457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12458 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12460 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12461 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12462 if ( s0.match( query_nodes ) ) {
12465 query_nodes = new HashSet<PhylogenyNode>();
12466 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12467 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12468 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12469 if ( s0.match( query_nodes ) ) {
12472 query_nodes = new HashSet<PhylogenyNode>();
12473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12475 if ( s0.match( query_nodes ) ) {
12478 query_nodes = new HashSet<PhylogenyNode>();
12479 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12480 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12481 if ( s0.match( query_nodes ) ) {
12484 query_nodes = new HashSet<PhylogenyNode>();
12485 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12486 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12487 if ( s0.match( query_nodes ) ) {
12490 query_nodes = new HashSet<PhylogenyNode>();
12491 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12493 if ( s0.match( query_nodes ) ) {
12496 query_nodes = new HashSet<PhylogenyNode>();
12497 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12499 if ( s0.match( query_nodes ) ) {
12502 query_nodes = new HashSet<PhylogenyNode>();
12503 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12504 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12505 if ( s0.match( query_nodes ) ) {
12508 query_nodes = new HashSet<PhylogenyNode>();
12509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12512 if ( s0.match( query_nodes ) ) {
12515 query_nodes = new HashSet<PhylogenyNode>();
12516 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12517 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12519 if ( s0.match( query_nodes ) ) {
12522 query_nodes = new HashSet<PhylogenyNode>();
12523 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12525 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12526 if ( s0.match( query_nodes ) ) {
12529 query_nodes = new HashSet<PhylogenyNode>();
12530 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12531 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12532 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12533 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12534 if ( s0.match( query_nodes ) ) {
12538 // query_nodes = new HashSet<PhylogenyNode>();
12539 // query_nodes.add( new PhylogenyNode( "X" ) );
12540 // query_nodes.add( new PhylogenyNode( "Y" ) );
12541 // query_nodes.add( new PhylogenyNode( "A" ) );
12542 // query_nodes.add( new PhylogenyNode( "B" ) );
12543 // query_nodes.add( new PhylogenyNode( "C" ) );
12544 // query_nodes.add( new PhylogenyNode( "D" ) );
12545 // query_nodes.add( new PhylogenyNode( "E" ) );
12546 // query_nodes.add( new PhylogenyNode( "F" ) );
12547 // query_nodes.add( new PhylogenyNode( "G" ) );
12548 // if ( !s0.match( query_nodes ) ) {
12551 // query_nodes = new HashSet<PhylogenyNode>();
12552 // query_nodes.add( new PhylogenyNode( "X" ) );
12553 // query_nodes.add( new PhylogenyNode( "Y" ) );
12554 // query_nodes.add( new PhylogenyNode( "A" ) );
12555 // query_nodes.add( new PhylogenyNode( "B" ) );
12556 // query_nodes.add( new PhylogenyNode( "C" ) );
12557 // if ( !s0.match( query_nodes ) ) {
12561 // query_nodes = new HashSet<PhylogenyNode>();
12562 // query_nodes.add( new PhylogenyNode( "X" ) );
12563 // query_nodes.add( new PhylogenyNode( "Y" ) );
12564 // query_nodes.add( new PhylogenyNode( "D" ) );
12565 // query_nodes.add( new PhylogenyNode( "E" ) );
12566 // query_nodes.add( new PhylogenyNode( "F" ) );
12567 // query_nodes.add( new PhylogenyNode( "G" ) );
12568 // if ( !s0.match( query_nodes ) ) {
12572 // query_nodes = new HashSet<PhylogenyNode>();
12573 // query_nodes.add( new PhylogenyNode( "X" ) );
12574 // query_nodes.add( new PhylogenyNode( "Y" ) );
12575 // query_nodes.add( new PhylogenyNode( "A" ) );
12576 // query_nodes.add( new PhylogenyNode( "B" ) );
12577 // query_nodes.add( new PhylogenyNode( "C" ) );
12578 // query_nodes.add( new PhylogenyNode( "D" ) );
12579 // if ( !s0.match( query_nodes ) ) {
12583 // query_nodes = new HashSet<PhylogenyNode>();
12584 // query_nodes.add( new PhylogenyNode( "X" ) );
12585 // query_nodes.add( new PhylogenyNode( "Y" ) );
12586 // query_nodes.add( new PhylogenyNode( "E" ) );
12587 // query_nodes.add( new PhylogenyNode( "F" ) );
12588 // query_nodes.add( new PhylogenyNode( "G" ) );
12589 // if ( !s0.match( query_nodes ) ) {
12593 // query_nodes = new HashSet<PhylogenyNode>();
12594 // query_nodes.add( new PhylogenyNode( "X" ) );
12595 // query_nodes.add( new PhylogenyNode( "Y" ) );
12596 // query_nodes.add( new PhylogenyNode( "F" ) );
12597 // query_nodes.add( new PhylogenyNode( "G" ) );
12598 // if ( !s0.match( query_nodes ) ) {
12602 query_nodes = new HashSet<PhylogenyNode>();
12603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12606 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12607 if ( s0.match( query_nodes ) ) {
12611 query_nodes = new HashSet<PhylogenyNode>();
12612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12616 if ( s0.match( query_nodes ) ) {
12619 ///////////////////////////
12621 query_nodes = new HashSet<PhylogenyNode>();
12622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12626 if ( s0.match( query_nodes ) ) {
12630 query_nodes = new HashSet<PhylogenyNode>();
12631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12635 if ( s0.match( query_nodes ) ) {
12639 query_nodes = new HashSet<PhylogenyNode>();
12640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12644 if ( s0.match( query_nodes ) ) {
12648 query_nodes = new HashSet<PhylogenyNode>();
12649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12653 if ( s0.match( query_nodes ) ) {
12657 query_nodes = new HashSet<PhylogenyNode>();
12658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12659 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12662 if ( s0.match( query_nodes ) ) {
12666 query_nodes = new HashSet<PhylogenyNode>();
12667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12668 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12670 if ( s0.match( query_nodes ) ) {
12674 query_nodes = new HashSet<PhylogenyNode>();
12675 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12680 if ( s0.match( query_nodes ) ) {
12684 query_nodes = new HashSet<PhylogenyNode>();
12685 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12690 if ( s0.match( query_nodes ) ) {
12694 query_nodes = new HashSet<PhylogenyNode>();
12695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12700 if ( s0.match( query_nodes ) ) {
12704 query_nodes = new HashSet<PhylogenyNode>();
12705 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12706 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12710 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12711 if ( s0.match( query_nodes ) ) {
12715 catch ( final Exception e ) {
12716 e.printStackTrace();
12722 private static boolean testSplitStrict() {
12724 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12725 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12726 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12727 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12728 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12729 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12730 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12731 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12732 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12733 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12734 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12735 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12738 if ( s0.match( query_nodes ) ) {
12741 query_nodes = new HashSet<PhylogenyNode>();
12742 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12743 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12744 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12749 if ( !s0.match( query_nodes ) ) {
12753 query_nodes = new HashSet<PhylogenyNode>();
12754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12757 if ( !s0.match( query_nodes ) ) {
12761 query_nodes = new HashSet<PhylogenyNode>();
12762 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12763 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12766 if ( !s0.match( query_nodes ) ) {
12770 query_nodes = new HashSet<PhylogenyNode>();
12771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12774 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12775 if ( !s0.match( query_nodes ) ) {
12779 query_nodes = new HashSet<PhylogenyNode>();
12780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12781 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12782 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12783 if ( !s0.match( query_nodes ) ) {
12787 query_nodes = new HashSet<PhylogenyNode>();
12788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12790 if ( !s0.match( query_nodes ) ) {
12794 query_nodes = new HashSet<PhylogenyNode>();
12795 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12799 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12800 if ( !s0.match( query_nodes ) ) {
12804 query_nodes = new HashSet<PhylogenyNode>();
12805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12808 if ( !s0.match( query_nodes ) ) {
12812 query_nodes = new HashSet<PhylogenyNode>();
12813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12815 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12816 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12817 if ( !s0.match( query_nodes ) ) {
12821 query_nodes = new HashSet<PhylogenyNode>();
12822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12824 if ( s0.match( query_nodes ) ) {
12828 query_nodes = new HashSet<PhylogenyNode>();
12829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12833 if ( s0.match( query_nodes ) ) {
12837 query_nodes = new HashSet<PhylogenyNode>();
12838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12842 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12843 if ( s0.match( query_nodes ) ) {
12847 query_nodes = new HashSet<PhylogenyNode>();
12848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12849 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12850 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12851 if ( s0.match( query_nodes ) ) {
12855 query_nodes = new HashSet<PhylogenyNode>();
12856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12858 if ( s0.match( query_nodes ) ) {
12862 query_nodes = new HashSet<PhylogenyNode>();
12863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12865 if ( s0.match( query_nodes ) ) {
12869 query_nodes = new HashSet<PhylogenyNode>();
12870 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12871 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12872 if ( s0.match( query_nodes ) ) {
12876 query_nodes = new HashSet<PhylogenyNode>();
12877 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12878 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12879 if ( s0.match( query_nodes ) ) {
12883 query_nodes = new HashSet<PhylogenyNode>();
12884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12885 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12886 if ( s0.match( query_nodes ) ) {
12890 query_nodes = new HashSet<PhylogenyNode>();
12891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12893 if ( s0.match( query_nodes ) ) {
12897 query_nodes = new HashSet<PhylogenyNode>();
12898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12901 if ( s0.match( query_nodes ) ) {
12905 query_nodes = new HashSet<PhylogenyNode>();
12906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12909 if ( s0.match( query_nodes ) ) {
12913 query_nodes = new HashSet<PhylogenyNode>();
12914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12917 if ( s0.match( query_nodes ) ) {
12921 query_nodes = new HashSet<PhylogenyNode>();
12922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12923 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12924 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12925 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12926 if ( s0.match( query_nodes ) ) {
12930 catch ( final Exception e ) {
12931 e.printStackTrace();
12937 private static boolean testSubtreeDeletion() {
12939 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12940 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12941 t1.deleteSubtree( t1.getNode( "A" ), false );
12942 if ( t1.getNumberOfExternalNodes() != 5 ) {
12945 t1.toNewHampshireX();
12946 t1.deleteSubtree( t1.getNode( "E" ), false );
12947 if ( t1.getNumberOfExternalNodes() != 4 ) {
12950 t1.toNewHampshireX();
12951 t1.deleteSubtree( t1.getNode( "F" ), false );
12952 if ( t1.getNumberOfExternalNodes() != 3 ) {
12955 t1.toNewHampshireX();
12956 t1.deleteSubtree( t1.getNode( "D" ), false );
12957 t1.toNewHampshireX();
12958 if ( t1.getNumberOfExternalNodes() != 3 ) {
12961 t1.deleteSubtree( t1.getNode( "def" ), false );
12962 t1.toNewHampshireX();
12963 if ( t1.getNumberOfExternalNodes() != 2 ) {
12966 t1.deleteSubtree( t1.getNode( "B" ), false );
12967 t1.toNewHampshireX();
12968 if ( t1.getNumberOfExternalNodes() != 1 ) {
12971 t1.deleteSubtree( t1.getNode( "C" ), false );
12972 t1.toNewHampshireX();
12973 if ( t1.getNumberOfExternalNodes() != 1 ) {
12976 t1.deleteSubtree( t1.getNode( "abc" ), false );
12977 t1.toNewHampshireX();
12978 if ( t1.getNumberOfExternalNodes() != 1 ) {
12981 t1.deleteSubtree( t1.getNode( "r" ), false );
12982 if ( t1.getNumberOfExternalNodes() != 0 ) {
12985 if ( !t1.isEmpty() ) {
12988 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12989 t2.deleteSubtree( t2.getNode( "A" ), false );
12990 t2.toNewHampshireX();
12991 if ( t2.getNumberOfExternalNodes() != 5 ) {
12994 t2.deleteSubtree( t2.getNode( "abc" ), false );
12995 t2.toNewHampshireX();
12996 if ( t2.getNumberOfExternalNodes() != 3 ) {
12999 t2.deleteSubtree( t2.getNode( "def" ), false );
13000 t2.toNewHampshireX();
13001 if ( t2.getNumberOfExternalNodes() != 1 ) {
13005 catch ( final Exception e ) {
13006 e.printStackTrace( System.out );
13012 private static boolean testSupportCount() {
13014 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13015 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
13016 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
13017 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
13018 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))" + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
13020 SupportCount.count( t0_1, phylogenies_1, true, false );
13021 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
13022 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
13023 + "(((((A,B),C),D),E),((F,G),X))" + "(((((A,Y),B),C),D),((F,G),E))" + "(((((A,B),C),D),E),(F,G))"
13024 + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G),Z)"
13025 + "(((((A,B),C),D),E),(F,G))" + "((((((A,B),C),D),E),F),G)" + "(((((X,Y),F,G),E),((A,B),C)),D)",
13027 SupportCount.count( t0_2, phylogenies_2, true, false );
13028 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
13029 while ( it.hasNext() ) {
13030 final PhylogenyNode n = it.next();
13031 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
13035 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
13036 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
13037 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
13038 SupportCount.count( t0_3, phylogenies_3, true, false );
13039 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
13040 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
13043 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
13046 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
13049 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
13052 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
13055 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
13058 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
13061 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
13064 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
13067 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
13070 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13071 final Phylogeny[] phylogenies_4 = factory
13072 .create( "((((((A,X),C),B),D),E),F) " + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
13073 SupportCount.count( t0_4, phylogenies_4, true, false );
13074 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
13075 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
13078 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
13081 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
13084 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
13087 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
13090 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
13093 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
13096 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
13099 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
13102 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
13105 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13106 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13107 double d = SupportCount.compare( b1, a, true, true, true );
13108 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
13111 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13112 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13113 d = SupportCount.compare( b2, a, true, true, true );
13114 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
13117 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13118 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
13119 d = SupportCount.compare( b3, a, true, true, true );
13120 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
13123 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
13124 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
13125 d = SupportCount.compare( b4, a, true, true, false );
13126 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
13130 catch ( final Exception e ) {
13131 e.printStackTrace( System.out );
13137 private static boolean testSupportTransfer() {
13139 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13140 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)",
13141 new NHXParser() )[ 0 ];
13142 final Phylogeny p2 = factory.create(
13143 "(((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)",
13144 new NHXParser() )[ 0 ];
13145 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
13148 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
13151 support_transfer.moveBranchLengthsToBootstrap( p1 );
13152 support_transfer.transferSupportValues( p1, p2 );
13153 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
13156 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
13159 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
13162 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
13165 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
13168 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13171 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13174 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13178 catch ( final Exception e ) {
13179 e.printStackTrace( System.out );
13185 private static boolean testTaxonomyExtraction() {
13187 final PhylogenyNode n0 = PhylogenyNode
13188 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13189 if ( n0.getNodeData().isHasTaxonomy() ) {
13192 final PhylogenyNode n1 = PhylogenyNode
13193 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13194 if ( n1.getNodeData().isHasTaxonomy() ) {
13195 System.out.println( n1.toString() );
13198 final PhylogenyNode n2x = PhylogenyNode
13199 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13200 if ( n2x.getNodeData().isHasTaxonomy() ) {
13203 final PhylogenyNode n3 = PhylogenyNode
13204 .createInstanceFromNhxString( "BLAGG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13205 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13206 System.out.println( n3.toString() );
13209 final PhylogenyNode n4 = PhylogenyNode
13210 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13211 if ( n4.getNodeData().isHasTaxonomy() ) {
13212 System.out.println( n4.toString() );
13215 final PhylogenyNode n5 = PhylogenyNode
13216 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13217 if ( n5.getNodeData().isHasTaxonomy() ) {
13218 System.out.println( n5.toString() );
13221 final PhylogenyNode n6 = PhylogenyNode
13222 .createInstanceFromNhxString( "BLAGG-12345-blag",
13223 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13224 if ( n6.getNodeData().isHasTaxonomy() ) {
13225 System.out.println( n6.toString() );
13228 final PhylogenyNode n7 = PhylogenyNode
13229 .createInstanceFromNhxString( "BL-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13230 if ( n7.getNodeData().isHasTaxonomy() ) {
13231 System.out.println( n7.toString() );
13234 final PhylogenyNode n8 = PhylogenyNode
13235 .createInstanceFromNhxString( "BLAGG_12345-blag",
13236 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13237 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13238 System.out.println( n8.toString() );
13241 final PhylogenyNode n9 = PhylogenyNode
13242 .createInstanceFromNhxString( "BLAGG_12345/blag",
13243 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13244 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13245 System.out.println( n9.toString() );
13248 final PhylogenyNode n10x = PhylogenyNode
13249 .createInstanceFromNhxString( "BLAG!_12X45-blag",
13250 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13251 if ( n10x.getNodeData().isHasTaxonomy() ) {
13252 System.out.println( n10x.toString() );
13255 final PhylogenyNode n10xx = PhylogenyNode
13256 .createInstanceFromNhxString( "BLAG!_1YX45-blag",
13257 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13258 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13259 System.out.println( n10xx.toString() );
13262 final PhylogenyNode n10 = PhylogenyNode
13263 .createInstanceFromNhxString( "BLAGG_9YX45-blag",
13264 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13265 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13266 System.out.println( n10.toString() );
13269 final PhylogenyNode n10v = PhylogenyNode
13270 .createInstanceFromNhxString( "BLAGG_BPM1-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13271 if ( !n10v.getNodeData().getTaxonomy().getTaxonomyCode().equals( "BPM1" ) ) {
13272 System.out.println( n10v.toString() );
13275 final PhylogenyNode n10v2 = PhylogenyNode
13276 .createInstanceFromNhxString( "BLAGG_ABV-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13277 if ( !n10v2.getNodeData().getTaxonomy().getTaxonomyCode().equals( "ABV" ) ) {
13278 System.out.println( n10v2.toString() );
13281 final PhylogenyNode n11 = PhylogenyNode
13282 .createInstanceFromNhxString( "BLAG@_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13283 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13284 System.out.println( n11.toString() );
13287 final PhylogenyNode n12 = PhylogenyNode
13288 .createInstanceFromNhxString( "BLA_G_Mus_musculus_musculus",
13289 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13290 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13291 System.out.println( n12.toString() );
13294 final PhylogenyNode n13 = PhylogenyNode
13295 .createInstanceFromNhxString( "BLAaG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13296 if ( n13.getNodeData().isHasTaxonomy() ) {
13297 System.out.println( n13.toString() );
13300 final PhylogenyNode n14 = PhylogenyNode
13301 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13302 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13303 System.out.println( n14.toString() );
13306 final PhylogenyNode n15 = PhylogenyNode
13307 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13308 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13309 System.out.println( n15.toString() );
13312 final PhylogenyNode n16 = PhylogenyNode
13313 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13314 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13315 System.out.println( n16.toString() );
13318 final PhylogenyNode n17 = PhylogenyNode
13319 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13320 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13321 System.out.println( n17.toString() );
13324 final PhylogenyNode n18 = PhylogenyNode
13325 .createInstanceFromNhxString( "Mus_musculus_musculus_392",
13326 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13327 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13328 System.out.println( n18.toString() );
13331 final PhylogenyNode n19 = PhylogenyNode
13332 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13333 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13334 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13335 System.out.println( n19.toString() );
13338 final PhylogenyNode n20 = PhylogenyNode
13339 .createInstanceFromNhxString( "Mus musculus musculus 392",
13340 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13341 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13342 System.out.println( n20.toString() );
13345 final PhylogenyNode n21 = PhylogenyNode
13346 .createInstanceFromNhxString( "Mus musculus musculus K392",
13347 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13348 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13349 System.out.println( n21.toString() );
13352 final PhylogenyNode n23 = PhylogenyNode
13353 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13354 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13355 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13356 System.out.println( n23.toString() );
13359 final PhylogenyNode n24 = PhylogenyNode
13360 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13361 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13362 System.out.println( n24.toString() );
13366 final PhylogenyNode n25 = PhylogenyNode
13367 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13368 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13369 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13370 System.out.println( n25.toString() );
13373 final PhylogenyNode n26 = PhylogenyNode
13374 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13375 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13376 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13377 System.out.println( n26.toString() );
13380 final PhylogenyNode n27 = PhylogenyNode
13381 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13382 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13383 System.out.println( n27.toString() );
13387 catch ( final Exception e ) {
13388 e.printStackTrace( System.out );
13394 private static boolean testTreeCopy() {
13396 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13397 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13398 final Phylogeny t1 = t0.copy();
13399 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13402 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13405 t0.deleteSubtree( t0.getNode( "c" ), true );
13406 t0.deleteSubtree( t0.getNode( "a" ), true );
13407 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13408 t0.getNode( "b" ).setName( "Bee" );
13409 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13412 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13415 t0.deleteSubtree( t0.getNode( "e" ), true );
13416 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13417 t0.deleteSubtree( t0.getNode( "d" ), true );
13418 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13422 catch ( final Exception e ) {
13423 e.printStackTrace();
13429 private static boolean testTreeMethods() {
13431 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13432 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13433 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13434 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13435 System.out.println( t0.toNewHampshireX() );
13438 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13439 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13440 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13443 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13446 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13450 catch ( final Exception e ) {
13451 e.printStackTrace( System.out );
13457 private static boolean testPhylogenyMethods() {
13459 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13460 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)r", new NHXParser() )[ 0 ];
13462 if ( PhylogenyMethods.calculateLevel( t0.getNode( "A" ) ) != 0 ) {
13465 if ( PhylogenyMethods.calculateLevel( t0.getNode( "B" ) ) != 0 ) {
13468 if ( PhylogenyMethods.calculateLevel( t0.getNode( "ab" ) ) != 1 ) {
13471 if ( PhylogenyMethods.calculateLevel( t0.getNode( "C" ) ) != 0 ) {
13474 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abc" ) ) != 2 ) {
13477 if ( PhylogenyMethods.calculateLevel( t0.getNode( "D" ) ) != 0 ) {
13480 if ( PhylogenyMethods.calculateLevel( t0.getNode( "abcd" ) ) != 3 ) {
13483 if ( PhylogenyMethods.calculateLevel( t0.getNode( "E" ) ) != 0 ) {
13486 if ( PhylogenyMethods.calculateLevel( t0.getNode( "r" ) ) != 4 ) {
13489 final Phylogeny t1 = factory.create( "((((A,B)ab,C)abc,D)abcd,E,((((((X)1)2)3)4)5)6)r", new NHXParser() )[ 0 ];
13490 if ( PhylogenyMethods.calculateLevel( t1.getNode( "r" ) ) != 7 ) {
13493 if ( PhylogenyMethods.calculateLevel( t1.getNode( "X" ) ) != 0 ) {
13496 if ( PhylogenyMethods.calculateLevel( t1.getNode( "6" ) ) != 6 ) {
13499 if ( PhylogenyMethods.calculateLevel( t1.getNode( "5" ) ) != 5 ) {
13502 if ( PhylogenyMethods.calculateLevel( t1.getNode( "4" ) ) != 4 ) {
13505 if ( PhylogenyMethods.calculateLevel( t1.getNode( "3" ) ) != 3 ) {
13508 if ( PhylogenyMethods.calculateLevel( t1.getNode( "2" ) ) != 2 ) {
13511 if ( PhylogenyMethods.calculateLevel( t1.getNode( "1" ) ) != 1 ) {
13514 if ( PhylogenyMethods.calculateLevel( t1.getNode( "abcd" ) ) != 3 ) {
13519 catch ( final Exception e ) {
13520 e.printStackTrace( System.out );
13526 private static boolean testUniprotEntryRetrieval() {
13528 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13529 if ( !entry.getAccession().equals( "P12345" ) ) {
13532 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13535 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13538 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13541 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13544 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13547 if ( entry.getMolecularSequence() == null ) {
13550 if ( !entry.getMolecularSequence().getMolecularSequenceAsString()
13551 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13552 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13553 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13554 System.out.println( "expected something else." );
13558 catch ( final IOException e ) {
13559 System.out.println();
13560 System.out.println( "the following might be due to absence internet connection:" );
13561 e.printStackTrace( System.out );
13564 catch ( final NullPointerException f ) {
13565 f.printStackTrace( System.out );
13568 catch ( final Exception e ) {
13574 private static boolean testUniprotTaxonomySearch() {
13576 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13578 if ( results.size() != 1 ) {
13581 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13584 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13587 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13590 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13593 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13597 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13598 if ( results.size() != 1 ) {
13601 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13604 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13607 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13610 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13613 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13617 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13618 if ( results.size() != 1 ) {
13621 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13624 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13627 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13630 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13633 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13637 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13638 if ( results.size() != 1 ) {
13641 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13644 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13647 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13650 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13653 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13656 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13659 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13662 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13663 .equals( "Nematostella vectensis" ) ) {
13664 System.out.println( results.get( 0 ).getLineage() );
13669 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13670 if ( results.size() != 1 ) {
13673 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13676 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13679 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13682 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13685 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13688 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13689 .equals( "Xenopus tropicalis" ) ) {
13690 System.out.println( results.get( 0 ).getLineage() );
13695 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13696 if ( results.size() != 1 ) {
13699 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13702 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13705 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13708 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13711 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13714 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13715 .equals( "Xenopus tropicalis" ) ) {
13716 System.out.println( results.get( 0 ).getLineage() );
13721 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13722 if ( results.size() != 1 ) {
13725 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13728 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13731 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13734 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13737 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13740 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13741 .equals( "Xenopus tropicalis" ) ) {
13742 System.out.println( results.get( 0 ).getLineage() );
13746 catch ( final IOException e ) {
13747 System.out.println();
13748 System.out.println( "the following might be due to absence internet connection:" );
13749 e.printStackTrace( System.out );
13752 catch ( final Exception e ) {