2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import javax.net.ssl.HttpsURLConnection;
44 import javax.net.ssl.SSLContext;
46 import org.forester.application.support_transfer;
47 import org.forester.archaeopteryx.AptxUtil;
48 import org.forester.archaeopteryx.TreePanelUtil;
49 import org.forester.archaeopteryx.webservices.WebserviceUtil;
50 import org.forester.development.DevelopmentTools;
51 import org.forester.evoinference.TestPhylogenyReconstruction;
52 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
53 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
54 import org.forester.go.TestGo;
55 import org.forester.io.parsers.FastaParser;
56 import org.forester.io.parsers.GeneralMsaParser;
57 import org.forester.io.parsers.HmmscanPerDomainTableParser;
58 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
59 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
60 import org.forester.io.parsers.nexus.NexusCharactersParser;
61 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
62 import org.forester.io.parsers.nhx.NHXParser;
63 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
64 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
65 import org.forester.io.parsers.tol.TolParser;
66 import org.forester.io.parsers.util.ParserUtils;
67 import org.forester.io.writers.PhylogenyWriter;
68 import org.forester.io.writers.SequenceWriter;
69 import org.forester.msa.BasicMsa;
70 import org.forester.msa.DeleteableMsa;
71 import org.forester.msa.Mafft;
72 import org.forester.msa.Msa;
73 import org.forester.msa.Msa.MSA_FORMAT;
74 import org.forester.msa.MsaInferrer;
75 import org.forester.msa.MsaMethods;
76 import org.forester.pccx.TestPccx;
77 import org.forester.phylogeny.Phylogeny;
78 import org.forester.phylogeny.PhylogenyBranch;
79 import org.forester.phylogeny.PhylogenyMethods;
80 import org.forester.phylogeny.PhylogenyNode;
81 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
82 import org.forester.phylogeny.data.Accession;
83 import org.forester.phylogeny.data.Accession.Source;
84 import org.forester.phylogeny.data.BinaryCharacters;
85 import org.forester.phylogeny.data.BranchWidth;
86 import org.forester.phylogeny.data.Confidence;
87 import org.forester.phylogeny.data.Distribution;
88 import org.forester.phylogeny.data.DomainArchitecture;
89 import org.forester.phylogeny.data.Event;
90 import org.forester.phylogeny.data.Identifier;
91 import org.forester.phylogeny.data.PhylogenyData;
92 import org.forester.phylogeny.data.PhylogenyDataUtil;
93 import org.forester.phylogeny.data.Polygon;
94 import org.forester.phylogeny.data.PropertiesMap;
95 import org.forester.phylogeny.data.Property;
96 import org.forester.phylogeny.data.Property.AppliesTo;
97 import org.forester.phylogeny.data.ProteinDomain;
98 import org.forester.phylogeny.data.Taxonomy;
99 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
100 import org.forester.phylogeny.factories.PhylogenyFactory;
101 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
102 import org.forester.protein.BasicDomain;
103 import org.forester.protein.BasicProtein;
104 import org.forester.protein.Domain;
105 import org.forester.protein.Protein;
106 import org.forester.protein.ProteinId;
107 import org.forester.rio.TestRIO;
108 import org.forester.sdi.SDI;
109 import org.forester.sdi.SDIR;
110 import org.forester.sdi.TestGSDI;
111 import org.forester.sequence.BasicSequence;
112 import org.forester.sequence.MolecularSequence;
113 import org.forester.species.BasicSpecies;
114 import org.forester.species.Species;
115 import org.forester.surfacing.TestSurfacing;
116 import org.forester.tools.ConfidenceAssessor;
117 import org.forester.tools.SupportCount;
118 import org.forester.tools.TreeSplitMatrix;
119 import org.forester.util.AsciiHistogram;
120 import org.forester.util.BasicDescriptiveStatistics;
121 import org.forester.util.BasicTable;
122 import org.forester.util.BasicTableParser;
123 import org.forester.util.DescriptiveStatistics;
124 import org.forester.util.ForesterConstants;
125 import org.forester.util.ForesterUtil;
126 import org.forester.util.GeneralTable;
127 import org.forester.util.SequenceAccessionTools;
128 import org.forester.ws.seqdb.SequenceDatabaseEntry;
129 import org.forester.ws.seqdb.SequenceDbWsTools;
130 import org.forester.ws.seqdb.UniProtTaxonomy;
133 @SuppressWarnings( "unused")
134 public final class Test {
136 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
137 + ForesterUtil.getFileSeparator() + "resources"
138 + ForesterUtil.getFileSeparator();
139 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
140 + ForesterUtil.getFileSeparator() + "test_data"
141 + ForesterUtil.getFileSeparator();
142 private final static boolean PERFORM_DB_TESTS = true;
143 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
144 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
145 + ForesterConstants.PHYLO_XML_VERSION + "/"
146 + ForesterConstants.PHYLO_XML_XSD;
147 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
148 + ForesterConstants.PHYLO_XML_VERSION + "/"
149 + ForesterConstants.PHYLO_XML_XSD;
150 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
151 private final static double ZERO_DIFF = 1.0E-9;
153 private static boolean isEqual( final double a, final double b ) {
154 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
157 public static void main( final String[] args ) {
158 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
159 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
161 Locale.setDefault( Locale.US );
162 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
165 System.out.print( "[Test if directory with files for testing exists/is readable: " );
166 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
167 System.out.println( "OK.]" );
170 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
171 System.out.println( "Testing aborted." );
174 System.out.print( "[Test if resources directory exists/is readable: " );
175 if ( testDir( PATH_TO_RESOURCES ) ) {
176 System.out.println( "OK.]" );
179 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
180 System.out.println( "Testing aborted." );
183 final long start_time = new Date().getTime();
185 System.out.print( "Basic node methods: " );
186 if ( Test.testBasicNodeMethods() ) {
187 System.out.println( "OK." );
191 System.out.println( "failed." );
194 System.out.print( "Protein id: " );
195 if ( !testProteinId() ) {
196 System.out.println( "failed." );
202 System.out.println( "OK." );
203 System.out.print( "Species: " );
204 if ( !testSpecies() ) {
205 System.out.println( "failed." );
211 System.out.println( "OK." );
212 System.out.print( "Basic domain: " );
213 if ( !testBasicDomain() ) {
214 System.out.println( "failed." );
220 System.out.println( "OK." );
221 System.out.print( "Basic protein: " );
222 if ( !testBasicProtein() ) {
223 System.out.println( "failed." );
229 System.out.println( "OK." );
230 System.out.print( "Sequence writer: " );
231 if ( testSequenceWriter() ) {
232 System.out.println( "OK." );
236 System.out.println( "failed." );
239 System.out.print( "Sequence id parsing: " );
240 if ( testSequenceIdParsing() ) {
241 System.out.println( "OK." );
245 System.out.println( "failed." );
248 System.out.print( "UniProtKB id extraction: " );
249 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
250 System.out.println( "OK." );
254 System.out.println( "failed." );
257 System.out.print( "Sequence DB tools 1: " );
258 if ( testSequenceDbWsTools1() ) {
259 System.out.println( "OK." );
263 System.out.println( "failed." );
266 System.out.print( "Hmmscan output parser: " );
267 if ( testHmmscanOutputParser() ) {
268 System.out.println( "OK." );
272 System.out.println( "failed." );
275 System.out.print( "Overlap removal: " );
276 if ( !org.forester.test.Test.testOverlapRemoval() ) {
277 System.out.println( "failed." );
283 System.out.println( "OK." );
284 System.out.print( "Engulfing overlap removal: " );
285 if ( !Test.testEngulfingOverlapRemoval() ) {
286 System.out.println( "failed." );
292 System.out.println( "OK." );
293 System.out.print( "Taxonomy data extraction: " );
294 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
295 System.out.println( "OK." );
299 System.out.println( "failed." );
302 System.out.print( "Taxonomy code extraction: " );
303 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
304 System.out.println( "OK." );
308 System.out.println( "failed." );
311 System.out.print( "SN extraction: " );
312 if ( Test.testExtractSNFromNodeName() ) {
313 System.out.println( "OK." );
317 System.out.println( "failed." );
320 System.out.print( "Taxonomy extraction (general): " );
321 if ( Test.testTaxonomyExtraction() ) {
322 System.out.println( "OK." );
326 System.out.println( "failed." );
329 System.out.print( "Uri for Aptx web sequence accession: " );
330 if ( Test.testCreateUriForSeqWeb() ) {
331 System.out.println( "OK." );
335 System.out.println( "failed." );
338 System.out.print( "Basic node construction and parsing of NHX (node level): " );
339 if ( Test.testNHXNodeParsing() ) {
340 System.out.println( "OK." );
344 System.out.println( "failed." );
347 System.out.print( "Node construction and parsing of NHX (node level): " );
348 if ( Test.testNHXNodeParsing2() ) {
349 System.out.println( "OK." );
353 System.out.println( "failed." );
356 System.out.print( "NHX parsing iterating: " );
357 if ( Test.testNHParsingIter() ) {
358 System.out.println( "OK." );
362 System.out.println( "failed." );
365 System.out.print( "NH parsing: " );
366 if ( Test.testNHParsing() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "NH parsing - special chars: " );
375 if ( Test.testNHParsingSpecialChars() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "Conversion to NHX (node level): " );
384 if ( Test.testNHXconversion() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing: " );
393 if ( Test.testNHXParsing() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "NHX parsing with quotes: " );
402 if ( Test.testNHXParsingQuotes() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "NHX parsing (MrBayes): " );
411 if ( Test.testNHXParsingMB() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus characters parsing: " );
420 if ( Test.testNexusCharactersParsing() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing iterating: " );
429 if ( Test.testNexusTreeParsingIterating() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus tree parsing: " );
438 if ( Test.testNexusTreeParsing() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Nexus tree parsing (translating): " );
447 if ( Test.testNexusTreeParsingTranslating() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Nexus matrix parsing: " );
456 if ( Test.testNexusMatrixParsing() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Basic phyloXML parsing: " );
465 if ( Test.testBasicPhyloXMLparsing() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "Basic phyloXML parsing (validating against schema): " );
474 if ( testBasicPhyloXMLparsingValidating() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "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( "Postorder Iterator: " );
555 if ( Test.testPostOrderIterator() ) {
556 System.out.println( "OK." );
560 System.out.println( "failed." );
563 System.out.print( "Preorder Iterator: " );
564 if ( Test.testPreOrderIterator() ) {
565 System.out.println( "OK." );
569 System.out.println( "failed." );
572 System.out.print( "Levelorder Iterator: " );
573 if ( Test.testLevelOrderIterator() ) {
574 System.out.println( "OK." );
578 System.out.println( "failed." );
581 System.out.print( "Re-id methods: " );
582 if ( Test.testReIdMethods() ) {
583 System.out.println( "OK." );
587 System.out.println( "failed." );
590 System.out.print( "Methods on last external nodes: " );
591 if ( Test.testLastExternalNodeMethods() ) {
592 System.out.println( "OK." );
596 System.out.println( "failed." );
599 System.out.print( "Methods on external nodes: " );
600 if ( Test.testExternalNodeRelatedMethods() ) {
601 System.out.println( "OK." );
605 System.out.println( "failed." );
608 System.out.print( "Deletion of external nodes: " );
609 if ( Test.testDeletionOfExternalNodes() ) {
610 System.out.println( "OK." );
614 System.out.println( "failed." );
617 System.out.print( "Subtree deletion: " );
618 if ( Test.testSubtreeDeletion() ) {
619 System.out.println( "OK." );
623 System.out.println( "failed." );
626 System.out.print( "Phylogeny branch: " );
627 if ( Test.testPhylogenyBranch() ) {
628 System.out.println( "OK." );
632 System.out.println( "failed." );
635 System.out.print( "Rerooting: " );
636 if ( Test.testRerooting() ) {
637 System.out.println( "OK." );
641 System.out.println( "failed." );
644 System.out.print( "Mipoint rooting: " );
645 if ( Test.testMidpointrooting() ) {
646 System.out.println( "OK." );
650 System.out.println( "failed." );
653 System.out.print( "Node removal: " );
654 if ( Test.testNodeRemoval() ) {
655 System.out.println( "OK." );
659 System.out.println( "failed." );
662 System.out.print( "Support count: " );
663 if ( Test.testSupportCount() ) {
664 System.out.println( "OK." );
668 System.out.println( "failed." );
671 System.out.print( "Support transfer: " );
672 if ( Test.testSupportTransfer() ) {
673 System.out.println( "OK." );
677 System.out.println( "failed." );
680 System.out.print( "Finding of LCA: " );
681 if ( Test.testGetLCA() ) {
682 System.out.println( "OK." );
686 System.out.println( "failed." );
689 System.out.print( "Finding of LCA 2: " );
690 if ( Test.testGetLCA2() ) {
691 System.out.println( "OK." );
695 System.out.println( "failed." );
698 System.out.print( "Calculation of distance between nodes: " );
699 if ( Test.testGetDistance() ) {
700 System.out.println( "OK." );
704 System.out.println( "failed." );
707 System.out.print( "Descriptive statistics: " );
708 if ( Test.testDescriptiveStatistics() ) {
709 System.out.println( "OK." );
713 System.out.println( "failed." );
716 System.out.print( "Data objects and methods: " );
717 if ( Test.testDataObjects() ) {
718 System.out.println( "OK." );
722 System.out.println( "failed." );
725 System.out.print( "Properties map: " );
726 if ( Test.testPropertiesMap() ) {
727 System.out.println( "OK." );
731 System.out.println( "failed." );
734 System.out.print( "SDIse: " );
735 if ( Test.testSDIse() ) {
736 System.out.println( "OK." );
740 System.out.println( "failed." );
743 System.out.print( "SDIunrooted: " );
744 if ( Test.testSDIunrooted() ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "GSDI: " );
753 if ( TestGSDI.test() ) {
754 System.out.println( "OK." );
758 System.out.println( "failed." );
761 System.out.print( "RIO: " );
762 if ( TestRIO.test() ) {
763 System.out.println( "OK." );
767 System.out.println( "failed." );
770 System.out.print( "Phylogeny reconstruction:" );
771 System.out.println();
772 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
773 System.out.println( "OK." );
777 System.out.println( "failed." );
780 System.out.print( "Analysis of domain architectures: " );
781 System.out.println();
782 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "GO: " );
791 System.out.println();
792 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
793 System.out.println( "OK." );
797 System.out.println( "failed." );
800 System.out.print( "Modeling tools: " );
801 if ( TestPccx.test() ) {
802 System.out.println( "OK." );
806 System.out.println( "failed." );
809 System.out.print( "Split Matrix strict: " );
810 if ( Test.testSplitStrict() ) {
811 System.out.println( "OK." );
815 System.out.println( "failed." );
818 System.out.print( "Split Matrix: " );
819 if ( Test.testSplit() ) {
820 System.out.println( "OK." );
824 System.out.println( "failed." );
827 System.out.print( "Confidence Assessor: " );
828 if ( Test.testConfidenceAssessor() ) {
829 System.out.println( "OK." );
833 System.out.println( "failed." );
836 System.out.print( "Basic table: " );
837 if ( Test.testBasicTable() ) {
838 System.out.println( "OK." );
842 System.out.println( "failed." );
845 System.out.print( "General table: " );
846 if ( Test.testGeneralTable() ) {
847 System.out.println( "OK." );
851 System.out.println( "failed." );
854 System.out.print( "Amino acid sequence: " );
855 if ( Test.testAminoAcidSequence() ) {
856 System.out.println( "OK." );
860 System.out.println( "failed." );
863 System.out.print( "General MSA parser: " );
864 if ( Test.testGeneralMsaParser() ) {
865 System.out.println( "OK." );
869 System.out.println( "failed." );
872 System.out.print( "Fasta parser for msa: " );
873 if ( Test.testFastaParser() ) {
874 System.out.println( "OK." );
878 System.out.println( "failed." );
881 System.out.print( "Creation of balanced phylogeny: " );
882 if ( Test.testCreateBalancedPhylogeny() ) {
883 System.out.println( "OK." );
887 System.out.println( "failed." );
890 System.out.print( "Genbank accessor parsing: " );
891 if ( Test.testGenbankAccessorParsing() ) {
892 System.out.println( "OK." );
896 System.out.println( "failed." );
900 final String os = ForesterUtil.OS_NAME.toLowerCase();
901 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
902 path = "/usr/local/bin/mafft";
904 else if ( os.indexOf( "win" ) >= 0 ) {
905 path = "C:\\Program Files\\mafft-win\\mafft.bat";
909 if ( !MsaInferrer.isInstalled( path ) ) {
910 path = "/usr/bin/mafft";
912 if ( !MsaInferrer.isInstalled( path ) ) {
913 path = "/usr/local/bin/mafft";
916 if ( MsaInferrer.isInstalled( path ) ) {
917 System.out.print( "MAFFT (external program): " );
918 if ( Test.testMafft( path ) ) {
919 System.out.println( "OK." );
923 System.out.println( "failed [will not count towards failed tests]" );
926 System.out.print( "Next nodes with collapsed: " );
927 if ( Test.testNextNodeWithCollapsing() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Simple MSA quality: " );
936 if ( Test.testMsaQualityMethod() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Deleteable MSA: " );
945 if ( Test.testDeleteableMsa() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
953 System.out.print( "MSA entropy: " );
954 if ( Test.testMsaEntropy() ) {
955 System.out.println( "OK." );
959 System.out.println( "failed." );
962 if ( PERFORM_DB_TESTS ) {
963 System.out.print( "Uniprot Entry Retrieval: " );
964 if ( Test.testUniprotEntryRetrieval() ) {
965 System.out.println( "OK." );
969 System.out.println( "failed." );
972 System.out.print( "Ebi Entry Retrieval: " );
973 if ( Test.testEbiEntryRetrieval() ) {
974 System.out.println( "OK." );
978 System.out.println( "failed." );
981 System.out.print( "Sequence DB tools 2: " );
982 if ( testSequenceDbWsTools2() ) {
983 System.out.println( "OK." );
987 System.out.println( "failed." );
991 System.out.print( "Uniprot Taxonomy Search: " );
992 if ( Test.testUniprotTaxonomySearch() ) {
993 System.out.println( "OK." );
997 System.out.println( "failed." );
1001 if ( PERFORM_WEB_TREE_ACCESS ) {
1002 System.out.print( "TreeBase acccess: " );
1003 if ( Test.testTreeBaseReading() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1011 System.out.print( "ToL access: " );
1012 if ( Test.testToLReading() ) {
1013 System.out.println( "OK." );
1017 System.out.println( "failed." );
1020 System.out.print( "NHX parsing from URL: " );
1021 if ( Test.testNHXparsingFromURL() ) {
1022 System.out.println( "OK." );
1026 System.out.println( "failed." );
1029 System.out.print( "NHX parsing from URL 2: " );
1030 if ( Test.testNHXparsingFromURL2() ) {
1031 System.out.println( "OK." );
1035 System.out.println( "failed." );
1038 System.out.print( "phyloXML parsing from URL: " );
1039 if ( Test.testPhyloXMLparsingFromURL() ) {
1040 System.out.println( "OK." );
1044 System.out.println( "failed." );
1047 System.out.print( "TreeFam access: " );
1048 if ( Test.testTreeFamReading() ) {
1049 System.out.println( "OK." );
1053 System.out.println( "failed." );
1056 System.out.print( "Pfam tree access: " );
1057 if ( Test.testPfamTreeReading() ) {
1058 System.out.println( "OK." );
1062 System.out.println( "failed." );
1066 System.out.println();
1067 final Runtime rt = java.lang.Runtime.getRuntime();
1068 final long free_memory = rt.freeMemory() / 1000000;
1069 final long total_memory = rt.totalMemory() / 1000000;
1070 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1071 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1072 System.out.println();
1073 System.out.println( "Successful tests: " + succeeded );
1074 System.out.println( "Failed tests: " + failed );
1075 System.out.println();
1077 System.out.println( "OK." );
1080 System.out.println( "Not OK." );
1084 private static boolean testEngulfingOverlapRemoval() {
1086 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1087 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1088 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1089 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1090 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1091 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1092 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1093 final List<Boolean> covered = new ArrayList<Boolean>();
1094 covered.add( true ); // 0
1095 covered.add( false ); // 1
1096 covered.add( true ); // 2
1097 covered.add( false ); // 3
1098 covered.add( true ); // 4
1099 covered.add( true ); // 5
1100 covered.add( false ); // 6
1101 covered.add( true ); // 7
1102 covered.add( true ); // 8
1103 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1106 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1109 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1112 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1115 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1118 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1121 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1124 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1125 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1126 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1127 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1128 abc.addProteinDomain( a );
1129 abc.addProteinDomain( b );
1130 abc.addProteinDomain( c );
1131 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1132 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1133 if ( abc.getNumberOfProteinDomains() != 3 ) {
1136 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1139 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1142 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1145 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1148 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1149 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1150 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1151 final Protein def = new BasicProtein( "def", "nemve", 0 );
1152 def.addProteinDomain( d );
1153 def.addProteinDomain( e );
1154 def.addProteinDomain( f );
1155 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1156 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1157 if ( def.getNumberOfProteinDomains() != 3 ) {
1160 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1163 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1166 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1169 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1172 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1176 catch ( final Exception e ) {
1177 e.printStackTrace( System.out );
1183 private static final boolean testNHXparsingFromURL2() {
1185 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1186 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1190 TAXONOMY_EXTRACTION.NO,
1192 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1195 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1196 System.out.println( phys[ 0 ].toNewHampshire() );
1199 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1200 System.out.println( phys[ 1 ].toNewHampshire() );
1203 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1207 TAXONOMY_EXTRACTION.NO,
1209 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1212 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1213 System.out.println( phys2[ 0 ].toNewHampshire() );
1216 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1217 System.out.println( phys2[ 1 ].toNewHampshire() );
1220 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1221 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1222 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1227 .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))))));" ) ) {
1228 System.out.println( phys3[ 0 ].toNewHampshire() );
1231 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1232 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1233 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1238 .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))))));" ) ) {
1239 System.out.println( phys4[ 0 ].toNewHampshire() );
1243 catch ( final Exception e ) {
1244 e.printStackTrace();
1250 private static final boolean testNHXparsingFromURL() {
1252 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1253 final URL u = new URL( s );
1254 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1255 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1256 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1259 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1260 System.out.println( phys[ 0 ].toNewHampshire() );
1263 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1264 System.out.println( phys[ 1 ].toNewHampshire() );
1267 final URL u2 = new URL( s );
1268 final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() );
1269 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1272 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1273 System.out.println( phys2[ 0 ].toNewHampshire() );
1276 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1277 final NHXParser p = new NHXParser();
1278 final URL u3 = new URL( s );
1280 if ( !p.hasNext() ) {
1283 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1286 if ( !p.hasNext() ) {
1290 if ( !p.hasNext() ) {
1293 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1296 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1300 if ( !p.hasNext() ) {
1303 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1306 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1310 catch ( final Exception e ) {
1311 System.out.println( e.toString() );
1312 e.printStackTrace();
1318 private static boolean testOverlapRemoval() {
1320 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1321 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1322 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1323 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1324 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1325 final List<Boolean> covered = new ArrayList<Boolean>();
1326 covered.add( true ); // 0
1327 covered.add( false ); // 1
1328 covered.add( true ); // 2
1329 covered.add( false ); // 3
1330 covered.add( true ); // 4
1331 covered.add( true ); // 5
1332 covered.add( false ); // 6
1333 covered.add( true ); // 7
1334 covered.add( true ); // 8
1335 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1338 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1341 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1344 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1347 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1350 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1351 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1352 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1353 ab.addProteinDomain( a );
1354 ab.addProteinDomain( b );
1355 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1356 if ( ab.getNumberOfProteinDomains() != 2 ) {
1359 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1362 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1365 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1366 if ( ab.getNumberOfProteinDomains() != 2 ) {
1369 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1372 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1373 final Domain d = new BasicDomain( "d",
1380 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1381 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1382 cde.addProteinDomain( c );
1383 cde.addProteinDomain( d );
1384 cde.addProteinDomain( e );
1385 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1386 if ( cde.getNumberOfProteinDomains() != 3 ) {
1389 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1392 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1393 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1394 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1395 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1396 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1397 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1398 fghi.addProteinDomain( f );
1399 fghi.addProteinDomain( g );
1400 fghi.addProteinDomain( h );
1401 fghi.addProteinDomain( i );
1402 fghi.addProteinDomain( i );
1403 fghi.addProteinDomain( i );
1404 fghi.addProteinDomain( i2 );
1405 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1406 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1409 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1412 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1415 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1416 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1419 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1422 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1423 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1424 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1425 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1426 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1427 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1428 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1429 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1430 jklm.addProteinDomain( j );
1431 jklm.addProteinDomain( k );
1432 jklm.addProteinDomain( l );
1433 jklm.addProteinDomain( m );
1434 jklm.addProteinDomain( m0 );
1435 jklm.addProteinDomain( m1 );
1436 jklm.addProteinDomain( m2 );
1437 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1438 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1441 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1444 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1447 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1448 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1451 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1454 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1455 final Protein od = new BasicProtein( "od", "varanus", 0 );
1456 od.addProteinDomain( only );
1457 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1458 if ( od.getNumberOfProteinDomains() != 1 ) {
1461 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1465 catch ( final Exception e ) {
1466 e.printStackTrace( System.out );
1472 private static final boolean testPfamTreeReading() {
1474 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1475 final NHXParser parser = new NHXParser();
1476 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1477 parser.setReplaceUnderscores( false );
1478 parser.setGuessRootedness( true );
1479 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser);
1480 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1483 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1487 catch ( final Exception e ) {
1488 e.printStackTrace();
1494 private static final boolean testPhyloXMLparsingFromURL() {
1496 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1497 final URL u = new URL( s );
1498 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1500 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1503 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1505 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1509 catch ( final Exception e ) {
1510 e.printStackTrace();
1516 private static final boolean testToLReading() {
1518 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1519 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1520 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1523 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1526 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1529 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1533 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1534 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1535 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1538 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1541 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1545 catch ( final Exception e ) {
1546 e.printStackTrace();
1552 private static final boolean testTreeBaseReading() {
1554 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1555 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1556 parser.setReplaceUnderscores( true );
1557 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1558 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1561 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1562 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1563 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1564 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1567 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1568 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1569 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1570 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1573 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1574 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1575 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1576 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1579 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1580 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1581 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1582 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1585 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1586 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1587 parser2.setReplaceUnderscores( true );
1588 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1589 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1592 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1593 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1594 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1595 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1598 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14525?format=nexus" ),
1599 new NexusPhylogeniesParser() );
1600 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1603 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15632?format=nexus" ) ,
1604 new NexusPhylogeniesParser() );
1605 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1608 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "10190?format=nexus" ) ,
1609 new NexusPhylogeniesParser() );
1610 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1613 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "13246?format=nexus" ) ,
1614 new NexusPhylogeniesParser() );
1615 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1618 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "11662?format=nexus" ) ,
1619 new NexusPhylogeniesParser() );
1620 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1623 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "562?format=nexus" ) ,
1624 new NexusPhylogeniesParser() );
1625 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1628 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "16424?format=nexus" ) ,
1629 new NexusPhylogeniesParser() );
1630 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1633 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "17878?format=nexus" ) ,
1634 new NexusPhylogeniesParser() );
1635 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1638 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "18804?format=nexus" ) ,
1639 new NexusPhylogeniesParser() );
1640 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1643 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl( new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "346?format=nexus" ) ,
1644 new NexusPhylogeniesParser() );
1645 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1649 catch ( final Exception e ) {
1650 e.printStackTrace();
1656 private static final boolean testTreeFamReading() {
1658 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1659 final NHXParser parser = new NHXParser();
1660 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1661 parser.setReplaceUnderscores( false );
1662 parser.setGuessRootedness( true );
1663 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1664 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1667 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1671 catch ( final Exception e ) {
1672 e.printStackTrace();
1678 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1679 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1683 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1684 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1687 private static boolean testAminoAcidSequence() {
1689 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1690 if ( aa1.getLength() != 13 ) {
1693 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1696 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1699 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1702 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1703 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1706 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1707 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1710 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1711 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1715 catch ( final Exception e ) {
1716 e.printStackTrace();
1722 private static boolean testBasicDomain() {
1724 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1725 if ( !pd.getDomainId().equals( "id" ) ) {
1728 if ( pd.getNumber() != 1 ) {
1731 if ( pd.getTotalCount() != 4 ) {
1734 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1737 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1738 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1739 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1740 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1741 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1742 if ( !a1.equals( a1 ) ) {
1745 if ( !a1.equals( a1_copy ) ) {
1748 if ( !a1.equals( a1_equal ) ) {
1751 if ( !a1.equals( a2 ) ) {
1754 if ( a1.equals( a3 ) ) {
1757 if ( a1.compareTo( a1 ) != 0 ) {
1760 if ( a1.compareTo( a1_copy ) != 0 ) {
1763 if ( a1.compareTo( a1_equal ) != 0 ) {
1766 if ( a1.compareTo( a2 ) != 0 ) {
1769 if ( a1.compareTo( a3 ) == 0 ) {
1773 catch ( final Exception e ) {
1774 e.printStackTrace( System.out );
1780 private static boolean testBasicNodeMethods() {
1782 if ( PhylogenyNode.getNodeCount() != 0 ) {
1785 final PhylogenyNode n1 = new PhylogenyNode();
1786 final PhylogenyNode n2 = PhylogenyNode
1787 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1788 final PhylogenyNode n3 = PhylogenyNode
1789 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1790 final PhylogenyNode n4 = PhylogenyNode
1791 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1792 if ( n1.isHasAssignedEvent() ) {
1795 if ( PhylogenyNode.getNodeCount() != 4 ) {
1798 if ( n3.getIndicator() != 0 ) {
1801 if ( n3.getNumberOfExternalNodes() != 1 ) {
1804 if ( !n3.isExternal() ) {
1807 if ( !n3.isRoot() ) {
1810 if ( !n4.getName().equals( "n4" ) ) {
1814 catch ( final Exception e ) {
1815 e.printStackTrace( System.out );
1821 private static boolean testUTF8ParsingFromFile() {
1823 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1824 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ),
1826 if ( xml_parser.getErrorCount() > 0 ) {
1827 System.out.println( xml_parser.getErrorMessages().toString() );
1830 if ( phylogenies_xml.length != 1 ) {
1834 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance().create( new StringBuffer( phylogenies_xml[0].toPhyloXML( 0 )),
1837 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
1838 if ( phylogenies_nh.length != 1 ) {
1842 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance().create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
1843 if ( phylogenies_nex.length != 1 ) {
1847 final String[] xml_n = phylogenies_xml[0].getAllExternalNodeNames();
1848 final String[] xml_n2 = phylogenies_xml2[0].getAllExternalNodeNames();
1849 final String[] nh_n = phylogenies_nh[0].getAllExternalNodeNames();
1850 final String[] nex_n = phylogenies_nex[0].getAllExternalNodeNames();
1851 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
1852 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
1853 final String n2 = "漢字ひらがなカタカナ";
1854 final String n3 = "อักษรไทย";
1855 final String n4 = "繁體字";
1856 final String n5 = "한글";
1857 final String n6 = "देवनागरी";
1859 final String n7 = "chữ Quốc ngữ";
1860 final String n8 = "ру́сский язы́к";
1861 final String n9 = "អក្សរខ្មែរ";
1863 if ( !xml_n[0].equals( n0 ) ) {
1864 System.out.println( xml_n[0] );
1865 System.out.println( n0 );
1868 if ( !xml_n2[0].equals( n0 ) ) {
1869 System.out.println( xml_n2[0] );
1870 System.out.println( n0 );
1873 if ( !nh_n[0].equals( n0 ) ) {
1874 System.out.println( nh_n[0] );
1875 System.out.println( n0 );
1878 if ( !nex_n[0].equals( n0 ) ) {
1879 System.out.println( nex_n[0] );
1880 System.out.println( n0 );
1884 if ( !xml_n[1].equals( n1 ) ) {
1885 System.out.println( xml_n[1] );
1886 System.out.println( n1 );
1889 if ( !xml_n2[1].equals( n1 ) ) {
1890 System.out.println( xml_n2[1] );
1891 System.out.println( n1 );
1894 if ( !nh_n[1].equals( n1 ) ) {
1895 System.out.println( nh_n[1] );
1896 System.out.println( n1 );
1899 if ( !nex_n[1].equals( n1 ) ) {
1900 System.out.println( nex_n[1] );
1901 System.out.println( n1 );
1905 if ( !xml_n[2].equals( n2 ) ) {
1906 System.out.println( xml_n[2] );
1907 System.out.println( n2 );
1910 if ( !xml_n2[2].equals( n2 ) ) {
1911 System.out.println( xml_n2[2] );
1912 System.out.println( n2 );
1915 if ( !nh_n[2].equals( n2 ) ) {
1916 System.out.println( nh_n[2] );
1917 System.out.println( n2 );
1920 if ( !nex_n[2].equals( n2 ) ) {
1921 System.out.println( nex_n[2] );
1922 System.out.println( n2 );
1926 if ( !xml_n[3].equals( n3 ) ) {
1927 System.out.println( xml_n[3] );
1928 System.out.println( n3 );
1931 if ( !xml_n2[3].equals( n3 ) ) {
1932 System.out.println( xml_n2[3] );
1933 System.out.println( n3 );
1936 if ( !nh_n[3].equals( n3 ) ) {
1937 System.out.println( nh_n[3] );
1938 System.out.println( n3 );
1941 if ( !nex_n[3].equals( n3 ) ) {
1942 System.out.println( nex_n[3] );
1943 System.out.println( n3 );
1947 if ( !xml_n[4].equals( n4 ) ) {
1948 System.out.println( xml_n[4] );
1949 System.out.println( n4 );
1952 if ( !nh_n[4].equals( n4 ) ) {
1953 System.out.println( nh_n[4] );
1954 System.out.println( n4 );
1957 if ( !nex_n[4].equals( n4 ) ) {
1958 System.out.println( nex_n[4] );
1959 System.out.println( n4 );
1963 if ( !xml_n[5].equals( n5 ) ) {
1964 System.out.println( xml_n[5] );
1965 System.out.println( n5 );
1968 if ( !nh_n[5].equals( n5 ) ) {
1969 System.out.println( nh_n[5] );
1970 System.out.println( n5 );
1973 if ( !nex_n[5].equals( n5 ) ) {
1974 System.out.println( nex_n[5] );
1975 System.out.println( n5 );
1979 if ( !xml_n[6].equals( n6 ) ) {
1980 System.out.println( xml_n[6] );
1981 System.out.println( n6 );
1984 if ( !nh_n[6].equals( n6 ) ) {
1985 System.out.println( nh_n[6] );
1986 System.out.println( n6 );
1989 if ( !nex_n[6].equals( n6 ) ) {
1990 System.out.println( nex_n[6] );
1991 System.out.println( n6 );
1995 if ( !xml_n[7].equals( n7 ) ) {
1996 System.out.println( xml_n[7] );
1997 System.out.println( n7 );
2000 if ( !nh_n[7].equals( n7 ) ) {
2001 System.out.println( nh_n[7] );
2002 System.out.println( n7 );
2005 if ( !nex_n[7].equals( n7 ) ) {
2006 System.out.println( nex_n[7] );
2007 System.out.println( n7 );
2010 if ( !xml_n[8].equals( n8 ) ) {
2011 System.out.println( xml_n[8] );
2012 System.out.println( n8 );
2015 if ( !nh_n[8].equals( n8 ) ) {
2016 System.out.println( nh_n[8] );
2017 System.out.println( n8 );
2020 if ( !nex_n[8].equals( n8 ) ) {
2021 System.out.println( nex_n[8] );
2022 System.out.println( n8 );
2025 if ( !xml_n[9].equals( n9 ) ) {
2026 System.out.println( xml_n[9] );
2027 System.out.println( n9 );
2030 if ( !xml_n2[9].equals( n9 ) ) {
2031 System.out.println( xml_n2[9] );
2032 System.out.println( n9 );
2035 if ( !nh_n[9].equals( n9 ) ) {
2036 System.out.println( nh_n[9] );
2037 System.out.println( n9 );
2040 if ( !nex_n[9].equals( n9 ) ) {
2041 System.out.println( nex_n[9] );
2042 System.out.println( n9 );
2045 if (!phylogenies_xml[0].toNewHampshire().equals(
2046 phylogenies_nh[0].toNewHampshire() ) ) {
2047 System.out.println( phylogenies_xml[0].toNewHampshire() );
2048 System.out.println( phylogenies_nh[0].toNewHampshire() );
2051 if (!phylogenies_xml[0].toNewHampshire().equals(
2052 phylogenies_nex[0].toNewHampshire() ) ) {
2053 System.out.println( phylogenies_xml[0].toNewHampshire() );
2054 System.out.println( phylogenies_nex[0].toNewHampshire() );
2058 catch ( final Exception e ) {
2059 e.printStackTrace( System.out );
2067 private static boolean testBasicPhyloXMLparsing() {
2069 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2070 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2071 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2073 if ( xml_parser.getErrorCount() > 0 ) {
2074 System.out.println( xml_parser.getErrorMessages().toString() );
2077 if ( phylogenies_0.length != 4 ) {
2080 final Phylogeny t1 = phylogenies_0[ 0 ];
2081 final Phylogeny t2 = phylogenies_0[ 1 ];
2082 final Phylogeny t3 = phylogenies_0[ 2 ];
2083 final Phylogeny t4 = phylogenies_0[ 3 ];
2084 if ( t1.getNumberOfExternalNodes() != 1 ) {
2087 if ( !t1.isRooted() ) {
2090 if ( t1.isRerootable() ) {
2093 if ( !t1.getType().equals( "gene_tree" ) ) {
2096 if ( t2.getNumberOfExternalNodes() != 2 ) {
2099 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2102 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2105 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2108 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2111 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2114 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2117 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2118 .startsWith( "actgtgggggt" ) ) {
2121 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2122 .startsWith( "ctgtgatgcat" ) ) {
2125 if ( t3.getNumberOfExternalNodes() != 4 ) {
2128 if ( !t1.getName().equals( "t1" ) ) {
2131 if ( !t2.getName().equals( "t2" ) ) {
2134 if ( !t3.getName().equals( "t3" ) ) {
2137 if ( !t4.getName().equals( "t4" ) ) {
2140 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2143 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2146 if ( !t3.getNode( "root node" ).isDuplication() ) {
2149 if ( !t3.getNode( "node a" ).isDuplication() ) {
2152 if ( t3.getNode( "node a" ).isSpeciation() ) {
2155 if ( t3.getNode( "node bc" ).isDuplication() ) {
2158 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2161 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2164 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2165 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2168 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2171 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2174 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
2177 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2178 .equals( "apoptosis" ) ) {
2181 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2182 .equals( "GO:0006915" ) ) {
2185 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2186 .equals( "UniProtKB" ) ) {
2189 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2190 .equals( "experimental" ) ) {
2193 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2194 .equals( "function" ) ) {
2197 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2198 .getValue() != 1 ) {
2201 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2202 .getType().equals( "ml" ) ) {
2205 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2206 .equals( "apoptosis" ) ) {
2209 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2210 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2213 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2214 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2217 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2218 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2221 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2222 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2225 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2226 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2229 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2230 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2233 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2234 .equals( "GO:0005829" ) ) {
2237 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2238 .equals( "intracellular organelle" ) ) {
2241 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2244 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2245 .equals( "UniProt link" ) ) ) {
2248 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2251 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2252 if ( x.size() != 4 ) {
2256 for( final Accession acc : x ) {
2258 if ( !acc.getSource().equals( "KEGG" ) ) {
2261 if ( !acc.getValue().equals( "hsa:596" ) ) {
2268 catch ( final Exception e ) {
2269 e.printStackTrace( System.out );
2275 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2277 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2278 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2279 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2280 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2283 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2285 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2287 if ( xml_parser.getErrorCount() > 0 ) {
2288 System.out.println( xml_parser.getErrorMessages().toString() );
2291 if ( phylogenies_0.length != 4 ) {
2294 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2295 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2296 if ( phylogenies_t1.length != 1 ) {
2299 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2300 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2303 if ( !t1_rt.isRooted() ) {
2306 if ( t1_rt.isRerootable() ) {
2309 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2312 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2313 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2314 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2315 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2318 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2321 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2324 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2327 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2328 .startsWith( "actgtgggggt" ) ) {
2331 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2332 .startsWith( "ctgtgatgcat" ) ) {
2335 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2336 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2337 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2338 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2339 if ( phylogenies_1.length != 1 ) {
2342 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2343 if ( !t3_rt.getName().equals( "t3" ) ) {
2346 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2349 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2352 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2355 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2358 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2359 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2362 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2365 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2368 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2369 .equals( "UniProtKB" ) ) {
2372 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2373 .equals( "apoptosis" ) ) {
2376 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2377 .equals( "GO:0006915" ) ) {
2380 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2381 .equals( "UniProtKB" ) ) {
2384 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2385 .equals( "experimental" ) ) {
2388 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2389 .equals( "function" ) ) {
2392 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2393 .getValue() != 1 ) {
2396 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2397 .getType().equals( "ml" ) ) {
2400 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2401 .equals( "apoptosis" ) ) {
2404 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2405 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2408 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2409 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2412 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2413 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2416 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2417 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2420 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2421 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2424 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2425 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2428 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2429 .equals( "GO:0005829" ) ) {
2432 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2433 .equals( "intracellular organelle" ) ) {
2436 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2439 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2440 .equals( "UniProt link" ) ) ) {
2443 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2446 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2449 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2450 .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." ) ) ) {
2451 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2454 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2457 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2460 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2463 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2466 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2467 .equals( "ncbi" ) ) {
2470 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2473 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2474 .getName().equals( "B" ) ) {
2477 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2478 .getFrom() != 21 ) {
2481 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2484 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2485 .getLength() != 24 ) {
2488 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2489 .getConfidence() != 0 ) {
2492 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2493 .equals( "pfam" ) ) {
2496 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2499 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2502 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2505 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2508 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2509 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2512 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2515 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2518 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2521 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2524 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2527 if ( taxbb.getSynonyms().size() != 2 ) {
2530 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2533 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2536 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2539 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2542 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2545 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2546 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2549 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2552 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2555 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2558 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2561 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2564 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2567 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2570 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2573 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2574 .equalsIgnoreCase( "435" ) ) {
2577 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2580 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2581 .equalsIgnoreCase( "443.7" ) ) {
2584 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2587 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2590 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2591 .equalsIgnoreCase( "433" ) ) {
2594 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2595 .getCrossReferences();
2596 if ( x.size() != 4 ) {
2600 for( final Accession acc : x ) {
2602 if ( !acc.getSource().equals( "KEGG" ) ) {
2605 if ( !acc.getValue().equals( "hsa:596" ) ) {
2612 catch ( final Exception e ) {
2613 e.printStackTrace( System.out );
2619 private static boolean testBasicPhyloXMLparsingValidating() {
2621 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2622 PhyloXmlParser xml_parser = null;
2624 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2626 catch ( final Exception e ) {
2627 // Do nothing -- means were not running from jar.
2629 if ( xml_parser == null ) {
2630 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2631 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2632 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2635 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2638 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ),
2640 if ( xml_parser.getErrorCount() > 0 ) {
2641 System.out.println( xml_parser.getErrorMessages().toString() );
2644 if ( phylogenies_0.length != 4 ) {
2647 final Phylogeny t1 = phylogenies_0[ 0 ];
2648 final Phylogeny t2 = phylogenies_0[ 1 ];
2649 final Phylogeny t3 = phylogenies_0[ 2 ];
2650 final Phylogeny t4 = phylogenies_0[ 3 ];
2651 if ( !t1.getName().equals( "t1" ) ) {
2654 if ( !t2.getName().equals( "t2" ) ) {
2657 if ( !t3.getName().equals( "t3" ) ) {
2660 if ( !t4.getName().equals( "t4" ) ) {
2663 if ( t1.getNumberOfExternalNodes() != 1 ) {
2666 if ( t2.getNumberOfExternalNodes() != 2 ) {
2669 if ( t3.getNumberOfExternalNodes() != 4 ) {
2672 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2673 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2674 if ( xml_parser.getErrorCount() > 0 ) {
2675 System.out.println( "errors:" );
2676 System.out.println( xml_parser.getErrorMessages().toString() );
2679 if ( phylogenies_1.length != 4 ) {
2682 final Phylogeny[] phylogenies_2 = factory.create( new File(Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ),
2684 if ( xml_parser.getErrorCount() > 0 ) {
2685 System.out.println( "errors:" );
2686 System.out.println( xml_parser.getErrorMessages().toString() );
2689 if ( phylogenies_2.length != 1 ) {
2692 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2695 final Phylogeny[] phylogenies_3 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ),
2697 if ( xml_parser.getErrorCount() > 0 ) {
2698 System.out.println( xml_parser.getErrorMessages().toString() );
2701 if ( phylogenies_3.length != 2 ) {
2704 final Phylogeny a = phylogenies_3[ 0 ];
2705 if ( !a.getName().equals( "tree 4" ) ) {
2708 if ( a.getNumberOfExternalNodes() != 3 ) {
2711 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2714 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2717 final Phylogeny[] phylogenies_4 = factory.create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml") ,
2719 if ( xml_parser.getErrorCount() > 0 ) {
2720 System.out.println( xml_parser.getErrorMessages().toString() );
2723 if ( phylogenies_4.length != 1 ) {
2726 final Phylogeny s = phylogenies_4[ 0 ];
2727 if ( s.getNumberOfExternalNodes() != 6 ) {
2730 s.getNode( "first" );
2732 s.getNode( "\"<a'b&c'd\">\"" );
2733 s.getNode( "'''\"" );
2734 s.getNode( "\"\"\"" );
2735 s.getNode( "dick & doof" );
2737 catch ( final Exception e ) {
2738 e.printStackTrace( System.out );
2744 private static boolean testBasicProtein() {
2746 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2747 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2748 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2749 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2750 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2751 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2752 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2753 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2754 p0.addProteinDomain( y );
2755 p0.addProteinDomain( e );
2756 p0.addProteinDomain( b );
2757 p0.addProteinDomain( c );
2758 p0.addProteinDomain( d );
2759 p0.addProteinDomain( a );
2760 p0.addProteinDomain( x );
2761 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2764 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2768 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2769 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2770 aa0.addProteinDomain( a1 );
2771 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2774 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2778 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2779 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2780 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2781 aa1.addProteinDomain( a11 );
2782 aa1.addProteinDomain( a12 );
2783 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2786 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2789 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2790 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2793 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2796 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2799 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2800 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2803 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2806 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2809 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2812 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2813 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2816 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2819 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2822 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2825 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2826 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2829 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2832 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2835 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2839 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2840 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2841 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2842 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2843 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2844 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2845 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2846 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2847 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2848 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2849 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2850 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2851 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2852 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2853 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2854 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2855 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2856 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2857 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2858 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2859 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2860 p00.addProteinDomain( y0 );
2861 p00.addProteinDomain( e0 );
2862 p00.addProteinDomain( b0 );
2863 p00.addProteinDomain( c0 );
2864 p00.addProteinDomain( d0 );
2865 p00.addProteinDomain( a0 );
2866 p00.addProteinDomain( x0 );
2867 p00.addProteinDomain( y1 );
2868 p00.addProteinDomain( y2 );
2869 p00.addProteinDomain( y3 );
2870 p00.addProteinDomain( e1 );
2871 p00.addProteinDomain( e2 );
2872 p00.addProteinDomain( e3 );
2873 p00.addProteinDomain( e4 );
2874 p00.addProteinDomain( e5 );
2875 p00.addProteinDomain( z0 );
2876 p00.addProteinDomain( z1 );
2877 p00.addProteinDomain( z2 );
2878 p00.addProteinDomain( zz0 );
2879 p00.addProteinDomain( zz1 );
2880 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2883 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2886 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2889 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2892 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" ) ) {
2895 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2896 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2897 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2898 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2899 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2900 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2901 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2902 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2903 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2904 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2905 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2906 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2907 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2908 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2909 p.addProteinDomain( B15 );
2910 p.addProteinDomain( C50 );
2911 p.addProteinDomain( A60 );
2912 p.addProteinDomain( A30 );
2913 p.addProteinDomain( C70 );
2914 p.addProteinDomain( B35 );
2915 p.addProteinDomain( B40 );
2916 p.addProteinDomain( A0 );
2917 p.addProteinDomain( A10 );
2918 p.addProteinDomain( A20 );
2919 p.addProteinDomain( B25 );
2920 p.addProteinDomain( D80 );
2921 List<String> domains_ids = new ArrayList<String>();
2922 domains_ids.add( "A" );
2923 domains_ids.add( "B" );
2924 domains_ids.add( "C" );
2925 if ( !p.contains( domains_ids, false ) ) {
2928 if ( !p.contains( domains_ids, true ) ) {
2931 domains_ids.add( "X" );
2932 if ( p.contains( domains_ids, false ) ) {
2935 if ( p.contains( domains_ids, true ) ) {
2938 domains_ids = new ArrayList<String>();
2939 domains_ids.add( "A" );
2940 domains_ids.add( "C" );
2941 domains_ids.add( "D" );
2942 if ( !p.contains( domains_ids, false ) ) {
2945 if ( !p.contains( domains_ids, true ) ) {
2948 domains_ids = new ArrayList<String>();
2949 domains_ids.add( "A" );
2950 domains_ids.add( "D" );
2951 domains_ids.add( "C" );
2952 if ( !p.contains( domains_ids, false ) ) {
2955 if ( p.contains( domains_ids, true ) ) {
2958 domains_ids = new ArrayList<String>();
2959 domains_ids.add( "A" );
2960 domains_ids.add( "A" );
2961 domains_ids.add( "B" );
2962 if ( !p.contains( domains_ids, false ) ) {
2965 if ( !p.contains( domains_ids, true ) ) {
2968 domains_ids = new ArrayList<String>();
2969 domains_ids.add( "A" );
2970 domains_ids.add( "A" );
2971 domains_ids.add( "A" );
2972 domains_ids.add( "B" );
2973 domains_ids.add( "B" );
2974 if ( !p.contains( domains_ids, false ) ) {
2977 if ( !p.contains( domains_ids, true ) ) {
2980 domains_ids = new ArrayList<String>();
2981 domains_ids.add( "A" );
2982 domains_ids.add( "A" );
2983 domains_ids.add( "B" );
2984 domains_ids.add( "A" );
2985 domains_ids.add( "B" );
2986 domains_ids.add( "B" );
2987 domains_ids.add( "A" );
2988 domains_ids.add( "B" );
2989 domains_ids.add( "C" );
2990 domains_ids.add( "A" );
2991 domains_ids.add( "C" );
2992 domains_ids.add( "D" );
2993 if ( !p.contains( domains_ids, false ) ) {
2996 if ( p.contains( domains_ids, true ) ) {
3000 catch ( final Exception e ) {
3001 e.printStackTrace( System.out );
3007 private static boolean testBasicTable() {
3009 final BasicTable<String> t0 = new BasicTable<String>();
3010 if ( t0.getNumberOfColumns() != 0 ) {
3013 if ( t0.getNumberOfRows() != 0 ) {
3016 t0.setValue( 3, 2, "23" );
3017 t0.setValue( 10, 1, "error" );
3018 t0.setValue( 10, 1, "110" );
3019 t0.setValue( 9, 1, "19" );
3020 t0.setValue( 1, 10, "101" );
3021 t0.setValue( 10, 10, "1010" );
3022 t0.setValue( 100, 10, "10100" );
3023 t0.setValue( 0, 0, "00" );
3024 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3027 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3030 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3033 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3036 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3039 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3042 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3045 if ( t0.getNumberOfColumns() != 101 ) {
3048 if ( t0.getNumberOfRows() != 11 ) {
3051 if ( t0.getValueAsString( 49, 4 ) != null ) {
3054 final String l = ForesterUtil.getLineSeparator();
3055 final StringBuffer source = new StringBuffer();
3056 source.append( "" + l );
3057 source.append( "# 1 1 1 1 1 1 1 1" + l );
3058 source.append( " 00 01 02 03" + l );
3059 source.append( " 10 11 12 13 " + l );
3060 source.append( "20 21 22 23 " + l );
3061 source.append( " 30 31 32 33" + l );
3062 source.append( "40 41 42 43" + l );
3063 source.append( " # 1 1 1 1 1 " + l );
3064 source.append( "50 51 52 53 54" + l );
3065 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3066 if ( t1.getNumberOfColumns() != 5 ) {
3069 if ( t1.getNumberOfRows() != 6 ) {
3072 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3075 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3078 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3081 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3084 final StringBuffer source1 = new StringBuffer();
3085 source1.append( "" + l );
3086 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3087 source1.append( " 00; 01 ;02;03" + l );
3088 source1.append( " 10; 11; 12; 13 " + l );
3089 source1.append( "20; 21; 22; 23 " + l );
3090 source1.append( " 30; 31; 32; 33" + l );
3091 source1.append( "40;41;42;43" + l );
3092 source1.append( " # 1 1 1 1 1 " + l );
3093 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3094 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3095 if ( t2.getNumberOfColumns() != 5 ) {
3098 if ( t2.getNumberOfRows() != 6 ) {
3101 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3104 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3107 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3110 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3113 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3116 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3119 final StringBuffer source2 = new StringBuffer();
3120 source2.append( "" + l );
3121 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3122 source2.append( " 00; 01 ;02;03" + l );
3123 source2.append( " 10; 11; 12; 13 " + l );
3124 source2.append( "20; 21; 22; 23 " + l );
3125 source2.append( " " + l );
3126 source2.append( " 30; 31; 32; 33" + l );
3127 source2.append( "40;41;42;43" + l );
3128 source2.append( " comment: 1 1 1 1 1 " + l );
3129 source2.append( ";;;50 ; 52; 53;;54 " + l );
3130 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3136 if ( tl.size() != 2 ) {
3139 final BasicTable<String> t3 = tl.get( 0 );
3140 final BasicTable<String> t4 = tl.get( 1 );
3141 if ( t3.getNumberOfColumns() != 4 ) {
3144 if ( t3.getNumberOfRows() != 3 ) {
3147 if ( t4.getNumberOfColumns() != 4 ) {
3150 if ( t4.getNumberOfRows() != 3 ) {
3153 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3156 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3160 catch ( final Exception e ) {
3161 e.printStackTrace( System.out );
3167 private static boolean testBasicTolXMLparsing() {
3169 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3170 final TolParser parser = new TolParser();
3171 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3172 if ( parser.getErrorCount() > 0 ) {
3173 System.out.println( parser.getErrorMessages().toString() );
3176 if ( phylogenies_0.length != 1 ) {
3179 final Phylogeny t1 = phylogenies_0[ 0 ];
3180 if ( t1.getNumberOfExternalNodes() != 5 ) {
3183 if ( !t1.isRooted() ) {
3186 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3189 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3192 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
3195 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3198 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3199 if ( parser.getErrorCount() > 0 ) {
3200 System.out.println( parser.getErrorMessages().toString() );
3203 if ( phylogenies_1.length != 1 ) {
3206 final Phylogeny t2 = phylogenies_1[ 0 ];
3207 if ( t2.getNumberOfExternalNodes() != 664 ) {
3210 if ( !t2.isRooted() ) {
3213 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3216 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3219 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3222 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3225 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
3228 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3229 .equals( "Aquifex" ) ) {
3232 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3233 if ( parser.getErrorCount() > 0 ) {
3234 System.out.println( parser.getErrorMessages().toString() );
3237 if ( phylogenies_2.length != 1 ) {
3240 final Phylogeny t3 = phylogenies_2[ 0 ];
3241 if ( t3.getNumberOfExternalNodes() != 184 ) {
3244 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3247 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3250 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3253 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3254 if ( parser.getErrorCount() > 0 ) {
3255 System.out.println( parser.getErrorMessages().toString() );
3258 if ( phylogenies_3.length != 1 ) {
3261 final Phylogeny t4 = phylogenies_3[ 0 ];
3262 if ( t4.getNumberOfExternalNodes() != 1 ) {
3265 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3268 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3271 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3274 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3275 if ( parser.getErrorCount() > 0 ) {
3276 System.out.println( parser.getErrorMessages().toString() );
3279 if ( phylogenies_4.length != 1 ) {
3282 final Phylogeny t5 = phylogenies_4[ 0 ];
3283 if ( t5.getNumberOfExternalNodes() != 13 ) {
3286 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3289 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3292 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3296 catch ( final Exception e ) {
3297 e.printStackTrace( System.out );
3303 private static boolean testBasicTreeMethods() {
3305 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3306 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3307 if ( t2.getNumberOfExternalNodes() != 4 ) {
3310 if ( t2.getHeight() != 8.5 ) {
3313 if ( !t2.isCompletelyBinary() ) {
3316 if ( t2.isEmpty() ) {
3319 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3320 if ( t3.getNumberOfExternalNodes() != 5 ) {
3323 if ( t3.getHeight() != 11 ) {
3326 if ( t3.isCompletelyBinary() ) {
3329 final PhylogenyNode n = t3.getNode( "ABC" );
3330 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
3331 if ( t4.getNumberOfExternalNodes() != 9 ) {
3334 if ( t4.getHeight() != 11 ) {
3337 if ( t4.isCompletelyBinary() ) {
3340 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)" );
3341 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3342 if ( t5.getNumberOfExternalNodes() != 8 ) {
3345 if ( t5.getHeight() != 15 ) {
3348 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)" );
3349 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3350 if ( t6.getHeight() != 15 ) {
3353 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)" );
3354 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3355 if ( t7.getHeight() != 15 ) {
3358 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)" );
3359 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3360 if ( t8.getNumberOfExternalNodes() != 10 ) {
3363 if ( t8.getHeight() != 15 ) {
3366 final char[] a9 = new char[] { 'a' };
3367 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3368 if ( t9.getHeight() != 0 ) {
3371 final char[] a10 = new char[] { 'a', ':', '6' };
3372 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3373 if ( t10.getHeight() != 6 ) {
3377 catch ( final Exception e ) {
3378 e.printStackTrace( System.out );
3384 private static boolean testConfidenceAssessor() {
3386 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3387 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3388 final Phylogeny[] ev0 = factory
3389 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3391 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3392 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3395 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3398 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3399 final Phylogeny[] ev1 = factory
3400 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3402 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3403 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3406 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3409 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3410 final Phylogeny[] ev_b = factory
3411 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3413 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3414 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3417 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3421 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3422 final Phylogeny[] ev1x = factory
3423 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3425 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3426 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3429 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3432 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3433 final Phylogeny[] ev_bx = factory
3434 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3436 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3437 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3440 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3443 final Phylogeny[] t2 = factory
3444 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
3446 final Phylogeny[] ev2 = factory
3447 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
3449 for( final Phylogeny target : t2 ) {
3450 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3452 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3453 new NHXParser() )[ 0 ];
3454 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3455 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3456 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3459 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3462 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3466 catch ( final Exception e ) {
3467 e.printStackTrace();
3473 private static boolean testCopyOfNodeData() {
3475 final PhylogenyNode n1 = PhylogenyNode
3476 .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]" );
3477 final PhylogenyNode n2 = n1.copyNodeData();
3478 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3482 catch ( final Exception e ) {
3483 e.printStackTrace();
3489 private static boolean testCreateBalancedPhylogeny() {
3491 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3492 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3495 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3498 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3499 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3502 if ( p1.getNumberOfExternalNodes() != 100 ) {
3506 catch ( final Exception e ) {
3507 e.printStackTrace();
3513 private static boolean testCreateUriForSeqWeb() {
3515 final PhylogenyNode n = new PhylogenyNode();
3516 n.setName( "tr|B3RJ64" );
3517 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3520 n.setName( "B0LM41_HUMAN" );
3521 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3524 n.setName( "NP_001025424" );
3525 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3528 n.setName( "_NM_001030253-" );
3529 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3532 n.setName( "XM_002122186" );
3533 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3536 n.setName( "dgh_AAA34956_gdg" );
3537 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3540 n.setName( "AAA34956" );
3541 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3544 n.setName( "GI:394892" );
3545 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3546 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3549 n.setName( "gi_394892" );
3550 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3551 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3554 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3555 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3556 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3559 n.setName( "P12345" );
3560 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3561 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3564 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3565 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3566 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3570 catch ( final Exception e ) {
3571 e.printStackTrace( System.out );
3577 private static boolean testDataObjects() {
3579 final Confidence s0 = new Confidence();
3580 final Confidence s1 = new Confidence();
3581 if ( !s0.isEqual( s1 ) ) {
3584 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3585 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3586 if ( s2.isEqual( s1 ) ) {
3589 if ( !s2.isEqual( s3 ) ) {
3592 final Confidence s4 = ( Confidence ) s3.copy();
3593 if ( !s4.isEqual( s3 ) ) {
3600 final Taxonomy t1 = new Taxonomy();
3601 final Taxonomy t2 = new Taxonomy();
3602 final Taxonomy t3 = new Taxonomy();
3603 final Taxonomy t4 = new Taxonomy();
3604 final Taxonomy t5 = new Taxonomy();
3605 t1.setIdentifier( new Identifier( "ecoli" ) );
3606 t1.setTaxonomyCode( "ECOLI" );
3607 t1.setScientificName( "E. coli" );
3608 t1.setCommonName( "coli" );
3609 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3610 if ( !t1.isEqual( t0 ) ) {
3613 t2.setIdentifier( new Identifier( "ecoli" ) );
3614 t2.setTaxonomyCode( "OTHER" );
3615 t2.setScientificName( "what" );
3616 t2.setCommonName( "something" );
3617 if ( !t1.isEqual( t2 ) ) {
3620 t2.setIdentifier( new Identifier( "nemve" ) );
3621 if ( t1.isEqual( t2 ) ) {
3624 t1.setIdentifier( null );
3625 t3.setTaxonomyCode( "ECOLI" );
3626 t3.setScientificName( "what" );
3627 t3.setCommonName( "something" );
3628 if ( !t1.isEqual( t3 ) ) {
3631 t1.setIdentifier( null );
3632 t1.setTaxonomyCode( "" );
3633 t4.setScientificName( "E. ColI" );
3634 t4.setCommonName( "something" );
3635 if ( !t1.isEqual( t4 ) ) {
3638 t4.setScientificName( "B. subtilis" );
3639 t4.setCommonName( "something" );
3640 if ( t1.isEqual( t4 ) ) {
3643 t1.setIdentifier( null );
3644 t1.setTaxonomyCode( "" );
3645 t1.setScientificName( "" );
3646 t5.setCommonName( "COLI" );
3647 if ( !t1.isEqual( t5 ) ) {
3650 t5.setCommonName( "vibrio" );
3651 if ( t1.isEqual( t5 ) ) {
3656 final Identifier id0 = new Identifier( "123", "pfam" );
3657 final Identifier id1 = ( Identifier ) id0.copy();
3658 if ( !id1.isEqual( id1 ) ) {
3661 if ( !id1.isEqual( id0 ) ) {
3664 if ( !id0.isEqual( id1 ) ) {
3671 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3672 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3673 if ( !pd1.isEqual( pd1 ) ) {
3676 if ( !pd1.isEqual( pd0 ) ) {
3681 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3682 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3683 if ( !pd3.isEqual( pd3 ) ) {
3686 if ( !pd2.isEqual( pd3 ) ) {
3689 if ( !pd0.isEqual( pd3 ) ) {
3694 // DomainArchitecture
3695 // ------------------
3696 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3697 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3698 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3699 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3700 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3701 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3706 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3707 if ( ds0.getNumberOfDomains() != 4 ) {
3710 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3711 if ( !ds0.isEqual( ds0 ) ) {
3714 if ( !ds0.isEqual( ds1 ) ) {
3717 if ( ds1.getNumberOfDomains() != 4 ) {
3720 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3725 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3726 if ( ds0.isEqual( ds2 ) ) {
3732 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3733 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3734 System.out.println( ds3.toNHX() );
3737 if ( ds3.getNumberOfDomains() != 3 ) {
3742 final Event e1 = new Event( Event.EventType.fusion );
3743 if ( e1.isDuplication() ) {
3746 if ( !e1.isFusion() ) {
3749 if ( !e1.asText().toString().equals( "fusion" ) ) {
3752 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3755 final Event e11 = new Event( Event.EventType.fusion );
3756 if ( !e11.isEqual( e1 ) ) {
3759 if ( !e11.toNHX().toString().equals( "" ) ) {
3762 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3763 if ( e2.isDuplication() ) {
3766 if ( !e2.isSpeciationOrDuplication() ) {
3769 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3772 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3775 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3778 if ( e11.isEqual( e2 ) ) {
3781 final Event e2c = ( Event ) e2.copy();
3782 if ( !e2c.isEqual( e2 ) ) {
3785 Event e3 = new Event( 1, 2, 3 );
3786 if ( e3.isDuplication() ) {
3789 if ( e3.isSpeciation() ) {
3792 if ( e3.isGeneLoss() ) {
3795 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3798 final Event e3c = ( Event ) e3.copy();
3799 final Event e3cc = ( Event ) e3c.copy();
3800 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3804 if ( !e3c.isEqual( e3cc ) ) {
3807 Event e4 = new Event( 1, 2, 3 );
3808 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3811 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3814 final Event e4c = ( Event ) e4.copy();
3816 final Event e4cc = ( Event ) e4c.copy();
3817 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3820 if ( !e4c.isEqual( e4cc ) ) {
3823 final Event e5 = new Event();
3824 if ( !e5.isUnassigned() ) {
3827 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3830 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3833 final Event e6 = new Event( 1, 0, 0 );
3834 if ( !e6.asText().toString().equals( "duplication" ) ) {
3837 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3840 final Event e7 = new Event( 0, 1, 0 );
3841 if ( !e7.asText().toString().equals( "speciation" ) ) {
3844 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3847 final Event e8 = new Event( 0, 0, 1 );
3848 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3851 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3855 catch ( final Exception e ) {
3856 e.printStackTrace( System.out );
3862 private static boolean testDeletionOfExternalNodes() {
3864 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3865 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3866 final PhylogenyWriter w = new PhylogenyWriter();
3867 if ( t0.isEmpty() ) {
3870 if ( t0.getNumberOfExternalNodes() != 1 ) {
3873 t0.deleteSubtree( t0.getNode( "A" ), false );
3874 if ( t0.getNumberOfExternalNodes() != 0 ) {
3877 if ( !t0.isEmpty() ) {
3880 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3881 if ( t1.getNumberOfExternalNodes() != 2 ) {
3884 t1.deleteSubtree( t1.getNode( "A" ), false );
3885 if ( t1.getNumberOfExternalNodes() != 1 ) {
3888 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3891 t1.deleteSubtree( t1.getNode( "B" ), false );
3892 if ( t1.getNumberOfExternalNodes() != 1 ) {
3895 t1.deleteSubtree( t1.getNode( "r" ), false );
3896 if ( !t1.isEmpty() ) {
3899 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3900 if ( t2.getNumberOfExternalNodes() != 3 ) {
3903 t2.deleteSubtree( t2.getNode( "B" ), false );
3904 if ( t2.getNumberOfExternalNodes() != 2 ) {
3907 t2.toNewHampshireX();
3908 PhylogenyNode n = t2.getNode( "A" );
3909 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3912 t2.deleteSubtree( t2.getNode( "A" ), false );
3913 if ( t2.getNumberOfExternalNodes() != 2 ) {
3916 t2.deleteSubtree( t2.getNode( "C" ), true );
3917 if ( t2.getNumberOfExternalNodes() != 1 ) {
3920 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3921 if ( t3.getNumberOfExternalNodes() != 4 ) {
3924 t3.deleteSubtree( t3.getNode( "B" ), true );
3925 if ( t3.getNumberOfExternalNodes() != 3 ) {
3928 n = t3.getNode( "A" );
3929 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3932 n = n.getNextExternalNode();
3933 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3936 t3.deleteSubtree( t3.getNode( "A" ), true );
3937 if ( t3.getNumberOfExternalNodes() != 2 ) {
3940 n = t3.getNode( "C" );
3941 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3944 t3.deleteSubtree( t3.getNode( "C" ), true );
3945 if ( t3.getNumberOfExternalNodes() != 1 ) {
3948 t3.deleteSubtree( t3.getNode( "D" ), true );
3949 if ( t3.getNumberOfExternalNodes() != 0 ) {
3952 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3953 if ( t4.getNumberOfExternalNodes() != 6 ) {
3956 t4.deleteSubtree( t4.getNode( "B2" ), true );
3957 if ( t4.getNumberOfExternalNodes() != 5 ) {
3960 String s = w.toNewHampshire( t4, true ).toString();
3961 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3964 t4.deleteSubtree( t4.getNode( "B11" ), true );
3965 if ( t4.getNumberOfExternalNodes() != 4 ) {
3968 t4.deleteSubtree( t4.getNode( "C" ), true );
3969 if ( t4.getNumberOfExternalNodes() != 3 ) {
3972 n = t4.getNode( "A" );
3973 n = n.getNextExternalNode();
3974 if ( !n.getName().equals( "B12" ) ) {
3977 n = n.getNextExternalNode();
3978 if ( !n.getName().equals( "D" ) ) {
3981 s = w.toNewHampshire( t4, true ).toString();
3982 if ( !s.equals( "((A,B12),D);" ) ) {
3985 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3986 t5.deleteSubtree( t5.getNode( "A" ), true );
3987 if ( t5.getNumberOfExternalNodes() != 5 ) {
3990 s = w.toNewHampshire( t5, true ).toString();
3991 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3994 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3995 t6.deleteSubtree( t6.getNode( "B11" ), true );
3996 if ( t6.getNumberOfExternalNodes() != 5 ) {
3999 s = w.toNewHampshire( t6, false ).toString();
4000 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4003 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4004 t7.deleteSubtree( t7.getNode( "B12" ), true );
4005 if ( t7.getNumberOfExternalNodes() != 5 ) {
4008 s = w.toNewHampshire( t7, true ).toString();
4009 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4012 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4013 t8.deleteSubtree( t8.getNode( "B2" ), true );
4014 if ( t8.getNumberOfExternalNodes() != 5 ) {
4017 s = w.toNewHampshire( t8, false ).toString();
4018 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4021 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4022 t9.deleteSubtree( t9.getNode( "C" ), true );
4023 if ( t9.getNumberOfExternalNodes() != 5 ) {
4026 s = w.toNewHampshire( t9, true ).toString();
4027 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4030 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4031 t10.deleteSubtree( t10.getNode( "D" ), true );
4032 if ( t10.getNumberOfExternalNodes() != 5 ) {
4035 s = w.toNewHampshire( t10, true ).toString();
4036 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4039 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4040 t11.deleteSubtree( t11.getNode( "A" ), true );
4041 if ( t11.getNumberOfExternalNodes() != 2 ) {
4044 s = w.toNewHampshire( t11, true ).toString();
4045 if ( !s.equals( "(B,C);" ) ) {
4048 t11.deleteSubtree( t11.getNode( "C" ), true );
4049 if ( t11.getNumberOfExternalNodes() != 1 ) {
4052 s = w.toNewHampshire( t11, false ).toString();
4053 if ( !s.equals( "B;" ) ) {
4056 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4057 t12.deleteSubtree( t12.getNode( "B2" ), true );
4058 if ( t12.getNumberOfExternalNodes() != 8 ) {
4061 s = w.toNewHampshire( t12, true ).toString();
4062 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4065 t12.deleteSubtree( t12.getNode( "B3" ), true );
4066 if ( t12.getNumberOfExternalNodes() != 7 ) {
4069 s = w.toNewHampshire( t12, true ).toString();
4070 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4073 t12.deleteSubtree( t12.getNode( "C3" ), true );
4074 if ( t12.getNumberOfExternalNodes() != 6 ) {
4077 s = w.toNewHampshire( t12, true ).toString();
4078 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4081 t12.deleteSubtree( t12.getNode( "A1" ), true );
4082 if ( t12.getNumberOfExternalNodes() != 5 ) {
4085 s = w.toNewHampshire( t12, true ).toString();
4086 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4089 t12.deleteSubtree( t12.getNode( "B1" ), true );
4090 if ( t12.getNumberOfExternalNodes() != 4 ) {
4093 s = w.toNewHampshire( t12, true ).toString();
4094 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4097 t12.deleteSubtree( t12.getNode( "A3" ), true );
4098 if ( t12.getNumberOfExternalNodes() != 3 ) {
4101 s = w.toNewHampshire( t12, true ).toString();
4102 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4105 t12.deleteSubtree( t12.getNode( "A2" ), true );
4106 if ( t12.getNumberOfExternalNodes() != 2 ) {
4109 s = w.toNewHampshire( t12, true ).toString();
4110 if ( !s.equals( "(C1,C2);" ) ) {
4113 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4114 t13.deleteSubtree( t13.getNode( "D" ), true );
4115 if ( t13.getNumberOfExternalNodes() != 4 ) {
4118 s = w.toNewHampshire( t13, true ).toString();
4119 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4122 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4123 t14.deleteSubtree( t14.getNode( "E" ), true );
4124 if ( t14.getNumberOfExternalNodes() != 5 ) {
4127 s = w.toNewHampshire( t14, true ).toString();
4128 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4131 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4132 t15.deleteSubtree( t15.getNode( "B2" ), true );
4133 if ( t15.getNumberOfExternalNodes() != 11 ) {
4136 t15.deleteSubtree( t15.getNode( "B1" ), true );
4137 if ( t15.getNumberOfExternalNodes() != 10 ) {
4140 t15.deleteSubtree( t15.getNode( "B3" ), true );
4141 if ( t15.getNumberOfExternalNodes() != 9 ) {
4144 t15.deleteSubtree( t15.getNode( "B4" ), true );
4145 if ( t15.getNumberOfExternalNodes() != 8 ) {
4148 t15.deleteSubtree( t15.getNode( "A1" ), true );
4149 if ( t15.getNumberOfExternalNodes() != 7 ) {
4152 t15.deleteSubtree( t15.getNode( "C4" ), true );
4153 if ( t15.getNumberOfExternalNodes() != 6 ) {
4157 catch ( final Exception e ) {
4158 e.printStackTrace( System.out );
4164 private static boolean testDescriptiveStatistics() {
4166 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4167 dss1.addValue( 82 );
4168 dss1.addValue( 78 );
4169 dss1.addValue( 70 );
4170 dss1.addValue( 58 );
4171 dss1.addValue( 42 );
4172 if ( dss1.getN() != 5 ) {
4175 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4178 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4181 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4184 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4187 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4190 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4193 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4196 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4199 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4202 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4205 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4208 dss1.addValue( 123 );
4209 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4212 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4215 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4218 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4219 dss2.addValue( -1.85 );
4220 dss2.addValue( 57.5 );
4221 dss2.addValue( 92.78 );
4222 dss2.addValue( 57.78 );
4223 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4226 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4229 final double[] a = dss2.getDataAsDoubleArray();
4230 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4233 dss2.addValue( -100 );
4234 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4237 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4240 final double[] ds = new double[ 14 ];
4255 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4256 if ( bins.length != 4 ) {
4259 if ( bins[ 0 ] != 2 ) {
4262 if ( bins[ 1 ] != 3 ) {
4265 if ( bins[ 2 ] != 4 ) {
4268 if ( bins[ 3 ] != 5 ) {
4271 final double[] ds1 = new double[ 9 ];
4281 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4282 if ( bins1.length != 4 ) {
4285 if ( bins1[ 0 ] != 2 ) {
4288 if ( bins1[ 1 ] != 3 ) {
4291 if ( bins1[ 2 ] != 0 ) {
4294 if ( bins1[ 3 ] != 4 ) {
4297 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4298 if ( bins1_1.length != 3 ) {
4301 if ( bins1_1[ 0 ] != 3 ) {
4304 if ( bins1_1[ 1 ] != 2 ) {
4307 if ( bins1_1[ 2 ] != 4 ) {
4310 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4311 if ( bins1_2.length != 3 ) {
4314 if ( bins1_2[ 0 ] != 2 ) {
4317 if ( bins1_2[ 1 ] != 2 ) {
4320 if ( bins1_2[ 2 ] != 2 ) {
4323 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4337 dss3.addValue( 10 );
4338 dss3.addValue( 10 );
4339 dss3.addValue( 10 );
4340 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4341 histo.toStringBuffer( 10, '=', 40, 5 );
4342 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4344 catch ( final Exception e ) {
4345 e.printStackTrace( System.out );
4351 private static boolean testDir( final String file ) {
4353 final File f = new File( file );
4354 if ( !f.exists() ) {
4357 if ( !f.isDirectory() ) {
4360 if ( !f.canRead() ) {
4364 catch ( final Exception e ) {
4370 private static boolean testEbiEntryRetrieval() {
4372 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4373 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4374 System.out.println( entry.getAccession() );
4377 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4378 System.out.println( entry.getTaxonomyScientificName() );
4381 if ( !entry.getSequenceName()
4382 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4383 System.out.println( entry.getSequenceName() );
4386 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4387 System.out.println( entry.getGeneName() );
4390 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4391 System.out.println( entry.getTaxonomyIdentifier() );
4394 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4395 System.out.println( entry.getAnnotations().first().getRefValue() );
4398 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4399 System.out.println( entry.getAnnotations().first().getRefSource() );
4402 if ( entry.getCrossReferences().size() < 1 ) {
4405 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4406 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4409 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4410 System.out.println( entry1.getTaxonomyScientificName() );
4413 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4414 System.out.println( entry1.getSequenceName() );
4417 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4418 System.out.println( entry1.getTaxonomyIdentifier() );
4421 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4422 System.out.println( entry1.getGeneName() );
4425 if ( entry1.getCrossReferences().size() < 1 ) {
4428 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4429 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4432 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4433 System.out.println( entry2.getTaxonomyScientificName() );
4436 if ( !entry2.getSequenceName()
4437 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4438 System.out.println( entry2.getSequenceName() );
4441 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4442 System.out.println( entry2.getTaxonomyIdentifier() );
4445 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4446 System.out.println( entry2.getGeneName() );
4449 if ( entry2.getCrossReferences().size() < 1 ) {
4452 if ( !entry2.getChromosome().equals( "20" ) ) {
4455 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4458 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4459 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4462 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4463 System.out.println( entry3.getTaxonomyScientificName() );
4466 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4467 System.out.println( entry3.getSequenceName() );
4470 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4471 System.out.println( entry3.getTaxonomyIdentifier() );
4474 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4475 System.out.println( entry3.getSequenceSymbol() );
4478 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4481 if ( entry3.getCrossReferences().size() < 1 ) {
4484 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4485 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4488 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4489 System.out.println( entry4.getTaxonomyScientificName() );
4492 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4493 System.out.println( entry4.getSequenceName() );
4496 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4497 System.out.println( entry4.getTaxonomyIdentifier() );
4500 if ( !entry4.getGeneName().equals( "ras" ) ) {
4501 System.out.println( entry4.getGeneName() );
4504 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4505 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4508 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4509 System.out.println( entry5.getTaxonomyScientificName() );
4512 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4513 System.out.println( entry5.getSequenceName() );
4516 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4517 System.out.println( entry5.getTaxonomyIdentifier() );
4520 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4521 if ( !entry6.getAccession().equals( "M30539" ) ) {
4524 if ( !entry6.getGeneName().equals( "ras" ) ) {
4527 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4530 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4533 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4536 if ( entry6.getCrossReferences().size() < 1 ) {
4540 catch ( final IOException e ) {
4541 System.out.println();
4542 System.out.println( "the following might be due to absence internet connection:" );
4543 e.printStackTrace( System.out );
4546 catch ( final Exception e ) {
4547 e.printStackTrace();
4553 private static boolean testExternalNodeRelatedMethods() {
4555 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4556 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4557 PhylogenyNode n = t1.getNode( "A" );
4558 n = n.getNextExternalNode();
4559 if ( !n.getName().equals( "B" ) ) {
4562 n = n.getNextExternalNode();
4563 if ( !n.getName().equals( "C" ) ) {
4566 n = n.getNextExternalNode();
4567 if ( !n.getName().equals( "D" ) ) {
4570 n = t1.getNode( "B" );
4571 while ( !n.isLastExternalNode() ) {
4572 n = n.getNextExternalNode();
4574 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4575 n = t2.getNode( "A" );
4576 n = n.getNextExternalNode();
4577 if ( !n.getName().equals( "B" ) ) {
4580 n = n.getNextExternalNode();
4581 if ( !n.getName().equals( "C" ) ) {
4584 n = n.getNextExternalNode();
4585 if ( !n.getName().equals( "D" ) ) {
4588 n = t2.getNode( "B" );
4589 while ( !n.isLastExternalNode() ) {
4590 n = n.getNextExternalNode();
4592 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4593 n = t3.getNode( "A" );
4594 n = n.getNextExternalNode();
4595 if ( !n.getName().equals( "B" ) ) {
4598 n = n.getNextExternalNode();
4599 if ( !n.getName().equals( "C" ) ) {
4602 n = n.getNextExternalNode();
4603 if ( !n.getName().equals( "D" ) ) {
4606 n = n.getNextExternalNode();
4607 if ( !n.getName().equals( "E" ) ) {
4610 n = n.getNextExternalNode();
4611 if ( !n.getName().equals( "F" ) ) {
4614 n = n.getNextExternalNode();
4615 if ( !n.getName().equals( "G" ) ) {
4618 n = n.getNextExternalNode();
4619 if ( !n.getName().equals( "H" ) ) {
4622 n = t3.getNode( "B" );
4623 while ( !n.isLastExternalNode() ) {
4624 n = n.getNextExternalNode();
4626 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4627 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4628 final PhylogenyNode node = iter.next();
4630 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4631 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4632 final PhylogenyNode node = iter.next();
4634 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4635 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4636 if ( !iter.next().getName().equals( "A" ) ) {
4639 if ( !iter.next().getName().equals( "B" ) ) {
4642 if ( !iter.next().getName().equals( "C" ) ) {
4645 if ( !iter.next().getName().equals( "D" ) ) {
4648 if ( !iter.next().getName().equals( "E" ) ) {
4651 if ( !iter.next().getName().equals( "F" ) ) {
4654 if ( iter.hasNext() ) {
4658 catch ( final Exception e ) {
4659 e.printStackTrace( System.out );
4665 private static boolean testExtractSNFromNodeName() {
4667 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4670 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4673 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4676 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4677 .equals( "Mus musculus musculus" ) ) {
4680 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4681 .equals( "Mus musculus musculus" ) ) {
4684 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4685 .equals( "Mus musculus musculus" ) ) {
4688 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4689 .equals( "Mus musculus musculus" ) ) {
4692 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4695 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4696 .equals( "Mus musculus musculus" ) ) {
4699 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4700 .equals( "Mus musculus musculus" ) ) {
4703 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4706 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4709 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4712 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4715 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4716 .equals( "Mus musculus musculus" ) ) {
4719 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4722 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4725 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4728 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4731 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4734 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4737 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4740 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4743 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4744 .equals( "Mus musculus" ) ) {
4747 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4748 .equals( "Mus musculus" ) ) {
4751 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4754 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4755 .equals( "Mus musculus musculus" ) ) {
4758 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4759 .equals( "Mus musculus musculus" ) ) {
4762 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4763 .equals( "Mus musculus musculus" ) ) {
4766 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4769 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4770 .equals( "Pilostyles mexicana" ) ) {
4773 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4774 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4777 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4778 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4781 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4782 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4785 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4786 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4789 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4790 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4793 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4794 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4797 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4798 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4801 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4802 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4805 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4806 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4809 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4810 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4813 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4814 .equals( "Escherichia coli (strain K12)" ) ) {
4817 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4818 .equals( "Escherichia coli (strain K12)" ) ) {
4821 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4822 .equals( "Escherichia coli (str. K12)" ) ) {
4825 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4826 .equals( "Escherichia coli (str. K12)" ) ) {
4829 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4830 .equals( "Escherichia coli (str. K12)" ) ) {
4833 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4834 .equals( "Escherichia coli (var. K12)" ) ) {
4837 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4838 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4841 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4842 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4846 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4847 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4850 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4851 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4855 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4856 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4859 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4860 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4863 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4864 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4867 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4870 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4873 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4876 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4877 .equals( "Macrocera sp." ) ) {
4880 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4883 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4884 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4887 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4888 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4891 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4892 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4895 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4896 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4900 catch ( final Exception e ) {
4901 e.printStackTrace( System.out );
4907 private static boolean testExtractTaxonomyDataFromNodeName() {
4909 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4910 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4913 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4914 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4917 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4918 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4921 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4922 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4925 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4926 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4929 n = new PhylogenyNode( "HNRPR_HUMAN" );
4930 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4933 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
4934 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4938 catch ( final Exception e ) {
4939 e.printStackTrace( System.out );
4945 private static boolean testExtractTaxonomyCodeFromNodeName() {
4947 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4950 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4951 .equals( "SOYBN" ) ) {
4954 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4955 .equals( "ARATH" ) ) {
4958 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4959 .equals( "ARATH" ) ) {
4962 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4965 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4968 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4971 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4972 .equals( "SOYBN" ) ) {
4975 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4976 .equals( "SOYBN" ) ) {
4979 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4980 .equals( "SOYBN" ) ) {
4983 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4984 .equals( "SOYBN" ) ) {
4987 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4988 .equals( "SOYBN" ) ) {
4991 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4992 .equals( "SOYBN" ) ) {
4995 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4996 .equals( "SOYBN" ) ) {
4999 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5000 .equals( "SOYBN" ) ) {
5003 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5006 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5007 .equals( "SOYBN" ) ) {
5010 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
5011 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
5014 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5015 .equals( "9YX45" ) ) {
5018 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5019 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5020 .equals( "MOUSE" ) ) {
5023 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5024 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5025 .equals( "MOUSE" ) ) {
5028 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5029 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5030 .equals( "MOUSE" ) ) {
5033 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5034 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5037 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5038 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5041 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5042 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5045 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5046 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5049 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5050 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
5053 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5054 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5057 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5058 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5061 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5062 .equals( "RAT" ) ) {
5065 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5066 .equals( "PIG" ) ) {
5070 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5071 .equals( "MOUSE" ) ) {
5074 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5075 .equals( "MOUSE" ) ) {
5078 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5082 catch ( final Exception e ) {
5083 e.printStackTrace( System.out );
5089 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5091 PhylogenyNode n = new PhylogenyNode();
5092 n.setName( "tr|B3RJ64" );
5093 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5096 n.setName( "tr.B3RJ64" );
5097 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5100 n.setName( "tr=B3RJ64" );
5101 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5104 n.setName( "tr-B3RJ64" );
5105 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5108 n.setName( "tr/B3RJ64" );
5109 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5112 n.setName( "tr\\B3RJ64" );
5113 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5116 n.setName( "tr_B3RJ64" );
5117 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5120 n.setName( " tr|B3RJ64 " );
5121 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5124 n.setName( "-tr|B3RJ64-" );
5125 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5128 n.setName( "-tr=B3RJ64-" );
5129 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5132 n.setName( "_tr=B3RJ64_" );
5133 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5136 n.setName( " tr_tr|B3RJ64_sp|123 " );
5137 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5140 n.setName( "B3RJ64" );
5141 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5144 n.setName( "sp|B3RJ64" );
5145 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5148 n.setName( "sp|B3RJ64C" );
5149 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5152 n.setName( "sp B3RJ64" );
5153 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5156 n.setName( "sp|B3RJ6X" );
5157 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5160 n.setName( "sp|B3RJ6" );
5161 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5164 n.setName( "K1PYK7_CRAGI" );
5165 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5168 n.setName( "K1PYK7_PEA" );
5169 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5172 n.setName( "K1PYK7_RAT" );
5173 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5176 n.setName( "K1PYK7_PIG" );
5177 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5180 n.setName( "~K1PYK7_PIG~" );
5181 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5184 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5185 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5188 n.setName( "K1PYKX_CRAGI" );
5189 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5192 n.setName( "XXXXX_CRAGI" );
5193 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5196 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5197 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5200 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5201 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5204 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5205 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5208 n = new PhylogenyNode();
5209 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5210 seq.setSymbol( "K1PYK7_CRAGI" );
5211 n.getNodeData().addSequence( seq );
5212 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5215 seq.setSymbol( "tr|B3RJ64" );
5216 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5219 n = new PhylogenyNode();
5220 seq = new org.forester.phylogeny.data.Sequence();
5221 seq.setName( "K1PYK7_CRAGI" );
5222 n.getNodeData().addSequence( seq );
5223 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5226 seq.setName( "tr|B3RJ64" );
5227 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5230 n = new PhylogenyNode();
5231 seq = new org.forester.phylogeny.data.Sequence();
5232 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5233 n.getNodeData().addSequence( seq );
5234 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5237 n = new PhylogenyNode();
5238 seq = new org.forester.phylogeny.data.Sequence();
5239 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5240 n.getNodeData().addSequence( seq );
5241 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5245 n = new PhylogenyNode();
5246 n.setName( "ACP19736" );
5247 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5250 n = new PhylogenyNode();
5251 n.setName( "|ACP19736|" );
5252 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5256 catch ( final Exception e ) {
5257 e.printStackTrace( System.out );
5263 private static boolean testFastaParser() {
5265 FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5266 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5273 FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5274 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5281 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5282 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5285 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5288 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5291 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5294 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5297 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5301 catch ( final Exception e ) {
5302 e.printStackTrace();
5308 private static boolean testGenbankAccessorParsing() {
5309 //The format for GenBank Accession numbers are:
5310 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5311 //Protein: 3 letters + 5 numerals
5312 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5313 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5316 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5319 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
5322 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5325 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5328 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5331 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5334 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5337 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5340 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5343 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5346 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5349 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5352 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5358 private static boolean testGeneralMsaParser() {
5360 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5361 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5362 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5363 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5364 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5365 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5366 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5367 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5368 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5371 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5374 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5377 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5380 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5383 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5386 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5389 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5392 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5395 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5398 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5401 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5404 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5405 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5408 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5411 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5414 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5415 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5418 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5421 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5424 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5425 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5428 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5431 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5435 catch ( final Exception e ) {
5436 e.printStackTrace();
5442 private static boolean testGeneralTable() {
5444 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5445 t0.setValue( 3, 2, "23" );
5446 t0.setValue( 10, 1, "error" );
5447 t0.setValue( 10, 1, "110" );
5448 t0.setValue( 9, 1, "19" );
5449 t0.setValue( 1, 10, "101" );
5450 t0.setValue( 10, 10, "1010" );
5451 t0.setValue( 100, 10, "10100" );
5452 t0.setValue( 0, 0, "00" );
5453 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5456 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5459 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5462 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5465 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5468 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5471 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5474 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5477 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5480 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5481 t1.setValue( "3", "2", "23" );
5482 t1.setValue( "10", "1", "error" );
5483 t1.setValue( "10", "1", "110" );
5484 t1.setValue( "9", "1", "19" );
5485 t1.setValue( "1", "10", "101" );
5486 t1.setValue( "10", "10", "1010" );
5487 t1.setValue( "100", "10", "10100" );
5488 t1.setValue( "0", "0", "00" );
5489 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5490 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5493 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5496 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5499 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5502 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5505 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5508 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5511 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5514 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5517 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5521 catch ( final Exception e ) {
5522 e.printStackTrace( System.out );
5528 private static boolean testGetDistance() {
5530 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5531 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",
5532 new NHXParser() )[ 0 ];
5533 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5536 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5539 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5542 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5545 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5548 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5551 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5554 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5557 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5560 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5563 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5566 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5569 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5572 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5575 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5578 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5581 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5584 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5587 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5590 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5593 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5596 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5599 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5602 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5605 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5608 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5611 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5614 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5617 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5620 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5623 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5626 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",
5627 new NHXParser() )[ 0 ];
5628 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5631 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5634 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5637 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5640 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5643 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5646 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5649 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5652 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5655 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5658 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5662 catch ( final Exception e ) {
5663 e.printStackTrace( System.out );
5669 private static boolean testGetLCA() {
5671 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5672 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5673 new NHXParser() )[ 0 ];
5674 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5675 if ( !A.getName().equals( "A" ) ) {
5678 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5679 if ( !gh.getName().equals( "gh" ) ) {
5682 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5683 if ( !ab.getName().equals( "ab" ) ) {
5686 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5687 if ( !ab2.getName().equals( "ab" ) ) {
5690 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5691 if ( !gh2.getName().equals( "gh" ) ) {
5694 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5695 if ( !gh3.getName().equals( "gh" ) ) {
5698 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5699 if ( !abc.getName().equals( "abc" ) ) {
5702 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5703 if ( !abc2.getName().equals( "abc" ) ) {
5706 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5707 if ( !abcd.getName().equals( "abcd" ) ) {
5710 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5711 if ( !abcd2.getName().equals( "abcd" ) ) {
5714 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5715 if ( !abcdef.getName().equals( "abcdef" ) ) {
5718 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5719 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5722 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5723 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5726 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5727 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5730 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5731 if ( !abcde.getName().equals( "abcde" ) ) {
5734 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5735 if ( !abcde2.getName().equals( "abcde" ) ) {
5738 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5739 if ( !r.getName().equals( "abcdefgh" ) ) {
5742 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5743 if ( !r2.getName().equals( "abcdefgh" ) ) {
5746 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5747 if ( !r3.getName().equals( "abcdefgh" ) ) {
5750 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5751 if ( !abcde3.getName().equals( "abcde" ) ) {
5754 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5755 if ( !abcde4.getName().equals( "abcde" ) ) {
5758 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5759 if ( !ab3.getName().equals( "ab" ) ) {
5762 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5763 if ( !ab4.getName().equals( "ab" ) ) {
5766 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5767 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5768 if ( !cd.getName().equals( "cd" ) ) {
5771 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5772 if ( !cd2.getName().equals( "cd" ) ) {
5775 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5776 if ( !cde.getName().equals( "cde" ) ) {
5779 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5780 if ( !cde2.getName().equals( "cde" ) ) {
5783 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5784 if ( !cdef.getName().equals( "cdef" ) ) {
5787 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5788 if ( !cdef2.getName().equals( "cdef" ) ) {
5791 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5792 if ( !cdef3.getName().equals( "cdef" ) ) {
5795 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5796 if ( !rt.getName().equals( "r" ) ) {
5799 final Phylogeny p3 = factory
5800 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5801 new NHXParser() )[ 0 ];
5802 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5803 if ( !bc_3.getName().equals( "bc" ) ) {
5806 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5807 if ( !ac_3.getName().equals( "abc" ) ) {
5810 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5811 if ( !ad_3.getName().equals( "abcde" ) ) {
5814 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5815 if ( !af_3.getName().equals( "abcdef" ) ) {
5818 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5819 if ( !ag_3.getName().equals( "" ) ) {
5822 if ( !ag_3.isRoot() ) {
5825 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5826 if ( !al_3.getName().equals( "" ) ) {
5829 if ( !al_3.isRoot() ) {
5832 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5833 if ( !kl_3.getName().equals( "" ) ) {
5836 if ( !kl_3.isRoot() ) {
5839 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5840 if ( !fl_3.getName().equals( "" ) ) {
5843 if ( !fl_3.isRoot() ) {
5846 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5847 if ( !gk_3.getName().equals( "ghijk" ) ) {
5850 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5851 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5852 if ( !r_4.getName().equals( "r" ) ) {
5855 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5856 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5857 if ( !r_5.getName().equals( "root" ) ) {
5860 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5861 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5862 if ( !r_6.getName().equals( "rot" ) ) {
5865 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5866 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5867 if ( !r_7.getName().equals( "rott" ) ) {
5871 catch ( final Exception e ) {
5872 e.printStackTrace( System.out );
5878 private static boolean testGetLCA2() {
5880 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5881 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5882 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5883 PhylogenyMethods.preOrderReId( p_a );
5884 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5885 p_a.getNode( "a" ) );
5886 if ( !p_a_1.getName().equals( "a" ) ) {
5889 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5890 PhylogenyMethods.preOrderReId( p_b );
5891 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5892 p_b.getNode( "a" ) );
5893 if ( !p_b_1.getName().equals( "b" ) ) {
5896 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5897 p_b.getNode( "b" ) );
5898 if ( !p_b_2.getName().equals( "b" ) ) {
5901 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5902 PhylogenyMethods.preOrderReId( p_c );
5903 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5904 p_c.getNode( "a" ) );
5905 if ( !p_c_1.getName().equals( "b" ) ) {
5908 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5909 p_c.getNode( "c" ) );
5910 if ( !p_c_2.getName().equals( "c" ) ) {
5911 System.out.println( p_c_2.getName() );
5915 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5916 p_c.getNode( "b" ) );
5917 if ( !p_c_3.getName().equals( "b" ) ) {
5920 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5921 p_c.getNode( "a" ) );
5922 if ( !p_c_4.getName().equals( "c" ) ) {
5925 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5926 new NHXParser() )[ 0 ];
5927 PhylogenyMethods.preOrderReId( p1 );
5928 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5929 p1.getNode( "A" ) );
5930 if ( !A.getName().equals( "A" ) ) {
5933 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5934 p1.getNode( "gh" ) );
5935 if ( !gh.getName().equals( "gh" ) ) {
5938 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5939 p1.getNode( "B" ) );
5940 if ( !ab.getName().equals( "ab" ) ) {
5943 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5944 p1.getNode( "A" ) );
5945 if ( !ab2.getName().equals( "ab" ) ) {
5948 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5949 p1.getNode( "G" ) );
5950 if ( !gh2.getName().equals( "gh" ) ) {
5953 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5954 p1.getNode( "H" ) );
5955 if ( !gh3.getName().equals( "gh" ) ) {
5958 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5959 p1.getNode( "A" ) );
5960 if ( !abc.getName().equals( "abc" ) ) {
5963 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5964 p1.getNode( "C" ) );
5965 if ( !abc2.getName().equals( "abc" ) ) {
5968 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5969 p1.getNode( "D" ) );
5970 if ( !abcd.getName().equals( "abcd" ) ) {
5973 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5974 p1.getNode( "A" ) );
5975 if ( !abcd2.getName().equals( "abcd" ) ) {
5978 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5979 p1.getNode( "F" ) );
5980 if ( !abcdef.getName().equals( "abcdef" ) ) {
5983 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5984 p1.getNode( "A" ) );
5985 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5988 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5989 p1.getNode( "F" ) );
5990 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5993 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5994 p1.getNode( "ab" ) );
5995 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5998 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5999 p1.getNode( "E" ) );
6000 if ( !abcde.getName().equals( "abcde" ) ) {
6003 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6004 p1.getNode( "A" ) );
6005 if ( !abcde2.getName().equals( "abcde" ) ) {
6008 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6009 p1.getNode( "abcdefgh" ) );
6010 if ( !r.getName().equals( "abcdefgh" ) ) {
6013 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6014 p1.getNode( "H" ) );
6015 if ( !r2.getName().equals( "abcdefgh" ) ) {
6018 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6019 p1.getNode( "A" ) );
6020 if ( !r3.getName().equals( "abcdefgh" ) ) {
6023 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6024 p1.getNode( "abcde" ) );
6025 if ( !abcde3.getName().equals( "abcde" ) ) {
6028 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6029 p1.getNode( "E" ) );
6030 if ( !abcde4.getName().equals( "abcde" ) ) {
6033 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6034 p1.getNode( "B" ) );
6035 if ( !ab3.getName().equals( "ab" ) ) {
6038 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6039 p1.getNode( "ab" ) );
6040 if ( !ab4.getName().equals( "ab" ) ) {
6043 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6044 PhylogenyMethods.preOrderReId( p2 );
6045 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6046 p2.getNode( "d" ) );
6047 if ( !cd.getName().equals( "cd" ) ) {
6050 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6051 p2.getNode( "c" ) );
6052 if ( !cd2.getName().equals( "cd" ) ) {
6055 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6056 p2.getNode( "e" ) );
6057 if ( !cde.getName().equals( "cde" ) ) {
6060 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6061 p2.getNode( "c" ) );
6062 if ( !cde2.getName().equals( "cde" ) ) {
6065 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6066 p2.getNode( "f" ) );
6067 if ( !cdef.getName().equals( "cdef" ) ) {
6070 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6071 p2.getNode( "f" ) );
6072 if ( !cdef2.getName().equals( "cdef" ) ) {
6075 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6076 p2.getNode( "d" ) );
6077 if ( !cdef3.getName().equals( "cdef" ) ) {
6080 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6081 p2.getNode( "a" ) );
6082 if ( !rt.getName().equals( "r" ) ) {
6085 final Phylogeny p3 = factory
6086 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6087 new NHXParser() )[ 0 ];
6088 PhylogenyMethods.preOrderReId( p3 );
6089 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6090 p3.getNode( "c" ) );
6091 if ( !bc_3.getName().equals( "bc" ) ) {
6094 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6095 p3.getNode( "c" ) );
6096 if ( !ac_3.getName().equals( "abc" ) ) {
6099 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6100 p3.getNode( "d" ) );
6101 if ( !ad_3.getName().equals( "abcde" ) ) {
6104 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6105 p3.getNode( "f" ) );
6106 if ( !af_3.getName().equals( "abcdef" ) ) {
6109 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6110 p3.getNode( "g" ) );
6111 if ( !ag_3.getName().equals( "" ) ) {
6114 if ( !ag_3.isRoot() ) {
6117 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6118 p3.getNode( "l" ) );
6119 if ( !al_3.getName().equals( "" ) ) {
6122 if ( !al_3.isRoot() ) {
6125 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6126 p3.getNode( "l" ) );
6127 if ( !kl_3.getName().equals( "" ) ) {
6130 if ( !kl_3.isRoot() ) {
6133 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6134 p3.getNode( "l" ) );
6135 if ( !fl_3.getName().equals( "" ) ) {
6138 if ( !fl_3.isRoot() ) {
6141 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6142 p3.getNode( "k" ) );
6143 if ( !gk_3.getName().equals( "ghijk" ) ) {
6146 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6147 PhylogenyMethods.preOrderReId( p4 );
6148 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6149 p4.getNode( "c" ) );
6150 if ( !r_4.getName().equals( "r" ) ) {
6153 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6154 PhylogenyMethods.preOrderReId( p5 );
6155 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6156 p5.getNode( "c" ) );
6157 if ( !r_5.getName().equals( "root" ) ) {
6160 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6161 PhylogenyMethods.preOrderReId( p6 );
6162 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6163 p6.getNode( "a" ) );
6164 if ( !r_6.getName().equals( "rot" ) ) {
6167 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6168 PhylogenyMethods.preOrderReId( p7 );
6169 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6170 p7.getNode( "e" ) );
6171 if ( !r_7.getName().equals( "rott" ) ) {
6174 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6175 p7.getNode( "a" ) );
6176 if ( !r_71.getName().equals( "rott" ) ) {
6179 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6180 p7.getNode( "rott" ) );
6181 if ( !r_72.getName().equals( "rott" ) ) {
6184 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6185 p7.getNode( "a" ) );
6186 if ( !r_73.getName().equals( "rott" ) ) {
6189 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6190 p7.getNode( "rott" ) );
6191 if ( !r_74.getName().equals( "rott" ) ) {
6194 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6195 p7.getNode( "e" ) );
6196 if ( !r_75.getName().equals( "e" ) ) {
6200 catch ( final Exception e ) {
6201 e.printStackTrace( System.out );
6207 private static boolean testHmmscanOutputParser() {
6208 final String test_dir = Test.PATH_TO_TEST_DATA;
6210 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6211 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6213 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6214 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
6215 final List<Protein> proteins = parser2.parse();
6216 if ( parser2.getProteinsEncountered() != 4 ) {
6219 if ( proteins.size() != 4 ) {
6222 if ( parser2.getDomainsEncountered() != 69 ) {
6225 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6228 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6231 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6234 final Protein p1 = proteins.get( 0 );
6235 if ( p1.getNumberOfProteinDomains() != 15 ) {
6238 if ( p1.getLength() != 850 ) {
6241 final Protein p2 = proteins.get( 1 );
6242 if ( p2.getNumberOfProteinDomains() != 51 ) {
6245 if ( p2.getLength() != 1291 ) {
6248 final Protein p3 = proteins.get( 2 );
6249 if ( p3.getNumberOfProteinDomains() != 2 ) {
6252 final Protein p4 = proteins.get( 3 );
6253 if ( p4.getNumberOfProteinDomains() != 1 ) {
6256 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6259 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6262 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6265 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6268 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6271 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6274 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6278 catch ( final Exception e ) {
6279 e.printStackTrace( System.out );
6285 private static boolean testLastExternalNodeMethods() {
6287 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6288 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6289 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6290 final PhylogenyNode n1 = t0.getNode( "A" );
6291 if ( n1.isLastExternalNode() ) {
6294 final PhylogenyNode n2 = t0.getNode( "B" );
6295 if ( n2.isLastExternalNode() ) {
6298 final PhylogenyNode n3 = t0.getNode( "C" );
6299 if ( n3.isLastExternalNode() ) {
6302 final PhylogenyNode n4 = t0.getNode( "D" );
6303 if ( !n4.isLastExternalNode() ) {
6307 catch ( final Exception e ) {
6308 e.printStackTrace( System.out );
6314 private static boolean testLevelOrderIterator() {
6316 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6317 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6318 PhylogenyNodeIterator it0;
6319 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6322 for( it0.reset(); it0.hasNext(); ) {
6325 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6326 if ( !it.next().getName().equals( "r" ) ) {
6329 if ( !it.next().getName().equals( "ab" ) ) {
6332 if ( !it.next().getName().equals( "cd" ) ) {
6335 if ( !it.next().getName().equals( "A" ) ) {
6338 if ( !it.next().getName().equals( "B" ) ) {
6341 if ( !it.next().getName().equals( "C" ) ) {
6344 if ( !it.next().getName().equals( "D" ) ) {
6347 if ( it.hasNext() ) {
6350 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",
6351 new NHXParser() )[ 0 ];
6352 PhylogenyNodeIterator it2;
6353 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6356 for( it2.reset(); it2.hasNext(); ) {
6359 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6360 if ( !it3.next().getName().equals( "r" ) ) {
6363 if ( !it3.next().getName().equals( "abc" ) ) {
6366 if ( !it3.next().getName().equals( "defg" ) ) {
6369 if ( !it3.next().getName().equals( "A" ) ) {
6372 if ( !it3.next().getName().equals( "B" ) ) {
6375 if ( !it3.next().getName().equals( "C" ) ) {
6378 if ( !it3.next().getName().equals( "D" ) ) {
6381 if ( !it3.next().getName().equals( "E" ) ) {
6384 if ( !it3.next().getName().equals( "F" ) ) {
6387 if ( !it3.next().getName().equals( "G" ) ) {
6390 if ( !it3.next().getName().equals( "1" ) ) {
6393 if ( !it3.next().getName().equals( "2" ) ) {
6396 if ( !it3.next().getName().equals( "3" ) ) {
6399 if ( !it3.next().getName().equals( "4" ) ) {
6402 if ( !it3.next().getName().equals( "5" ) ) {
6405 if ( !it3.next().getName().equals( "6" ) ) {
6408 if ( !it3.next().getName().equals( "f1" ) ) {
6411 if ( !it3.next().getName().equals( "f2" ) ) {
6414 if ( !it3.next().getName().equals( "f3" ) ) {
6417 if ( !it3.next().getName().equals( "a" ) ) {
6420 if ( !it3.next().getName().equals( "b" ) ) {
6423 if ( !it3.next().getName().equals( "f21" ) ) {
6426 if ( !it3.next().getName().equals( "X" ) ) {
6429 if ( !it3.next().getName().equals( "Y" ) ) {
6432 if ( !it3.next().getName().equals( "Z" ) ) {
6435 if ( it3.hasNext() ) {
6438 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6439 PhylogenyNodeIterator it4;
6440 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6443 for( it4.reset(); it4.hasNext(); ) {
6446 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6447 if ( !it5.next().getName().equals( "r" ) ) {
6450 if ( !it5.next().getName().equals( "A" ) ) {
6453 if ( !it5.next().getName().equals( "B" ) ) {
6456 if ( !it5.next().getName().equals( "C" ) ) {
6459 if ( !it5.next().getName().equals( "D" ) ) {
6462 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6463 PhylogenyNodeIterator it6;
6464 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6467 for( it6.reset(); it6.hasNext(); ) {
6470 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6471 if ( !it7.next().getName().equals( "A" ) ) {
6474 if ( it.hasNext() ) {
6478 catch ( final Exception e ) {
6479 e.printStackTrace( System.out );
6485 private static boolean testMafft( final String path ) {
6487 final List<String> opts = new ArrayList<String>();
6488 opts.add( "--maxiterate" );
6490 opts.add( "--localpair" );
6491 opts.add( "--quiet" );
6493 final MsaInferrer mafft = Mafft.createInstance( path );
6494 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6495 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6498 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6502 catch ( final Exception e ) {
6503 e.printStackTrace( System.out );
6509 private static boolean testMidpointrooting() {
6511 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6512 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6513 PhylogenyMethods.midpointRoot( t0 );
6514 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6517 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6520 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6524 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",
6525 new NHXParser() )[ 0 ];
6526 if ( !t1.isRooted() ) {
6529 PhylogenyMethods.midpointRoot( t1 );
6530 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6533 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6536 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6539 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6542 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6545 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6548 t1.reRoot( t1.getNode( "A" ) );
6549 PhylogenyMethods.midpointRoot( t1 );
6550 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6553 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6556 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6559 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6562 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6566 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6570 catch ( final Exception e ) {
6571 e.printStackTrace( System.out );
6577 private static boolean testMsaQualityMethod() {
6579 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6580 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6581 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6582 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6583 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6588 final Msa msa = BasicMsa.createInstance( l );
6589 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6592 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6595 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6598 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6601 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6604 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6607 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6611 catch ( final Exception e ) {
6612 e.printStackTrace( System.out );
6618 private static boolean testMsaEntropy() {
6620 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6621 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6622 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6623 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6624 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6629 final Msa msa = BasicMsa.createInstance( l );
6630 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6632 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6633 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6634 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6635 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6636 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6637 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6638 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6639 // System.out.println();
6640 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6641 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6642 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6643 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6644 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6645 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6646 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6647 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6648 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6649 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6650 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6651 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6652 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6653 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6654 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6655 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6656 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6657 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6658 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6659 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6660 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6661 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6662 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6663 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6664 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6665 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6666 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6667 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6668 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6669 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6670 final Msa msa2 = BasicMsa.createInstance( l2 );
6671 // System.out.println();
6672 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6673 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6674 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6676 catch ( final Exception e ) {
6677 e.printStackTrace( System.out );
6683 private static boolean testDeleteableMsa() {
6685 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6686 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6687 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6688 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6689 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6690 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6691 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6698 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6699 dmsa0.deleteRow( "b", false );
6700 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6703 dmsa0.deleteRow( "e", false );
6704 dmsa0.deleteRow( "a", false );
6705 dmsa0.deleteRow( "f", false );
6706 if ( dmsa0.getLength() != 4 ) {
6709 if ( dmsa0.getNumberOfSequences() != 2 ) {
6712 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6715 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6718 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6721 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6724 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6727 dmsa0.deleteRow( "c", false );
6728 dmsa0.deleteRow( "d", false );
6729 if ( dmsa0.getNumberOfSequences() != 0 ) {
6733 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6734 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6735 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6736 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6737 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6738 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6739 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6746 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6747 dmsa1.deleteGapOnlyColumns();
6748 dmsa1.deleteRow( "a", false );
6749 dmsa1.deleteRow( "f", false );
6750 dmsa1.deleteRow( "d", false );
6751 dmsa1.deleteGapOnlyColumns();
6752 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6755 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6758 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6761 dmsa1.deleteRow( "c", false );
6762 dmsa1.deleteGapOnlyColumns();
6763 final Writer w0 = new StringWriter();
6764 dmsa1.write( w0, MSA_FORMAT.FASTA );
6765 final Writer w1 = new StringWriter();
6766 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6767 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6770 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6773 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6774 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6775 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6776 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6777 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6778 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6779 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6786 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6787 dmsa2.deleteGapColumns( 0.5 );
6788 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6791 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6794 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6797 dmsa2.deleteGapColumns( 0.2 );
6798 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6801 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6804 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6807 dmsa2.deleteGapColumns( 0 );
6808 dmsa2.deleteRow( "a", false );
6809 dmsa2.deleteRow( "b", false );
6810 dmsa2.deleteRow( "f", false );
6811 dmsa2.deleteRow( "e", false );
6812 dmsa2.setIdentifier( 0, "new_c" );
6813 dmsa2.setIdentifier( 1, "new_d" );
6814 dmsa2.setResidueAt( 0, 0, 'x' );
6815 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6816 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6819 final Writer w = new StringWriter();
6820 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6821 final String phylip = w.toString();
6822 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6823 System.out.println( phylip );
6826 final Writer w2 = new StringWriter();
6827 dmsa2.write( w2, MSA_FORMAT.FASTA );
6828 final String fasta = w2.toString();
6829 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6830 System.out.println( fasta );
6834 catch ( final Exception e ) {
6835 e.printStackTrace( System.out );
6841 private static boolean testNextNodeWithCollapsing() {
6843 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6845 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6846 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6847 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
6848 t0.getNode( "cd" ).setCollapse( true );
6849 t0.getNode( "cde" ).setCollapse( true );
6850 n = t0.getFirstExternalNode();
6851 while ( n != null ) {
6853 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6855 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6858 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6861 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6864 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6867 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6870 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6874 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6875 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
6876 t1.getNode( "ab" ).setCollapse( true );
6877 t1.getNode( "cd" ).setCollapse( true );
6878 t1.getNode( "cde" ).setCollapse( true );
6879 n = t1.getNode( "ab" );
6880 ext = new ArrayList<PhylogenyNode>();
6881 while ( n != null ) {
6883 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6885 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6888 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6891 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6894 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6897 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6901 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6902 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
6903 t2.getNode( "ab" ).setCollapse( true );
6904 t2.getNode( "cd" ).setCollapse( true );
6905 t2.getNode( "cde" ).setCollapse( true );
6906 t2.getNode( "c" ).setCollapse( true );
6907 t2.getNode( "d" ).setCollapse( true );
6908 t2.getNode( "e" ).setCollapse( true );
6909 t2.getNode( "gh" ).setCollapse( true );
6910 n = t2.getNode( "ab" );
6911 ext = new ArrayList<PhylogenyNode>();
6912 while ( n != null ) {
6914 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6916 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6919 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6922 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6925 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6929 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6930 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
6931 t3.getNode( "ab" ).setCollapse( true );
6932 t3.getNode( "cd" ).setCollapse( true );
6933 t3.getNode( "cde" ).setCollapse( true );
6934 t3.getNode( "c" ).setCollapse( true );
6935 t3.getNode( "d" ).setCollapse( true );
6936 t3.getNode( "e" ).setCollapse( true );
6937 t3.getNode( "gh" ).setCollapse( true );
6938 t3.getNode( "fgh" ).setCollapse( true );
6939 n = t3.getNode( "ab" );
6940 ext = new ArrayList<PhylogenyNode>();
6941 while ( n != null ) {
6943 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6945 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6948 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6951 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6955 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6956 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
6957 t4.getNode( "ab" ).setCollapse( true );
6958 t4.getNode( "cd" ).setCollapse( true );
6959 t4.getNode( "cde" ).setCollapse( true );
6960 t4.getNode( "c" ).setCollapse( true );
6961 t4.getNode( "d" ).setCollapse( true );
6962 t4.getNode( "e" ).setCollapse( true );
6963 t4.getNode( "gh" ).setCollapse( true );
6964 t4.getNode( "fgh" ).setCollapse( true );
6965 t4.getNode( "abcdefgh" ).setCollapse( true );
6966 n = t4.getNode( "abcdefgh" );
6967 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6970 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6971 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
6973 n = t5.getFirstExternalNode();
6974 while ( n != null ) {
6976 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6978 if ( ext.size() != 8 ) {
6981 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6984 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6987 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6990 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6993 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6996 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6999 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7002 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7005 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7006 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7008 t6.getNode( "ab" ).setCollapse( true );
7009 n = t6.getNode( "ab" );
7010 while ( n != null ) {
7012 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7014 if ( ext.size() != 7 ) {
7017 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7020 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7023 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7026 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7029 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7032 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7035 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7038 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7039 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7041 t7.getNode( "cd" ).setCollapse( true );
7042 n = t7.getNode( "a" );
7043 while ( n != null ) {
7045 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7047 if ( ext.size() != 7 ) {
7050 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7053 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7056 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7059 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7062 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7065 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7068 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7071 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7072 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7074 t8.getNode( "cd" ).setCollapse( true );
7075 t8.getNode( "c" ).setCollapse( true );
7076 t8.getNode( "d" ).setCollapse( true );
7077 n = t8.getNode( "a" );
7078 while ( n != null ) {
7080 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7082 if ( ext.size() != 7 ) {
7085 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7088 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7091 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7092 System.out.println( "2 fail" );
7095 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7098 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7101 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7104 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7107 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7108 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7110 t9.getNode( "gh" ).setCollapse( true );
7111 n = t9.getNode( "a" );
7112 while ( n != null ) {
7114 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7116 if ( ext.size() != 7 ) {
7119 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7122 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7125 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7128 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7131 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7134 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7137 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7140 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7141 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7143 t10.getNode( "gh" ).setCollapse( true );
7144 t10.getNode( "g" ).setCollapse( true );
7145 t10.getNode( "h" ).setCollapse( true );
7146 n = t10.getNode( "a" );
7147 while ( n != null ) {
7149 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7151 if ( ext.size() != 7 ) {
7154 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7157 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7160 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7163 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7166 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7169 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7172 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7175 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7176 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7178 t11.getNode( "gh" ).setCollapse( true );
7179 t11.getNode( "fgh" ).setCollapse( true );
7180 n = t11.getNode( "a" );
7181 while ( n != null ) {
7183 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7185 if ( ext.size() != 6 ) {
7188 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7191 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7194 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7197 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7200 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7203 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7206 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7207 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7209 t12.getNode( "gh" ).setCollapse( true );
7210 t12.getNode( "fgh" ).setCollapse( true );
7211 t12.getNode( "g" ).setCollapse( true );
7212 t12.getNode( "h" ).setCollapse( true );
7213 t12.getNode( "f" ).setCollapse( true );
7214 n = t12.getNode( "a" );
7215 while ( n != null ) {
7217 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7219 if ( ext.size() != 6 ) {
7222 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7225 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7228 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7231 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7234 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7237 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7240 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7241 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7243 t13.getNode( "ab" ).setCollapse( true );
7244 t13.getNode( "b" ).setCollapse( true );
7245 t13.getNode( "fgh" ).setCollapse( true );
7246 t13.getNode( "gh" ).setCollapse( true );
7247 n = t13.getNode( "ab" );
7248 while ( n != null ) {
7250 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7252 if ( ext.size() != 5 ) {
7255 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7258 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7261 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7264 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7267 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7270 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7271 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7273 t14.getNode( "ab" ).setCollapse( true );
7274 t14.getNode( "a" ).setCollapse( true );
7275 t14.getNode( "fgh" ).setCollapse( true );
7276 t14.getNode( "gh" ).setCollapse( true );
7277 n = t14.getNode( "ab" );
7278 while ( n != null ) {
7280 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7282 if ( ext.size() != 5 ) {
7285 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7288 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7291 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7294 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7297 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7300 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" );
7301 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7303 t15.getNode( "ab" ).setCollapse( true );
7304 t15.getNode( "a" ).setCollapse( true );
7305 t15.getNode( "fgh" ).setCollapse( true );
7306 t15.getNode( "gh" ).setCollapse( true );
7307 n = t15.getNode( "ab" );
7308 while ( n != null ) {
7310 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7312 if ( ext.size() != 6 ) {
7315 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7318 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7321 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7324 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7327 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7330 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7335 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" );
7336 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7338 t16.getNode( "ab" ).setCollapse( true );
7339 t16.getNode( "a" ).setCollapse( true );
7340 t16.getNode( "fgh" ).setCollapse( true );
7341 t16.getNode( "gh" ).setCollapse( true );
7342 t16.getNode( "cd" ).setCollapse( true );
7343 t16.getNode( "cde" ).setCollapse( true );
7344 t16.getNode( "d" ).setCollapse( true );
7345 t16.getNode( "x" ).setCollapse( true );
7346 n = t16.getNode( "ab" );
7347 while ( n != null ) {
7349 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7351 if ( ext.size() != 4 ) {
7354 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7357 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7360 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7363 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7367 catch ( final Exception e ) {
7368 e.printStackTrace( System.out );
7374 private static boolean testNexusCharactersParsing() {
7376 final NexusCharactersParser parser = new NexusCharactersParser();
7377 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7379 String[] labels = parser.getCharStateLabels();
7380 if ( labels.length != 7 ) {
7383 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7386 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7389 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7392 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7395 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7398 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7401 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7404 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7406 labels = parser.getCharStateLabels();
7407 if ( labels.length != 7 ) {
7410 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7413 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7416 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7419 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7422 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7425 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7428 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7432 catch ( final Exception e ) {
7433 e.printStackTrace( System.out );
7439 private static boolean testNexusMatrixParsing() {
7441 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7442 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7444 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7445 if ( m.getNumberOfCharacters() != 9 ) {
7448 if ( m.getNumberOfIdentifiers() != 5 ) {
7451 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7454 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7457 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7460 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7463 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7466 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7469 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
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 testNexusTreeParsing() {
7533 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7534 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7535 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7536 if ( phylogenies.length != 1 ) {
7539 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7542 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7546 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7547 if ( phylogenies.length != 1 ) {
7550 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7553 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7557 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7558 if ( phylogenies.length != 1 ) {
7561 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7564 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7567 if ( phylogenies[ 0 ].isRooted() ) {
7571 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7572 if ( phylogenies.length != 18 ) {
7575 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7578 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7581 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7584 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7587 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7590 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7593 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7596 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7599 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7602 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7605 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7608 if ( phylogenies[ 8 ].isRooted() ) {
7611 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7614 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7617 if ( !phylogenies[ 9 ].isRooted() ) {
7620 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7623 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7626 if ( !phylogenies[ 10 ].isRooted() ) {
7629 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7632 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7635 if ( phylogenies[ 11 ].isRooted() ) {
7638 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7641 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7644 if ( !phylogenies[ 12 ].isRooted() ) {
7647 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7650 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7653 if ( !phylogenies[ 13 ].isRooted() ) {
7656 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7659 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7662 if ( !phylogenies[ 14 ].isRooted() ) {
7665 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7668 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7671 if ( phylogenies[ 15 ].isRooted() ) {
7674 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7677 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7680 if ( !phylogenies[ 16 ].isRooted() ) {
7683 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7686 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7689 if ( phylogenies[ 17 ].isRooted() ) {
7692 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7695 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7697 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7698 if ( phylogenies.length != 9 ) {
7701 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7702 .getDistanceToParent() ) ) {
7705 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7706 .getDistanceToParent() ) ) {
7709 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7712 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7715 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7718 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7721 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7725 catch ( final Exception e ) {
7726 e.printStackTrace( System.out );
7732 private static boolean testNexusTreeParsingIterating() {
7734 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7735 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7736 if ( !p.hasNext() ) {
7739 Phylogeny phy = p.next();
7740 if ( phy == null ) {
7743 if ( phy.getNumberOfExternalNodes() != 25 ) {
7746 if ( !phy.getName().equals( "" ) ) {
7749 if ( p.hasNext() ) {
7753 if ( phy != null ) {
7757 if ( !p.hasNext() ) {
7761 if ( phy == null ) {
7764 if ( phy.getNumberOfExternalNodes() != 25 ) {
7767 if ( !phy.getName().equals( "" ) ) {
7770 if ( p.hasNext() ) {
7774 if ( phy != null ) {
7777 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7778 if ( !p.hasNext() ) {
7782 if ( phy == null ) {
7785 if ( phy.getNumberOfExternalNodes() != 10 ) {
7788 if ( !phy.getName().equals( "name" ) ) {
7791 if ( p.hasNext() ) {
7795 if ( phy != null ) {
7799 if ( !p.hasNext() ) {
7803 if ( phy == null ) {
7806 if ( phy.getNumberOfExternalNodes() != 10 ) {
7809 if ( !phy.getName().equals( "name" ) ) {
7812 if ( p.hasNext() ) {
7816 if ( phy != null ) {
7819 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7820 if ( !p.hasNext() ) {
7824 if ( phy == null ) {
7827 if ( phy.getNumberOfExternalNodes() != 3 ) {
7830 if ( !phy.getName().equals( "" ) ) {
7833 if ( phy.isRooted() ) {
7836 if ( p.hasNext() ) {
7840 if ( phy != null ) {
7845 if ( !p.hasNext() ) {
7849 if ( phy == null ) {
7852 if ( phy.getNumberOfExternalNodes() != 3 ) {
7855 if ( !phy.getName().equals( "" ) ) {
7858 if ( p.hasNext() ) {
7862 if ( phy != null ) {
7866 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7867 if ( !p.hasNext() ) {
7872 if ( phy == null ) {
7875 if ( phy.getNumberOfExternalNodes() != 10 ) {
7878 if ( !phy.getName().equals( "tree 0" ) ) {
7882 if ( !p.hasNext() ) {
7886 if ( phy == null ) {
7889 if ( phy.getNumberOfExternalNodes() != 10 ) {
7892 if ( !phy.getName().equals( "tree 1" ) ) {
7896 if ( !p.hasNext() ) {
7900 if ( phy == null ) {
7903 if ( phy.getNumberOfExternalNodes() != 3 ) {
7904 System.out.println( phy.toString() );
7907 if ( !phy.getName().equals( "" ) ) {
7910 if ( phy.isRooted() ) {
7914 if ( !p.hasNext() ) {
7918 if ( phy == null ) {
7921 if ( phy.getNumberOfExternalNodes() != 4 ) {
7924 if ( !phy.getName().equals( "" ) ) {
7927 if ( !phy.isRooted() ) {
7931 if ( !p.hasNext() ) {
7935 if ( phy == null ) {
7938 if ( phy.getNumberOfExternalNodes() != 5 ) {
7939 System.out.println( phy.getNumberOfExternalNodes() );
7942 if ( !phy.getName().equals( "" ) ) {
7945 if ( !phy.isRooted() ) {
7949 if ( !p.hasNext() ) {
7953 if ( phy == null ) {
7956 if ( phy.getNumberOfExternalNodes() != 3 ) {
7959 if ( !phy.getName().equals( "" ) ) {
7962 if ( phy.isRooted() ) {
7966 if ( !p.hasNext() ) {
7970 if ( phy == null ) {
7973 if ( phy.getNumberOfExternalNodes() != 2 ) {
7976 if ( !phy.getName().equals( "" ) ) {
7979 if ( !phy.isRooted() ) {
7983 if ( !p.hasNext() ) {
7987 if ( phy.getNumberOfExternalNodes() != 3 ) {
7990 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7993 if ( !phy.isRooted() ) {
7997 if ( !p.hasNext() ) {
8001 if ( phy.getNumberOfExternalNodes() != 3 ) {
8004 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8007 if ( !phy.getName().equals( "tree 8" ) ) {
8011 if ( !p.hasNext() ) {
8015 if ( phy.getNumberOfExternalNodes() != 3 ) {
8018 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8021 if ( !phy.getName().equals( "tree 9" ) ) {
8025 if ( !p.hasNext() ) {
8029 if ( phy.getNumberOfExternalNodes() != 3 ) {
8032 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8035 if ( !phy.getName().equals( "tree 10" ) ) {
8038 if ( !phy.isRooted() ) {
8042 if ( !p.hasNext() ) {
8046 if ( phy.getNumberOfExternalNodes() != 3 ) {
8049 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8052 if ( !phy.getName().equals( "tree 11" ) ) {
8055 if ( phy.isRooted() ) {
8059 if ( !p.hasNext() ) {
8063 if ( phy.getNumberOfExternalNodes() != 3 ) {
8066 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8069 if ( !phy.getName().equals( "tree 12" ) ) {
8072 if ( !phy.isRooted() ) {
8076 if ( !p.hasNext() ) {
8080 if ( phy.getNumberOfExternalNodes() != 3 ) {
8083 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8086 if ( !phy.getName().equals( "tree 13" ) ) {
8089 if ( !phy.isRooted() ) {
8093 if ( !p.hasNext() ) {
8097 if ( phy.getNumberOfExternalNodes() != 10 ) {
8098 System.out.println( phy.getNumberOfExternalNodes() );
8103 .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;" ) ) {
8104 System.out.println( phy.toNewHampshire() );
8107 if ( !phy.getName().equals( "tree 14" ) ) {
8110 if ( !phy.isRooted() ) {
8114 if ( !p.hasNext() ) {
8118 if ( phy.getNumberOfExternalNodes() != 10 ) {
8119 System.out.println( phy.getNumberOfExternalNodes() );
8124 .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;" ) ) {
8125 System.out.println( phy.toNewHampshire() );
8128 if ( !phy.getName().equals( "tree 15" ) ) {
8131 if ( phy.isRooted() ) {
8135 if ( !p.hasNext() ) {
8139 if ( phy.getNumberOfExternalNodes() != 10 ) {
8140 System.out.println( phy.getNumberOfExternalNodes() );
8145 .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;" ) ) {
8146 System.out.println( phy.toNewHampshire() );
8149 if ( !phy.getName().equals( "tree 16" ) ) {
8152 if ( !phy.isRooted() ) {
8156 if ( !p.hasNext() ) {
8160 if ( phy.getNumberOfExternalNodes() != 10 ) {
8161 System.out.println( phy.getNumberOfExternalNodes() );
8166 .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;" ) ) {
8167 System.out.println( phy.toNewHampshire() );
8170 if ( !phy.getName().equals( "tree 17" ) ) {
8173 if ( phy.isRooted() ) {
8177 if ( p.hasNext() ) {
8181 if ( phy != null ) {
8186 if ( !p.hasNext() ) {
8190 if ( phy == null ) {
8193 if ( phy.getNumberOfExternalNodes() != 10 ) {
8196 if ( !phy.getName().equals( "tree 0" ) ) {
8200 if ( !p.hasNext() ) {
8204 if ( phy == null ) {
8207 if ( phy.getNumberOfExternalNodes() != 10 ) {
8210 if ( !phy.getName().equals( "tree 1" ) ) {
8214 if ( !p.hasNext() ) {
8218 if ( phy == null ) {
8221 if ( phy.getNumberOfExternalNodes() != 3 ) {
8224 if ( !phy.getName().equals( "" ) ) {
8227 if ( phy.isRooted() ) {
8231 if ( !p.hasNext() ) {
8235 if ( phy == null ) {
8238 if ( phy.getNumberOfExternalNodes() != 4 ) {
8241 if ( !phy.getName().equals( "" ) ) {
8244 if ( !phy.isRooted() ) {
8248 if ( !p.hasNext() ) {
8252 if ( phy == null ) {
8255 if ( phy.getNumberOfExternalNodes() != 5 ) {
8256 System.out.println( phy.getNumberOfExternalNodes() );
8259 if ( !phy.getName().equals( "" ) ) {
8262 if ( !phy.isRooted() ) {
8266 if ( !p.hasNext() ) {
8270 if ( phy == null ) {
8273 if ( phy.getNumberOfExternalNodes() != 3 ) {
8276 if ( !phy.getName().equals( "" ) ) {
8279 if ( phy.isRooted() ) {
8283 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8284 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8286 if ( !p2.hasNext() ) {
8290 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8293 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8297 if ( !p2.hasNext() ) {
8302 if ( !p2.hasNext() ) {
8307 if ( !p2.hasNext() ) {
8312 if ( !p2.hasNext() ) {
8317 if ( !p2.hasNext() ) {
8322 if ( !p2.hasNext() ) {
8327 if ( !p2.hasNext() ) {
8332 if ( !p2.hasNext() ) {
8336 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8339 if ( p2.hasNext() ) {
8343 if ( phy != null ) {
8348 if ( !p2.hasNext() ) {
8352 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8355 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8359 catch ( final Exception e ) {
8360 e.printStackTrace( System.out );
8366 private static boolean testNexusTreeParsingTranslating() {
8368 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8369 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8370 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8371 if ( phylogenies.length != 1 ) {
8374 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8377 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8380 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8383 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8386 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8387 .equals( "Aranaeus" ) ) {
8391 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8392 if ( phylogenies.length != 3 ) {
8395 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8398 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8401 if ( phylogenies[ 0 ].isRooted() ) {
8404 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8407 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8410 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8411 .equals( "Aranaeus" ) ) {
8414 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8417 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8420 if ( phylogenies[ 1 ].isRooted() ) {
8423 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8426 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8429 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8430 .equals( "Aranaeus" ) ) {
8433 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8436 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8439 if ( !phylogenies[ 2 ].isRooted() ) {
8442 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8445 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8448 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8449 .equals( "Aranaeus" ) ) {
8453 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8454 if ( phylogenies.length != 3 ) {
8457 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8460 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8463 if ( phylogenies[ 0 ].isRooted() ) {
8466 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8469 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8472 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8473 .equals( "Aranaeus" ) ) {
8476 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8479 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8482 if ( phylogenies[ 1 ].isRooted() ) {
8485 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8488 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8491 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8492 .equals( "Aranaeus" ) ) {
8495 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8498 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8501 if ( !phylogenies[ 2 ].isRooted() ) {
8504 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8507 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8510 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8511 .equals( "Aranaeus" ) ) {
8514 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8515 if ( phylogenies.length != 3 ) {
8518 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8523 catch ( final Exception e ) {
8524 e.printStackTrace( System.out );
8530 private static boolean testNHParsing() {
8532 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8533 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8534 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8537 final NHXParser nhxp = new NHXParser();
8538 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8539 nhxp.setReplaceUnderscores( true );
8540 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8541 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8544 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8547 final Phylogeny p1b = factory
8548 .create( " \n \t \b \r \f ; ( \n \t \b \r \f; A ; \n \t \b \r \f, \n \t \b \r \f; B ; \n \t \b \r \f 1 \n \t \b \r \f ; \n \t \b \r \f );;;;; \n \t \b \r \f;;; \n \t \b \r \f ",
8549 new NHXParser() )[ 0 ];
8550 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8553 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8556 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8557 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8558 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8559 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8560 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8561 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8562 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8563 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8564 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8565 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8566 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8567 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8568 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8570 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8573 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8576 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8579 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8582 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8583 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8584 final String p16_S = "((A,B),C)";
8585 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8586 if ( p16.length != 1 ) {
8589 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8592 final String p17_S = "(C,(A,B))";
8593 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8594 if ( p17.length != 1 ) {
8597 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8600 final String p18_S = "((A,B),(C,D))";
8601 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8602 if ( p18.length != 1 ) {
8605 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8608 final String p19_S = "(((A,B),C),D)";
8609 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8610 if ( p19.length != 1 ) {
8613 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8616 final String p20_S = "(A,(B,(C,D)))";
8617 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8618 if ( p20.length != 1 ) {
8621 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8624 final String p21_S = "(A,(B,(C,(D,E))))";
8625 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8626 if ( p21.length != 1 ) {
8629 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8632 final String p22_S = "((((A,B),C),D),E)";
8633 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8634 if ( p22.length != 1 ) {
8637 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8640 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8641 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8642 if ( p23.length != 1 ) {
8643 System.out.println( "xl=" + p23.length );
8647 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8650 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8651 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8652 if ( p24.length != 1 ) {
8655 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8658 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8659 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8660 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8661 if ( p241.length != 2 ) {
8664 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8667 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8670 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8671 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8672 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8673 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8674 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8675 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8676 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8677 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8678 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8679 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8682 final String p26_S = "(A,B)ab";
8683 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8684 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8687 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8688 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8689 if ( p27s.length != 1 ) {
8690 System.out.println( "xxl=" + p27s.length );
8694 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8695 System.out.println( p27s[ 0 ].toNewHampshireX() );
8699 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8701 if ( p27.length != 1 ) {
8702 System.out.println( "yl=" + p27.length );
8706 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8707 System.out.println( p27[ 0 ].toNewHampshireX() );
8711 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8712 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8713 final String p28_S3 = "(A,B)ab";
8714 final String p28_S4 = "((((A,B),C),D),;E;)";
8715 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8717 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8720 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8723 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8726 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8729 if ( p28.length != 4 ) {
8732 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";
8733 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8734 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8737 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";
8738 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8739 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8742 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8743 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8744 if ( ( p32.length != 0 ) ) {
8747 final String p33_S = "A";
8748 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8749 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8752 final String p34_S = "B;";
8753 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8754 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8757 final String p35_S = "B:0.2";
8758 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8759 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8762 final String p36_S = "(A)";
8763 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8764 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8767 final String p37_S = "((A))";
8768 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8769 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8772 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8773 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8774 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8777 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8778 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8779 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8782 final String p40_S = "(A,B,C)";
8783 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8784 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8787 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8788 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8789 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8792 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8793 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8794 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8797 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)";
8798 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8799 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8802 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)))";
8803 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8804 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8807 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8808 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8809 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8812 final String p46_S = "";
8813 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8814 if ( p46.length != 0 ) {
8817 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(), new NHXParser() )[ 0 ];
8818 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8821 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8822 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8825 final Phylogeny p49 = factory
8826 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
8827 new NHXParser() )[ 0 ];
8828 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8831 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8832 if ( p50.getNode( "A" ) == null ) {
8835 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8836 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8839 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8842 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8843 .equals( "((A,B)88:2.0,C);" ) ) {
8846 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8847 if ( p51.getNode( "A(A" ) == null ) {
8850 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(), new NHXParser() )[ 0 ];
8851 if ( p52.getNode( "A(A" ) == null ) {
8854 final Phylogeny p53 = factory
8855 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
8856 new NHXParser() )[ 0 ];
8857 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8860 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(), new NHXParser() )[ 0 ];
8861 if ( p54.getNode( "A" ) == null ) {
8864 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8867 final Phylogeny p55 = factory
8868 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1x\":0.0798012);" ).toString(),
8869 new NHXParser() )[ 0 ];
8872 .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);" ) ) {
8873 System.out.println( p55.toNewHampshire() );
8876 final Phylogeny p56 = factory
8877 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ).toString(),
8878 new NHXParser() )[ 0 ];
8881 .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);" ) ) {
8882 System.out.println( p56.toNewHampshire() );
8885 final Phylogeny p57 = factory
8886 .create( new StringBuffer( "((\"lcl|HPV32_L1.:1 s\":0.195593,\"lcl|HPV30_L1.1|;a\":0.114\n237):0.0359322,\"lcl|HPV56_L1.1|,d\":0.0727412,\"lcl|HPV66_L1.1:x\":0.0798012);" ).toString(),
8887 new NHXParser() )[ 0 ];
8890 .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);" ) ) {
8891 System.out.println( p56.toNewHampshire() );
8894 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8895 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
8896 if ( !p58.toNewHampshire().equals( s58 ) ) {
8897 System.out.println( p58.toNewHampshire() );
8900 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8901 final Phylogeny p59 = factory.create( s59 , new NHXParser() )[ 0 ];
8902 if ( !p59.toNewHampshire().equals( s59 ) ) {
8903 System.out.println( p59.toNewHampshire() );
8906 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8907 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
8908 if ( !p60.toNewHampshire().equals( s60 ) ) {
8909 System.out.println( p60.toNewHampshire() );
8912 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8913 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
8914 if ( !p61.toNewHampshire()
8915 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8916 System.out.println( p61.toNewHampshire() );
8919 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;";
8920 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
8921 if ( !p62.toNewHampshire()
8922 .equals( "(1:0.003,2:0.004):0.0;" ) ) {
8923 System.out.println( p62.toNewHampshire() );
8926 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)\"];";
8927 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
8928 if ( !p63.toNewHampshire()
8929 .equals( "(1:0.003,2:0.004):0.0;" ) ) {
8930 System.out.println( p63.toNewHampshire() );
8933 final String s64 = "((1,2):[95.5],3);";
8934 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
8935 if ( !p64.toNewHampshireX()
8936 .equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
8937 System.out.println( p64.toNewHampshireX() );
8940 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
8941 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
8942 if ( !p65.toNewHampshireX()
8943 .equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
8944 System.out.println( p65.toNewHampshireX() );
8948 catch ( final Exception e ) {
8949 e.printStackTrace( System.out );
8955 private static boolean testNHParsingSpecialChars() {
8957 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8958 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
8959 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
8960 if ( !p0.toNewHampshireX().equals( i0 ) ) {
8961 System.out.println();
8962 System.out.println( p0.toNewHampshireX() );
8963 System.out.println( i0 );
8966 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
8967 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
8968 if ( !p1.toNewHampshireX().equals( i1 ) ) {
8969 System.out.println();
8970 System.out.println( p1.toNewHampshireX() );
8971 System.out.println( i1 );
8975 catch ( final Exception e ) {
8976 e.printStackTrace( System.out );
8984 private static boolean testNHParsingIter() {
8986 final String p0_str = "(A,B);";
8987 final NHXParser p = new NHXParser();
8988 p.setSource( p0_str );
8989 if ( !p.hasNext() ) {
8992 final Phylogeny p0 = p.next();
8993 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8994 System.out.println( p0.toNewHampshire() );
8997 if ( p.hasNext() ) {
9000 if ( p.next() != null ) {
9004 final String p00_str = "(A,B)root;";
9005 p.setSource( p00_str );
9006 final Phylogeny p00 = p.next();
9007 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9008 System.out.println( p00.toNewHampshire() );
9012 final String p000_str = "A;";
9013 p.setSource( p000_str );
9014 final Phylogeny p000 = p.next();
9015 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9016 System.out.println( p000.toNewHampshire() );
9020 final String p0000_str = "A";
9021 p.setSource( p0000_str );
9022 final Phylogeny p0000 = p.next();
9023 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9024 System.out.println( p0000.toNewHampshire() );
9028 p.setSource( "(A)" );
9029 final Phylogeny p00000 = p.next();
9030 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9031 System.out.println( p00000.toNewHampshire() );
9035 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9036 p.setSource( p1_str );
9037 if ( !p.hasNext() ) {
9040 final Phylogeny p1_0 = p.next();
9041 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9042 System.out.println( p1_0.toNewHampshire() );
9045 if ( !p.hasNext() ) {
9048 final Phylogeny p1_1 = p.next();
9049 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9050 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9053 if ( !p.hasNext() ) {
9056 final Phylogeny p1_2 = p.next();
9057 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9058 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9061 if ( !p.hasNext() ) {
9064 final Phylogeny p1_3 = p.next();
9065 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9066 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9069 if ( p.hasNext() ) {
9072 if ( p.next() != null ) {
9076 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9077 p.setSource( p2_str );
9078 if ( !p.hasNext() ) {
9081 Phylogeny p2_0 = p.next();
9082 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9083 System.out.println( p2_0.toNewHampshire() );
9086 if ( !p.hasNext() ) {
9089 Phylogeny p2_1 = p.next();
9090 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9091 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9094 if ( !p.hasNext() ) {
9097 Phylogeny p2_2 = p.next();
9098 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9099 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9102 if ( !p.hasNext() ) {
9105 Phylogeny p2_3 = p.next();
9106 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9107 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9110 if ( !p.hasNext() ) {
9113 Phylogeny p2_4 = p.next();
9114 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9115 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9118 if ( p.hasNext() ) {
9121 if ( p.next() != null ) {
9126 if ( !p.hasNext() ) {
9130 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9131 System.out.println( p2_0.toNewHampshire() );
9134 if ( !p.hasNext() ) {
9138 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9139 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9142 if ( !p.hasNext() ) {
9146 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9147 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9150 if ( !p.hasNext() ) {
9154 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9155 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9158 if ( !p.hasNext() ) {
9162 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9163 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9166 if ( p.hasNext() ) {
9169 if ( p.next() != null ) {
9173 final String p3_str = "((A,B),C)abc";
9174 p.setSource( p3_str );
9175 if ( !p.hasNext() ) {
9178 final Phylogeny p3_0 = p.next();
9179 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9182 if ( p.hasNext() ) {
9185 if ( p.next() != null ) {
9189 final String p4_str = "((A,B)ab,C)abc";
9190 p.setSource( p4_str );
9191 if ( !p.hasNext() ) {
9194 final Phylogeny p4_0 = p.next();
9195 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9198 if ( p.hasNext() ) {
9201 if ( p.next() != null ) {
9205 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9206 p.setSource( p5_str );
9207 if ( !p.hasNext() ) {
9210 final Phylogeny p5_0 = p.next();
9211 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9214 if ( p.hasNext() ) {
9217 if ( p.next() != null ) {
9221 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9222 p.setSource( p6_str );
9223 if ( !p.hasNext() ) {
9226 Phylogeny p6_0 = p.next();
9227 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9230 if ( p.hasNext() ) {
9233 if ( p.next() != null ) {
9237 if ( !p.hasNext() ) {
9241 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9244 if ( p.hasNext() ) {
9247 if ( p.next() != null ) {
9251 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9252 p.setSource( p7_str );
9253 if ( !p.hasNext() ) {
9256 Phylogeny p7_0 = p.next();
9257 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9260 if ( p.hasNext() ) {
9263 if ( p.next() != null ) {
9267 if ( !p.hasNext() ) {
9271 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9274 if ( p.hasNext() ) {
9277 if ( p.next() != null ) {
9281 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9282 p.setSource( p8_str );
9283 if ( !p.hasNext() ) {
9286 Phylogeny p8_0 = p.next();
9287 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9290 if ( !p.hasNext() ) {
9293 if ( !p.hasNext() ) {
9296 Phylogeny p8_1 = p.next();
9297 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9300 if ( p.hasNext() ) {
9303 if ( p.next() != null ) {
9307 if ( !p.hasNext() ) {
9311 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9314 if ( !p.hasNext() ) {
9318 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9321 if ( p.hasNext() ) {
9324 if ( p.next() != null ) {
9330 if ( p.hasNext() ) {
9334 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9335 if ( !p.hasNext() ) {
9338 Phylogeny p_27 = p.next();
9339 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9340 System.out.println( p_27.toNewHampshireX() );
9344 if ( p.hasNext() ) {
9347 if ( p.next() != null ) {
9351 if ( !p.hasNext() ) {
9355 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9356 System.out.println( p_27.toNewHampshireX() );
9360 if ( p.hasNext() ) {
9363 if ( p.next() != null ) {
9367 final String p30_str = "(A,B);(C,D)";
9368 final NHXParser p30 = new NHXParser();
9369 p30.setSource( p30_str );
9370 if ( !p30.hasNext() ) {
9373 Phylogeny phy30 = p30.next();
9374 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9375 System.out.println( phy30.toNewHampshire() );
9378 if ( !p30.hasNext() ) {
9381 Phylogeny phy301 = p30.next();
9382 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9383 System.out.println( phy301.toNewHampshire() );
9386 if ( p30.hasNext() ) {
9389 if ( p30.hasNext() ) {
9392 if ( p30.next() != null ) {
9395 if ( p30.next() != null ) {
9399 if ( !p30.hasNext() ) {
9403 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9404 System.out.println( phy30.toNewHampshire() );
9407 if ( !p30.hasNext() ) {
9410 phy301 = p30.next();
9411 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9412 System.out.println( phy301.toNewHampshire() );
9415 if ( p30.hasNext() ) {
9418 if ( p30.hasNext() ) {
9421 if ( p30.next() != null ) {
9424 if ( p30.next() != null ) {
9428 catch ( final Exception e ) {
9429 e.printStackTrace( System.out );
9435 private static boolean testNHXconversion() {
9437 final PhylogenyNode n1 = new PhylogenyNode();
9438 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9439 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9440 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9441 final PhylogenyNode n5 = PhylogenyNode
9442 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9443 final PhylogenyNode n6 = PhylogenyNode
9444 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9445 if ( !n1.toNewHampshireX().equals( "" ) ) {
9448 if ( !n2.toNewHampshireX().equals( "" ) ) {
9451 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9454 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9457 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9460 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9461 System.out.println( n6.toNewHampshireX() );
9464 final PhylogenyNode n7 = new PhylogenyNode();
9465 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9466 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9467 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9468 System.out.println( n7
9469 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9473 catch ( final Exception e ) {
9474 e.printStackTrace( System.out );
9480 private static boolean testNHXNodeParsing() {
9482 final PhylogenyNode n1 = new PhylogenyNode();
9483 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9484 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9485 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9486 final PhylogenyNode n5 = PhylogenyNode
9487 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y: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]" );
9488 if ( !n3.getName().equals( "n3" ) ) {
9491 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9494 if ( n3.isDuplication() ) {
9497 if ( n3.isHasAssignedEvent() ) {
9500 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9503 if ( !n4.getName().equals( "n4" ) ) {
9506 if ( n4.getDistanceToParent() != 0.01 ) {
9509 if ( !n5.getName().equals( "n5" ) ) {
9512 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9515 if ( n5.getDistanceToParent() != 0.1 ) {
9518 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9521 if ( !n5.isDuplication() ) {
9524 if ( !n5.isHasAssignedEvent() ) {
9527 final PhylogenyNode n8 = PhylogenyNode
9528 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9529 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9530 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9533 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9536 final PhylogenyNode n9 = PhylogenyNode
9537 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9538 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9539 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9542 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9545 final PhylogenyNode n10 = PhylogenyNode
9546 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9547 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9550 final PhylogenyNode n20 = PhylogenyNode
9551 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9552 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9555 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9558 final PhylogenyNode n20x = PhylogenyNode
9559 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9560 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9563 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9566 final PhylogenyNode n20xx = PhylogenyNode
9567 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9568 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9571 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9574 final PhylogenyNode n20xxx = PhylogenyNode
9575 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9576 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9579 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9582 final PhylogenyNode n20xxxx = PhylogenyNode
9583 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9584 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9587 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9590 final PhylogenyNode n21 = PhylogenyNode
9591 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9592 if ( !n21.getName().equals( "N21_PIG" ) ) {
9595 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9598 final PhylogenyNode n21x = PhylogenyNode
9599 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9600 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9603 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9606 final PhylogenyNode n22 = PhylogenyNode
9607 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9608 if ( !n22.getName().equals( "n22/PIG" ) ) {
9611 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9614 final PhylogenyNode n23 = PhylogenyNode
9615 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9616 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9619 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9622 final PhylogenyNode a = PhylogenyNode
9623 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9624 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9627 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9630 final PhylogenyNode c1 = PhylogenyNode
9631 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9632 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9633 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9636 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9639 final PhylogenyNode c2 = PhylogenyNode
9640 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9641 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9642 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9645 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9648 final PhylogenyNode e3 = PhylogenyNode
9649 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9650 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9653 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9656 final PhylogenyNode n11 = PhylogenyNode
9657 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9658 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9659 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9662 if ( n11.getDistanceToParent() != 0.4 ) {
9665 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9668 final PhylogenyNode n12 = PhylogenyNode
9669 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9670 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9671 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9674 if ( n12.getDistanceToParent() != 0.4 ) {
9677 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9680 final PhylogenyNode o = PhylogenyNode
9681 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9682 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9685 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9688 if ( n1.getName().compareTo( "" ) != 0 ) {
9691 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9694 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9697 if ( n2.getName().compareTo( "" ) != 0 ) {
9700 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9703 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9706 final PhylogenyNode n00 = PhylogenyNode
9707 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9708 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9711 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9714 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9715 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9718 final PhylogenyNode n13 = PhylogenyNode
9719 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9720 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9723 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9726 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9729 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9732 final PhylogenyNode n14 = PhylogenyNode
9733 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9734 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9737 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9740 final PhylogenyNode n15 = PhylogenyNode
9741 .createInstanceFromNhxString( "something_wicked[123]",
9742 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9743 if ( !n15.getName().equals( "something_wicked" ) ) {
9746 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9749 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9752 final PhylogenyNode n16 = PhylogenyNode
9753 .createInstanceFromNhxString( "something_wicked2[9]",
9754 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9755 if ( !n16.getName().equals( "something_wicked2" ) ) {
9758 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9761 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9764 final PhylogenyNode n17 = PhylogenyNode
9765 .createInstanceFromNhxString( "something_wicked3[a]",
9766 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9767 if ( !n17.getName().equals( "something_wicked3" ) ) {
9770 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9773 final PhylogenyNode n18 = PhylogenyNode
9774 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9775 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9778 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9781 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9784 final PhylogenyNode n19 = PhylogenyNode
9785 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9786 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9789 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9792 final PhylogenyNode n30 = PhylogenyNode
9793 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9794 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9795 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9798 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9801 final PhylogenyNode n31 = PhylogenyNode
9802 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9803 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9804 if ( n31.getNodeData().isHasTaxonomy() ) {
9807 final PhylogenyNode n32 = PhylogenyNode
9808 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9809 if ( n32.getNodeData().isHasTaxonomy() ) {
9812 final PhylogenyNode n40 = PhylogenyNode
9813 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9814 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9817 final PhylogenyNode n41 = PhylogenyNode
9818 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9819 if ( n41.getNodeData().isHasTaxonomy() ) {
9822 final PhylogenyNode n42 = PhylogenyNode
9823 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9824 if ( n42.getNodeData().isHasTaxonomy() ) {
9827 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9828 NHXParser.TAXONOMY_EXTRACTION.NO );
9829 if ( n43.getNodeData().isHasTaxonomy() ) {
9832 final PhylogenyNode n44 = PhylogenyNode
9833 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9834 if ( n44.getNodeData().isHasTaxonomy() ) {
9838 catch ( final Exception e ) {
9839 e.printStackTrace( System.out );
9846 private static boolean testNHXNodeParsing2() {
9849 final PhylogenyNode n0_0 = PhylogenyNode
9850 .createInstanceFromNhxString( "n0:[ignore me 123]:1E-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9851 if ( !n0_0.getName().equals( "n0" ) ) {
9854 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
9857 final PhylogenyNode n0_1 = PhylogenyNode
9858 .createInstanceFromNhxString( "n0[ignore me 123]:1E-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9859 if ( !n0_1.getName().equals( "n0" ) ) {
9862 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
9865 final PhylogenyNode n0_2 = PhylogenyNode
9866 .createInstanceFromNhxString( "n0:1E-3[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9867 if ( !n0_2.getName().equals( "n0" ) ) {
9870 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
9873 final PhylogenyNode n0_3 = PhylogenyNode
9874 .createInstanceFromNhxString( "n0:1E-3:[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9875 if ( !n0_3.getName().equals( "n0" ) ) {
9878 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
9881 final PhylogenyNode n0_4 = PhylogenyNode
9882 .createInstanceFromNhxString( "n0:0.001:[ignore me 123]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9883 if ( !n0_4.getName().equals( "n0" ) ) {
9886 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
9889 final PhylogenyNode n1_0 = PhylogenyNode
9890 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9891 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9894 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9897 final PhylogenyNode n1_1 = PhylogenyNode
9898 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9899 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9902 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9905 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
9908 final PhylogenyNode n1_2 = PhylogenyNode
9909 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9910 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9913 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9916 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
9919 final PhylogenyNode n1_3 = PhylogenyNode
9920 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9921 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9924 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9927 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
9930 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
9933 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
9936 final PhylogenyNode n1_4 = PhylogenyNode
9937 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9938 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9941 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen()!=255 ) {
9944 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
9947 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
9950 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
9953 final PhylogenyNode n1_5 = PhylogenyNode
9954 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9955 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9958 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
9961 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
9964 final PhylogenyNode n1_6 = PhylogenyNode
9965 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3", NHXParser.TAXONOMY_EXTRACTION.NO, true, true );
9966 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
9970 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
9973 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
9976 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
9979 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
9983 catch ( final Exception e ) {
9984 e.printStackTrace( System.out );
9990 private static boolean testNHXParsing() {
9992 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9993 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9994 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9997 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]";
9998 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9999 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10002 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]";
10003 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10004 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10007 final Phylogeny[] p3 = factory
10008 .create( "[ comment&&NHX,())))](((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]",
10010 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10013 final Phylogeny[] p4 = factory
10014 .create( "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(]",
10016 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10019 final Phylogeny[] p5 = factory
10020 .create( "[] ( [][ ][ ] ([((( &&NHXcomment only![[[[[[]([]((((A:0.2[&&NHX:S=q[comment )))]werty][,,,,))]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=a[comment,,))]sdf])[comment(((]:0.4[&&NHX:S=zxc][comment(((][comment(((]):0.5[&&NHX:S=a]):0.6[&&NHX:S=a[comment(((]sd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(((]",
10022 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10025 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)";
10026 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)";
10027 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10028 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10031 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)))";
10032 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)))";
10033 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10034 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10037 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]) ))[,,, ])))))))";
10038 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10039 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10040 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10043 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10044 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10047 final Phylogeny p10 = factory
10048 .create( " [79] ( (A [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
10049 new NHXParser() )[ 0 ];
10050 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10053 final Phylogeny p11 = factory
10054 .create( " [79] ( ('A: \" ' [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
10055 new NHXParser() )[ 0 ];
10056 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10059 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]",
10060 new NHXParser() )[ 0 ];
10061 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10065 catch ( final Exception e ) {
10066 e.printStackTrace( System.out );
10072 private static boolean testNHXParsingMB() {
10074 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10075 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10076 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10077 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10078 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10079 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10080 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10081 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10082 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10083 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10084 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10087 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10090 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10091 0.1100000000000000e+00 ) ) {
10094 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10097 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10100 final Phylogeny p2 = factory
10101 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10102 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10103 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10104 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10105 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10106 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10107 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10108 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10109 + "7.369400000000000e-02}])",
10110 new NHXParser() )[ 0 ];
10111 if ( p2.getNode( "1" ) == null ) {
10114 if ( p2.getNode( "2" ) == null ) {
10118 catch ( final Exception e ) {
10119 e.printStackTrace( System.out );
10126 private static boolean testNHXParsingQuotes() {
10128 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10129 final NHXParser p = new NHXParser();
10130 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10131 if ( phylogenies_0.length != 5 ) {
10134 final Phylogeny phy = phylogenies_0[ 4 ];
10135 if ( phy.getNumberOfExternalNodes() != 7 ) {
10138 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10141 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10144 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10145 .getScientificName().equals( "hsapiens" ) ) {
10148 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10151 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10154 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10157 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10160 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10163 final NHXParser p1p = new NHXParser();
10164 p1p.setIgnoreQuotes( true );
10165 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10166 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10169 final NHXParser p2p = new NHXParser();
10170 p1p.setIgnoreQuotes( false );
10171 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10172 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10175 final NHXParser p3p = new NHXParser();
10176 p3p.setIgnoreQuotes( false );
10177 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10178 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10181 final NHXParser p4p = new NHXParser();
10182 p4p.setIgnoreQuotes( false );
10183 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10184 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10187 final Phylogeny p10 = factory
10188 .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]",
10189 new NHXParser() )[ 0 ];
10190 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]";
10191 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10194 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10195 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10198 final Phylogeny p12 = factory
10199 .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]",
10200 new NHXParser() )[ 0 ];
10201 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]";
10202 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10205 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10206 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10209 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;";
10210 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10213 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10214 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10218 catch ( final Exception e ) {
10219 e.printStackTrace( System.out );
10225 private static boolean testNodeRemoval() {
10227 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10228 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10229 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10230 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10233 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10234 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10235 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10238 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10239 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10240 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10244 catch ( final Exception e ) {
10245 e.printStackTrace( System.out );
10251 private static boolean testPhylogenyBranch() {
10253 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10254 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10255 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10256 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10257 if ( !a1b1.equals( a1b1 ) ) {
10260 if ( !a1b1.equals( b1a1 ) ) {
10263 if ( !b1a1.equals( a1b1 ) ) {
10266 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10267 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10268 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10269 if ( a1_b1.equals( b1_a1 ) ) {
10272 if ( a1_b1.equals( a1_b1_ ) ) {
10275 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10276 if ( !a1_b1.equals( b1_a1_ ) ) {
10279 if ( a1_b1_.equals( b1_a1_ ) ) {
10282 if ( !a1_b1_.equals( b1_a1 ) ) {
10286 catch ( final Exception e ) {
10287 e.printStackTrace( System.out );
10293 private static boolean testPhyloXMLparsingOfDistributionElement() {
10295 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10296 PhyloXmlParser xml_parser = null;
10298 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10300 catch ( final Exception e ) {
10301 // Do nothing -- means were not running from jar.
10303 if ( xml_parser == null ) {
10304 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10305 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10306 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10309 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10312 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ),
10314 if ( xml_parser.getErrorCount() > 0 ) {
10315 System.out.println( xml_parser.getErrorMessages().toString() );
10318 if ( phylogenies_0.length != 1 ) {
10321 final Phylogeny t1 = phylogenies_0[ 0 ];
10322 PhylogenyNode n = null;
10323 Distribution d = null;
10324 n = t1.getNode( "root node" );
10325 if ( !n.getNodeData().isHasDistribution() ) {
10328 if ( n.getNodeData().getDistributions().size() != 1 ) {
10331 d = n.getNodeData().getDistribution();
10332 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10335 if ( d.getPoints().size() != 1 ) {
10338 if ( d.getPolygons() != null ) {
10341 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10344 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10347 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10350 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10353 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10356 n = t1.getNode( "node a" );
10357 if ( !n.getNodeData().isHasDistribution() ) {
10360 if ( n.getNodeData().getDistributions().size() != 2 ) {
10363 d = n.getNodeData().getDistribution( 1 );
10364 if ( !d.getDesc().equals( "San Diego" ) ) {
10367 if ( d.getPoints().size() != 1 ) {
10370 if ( d.getPolygons() != null ) {
10373 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10376 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10379 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10382 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10385 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10388 n = t1.getNode( "node bb" );
10389 if ( !n.getNodeData().isHasDistribution() ) {
10392 if ( n.getNodeData().getDistributions().size() != 1 ) {
10395 d = n.getNodeData().getDistribution( 0 );
10396 if ( d.getPoints().size() != 3 ) {
10399 if ( d.getPolygons().size() != 2 ) {
10402 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10405 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10408 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10411 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10414 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10417 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10420 Polygon p = d.getPolygons().get( 0 );
10421 if ( p.getPoints().size() != 3 ) {
10424 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10427 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10430 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10433 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10436 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10439 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10442 p = d.getPolygons().get( 1 );
10443 if ( p.getPoints().size() != 3 ) {
10446 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10449 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10452 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10456 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10457 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10458 if ( rt.length != 1 ) {
10461 final Phylogeny t1_rt = rt[ 0 ];
10462 n = t1_rt.getNode( "root node" );
10463 if ( !n.getNodeData().isHasDistribution() ) {
10466 if ( n.getNodeData().getDistributions().size() != 1 ) {
10469 d = n.getNodeData().getDistribution();
10470 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10473 if ( d.getPoints().size() != 1 ) {
10476 if ( d.getPolygons() != null ) {
10479 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10482 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10485 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10488 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10491 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10494 n = t1_rt.getNode( "node a" );
10495 if ( !n.getNodeData().isHasDistribution() ) {
10498 if ( n.getNodeData().getDistributions().size() != 2 ) {
10501 d = n.getNodeData().getDistribution( 1 );
10502 if ( !d.getDesc().equals( "San Diego" ) ) {
10505 if ( d.getPoints().size() != 1 ) {
10508 if ( d.getPolygons() != null ) {
10511 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10514 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10517 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10520 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10523 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10526 n = t1_rt.getNode( "node bb" );
10527 if ( !n.getNodeData().isHasDistribution() ) {
10530 if ( n.getNodeData().getDistributions().size() != 1 ) {
10533 d = n.getNodeData().getDistribution( 0 );
10534 if ( d.getPoints().size() != 3 ) {
10537 if ( d.getPolygons().size() != 2 ) {
10540 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10543 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10546 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10549 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10552 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10555 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10558 p = d.getPolygons().get( 0 );
10559 if ( p.getPoints().size() != 3 ) {
10562 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10565 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10568 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10571 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10574 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10577 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10580 p = d.getPolygons().get( 1 );
10581 if ( p.getPoints().size() != 3 ) {
10584 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10587 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10590 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10594 catch ( final Exception e ) {
10595 e.printStackTrace( System.out );
10601 private static boolean testPostOrderIterator() {
10603 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10604 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10605 PhylogenyNodeIterator it0;
10606 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10609 for( it0.reset(); it0.hasNext(); ) {
10612 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10613 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10614 if ( !it.next().getName().equals( "A" ) ) {
10617 if ( !it.next().getName().equals( "B" ) ) {
10620 if ( !it.next().getName().equals( "ab" ) ) {
10623 if ( !it.next().getName().equals( "C" ) ) {
10626 if ( !it.next().getName().equals( "D" ) ) {
10629 if ( !it.next().getName().equals( "cd" ) ) {
10632 if ( !it.next().getName().equals( "abcd" ) ) {
10635 if ( !it.next().getName().equals( "E" ) ) {
10638 if ( !it.next().getName().equals( "F" ) ) {
10641 if ( !it.next().getName().equals( "ef" ) ) {
10644 if ( !it.next().getName().equals( "G" ) ) {
10647 if ( !it.next().getName().equals( "H" ) ) {
10650 if ( !it.next().getName().equals( "gh" ) ) {
10653 if ( !it.next().getName().equals( "efgh" ) ) {
10656 if ( !it.next().getName().equals( "r" ) ) {
10659 if ( it.hasNext() ) {
10663 catch ( final Exception e ) {
10664 e.printStackTrace( System.out );
10670 private static boolean testPreOrderIterator() {
10672 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10673 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10674 PhylogenyNodeIterator it0;
10675 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10678 for( it0.reset(); it0.hasNext(); ) {
10681 PhylogenyNodeIterator it = t0.iteratorPreorder();
10682 if ( !it.next().getName().equals( "r" ) ) {
10685 if ( !it.next().getName().equals( "ab" ) ) {
10688 if ( !it.next().getName().equals( "A" ) ) {
10691 if ( !it.next().getName().equals( "B" ) ) {
10694 if ( !it.next().getName().equals( "cd" ) ) {
10697 if ( !it.next().getName().equals( "C" ) ) {
10700 if ( !it.next().getName().equals( "D" ) ) {
10703 if ( it.hasNext() ) {
10706 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10707 it = t1.iteratorPreorder();
10708 if ( !it.next().getName().equals( "r" ) ) {
10711 if ( !it.next().getName().equals( "abcd" ) ) {
10714 if ( !it.next().getName().equals( "ab" ) ) {
10717 if ( !it.next().getName().equals( "A" ) ) {
10720 if ( !it.next().getName().equals( "B" ) ) {
10723 if ( !it.next().getName().equals( "cd" ) ) {
10726 if ( !it.next().getName().equals( "C" ) ) {
10729 if ( !it.next().getName().equals( "D" ) ) {
10732 if ( !it.next().getName().equals( "efgh" ) ) {
10735 if ( !it.next().getName().equals( "ef" ) ) {
10738 if ( !it.next().getName().equals( "E" ) ) {
10741 if ( !it.next().getName().equals( "F" ) ) {
10744 if ( !it.next().getName().equals( "gh" ) ) {
10747 if ( !it.next().getName().equals( "G" ) ) {
10750 if ( !it.next().getName().equals( "H" ) ) {
10753 if ( it.hasNext() ) {
10757 catch ( final Exception e ) {
10758 e.printStackTrace( System.out );
10764 private static boolean testPropertiesMap() {
10766 final PropertiesMap pm = new PropertiesMap();
10767 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10768 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10769 final Property p2 = new Property( "something:else",
10771 "improbable:research",
10774 pm.addProperty( p0 );
10775 pm.addProperty( p1 );
10776 pm.addProperty( p2 );
10777 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10780 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10783 if ( pm.getProperties().size() != 3 ) {
10786 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10789 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10792 if ( pm.getProperties().size() != 3 ) {
10795 pm.removeProperty( "dimensions:diameter" );
10796 if ( pm.getProperties().size() != 2 ) {
10799 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10802 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10806 catch ( final Exception e ) {
10807 e.printStackTrace( System.out );
10813 private static boolean testProteinId() {
10815 final ProteinId id1 = new ProteinId( "a" );
10816 final ProteinId id2 = new ProteinId( "a" );
10817 final ProteinId id3 = new ProteinId( "A" );
10818 final ProteinId id4 = new ProteinId( "b" );
10819 if ( !id1.equals( id1 ) ) {
10822 if ( id1.getId().equals( "x" ) ) {
10825 if ( id1.getId().equals( null ) ) {
10828 if ( !id1.equals( id2 ) ) {
10831 if ( id1.equals( id3 ) ) {
10834 if ( id1.hashCode() != id1.hashCode() ) {
10837 if ( id1.hashCode() != id2.hashCode() ) {
10840 if ( id1.hashCode() == id3.hashCode() ) {
10843 if ( id1.compareTo( id1 ) != 0 ) {
10846 if ( id1.compareTo( id2 ) != 0 ) {
10849 if ( id1.compareTo( id3 ) != 0 ) {
10852 if ( id1.compareTo( id4 ) >= 0 ) {
10855 if ( id4.compareTo( id1 ) <= 0 ) {
10858 if ( !id4.getId().equals( "b" ) ) {
10861 final ProteinId id5 = new ProteinId( " C " );
10862 if ( !id5.getId().equals( "C" ) ) {
10865 if ( id5.equals( id1 ) ) {
10869 catch ( final Exception e ) {
10870 e.printStackTrace( System.out );
10876 private static boolean testReIdMethods() {
10878 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10879 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10880 final long count = PhylogenyNode.getNodeCount();
10881 p.levelOrderReID();
10882 if ( p.getNode( "r" ).getId() != count ) {
10885 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10888 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10891 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10894 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10897 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10900 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10903 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10906 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10909 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10912 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10915 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10918 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10921 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10924 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10928 catch ( final Exception e ) {
10929 e.printStackTrace( System.out );
10935 private static boolean testRerooting() {
10937 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10938 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",
10939 new NHXParser() )[ 0 ];
10940 if ( !t1.isRooted() ) {
10943 t1.reRoot( t1.getNode( "D" ) );
10944 t1.reRoot( t1.getNode( "CD" ) );
10945 t1.reRoot( t1.getNode( "A" ) );
10946 t1.reRoot( t1.getNode( "B" ) );
10947 t1.reRoot( t1.getNode( "AB" ) );
10948 t1.reRoot( t1.getNode( "D" ) );
10949 t1.reRoot( t1.getNode( "C" ) );
10950 t1.reRoot( t1.getNode( "CD" ) );
10951 t1.reRoot( t1.getNode( "A" ) );
10952 t1.reRoot( t1.getNode( "B" ) );
10953 t1.reRoot( t1.getNode( "AB" ) );
10954 t1.reRoot( t1.getNode( "D" ) );
10955 t1.reRoot( t1.getNode( "D" ) );
10956 t1.reRoot( t1.getNode( "C" ) );
10957 t1.reRoot( t1.getNode( "A" ) );
10958 t1.reRoot( t1.getNode( "B" ) );
10959 t1.reRoot( t1.getNode( "AB" ) );
10960 t1.reRoot( t1.getNode( "C" ) );
10961 t1.reRoot( t1.getNode( "D" ) );
10962 t1.reRoot( t1.getNode( "CD" ) );
10963 t1.reRoot( t1.getNode( "D" ) );
10964 t1.reRoot( t1.getNode( "A" ) );
10965 t1.reRoot( t1.getNode( "B" ) );
10966 t1.reRoot( t1.getNode( "AB" ) );
10967 t1.reRoot( t1.getNode( "C" ) );
10968 t1.reRoot( t1.getNode( "D" ) );
10969 t1.reRoot( t1.getNode( "CD" ) );
10970 t1.reRoot( t1.getNode( "D" ) );
10971 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10974 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10977 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10980 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10983 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10986 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10989 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",
10990 new NHXParser() )[ 0 ];
10991 t2.reRoot( t2.getNode( "A" ) );
10992 t2.reRoot( t2.getNode( "D" ) );
10993 t2.reRoot( t2.getNode( "ABC" ) );
10994 t2.reRoot( t2.getNode( "A" ) );
10995 t2.reRoot( t2.getNode( "B" ) );
10996 t2.reRoot( t2.getNode( "D" ) );
10997 t2.reRoot( t2.getNode( "C" ) );
10998 t2.reRoot( t2.getNode( "ABC" ) );
10999 t2.reRoot( t2.getNode( "A" ) );
11000 t2.reRoot( t2.getNode( "B" ) );
11001 t2.reRoot( t2.getNode( "AB" ) );
11002 t2.reRoot( t2.getNode( "AB" ) );
11003 t2.reRoot( t2.getNode( "D" ) );
11004 t2.reRoot( t2.getNode( "C" ) );
11005 t2.reRoot( t2.getNode( "B" ) );
11006 t2.reRoot( t2.getNode( "AB" ) );
11007 t2.reRoot( t2.getNode( "D" ) );
11008 t2.reRoot( t2.getNode( "D" ) );
11009 t2.reRoot( t2.getNode( "ABC" ) );
11010 t2.reRoot( t2.getNode( "A" ) );
11011 t2.reRoot( t2.getNode( "B" ) );
11012 t2.reRoot( t2.getNode( "AB" ) );
11013 t2.reRoot( t2.getNode( "D" ) );
11014 t2.reRoot( t2.getNode( "C" ) );
11015 t2.reRoot( t2.getNode( "ABC" ) );
11016 t2.reRoot( t2.getNode( "A" ) );
11017 t2.reRoot( t2.getNode( "B" ) );
11018 t2.reRoot( t2.getNode( "AB" ) );
11019 t2.reRoot( t2.getNode( "D" ) );
11020 t2.reRoot( t2.getNode( "D" ) );
11021 t2.reRoot( t2.getNode( "C" ) );
11022 t2.reRoot( t2.getNode( "A" ) );
11023 t2.reRoot( t2.getNode( "B" ) );
11024 t2.reRoot( t2.getNode( "AB" ) );
11025 t2.reRoot( t2.getNode( "C" ) );
11026 t2.reRoot( t2.getNode( "D" ) );
11027 t2.reRoot( t2.getNode( "ABC" ) );
11028 t2.reRoot( t2.getNode( "D" ) );
11029 t2.reRoot( t2.getNode( "A" ) );
11030 t2.reRoot( t2.getNode( "B" ) );
11031 t2.reRoot( t2.getNode( "AB" ) );
11032 t2.reRoot( t2.getNode( "C" ) );
11033 t2.reRoot( t2.getNode( "D" ) );
11034 t2.reRoot( t2.getNode( "ABC" ) );
11035 t2.reRoot( t2.getNode( "D" ) );
11036 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11039 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11042 t2.reRoot( t2.getNode( "ABC" ) );
11043 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11046 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11049 t2.reRoot( t2.getNode( "AB" ) );
11050 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11053 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11056 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11059 t2.reRoot( t2.getNode( "AB" ) );
11060 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11063 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11066 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11069 t2.reRoot( t2.getNode( "D" ) );
11070 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11073 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11076 t2.reRoot( t2.getNode( "ABC" ) );
11077 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11080 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11083 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11084 new NHXParser() )[ 0 ];
11085 t3.reRoot( t3.getNode( "B" ) );
11086 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11089 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11092 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11095 t3.reRoot( t3.getNode( "B" ) );
11096 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11099 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11102 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11105 t3.reRoot( t3.getRoot() );
11106 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11109 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11112 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11116 catch ( final Exception e ) {
11117 e.printStackTrace( System.out );
11123 private static boolean testSDIse() {
11125 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11126 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11127 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11128 gene1.setRooted( true );
11129 species1.setRooted( true );
11130 final SDI sdi = new SDI( gene1, species1 );
11131 if ( !gene1.getRoot().isDuplication() ) {
11134 final Phylogeny species2 = factory
11135 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11136 new NHXParser() )[ 0 ];
11137 final Phylogeny gene2 = factory
11138 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11139 new NHXParser() )[ 0 ];
11140 species2.setRooted( true );
11141 gene2.setRooted( true );
11142 final SDI sdi2 = new SDI( gene2, species2 );
11143 if ( sdi2.getDuplicationsSum() != 0 ) {
11146 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11149 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11152 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11155 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11158 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11161 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11164 final Phylogeny species3 = factory
11165 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11166 new NHXParser() )[ 0 ];
11167 final Phylogeny gene3 = factory
11168 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11169 new NHXParser() )[ 0 ];
11170 species3.setRooted( true );
11171 gene3.setRooted( true );
11172 final SDI sdi3 = new SDI( gene3, species3 );
11173 if ( sdi3.getDuplicationsSum() != 1 ) {
11176 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11179 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11182 final Phylogeny species4 = factory
11183 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11184 new NHXParser() )[ 0 ];
11185 final Phylogeny gene4 = factory
11186 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11187 new NHXParser() )[ 0 ];
11188 species4.setRooted( true );
11189 gene4.setRooted( true );
11190 final SDI sdi4 = new SDI( gene4, species4 );
11191 if ( sdi4.getDuplicationsSum() != 1 ) {
11194 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11197 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11200 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11203 if ( species4.getNumberOfExternalNodes() != 6 ) {
11206 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11209 final Phylogeny species5 = factory
11210 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11211 new NHXParser() )[ 0 ];
11212 final Phylogeny gene5 = factory
11213 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11214 new NHXParser() )[ 0 ];
11215 species5.setRooted( true );
11216 gene5.setRooted( true );
11217 final SDI sdi5 = new SDI( gene5, species5 );
11218 if ( sdi5.getDuplicationsSum() != 2 ) {
11221 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11224 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11227 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11230 if ( species5.getNumberOfExternalNodes() != 6 ) {
11233 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11236 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11237 // Conjecture for Comparing Molecular Phylogenies"
11238 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11239 final Phylogeny species6 = factory
11240 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11241 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11242 new NHXParser() )[ 0 ];
11243 final Phylogeny gene6 = factory
11244 .create( "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1,3:0.1[&&NHX:S=3])1-2-3:0.1,"
11245 + "((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,"
11246 + "(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;",
11247 new NHXParser() )[ 0 ];
11248 species6.setRooted( true );
11249 gene6.setRooted( true );
11250 final SDI sdi6 = new SDI( gene6, species6 );
11251 if ( sdi6.getDuplicationsSum() != 3 ) {
11254 if ( !gene6.getNode( "r" ).isDuplication() ) {
11257 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11260 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11263 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11266 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11269 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11272 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11275 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11278 sdi6.computeMappingCostL();
11279 if ( sdi6.computeMappingCostL() != 17 ) {
11282 if ( species6.getNumberOfExternalNodes() != 9 ) {
11285 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11288 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11289 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11290 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11291 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11292 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11293 species7.setRooted( true );
11294 final Phylogeny gene7_1 = Test
11295 .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])" );
11296 gene7_1.setRooted( true );
11297 final SDI sdi7 = new SDI( gene7_1, species7 );
11298 if ( sdi7.getDuplicationsSum() != 0 ) {
11301 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11304 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11307 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11310 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11313 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11316 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11319 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11322 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11325 final Phylogeny gene7_2 = Test
11326 .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])" );
11327 gene7_2.setRooted( true );
11328 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11329 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11332 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11335 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11338 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11341 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11344 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11347 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11350 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11353 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11356 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11360 catch ( final Exception e ) {
11366 private static boolean testSDIunrooted() {
11368 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11369 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
11370 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11371 final Iterator<PhylogenyBranch> iter = l.iterator();
11372 PhylogenyBranch br = iter.next();
11373 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11376 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11380 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11383 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11387 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11390 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11394 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11397 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11401 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11404 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11408 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11411 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11415 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11418 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11422 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11425 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11429 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11432 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11436 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11439 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11443 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11446 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11450 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11453 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11457 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11460 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11464 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11467 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11471 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11474 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11477 if ( iter.hasNext() ) {
11480 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11481 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11482 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11484 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11487 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11491 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11494 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11498 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11501 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11504 if ( iter1.hasNext() ) {
11507 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11508 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11509 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11511 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11514 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11518 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11521 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11525 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11528 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11531 if ( iter2.hasNext() ) {
11534 final Phylogeny species0 = factory
11535 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11536 new NHXParser() )[ 0 ];
11537 final Phylogeny gene1 = factory
11538 .create( "(((((A:0.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
11539 new NHXParser() )[ 0 ];
11540 species0.setRooted( true );
11541 gene1.setRooted( true );
11542 final SDIR sdi_unrooted = new SDIR();
11543 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11544 if ( sdi_unrooted.getCount() != 1 ) {
11547 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11550 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11553 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11556 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11559 final Phylogeny gene2 = factory
11560 .create( "(((((A:2.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
11561 new NHXParser() )[ 0 ];
11562 gene2.setRooted( true );
11563 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11564 if ( sdi_unrooted.getCount() != 1 ) {
11567 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11570 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11573 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11576 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11579 final Phylogeny species6 = factory
11580 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11581 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11582 new NHXParser() )[ 0 ];
11583 final Phylogeny gene6 = factory
11584 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11585 + "(((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],"
11586 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11587 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11588 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11589 new NHXParser() )[ 0 ];
11590 species6.setRooted( true );
11591 gene6.setRooted( true );
11592 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11593 if ( sdi_unrooted.getCount() != 1 ) {
11596 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11599 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11602 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11605 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11608 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11611 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11614 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11617 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11620 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11623 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11626 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11629 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11633 final Phylogeny species7 = factory
11634 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11635 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11636 new NHXParser() )[ 0 ];
11637 final Phylogeny gene7 = factory
11638 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11639 + "(((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],"
11640 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11641 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11642 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11643 new NHXParser() )[ 0 ];
11644 species7.setRooted( true );
11645 gene7.setRooted( true );
11646 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11647 if ( sdi_unrooted.getCount() != 1 ) {
11650 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11653 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11656 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11659 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11662 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11665 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11668 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11671 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11674 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11677 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11680 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11683 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11687 final Phylogeny species8 = factory
11688 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11689 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11690 new NHXParser() )[ 0 ];
11691 final Phylogeny gene8 = factory
11692 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11693 + "(((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],"
11694 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11695 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11696 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11697 new NHXParser() )[ 0 ];
11698 species8.setRooted( true );
11699 gene8.setRooted( true );
11700 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11701 if ( sdi_unrooted.getCount() != 1 ) {
11704 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11707 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11710 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11713 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11716 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11719 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11722 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11725 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11728 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11731 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11734 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11737 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11742 catch ( final Exception e ) {
11743 e.printStackTrace( System.out );
11749 private static boolean testSequenceDbWsTools1() {
11751 final PhylogenyNode n = new PhylogenyNode();
11752 n.setName( "NP_001025424" );
11753 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11754 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11755 || !acc.getValue().equals( "NP_001025424" ) ) {
11758 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11759 acc = SequenceDbWsTools.obtainSeqAccession( n );
11760 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11761 || !acc.getValue().equals( "NP_001025424" ) ) {
11764 n.setName( "NP_001025424.1" );
11765 acc = SequenceDbWsTools.obtainSeqAccession( n );
11766 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11767 || !acc.getValue().equals( "NP_001025424" ) ) {
11770 n.setName( "NM_001030253" );
11771 acc = SequenceDbWsTools.obtainSeqAccession( n );
11772 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11773 || !acc.getValue().equals( "NM_001030253" ) ) {
11776 n.setName( "BCL2_HUMAN" );
11777 acc = SequenceDbWsTools.obtainSeqAccession( n );
11778 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11779 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11780 System.out.println( acc.toString() );
11783 n.setName( "P10415" );
11784 acc = SequenceDbWsTools.obtainSeqAccession( n );
11785 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11786 || !acc.getValue().equals( "P10415" ) ) {
11787 System.out.println( acc.toString() );
11790 n.setName( " P10415 " );
11791 acc = SequenceDbWsTools.obtainSeqAccession( n );
11792 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11793 || !acc.getValue().equals( "P10415" ) ) {
11794 System.out.println( acc.toString() );
11797 n.setName( "_P10415|" );
11798 acc = SequenceDbWsTools.obtainSeqAccession( n );
11799 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11800 || !acc.getValue().equals( "P10415" ) ) {
11801 System.out.println( acc.toString() );
11804 n.setName( "AY695820" );
11805 acc = SequenceDbWsTools.obtainSeqAccession( n );
11806 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11807 || !acc.getValue().equals( "AY695820" ) ) {
11808 System.out.println( acc.toString() );
11811 n.setName( "_AY695820_" );
11812 acc = SequenceDbWsTools.obtainSeqAccession( n );
11813 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11814 || !acc.getValue().equals( "AY695820" ) ) {
11815 System.out.println( acc.toString() );
11818 n.setName( "AAA59452" );
11819 acc = SequenceDbWsTools.obtainSeqAccession( n );
11820 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11821 || !acc.getValue().equals( "AAA59452" ) ) {
11822 System.out.println( acc.toString() );
11825 n.setName( "_AAA59452_" );
11826 acc = SequenceDbWsTools.obtainSeqAccession( n );
11827 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11828 || !acc.getValue().equals( "AAA59452" ) ) {
11829 System.out.println( acc.toString() );
11832 n.setName( "AAA59452.1" );
11833 acc = SequenceDbWsTools.obtainSeqAccession( n );
11834 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11835 || !acc.getValue().equals( "AAA59452.1" ) ) {
11836 System.out.println( acc.toString() );
11839 n.setName( "_AAA59452.1_" );
11840 acc = SequenceDbWsTools.obtainSeqAccession( n );
11841 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11842 || !acc.getValue().equals( "AAA59452.1" ) ) {
11843 System.out.println( acc.toString() );
11846 n.setName( "GI:94894583" );
11847 acc = SequenceDbWsTools.obtainSeqAccession( n );
11848 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11849 || !acc.getValue().equals( "94894583" ) ) {
11850 System.out.println( acc.toString() );
11853 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11854 acc = SequenceDbWsTools.obtainSeqAccession( n );
11855 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11856 || !acc.getValue().equals( "71845847" ) ) {
11857 System.out.println( acc.toString() );
11860 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11861 acc = SequenceDbWsTools.obtainSeqAccession( n );
11862 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11863 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11864 System.out.println( acc.toString() );
11868 catch ( final Exception e ) {
11874 private static boolean testSequenceDbWsTools2() {
11876 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11877 SequenceDbWsTools.obtainSeqInformation( n1 );
11878 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11881 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11884 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11887 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11890 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11891 SequenceDbWsTools.obtainSeqInformation( n2 );
11892 if ( !n2.getNodeData().getSequence().getName().equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
11895 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11898 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11901 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11904 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11905 SequenceDbWsTools.obtainSeqInformation( n3 );
11906 if ( !n3.getNodeData().getSequence().getName()
11907 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11910 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11913 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11916 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11920 catch ( final IOException e ) {
11921 System.out.println();
11922 System.out.println( "the following might be due to absence internet connection:" );
11923 e.printStackTrace( System.out );
11926 catch ( final Exception e ) {
11927 e.printStackTrace();
11933 private static boolean testSequenceIdParsing() {
11935 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11936 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11937 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11938 if ( id != null ) {
11939 System.out.println( "value =" + id.getValue() );
11940 System.out.println( "provider=" + id.getSource() );
11944 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11945 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11946 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11947 if ( id != null ) {
11948 System.out.println( "value =" + id.getValue() );
11949 System.out.println( "provider=" + id.getSource() );
11953 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11954 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11955 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11956 if ( id != null ) {
11957 System.out.println( "value =" + id.getValue() );
11958 System.out.println( "provider=" + id.getSource() );
11962 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11963 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11964 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11965 if ( id != null ) {
11966 System.out.println( "value =" + id.getValue() );
11967 System.out.println( "provider=" + id.getSource() );
11971 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11972 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11973 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11974 if ( id != null ) {
11975 System.out.println( "value =" + id.getValue() );
11976 System.out.println( "provider=" + id.getSource() );
11980 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11981 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11982 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11983 if ( id != null ) {
11984 System.out.println( "value =" + id.getValue() );
11985 System.out.println( "provider=" + id.getSource() );
11989 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11990 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11991 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11992 if ( id != null ) {
11993 System.out.println( "value =" + id.getValue() );
11994 System.out.println( "provider=" + id.getSource() );
11998 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11999 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12000 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12001 if ( id != null ) {
12002 System.out.println( "value =" + id.getValue() );
12003 System.out.println( "provider=" + id.getSource() );
12007 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12008 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12009 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12010 if ( id != null ) {
12011 System.out.println( "value =" + id.getValue() );
12012 System.out.println( "provider=" + id.getSource() );
12016 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12017 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12018 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12019 if ( id != null ) {
12020 System.out.println( "value =" + id.getValue() );
12021 System.out.println( "provider=" + id.getSource() );
12025 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12026 if ( id != null ) {
12027 System.out.println( "value =" + id.getValue() );
12028 System.out.println( "provider=" + id.getSource() );
12031 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12032 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12033 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12034 if ( id != null ) {
12035 System.out.println( "value =" + id.getValue() );
12036 System.out.println( "provider=" + id.getSource() );
12040 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12041 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12042 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12043 if ( id != null ) {
12044 System.out.println( "value =" + id.getValue() );
12045 System.out.println( "provider=" + id.getSource() );
12049 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12050 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12051 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12052 if ( id != null ) {
12053 System.out.println( "value =" + id.getValue() );
12054 System.out.println( "provider=" + id.getSource() );
12058 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12059 if ( id != null ) {
12060 System.out.println( "value =" + id.getValue() );
12061 System.out.println( "provider=" + id.getSource() );
12065 catch ( final Exception e ) {
12066 e.printStackTrace( System.out );
12072 private static boolean testSequenceWriter() {
12074 final String n = ForesterUtil.LINE_SEPARATOR;
12075 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12078 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12081 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12084 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12087 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12088 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12091 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12092 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12096 catch ( final Exception e ) {
12097 e.printStackTrace();
12103 private static boolean testSpecies() {
12105 final Species s1 = new BasicSpecies( "a" );
12106 final Species s2 = new BasicSpecies( "a" );
12107 final Species s3 = new BasicSpecies( "A" );
12108 final Species s4 = new BasicSpecies( "b" );
12109 if ( !s1.equals( s1 ) ) {
12112 if ( s1.getSpeciesId().equals( "x" ) ) {
12115 if ( s1.getSpeciesId().equals( null ) ) {
12118 if ( !s1.equals( s2 ) ) {
12121 if ( s1.equals( s3 ) ) {
12124 if ( s1.hashCode() != s1.hashCode() ) {
12127 if ( s1.hashCode() != s2.hashCode() ) {
12130 if ( s1.hashCode() == s3.hashCode() ) {
12133 if ( s1.compareTo( s1 ) != 0 ) {
12136 if ( s1.compareTo( s2 ) != 0 ) {
12139 if ( s1.compareTo( s3 ) != 0 ) {
12142 if ( s1.compareTo( s4 ) >= 0 ) {
12145 if ( s4.compareTo( s1 ) <= 0 ) {
12148 if ( !s4.getSpeciesId().equals( "b" ) ) {
12151 final Species s5 = new BasicSpecies( " C " );
12152 if ( !s5.getSpeciesId().equals( "C" ) ) {
12155 if ( s5.equals( s1 ) ) {
12159 catch ( final Exception e ) {
12160 e.printStackTrace( System.out );
12166 private static boolean testSplit() {
12168 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12169 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12170 //Archaeopteryx.createApplication( p0 );
12171 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12172 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12173 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12174 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12175 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12176 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12177 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12178 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12179 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12180 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12181 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12182 // System.out.println( s0.toString() );
12184 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12185 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12186 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12187 if ( s0.match( query_nodes ) ) {
12190 query_nodes = new HashSet<PhylogenyNode>();
12191 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12192 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12193 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12194 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12195 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12196 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12197 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12198 if ( !s0.match( query_nodes ) ) {
12202 query_nodes = new HashSet<PhylogenyNode>();
12203 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12204 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12205 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12206 if ( !s0.match( query_nodes ) ) {
12210 query_nodes = new HashSet<PhylogenyNode>();
12211 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12212 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12213 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12214 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12215 if ( !s0.match( query_nodes ) ) {
12219 query_nodes = new HashSet<PhylogenyNode>();
12220 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12221 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12222 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12223 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12224 if ( !s0.match( query_nodes ) ) {
12228 query_nodes = new HashSet<PhylogenyNode>();
12229 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12230 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12231 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12232 if ( !s0.match( query_nodes ) ) {
12235 query_nodes = new HashSet<PhylogenyNode>();
12236 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12237 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12238 if ( !s0.match( query_nodes ) ) {
12241 query_nodes = new HashSet<PhylogenyNode>();
12242 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12243 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12244 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12245 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12246 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12247 if ( !s0.match( query_nodes ) ) {
12250 query_nodes = new HashSet<PhylogenyNode>();
12251 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12252 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12253 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12254 if ( !s0.match( query_nodes ) ) {
12257 query_nodes = new HashSet<PhylogenyNode>();
12258 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12259 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12260 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12261 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12262 if ( !s0.match( query_nodes ) ) {
12265 query_nodes = new HashSet<PhylogenyNode>();
12266 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12267 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12268 if ( s0.match( query_nodes ) ) {
12271 query_nodes = new HashSet<PhylogenyNode>();
12272 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12273 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12274 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12275 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12276 if ( s0.match( query_nodes ) ) {
12279 query_nodes = new HashSet<PhylogenyNode>();
12280 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12281 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12282 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12283 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12284 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12285 if ( s0.match( query_nodes ) ) {
12288 query_nodes = new HashSet<PhylogenyNode>();
12289 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12290 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12291 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12292 if ( s0.match( query_nodes ) ) {
12295 query_nodes = new HashSet<PhylogenyNode>();
12296 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12297 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12298 if ( s0.match( query_nodes ) ) {
12301 query_nodes = new HashSet<PhylogenyNode>();
12302 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12303 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12304 if ( s0.match( query_nodes ) ) {
12307 query_nodes = new HashSet<PhylogenyNode>();
12308 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12309 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12310 if ( s0.match( query_nodes ) ) {
12313 query_nodes = new HashSet<PhylogenyNode>();
12314 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12315 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12316 if ( s0.match( query_nodes ) ) {
12319 query_nodes = new HashSet<PhylogenyNode>();
12320 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12321 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12322 if ( s0.match( query_nodes ) ) {
12325 query_nodes = new HashSet<PhylogenyNode>();
12326 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12327 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12328 if ( s0.match( query_nodes ) ) {
12331 query_nodes = new HashSet<PhylogenyNode>();
12332 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12333 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12334 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12335 if ( s0.match( query_nodes ) ) {
12338 query_nodes = new HashSet<PhylogenyNode>();
12339 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12340 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12341 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12342 if ( s0.match( query_nodes ) ) {
12345 query_nodes = new HashSet<PhylogenyNode>();
12346 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12347 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12348 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12349 if ( s0.match( query_nodes ) ) {
12352 query_nodes = new HashSet<PhylogenyNode>();
12353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12355 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12356 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12357 if ( s0.match( query_nodes ) ) {
12361 // query_nodes = new HashSet<PhylogenyNode>();
12362 // query_nodes.add( new PhylogenyNode( "X" ) );
12363 // query_nodes.add( new PhylogenyNode( "Y" ) );
12364 // query_nodes.add( new PhylogenyNode( "A" ) );
12365 // query_nodes.add( new PhylogenyNode( "B" ) );
12366 // query_nodes.add( new PhylogenyNode( "C" ) );
12367 // query_nodes.add( new PhylogenyNode( "D" ) );
12368 // query_nodes.add( new PhylogenyNode( "E" ) );
12369 // query_nodes.add( new PhylogenyNode( "F" ) );
12370 // query_nodes.add( new PhylogenyNode( "G" ) );
12371 // if ( !s0.match( query_nodes ) ) {
12374 // query_nodes = new HashSet<PhylogenyNode>();
12375 // query_nodes.add( new PhylogenyNode( "X" ) );
12376 // query_nodes.add( new PhylogenyNode( "Y" ) );
12377 // query_nodes.add( new PhylogenyNode( "A" ) );
12378 // query_nodes.add( new PhylogenyNode( "B" ) );
12379 // query_nodes.add( new PhylogenyNode( "C" ) );
12380 // if ( !s0.match( query_nodes ) ) {
12384 // query_nodes = new HashSet<PhylogenyNode>();
12385 // query_nodes.add( new PhylogenyNode( "X" ) );
12386 // query_nodes.add( new PhylogenyNode( "Y" ) );
12387 // query_nodes.add( new PhylogenyNode( "D" ) );
12388 // query_nodes.add( new PhylogenyNode( "E" ) );
12389 // query_nodes.add( new PhylogenyNode( "F" ) );
12390 // query_nodes.add( new PhylogenyNode( "G" ) );
12391 // if ( !s0.match( query_nodes ) ) {
12395 // query_nodes = new HashSet<PhylogenyNode>();
12396 // query_nodes.add( new PhylogenyNode( "X" ) );
12397 // query_nodes.add( new PhylogenyNode( "Y" ) );
12398 // query_nodes.add( new PhylogenyNode( "A" ) );
12399 // query_nodes.add( new PhylogenyNode( "B" ) );
12400 // query_nodes.add( new PhylogenyNode( "C" ) );
12401 // query_nodes.add( new PhylogenyNode( "D" ) );
12402 // if ( !s0.match( query_nodes ) ) {
12406 // query_nodes = new HashSet<PhylogenyNode>();
12407 // query_nodes.add( new PhylogenyNode( "X" ) );
12408 // query_nodes.add( new PhylogenyNode( "Y" ) );
12409 // query_nodes.add( new PhylogenyNode( "E" ) );
12410 // query_nodes.add( new PhylogenyNode( "F" ) );
12411 // query_nodes.add( new PhylogenyNode( "G" ) );
12412 // if ( !s0.match( query_nodes ) ) {
12416 // query_nodes = new HashSet<PhylogenyNode>();
12417 // query_nodes.add( new PhylogenyNode( "X" ) );
12418 // query_nodes.add( new PhylogenyNode( "Y" ) );
12419 // query_nodes.add( new PhylogenyNode( "F" ) );
12420 // query_nodes.add( new PhylogenyNode( "G" ) );
12421 // if ( !s0.match( query_nodes ) ) {
12425 query_nodes = new HashSet<PhylogenyNode>();
12426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12430 if ( s0.match( query_nodes ) ) {
12434 query_nodes = new HashSet<PhylogenyNode>();
12435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12436 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12437 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12438 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12439 if ( s0.match( query_nodes ) ) {
12442 ///////////////////////////
12444 query_nodes = new HashSet<PhylogenyNode>();
12445 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12446 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12447 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12448 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12449 if ( s0.match( query_nodes ) ) {
12453 query_nodes = new HashSet<PhylogenyNode>();
12454 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12455 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12456 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12458 if ( s0.match( query_nodes ) ) {
12462 query_nodes = new HashSet<PhylogenyNode>();
12463 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12466 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12467 if ( s0.match( query_nodes ) ) {
12471 query_nodes = new HashSet<PhylogenyNode>();
12472 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12473 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12474 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12475 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12476 if ( s0.match( query_nodes ) ) {
12480 query_nodes = new HashSet<PhylogenyNode>();
12481 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12482 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12483 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12484 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12485 if ( s0.match( query_nodes ) ) {
12489 query_nodes = new HashSet<PhylogenyNode>();
12490 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12491 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12492 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12493 if ( s0.match( query_nodes ) ) {
12497 query_nodes = new HashSet<PhylogenyNode>();
12498 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12499 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12500 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12501 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12502 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12503 if ( s0.match( query_nodes ) ) {
12507 query_nodes = new HashSet<PhylogenyNode>();
12508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12510 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12511 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12512 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12513 if ( s0.match( query_nodes ) ) {
12517 query_nodes = new HashSet<PhylogenyNode>();
12518 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12519 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12520 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12522 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12523 if ( s0.match( query_nodes ) ) {
12527 query_nodes = new HashSet<PhylogenyNode>();
12528 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12529 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
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 catch ( final Exception e ) {
12539 e.printStackTrace();
12545 private static boolean testSplitStrict() {
12547 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12548 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12549 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12550 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12551 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12552 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12553 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12554 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12555 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12556 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12557 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12558 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12559 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12560 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12561 if ( s0.match( query_nodes ) ) {
12564 query_nodes = new HashSet<PhylogenyNode>();
12565 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12566 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12569 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12570 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12571 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12572 if ( !s0.match( query_nodes ) ) {
12576 query_nodes = new HashSet<PhylogenyNode>();
12577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12580 if ( !s0.match( query_nodes ) ) {
12584 query_nodes = new HashSet<PhylogenyNode>();
12585 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12586 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12588 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12589 if ( !s0.match( query_nodes ) ) {
12593 query_nodes = new HashSet<PhylogenyNode>();
12594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12598 if ( !s0.match( query_nodes ) ) {
12602 query_nodes = new HashSet<PhylogenyNode>();
12603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12606 if ( !s0.match( query_nodes ) ) {
12610 query_nodes = new HashSet<PhylogenyNode>();
12611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12613 if ( !s0.match( query_nodes ) ) {
12617 query_nodes = new HashSet<PhylogenyNode>();
12618 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12621 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12623 if ( !s0.match( query_nodes ) ) {
12627 query_nodes = new HashSet<PhylogenyNode>();
12628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12631 if ( !s0.match( query_nodes ) ) {
12635 query_nodes = new HashSet<PhylogenyNode>();
12636 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12639 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12640 if ( !s0.match( query_nodes ) ) {
12644 query_nodes = new HashSet<PhylogenyNode>();
12645 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12647 if ( s0.match( query_nodes ) ) {
12651 query_nodes = new HashSet<PhylogenyNode>();
12652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12655 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12656 if ( s0.match( query_nodes ) ) {
12660 query_nodes = new HashSet<PhylogenyNode>();
12661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12664 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12665 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12666 if ( s0.match( query_nodes ) ) {
12670 query_nodes = new HashSet<PhylogenyNode>();
12671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12674 if ( s0.match( query_nodes ) ) {
12678 query_nodes = new HashSet<PhylogenyNode>();
12679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12681 if ( s0.match( query_nodes ) ) {
12685 query_nodes = new HashSet<PhylogenyNode>();
12686 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12688 if ( s0.match( query_nodes ) ) {
12692 query_nodes = new HashSet<PhylogenyNode>();
12693 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12695 if ( s0.match( query_nodes ) ) {
12699 query_nodes = new HashSet<PhylogenyNode>();
12700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12702 if ( s0.match( query_nodes ) ) {
12706 query_nodes = new HashSet<PhylogenyNode>();
12707 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12709 if ( s0.match( query_nodes ) ) {
12713 query_nodes = new HashSet<PhylogenyNode>();
12714 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12716 if ( s0.match( query_nodes ) ) {
12720 query_nodes = new HashSet<PhylogenyNode>();
12721 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12724 if ( s0.match( query_nodes ) ) {
12728 query_nodes = new HashSet<PhylogenyNode>();
12729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12732 if ( s0.match( query_nodes ) ) {
12736 query_nodes = new HashSet<PhylogenyNode>();
12737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12740 if ( s0.match( query_nodes ) ) {
12744 query_nodes = new HashSet<PhylogenyNode>();
12745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12748 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12749 if ( s0.match( query_nodes ) ) {
12753 catch ( final Exception e ) {
12754 e.printStackTrace();
12760 private static boolean testSubtreeDeletion() {
12762 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12763 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12764 t1.deleteSubtree( t1.getNode( "A" ), false );
12765 if ( t1.getNumberOfExternalNodes() != 5 ) {
12768 t1.toNewHampshireX();
12769 t1.deleteSubtree( t1.getNode( "E" ), false );
12770 if ( t1.getNumberOfExternalNodes() != 4 ) {
12773 t1.toNewHampshireX();
12774 t1.deleteSubtree( t1.getNode( "F" ), false );
12775 if ( t1.getNumberOfExternalNodes() != 3 ) {
12778 t1.toNewHampshireX();
12779 t1.deleteSubtree( t1.getNode( "D" ), false );
12780 t1.toNewHampshireX();
12781 if ( t1.getNumberOfExternalNodes() != 3 ) {
12784 t1.deleteSubtree( t1.getNode( "def" ), false );
12785 t1.toNewHampshireX();
12786 if ( t1.getNumberOfExternalNodes() != 2 ) {
12789 t1.deleteSubtree( t1.getNode( "B" ), false );
12790 t1.toNewHampshireX();
12791 if ( t1.getNumberOfExternalNodes() != 1 ) {
12794 t1.deleteSubtree( t1.getNode( "C" ), false );
12795 t1.toNewHampshireX();
12796 if ( t1.getNumberOfExternalNodes() != 1 ) {
12799 t1.deleteSubtree( t1.getNode( "abc" ), false );
12800 t1.toNewHampshireX();
12801 if ( t1.getNumberOfExternalNodes() != 1 ) {
12804 t1.deleteSubtree( t1.getNode( "r" ), false );
12805 if ( t1.getNumberOfExternalNodes() != 0 ) {
12808 if ( !t1.isEmpty() ) {
12811 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12812 t2.deleteSubtree( t2.getNode( "A" ), false );
12813 t2.toNewHampshireX();
12814 if ( t2.getNumberOfExternalNodes() != 5 ) {
12817 t2.deleteSubtree( t2.getNode( "abc" ), false );
12818 t2.toNewHampshireX();
12819 if ( t2.getNumberOfExternalNodes() != 3 ) {
12822 t2.deleteSubtree( t2.getNode( "def" ), false );
12823 t2.toNewHampshireX();
12824 if ( t2.getNumberOfExternalNodes() != 1 ) {
12828 catch ( final Exception e ) {
12829 e.printStackTrace( System.out );
12835 private static boolean testSupportCount() {
12837 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12838 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12839 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12840 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12841 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12842 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12843 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12845 SupportCount.count( t0_1, phylogenies_1, true, false );
12846 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12847 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12848 + "(((((A,B),C),D),E),((F,G),X))"
12849 + "(((((A,Y),B),C),D),((F,G),E))"
12850 + "(((((A,B),C),D),E),(F,G))"
12851 + "(((((A,B),C),D),E),(F,G))"
12852 + "(((((A,B),C),D),E),(F,G))"
12853 + "(((((A,B),C),D),E),(F,G),Z)"
12854 + "(((((A,B),C),D),E),(F,G))"
12855 + "((((((A,B),C),D),E),F),G)"
12856 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12858 SupportCount.count( t0_2, phylogenies_2, true, false );
12859 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12860 while ( it.hasNext() ) {
12861 final PhylogenyNode n = it.next();
12862 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12866 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12867 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12868 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12869 SupportCount.count( t0_3, phylogenies_3, true, false );
12870 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12871 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12874 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12877 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12880 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12883 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12886 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12889 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12892 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12895 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12898 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12901 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12902 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12903 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12904 SupportCount.count( t0_4, phylogenies_4, true, false );
12905 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12906 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12909 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12912 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12915 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12918 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12921 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12924 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12927 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12930 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12933 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12936 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12937 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12938 double d = SupportCount.compare( b1, a, true, true, true );
12939 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12942 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12943 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12944 d = SupportCount.compare( b2, a, true, true, true );
12945 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12948 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12949 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12950 d = SupportCount.compare( b3, a, true, true, true );
12951 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12954 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12955 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12956 d = SupportCount.compare( b4, a, true, true, false );
12957 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12961 catch ( final Exception e ) {
12962 e.printStackTrace( System.out );
12968 private static boolean testSupportTransfer() {
12970 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12971 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)",
12972 new NHXParser() )[ 0 ];
12973 final Phylogeny p2 = factory
12974 .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
12975 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12978 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12981 support_transfer.moveBranchLengthsToBootstrap( p1 );
12982 support_transfer.transferSupportValues( p1, p2 );
12983 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12986 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12989 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12992 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12995 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12998 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13001 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13004 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13008 catch ( final Exception e ) {
13009 e.printStackTrace( System.out );
13015 private static boolean testTaxonomyExtraction() {
13017 final PhylogenyNode n0 = PhylogenyNode
13018 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13019 if ( n0.getNodeData().isHasTaxonomy() ) {
13022 final PhylogenyNode n1 = PhylogenyNode
13023 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13024 if ( n1.getNodeData().isHasTaxonomy() ) {
13025 System.out.println( n1.toString() );
13028 final PhylogenyNode n2x = PhylogenyNode
13029 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13030 if ( n2x.getNodeData().isHasTaxonomy() ) {
13033 final PhylogenyNode n3 = PhylogenyNode
13034 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13035 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13036 System.out.println( n3.toString() );
13039 final PhylogenyNode n4 = PhylogenyNode
13040 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13041 if ( n4.getNodeData().isHasTaxonomy() ) {
13042 System.out.println( n4.toString() );
13045 final PhylogenyNode n5 = PhylogenyNode
13046 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13047 if ( n5.getNodeData().isHasTaxonomy() ) {
13048 System.out.println( n5.toString() );
13051 final PhylogenyNode n6 = PhylogenyNode
13052 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13053 if ( n6.getNodeData().isHasTaxonomy() ) {
13054 System.out.println( n6.toString() );
13057 final PhylogenyNode n7 = PhylogenyNode
13058 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13059 if ( n7.getNodeData().isHasTaxonomy() ) {
13060 System.out.println( n7.toString() );
13063 final PhylogenyNode n8 = PhylogenyNode
13064 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13065 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13066 System.out.println( n8.toString() );
13069 final PhylogenyNode n9 = PhylogenyNode
13070 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13071 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13072 System.out.println( n9.toString() );
13075 final PhylogenyNode n10x = PhylogenyNode
13076 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13077 if ( n10x.getNodeData().isHasTaxonomy() ) {
13078 System.out.println( n10x.toString() );
13081 final PhylogenyNode n10xx = PhylogenyNode
13082 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13083 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13084 System.out.println( n10xx.toString() );
13087 final PhylogenyNode n10 = PhylogenyNode
13088 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13089 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13090 System.out.println( n10.toString() );
13093 final PhylogenyNode n11 = PhylogenyNode
13094 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13095 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13096 System.out.println( n11.toString() );
13099 final PhylogenyNode n12 = PhylogenyNode
13100 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
13101 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13102 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13103 System.out.println( n12.toString() );
13106 final PhylogenyNode n13 = PhylogenyNode
13107 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13108 if ( n13.getNodeData().isHasTaxonomy() ) {
13109 System.out.println( n13.toString() );
13112 final PhylogenyNode n14 = PhylogenyNode
13113 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13114 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13115 System.out.println( n14.toString() );
13118 final PhylogenyNode n15 = PhylogenyNode
13119 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13120 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13121 System.out.println( n15.toString() );
13124 final PhylogenyNode n16 = PhylogenyNode
13125 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13126 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13127 System.out.println( n16.toString() );
13130 final PhylogenyNode n17 = PhylogenyNode
13131 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13132 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13133 System.out.println( n17.toString() );
13136 final PhylogenyNode n18 = PhylogenyNode
13137 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13138 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13139 System.out.println( n18.toString() );
13142 final PhylogenyNode n19 = PhylogenyNode
13143 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13144 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13145 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13146 System.out.println( n19.toString() );
13149 final PhylogenyNode n20 = PhylogenyNode
13150 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13151 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13152 System.out.println( n20.toString() );
13155 final PhylogenyNode n21 = PhylogenyNode
13156 .createInstanceFromNhxString( "Mus musculus musculus K392",
13157 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13158 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13159 System.out.println( n21.toString() );
13162 final PhylogenyNode n23 = PhylogenyNode
13163 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13164 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13165 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13166 System.out.println( n23.toString() );
13169 final PhylogenyNode n24 = PhylogenyNode
13170 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13171 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13172 System.out.println( n24.toString() );
13176 final PhylogenyNode n25 = PhylogenyNode
13177 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13178 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13179 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13180 System.out.println( n25.toString() );
13183 final PhylogenyNode n26 = PhylogenyNode
13184 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13185 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13186 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13187 System.out.println( n26.toString() );
13190 final PhylogenyNode n27 = PhylogenyNode
13191 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13192 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13193 System.out.println( n27.toString() );
13197 catch ( final Exception e ) {
13198 e.printStackTrace( System.out );
13204 private static boolean testTreeCopy() {
13206 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13207 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13208 final Phylogeny t1 = t0.copy();
13209 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13212 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13215 t0.deleteSubtree( t0.getNode( "c" ), true );
13216 t0.deleteSubtree( t0.getNode( "a" ), true );
13217 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13218 t0.getNode( "b" ).setName( "Bee" );
13219 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13222 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13225 t0.deleteSubtree( t0.getNode( "e" ), true );
13226 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13227 t0.deleteSubtree( t0.getNode( "d" ), true );
13228 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13232 catch ( final Exception e ) {
13233 e.printStackTrace();
13239 private static boolean testTreeMethods() {
13241 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13242 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13243 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13244 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13245 System.out.println( t0.toNewHampshireX() );
13248 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13249 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13250 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13253 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13256 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13260 catch ( final Exception e ) {
13261 e.printStackTrace( System.out );
13267 private static boolean testUniprotEntryRetrieval() {
13269 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13270 if ( !entry.getAccession().equals( "P12345" ) ) {
13273 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13276 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13279 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13282 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13285 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13288 if ( entry.getMolecularSequence() == null ) {
13292 .getMolecularSequence()
13293 .getMolecularSequenceAsString()
13294 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13295 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13296 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13297 System.out.println( "expected something else." );
13301 catch ( final IOException e ) {
13302 System.out.println();
13303 System.out.println( "the following might be due to absence internet connection:" );
13304 e.printStackTrace( System.out );
13307 catch ( final NullPointerException f ) {
13308 f.printStackTrace( System.out );
13311 catch ( final Exception e ) {
13317 private static boolean testUniprotTaxonomySearch() {
13319 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13321 if ( results.size() != 1 ) {
13324 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13327 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13330 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13333 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13336 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13340 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13341 if ( results.size() != 1 ) {
13344 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13347 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13350 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13353 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13356 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13360 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13361 if ( results.size() != 1 ) {
13364 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13367 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13370 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13373 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13376 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13380 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13381 if ( results.size() != 1 ) {
13384 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13387 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13390 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13393 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13396 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13399 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13402 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13405 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13406 .equals( "Nematostella vectensis" ) ) {
13407 System.out.println( results.get( 0 ).getLineage() );
13412 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13413 if ( results.size() != 1 ) {
13416 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13419 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13422 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13425 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13428 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13431 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13432 .equals( "Xenopus tropicalis" ) ) {
13433 System.out.println( results.get( 0 ).getLineage() );
13438 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13439 if ( results.size() != 1 ) {
13442 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13445 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13448 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13451 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13454 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13457 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13458 .equals( "Xenopus tropicalis" ) ) {
13459 System.out.println( results.get( 0 ).getLineage() );
13464 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13465 if ( results.size() != 1 ) {
13468 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13471 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13474 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13477 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13480 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13483 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13484 .equals( "Xenopus tropicalis" ) ) {
13485 System.out.println( results.get( 0 ).getLineage() );
13489 catch ( final IOException e ) {
13490 System.out.println();
13491 System.out.println( "the following might be due to absence internet connection:" );
13492 e.printStackTrace( System.out );
13495 catch ( final Exception e ) {