2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2014 Christian M. Zmasek
6 // Copyright (C) 2014 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25 package org.forester.test;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.HashSet;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Locale;
41 import java.util.SortedSet;
43 import org.forester.application.support_transfer;
44 import org.forester.archaeopteryx.AptxUtil;
45 import org.forester.archaeopteryx.TreePanelUtil;
46 import org.forester.archaeopteryx.webservices.WebserviceUtil;
47 import org.forester.development.DevelopmentTools;
48 import org.forester.evoinference.TestPhylogenyReconstruction;
49 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
50 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
51 import org.forester.go.TestGo;
52 import org.forester.io.parsers.FastaParser;
53 import org.forester.io.parsers.GeneralMsaParser;
54 import org.forester.io.parsers.HmmscanPerDomainTableParser;
55 import org.forester.io.parsers.HmmscanPerDomainTableParser.INDIVIDUAL_SCORE_CUTOFF;
56 import org.forester.io.parsers.nexus.NexusBinaryStatesMatrixParser;
57 import org.forester.io.parsers.nexus.NexusCharactersParser;
58 import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
59 import org.forester.io.parsers.nhx.NHXParser;
60 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
61 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
62 import org.forester.io.parsers.tol.TolParser;
63 import org.forester.io.parsers.util.ParserUtils;
64 import org.forester.io.writers.PhylogenyWriter;
65 import org.forester.io.writers.SequenceWriter;
66 import org.forester.msa.BasicMsa;
67 import org.forester.msa.DeleteableMsa;
68 import org.forester.msa.Mafft;
69 import org.forester.msa.Msa;
70 import org.forester.msa.Msa.MSA_FORMAT;
71 import org.forester.msa.MsaInferrer;
72 import org.forester.msa.MsaMethods;
73 import org.forester.pccx.TestPccx;
74 import org.forester.phylogeny.Phylogeny;
75 import org.forester.phylogeny.PhylogenyBranch;
76 import org.forester.phylogeny.PhylogenyMethods;
77 import org.forester.phylogeny.PhylogenyNode;
78 import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE;
79 import org.forester.phylogeny.data.Accession;
80 import org.forester.phylogeny.data.Accession.Source;
81 import org.forester.phylogeny.data.BinaryCharacters;
82 import org.forester.phylogeny.data.BranchWidth;
83 import org.forester.phylogeny.data.Confidence;
84 import org.forester.phylogeny.data.Distribution;
85 import org.forester.phylogeny.data.DomainArchitecture;
86 import org.forester.phylogeny.data.Event;
87 import org.forester.phylogeny.data.Identifier;
88 import org.forester.phylogeny.data.PhylogenyData;
89 import org.forester.phylogeny.data.PhylogenyDataUtil;
90 import org.forester.phylogeny.data.Polygon;
91 import org.forester.phylogeny.data.PropertiesList;
92 import org.forester.phylogeny.data.Property;
93 import org.forester.phylogeny.data.Property.AppliesTo;
94 import org.forester.phylogeny.data.ProteinDomain;
95 import org.forester.phylogeny.data.Taxonomy;
96 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
97 import org.forester.phylogeny.factories.PhylogenyFactory;
98 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
99 import org.forester.protein.BasicDomain;
100 import org.forester.protein.BasicProtein;
101 import org.forester.protein.Domain;
102 import org.forester.protein.Protein;
103 import org.forester.protein.ProteinId;
104 import org.forester.rio.TestRIO;
105 import org.forester.sdi.SDI;
106 import org.forester.sdi.SDIR;
107 import org.forester.sdi.TestGSDI;
108 import org.forester.sequence.BasicSequence;
109 import org.forester.sequence.MolecularSequence;
110 import org.forester.species.BasicSpecies;
111 import org.forester.species.Species;
112 import org.forester.surfacing.TestSurfacing;
113 import org.forester.tools.ConfidenceAssessor;
114 import org.forester.tools.SupportCount;
115 import org.forester.tools.TreeSplitMatrix;
116 import org.forester.util.AsciiHistogram;
117 import org.forester.util.BasicDescriptiveStatistics;
118 import org.forester.util.BasicTable;
119 import org.forester.util.BasicTableParser;
120 import org.forester.util.DescriptiveStatistics;
121 import org.forester.util.ForesterConstants;
122 import org.forester.util.ForesterUtil;
123 import org.forester.util.GeneralTable;
124 import org.forester.util.SequenceAccessionTools;
125 import org.forester.ws.seqdb.SequenceDatabaseEntry;
126 import org.forester.ws.seqdb.SequenceDbWsTools;
127 import org.forester.ws.seqdb.UniProtTaxonomy;
129 @SuppressWarnings( "unused")
130 public final class Test {
132 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
133 + ForesterUtil.getFileSeparator() + "resources" + ForesterUtil.getFileSeparator();
134 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
135 + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator();
136 private final static boolean PERFORM_DB_TESTS = false;
137 private static final boolean PERFORM_WEB_TREE_ACCESS = false;
138 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
139 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
140 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
141 + ForesterConstants.PHYLO_XML_VERSION + "/" + ForesterConstants.PHYLO_XML_XSD;
142 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
143 private final static double ZERO_DIFF = 1.0E-9;
145 private static boolean isEqual( final double a, final double b ) {
146 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
149 public static void main( final String[] args ) {
150 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
151 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
153 Locale.setDefault( Locale.US );
154 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
157 System.out.print( "[Test if directory with files for testing exists/is readable: " );
158 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
159 System.out.println( "OK.]" );
162 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
163 System.out.println( "Testing aborted." );
166 System.out.print( "[Test if resources directory exists/is readable: " );
167 if ( testDir( PATH_TO_RESOURCES ) ) {
168 System.out.println( "OK.]" );
171 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
172 System.out.println( "Testing aborted." );
175 final long start_time = new Date().getTime();
176 System.out.print( "Basic node methods: " );
177 if ( Test.testBasicNodeMethods() ) {
178 System.out.println( "OK." );
182 System.out.println( "failed." );
185 System.out.print( "Protein id: " );
186 if ( !testProteinId() ) {
187 System.out.println( "failed." );
193 System.out.println( "OK." );
194 System.out.print( "Species: " );
195 if ( !testSpecies() ) {
196 System.out.println( "failed." );
202 System.out.println( "OK." );
203 System.out.print( "Basic domain: " );
204 if ( !testBasicDomain() ) {
205 System.out.println( "failed." );
211 System.out.println( "OK." );
212 System.out.print( "Basic protein: " );
213 if ( !testBasicProtein() ) {
214 System.out.println( "failed." );
220 System.out.println( "OK." );
221 System.out.print( "Sequence writer: " );
222 if ( testSequenceWriter() ) {
223 System.out.println( "OK." );
227 System.out.println( "failed." );
230 System.out.print( "Sequence id parsing: " );
231 if ( testSequenceIdParsing() ) {
232 System.out.println( "OK." );
236 System.out.println( "failed." );
239 System.out.print( "UniProtKB id extraction: " );
240 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
241 System.out.println( "OK." );
245 System.out.println( "failed." );
248 System.out.print( "Sequence DB tools 1: " );
249 if ( testSequenceDbWsTools1() ) {
250 System.out.println( "OK." );
254 System.out.println( "failed." );
257 System.out.print( "Hmmscan output parser: " );
258 if ( testHmmscanOutputParser() ) {
259 System.out.println( "OK." );
263 System.out.println( "failed." );
266 System.out.print( "Overlap removal: " );
267 if ( !org.forester.test.Test.testOverlapRemoval() ) {
268 System.out.println( "failed." );
274 System.out.println( "OK." );
275 System.out.print( "Engulfing overlap removal: " );
276 if ( !Test.testEngulfingOverlapRemoval() ) {
277 System.out.println( "failed." );
283 System.out.println( "OK." );
284 System.out.print( "Taxonomy data extraction: " );
285 if ( Test.testExtractTaxonomyDataFromNodeName() ) {
286 System.out.println( "OK." );
290 System.out.println( "failed." );
293 System.out.print( "Taxonomy code extraction: " );
294 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
295 System.out.println( "OK." );
299 System.out.println( "failed." );
302 System.out.print( "SN extraction: " );
303 if ( Test.testExtractSNFromNodeName() ) {
304 System.out.println( "OK." );
308 System.out.println( "failed." );
311 System.out.print( "Taxonomy extraction (general): " );
312 if ( Test.testTaxonomyExtraction() ) {
313 System.out.println( "OK." );
317 System.out.println( "failed." );
320 System.out.print( "Uri for Aptx web sequence accession: " );
321 if ( Test.testCreateUriForSeqWeb() ) {
322 System.out.println( "OK." );
326 System.out.println( "failed." );
329 System.out.print( "Basic node construction and parsing of NHX (node level): " );
330 if ( Test.testNHXNodeParsing() ) {
331 System.out.println( "OK." );
335 System.out.println( "failed." );
338 System.out.print( "Node construction and parsing of NHX (node level): " );
339 if ( Test.testNHXNodeParsing2() ) {
340 System.out.println( "OK." );
344 System.out.println( "failed." );
347 System.out.print( "NHX parsing iterating: " );
348 if ( Test.testNHParsingIter() ) {
349 System.out.println( "OK." );
353 System.out.println( "failed." );
356 System.out.print( "NH parsing: " );
357 if ( Test.testNHParsing() ) {
358 System.out.println( "OK." );
362 System.out.println( "failed." );
365 System.out.print( "NH parsing - special chars: " );
366 if ( Test.testNHParsingSpecialChars() ) {
367 System.out.println( "OK." );
371 System.out.println( "failed." );
374 System.out.print( "Conversion to NHX (node level): " );
375 if ( Test.testNHXconversion() ) {
376 System.out.println( "OK." );
380 System.out.println( "failed." );
383 System.out.print( "NHX parsing: " );
384 if ( Test.testNHXParsing() ) {
385 System.out.println( "OK." );
389 System.out.println( "failed." );
392 System.out.print( "NHX parsing with quotes: " );
393 if ( Test.testNHXParsingQuotes() ) {
394 System.out.println( "OK." );
398 System.out.println( "failed." );
401 System.out.print( "NHX parsing (MrBayes): " );
402 if ( Test.testNHXParsingMB() ) {
403 System.out.println( "OK." );
407 System.out.println( "failed." );
410 System.out.print( "Nexus characters parsing: " );
411 if ( Test.testNexusCharactersParsing() ) {
412 System.out.println( "OK." );
416 System.out.println( "failed." );
419 System.out.print( "Nexus tree parsing iterating: " );
420 if ( Test.testNexusTreeParsingIterating() ) {
421 System.out.println( "OK." );
425 System.out.println( "failed." );
428 System.out.print( "Nexus tree parsing: " );
429 if ( Test.testNexusTreeParsing() ) {
430 System.out.println( "OK." );
434 System.out.println( "failed." );
437 System.out.print( "Nexus tree parsing (translating): " );
438 if ( Test.testNexusTreeParsingTranslating() ) {
439 System.out.println( "OK." );
443 System.out.println( "failed." );
446 System.out.print( "Nexus matrix parsing: " );
447 if ( Test.testNexusMatrixParsing() ) {
448 System.out.println( "OK." );
452 System.out.println( "failed." );
455 System.out.print( "Basic phyloXML parsing: " );
456 if ( Test.testBasicPhyloXMLparsing() ) {
457 System.out.println( "OK." );
461 System.out.println( "failed." );
464 System.out.print( "Basic phyloXML parsing (validating against schema): " );
465 if ( testBasicPhyloXMLparsingValidating() ) {
466 System.out.println( "OK." );
470 System.out.println( "failed." );
473 System.out.print( "phyloXML parsing (validating against schema): " );
474 if ( testPhyloXMLparsingValidating() ) {
475 System.out.println( "OK." );
479 System.out.println( "failed." );
482 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
483 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
484 System.out.println( "OK." );
488 System.out.println( "failed." );
491 System.out.print( "phyloXML Distribution Element: " );
492 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
493 System.out.println( "OK." );
497 System.out.println( "failed." );
500 System.out.print( "Tol XML parsing: " );
501 if ( Test.testBasicTolXMLparsing() ) {
502 System.out.println( "OK." );
506 System.out.println( "failed." );
509 System.out.print( "UTF-8 parsing from file: " );
510 if ( Test.testUTF8ParsingFromFile() ) {
511 System.out.println( "OK." );
515 System.out.println( "failed." );
518 System.out.print( "Copying of node data: " );
519 if ( Test.testCopyOfNodeData() ) {
520 System.out.println( "OK." );
524 System.out.println( "failed." );
527 System.out.print( "Tree copy: " );
528 if ( Test.testTreeCopy() ) {
529 System.out.println( "OK." );
533 System.out.println( "failed." );
536 System.out.print( "Basic tree methods: " );
537 if ( Test.testBasicTreeMethods() ) {
538 System.out.println( "OK." );
542 System.out.println( "failed." );
545 System.out.print( "Tree methods: " );
546 if ( Test.testTreeMethods() ) {
547 System.out.println( "OK." );
551 System.out.println( "failed." );
554 System.out.print( "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
1187 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1188 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1191 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1192 System.out.println( phys[ 0 ].toNewHampshire() );
1195 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1196 System.out.println( phys[ 1 ].toNewHampshire() );
1199 final Phylogeny phys2[] = AptxUtil
1200 .readPhylogeniesFromUrl( new URL( s ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1201 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1204 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1205 System.out.println( phys2[ 0 ].toNewHampshire() );
1208 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1209 System.out.println( phys2[ 1 ].toNewHampshire() );
1212 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1213 + "SwissTree/ST001/consensus_tree.nhx" ),
1217 TAXONOMY_EXTRACTION.NO,
1219 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1222 if ( !phys3[ 0 ].toNewHampshire()
1223 .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))))));" ) ) {
1224 System.out.println( phys3[ 0 ].toNewHampshire() );
1227 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1228 + "SwissTree/ST001/consensus_tree.nhx" ),
1232 TAXONOMY_EXTRACTION.NO,
1234 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1237 if ( !phys4[ 0 ].toNewHampshire()
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",
1387 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1388 cde.addProteinDomain( c );
1389 cde.addProteinDomain( d );
1390 cde.addProteinDomain( e );
1391 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1392 if ( cde.getNumberOfProteinDomains() != 3 ) {
1395 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1398 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1399 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1400 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1401 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1402 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1403 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1404 fghi.addProteinDomain( f );
1405 fghi.addProteinDomain( g );
1406 fghi.addProteinDomain( h );
1407 fghi.addProteinDomain( i );
1408 fghi.addProteinDomain( i );
1409 fghi.addProteinDomain( i );
1410 fghi.addProteinDomain( i2 );
1411 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1412 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1415 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1418 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1421 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1422 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1425 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1428 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1429 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1430 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1431 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1432 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1433 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1434 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1435 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1436 jklm.addProteinDomain( j );
1437 jklm.addProteinDomain( k );
1438 jklm.addProteinDomain( l );
1439 jklm.addProteinDomain( m );
1440 jklm.addProteinDomain( m0 );
1441 jklm.addProteinDomain( m1 );
1442 jklm.addProteinDomain( m2 );
1443 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1444 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1447 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1450 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1453 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1454 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1457 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1460 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1461 final Protein od = new BasicProtein( "od", "varanus", 0 );
1462 od.addProteinDomain( only );
1463 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1464 if ( od.getNumberOfProteinDomains() != 1 ) {
1467 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1471 catch ( final Exception e ) {
1472 e.printStackTrace( System.out );
1478 private static final boolean testPfamTreeReading() {
1480 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1481 final NHXParser parser = new NHXParser();
1482 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1483 parser.setReplaceUnderscores( false );
1484 parser.setGuessRootedness( true );
1485 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1486 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1489 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1493 catch ( final Exception e ) {
1494 e.printStackTrace();
1500 private static final boolean testPhyloXMLparsingFromURL() {
1502 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1503 final URL u = new URL( s );
1504 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1505 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1508 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u, PhyloXmlParser.createPhyloXmlParser() );
1509 if ( ( phys2 == null ) || ( phys2.length != 2 ) ) {
1513 catch ( final Exception e ) {
1514 e.printStackTrace();
1520 private static final boolean testToLReading() {
1522 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1523 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, new TolParser() );
1524 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1527 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1530 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName()
1531 .equals( "Protacanthopterygii" ) ) {
1534 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1538 final URL u2 = new URL( WebserviceUtil.TOL_URL_BASE + "17706" );
1539 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, new TolParser() );
1540 if ( ( phys2 == null ) || ( phys2.length != 1 ) ) {
1543 if ( !phys2[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "17706" ) ) {
1546 if ( phys2[ 0 ].getNumberOfExternalNodes() < 5 ) {
1550 catch ( final Exception e ) {
1551 e.printStackTrace();
1557 private static final boolean testTreeBaseReading() {
1559 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "72557?format=nexus" );
1560 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1561 parser.setReplaceUnderscores( true );
1562 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1563 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1566 final URL u_1 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2406?format=nexus" );
1567 final NexusPhylogeniesParser parser_1 = new NexusPhylogeniesParser();
1568 final Phylogeny[] phys_1 = ForesterUtil.readPhylogeniesFromUrl( u_1, parser_1 );
1569 if ( ( phys_1 == null ) || ( phys_1.length != 1 ) ) {
1572 final URL u_2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "422?format=nexus" );
1573 final NexusPhylogeniesParser parser_2 = new NexusPhylogeniesParser();
1574 final Phylogeny[] phys_2 = ForesterUtil.readPhylogeniesFromUrl( u_2, parser_2 );
1575 if ( ( phys_2 == null ) || ( phys_2.length != 1 ) ) {
1578 final URL u_3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "2654?format=nexus" );
1579 final NexusPhylogeniesParser parser_3 = new NexusPhylogeniesParser();
1580 final Phylogeny[] phys_3 = ForesterUtil.readPhylogeniesFromUrl( u_3, parser_3 );
1581 if ( ( phys_3 == null ) || ( phys_3.length != 1 ) ) {
1584 final URL u_4 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1585 final NexusPhylogeniesParser parser_4 = new NexusPhylogeniesParser();
1586 final Phylogeny[] phys_4 = ForesterUtil.readPhylogeniesFromUrl( u_4, parser_4 );
1587 if ( ( phys_4 == null ) || ( phys_4.length != 1 ) ) {
1590 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1591 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1592 parser2.setReplaceUnderscores( true );
1593 final Phylogeny[] phys2 = ForesterUtil.readPhylogeniesFromUrl( u2, parser2 );
1594 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1597 final URL u3 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "14909?format=nexus" );
1598 final NexusPhylogeniesParser parser3 = new NexusPhylogeniesParser();
1599 final Phylogeny[] phys3 = ForesterUtil.readPhylogeniesFromUrl( u3, parser3 );
1600 if ( ( phys3 == null ) || ( phys3.length != 2 ) ) {
1603 final Phylogeny[] phys4 = ForesterUtil.readPhylogeniesFromUrl(
1604 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1605 + "14525?format=nexus" ),
1606 new NexusPhylogeniesParser() );
1607 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1610 final Phylogeny[] phys5 = ForesterUtil.readPhylogeniesFromUrl(
1611 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1612 + "15632?format=nexus" ),
1613 new NexusPhylogeniesParser() );
1614 if ( ( phys5 == null ) || ( phys5.length != 1 ) ) {
1617 final Phylogeny[] phys6 = ForesterUtil.readPhylogeniesFromUrl(
1618 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1619 + "10190?format=nexus" ),
1620 new NexusPhylogeniesParser() );
1621 if ( ( phys6 == null ) || ( phys6.length != 1 ) ) {
1624 final Phylogeny[] phys7 = ForesterUtil.readPhylogeniesFromUrl(
1625 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1626 + "13246?format=nexus" ),
1627 new NexusPhylogeniesParser() );
1628 if ( ( phys7 == null ) || ( phys7.length != 2 ) ) {
1631 final Phylogeny[] phys8 = ForesterUtil.readPhylogeniesFromUrl(
1632 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1633 + "11662?format=nexus" ),
1634 new NexusPhylogeniesParser() );
1635 if ( ( phys8 == null ) || ( phys8.length != 2 ) ) {
1638 final Phylogeny[] phys9 = ForesterUtil.readPhylogeniesFromUrl(
1639 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1640 + "562?format=nexus" ),
1641 new NexusPhylogeniesParser() );
1642 if ( ( phys9 == null ) || ( phys9.length != 4 ) ) {
1645 final Phylogeny[] phys16424 = ForesterUtil.readPhylogeniesFromUrl(
1646 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1647 + "16424?format=nexus" ),
1648 new NexusPhylogeniesParser() );
1649 if ( ( phys16424 == null ) || ( phys16424.length != 1 ) ) {
1652 final Phylogeny[] phys17878 = ForesterUtil.readPhylogeniesFromUrl(
1653 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1654 + "17878?format=nexus" ),
1655 new NexusPhylogeniesParser() );
1656 if ( ( phys17878 == null ) || ( phys17878.length != 17 ) ) {
1659 final Phylogeny[] phys18804 = ForesterUtil.readPhylogeniesFromUrl(
1660 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1661 + "18804?format=nexus" ),
1662 new NexusPhylogeniesParser() );
1663 if ( ( phys18804 == null ) || ( phys18804.length != 2 ) ) {
1666 final Phylogeny[] phys346 = ForesterUtil.readPhylogeniesFromUrl(
1667 new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE
1668 + "346?format=nexus" ),
1669 new NexusPhylogeniesParser() );
1670 if ( ( phys346 == null ) || ( phys346.length != 1 ) ) {
1674 catch ( final Exception e ) {
1675 e.printStackTrace();
1681 private static final boolean testTreeFamReading() {
1683 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1684 final NHXParser parser = new NHXParser();
1685 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1686 parser.setReplaceUnderscores( false );
1687 parser.setGuessRootedness( true );
1688 final Phylogeny[] phys = ForesterUtil.readPhylogeniesFromUrl( u, parser );
1689 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1692 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1696 catch ( final Exception e ) {
1697 e.printStackTrace();
1703 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1704 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1708 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1709 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1712 private static boolean testAminoAcidSequence() {
1714 final MolecularSequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1715 if ( aa1.getLength() != 13 ) {
1718 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1721 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1724 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1727 final MolecularSequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1728 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZOXU" ) ) {
1731 final MolecularSequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1732 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1735 final MolecularSequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1736 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1740 catch ( final Exception e ) {
1741 e.printStackTrace();
1747 private static boolean testBasicDomain() {
1749 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1750 if ( !pd.getDomainId().equals( "id" ) ) {
1753 if ( pd.getNumber() != 1 ) {
1756 if ( pd.getTotalCount() != 4 ) {
1759 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1762 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1763 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1764 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1765 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1766 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1767 if ( !a1.equals( a1 ) ) {
1770 if ( !a1.equals( a1_copy ) ) {
1773 if ( !a1.equals( a1_equal ) ) {
1776 if ( !a1.equals( a2 ) ) {
1779 if ( a1.equals( a3 ) ) {
1782 if ( a1.compareTo( a1 ) != 0 ) {
1785 if ( a1.compareTo( a1_copy ) != 0 ) {
1788 if ( a1.compareTo( a1_equal ) != 0 ) {
1791 if ( a1.compareTo( a2 ) != 0 ) {
1794 if ( a1.compareTo( a3 ) == 0 ) {
1798 catch ( final Exception e ) {
1799 e.printStackTrace( System.out );
1805 private static boolean testBasicNodeMethods() {
1807 if ( PhylogenyNode.getNodeCount() != 0 ) {
1810 final PhylogenyNode n1 = new PhylogenyNode();
1811 final PhylogenyNode n2 = PhylogenyNode
1812 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1813 final PhylogenyNode n3 = PhylogenyNode
1814 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1815 final PhylogenyNode n4 = PhylogenyNode
1816 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1817 if ( n1.isHasAssignedEvent() ) {
1820 if ( PhylogenyNode.getNodeCount() != 4 ) {
1823 if ( n3.getIndicator() != 0 ) {
1826 if ( n3.getNumberOfExternalNodes() != 1 ) {
1829 if ( !n3.isExternal() ) {
1832 if ( !n3.isRoot() ) {
1835 if ( !n4.getName().equals( "n4" ) ) {
1839 catch ( final Exception e ) {
1840 e.printStackTrace( System.out );
1846 private static boolean testUTF8ParsingFromFile() {
1848 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1849 final Phylogeny[] phylogenies_xml = ParserBasedPhylogenyFactory.getInstance()
1850 .create( new File( Test.PATH_TO_TEST_DATA + "chars.xml" ), xml_parser );
1851 if ( xml_parser.getErrorCount() > 0 ) {
1852 System.out.println( xml_parser.getErrorMessages().toString() );
1855 if ( phylogenies_xml.length != 1 ) {
1858 final Phylogeny[] phylogenies_xml2 = ParserBasedPhylogenyFactory.getInstance()
1859 .create( new StringBuffer( phylogenies_xml[ 0 ].toPhyloXML( 0 ) ), xml_parser );
1860 final Phylogeny[] phylogenies_nh = ParserBasedPhylogenyFactory.getInstance()
1861 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nh" ), new NHXParser() );
1862 if ( phylogenies_nh.length != 1 ) {
1865 final Phylogeny[] phylogenies_nex = ParserBasedPhylogenyFactory.getInstance()
1866 .create( new File( Test.PATH_TO_TEST_DATA + "chars.nex" ), new NexusPhylogeniesParser() );
1867 if ( phylogenies_nex.length != 1 ) {
1870 final String[] xml_n = phylogenies_xml[ 0 ].getAllExternalNodeNames();
1871 final String[] xml_n2 = phylogenies_xml2[ 0 ].getAllExternalNodeNames();
1872 final String[] nh_n = phylogenies_nh[ 0 ].getAllExternalNodeNames();
1873 final String[] nex_n = phylogenies_nex[ 0 ].getAllExternalNodeNames();
1874 final String n0 = "AQ~!@#$%^&*()_+-=\\{}|;:\"<>?,./";
1875 final String n1 = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ";
1876 final String n2 = "漢字ひらがなカタカナ";
1877 final String n3 = "อักษรไทย";
1878 final String n4 = "繁體字";
1879 final String n5 = "한글";
1880 final String n6 = "देवनागरी";
1881 final String n7 = "chữ Quốc ngữ";
1882 final String n8 = "ру́сский язы́к";
1883 final String n9 = "អក្សរខ្មែរ";
1884 if ( !xml_n[ 0 ].equals( n0 ) ) {
1885 System.out.println( xml_n[ 0 ] );
1886 System.out.println( n0 );
1889 if ( !xml_n2[ 0 ].equals( n0 ) ) {
1890 System.out.println( xml_n2[ 0 ] );
1891 System.out.println( n0 );
1894 if ( !nh_n[ 0 ].equals( n0 ) ) {
1895 System.out.println( nh_n[ 0 ] );
1896 System.out.println( n0 );
1899 if ( !nex_n[ 0 ].equals( n0 ) ) {
1900 System.out.println( nex_n[ 0 ] );
1901 System.out.println( n0 );
1904 if ( !xml_n[ 1 ].equals( n1 ) ) {
1905 System.out.println( xml_n[ 1 ] );
1906 System.out.println( n1 );
1909 if ( !xml_n2[ 1 ].equals( n1 ) ) {
1910 System.out.println( xml_n2[ 1 ] );
1911 System.out.println( n1 );
1914 if ( !nh_n[ 1 ].equals( n1 ) ) {
1915 System.out.println( nh_n[ 1 ] );
1916 System.out.println( n1 );
1919 if ( !nex_n[ 1 ].equals( n1 ) ) {
1920 System.out.println( nex_n[ 1 ] );
1921 System.out.println( n1 );
1924 if ( !xml_n[ 2 ].equals( n2 ) ) {
1925 System.out.println( xml_n[ 2 ] );
1926 System.out.println( n2 );
1929 if ( !xml_n2[ 2 ].equals( n2 ) ) {
1930 System.out.println( xml_n2[ 2 ] );
1931 System.out.println( n2 );
1934 if ( !nh_n[ 2 ].equals( n2 ) ) {
1935 System.out.println( nh_n[ 2 ] );
1936 System.out.println( n2 );
1939 if ( !nex_n[ 2 ].equals( n2 ) ) {
1940 System.out.println( nex_n[ 2 ] );
1941 System.out.println( n2 );
1945 if ( !xml_n[ 3 ].equals( n3 ) ) {
1946 System.out.println( xml_n[ 3 ] );
1947 System.out.println( n3 );
1950 if ( !xml_n2[ 3 ].equals( n3 ) ) {
1951 System.out.println( xml_n2[ 3 ] );
1952 System.out.println( n3 );
1955 if ( !nh_n[ 3 ].equals( n3 ) ) {
1956 System.out.println( nh_n[ 3 ] );
1957 System.out.println( n3 );
1960 if ( !nex_n[ 3 ].equals( n3 ) ) {
1961 System.out.println( nex_n[ 3 ] );
1962 System.out.println( n3 );
1966 if ( !xml_n[ 4 ].equals( n4 ) ) {
1967 System.out.println( xml_n[ 4 ] );
1968 System.out.println( n4 );
1971 if ( !nh_n[ 4 ].equals( n4 ) ) {
1972 System.out.println( nh_n[ 4 ] );
1973 System.out.println( n4 );
1976 if ( !nex_n[ 4 ].equals( n4 ) ) {
1977 System.out.println( nex_n[ 4 ] );
1978 System.out.println( n4 );
1982 if ( !xml_n[ 5 ].equals( n5 ) ) {
1983 System.out.println( xml_n[ 5 ] );
1984 System.out.println( n5 );
1987 if ( !nh_n[ 5 ].equals( n5 ) ) {
1988 System.out.println( nh_n[ 5 ] );
1989 System.out.println( n5 );
1992 if ( !nex_n[ 5 ].equals( n5 ) ) {
1993 System.out.println( nex_n[ 5 ] );
1994 System.out.println( n5 );
1998 if ( !xml_n[ 6 ].equals( n6 ) ) {
1999 System.out.println( xml_n[ 6 ] );
2000 System.out.println( n6 );
2003 if ( !nh_n[ 6 ].equals( n6 ) ) {
2004 System.out.println( nh_n[ 6 ] );
2005 System.out.println( n6 );
2008 if ( !nex_n[ 6 ].equals( n6 ) ) {
2009 System.out.println( nex_n[ 6 ] );
2010 System.out.println( n6 );
2014 if ( !xml_n[ 7 ].equals( n7 ) ) {
2015 System.out.println( xml_n[ 7 ] );
2016 System.out.println( n7 );
2019 if ( !nh_n[ 7 ].equals( n7 ) ) {
2020 System.out.println( nh_n[ 7 ] );
2021 System.out.println( n7 );
2024 if ( !nex_n[ 7 ].equals( n7 ) ) {
2025 System.out.println( nex_n[ 7 ] );
2026 System.out.println( n7 );
2029 if ( !xml_n[ 8 ].equals( n8 ) ) {
2030 System.out.println( xml_n[ 8 ] );
2031 System.out.println( n8 );
2034 if ( !nh_n[ 8 ].equals( n8 ) ) {
2035 System.out.println( nh_n[ 8 ] );
2036 System.out.println( n8 );
2039 if ( !nex_n[ 8 ].equals( n8 ) ) {
2040 System.out.println( nex_n[ 8 ] );
2041 System.out.println( n8 );
2044 if ( !xml_n[ 9 ].equals( n9 ) ) {
2045 System.out.println( xml_n[ 9 ] );
2046 System.out.println( n9 );
2049 if ( !xml_n2[ 9 ].equals( n9 ) ) {
2050 System.out.println( xml_n2[ 9 ] );
2051 System.out.println( n9 );
2054 if ( !nh_n[ 9 ].equals( n9 ) ) {
2055 System.out.println( nh_n[ 9 ] );
2056 System.out.println( n9 );
2059 if ( !nex_n[ 9 ].equals( n9 ) ) {
2060 System.out.println( nex_n[ 9 ] );
2061 System.out.println( n9 );
2064 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nh[ 0 ].toNewHampshire() ) ) {
2065 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2066 System.out.println( phylogenies_nh[ 0 ].toNewHampshire() );
2069 if ( !phylogenies_xml[ 0 ].toNewHampshire().equals( phylogenies_nex[ 0 ].toNewHampshire() ) ) {
2070 System.out.println( phylogenies_xml[ 0 ].toNewHampshire() );
2071 System.out.println( phylogenies_nex[ 0 ].toNewHampshire() );
2075 catch ( final Exception e ) {
2076 e.printStackTrace( System.out );
2082 private static boolean testBasicPhyloXMLparsing() {
2084 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2085 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2086 final Phylogeny[] phylogenies_0 = factory
2087 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2088 if ( xml_parser.getErrorCount() > 0 ) {
2089 System.out.println( xml_parser.getErrorMessages().toString() );
2092 if ( phylogenies_0.length != 4 ) {
2095 final Phylogeny t1 = phylogenies_0[ 0 ];
2096 final Phylogeny t2 = phylogenies_0[ 1 ];
2097 final Phylogeny t3 = phylogenies_0[ 2 ];
2098 final Phylogeny t4 = phylogenies_0[ 3 ];
2099 if ( t1.getNumberOfExternalNodes() != 1 ) {
2102 if ( !t1.isRooted() ) {
2105 if ( t1.isRerootable() ) {
2108 if ( !t1.getType().equals( "gene_tree" ) ) {
2111 if ( t2.getNumberOfExternalNodes() != 2 ) {
2114 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
2117 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
2120 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2123 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2126 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2129 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2132 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2133 .startsWith( "actgtgggggt" ) ) {
2136 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2137 .startsWith( "ctgtgatgcat" ) ) {
2140 if ( t3.getNumberOfExternalNodes() != 4 ) {
2143 if ( !t1.getName().equals( "t1" ) ) {
2146 if ( !t2.getName().equals( "t2" ) ) {
2149 if ( !t3.getName().equals( "t3" ) ) {
2152 if ( !t4.getName().equals( "t4" ) ) {
2155 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
2158 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
2161 if ( !t3.getNode( "root node" ).isDuplication() ) {
2164 if ( !t3.getNode( "node a" ).isDuplication() ) {
2167 if ( t3.getNode( "node a" ).isSpeciation() ) {
2170 if ( t3.getNode( "node bc" ).isDuplication() ) {
2173 if ( !t3.getNode( "node bc" ).isSpeciation() ) {
2176 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2179 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
2180 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2183 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2186 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
2189 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2190 .equals( "UniProtKB" ) ) {
2193 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2194 .equals( "apoptosis" ) ) {
2197 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2198 .equals( "GO:0006915" ) ) {
2201 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2202 .equals( "UniProtKB" ) ) {
2205 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2206 .equals( "experimental" ) ) {
2209 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2210 .equals( "function" ) ) {
2213 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2214 .getValue() != 1 ) {
2217 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence().getType()
2221 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2222 .equals( "apoptosis" ) ) {
2225 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2226 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2229 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2230 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2233 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2234 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2237 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2238 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2241 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2242 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2245 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2246 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2249 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2250 .equals( "GO:0005829" ) ) {
2253 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2254 .equals( "intracellular organelle" ) ) {
2257 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2260 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2261 .equals( "UniProt link" ) ) ) {
2264 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2267 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
2268 if ( x.size() != 4 ) {
2272 for( final Accession acc : x ) {
2274 if ( !acc.getSource().equals( "KEGG" ) ) {
2277 if ( !acc.getValue().equals( "hsa:596" ) ) {
2284 catch ( final Exception e ) {
2285 e.printStackTrace( System.out );
2291 private static boolean testBasicPhyloXMLparsingRoundtrip() {
2293 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2294 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
2295 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2296 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2299 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2301 final Phylogeny[] phylogenies_0 = factory
2302 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2303 if ( xml_parser.getErrorCount() > 0 ) {
2304 System.out.println( xml_parser.getErrorMessages().toString() );
2307 if ( phylogenies_0.length != 4 ) {
2310 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
2311 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
2312 if ( phylogenies_t1.length != 1 ) {
2315 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
2316 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
2319 if ( !t1_rt.isRooted() ) {
2322 if ( t1_rt.isRerootable() ) {
2325 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
2328 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
2329 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
2330 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
2331 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
2334 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
2337 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
2340 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
2343 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
2344 .startsWith( "actgtgggggt" ) ) {
2347 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
2348 .startsWith( "ctgtgatgcat" ) ) {
2351 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
2352 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
2353 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
2354 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
2355 if ( phylogenies_1.length != 1 ) {
2358 final Phylogeny t3_rt = phylogenies_1[ 0 ];
2359 if ( !t3_rt.getName().equals( "t3" ) ) {
2362 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
2365 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
2368 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
2371 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
2374 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
2375 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
2378 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
2381 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue()
2382 .equals( "Q9BZR8" ) ) {
2385 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
2386 .equals( "UniProtKB" ) ) {
2389 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2390 .equals( "apoptosis" ) ) {
2393 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
2394 .equals( "GO:0006915" ) ) {
2397 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
2398 .equals( "UniProtKB" ) ) {
2401 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
2402 .equals( "experimental" ) ) {
2405 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
2406 .equals( "function" ) ) {
2409 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2410 .getValue() != 1 ) {
2413 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2414 .getType().equals( "ml" ) ) {
2417 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2418 .equals( "apoptosis" ) ) {
2421 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2422 .getProperties( "AFFY:expression" ).get( 0 ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2425 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2426 .getProperties( "AFFY:expression" ).get( 0 ).getDataType().equals( "xsd:double" ) ) {
2429 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2430 .getProperties( "AFFY:expression" ).get( 0 ).getRef().equals( "AFFY:expression" ) ) {
2433 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2434 .getProperties( "AFFY:expression" ).get( 0 ).getUnit().equals( "AFFY:x" ) ) {
2437 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2438 .getProperties( "AFFY:expression" ).get( 0 ).getValue().equals( "0.2" ) ) {
2441 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2442 .getProperties( "MED:disease" ).get( 0 ).getValue().equals( "lymphoma" ) ) {
2445 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2446 .equals( "GO:0005829" ) ) {
2449 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2450 .equals( "intracellular organelle" ) ) {
2453 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType()
2454 .equals( "source" ) ) ) {
2457 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2458 .equals( "UniProt link" ) ) ) {
2461 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2464 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi()
2465 .equals( "10.1038/387489a0" ) ) ) {
2468 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2469 .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." ) ) ) {
2470 System.out.println( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription() );
2473 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2476 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2479 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName()
2480 .equals( "molting animals" ) ) {
2483 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2486 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2487 .equals( "ncbi" ) ) {
2490 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture()
2491 .getTotalLength() != 124 ) {
2494 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2495 .getName().equals( "B" ) ) {
2498 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2499 .getFrom() != 21 ) {
2502 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2506 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2507 .getLength() != 24 ) {
2510 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2511 .getConfidence() != 0 ) {
2514 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2515 .equals( "pfam" ) ) {
2518 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2521 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2524 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2527 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2530 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2531 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2534 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2537 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2540 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2543 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2546 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2549 if ( taxbb.getSynonyms().size() != 2 ) {
2552 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2555 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2558 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2561 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2564 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2567 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2568 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2571 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2574 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2577 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2580 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2583 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2586 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2589 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2592 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2595 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2596 .equalsIgnoreCase( "435" ) ) {
2599 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString()
2600 .equalsIgnoreCase( "416" ) ) {
2603 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2604 .equalsIgnoreCase( "443.7" ) ) {
2607 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2610 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2613 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2614 .equalsIgnoreCase( "433" ) ) {
2617 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2618 .getCrossReferences();
2619 if ( x.size() != 4 ) {
2623 for( final Accession acc : x ) {
2625 if ( !acc.getSource().equals( "KEGG" ) ) {
2628 if ( !acc.getValue().equals( "hsa:596" ) ) {
2635 catch ( final Exception e ) {
2636 e.printStackTrace( System.out );
2642 private static boolean testBasicPhyloXMLparsingValidating() {
2644 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2645 PhyloXmlParser xml_parser = null;
2647 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2649 catch ( final Exception e ) {
2650 // Do nothing -- means were not running from jar.
2652 if ( xml_parser == null ) {
2653 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2654 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2655 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2658 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2661 final Phylogeny[] phylogenies_0 = factory
2662 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml" ), xml_parser );
2663 if ( xml_parser.getErrorCount() > 0 ) {
2664 System.out.println( xml_parser.getErrorMessages().toString() );
2667 if ( phylogenies_0.length != 4 ) {
2670 final Phylogeny t1 = phylogenies_0[ 0 ];
2671 final Phylogeny t2 = phylogenies_0[ 1 ];
2672 final Phylogeny t3 = phylogenies_0[ 2 ];
2673 final Phylogeny t4 = phylogenies_0[ 3 ];
2674 if ( !t1.getName().equals( "t1" ) ) {
2677 if ( !t2.getName().equals( "t2" ) ) {
2680 if ( !t3.getName().equals( "t3" ) ) {
2683 if ( !t4.getName().equals( "t4" ) ) {
2686 if ( t1.getNumberOfExternalNodes() != 1 ) {
2689 if ( t2.getNumberOfExternalNodes() != 2 ) {
2692 if ( t3.getNumberOfExternalNodes() != 4 ) {
2695 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2696 final Phylogeny[] phylogenies_1 = factory.create( new File( x2 ), xml_parser );
2697 if ( xml_parser.getErrorCount() > 0 ) {
2698 System.out.println( "errors:" );
2699 System.out.println( xml_parser.getErrorMessages().toString() );
2702 if ( phylogenies_1.length != 4 ) {
2705 final Phylogeny[] phylogenies_2 = factory
2706 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml" ), xml_parser );
2707 if ( xml_parser.getErrorCount() > 0 ) {
2708 System.out.println( "errors:" );
2709 System.out.println( xml_parser.getErrorMessages().toString() );
2712 if ( phylogenies_2.length != 1 ) {
2715 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2718 final Phylogeny[] phylogenies_3 = factory
2719 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml" ), xml_parser );
2720 if ( xml_parser.getErrorCount() > 0 ) {
2721 System.out.println( xml_parser.getErrorMessages().toString() );
2724 if ( phylogenies_3.length != 2 ) {
2727 final Phylogeny a = phylogenies_3[ 0 ];
2728 if ( !a.getName().equals( "tree 4" ) ) {
2731 if ( a.getNumberOfExternalNodes() != 3 ) {
2734 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2737 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2740 final Phylogeny[] phylogenies_4 = factory
2741 .create( new File( Test.PATH_TO_TEST_DATA + "special_characters.xml" ), xml_parser );
2742 if ( xml_parser.getErrorCount() > 0 ) {
2743 System.out.println( xml_parser.getErrorMessages().toString() );
2746 if ( phylogenies_4.length != 1 ) {
2749 final Phylogeny s = phylogenies_4[ 0 ];
2750 if ( s.getNumberOfExternalNodes() != 6 ) {
2753 s.getNode( "first" );
2755 s.getNode( "\"<a'b&c'd\">\"" );
2756 s.getNode( "'''\"" );
2757 s.getNode( "\"\"\"" );
2758 s.getNode( "dick & doof" );
2760 catch ( final Exception e ) {
2761 e.printStackTrace( System.out );
2767 private static boolean testPhyloXMLparsingValidating() {
2769 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2770 PhyloXmlParser xml_parser = null;
2772 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2774 catch ( final Exception e ) {
2775 // Do nothing -- means were not running from jar.
2777 if ( xml_parser == null ) {
2778 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2779 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2780 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2783 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2786 final Phylogeny[] phylogenies_0 = factory
2787 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_test_1.xml" ), xml_parser );
2788 if ( xml_parser.getErrorCount() > 0 ) {
2789 System.out.println( xml_parser.getErrorMessages().toString() );
2792 if ( phylogenies_0.length != 3 ) {
2796 catch ( final Exception e ) {
2797 e.printStackTrace( System.out );
2803 private static boolean testBasicProtein() {
2805 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2806 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2807 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2808 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2809 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2810 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2811 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2812 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2813 p0.addProteinDomain( y );
2814 p0.addProteinDomain( e );
2815 p0.addProteinDomain( b );
2816 p0.addProteinDomain( c );
2817 p0.addProteinDomain( d );
2818 p0.addProteinDomain( a );
2819 p0.addProteinDomain( x );
2820 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2823 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2827 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2828 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2829 aa0.addProteinDomain( a1 );
2830 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2833 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2837 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2838 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2839 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2840 aa1.addProteinDomain( a11 );
2841 aa1.addProteinDomain( a12 );
2842 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2845 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2848 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2849 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2852 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2855 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2858 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2859 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2862 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2865 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2868 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2871 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2872 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2875 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2878 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2881 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2884 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2885 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2888 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2891 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2894 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2898 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2899 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2900 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2901 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2902 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2903 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2904 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2905 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2906 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2907 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2908 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2909 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2910 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2911 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2912 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2913 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2914 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2915 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2916 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2917 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2918 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2919 p00.addProteinDomain( y0 );
2920 p00.addProteinDomain( e0 );
2921 p00.addProteinDomain( b0 );
2922 p00.addProteinDomain( c0 );
2923 p00.addProteinDomain( d0 );
2924 p00.addProteinDomain( a0 );
2925 p00.addProteinDomain( x0 );
2926 p00.addProteinDomain( y1 );
2927 p00.addProteinDomain( y2 );
2928 p00.addProteinDomain( y3 );
2929 p00.addProteinDomain( e1 );
2930 p00.addProteinDomain( e2 );
2931 p00.addProteinDomain( e3 );
2932 p00.addProteinDomain( e4 );
2933 p00.addProteinDomain( e5 );
2934 p00.addProteinDomain( z0 );
2935 p00.addProteinDomain( z1 );
2936 p00.addProteinDomain( z2 );
2937 p00.addProteinDomain( zz0 );
2938 p00.addProteinDomain( zz1 );
2939 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2942 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2945 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2948 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2951 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" ) ) {
2954 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2955 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2956 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2957 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2958 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2959 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2960 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2961 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2962 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2963 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2964 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2965 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2966 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2967 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2968 p.addProteinDomain( B15 );
2969 p.addProteinDomain( C50 );
2970 p.addProteinDomain( A60 );
2971 p.addProteinDomain( A30 );
2972 p.addProteinDomain( C70 );
2973 p.addProteinDomain( B35 );
2974 p.addProteinDomain( B40 );
2975 p.addProteinDomain( A0 );
2976 p.addProteinDomain( A10 );
2977 p.addProteinDomain( A20 );
2978 p.addProteinDomain( B25 );
2979 p.addProteinDomain( D80 );
2980 List<String> domains_ids = new ArrayList<String>();
2981 domains_ids.add( "A" );
2982 domains_ids.add( "B" );
2983 domains_ids.add( "C" );
2984 if ( !p.contains( domains_ids, false ) ) {
2987 if ( !p.contains( domains_ids, true ) ) {
2990 domains_ids.add( "X" );
2991 if ( p.contains( domains_ids, false ) ) {
2994 if ( p.contains( domains_ids, true ) ) {
2997 domains_ids = new ArrayList<String>();
2998 domains_ids.add( "A" );
2999 domains_ids.add( "C" );
3000 domains_ids.add( "D" );
3001 if ( !p.contains( domains_ids, false ) ) {
3004 if ( !p.contains( domains_ids, true ) ) {
3007 domains_ids = new ArrayList<String>();
3008 domains_ids.add( "A" );
3009 domains_ids.add( "D" );
3010 domains_ids.add( "C" );
3011 if ( !p.contains( domains_ids, false ) ) {
3014 if ( p.contains( domains_ids, true ) ) {
3017 domains_ids = new ArrayList<String>();
3018 domains_ids.add( "A" );
3019 domains_ids.add( "A" );
3020 domains_ids.add( "B" );
3021 if ( !p.contains( domains_ids, false ) ) {
3024 if ( !p.contains( domains_ids, true ) ) {
3027 domains_ids = new ArrayList<String>();
3028 domains_ids.add( "A" );
3029 domains_ids.add( "A" );
3030 domains_ids.add( "A" );
3031 domains_ids.add( "B" );
3032 domains_ids.add( "B" );
3033 if ( !p.contains( domains_ids, false ) ) {
3036 if ( !p.contains( domains_ids, true ) ) {
3039 domains_ids = new ArrayList<String>();
3040 domains_ids.add( "A" );
3041 domains_ids.add( "A" );
3042 domains_ids.add( "B" );
3043 domains_ids.add( "A" );
3044 domains_ids.add( "B" );
3045 domains_ids.add( "B" );
3046 domains_ids.add( "A" );
3047 domains_ids.add( "B" );
3048 domains_ids.add( "C" );
3049 domains_ids.add( "A" );
3050 domains_ids.add( "C" );
3051 domains_ids.add( "D" );
3052 if ( !p.contains( domains_ids, false ) ) {
3055 if ( p.contains( domains_ids, true ) ) {
3059 catch ( final Exception e ) {
3060 e.printStackTrace( System.out );
3066 private static boolean testBasicTable() {
3068 final BasicTable<String> t0 = new BasicTable<String>();
3069 if ( t0.getNumberOfColumns() != 0 ) {
3072 if ( t0.getNumberOfRows() != 0 ) {
3075 t0.setValue( 3, 2, "23" );
3076 t0.setValue( 10, 1, "error" );
3077 t0.setValue( 10, 1, "110" );
3078 t0.setValue( 9, 1, "19" );
3079 t0.setValue( 1, 10, "101" );
3080 t0.setValue( 10, 10, "1010" );
3081 t0.setValue( 100, 10, "10100" );
3082 t0.setValue( 0, 0, "00" );
3083 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
3086 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
3089 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
3092 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
3095 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
3098 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
3101 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
3104 if ( t0.getNumberOfColumns() != 101 ) {
3107 if ( t0.getNumberOfRows() != 11 ) {
3110 if ( t0.getValueAsString( 49, 4 ) != null ) {
3113 final String l = ForesterUtil.getLineSeparator();
3114 final StringBuffer source = new StringBuffer();
3115 source.append( "" + l );
3116 source.append( "# 1 1 1 1 1 1 1 1" + l );
3117 source.append( " 00 01 02 03" + l );
3118 source.append( " 10 11 12 13 " + l );
3119 source.append( "20 21 22 23 " + l );
3120 source.append( " 30 31 32 33" + l );
3121 source.append( "40 41 42 43" + l );
3122 source.append( " # 1 1 1 1 1 " + l );
3123 source.append( "50 51 52 53 54" + l );
3124 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
3125 if ( t1.getNumberOfColumns() != 5 ) {
3128 if ( t1.getNumberOfRows() != 6 ) {
3131 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
3134 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
3137 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
3140 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
3143 final StringBuffer source1 = new StringBuffer();
3144 source1.append( "" + l );
3145 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3146 source1.append( " 00; 01 ;02;03" + l );
3147 source1.append( " 10; 11; 12; 13 " + l );
3148 source1.append( "20; 21; 22; 23 " + l );
3149 source1.append( " 30; 31; 32; 33" + l );
3150 source1.append( "40;41;42;43" + l );
3151 source1.append( " # 1 1 1 1 1 " + l );
3152 source1.append( ";;;50 ; ;52; 53;;54 " + l );
3153 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
3154 if ( t2.getNumberOfColumns() != 5 ) {
3157 if ( t2.getNumberOfRows() != 6 ) {
3160 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
3163 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
3166 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
3169 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
3172 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
3175 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
3178 final StringBuffer source2 = new StringBuffer();
3179 source2.append( "" + l );
3180 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
3181 source2.append( " 00; 01 ;02;03" + l );
3182 source2.append( " 10; 11; 12; 13 " + l );
3183 source2.append( "20; 21; 22; 23 " + l );
3184 source2.append( " " + l );
3185 source2.append( " 30; 31; 32; 33" + l );
3186 source2.append( "40;41;42;43" + l );
3187 source2.append( " comment: 1 1 1 1 1 " + l );
3188 source2.append( ";;;50 ; 52; 53;;54 " + l );
3189 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
3195 if ( tl.size() != 2 ) {
3198 final BasicTable<String> t3 = tl.get( 0 );
3199 final BasicTable<String> t4 = tl.get( 1 );
3200 if ( t3.getNumberOfColumns() != 4 ) {
3203 if ( t3.getNumberOfRows() != 3 ) {
3206 if ( t4.getNumberOfColumns() != 4 ) {
3209 if ( t4.getNumberOfRows() != 3 ) {
3212 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
3215 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
3219 catch ( final Exception e ) {
3220 e.printStackTrace( System.out );
3226 private static boolean testBasicTolXMLparsing() {
3228 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3229 final TolParser parser = new TolParser();
3230 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
3231 if ( parser.getErrorCount() > 0 ) {
3232 System.out.println( parser.getErrorMessages().toString() );
3235 if ( phylogenies_0.length != 1 ) {
3238 final Phylogeny t1 = phylogenies_0[ 0 ];
3239 if ( t1.getNumberOfExternalNodes() != 5 ) {
3242 if ( !t1.isRooted() ) {
3245 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
3248 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
3251 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3252 .equals( "Rhombozoa" ) ) {
3255 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
3258 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
3259 if ( parser.getErrorCount() > 0 ) {
3260 System.out.println( parser.getErrorMessages().toString() );
3263 if ( phylogenies_1.length != 1 ) {
3266 final Phylogeny t2 = phylogenies_1[ 0 ];
3267 if ( t2.getNumberOfExternalNodes() != 664 ) {
3270 if ( !t2.isRooted() ) {
3273 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
3276 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
3279 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3282 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
3285 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3286 .equals( "Aquificae" ) ) {
3289 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
3290 .equals( "Aquifex" ) ) {
3293 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
3294 if ( parser.getErrorCount() > 0 ) {
3295 System.out.println( parser.getErrorMessages().toString() );
3298 if ( phylogenies_2.length != 1 ) {
3301 final Phylogeny t3 = phylogenies_2[ 0 ];
3302 if ( t3.getNumberOfExternalNodes() != 184 ) {
3305 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
3308 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
3311 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
3314 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
3315 if ( parser.getErrorCount() > 0 ) {
3316 System.out.println( parser.getErrorMessages().toString() );
3319 if ( phylogenies_3.length != 1 ) {
3322 final Phylogeny t4 = phylogenies_3[ 0 ];
3323 if ( t4.getNumberOfExternalNodes() != 1 ) {
3326 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
3329 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
3332 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
3335 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
3336 if ( parser.getErrorCount() > 0 ) {
3337 System.out.println( parser.getErrorMessages().toString() );
3340 if ( phylogenies_4.length != 1 ) {
3343 final Phylogeny t5 = phylogenies_4[ 0 ];
3344 if ( t5.getNumberOfExternalNodes() != 13 ) {
3347 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
3350 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
3353 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
3357 catch ( final Exception e ) {
3358 e.printStackTrace( System.out );
3364 private static boolean testBasicTreeMethods() {
3366 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3367 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
3368 if ( t2.getNumberOfExternalNodes() != 4 ) {
3371 if ( t2.calculateHeight( false ) != 8.5 ) {
3374 if ( !t2.isCompletelyBinary() ) {
3377 if ( t2.isEmpty() ) {
3380 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
3381 if ( t3.getNumberOfExternalNodes() != 5 ) {
3384 if ( t3.calculateHeight( true ) != 11 ) {
3387 if ( t3.isCompletelyBinary() ) {
3390 final PhylogenyNode n = t3.getNode( "ABC" );
3391 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))",
3392 new NHXParser() )[ 0 ];
3393 if ( t4.getNumberOfExternalNodes() != 9 ) {
3396 if ( t4.calculateHeight( false ) != 11 ) {
3399 if ( t4.isCompletelyBinary() ) {
3402 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)" );
3403 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
3404 if ( t5.getNumberOfExternalNodes() != 8 ) {
3407 if ( t5.calculateHeight( false ) != 15 ) {
3410 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)" );
3411 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
3412 if ( t6.calculateHeight( true ) != 15 ) {
3415 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)" );
3416 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
3417 if ( t7.calculateHeight( true ) != 15 ) {
3420 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)" );
3421 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
3422 if ( t8.getNumberOfExternalNodes() != 10 ) {
3425 if ( t8.calculateHeight( true ) != 15 ) {
3428 final char[] a9 = new char[] { 'a' };
3429 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
3430 if ( t9.calculateHeight( true ) != 0 ) {
3433 final char[] a10 = new char[] { 'a', ':', '6' };
3434 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
3435 if ( t10.calculateHeight( true ) != 6 ) {
3439 catch ( final Exception e ) {
3440 e.printStackTrace( System.out );
3446 private static boolean testConfidenceAssessor() {
3448 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3449 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3450 final Phylogeny[] ev0 = factory.create(
3451 "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
3453 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
3454 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3457 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3460 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3461 final Phylogeny[] ev1 = factory.create(
3462 "((((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)));",
3464 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3465 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3468 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3471 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3472 final Phylogeny[] ev_b = factory.create(
3473 "((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",
3475 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3476 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3479 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3483 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3484 final Phylogeny[] ev1x = factory.create(
3485 "((((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)));",
3487 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3488 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3491 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3494 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3495 final Phylogeny[] ev_bx = factory.create(
3496 "((((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",
3498 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3499 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3502 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3505 final Phylogeny[] t2 = factory.create(
3506 "((((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);",
3508 final Phylogeny[] ev2 = factory.create(
3509 "((((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);",
3511 for( final Phylogeny target : t2 ) {
3512 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3514 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3515 new NHXParser() )[ 0 ];
3516 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3517 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3518 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3521 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3524 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3528 catch ( final Exception e ) {
3529 e.printStackTrace();
3535 private static boolean testCopyOfNodeData() {
3537 final PhylogenyNode n1 = PhylogenyNode
3538 .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]" );
3539 final PhylogenyNode n2 = n1.copyNodeData();
3540 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3544 catch ( final Exception e ) {
3545 e.printStackTrace();
3551 private static boolean testCreateBalancedPhylogeny() {
3553 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3554 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3557 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3560 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3561 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3564 if ( p1.getNumberOfExternalNodes() != 100 ) {
3568 catch ( final Exception e ) {
3569 e.printStackTrace();
3575 private static boolean testCreateUriForSeqWeb() {
3577 final PhylogenyNode n = new PhylogenyNode();
3578 n.setName( "tr|B3RJ64" );
3579 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3582 n.setName( "B0LM41_HUMAN" );
3583 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3584 .equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3587 n.setName( "NP_001025424" );
3588 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3589 .equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3592 n.setName( "_NM_001030253-" );
3593 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3594 .equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3597 n.setName( "XM_002122186" );
3598 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null )
3599 .equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3602 n.setName( "dgh_AAA34956_gdg" );
3603 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3606 n.setName( "AAA34956" );
3607 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3610 n.setName( "GI:394892" );
3611 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3612 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3615 n.setName( "gi_394892" );
3616 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3617 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3620 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3621 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3622 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3625 n.setName( "P12345" );
3626 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3627 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3630 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3631 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3632 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3636 catch ( final Exception e ) {
3637 e.printStackTrace( System.out );
3643 private static boolean testDataObjects() {
3645 final Confidence s0 = new Confidence();
3646 final Confidence s1 = new Confidence();
3647 if ( !s0.isEqual( s1 ) ) {
3650 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3651 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3652 if ( s2.isEqual( s1 ) ) {
3655 if ( !s2.isEqual( s3 ) ) {
3658 final Confidence s4 = ( Confidence ) s3.copy();
3659 if ( !s4.isEqual( s3 ) ) {
3666 final Taxonomy t1 = new Taxonomy();
3667 final Taxonomy t2 = new Taxonomy();
3668 final Taxonomy t3 = new Taxonomy();
3669 final Taxonomy t4 = new Taxonomy();
3670 final Taxonomy t5 = new Taxonomy();
3671 t1.setIdentifier( new Identifier( "ecoli" ) );
3672 t1.setTaxonomyCode( "ECOLI" );
3673 t1.setScientificName( "E. coli" );
3674 t1.setCommonName( "coli" );
3675 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3676 if ( !t1.isEqual( t0 ) ) {
3679 t2.setIdentifier( new Identifier( "ecoli" ) );
3680 t2.setTaxonomyCode( "OTHER" );
3681 t2.setScientificName( "what" );
3682 t2.setCommonName( "something" );
3683 if ( !t1.isEqual( t2 ) ) {
3686 t2.setIdentifier( new Identifier( "nemve" ) );
3687 if ( t1.isEqual( t2 ) ) {
3690 t1.setIdentifier( null );
3691 t3.setTaxonomyCode( "ECOLI" );
3692 t3.setScientificName( "what" );
3693 t3.setCommonName( "something" );
3694 if ( !t1.isEqual( t3 ) ) {
3697 t1.setIdentifier( null );
3698 t1.setTaxonomyCode( "" );
3699 t4.setScientificName( "E. ColI" );
3700 t4.setCommonName( "something" );
3701 if ( !t1.isEqual( t4 ) ) {
3704 t4.setScientificName( "B. subtilis" );
3705 t4.setCommonName( "something" );
3706 if ( t1.isEqual( t4 ) ) {
3709 t1.setIdentifier( null );
3710 t1.setTaxonomyCode( "" );
3711 t1.setScientificName( "" );
3712 t5.setCommonName( "COLI" );
3713 if ( !t1.isEqual( t5 ) ) {
3716 t5.setCommonName( "vibrio" );
3717 if ( t1.isEqual( t5 ) ) {
3722 final Identifier id0 = new Identifier( "123", "pfam" );
3723 final Identifier id1 = ( Identifier ) id0.copy();
3724 if ( !id1.isEqual( id1 ) ) {
3727 if ( !id1.isEqual( id0 ) ) {
3730 if ( !id0.isEqual( id1 ) ) {
3737 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3738 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3739 if ( !pd1.isEqual( pd1 ) ) {
3742 if ( !pd1.isEqual( pd0 ) ) {
3747 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3748 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3749 if ( !pd3.isEqual( pd3 ) ) {
3752 if ( !pd2.isEqual( pd3 ) ) {
3755 if ( !pd0.isEqual( pd3 ) ) {
3760 // DomainArchitecture
3761 // ------------------
3762 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3763 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3764 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3765 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3766 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3767 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3772 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3773 if ( ds0.getNumberOfDomains() != 4 ) {
3776 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3777 if ( !ds0.isEqual( ds0 ) ) {
3780 if ( !ds0.isEqual( ds1 ) ) {
3783 if ( ds1.getNumberOfDomains() != 4 ) {
3786 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3791 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3792 if ( ds0.isEqual( ds2 ) ) {
3798 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3799 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3800 System.out.println( ds3.toNHX() );
3803 if ( ds3.getNumberOfDomains() != 3 ) {
3808 final Event e1 = new Event( Event.EventType.fusion );
3809 if ( e1.isDuplication() ) {
3812 if ( !e1.isFusion() ) {
3815 if ( !e1.asText().toString().equals( "fusion" ) ) {
3818 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3821 final Event e11 = new Event( Event.EventType.fusion );
3822 if ( !e11.isEqual( e1 ) ) {
3825 if ( !e11.toNHX().toString().equals( "" ) ) {
3828 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3829 if ( e2.isDuplication() ) {
3832 if ( !e2.isSpeciationOrDuplication() ) {
3835 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3838 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3841 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3844 if ( e11.isEqual( e2 ) ) {
3847 final Event e2c = ( Event ) e2.copy();
3848 if ( !e2c.isEqual( e2 ) ) {
3851 Event e3 = new Event( 1, 2, 3 );
3852 if ( e3.isDuplication() ) {
3855 if ( e3.isSpeciation() ) {
3858 if ( e3.isGeneLoss() ) {
3861 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3864 final Event e3c = ( Event ) e3.copy();
3865 final Event e3cc = ( Event ) e3c.copy();
3866 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3870 if ( !e3c.isEqual( e3cc ) ) {
3873 Event e4 = new Event( 1, 2, 3 );
3874 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3877 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3880 final Event e4c = ( Event ) e4.copy();
3882 final Event e4cc = ( Event ) e4c.copy();
3883 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3886 if ( !e4c.isEqual( e4cc ) ) {
3889 final Event e5 = new Event();
3890 if ( !e5.isUnassigned() ) {
3893 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3896 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3899 final Event e6 = new Event( 1, 0, 0 );
3900 if ( !e6.asText().toString().equals( "duplication" ) ) {
3903 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3906 final Event e7 = new Event( 0, 1, 0 );
3907 if ( !e7.asText().toString().equals( "speciation" ) ) {
3910 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3913 final Event e8 = new Event( 0, 0, 1 );
3914 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3917 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3921 catch ( final Exception e ) {
3922 e.printStackTrace( System.out );
3928 private static boolean testDeletionOfExternalNodes() {
3930 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3931 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3932 final PhylogenyWriter w = new PhylogenyWriter();
3933 if ( t0.isEmpty() ) {
3936 if ( t0.getNumberOfExternalNodes() != 1 ) {
3939 t0.deleteSubtree( t0.getNode( "A" ), false );
3940 if ( t0.getNumberOfExternalNodes() != 0 ) {
3943 if ( !t0.isEmpty() ) {
3946 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3947 if ( t1.getNumberOfExternalNodes() != 2 ) {
3950 t1.deleteSubtree( t1.getNode( "A" ), false );
3951 if ( t1.getNumberOfExternalNodes() != 1 ) {
3954 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3957 t1.deleteSubtree( t1.getNode( "B" ), false );
3958 if ( t1.getNumberOfExternalNodes() != 1 ) {
3961 t1.deleteSubtree( t1.getNode( "r" ), false );
3962 if ( !t1.isEmpty() ) {
3965 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3966 if ( t2.getNumberOfExternalNodes() != 3 ) {
3969 t2.deleteSubtree( t2.getNode( "B" ), false );
3970 if ( t2.getNumberOfExternalNodes() != 2 ) {
3973 t2.toNewHampshireX();
3974 PhylogenyNode n = t2.getNode( "A" );
3975 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3978 t2.deleteSubtree( t2.getNode( "A" ), false );
3979 if ( t2.getNumberOfExternalNodes() != 2 ) {
3982 t2.deleteSubtree( t2.getNode( "C" ), true );
3983 if ( t2.getNumberOfExternalNodes() != 1 ) {
3986 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3987 if ( t3.getNumberOfExternalNodes() != 4 ) {
3990 t3.deleteSubtree( t3.getNode( "B" ), true );
3991 if ( t3.getNumberOfExternalNodes() != 3 ) {
3994 n = t3.getNode( "A" );
3995 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3998 n = n.getNextExternalNode();
3999 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4002 t3.deleteSubtree( t3.getNode( "A" ), true );
4003 if ( t3.getNumberOfExternalNodes() != 2 ) {
4006 n = t3.getNode( "C" );
4007 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
4010 t3.deleteSubtree( t3.getNode( "C" ), true );
4011 if ( t3.getNumberOfExternalNodes() != 1 ) {
4014 t3.deleteSubtree( t3.getNode( "D" ), true );
4015 if ( t3.getNumberOfExternalNodes() != 0 ) {
4018 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4019 if ( t4.getNumberOfExternalNodes() != 6 ) {
4022 t4.deleteSubtree( t4.getNode( "B2" ), true );
4023 if ( t4.getNumberOfExternalNodes() != 5 ) {
4026 String s = w.toNewHampshire( t4, true ).toString();
4027 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4030 t4.deleteSubtree( t4.getNode( "B11" ), true );
4031 if ( t4.getNumberOfExternalNodes() != 4 ) {
4034 t4.deleteSubtree( t4.getNode( "C" ), true );
4035 if ( t4.getNumberOfExternalNodes() != 3 ) {
4038 n = t4.getNode( "A" );
4039 n = n.getNextExternalNode();
4040 if ( !n.getName().equals( "B12" ) ) {
4043 n = n.getNextExternalNode();
4044 if ( !n.getName().equals( "D" ) ) {
4047 s = w.toNewHampshire( t4, true ).toString();
4048 if ( !s.equals( "((A,B12),D);" ) ) {
4051 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4052 t5.deleteSubtree( t5.getNode( "A" ), true );
4053 if ( t5.getNumberOfExternalNodes() != 5 ) {
4056 s = w.toNewHampshire( t5, true ).toString();
4057 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
4060 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4061 t6.deleteSubtree( t6.getNode( "B11" ), true );
4062 if ( t6.getNumberOfExternalNodes() != 5 ) {
4065 s = w.toNewHampshire( t6, false ).toString();
4066 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
4069 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4070 t7.deleteSubtree( t7.getNode( "B12" ), true );
4071 if ( t7.getNumberOfExternalNodes() != 5 ) {
4074 s = w.toNewHampshire( t7, true ).toString();
4075 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
4078 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4079 t8.deleteSubtree( t8.getNode( "B2" ), true );
4080 if ( t8.getNumberOfExternalNodes() != 5 ) {
4083 s = w.toNewHampshire( t8, false ).toString();
4084 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
4087 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4088 t9.deleteSubtree( t9.getNode( "C" ), true );
4089 if ( t9.getNumberOfExternalNodes() != 5 ) {
4092 s = w.toNewHampshire( t9, true ).toString();
4093 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
4096 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
4097 t10.deleteSubtree( t10.getNode( "D" ), true );
4098 if ( t10.getNumberOfExternalNodes() != 5 ) {
4101 s = w.toNewHampshire( t10, true ).toString();
4102 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
4105 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
4106 t11.deleteSubtree( t11.getNode( "A" ), true );
4107 if ( t11.getNumberOfExternalNodes() != 2 ) {
4110 s = w.toNewHampshire( t11, true ).toString();
4111 if ( !s.equals( "(B,C);" ) ) {
4114 t11.deleteSubtree( t11.getNode( "C" ), true );
4115 if ( t11.getNumberOfExternalNodes() != 1 ) {
4118 s = w.toNewHampshire( t11, false ).toString();
4119 if ( !s.equals( "B;" ) ) {
4122 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
4123 t12.deleteSubtree( t12.getNode( "B2" ), true );
4124 if ( t12.getNumberOfExternalNodes() != 8 ) {
4127 s = w.toNewHampshire( t12, true ).toString();
4128 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
4131 t12.deleteSubtree( t12.getNode( "B3" ), true );
4132 if ( t12.getNumberOfExternalNodes() != 7 ) {
4135 s = w.toNewHampshire( t12, true ).toString();
4136 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
4139 t12.deleteSubtree( t12.getNode( "C3" ), true );
4140 if ( t12.getNumberOfExternalNodes() != 6 ) {
4143 s = w.toNewHampshire( t12, true ).toString();
4144 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
4147 t12.deleteSubtree( t12.getNode( "A1" ), true );
4148 if ( t12.getNumberOfExternalNodes() != 5 ) {
4151 s = w.toNewHampshire( t12, true ).toString();
4152 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
4155 t12.deleteSubtree( t12.getNode( "B1" ), true );
4156 if ( t12.getNumberOfExternalNodes() != 4 ) {
4159 s = w.toNewHampshire( t12, true ).toString();
4160 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
4163 t12.deleteSubtree( t12.getNode( "A3" ), true );
4164 if ( t12.getNumberOfExternalNodes() != 3 ) {
4167 s = w.toNewHampshire( t12, true ).toString();
4168 if ( !s.equals( "(A2,(C1,C2));" ) ) {
4171 t12.deleteSubtree( t12.getNode( "A2" ), true );
4172 if ( t12.getNumberOfExternalNodes() != 2 ) {
4175 s = w.toNewHampshire( t12, true ).toString();
4176 if ( !s.equals( "(C1,C2);" ) ) {
4179 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
4180 t13.deleteSubtree( t13.getNode( "D" ), true );
4181 if ( t13.getNumberOfExternalNodes() != 4 ) {
4184 s = w.toNewHampshire( t13, true ).toString();
4185 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
4188 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
4189 t14.deleteSubtree( t14.getNode( "E" ), true );
4190 if ( t14.getNumberOfExternalNodes() != 5 ) {
4193 s = w.toNewHampshire( t14, true ).toString();
4194 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
4197 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
4198 t15.deleteSubtree( t15.getNode( "B2" ), true );
4199 if ( t15.getNumberOfExternalNodes() != 11 ) {
4202 t15.deleteSubtree( t15.getNode( "B1" ), true );
4203 if ( t15.getNumberOfExternalNodes() != 10 ) {
4206 t15.deleteSubtree( t15.getNode( "B3" ), true );
4207 if ( t15.getNumberOfExternalNodes() != 9 ) {
4210 t15.deleteSubtree( t15.getNode( "B4" ), true );
4211 if ( t15.getNumberOfExternalNodes() != 8 ) {
4214 t15.deleteSubtree( t15.getNode( "A1" ), true );
4215 if ( t15.getNumberOfExternalNodes() != 7 ) {
4218 t15.deleteSubtree( t15.getNode( "C4" ), true );
4219 if ( t15.getNumberOfExternalNodes() != 6 ) {
4223 catch ( final Exception e ) {
4224 e.printStackTrace( System.out );
4230 private static boolean testDescriptiveStatistics() {
4232 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
4233 dss1.addValue( 82 );
4234 dss1.addValue( 78 );
4235 dss1.addValue( 70 );
4236 dss1.addValue( 58 );
4237 dss1.addValue( 42 );
4238 if ( dss1.getN() != 5 ) {
4241 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
4244 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
4247 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
4250 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
4253 if ( !Test.isEqual( dss1.median(), 70 ) ) {
4256 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
4259 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
4262 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
4265 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
4268 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
4271 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
4274 dss1.addValue( 123 );
4275 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
4278 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
4281 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
4284 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
4285 dss2.addValue( -1.85 );
4286 dss2.addValue( 57.5 );
4287 dss2.addValue( 92.78 );
4288 dss2.addValue( 57.78 );
4289 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
4292 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
4295 final double[] a = dss2.getDataAsDoubleArray();
4296 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
4299 dss2.addValue( -100 );
4300 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
4303 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
4306 final double[] ds = new double[ 14 ];
4321 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
4322 if ( bins.length != 4 ) {
4325 if ( bins[ 0 ] != 2 ) {
4328 if ( bins[ 1 ] != 3 ) {
4331 if ( bins[ 2 ] != 4 ) {
4334 if ( bins[ 3 ] != 5 ) {
4337 final double[] ds1 = new double[ 9 ];
4347 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
4348 if ( bins1.length != 4 ) {
4351 if ( bins1[ 0 ] != 2 ) {
4354 if ( bins1[ 1 ] != 3 ) {
4357 if ( bins1[ 2 ] != 0 ) {
4360 if ( bins1[ 3 ] != 4 ) {
4363 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
4364 if ( bins1_1.length != 3 ) {
4367 if ( bins1_1[ 0 ] != 3 ) {
4370 if ( bins1_1[ 1 ] != 2 ) {
4373 if ( bins1_1[ 2 ] != 4 ) {
4376 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
4377 if ( bins1_2.length != 3 ) {
4380 if ( bins1_2[ 0 ] != 2 ) {
4383 if ( bins1_2[ 1 ] != 2 ) {
4386 if ( bins1_2[ 2 ] != 2 ) {
4389 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
4403 dss3.addValue( 10 );
4404 dss3.addValue( 10 );
4405 dss3.addValue( 10 );
4406 final AsciiHistogram histo = new AsciiHistogram( dss3 );
4407 histo.toStringBuffer( 10, '=', 40, 5 );
4408 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
4410 catch ( final Exception e ) {
4411 e.printStackTrace( System.out );
4417 private static boolean testDir( final String file ) {
4419 final File f = new File( file );
4420 if ( !f.exists() ) {
4423 if ( !f.isDirectory() ) {
4426 if ( !f.canRead() ) {
4430 catch ( final Exception e ) {
4436 private static boolean testEbiEntryRetrieval() {
4438 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
4439 if ( !entry.getAccession().equals( "AAK41263" ) ) {
4440 System.out.println( entry.getAccession() );
4443 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
4444 System.out.println( entry.getTaxonomyScientificName() );
4447 if ( !entry.getSequenceName()
4448 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
4449 System.out.println( entry.getSequenceName() );
4452 if ( !entry.getGeneName().equals( "treX-like" ) ) {
4453 System.out.println( entry.getGeneName() );
4456 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4457 System.out.println( entry.getTaxonomyIdentifier() );
4460 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4461 System.out.println( entry.getAnnotations().first().getRefValue() );
4464 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4465 System.out.println( entry.getAnnotations().first().getRefSource() );
4468 if ( entry.getCrossReferences().size() < 1 ) {
4471 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4472 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4475 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4476 System.out.println( entry1.getTaxonomyScientificName() );
4479 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4480 System.out.println( entry1.getSequenceName() );
4483 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4484 System.out.println( entry1.getTaxonomyIdentifier() );
4487 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4488 System.out.println( entry1.getGeneName() );
4491 if ( entry1.getCrossReferences().size() < 1 ) {
4494 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4495 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4498 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4499 System.out.println( entry2.getTaxonomyScientificName() );
4502 if ( !entry2.getSequenceName()
4503 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4504 System.out.println( entry2.getSequenceName() );
4507 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4508 System.out.println( entry2.getTaxonomyIdentifier() );
4511 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4512 System.out.println( entry2.getGeneName() );
4515 if ( entry2.getCrossReferences().size() < 1 ) {
4518 if ( !entry2.getChromosome().equals( "20" ) ) {
4521 if ( !entry2.getMap().equals( "20q11.22" ) ) {
4524 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4525 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4528 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4529 System.out.println( entry3.getTaxonomyScientificName() );
4532 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4533 System.out.println( entry3.getSequenceName() );
4536 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4537 System.out.println( entry3.getTaxonomyIdentifier() );
4540 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4541 System.out.println( entry3.getSequenceSymbol() );
4544 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4547 if ( entry3.getCrossReferences().size() < 1 ) {
4550 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4551 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4554 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4555 System.out.println( entry4.getTaxonomyScientificName() );
4558 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4559 System.out.println( entry4.getSequenceName() );
4562 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4563 System.out.println( entry4.getTaxonomyIdentifier() );
4566 if ( !entry4.getGeneName().equals( "ras" ) ) {
4567 System.out.println( entry4.getGeneName() );
4570 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4571 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4574 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4575 System.out.println( entry5.getTaxonomyScientificName() );
4578 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4579 System.out.println( entry5.getSequenceName() );
4582 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4583 System.out.println( entry5.getTaxonomyIdentifier() );
4586 final SequenceDatabaseEntry entry6 = SequenceDbWsTools.obtainEntry( "M30539" );
4587 if ( !entry6.getAccession().equals( "M30539" ) ) {
4590 if ( !entry6.getGeneName().equals( "ras" ) ) {
4593 if ( !entry6.getSequenceName().equals( "Human SK2 c-Ha-ras-1 oncogene-encoded protein gene, exon 1" ) ) {
4596 if ( !entry6.getTaxonomyIdentifier().equals( "9606" ) ) {
4599 if ( !entry6.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4602 if ( entry6.getCrossReferences().size() < 1 ) {
4606 catch ( final IOException e ) {
4607 System.out.println();
4608 System.out.println( "the following might be due to absence internet connection:" );
4609 e.printStackTrace( System.out );
4612 catch ( final Exception e ) {
4613 e.printStackTrace();
4619 private static boolean testExternalNodeRelatedMethods() {
4621 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4622 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4623 PhylogenyNode n = t1.getNode( "A" );
4624 n = n.getNextExternalNode();
4625 if ( !n.getName().equals( "B" ) ) {
4628 n = n.getNextExternalNode();
4629 if ( !n.getName().equals( "C" ) ) {
4632 n = n.getNextExternalNode();
4633 if ( !n.getName().equals( "D" ) ) {
4636 n = t1.getNode( "B" );
4637 while ( !n.isLastExternalNode() ) {
4638 n = n.getNextExternalNode();
4640 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4641 n = t2.getNode( "A" );
4642 n = n.getNextExternalNode();
4643 if ( !n.getName().equals( "B" ) ) {
4646 n = n.getNextExternalNode();
4647 if ( !n.getName().equals( "C" ) ) {
4650 n = n.getNextExternalNode();
4651 if ( !n.getName().equals( "D" ) ) {
4654 n = t2.getNode( "B" );
4655 while ( !n.isLastExternalNode() ) {
4656 n = n.getNextExternalNode();
4658 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4659 n = t3.getNode( "A" );
4660 n = n.getNextExternalNode();
4661 if ( !n.getName().equals( "B" ) ) {
4664 n = n.getNextExternalNode();
4665 if ( !n.getName().equals( "C" ) ) {
4668 n = n.getNextExternalNode();
4669 if ( !n.getName().equals( "D" ) ) {
4672 n = n.getNextExternalNode();
4673 if ( !n.getName().equals( "E" ) ) {
4676 n = n.getNextExternalNode();
4677 if ( !n.getName().equals( "F" ) ) {
4680 n = n.getNextExternalNode();
4681 if ( !n.getName().equals( "G" ) ) {
4684 n = n.getNextExternalNode();
4685 if ( !n.getName().equals( "H" ) ) {
4688 n = t3.getNode( "B" );
4689 while ( !n.isLastExternalNode() ) {
4690 n = n.getNextExternalNode();
4692 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4693 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4694 final PhylogenyNode node = iter.next();
4696 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4697 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4698 final PhylogenyNode node = iter.next();
4700 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))",
4701 new NHXParser() )[ 0 ];
4702 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4703 if ( !iter.next().getName().equals( "A" ) ) {
4706 if ( !iter.next().getName().equals( "B" ) ) {
4709 if ( !iter.next().getName().equals( "C" ) ) {
4712 if ( !iter.next().getName().equals( "D" ) ) {
4715 if ( !iter.next().getName().equals( "E" ) ) {
4718 if ( !iter.next().getName().equals( "F" ) ) {
4721 if ( iter.hasNext() ) {
4725 catch ( final Exception e ) {
4726 e.printStackTrace( System.out );
4732 private static boolean testExtractSNFromNodeName() {
4734 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4737 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4740 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4743 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4744 .equals( "Mus musculus musculus" ) ) {
4747 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4748 .equals( "Mus musculus musculus" ) ) {
4751 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4752 .equals( "Mus musculus musculus" ) ) {
4755 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4756 .equals( "Mus musculus musculus" ) ) {
4759 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4762 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4763 .equals( "Mus musculus musculus" ) ) {
4766 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4767 .equals( "Mus musculus musculus" ) ) {
4771 .extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4774 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4777 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4780 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4783 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4784 .equals( "Mus musculus musculus" ) ) {
4787 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4790 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4793 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4796 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4799 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4802 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4805 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4808 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4811 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4812 .equals( "Mus musculus" ) ) {
4815 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4816 .equals( "Mus musculus" ) ) {
4819 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4822 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4823 .equals( "Mus musculus musculus" ) ) {
4826 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4827 .equals( "Mus musculus musculus" ) ) {
4830 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4831 .equals( "Mus musculus musculus" ) ) {
4834 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4837 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4838 .equals( "Pilostyles mexicana" ) ) {
4841 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4842 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4845 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4846 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4849 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4850 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4853 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4854 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4857 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4858 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4861 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4862 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4865 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4866 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4869 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4870 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4873 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4874 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4877 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4878 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4881 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4882 .equals( "Escherichia coli (strain K12)" ) ) {
4885 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4886 .equals( "Escherichia coli (strain K12)" ) ) {
4889 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4890 .equals( "Escherichia coli (str. K12)" ) ) {
4893 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4894 .equals( "Escherichia coli (str. K12)" ) ) {
4897 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4898 .equals( "Escherichia coli (str. K12)" ) ) {
4901 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4902 .equals( "Escherichia coli (var. K12)" ) ) {
4905 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4906 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4909 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4910 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4914 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4915 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4918 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4919 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4923 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4924 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4927 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4928 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4931 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4932 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4935 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4938 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4941 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4944 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4945 .equals( "Macrocera sp." ) ) {
4948 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4951 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4952 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4955 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4956 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4959 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4960 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4963 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4964 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4968 catch ( final Exception e ) {
4969 e.printStackTrace( System.out );
4975 private static boolean testExtractTaxonomyDataFromNodeName() {
4977 PhylogenyNode n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN" );
4978 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4981 n = new PhylogenyNode( "tr|B1AM49|B1AM49_HUMAN~1-2" );
4982 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4985 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN" );
4986 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4989 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN|" );
4990 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4993 n = new PhylogenyNode( "tr|B1AM49|HNRPR_HUMAN~12" );
4994 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
4997 n = new PhylogenyNode( "HNRPR_HUMAN" );
4998 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5001 n = new PhylogenyNode( "HNRPR_HUMAN_X" );
5002 if ( !ParserUtils.extractTaxonomyDataFromNodeName( n, TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "HUMAN" ) ) {
5006 catch ( final Exception e ) {
5007 e.printStackTrace( System.out );
5013 private static boolean testExtractTaxonomyCodeFromNodeName() {
5015 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE",
5016 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5019 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5020 .equals( "SOYBN" ) ) {
5023 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5024 .equals( "ARATH" ) ) {
5027 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
5028 .equals( "ARATH" ) ) {
5031 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5032 .equals( "RAT" ) ) {
5035 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE )
5036 .equals( "RAT" ) ) {
5039 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1",
5040 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5043 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5044 .equals( "SOYBN" ) ) {
5047 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5048 .equals( "SOYBN" ) ) {
5051 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5052 .equals( "SOYBN" ) ) {
5055 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5056 .equals( "SOYBN" ) ) {
5059 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5060 .equals( "SOYBN" ) ) {
5063 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
5064 .equals( "SOYBN" ) ) {
5067 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
5068 .equals( "SOYBN" ) ) {
5071 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
5072 .equals( "SOYBN" ) ) {
5075 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx",
5076 TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
5079 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
5080 .equals( "SOYBN" ) ) {
5084 .extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5085 .equals( "ECOLI" ) ) {
5088 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
5089 .equals( "9YX45" ) ) {
5092 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
5093 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5094 .equals( "MOUSE" ) ) {
5097 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
5098 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5099 .equals( "MOUSE" ) ) {
5102 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
5103 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5104 .equals( "MOUSE" ) ) {
5107 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
5108 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5111 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
5112 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5115 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5116 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5117 .equals( "RAT" ) ) {
5120 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
5121 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5122 .equals( "RAT" ) ) {
5125 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
5126 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5127 .equals( "RAT" ) ) {
5130 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
5131 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5134 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
5135 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5138 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5139 .equals( "RAT" ) ) {
5142 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5143 .equals( "PIG" ) ) {
5147 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
5148 .equals( "MOUSE" ) ) {
5151 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
5152 .equals( "MOUSE" ) ) {
5155 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ",
5156 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
5160 catch ( final Exception e ) {
5161 e.printStackTrace( System.out );
5167 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
5169 PhylogenyNode n = new PhylogenyNode();
5170 n.setName( "tr|B3RJ64" );
5171 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5174 n.setName( "tr.B3RJ64" );
5175 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5178 n.setName( "tr=B3RJ64" );
5179 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5182 n.setName( "tr-B3RJ64" );
5183 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5186 n.setName( "tr/B3RJ64" );
5187 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5190 n.setName( "tr\\B3RJ64" );
5191 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5194 n.setName( "tr_B3RJ64" );
5195 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5198 n.setName( " tr|B3RJ64 " );
5199 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5202 n.setName( "-tr|B3RJ64-" );
5203 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5206 n.setName( "-tr=B3RJ64-" );
5207 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5210 n.setName( "_tr=B3RJ64_" );
5211 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5214 n.setName( " tr_tr|B3RJ64_sp|123 " );
5215 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5218 n.setName( "B3RJ64" );
5219 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5222 n.setName( "sp|B3RJ64" );
5223 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5226 n.setName( "sp|B3RJ64C" );
5227 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5230 n.setName( "sp B3RJ64" );
5231 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5234 n.setName( "sp|B3RJ6X" );
5235 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5238 n.setName( "sp|B3RJ6" );
5239 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5242 n.setName( "K1PYK7_CRAGI" );
5243 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5246 n.setName( "K1PYK7_PEA" );
5247 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
5250 n.setName( "K1PYK7_RAT" );
5251 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
5254 n.setName( "K1PYK7_PIG" );
5255 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5258 n.setName( "~K1PYK7_PIG~" );
5259 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
5262 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
5263 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5266 n.setName( "K1PYKX_CRAGI" );
5267 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5270 n.setName( "XXXXX_CRAGI" );
5271 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
5274 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
5275 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
5278 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
5279 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
5282 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
5283 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
5286 n = new PhylogenyNode();
5287 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
5288 seq.setSymbol( "K1PYK7_CRAGI" );
5289 n.getNodeData().addSequence( seq );
5290 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5293 seq.setSymbol( "tr|B3RJ64" );
5294 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5297 n = new PhylogenyNode();
5298 seq = new org.forester.phylogeny.data.Sequence();
5299 seq.setName( "K1PYK7_CRAGI" );
5300 n.getNodeData().addSequence( seq );
5301 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
5304 seq.setName( "tr|B3RJ64" );
5305 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5308 n = new PhylogenyNode();
5309 seq = new org.forester.phylogeny.data.Sequence();
5310 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
5311 n.getNodeData().addSequence( seq );
5312 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
5315 n = new PhylogenyNode();
5316 seq = new org.forester.phylogeny.data.Sequence();
5317 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
5318 n.getNodeData().addSequence( seq );
5319 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
5323 n = new PhylogenyNode();
5324 n.setName( "ACP19736" );
5325 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5328 n = new PhylogenyNode();
5329 n.setName( "|ACP19736|" );
5330 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
5334 catch ( final Exception e ) {
5335 e.printStackTrace( System.out );
5341 private static boolean testFastaParser() {
5343 final FileInputStream fis1 = new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" );
5344 if ( !FastaParser.isLikelyFasta( fis1 ) ) {
5351 final FileInputStream fis2 = new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" );
5352 if ( FastaParser.isLikelyFasta( fis2 ) ) {
5359 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
5360 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
5363 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
5366 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
5369 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPROWXERR" ) ) {
5372 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
5375 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
5379 catch ( final Exception e ) {
5380 e.printStackTrace();
5386 private static boolean testGenbankAccessorParsing() {
5387 //The format for GenBank Accession numbers are:
5388 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
5389 //Protein: 3 letters + 5 numerals
5390 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
5391 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
5394 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
5397 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" )
5398 .equals( "AY423861.24" ) ) {
5401 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
5404 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
5407 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
5410 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
5413 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
5416 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
5419 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
5422 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
5425 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
5428 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
5431 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
5437 private static boolean testGeneralMsaParser() {
5439 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
5440 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
5441 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
5442 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
5443 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
5444 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
5445 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
5446 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
5447 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5450 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5453 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5456 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5459 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5462 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5465 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5468 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5471 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
5474 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
5477 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
5480 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
5483 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
5484 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5487 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5490 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5493 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
5494 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
5497 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
5500 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
5503 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
5504 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
5507 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
5510 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
5514 catch ( final Exception e ) {
5515 e.printStackTrace();
5521 private static boolean testGeneralTable() {
5523 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5524 t0.setValue( 3, 2, "23" );
5525 t0.setValue( 10, 1, "error" );
5526 t0.setValue( 10, 1, "110" );
5527 t0.setValue( 9, 1, "19" );
5528 t0.setValue( 1, 10, "101" );
5529 t0.setValue( 10, 10, "1010" );
5530 t0.setValue( 100, 10, "10100" );
5531 t0.setValue( 0, 0, "00" );
5532 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5535 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5538 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5541 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5544 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5547 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5550 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5553 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5556 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5559 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5560 t1.setValue( "3", "2", "23" );
5561 t1.setValue( "10", "1", "error" );
5562 t1.setValue( "10", "1", "110" );
5563 t1.setValue( "9", "1", "19" );
5564 t1.setValue( "1", "10", "101" );
5565 t1.setValue( "10", "10", "1010" );
5566 t1.setValue( "100", "10", "10100" );
5567 t1.setValue( "0", "0", "00" );
5568 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5569 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5572 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5575 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5578 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5581 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5584 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5587 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5590 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5593 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5596 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5600 catch ( final Exception e ) {
5601 e.printStackTrace( System.out );
5607 private static boolean testGetDistance() {
5609 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5610 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",
5611 new NHXParser() )[ 0 ];
5612 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5615 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5618 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5621 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5624 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5627 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5630 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5633 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5636 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5639 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5642 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5645 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5648 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5651 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5654 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5657 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5660 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5663 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5666 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5669 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5672 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5675 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5678 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5681 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5684 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5687 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5690 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5693 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5696 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5699 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5702 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5705 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",
5706 new NHXParser() )[ 0 ];
5707 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5710 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5713 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5716 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5719 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5722 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5725 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5728 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5731 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5734 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5737 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5741 catch ( final Exception e ) {
5742 e.printStackTrace( System.out );
5748 private static boolean testGetLCA() {
5750 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5751 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5752 new NHXParser() )[ 0 ];
5753 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5754 if ( !A.getName().equals( "A" ) ) {
5757 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5758 if ( !gh.getName().equals( "gh" ) ) {
5761 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5762 if ( !ab.getName().equals( "ab" ) ) {
5765 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5766 if ( !ab2.getName().equals( "ab" ) ) {
5769 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5770 if ( !gh2.getName().equals( "gh" ) ) {
5773 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5774 if ( !gh3.getName().equals( "gh" ) ) {
5777 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5778 if ( !abc.getName().equals( "abc" ) ) {
5781 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5782 if ( !abc2.getName().equals( "abc" ) ) {
5785 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5786 if ( !abcd.getName().equals( "abcd" ) ) {
5789 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5790 if ( !abcd2.getName().equals( "abcd" ) ) {
5793 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5794 if ( !abcdef.getName().equals( "abcdef" ) ) {
5797 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5798 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5801 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5802 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5805 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5806 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5809 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5810 if ( !abcde.getName().equals( "abcde" ) ) {
5813 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5814 if ( !abcde2.getName().equals( "abcde" ) ) {
5817 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5818 if ( !r.getName().equals( "abcdefgh" ) ) {
5821 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5822 if ( !r2.getName().equals( "abcdefgh" ) ) {
5825 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5826 if ( !r3.getName().equals( "abcdefgh" ) ) {
5829 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5830 if ( !abcde3.getName().equals( "abcde" ) ) {
5833 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5834 if ( !abcde4.getName().equals( "abcde" ) ) {
5837 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5838 if ( !ab3.getName().equals( "ab" ) ) {
5841 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5842 if ( !ab4.getName().equals( "ab" ) ) {
5845 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5846 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5847 if ( !cd.getName().equals( "cd" ) ) {
5850 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5851 if ( !cd2.getName().equals( "cd" ) ) {
5854 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5855 if ( !cde.getName().equals( "cde" ) ) {
5858 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5859 if ( !cde2.getName().equals( "cde" ) ) {
5862 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5863 if ( !cdef.getName().equals( "cdef" ) ) {
5866 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5867 if ( !cdef2.getName().equals( "cdef" ) ) {
5870 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5871 if ( !cdef3.getName().equals( "cdef" ) ) {
5874 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5875 if ( !rt.getName().equals( "r" ) ) {
5878 final Phylogeny p3 = factory.create(
5879 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5880 new NHXParser() )[ 0 ];
5881 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5882 if ( !bc_3.getName().equals( "bc" ) ) {
5885 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5886 if ( !ac_3.getName().equals( "abc" ) ) {
5889 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5890 if ( !ad_3.getName().equals( "abcde" ) ) {
5893 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5894 if ( !af_3.getName().equals( "abcdef" ) ) {
5897 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5898 if ( !ag_3.getName().equals( "" ) ) {
5901 if ( !ag_3.isRoot() ) {
5904 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5905 if ( !al_3.getName().equals( "" ) ) {
5908 if ( !al_3.isRoot() ) {
5911 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5912 if ( !kl_3.getName().equals( "" ) ) {
5915 if ( !kl_3.isRoot() ) {
5918 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5919 if ( !fl_3.getName().equals( "" ) ) {
5922 if ( !fl_3.isRoot() ) {
5925 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5926 if ( !gk_3.getName().equals( "ghijk" ) ) {
5929 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5930 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5931 if ( !r_4.getName().equals( "r" ) ) {
5934 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5935 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5936 if ( !r_5.getName().equals( "root" ) ) {
5939 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5940 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5941 if ( !r_6.getName().equals( "rot" ) ) {
5944 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5945 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5946 if ( !r_7.getName().equals( "rott" ) ) {
5950 catch ( final Exception e ) {
5951 e.printStackTrace( System.out );
5957 private static boolean testGetLCA2() {
5959 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5960 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5961 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5962 PhylogenyMethods.preOrderReId( p_a );
5963 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5964 p_a.getNode( "a" ) );
5965 if ( !p_a_1.getName().equals( "a" ) ) {
5968 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5969 PhylogenyMethods.preOrderReId( p_b );
5970 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5971 p_b.getNode( "a" ) );
5972 if ( !p_b_1.getName().equals( "b" ) ) {
5975 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5976 p_b.getNode( "b" ) );
5977 if ( !p_b_2.getName().equals( "b" ) ) {
5980 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5981 PhylogenyMethods.preOrderReId( p_c );
5982 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5983 p_c.getNode( "a" ) );
5984 if ( !p_c_1.getName().equals( "b" ) ) {
5987 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5988 p_c.getNode( "c" ) );
5989 if ( !p_c_2.getName().equals( "c" ) ) {
5990 System.out.println( p_c_2.getName() );
5994 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5995 p_c.getNode( "b" ) );
5996 if ( !p_c_3.getName().equals( "b" ) ) {
5999 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
6000 p_c.getNode( "a" ) );
6001 if ( !p_c_4.getName().equals( "c" ) ) {
6004 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
6005 new NHXParser() )[ 0 ];
6006 PhylogenyMethods.preOrderReId( p1 );
6007 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6008 p1.getNode( "A" ) );
6009 if ( !A.getName().equals( "A" ) ) {
6012 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
6013 p1.getNode( "gh" ) );
6014 if ( !gh.getName().equals( "gh" ) ) {
6017 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6018 p1.getNode( "B" ) );
6019 if ( !ab.getName().equals( "ab" ) ) {
6022 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6023 p1.getNode( "A" ) );
6024 if ( !ab2.getName().equals( "ab" ) ) {
6027 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6028 p1.getNode( "G" ) );
6029 if ( !gh2.getName().equals( "gh" ) ) {
6032 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
6033 p1.getNode( "H" ) );
6034 if ( !gh3.getName().equals( "gh" ) ) {
6037 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
6038 p1.getNode( "A" ) );
6039 if ( !abc.getName().equals( "abc" ) ) {
6042 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6043 p1.getNode( "C" ) );
6044 if ( !abc2.getName().equals( "abc" ) ) {
6047 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6048 p1.getNode( "D" ) );
6049 if ( !abcd.getName().equals( "abcd" ) ) {
6052 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
6053 p1.getNode( "A" ) );
6054 if ( !abcd2.getName().equals( "abcd" ) ) {
6057 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6058 p1.getNode( "F" ) );
6059 if ( !abcdef.getName().equals( "abcdef" ) ) {
6062 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6063 p1.getNode( "A" ) );
6064 if ( !abcdef2.getName().equals( "abcdef" ) ) {
6067 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6068 p1.getNode( "F" ) );
6069 if ( !abcdef3.getName().equals( "abcdef" ) ) {
6072 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
6073 p1.getNode( "ab" ) );
6074 if ( !abcdef4.getName().equals( "abcdef" ) ) {
6077 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6078 p1.getNode( "E" ) );
6079 if ( !abcde.getName().equals( "abcde" ) ) {
6082 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6083 p1.getNode( "A" ) );
6084 if ( !abcde2.getName().equals( "abcde" ) ) {
6087 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
6088 p1.getNode( "abcdefgh" ) );
6089 if ( !r.getName().equals( "abcdefgh" ) ) {
6092 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
6093 p1.getNode( "H" ) );
6094 if ( !r2.getName().equals( "abcdefgh" ) ) {
6097 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
6098 p1.getNode( "A" ) );
6099 if ( !r3.getName().equals( "abcdefgh" ) ) {
6102 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
6103 p1.getNode( "abcde" ) );
6104 if ( !abcde3.getName().equals( "abcde" ) ) {
6107 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
6108 p1.getNode( "E" ) );
6109 if ( !abcde4.getName().equals( "abcde" ) ) {
6112 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
6113 p1.getNode( "B" ) );
6114 if ( !ab3.getName().equals( "ab" ) ) {
6117 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
6118 p1.getNode( "ab" ) );
6119 if ( !ab4.getName().equals( "ab" ) ) {
6122 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
6123 PhylogenyMethods.preOrderReId( p2 );
6124 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6125 p2.getNode( "d" ) );
6126 if ( !cd.getName().equals( "cd" ) ) {
6129 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6130 p2.getNode( "c" ) );
6131 if ( !cd2.getName().equals( "cd" ) ) {
6134 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6135 p2.getNode( "e" ) );
6136 if ( !cde.getName().equals( "cde" ) ) {
6139 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
6140 p2.getNode( "c" ) );
6141 if ( !cde2.getName().equals( "cde" ) ) {
6144 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6145 p2.getNode( "f" ) );
6146 if ( !cdef.getName().equals( "cdef" ) ) {
6149 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
6150 p2.getNode( "f" ) );
6151 if ( !cdef2.getName().equals( "cdef" ) ) {
6154 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
6155 p2.getNode( "d" ) );
6156 if ( !cdef3.getName().equals( "cdef" ) ) {
6159 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
6160 p2.getNode( "a" ) );
6161 if ( !rt.getName().equals( "r" ) ) {
6164 final Phylogeny p3 = factory.create(
6165 "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
6166 new NHXParser() )[ 0 ];
6167 PhylogenyMethods.preOrderReId( p3 );
6168 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
6169 p3.getNode( "c" ) );
6170 if ( !bc_3.getName().equals( "bc" ) ) {
6173 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6174 p3.getNode( "c" ) );
6175 if ( !ac_3.getName().equals( "abc" ) ) {
6178 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6179 p3.getNode( "d" ) );
6180 if ( !ad_3.getName().equals( "abcde" ) ) {
6183 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6184 p3.getNode( "f" ) );
6185 if ( !af_3.getName().equals( "abcdef" ) ) {
6188 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6189 p3.getNode( "g" ) );
6190 if ( !ag_3.getName().equals( "" ) ) {
6193 if ( !ag_3.isRoot() ) {
6196 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
6197 p3.getNode( "l" ) );
6198 if ( !al_3.getName().equals( "" ) ) {
6201 if ( !al_3.isRoot() ) {
6204 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
6205 p3.getNode( "l" ) );
6206 if ( !kl_3.getName().equals( "" ) ) {
6209 if ( !kl_3.isRoot() ) {
6212 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
6213 p3.getNode( "l" ) );
6214 if ( !fl_3.getName().equals( "" ) ) {
6217 if ( !fl_3.isRoot() ) {
6220 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
6221 p3.getNode( "k" ) );
6222 if ( !gk_3.getName().equals( "ghijk" ) ) {
6225 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
6226 PhylogenyMethods.preOrderReId( p4 );
6227 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
6228 p4.getNode( "c" ) );
6229 if ( !r_4.getName().equals( "r" ) ) {
6232 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
6233 PhylogenyMethods.preOrderReId( p5 );
6234 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
6235 p5.getNode( "c" ) );
6236 if ( !r_5.getName().equals( "root" ) ) {
6239 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
6240 PhylogenyMethods.preOrderReId( p6 );
6241 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
6242 p6.getNode( "a" ) );
6243 if ( !r_6.getName().equals( "rot" ) ) {
6246 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
6247 PhylogenyMethods.preOrderReId( p7 );
6248 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
6249 p7.getNode( "e" ) );
6250 if ( !r_7.getName().equals( "rott" ) ) {
6253 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6254 p7.getNode( "a" ) );
6255 if ( !r_71.getName().equals( "rott" ) ) {
6258 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6259 p7.getNode( "rott" ) );
6260 if ( !r_72.getName().equals( "rott" ) ) {
6263 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6264 p7.getNode( "a" ) );
6265 if ( !r_73.getName().equals( "rott" ) ) {
6268 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
6269 p7.getNode( "rott" ) );
6270 if ( !r_74.getName().equals( "rott" ) ) {
6273 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
6274 p7.getNode( "e" ) );
6275 if ( !r_75.getName().equals( "e" ) ) {
6279 catch ( final Exception e ) {
6280 e.printStackTrace( System.out );
6286 private static boolean testHmmscanOutputParser() {
6287 final String test_dir = Test.PATH_TO_TEST_DATA;
6289 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
6290 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ),
6292 INDIVIDUAL_SCORE_CUTOFF.NONE );
6294 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
6295 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ),
6297 INDIVIDUAL_SCORE_CUTOFF.NONE );
6298 final List<Protein> proteins = parser2.parse();
6299 if ( parser2.getProteinsEncountered() != 4 ) {
6302 if ( proteins.size() != 4 ) {
6305 if ( parser2.getDomainsEncountered() != 69 ) {
6308 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
6311 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
6314 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
6317 final Protein p1 = proteins.get( 0 );
6318 if ( p1.getNumberOfProteinDomains() != 15 ) {
6321 if ( p1.getLength() != 850 ) {
6324 final Protein p2 = proteins.get( 1 );
6325 if ( p2.getNumberOfProteinDomains() != 51 ) {
6328 if ( p2.getLength() != 1291 ) {
6331 final Protein p3 = proteins.get( 2 );
6332 if ( p3.getNumberOfProteinDomains() != 2 ) {
6335 final Protein p4 = proteins.get( 3 );
6336 if ( p4.getNumberOfProteinDomains() != 1 ) {
6339 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
6342 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
6345 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
6348 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
6351 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
6354 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
6357 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
6361 catch ( final Exception e ) {
6362 e.printStackTrace( System.out );
6368 private static boolean testLastExternalNodeMethods() {
6370 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6371 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
6372 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
6373 final PhylogenyNode n1 = t0.getNode( "A" );
6374 if ( n1.isLastExternalNode() ) {
6377 final PhylogenyNode n2 = t0.getNode( "B" );
6378 if ( n2.isLastExternalNode() ) {
6381 final PhylogenyNode n3 = t0.getNode( "C" );
6382 if ( n3.isLastExternalNode() ) {
6385 final PhylogenyNode n4 = t0.getNode( "D" );
6386 if ( !n4.isLastExternalNode() ) {
6390 catch ( final Exception e ) {
6391 e.printStackTrace( System.out );
6397 private static boolean testLevelOrderIterator() {
6399 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6400 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
6401 PhylogenyNodeIterator it0;
6402 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
6405 for( it0.reset(); it0.hasNext(); ) {
6408 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
6409 if ( !it.next().getName().equals( "r" ) ) {
6412 if ( !it.next().getName().equals( "ab" ) ) {
6415 if ( !it.next().getName().equals( "cd" ) ) {
6418 if ( !it.next().getName().equals( "A" ) ) {
6421 if ( !it.next().getName().equals( "B" ) ) {
6424 if ( !it.next().getName().equals( "C" ) ) {
6427 if ( !it.next().getName().equals( "D" ) ) {
6430 if ( it.hasNext() ) {
6433 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",
6434 new NHXParser() )[ 0 ];
6435 PhylogenyNodeIterator it2;
6436 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
6439 for( it2.reset(); it2.hasNext(); ) {
6442 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
6443 if ( !it3.next().getName().equals( "r" ) ) {
6446 if ( !it3.next().getName().equals( "abc" ) ) {
6449 if ( !it3.next().getName().equals( "defg" ) ) {
6452 if ( !it3.next().getName().equals( "A" ) ) {
6455 if ( !it3.next().getName().equals( "B" ) ) {
6458 if ( !it3.next().getName().equals( "C" ) ) {
6461 if ( !it3.next().getName().equals( "D" ) ) {
6464 if ( !it3.next().getName().equals( "E" ) ) {
6467 if ( !it3.next().getName().equals( "F" ) ) {
6470 if ( !it3.next().getName().equals( "G" ) ) {
6473 if ( !it3.next().getName().equals( "1" ) ) {
6476 if ( !it3.next().getName().equals( "2" ) ) {
6479 if ( !it3.next().getName().equals( "3" ) ) {
6482 if ( !it3.next().getName().equals( "4" ) ) {
6485 if ( !it3.next().getName().equals( "5" ) ) {
6488 if ( !it3.next().getName().equals( "6" ) ) {
6491 if ( !it3.next().getName().equals( "f1" ) ) {
6494 if ( !it3.next().getName().equals( "f2" ) ) {
6497 if ( !it3.next().getName().equals( "f3" ) ) {
6500 if ( !it3.next().getName().equals( "a" ) ) {
6503 if ( !it3.next().getName().equals( "b" ) ) {
6506 if ( !it3.next().getName().equals( "f21" ) ) {
6509 if ( !it3.next().getName().equals( "X" ) ) {
6512 if ( !it3.next().getName().equals( "Y" ) ) {
6515 if ( !it3.next().getName().equals( "Z" ) ) {
6518 if ( it3.hasNext() ) {
6521 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
6522 PhylogenyNodeIterator it4;
6523 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6526 for( it4.reset(); it4.hasNext(); ) {
6529 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6530 if ( !it5.next().getName().equals( "r" ) ) {
6533 if ( !it5.next().getName().equals( "A" ) ) {
6536 if ( !it5.next().getName().equals( "B" ) ) {
6539 if ( !it5.next().getName().equals( "C" ) ) {
6542 if ( !it5.next().getName().equals( "D" ) ) {
6545 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6546 PhylogenyNodeIterator it6;
6547 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6550 for( it6.reset(); it6.hasNext(); ) {
6553 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6554 if ( !it7.next().getName().equals( "A" ) ) {
6557 if ( it.hasNext() ) {
6561 catch ( final Exception e ) {
6562 e.printStackTrace( System.out );
6568 private static boolean testMafft( final String path ) {
6570 final List<String> opts = new ArrayList<String>();
6571 opts.add( "--maxiterate" );
6573 opts.add( "--localpair" );
6574 opts.add( "--quiet" );
6576 final MsaInferrer mafft = Mafft.createInstance( path );
6577 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6578 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6581 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6585 catch ( final Exception e ) {
6586 e.printStackTrace( System.out );
6592 private static boolean testMidpointrooting() {
6594 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6595 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6596 PhylogenyMethods.midpointRoot( t0 );
6597 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6600 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6603 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6607 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",
6608 new NHXParser() )[ 0 ];
6609 if ( !t1.isRooted() ) {
6612 PhylogenyMethods.midpointRoot( t1 );
6613 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6616 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6619 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6622 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6625 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6628 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6631 t1.reRoot( t1.getNode( "A" ) );
6632 PhylogenyMethods.midpointRoot( t1 );
6633 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6636 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6639 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6642 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6645 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6649 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6653 catch ( final Exception e ) {
6654 e.printStackTrace( System.out );
6660 private static boolean testMsaQualityMethod() {
6662 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6663 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6664 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6665 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6666 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6671 final Msa msa = BasicMsa.createInstance( l );
6672 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6675 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6678 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6681 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6684 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6687 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6690 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6694 catch ( final Exception e ) {
6695 e.printStackTrace( System.out );
6701 private static boolean testMsaEntropy() {
6703 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6704 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6705 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6706 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6707 final List<MolecularSequence> l = new ArrayList<MolecularSequence>();
6712 final Msa msa = BasicMsa.createInstance( l );
6713 //TODO need to DO the tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6715 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6716 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6717 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6718 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6719 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6720 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6721 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6722 // System.out.println();
6723 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6724 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6725 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6726 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6727 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6728 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6729 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6730 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6731 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6732 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6733 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6734 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6735 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6736 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6737 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6738 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6739 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6740 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6741 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6742 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6743 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6744 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6745 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6746 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6747 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6748 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6749 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6750 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6751 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6752 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6753 final Msa msa2 = BasicMsa.createInstance( l2 );
6754 // System.out.println();
6755 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6756 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6757 // System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6759 catch ( final Exception e ) {
6760 e.printStackTrace( System.out );
6766 private static boolean testDeleteableMsa() {
6768 final MolecularSequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6769 final MolecularSequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6770 final MolecularSequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6771 final MolecularSequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6772 final MolecularSequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6773 final MolecularSequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6774 final List<MolecularSequence> l0 = new ArrayList<MolecularSequence>();
6781 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6782 dmsa0.deleteRow( "b", false );
6783 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6786 dmsa0.deleteRow( "e", false );
6787 dmsa0.deleteRow( "a", false );
6788 dmsa0.deleteRow( "f", false );
6789 if ( dmsa0.getLength() != 4 ) {
6792 if ( dmsa0.getNumberOfSequences() != 2 ) {
6795 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6798 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6801 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6804 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6807 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6810 dmsa0.deleteRow( "c", false );
6811 dmsa0.deleteRow( "d", false );
6812 if ( dmsa0.getNumberOfSequences() != 0 ) {
6816 final MolecularSequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6817 final MolecularSequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6818 final MolecularSequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6819 final MolecularSequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6820 final MolecularSequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6821 final MolecularSequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6822 final List<MolecularSequence> l1 = new ArrayList<MolecularSequence>();
6829 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6830 dmsa1.deleteGapOnlyColumns();
6831 dmsa1.deleteRow( "a", false );
6832 dmsa1.deleteRow( "f", false );
6833 dmsa1.deleteRow( "d", false );
6834 dmsa1.deleteGapOnlyColumns();
6835 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6838 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6841 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6844 dmsa1.deleteRow( "c", false );
6845 dmsa1.deleteGapOnlyColumns();
6846 final Writer w0 = new StringWriter();
6847 dmsa1.write( w0, MSA_FORMAT.FASTA );
6848 final Writer w1 = new StringWriter();
6849 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6850 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6853 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6856 final MolecularSequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6857 final MolecularSequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6858 final MolecularSequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6859 final MolecularSequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6860 final MolecularSequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6861 final MolecularSequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6862 final List<MolecularSequence> l2 = new ArrayList<MolecularSequence>();
6869 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6870 dmsa2.deleteGapColumns( 0.5 );
6871 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6874 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6877 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6880 dmsa2.deleteGapColumns( 0.2 );
6881 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6884 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6887 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6890 dmsa2.deleteGapColumns( 0 );
6891 dmsa2.deleteRow( "a", false );
6892 dmsa2.deleteRow( "b", false );
6893 dmsa2.deleteRow( "f", false );
6894 dmsa2.deleteRow( "e", false );
6895 dmsa2.setIdentifier( 0, "new_c" );
6896 dmsa2.setIdentifier( 1, "new_d" );
6897 dmsa2.setResidueAt( 0, 0, 'x' );
6898 final MolecularSequence s = dmsa2.deleteRow( "new_d", true );
6899 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6902 final Writer w = new StringWriter();
6903 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6904 final String phylip = w.toString();
6905 if ( !phylip.equals( "1 1" + ForesterUtil.LINE_SEPARATOR + "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6906 System.out.println( phylip );
6909 final Writer w2 = new StringWriter();
6910 dmsa2.write( w2, MSA_FORMAT.FASTA );
6911 final String fasta = w2.toString();
6912 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6913 System.out.println( fasta );
6917 catch ( final Exception e ) {
6918 e.printStackTrace( System.out );
6924 private static boolean testNextNodeWithCollapsing() {
6926 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6928 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6929 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6930 final Phylogeny t0 = factory.create( sb0.toString(), new NHXParser() )[ 0 ];
6931 t0.getNode( "cd" ).setCollapse( true );
6932 t0.getNode( "cde" ).setCollapse( true );
6933 n = t0.getFirstExternalNode();
6934 while ( n != null ) {
6936 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6938 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6941 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6944 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6947 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6950 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6953 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6957 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6958 final Phylogeny t1 = factory.create( sb1.toString(), new NHXParser() )[ 0 ];
6959 t1.getNode( "ab" ).setCollapse( true );
6960 t1.getNode( "cd" ).setCollapse( true );
6961 t1.getNode( "cde" ).setCollapse( true );
6962 n = t1.getNode( "ab" );
6963 ext = new ArrayList<PhylogenyNode>();
6964 while ( n != null ) {
6966 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6968 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6971 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6974 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6977 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6980 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6984 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6985 final Phylogeny t2 = factory.create( sb2.toString(), new NHXParser() )[ 0 ];
6986 t2.getNode( "ab" ).setCollapse( true );
6987 t2.getNode( "cd" ).setCollapse( true );
6988 t2.getNode( "cde" ).setCollapse( true );
6989 t2.getNode( "c" ).setCollapse( true );
6990 t2.getNode( "d" ).setCollapse( true );
6991 t2.getNode( "e" ).setCollapse( true );
6992 t2.getNode( "gh" ).setCollapse( true );
6993 n = t2.getNode( "ab" );
6994 ext = new ArrayList<PhylogenyNode>();
6995 while ( n != null ) {
6997 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6999 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7002 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7005 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
7008 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
7012 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7013 final Phylogeny t3 = factory.create( sb3.toString(), new NHXParser() )[ 0 ];
7014 t3.getNode( "ab" ).setCollapse( true );
7015 t3.getNode( "cd" ).setCollapse( true );
7016 t3.getNode( "cde" ).setCollapse( true );
7017 t3.getNode( "c" ).setCollapse( true );
7018 t3.getNode( "d" ).setCollapse( true );
7019 t3.getNode( "e" ).setCollapse( true );
7020 t3.getNode( "gh" ).setCollapse( true );
7021 t3.getNode( "fgh" ).setCollapse( true );
7022 n = t3.getNode( "ab" );
7023 ext = new ArrayList<PhylogenyNode>();
7024 while ( n != null ) {
7026 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7028 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7031 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7034 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
7038 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7039 final Phylogeny t4 = factory.create( sb4.toString(), new NHXParser() )[ 0 ];
7040 t4.getNode( "ab" ).setCollapse( true );
7041 t4.getNode( "cd" ).setCollapse( true );
7042 t4.getNode( "cde" ).setCollapse( true );
7043 t4.getNode( "c" ).setCollapse( true );
7044 t4.getNode( "d" ).setCollapse( true );
7045 t4.getNode( "e" ).setCollapse( true );
7046 t4.getNode( "gh" ).setCollapse( true );
7047 t4.getNode( "fgh" ).setCollapse( true );
7048 t4.getNode( "abcdefgh" ).setCollapse( true );
7049 n = t4.getNode( "abcdefgh" );
7050 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
7053 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7054 final Phylogeny t5 = factory.create( sb5.toString(), new NHXParser() )[ 0 ];
7056 n = t5.getFirstExternalNode();
7057 while ( n != null ) {
7059 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7061 if ( ext.size() != 8 ) {
7064 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7067 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7070 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7073 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7076 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7079 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7082 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
7085 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
7088 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7089 final Phylogeny t6 = factory.create( sb6.toString(), new NHXParser() )[ 0 ];
7091 t6.getNode( "ab" ).setCollapse( true );
7092 n = t6.getNode( "ab" );
7093 while ( n != null ) {
7095 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7097 if ( ext.size() != 7 ) {
7100 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7103 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7106 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7109 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7112 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7115 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7118 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7121 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7122 final Phylogeny t7 = factory.create( sb7.toString(), new NHXParser() )[ 0 ];
7124 t7.getNode( "cd" ).setCollapse( true );
7125 n = t7.getNode( "a" );
7126 while ( n != null ) {
7128 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7130 if ( ext.size() != 7 ) {
7133 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7136 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7139 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7142 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7145 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7148 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7151 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7154 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
7155 final Phylogeny t8 = factory.create( sb8.toString(), new NHXParser() )[ 0 ];
7157 t8.getNode( "cd" ).setCollapse( true );
7158 t8.getNode( "c" ).setCollapse( true );
7159 t8.getNode( "d" ).setCollapse( true );
7160 n = t8.getNode( "a" );
7161 while ( n != null ) {
7163 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7165 if ( ext.size() != 7 ) {
7168 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7171 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7174 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
7175 System.out.println( "2 fail" );
7178 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7181 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
7184 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
7187 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
7190 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7191 final Phylogeny t9 = factory.create( sb9.toString(), new NHXParser() )[ 0 ];
7193 t9.getNode( "gh" ).setCollapse( true );
7194 n = t9.getNode( "a" );
7195 while ( n != null ) {
7197 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7199 if ( ext.size() != 7 ) {
7202 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7205 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7208 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7211 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7214 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7217 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7220 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7223 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7224 final Phylogeny t10 = factory.create( sb10.toString(), new NHXParser() )[ 0 ];
7226 t10.getNode( "gh" ).setCollapse( true );
7227 t10.getNode( "g" ).setCollapse( true );
7228 t10.getNode( "h" ).setCollapse( true );
7229 n = t10.getNode( "a" );
7230 while ( n != null ) {
7232 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7234 if ( ext.size() != 7 ) {
7237 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7240 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7243 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7246 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7249 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7252 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
7255 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
7258 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7259 final Phylogeny t11 = factory.create( sb11.toString(), new NHXParser() )[ 0 ];
7261 t11.getNode( "gh" ).setCollapse( true );
7262 t11.getNode( "fgh" ).setCollapse( true );
7263 n = t11.getNode( "a" );
7264 while ( n != null ) {
7266 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7268 if ( ext.size() != 6 ) {
7271 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7274 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7277 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7280 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7283 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7286 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7289 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7290 final Phylogeny t12 = factory.create( sb12.toString(), new NHXParser() )[ 0 ];
7292 t12.getNode( "gh" ).setCollapse( true );
7293 t12.getNode( "fgh" ).setCollapse( true );
7294 t12.getNode( "g" ).setCollapse( true );
7295 t12.getNode( "h" ).setCollapse( true );
7296 t12.getNode( "f" ).setCollapse( true );
7297 n = t12.getNode( "a" );
7298 while ( n != null ) {
7300 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7302 if ( ext.size() != 6 ) {
7305 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
7308 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
7311 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
7314 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
7317 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
7320 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7323 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
7324 final Phylogeny t13 = factory.create( sb13.toString(), new NHXParser() )[ 0 ];
7326 t13.getNode( "ab" ).setCollapse( true );
7327 t13.getNode( "b" ).setCollapse( true );
7328 t13.getNode( "fgh" ).setCollapse( true );
7329 t13.getNode( "gh" ).setCollapse( true );
7330 n = t13.getNode( "ab" );
7331 while ( n != null ) {
7333 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7335 if ( ext.size() != 5 ) {
7338 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7341 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7344 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7347 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7350 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7353 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
7354 final Phylogeny t14 = factory.create( sb14.toString(), new NHXParser() )[ 0 ];
7356 t14.getNode( "ab" ).setCollapse( true );
7357 t14.getNode( "a" ).setCollapse( true );
7358 t14.getNode( "fgh" ).setCollapse( true );
7359 t14.getNode( "gh" ).setCollapse( true );
7360 n = t14.getNode( "ab" );
7361 while ( n != null ) {
7363 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7365 if ( ext.size() != 5 ) {
7368 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7371 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7374 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7377 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7380 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
7383 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" );
7384 final Phylogeny t15 = factory.create( sb15.toString(), new NHXParser() )[ 0 ];
7386 t15.getNode( "ab" ).setCollapse( true );
7387 t15.getNode( "a" ).setCollapse( true );
7388 t15.getNode( "fgh" ).setCollapse( true );
7389 t15.getNode( "gh" ).setCollapse( true );
7390 n = t15.getNode( "ab" );
7391 while ( n != null ) {
7393 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7395 if ( ext.size() != 6 ) {
7398 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7401 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
7404 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
7407 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
7410 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
7413 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
7418 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" );
7419 final Phylogeny t16 = factory.create( sb16.toString(), new NHXParser() )[ 0 ];
7421 t16.getNode( "ab" ).setCollapse( true );
7422 t16.getNode( "a" ).setCollapse( true );
7423 t16.getNode( "fgh" ).setCollapse( true );
7424 t16.getNode( "gh" ).setCollapse( true );
7425 t16.getNode( "cd" ).setCollapse( true );
7426 t16.getNode( "cde" ).setCollapse( true );
7427 t16.getNode( "d" ).setCollapse( true );
7428 t16.getNode( "x" ).setCollapse( true );
7429 n = t16.getNode( "ab" );
7430 while ( n != null ) {
7432 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
7434 if ( ext.size() != 4 ) {
7437 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
7440 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
7443 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
7446 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
7450 catch ( final Exception e ) {
7451 e.printStackTrace( System.out );
7457 private static boolean testNexusCharactersParsing() {
7459 final NexusCharactersParser parser = new NexusCharactersParser();
7460 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
7462 String[] labels = parser.getCharStateLabels();
7463 if ( labels.length != 7 ) {
7466 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7469 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7472 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7475 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7478 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7481 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7484 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7487 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7489 labels = parser.getCharStateLabels();
7490 if ( labels.length != 7 ) {
7493 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7496 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7499 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7502 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7505 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7508 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7511 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7515 catch ( final Exception e ) {
7516 e.printStackTrace( System.out );
7522 private static boolean testNexusMatrixParsing() {
7524 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7525 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7527 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7528 if ( m.getNumberOfCharacters() != 9 ) {
7531 if ( m.getNumberOfIdentifiers() != 5 ) {
7534 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7537 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7540 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7543 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7546 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7549 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7552 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7555 // if ( labels.length != 7 ) {
7558 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7561 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7564 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7567 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7570 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7573 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7576 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7579 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7581 // labels = parser.getCharStateLabels();
7582 // if ( labels.length != 7 ) {
7585 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7588 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7591 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7594 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7597 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7600 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7603 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7607 catch ( final Exception e ) {
7608 e.printStackTrace( System.out );
7614 private static boolean testNexusTreeParsing() {
7616 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7617 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7618 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7619 if ( phylogenies.length != 1 ) {
7622 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7625 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7629 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7630 if ( phylogenies.length != 1 ) {
7633 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7636 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7640 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7641 if ( phylogenies.length != 1 ) {
7644 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7647 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7650 if ( phylogenies[ 0 ].isRooted() ) {
7654 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7655 if ( phylogenies.length != 18 ) {
7658 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7661 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7664 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7667 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7670 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7673 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7676 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7679 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7682 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7685 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7688 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7691 if ( phylogenies[ 8 ].isRooted() ) {
7694 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7697 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7700 if ( !phylogenies[ 9 ].isRooted() ) {
7703 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7706 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7709 if ( !phylogenies[ 10 ].isRooted() ) {
7712 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7715 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7718 if ( phylogenies[ 11 ].isRooted() ) {
7721 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7724 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7727 if ( !phylogenies[ 12 ].isRooted() ) {
7730 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7733 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7736 if ( !phylogenies[ 13 ].isRooted() ) {
7739 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7742 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7745 if ( !phylogenies[ 14 ].isRooted() ) {
7748 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7751 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7754 if ( phylogenies[ 15 ].isRooted() ) {
7757 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7760 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7763 if ( !phylogenies[ 16 ].isRooted() ) {
7766 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7769 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7772 if ( phylogenies[ 17 ].isRooted() ) {
7775 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7778 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7780 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7781 if ( phylogenies.length != 9 ) {
7784 if ( !isEqual( 0.48039661496919533,
7785 phylogenies[ 0 ].getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7788 if ( !isEqual( 0.3959796191512233,
7789 phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7792 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7795 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7798 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7801 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7804 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7808 catch ( final Exception e ) {
7809 e.printStackTrace( System.out );
7815 private static boolean testNexusTreeParsingIterating() {
7817 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7818 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7819 if ( !p.hasNext() ) {
7822 Phylogeny phy = p.next();
7823 if ( phy == null ) {
7826 if ( phy.getNumberOfExternalNodes() != 25 ) {
7829 if ( !phy.getName().equals( "" ) ) {
7832 if ( p.hasNext() ) {
7836 if ( phy != null ) {
7840 if ( !p.hasNext() ) {
7844 if ( phy == null ) {
7847 if ( phy.getNumberOfExternalNodes() != 25 ) {
7850 if ( !phy.getName().equals( "" ) ) {
7853 if ( p.hasNext() ) {
7857 if ( phy != null ) {
7860 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7861 if ( !p.hasNext() ) {
7865 if ( phy == null ) {
7868 if ( phy.getNumberOfExternalNodes() != 10 ) {
7871 if ( !phy.getName().equals( "name" ) ) {
7874 if ( p.hasNext() ) {
7878 if ( phy != null ) {
7882 if ( !p.hasNext() ) {
7886 if ( phy == null ) {
7889 if ( phy.getNumberOfExternalNodes() != 10 ) {
7892 if ( !phy.getName().equals( "name" ) ) {
7895 if ( p.hasNext() ) {
7899 if ( phy != null ) {
7902 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7903 if ( !p.hasNext() ) {
7907 if ( phy == null ) {
7910 if ( phy.getNumberOfExternalNodes() != 3 ) {
7913 if ( !phy.getName().equals( "" ) ) {
7916 if ( phy.isRooted() ) {
7919 if ( p.hasNext() ) {
7923 if ( phy != null ) {
7928 if ( !p.hasNext() ) {
7932 if ( phy == null ) {
7935 if ( phy.getNumberOfExternalNodes() != 3 ) {
7938 if ( !phy.getName().equals( "" ) ) {
7941 if ( p.hasNext() ) {
7945 if ( phy != null ) {
7949 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7950 if ( !p.hasNext() ) {
7955 if ( phy == null ) {
7958 if ( phy.getNumberOfExternalNodes() != 10 ) {
7961 if ( !phy.getName().equals( "tree 0" ) ) {
7965 if ( !p.hasNext() ) {
7969 if ( phy == null ) {
7972 if ( phy.getNumberOfExternalNodes() != 10 ) {
7975 if ( !phy.getName().equals( "tree 1" ) ) {
7979 if ( !p.hasNext() ) {
7983 if ( phy == null ) {
7986 if ( phy.getNumberOfExternalNodes() != 3 ) {
7987 System.out.println( phy.toString() );
7990 if ( !phy.getName().equals( "" ) ) {
7993 if ( phy.isRooted() ) {
7997 if ( !p.hasNext() ) {
8001 if ( phy == null ) {
8004 if ( phy.getNumberOfExternalNodes() != 4 ) {
8007 if ( !phy.getName().equals( "" ) ) {
8010 if ( !phy.isRooted() ) {
8014 if ( !p.hasNext() ) {
8018 if ( phy == null ) {
8021 if ( phy.getNumberOfExternalNodes() != 5 ) {
8022 System.out.println( phy.getNumberOfExternalNodes() );
8025 if ( !phy.getName().equals( "" ) ) {
8028 if ( !phy.isRooted() ) {
8032 if ( !p.hasNext() ) {
8036 if ( phy == null ) {
8039 if ( phy.getNumberOfExternalNodes() != 3 ) {
8042 if ( !phy.getName().equals( "" ) ) {
8045 if ( phy.isRooted() ) {
8049 if ( !p.hasNext() ) {
8053 if ( phy == null ) {
8056 if ( phy.getNumberOfExternalNodes() != 2 ) {
8059 if ( !phy.getName().equals( "" ) ) {
8062 if ( !phy.isRooted() ) {
8066 if ( !p.hasNext() ) {
8070 if ( phy.getNumberOfExternalNodes() != 3 ) {
8073 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8076 if ( !phy.isRooted() ) {
8080 if ( !p.hasNext() ) {
8084 if ( phy.getNumberOfExternalNodes() != 3 ) {
8087 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
8090 if ( !phy.getName().equals( "tree 8" ) ) {
8094 if ( !p.hasNext() ) {
8098 if ( phy.getNumberOfExternalNodes() != 3 ) {
8101 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
8104 if ( !phy.getName().equals( "tree 9" ) ) {
8108 if ( !p.hasNext() ) {
8112 if ( phy.getNumberOfExternalNodes() != 3 ) {
8115 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8118 if ( !phy.getName().equals( "tree 10" ) ) {
8121 if ( !phy.isRooted() ) {
8125 if ( !p.hasNext() ) {
8129 if ( phy.getNumberOfExternalNodes() != 3 ) {
8132 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
8135 if ( !phy.getName().equals( "tree 11" ) ) {
8138 if ( phy.isRooted() ) {
8142 if ( !p.hasNext() ) {
8146 if ( phy.getNumberOfExternalNodes() != 3 ) {
8149 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
8152 if ( !phy.getName().equals( "tree 12" ) ) {
8155 if ( !phy.isRooted() ) {
8159 if ( !p.hasNext() ) {
8163 if ( phy.getNumberOfExternalNodes() != 3 ) {
8166 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
8169 if ( !phy.getName().equals( "tree 13" ) ) {
8172 if ( !phy.isRooted() ) {
8176 if ( !p.hasNext() ) {
8180 if ( phy.getNumberOfExternalNodes() != 10 ) {
8181 System.out.println( phy.getNumberOfExternalNodes() );
8184 if ( !phy.toNewHampshire()
8185 .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;" ) ) {
8186 System.out.println( phy.toNewHampshire() );
8189 if ( !phy.getName().equals( "tree 14" ) ) {
8192 if ( !phy.isRooted() ) {
8196 if ( !p.hasNext() ) {
8200 if ( phy.getNumberOfExternalNodes() != 10 ) {
8201 System.out.println( phy.getNumberOfExternalNodes() );
8204 if ( !phy.toNewHampshire()
8205 .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;" ) ) {
8206 System.out.println( phy.toNewHampshire() );
8209 if ( !phy.getName().equals( "tree 15" ) ) {
8212 if ( phy.isRooted() ) {
8216 if ( !p.hasNext() ) {
8220 if ( phy.getNumberOfExternalNodes() != 10 ) {
8221 System.out.println( phy.getNumberOfExternalNodes() );
8224 if ( !phy.toNewHampshire()
8225 .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;" ) ) {
8226 System.out.println( phy.toNewHampshire() );
8229 if ( !phy.getName().equals( "tree 16" ) ) {
8232 if ( !phy.isRooted() ) {
8236 if ( !p.hasNext() ) {
8240 if ( phy.getNumberOfExternalNodes() != 10 ) {
8241 System.out.println( phy.getNumberOfExternalNodes() );
8244 if ( !phy.toNewHampshire()
8245 .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;" ) ) {
8246 System.out.println( phy.toNewHampshire() );
8249 if ( !phy.getName().equals( "tree 17" ) ) {
8252 if ( phy.isRooted() ) {
8256 if ( p.hasNext() ) {
8260 if ( phy != null ) {
8265 if ( !p.hasNext() ) {
8269 if ( phy == null ) {
8272 if ( phy.getNumberOfExternalNodes() != 10 ) {
8275 if ( !phy.getName().equals( "tree 0" ) ) {
8279 if ( !p.hasNext() ) {
8283 if ( phy == null ) {
8286 if ( phy.getNumberOfExternalNodes() != 10 ) {
8289 if ( !phy.getName().equals( "tree 1" ) ) {
8293 if ( !p.hasNext() ) {
8297 if ( phy == null ) {
8300 if ( phy.getNumberOfExternalNodes() != 3 ) {
8303 if ( !phy.getName().equals( "" ) ) {
8306 if ( phy.isRooted() ) {
8310 if ( !p.hasNext() ) {
8314 if ( phy == null ) {
8317 if ( phy.getNumberOfExternalNodes() != 4 ) {
8320 if ( !phy.getName().equals( "" ) ) {
8323 if ( !phy.isRooted() ) {
8327 if ( !p.hasNext() ) {
8331 if ( phy == null ) {
8334 if ( phy.getNumberOfExternalNodes() != 5 ) {
8335 System.out.println( phy.getNumberOfExternalNodes() );
8338 if ( !phy.getName().equals( "" ) ) {
8341 if ( !phy.isRooted() ) {
8345 if ( !p.hasNext() ) {
8349 if ( phy == null ) {
8352 if ( phy.getNumberOfExternalNodes() != 3 ) {
8355 if ( !phy.getName().equals( "" ) ) {
8358 if ( phy.isRooted() ) {
8362 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
8363 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
8365 if ( !p2.hasNext() ) {
8369 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8372 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8376 if ( !p2.hasNext() ) {
8381 if ( !p2.hasNext() ) {
8386 if ( !p2.hasNext() ) {
8391 if ( !p2.hasNext() ) {
8396 if ( !p2.hasNext() ) {
8401 if ( !p2.hasNext() ) {
8406 if ( !p2.hasNext() ) {
8411 if ( !p2.hasNext() ) {
8415 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
8418 if ( p2.hasNext() ) {
8422 if ( phy != null ) {
8427 if ( !p2.hasNext() ) {
8431 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
8434 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
8438 catch ( final Exception e ) {
8439 e.printStackTrace( System.out );
8445 private static boolean testNexusTreeParsingTranslating() {
8447 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8448 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
8449 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
8450 if ( phylogenies.length != 1 ) {
8453 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8456 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8459 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8462 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8465 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8466 .equals( "Aranaeus" ) ) {
8470 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
8471 if ( phylogenies.length != 3 ) {
8474 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8477 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8480 if ( phylogenies[ 0 ].isRooted() ) {
8483 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8486 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8489 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8490 .equals( "Aranaeus" ) ) {
8493 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8496 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8499 if ( phylogenies[ 1 ].isRooted() ) {
8502 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8505 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8508 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8509 .equals( "Aranaeus" ) ) {
8512 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8515 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8518 if ( !phylogenies[ 2 ].isRooted() ) {
8521 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8524 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8527 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8528 .equals( "Aranaeus" ) ) {
8532 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8533 if ( phylogenies.length != 3 ) {
8536 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8539 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8542 if ( phylogenies[ 0 ].isRooted() ) {
8545 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8548 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8551 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8552 .equals( "Aranaeus" ) ) {
8555 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8558 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8561 if ( phylogenies[ 1 ].isRooted() ) {
8564 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8567 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8570 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8571 .equals( "Aranaeus" ) ) {
8574 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8577 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8580 if ( !phylogenies[ 2 ].isRooted() ) {
8583 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8586 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8589 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8590 .equals( "Aranaeus" ) ) {
8593 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8594 if ( phylogenies.length != 3 ) {
8597 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8602 catch ( final Exception e ) {
8603 e.printStackTrace( System.out );
8609 private static boolean testNHParsing() {
8611 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8612 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8613 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8616 final NHXParser nhxp = new NHXParser();
8617 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8618 nhxp.setReplaceUnderscores( true );
8619 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8620 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8623 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8626 final Phylogeny p1b = factory.create(
8627 " \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 ",
8628 new NHXParser() )[ 0 ];
8629 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8632 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8635 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ).toString(), new NHXParser() )[ 0 ];
8636 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8637 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8638 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ).toString(), new NHXParser() )[ 0 ];
8639 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8640 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8641 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8642 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8643 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8644 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8645 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8646 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; " + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8648 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8651 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8654 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8657 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8660 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8661 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8662 final String p16_S = "((A,B),C)";
8663 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8664 if ( p16.length != 1 ) {
8667 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8670 final String p17_S = "(C,(A,B))";
8671 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8672 if ( p17.length != 1 ) {
8675 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8678 final String p18_S = "((A,B),(C,D))";
8679 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8680 if ( p18.length != 1 ) {
8683 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8686 final String p19_S = "(((A,B),C),D)";
8687 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8688 if ( p19.length != 1 ) {
8691 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8694 final String p20_S = "(A,(B,(C,D)))";
8695 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8696 if ( p20.length != 1 ) {
8699 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8702 final String p21_S = "(A,(B,(C,(D,E))))";
8703 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8704 if ( p21.length != 1 ) {
8707 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8710 final String p22_S = "((((A,B),C),D),E)";
8711 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8712 if ( p22.length != 1 ) {
8715 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8718 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8719 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8720 if ( p23.length != 1 ) {
8721 System.out.println( "xl=" + p23.length );
8725 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8728 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8729 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8730 if ( p24.length != 1 ) {
8733 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8736 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8737 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8738 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8739 if ( p241.length != 2 ) {
8742 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8745 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8748 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8749 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8750 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8751 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8752 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8753 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8754 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8755 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8756 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8757 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8760 final String p26_S = "(A,B)ab";
8761 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8762 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8765 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8766 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8767 if ( p27s.length != 1 ) {
8768 System.out.println( "xxl=" + p27s.length );
8772 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8773 System.out.println( p27s[ 0 ].toNewHampshireX() );
8777 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8779 if ( p27.length != 1 ) {
8780 System.out.println( "yl=" + p27.length );
8784 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8785 System.out.println( p27[ 0 ].toNewHampshireX() );
8789 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8790 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8791 final String p28_S3 = "(A,B)ab";
8792 final String p28_S4 = "((((A,B),C),D),;E;)";
8793 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8795 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8798 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8801 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8804 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8807 if ( p28.length != 4 ) {
8810 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";
8811 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8812 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8815 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";
8816 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8817 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8820 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8821 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8822 if ( ( p32.length != 0 ) ) {
8825 final String p33_S = "A";
8826 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8827 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8830 final String p34_S = "B;";
8831 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8832 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8835 final String p35_S = "B:0.2";
8836 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8837 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8840 final String p36_S = "(A)";
8841 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8842 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8845 final String p37_S = "((A))";
8846 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8847 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8850 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8851 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8852 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8855 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8856 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8857 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8860 final String p40_S = "(A,B,C)";
8861 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8862 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8865 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8866 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8867 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8870 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8871 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8872 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8875 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)";
8876 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8877 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8880 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)))";
8881 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8882 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8885 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8886 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8887 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8890 final String p46_S = "";
8891 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8892 if ( p46.length != 0 ) {
8895 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ).toString(),
8896 new NHXParser() )[ 0 ];
8897 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8900 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ).toString(),
8901 new NHXParser() )[ 0 ];
8902 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8905 final Phylogeny p49 = factory
8906 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ).toString(),
8907 new NHXParser() )[ 0 ];
8908 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8911 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ).toString(),
8912 new NHXParser() )[ 0 ];
8913 if ( p50.getNode( "A" ) == null ) {
8916 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8917 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8920 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8923 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8924 .equals( "((A,B)88:2.0,C);" ) ) {
8927 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ).toString(),
8928 new NHXParser() )[ 0 ];
8929 if ( p51.getNode( "A(A" ) == null ) {
8932 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ).toString(),
8933 new NHXParser() )[ 0 ];
8934 if ( p52.getNode( "A(A" ) == null ) {
8937 final Phylogeny p53 = factory
8938 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ).toString(),
8939 new NHXParser() )[ 0 ];
8940 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8943 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ).toString(),
8944 new NHXParser() )[ 0 ];
8945 if ( p54.getNode( "A" ) == null ) {
8948 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8949 .equals( "((A,B)[88],C);" ) ) {
8952 final Phylogeny p55 = factory
8953 .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);" )
8954 .toString(), new NHXParser() )[ 0 ];
8955 if ( !p55.toNewHampshire()
8956 .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);" ) ) {
8957 System.out.println( p55.toNewHampshire() );
8960 final Phylogeny p56 = factory
8961 .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);" )
8962 .toString(), new NHXParser() )[ 0 ];
8963 if ( !p56.toNewHampshire()
8964 .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);" ) ) {
8965 System.out.println( p56.toNewHampshire() );
8968 final Phylogeny p57 = factory
8969 .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);" )
8970 .toString(), new NHXParser() )[ 0 ];
8971 if ( !p57.toNewHampshire()
8972 .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);" ) ) {
8973 System.out.println( p56.toNewHampshire() );
8976 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8977 final Phylogeny p58 = factory.create( s58, new NHXParser() )[ 0 ];
8978 if ( !p58.toNewHampshire().equals( s58 ) ) {
8979 System.out.println( p58.toNewHampshire() );
8982 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8983 final Phylogeny p59 = factory.create( s59, new NHXParser() )[ 0 ];
8984 if ( !p59.toNewHampshire().equals( s59 ) ) {
8985 System.out.println( p59.toNewHampshire() );
8988 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8989 final Phylogeny p60 = factory.create( s60, new NHXParser() )[ 0 ];
8990 if ( !p60.toNewHampshire().equals( s60 ) ) {
8991 System.out.println( p60.toNewHampshire() );
8994 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8995 final Phylogeny p61 = factory.create( s61, new NHXParser() )[ 0 ];
8996 if ( !p61.toNewHampshire()
8997 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8998 System.out.println( p61.toNewHampshire() );
9001 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;";
9002 final Phylogeny p62 = factory.create( s62, new NHXParser() )[ 0 ];
9003 if ( !p62.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9004 System.out.println( p62.toNewHampshire() );
9007 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)\"];";
9008 final Phylogeny p63 = factory.create( s63, new NHXParser() )[ 0 ];
9009 if ( !p63.toNewHampshire().equals( "(1:0.003,2:0.004):0.0;" ) ) {
9010 System.out.println( p63.toNewHampshire() );
9013 final String s64 = "((1,2):[95.5],3);";
9014 final Phylogeny p64 = factory.create( s64, new NHXParser() )[ 0 ];
9015 if ( !p64.toNewHampshireX().equals( "((1,2)[&&NHX:B=95.5],3)" ) ) {
9016 System.out.println( p64.toNewHampshireX() );
9019 final String s65 = "((1:0.1,2:0.2):0.3[10.2],3);";
9020 final Phylogeny p65 = factory.create( s65, new NHXParser() )[ 0 ];
9021 if ( !p65.toNewHampshireX().equals( "((1:0.1,2:0.2):0.3[&&NHX:B=10.2],3)" ) ) {
9022 System.out.println( p65.toNewHampshireX() );
9025 final Phylogeny p66 = factory.create( "((A,B)ab:2[0.44],C)", new NHXParser() )[ 0 ];
9026 if ( !isEqual( 0.44, p66.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
9029 final Phylogeny p67 = factory.create( "((A,B):2[0.67],C)", new NHXParser() )[ 0 ];
9030 if ( !isEqual( 0.67, p67.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9033 final Phylogeny p68 = factory.create( "((A,B):[0.68],C)", new NHXParser() )[ 0 ];
9034 if ( !isEqual( 0.68, p68.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9037 final Phylogeny p69 = factory.create( "((A,B)[0.69],C)", new NHXParser() )[ 0 ];
9038 if ( !isEqual( 0.69, p69.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9041 final Phylogeny p70 = factory.create( "((A,B)[+0.7],C)", new NHXParser() )[ 0 ];
9042 if ( !isEqual( 0.7, p70.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9045 final Phylogeny p71 = factory.create( "((A,B)[-0.71],C)", new NHXParser() )[ 0 ];
9046 if ( !isEqual( -0.71, p71.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9049 final Phylogeny p72 = factory.create( "((A,B)[],C)", new NHXParser() )[ 0 ];
9050 if ( !p72.toNewHampshireX().equals( "((A,B),C)" ) ) {
9053 final Phylogeny p73 = factory.create( "((A,B)[12x],C)", new NHXParser() )[ 0 ];
9054 if ( !p73.toNewHampshireX().equals( "((A,B),C)" ) ) {
9057 final Phylogeny p74 = factory.create( "((A,B)[12+],C)", new NHXParser() )[ 0 ];
9058 if ( !p74.toNewHampshireX().equals( "((A,B),C)" ) ) {
9061 final Phylogeny p75 = factory.create( "((A,B)ab[222]:3,C)", new NHXParser() )[ 0 ];
9062 if ( !isEqual( 222, p75.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9065 final Phylogeny p76 = factory.create( "((A,B)[100]:12,C)", new NHXParser() )[ 0 ];
9066 if ( !isEqual( 100, p76.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9069 final Phylogeny p77 = factory.create( "((A,B)abcde:13[77],C)", new NHXParser() )[ 0 ];
9070 if ( !isEqual( 77, p77.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9073 final Phylogeny p78 = factory.create( "((A,B):14[0],C)", new NHXParser() )[ 0 ];
9074 if ( !isEqual( 0, p78.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() ) ) {
9077 final String the_one = "((((((a,b)ab:3.0[2],c):12.0[100],(d,e)de)abcde:13.0[2],f):14.0[0]):0.0[0]):0.0[0];";
9078 final Phylogeny p79 = factory.create(
9079 "((((((a,b)ab[2]:3,c)[100]:12,(d,e)de)abcde:13[2],f):14[0]):0[0])[0]:0;",
9080 new NHXParser() )[ 0 ];
9081 final String str79 = p79.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9082 if ( !str79.equals( the_one ) ) {
9083 System.out.println( str79 );
9086 final Phylogeny p80 = factory.create(
9087 "((((((a[a)],b[12])ab[2]:3,c)[+100]:12,(d,e)de[12d,)])ab[]c[]de:13[2],f):14[0]):0[0])[0]:0;",
9088 new NHXParser() )[ 0 ];
9089 final String str80 = p80.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
9090 if ( !str80.equals( the_one ) ) {
9091 System.out.println( str80 );
9095 catch ( final Exception e ) {
9096 e.printStackTrace( System.out );
9102 private static boolean testNHParsingSpecialChars() {
9104 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9105 final String i0 = "(A!+=~QWERTY!@#$%^&*-,€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜˜˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±¹²³´µ¶·¸º»¼¿À÷þÿ)";
9106 final Phylogeny p0 = factory.create( i0, new NHXParser() )[ 0 ];
9107 if ( !p0.toNewHampshireX().equals( i0 ) ) {
9108 System.out.println();
9109 System.out.println( p0.toNewHampshireX() );
9110 System.out.println( i0 );
9113 final String i1 = "(हिंदी,한글,ไทย,'Tiếng Việt',ひらがなカタカナ漢字,繁體字,русский)";
9114 final Phylogeny p1 = factory.create( i1, new NHXParser() )[ 0 ];
9115 if ( !p1.toNewHampshireX().equals( i1 ) ) {
9116 System.out.println();
9117 System.out.println( p1.toNewHampshireX() );
9118 System.out.println( i1 );
9122 catch ( final Exception e ) {
9123 e.printStackTrace( System.out );
9129 private static boolean testNHParsingIter() {
9131 final String p0_str = "(A,B);";
9132 final NHXParser p = new NHXParser();
9133 p.setSource( p0_str );
9134 if ( !p.hasNext() ) {
9137 final Phylogeny p0 = p.next();
9138 if ( !p0.toNewHampshire().equals( p0_str ) ) {
9139 System.out.println( p0.toNewHampshire() );
9142 if ( p.hasNext() ) {
9145 if ( p.next() != null ) {
9149 final String p00_str = "(A,B)root;";
9150 p.setSource( p00_str );
9151 final Phylogeny p00 = p.next();
9152 if ( !p00.toNewHampshire().equals( p00_str ) ) {
9153 System.out.println( p00.toNewHampshire() );
9157 final String p000_str = "A;";
9158 p.setSource( p000_str );
9159 final Phylogeny p000 = p.next();
9160 if ( !p000.toNewHampshire().equals( p000_str ) ) {
9161 System.out.println( p000.toNewHampshire() );
9165 final String p0000_str = "A";
9166 p.setSource( p0000_str );
9167 final Phylogeny p0000 = p.next();
9168 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
9169 System.out.println( p0000.toNewHampshire() );
9173 p.setSource( "(A)" );
9174 final Phylogeny p00000 = p.next();
9175 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
9176 System.out.println( p00000.toNewHampshire() );
9180 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
9181 p.setSource( p1_str );
9182 if ( !p.hasNext() ) {
9185 final Phylogeny p1_0 = p.next();
9186 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
9187 System.out.println( p1_0.toNewHampshire() );
9190 if ( !p.hasNext() ) {
9193 final Phylogeny p1_1 = p.next();
9194 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
9195 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
9198 if ( !p.hasNext() ) {
9201 final Phylogeny p1_2 = p.next();
9202 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
9203 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
9206 if ( !p.hasNext() ) {
9209 final Phylogeny p1_3 = p.next();
9210 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
9211 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
9214 if ( p.hasNext() ) {
9217 if ( p.next() != null ) {
9221 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
9222 p.setSource( p2_str );
9223 if ( !p.hasNext() ) {
9226 Phylogeny p2_0 = p.next();
9227 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9228 System.out.println( p2_0.toNewHampshire() );
9231 if ( !p.hasNext() ) {
9234 Phylogeny p2_1 = p.next();
9235 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9236 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9239 if ( !p.hasNext() ) {
9242 Phylogeny p2_2 = p.next();
9243 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9244 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9247 if ( !p.hasNext() ) {
9250 Phylogeny p2_3 = p.next();
9251 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9252 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9255 if ( !p.hasNext() ) {
9258 Phylogeny p2_4 = p.next();
9259 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9260 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9263 if ( p.hasNext() ) {
9266 if ( p.next() != null ) {
9271 if ( !p.hasNext() ) {
9275 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
9276 System.out.println( p2_0.toNewHampshire() );
9279 if ( !p.hasNext() ) {
9283 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
9284 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
9287 if ( !p.hasNext() ) {
9291 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
9292 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
9295 if ( !p.hasNext() ) {
9299 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
9300 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
9303 if ( !p.hasNext() ) {
9307 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
9308 System.out.println( "(X) != " + p2_4.toNewHampshire() );
9311 if ( p.hasNext() ) {
9314 if ( p.next() != null ) {
9318 final String p3_str = "((A,B),C)abc";
9319 p.setSource( p3_str );
9320 if ( !p.hasNext() ) {
9323 final Phylogeny p3_0 = p.next();
9324 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
9327 if ( p.hasNext() ) {
9330 if ( p.next() != null ) {
9334 final String p4_str = "((A,B)ab,C)abc";
9335 p.setSource( p4_str );
9336 if ( !p.hasNext() ) {
9339 final Phylogeny p4_0 = p.next();
9340 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
9343 if ( p.hasNext() ) {
9346 if ( p.next() != null ) {
9350 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
9351 p.setSource( p5_str );
9352 if ( !p.hasNext() ) {
9355 final Phylogeny p5_0 = p.next();
9356 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
9359 if ( p.hasNext() ) {
9362 if ( p.next() != null ) {
9366 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
9367 p.setSource( p6_str );
9368 if ( !p.hasNext() ) {
9371 Phylogeny p6_0 = p.next();
9372 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9375 if ( p.hasNext() ) {
9378 if ( p.next() != null ) {
9382 if ( !p.hasNext() ) {
9386 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
9389 if ( p.hasNext() ) {
9392 if ( p.next() != null ) {
9396 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
9397 p.setSource( p7_str );
9398 if ( !p.hasNext() ) {
9401 Phylogeny p7_0 = p.next();
9402 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9405 if ( p.hasNext() ) {
9408 if ( p.next() != null ) {
9412 if ( !p.hasNext() ) {
9416 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9419 if ( p.hasNext() ) {
9422 if ( p.next() != null ) {
9426 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
9427 p.setSource( p8_str );
9428 if ( !p.hasNext() ) {
9431 Phylogeny p8_0 = p.next();
9432 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9435 if ( !p.hasNext() ) {
9438 if ( !p.hasNext() ) {
9441 Phylogeny p8_1 = p.next();
9442 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9445 if ( p.hasNext() ) {
9448 if ( p.next() != null ) {
9452 if ( !p.hasNext() ) {
9456 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
9459 if ( !p.hasNext() ) {
9463 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
9466 if ( p.hasNext() ) {
9469 if ( p.next() != null ) {
9475 if ( p.hasNext() ) {
9479 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
9480 if ( !p.hasNext() ) {
9483 Phylogeny p_27 = p.next();
9484 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9485 System.out.println( p_27.toNewHampshireX() );
9489 if ( p.hasNext() ) {
9492 if ( p.next() != null ) {
9496 if ( !p.hasNext() ) {
9500 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
9501 System.out.println( p_27.toNewHampshireX() );
9505 if ( p.hasNext() ) {
9508 if ( p.next() != null ) {
9512 final String p30_str = "(A,B);(C,D)";
9513 final NHXParser p30 = new NHXParser();
9514 p30.setSource( p30_str );
9515 if ( !p30.hasNext() ) {
9518 Phylogeny phy30 = p30.next();
9519 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9520 System.out.println( phy30.toNewHampshire() );
9523 if ( !p30.hasNext() ) {
9526 Phylogeny phy301 = p30.next();
9527 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9528 System.out.println( phy301.toNewHampshire() );
9531 if ( p30.hasNext() ) {
9534 if ( p30.hasNext() ) {
9537 if ( p30.next() != null ) {
9540 if ( p30.next() != null ) {
9544 if ( !p30.hasNext() ) {
9548 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
9549 System.out.println( phy30.toNewHampshire() );
9552 if ( !p30.hasNext() ) {
9555 phy301 = p30.next();
9556 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
9557 System.out.println( phy301.toNewHampshire() );
9560 if ( p30.hasNext() ) {
9563 if ( p30.hasNext() ) {
9566 if ( p30.next() != null ) {
9569 if ( p30.next() != null ) {
9573 catch ( final Exception e ) {
9574 e.printStackTrace( System.out );
9580 private static boolean testNHXconversion() {
9582 final PhylogenyNode n1 = new PhylogenyNode();
9583 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9584 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9585 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9586 final PhylogenyNode n5 = PhylogenyNode
9587 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
9588 final PhylogenyNode n6 = PhylogenyNode
9589 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
9590 if ( !n1.toNewHampshireX().equals( "" ) ) {
9593 if ( !n2.toNewHampshireX().equals( "" ) ) {
9596 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
9599 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
9602 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
9605 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
9606 System.out.println( n6.toNewHampshireX() );
9609 final PhylogenyNode n7 = new PhylogenyNode();
9610 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
9611 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
9612 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
9613 System.out.println( n7
9614 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9618 catch ( final Exception e ) {
9619 e.printStackTrace( System.out );
9625 private static boolean testNHXNodeParsing() {
9627 final PhylogenyNode n1 = new PhylogenyNode();
9628 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9629 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9630 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9631 final PhylogenyNode n5 = PhylogenyNode
9632 .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]" );
9633 if ( !n3.getName().equals( "n3" ) ) {
9636 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9639 if ( n3.isDuplication() ) {
9642 if ( n3.isHasAssignedEvent() ) {
9645 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9648 if ( !n4.getName().equals( "n4" ) ) {
9651 if ( n4.getDistanceToParent() != 0.01 ) {
9654 if ( !n5.getName().equals( "n5" ) ) {
9657 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9660 if ( n5.getDistanceToParent() != 0.1 ) {
9663 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9666 if ( !n5.isDuplication() ) {
9669 if ( !n5.isHasAssignedEvent() ) {
9672 final PhylogenyNode n8 = PhylogenyNode
9673 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9674 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9675 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9678 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9681 final PhylogenyNode n9 = PhylogenyNode
9682 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9683 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9684 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9687 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9690 final PhylogenyNode n10 = PhylogenyNode
9691 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9692 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9695 final PhylogenyNode n20 = PhylogenyNode
9696 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9697 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9700 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9703 final PhylogenyNode n20x = PhylogenyNode
9704 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9705 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9708 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9711 final PhylogenyNode n20xx = PhylogenyNode
9712 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9713 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9716 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9719 final PhylogenyNode n20xxx = PhylogenyNode
9720 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9721 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9724 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9727 final PhylogenyNode n20xxxx = PhylogenyNode
9728 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9729 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9732 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9735 final PhylogenyNode n21 = PhylogenyNode
9736 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9737 if ( !n21.getName().equals( "N21_PIG" ) ) {
9740 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9743 final PhylogenyNode n21x = PhylogenyNode
9744 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9745 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9748 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9751 final PhylogenyNode n22 = PhylogenyNode
9752 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9753 if ( !n22.getName().equals( "n22/PIG" ) ) {
9756 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9759 final PhylogenyNode n23 = PhylogenyNode
9760 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9761 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9764 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9767 final PhylogenyNode a = PhylogenyNode
9768 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9769 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9772 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9775 final PhylogenyNode c1 = PhylogenyNode
9776 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9777 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9778 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9781 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9784 final PhylogenyNode c2 = PhylogenyNode
9785 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9786 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9787 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9790 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9793 final PhylogenyNode e3 = PhylogenyNode
9794 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9795 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9798 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9801 final PhylogenyNode n11 = PhylogenyNode
9802 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9803 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9804 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9807 if ( n11.getDistanceToParent() != 0.4 ) {
9810 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9813 final PhylogenyNode n12 = PhylogenyNode
9814 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9815 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9816 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9819 if ( n12.getDistanceToParent() != 0.4 ) {
9822 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9825 final PhylogenyNode o = PhylogenyNode
9826 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9827 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9830 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9833 if ( n1.getName().compareTo( "" ) != 0 ) {
9836 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9839 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9842 if ( n2.getName().compareTo( "" ) != 0 ) {
9845 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9848 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9851 final PhylogenyNode n00 = PhylogenyNode
9852 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9853 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9856 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9859 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9860 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9863 final PhylogenyNode n13 = PhylogenyNode
9864 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9865 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9868 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9871 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9874 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9877 final PhylogenyNode n14 = PhylogenyNode
9878 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9879 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9882 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9885 final PhylogenyNode n15 = PhylogenyNode
9886 .createInstanceFromNhxString( "something_wicked[123]",
9887 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9888 if ( !n15.getName().equals( "something_wicked" ) ) {
9891 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9894 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9897 final PhylogenyNode n16 = PhylogenyNode
9898 .createInstanceFromNhxString( "something_wicked2[9]",
9899 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9900 if ( !n16.getName().equals( "something_wicked2" ) ) {
9903 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9906 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9909 final PhylogenyNode n17 = PhylogenyNode
9910 .createInstanceFromNhxString( "something_wicked3[a]",
9911 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9912 if ( !n17.getName().equals( "something_wicked3" ) ) {
9915 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9918 final PhylogenyNode n18 = PhylogenyNode
9919 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9920 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9923 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9926 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9929 final PhylogenyNode n19 = PhylogenyNode
9930 .createInstanceFromNhxString( "BLAH_1-roejojoej",
9931 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9932 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9935 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9938 final PhylogenyNode n30 = PhylogenyNode
9939 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9940 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9941 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9944 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9947 final PhylogenyNode n31 = PhylogenyNode
9948 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9949 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9950 if ( n31.getNodeData().isHasTaxonomy() ) {
9953 final PhylogenyNode n32 = PhylogenyNode
9954 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9955 if ( n32.getNodeData().isHasTaxonomy() ) {
9958 final PhylogenyNode n40 = PhylogenyNode
9959 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9960 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9963 final PhylogenyNode n41 = PhylogenyNode
9964 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9965 if ( n41.getNodeData().isHasTaxonomy() ) {
9968 final PhylogenyNode n42 = PhylogenyNode
9969 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9970 if ( n42.getNodeData().isHasTaxonomy() ) {
9973 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9974 NHXParser.TAXONOMY_EXTRACTION.NO );
9975 if ( n43.getNodeData().isHasTaxonomy() ) {
9978 final PhylogenyNode n44 = PhylogenyNode
9979 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9980 if ( n44.getNodeData().isHasTaxonomy() ) {
9984 catch ( final Exception e ) {
9985 e.printStackTrace( System.out );
9991 private static boolean testNHXNodeParsing2() {
9993 final PhylogenyNode n0_0 = PhylogenyNode.createInstanceFromNhxString( "n0:[ignore me 123]:1E-3",
9994 NHXParser.TAXONOMY_EXTRACTION.NO,
9997 if ( !n0_0.getName().equals( "n0" ) ) {
10000 if ( !isEqual( n0_0.getDistanceToParent(), 0.001 ) ) {
10003 final PhylogenyNode n0_1 = PhylogenyNode.createInstanceFromNhxString( "n0[ignore me 123]:1E-3",
10004 NHXParser.TAXONOMY_EXTRACTION.NO,
10007 if ( !n0_1.getName().equals( "n0" ) ) {
10010 if ( !isEqual( n0_1.getDistanceToParent(), 0.001 ) ) {
10013 final PhylogenyNode n0_2 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3[ignore me 123]",
10014 NHXParser.TAXONOMY_EXTRACTION.NO,
10017 if ( !n0_2.getName().equals( "n0" ) ) {
10020 if ( !isEqual( n0_2.getDistanceToParent(), 0.001 ) ) {
10023 final PhylogenyNode n0_3 = PhylogenyNode.createInstanceFromNhxString( "n0:1E-3:[ignore me 123]",
10024 NHXParser.TAXONOMY_EXTRACTION.NO,
10027 if ( !n0_3.getName().equals( "n0" ) ) {
10030 if ( !isEqual( n0_3.getDistanceToParent(), 0.001 ) ) {
10033 final PhylogenyNode n0_4 = PhylogenyNode.createInstanceFromNhxString( "n0:0.001:[ignore me 123]",
10034 NHXParser.TAXONOMY_EXTRACTION.NO,
10037 if ( !n0_4.getName().equals( "n0" ) ) {
10040 if ( !isEqual( n0_4.getDistanceToParent(), 0.001 ) ) {
10043 final PhylogenyNode n1_0 = PhylogenyNode
10044 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]",
10045 NHXParser.TAXONOMY_EXTRACTION.NO,
10048 if ( !n1_0.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10051 if ( n1_0.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10054 final PhylogenyNode n1_1 = PhylogenyNode
10055 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&!color=#FFFFFF]:0.001",
10056 NHXParser.TAXONOMY_EXTRACTION.NO,
10059 if ( !n1_1.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10062 if ( n1_1.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10065 if ( !isEqual( n1_1.getDistanceToParent(), 0.001 ) ) {
10068 final PhylogenyNode n1_2 = PhylogenyNode
10069 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:0.001[&!color=#FFFFFF]",
10070 NHXParser.TAXONOMY_EXTRACTION.NO,
10073 if ( !n1_2.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10076 if ( n1_2.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10079 if ( !isEqual( n1_2.getDistanceToParent(), 0.001 ) ) {
10082 final PhylogenyNode n1_3 = PhylogenyNode
10083 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[&boostrap=69,&!color=#FFFFFF]",
10084 NHXParser.TAXONOMY_EXTRACTION.NO,
10087 if ( !n1_3.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10090 if ( n1_3.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10093 if ( !isEqual( n1_3.getDistanceToParent(), 0.001 ) ) {
10096 if ( !isEqual( n1_3.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10099 if ( !n1_3.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10102 final PhylogenyNode n1_4 = PhylogenyNode
10103 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&bootstrap=69,&!colour=#FFFFFF]:1e-3",
10104 NHXParser.TAXONOMY_EXTRACTION.NO,
10107 if ( !n1_4.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10110 if ( n1_4.getBranchData().getBranchColor().getValue().getGreen() != 255 ) {
10113 if ( !isEqual( n1_4.getDistanceToParent(), 0.001 ) ) {
10116 if ( !isEqual( n1_4.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10119 if ( !n1_4.getBranchData().getConfidence( 0 ).getType().equals( "bootstrap" ) ) {
10122 final PhylogenyNode n1_5 = PhylogenyNode
10123 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada:1e-3[69.0]",
10124 NHXParser.TAXONOMY_EXTRACTION.NO,
10127 if ( !n1_5.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10130 if ( !isEqual( n1_5.getDistanceToParent(), 0.001 ) ) {
10133 if ( !isEqual( n1_5.getBranchData().getConfidence( 0 ).getValue(), 69 ) ) {
10136 final PhylogenyNode n1_6 = PhylogenyNode
10137 .createInstanceFromNhxString( "xyz|A/American_duck/NH/00321/|Duck|Canada[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00]:1e-3",
10138 NHXParser.TAXONOMY_EXTRACTION.NO,
10141 if ( !n1_6.getName().equals( "xyz|A/American duck/NH/00321/|Duck|Canada" ) ) {
10144 if ( !isEqual( n1_6.getDistanceToParent(), 0.001 ) ) {
10147 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getStandardDeviation(), 0.11 ) ) {
10150 if ( !isEqual( n1_6.getBranchData().getConfidence( 0 ).getValue(), 0.95 ) ) {
10153 if ( !n1_6.getBranchData().getConfidence( 0 ).getType().equals( "posterior probability" ) ) {
10157 catch ( final Exception e ) {
10158 e.printStackTrace( System.out );
10164 private static boolean testNHXParsing() {
10166 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10167 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])",
10168 new NHXParser() )[ 0 ];
10169 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
10172 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]";
10173 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
10174 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10177 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]";
10178 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
10179 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
10182 final Phylogeny[] p3 = factory.create(
10183 "[ 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]",
10185 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10188 final Phylogeny[] p4 = factory.create(
10189 "(((((((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(]",
10191 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10194 final Phylogeny[] p5 = factory.create(
10195 "[] ( [][ ][ ] ([((( &&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(((]",
10197 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
10200 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)";
10201 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)";
10202 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
10203 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
10206 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)))";
10207 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)))";
10208 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
10209 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
10212 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]) ))[,,, ])))))))";
10213 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
10214 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
10215 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
10218 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
10219 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10222 final Phylogeny p10 = factory.create(
10223 " [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]",
10224 new NHXParser() )[ 0 ];
10225 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10228 final Phylogeny p11 = factory.create(
10229 " [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]",
10230 new NHXParser() )[ 0 ];
10231 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10234 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]",
10235 new NHXParser() )[ 0 ];
10236 if ( !p12.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
10240 catch ( final Exception e ) {
10241 e.printStackTrace( System.out );
10247 private static boolean testNHXParsingMB() {
10249 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10250 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
10251 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10252 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10253 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10254 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10255 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10256 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10257 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10258 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10259 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
10262 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
10265 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
10266 0.1100000000000000e+00 ) ) {
10269 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
10272 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
10275 final Phylogeny p2 = factory
10276 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
10277 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10278 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
10279 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
10280 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
10281 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
10282 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
10283 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
10284 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
10285 if ( p2.getNode( "1" ) == null ) {
10288 if ( p2.getNode( "2" ) == null ) {
10292 catch ( final Exception e ) {
10293 e.printStackTrace( System.out );
10300 private static boolean testNHXParsingQuotes() {
10302 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10303 final NHXParser p = new NHXParser();
10304 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
10305 if ( phylogenies_0.length != 5 ) {
10308 final Phylogeny phy = phylogenies_0[ 4 ];
10309 if ( phy.getNumberOfExternalNodes() != 7 ) {
10312 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
10315 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
10318 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
10319 .getScientificName().equals( "hsapiens" ) ) {
10322 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
10325 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
10328 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
10331 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
10334 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
10337 final NHXParser p1p = new NHXParser();
10338 p1p.setIgnoreQuotes( true );
10339 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
10340 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
10343 final NHXParser p2p = new NHXParser();
10344 p1p.setIgnoreQuotes( false );
10345 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
10346 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
10349 final NHXParser p3p = new NHXParser();
10350 p3p.setIgnoreQuotes( false );
10351 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
10352 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
10355 final NHXParser p4p = new NHXParser();
10356 p4p.setIgnoreQuotes( false );
10357 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
10358 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
10361 final Phylogeny p10 = factory.create(
10362 " [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]",
10363 new NHXParser() )[ 0 ];
10364 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]";
10365 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
10368 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
10369 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
10372 final Phylogeny p12 = factory.create(
10373 " [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]",
10374 new NHXParser() )[ 0 ];
10375 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]";
10376 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
10379 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
10380 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
10383 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;";
10384 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
10387 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
10388 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
10392 catch ( final Exception e ) {
10393 e.printStackTrace( System.out );
10399 private static boolean testNodeRemoval() {
10401 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10402 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
10403 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
10404 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
10407 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
10408 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
10409 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
10412 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
10413 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
10414 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
10418 catch ( final Exception e ) {
10419 e.printStackTrace( System.out );
10425 private static boolean testPhylogenyBranch() {
10427 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
10428 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
10429 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
10430 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
10431 if ( !a1b1.equals( a1b1 ) ) {
10434 if ( !a1b1.equals( b1a1 ) ) {
10437 if ( !b1a1.equals( a1b1 ) ) {
10440 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
10441 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
10442 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
10443 if ( a1_b1.equals( b1_a1 ) ) {
10446 if ( a1_b1.equals( a1_b1_ ) ) {
10449 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
10450 if ( !a1_b1.equals( b1_a1_ ) ) {
10453 if ( a1_b1_.equals( b1_a1_ ) ) {
10456 if ( !a1_b1_.equals( b1_a1 ) ) {
10460 catch ( final Exception e ) {
10461 e.printStackTrace( System.out );
10467 private static boolean testPhyloXMLparsingOfDistributionElement() {
10469 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10470 PhyloXmlParser xml_parser = null;
10472 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
10474 catch ( final Exception e ) {
10475 // Do nothing -- means were not running from jar.
10477 if ( xml_parser == null ) {
10478 xml_parser = PhyloXmlParser.createPhyloXmlParser();
10479 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
10480 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
10483 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
10486 final Phylogeny[] phylogenies_0 = factory
10487 .create( new File( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml" ), xml_parser );
10488 if ( xml_parser.getErrorCount() > 0 ) {
10489 System.out.println( xml_parser.getErrorMessages().toString() );
10492 if ( phylogenies_0.length != 1 ) {
10495 final Phylogeny t1 = phylogenies_0[ 0 ];
10496 PhylogenyNode n = null;
10497 Distribution d = null;
10498 n = t1.getNode( "root node" );
10499 if ( !n.getNodeData().isHasDistribution() ) {
10502 if ( n.getNodeData().getDistributions().size() != 1 ) {
10505 d = n.getNodeData().getDistribution();
10506 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10509 if ( d.getPoints().size() != 1 ) {
10512 if ( d.getPolygons() != null ) {
10515 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10518 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10521 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10524 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10527 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10530 n = t1.getNode( "node a" );
10531 if ( !n.getNodeData().isHasDistribution() ) {
10534 if ( n.getNodeData().getDistributions().size() != 2 ) {
10537 d = n.getNodeData().getDistribution( 1 );
10538 if ( !d.getDesc().equals( "San Diego" ) ) {
10541 if ( d.getPoints().size() != 1 ) {
10544 if ( d.getPolygons() != null ) {
10547 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10550 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10553 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10556 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10559 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10562 n = t1.getNode( "node bb" );
10563 if ( !n.getNodeData().isHasDistribution() ) {
10566 if ( n.getNodeData().getDistributions().size() != 1 ) {
10569 d = n.getNodeData().getDistribution( 0 );
10570 if ( d.getPoints().size() != 3 ) {
10573 if ( d.getPolygons().size() != 2 ) {
10576 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10579 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10582 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10585 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10588 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10591 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10594 Polygon p = d.getPolygons().get( 0 );
10595 if ( p.getPoints().size() != 3 ) {
10598 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10601 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10604 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10607 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10610 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10613 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10616 p = d.getPolygons().get( 1 );
10617 if ( p.getPoints().size() != 3 ) {
10620 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10623 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10626 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10630 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
10631 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
10632 if ( rt.length != 1 ) {
10635 final Phylogeny t1_rt = rt[ 0 ];
10636 n = t1_rt.getNode( "root node" );
10637 if ( !n.getNodeData().isHasDistribution() ) {
10640 if ( n.getNodeData().getDistributions().size() != 1 ) {
10643 d = n.getNodeData().getDistribution();
10644 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
10647 if ( d.getPoints().size() != 1 ) {
10650 if ( d.getPolygons() != null ) {
10653 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
10656 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10659 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10662 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
10665 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
10668 n = t1_rt.getNode( "node a" );
10669 if ( !n.getNodeData().isHasDistribution() ) {
10672 if ( n.getNodeData().getDistributions().size() != 2 ) {
10675 d = n.getNodeData().getDistribution( 1 );
10676 if ( !d.getDesc().equals( "San Diego" ) ) {
10679 if ( d.getPoints().size() != 1 ) {
10682 if ( d.getPolygons() != null ) {
10685 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
10688 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
10691 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
10694 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
10697 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
10700 n = t1_rt.getNode( "node bb" );
10701 if ( !n.getNodeData().isHasDistribution() ) {
10704 if ( n.getNodeData().getDistributions().size() != 1 ) {
10707 d = n.getNodeData().getDistribution( 0 );
10708 if ( d.getPoints().size() != 3 ) {
10711 if ( d.getPolygons().size() != 2 ) {
10714 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
10717 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
10720 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
10723 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
10726 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
10729 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
10732 p = d.getPolygons().get( 0 );
10733 if ( p.getPoints().size() != 3 ) {
10736 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
10739 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
10742 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10745 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
10748 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
10751 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
10754 p = d.getPolygons().get( 1 );
10755 if ( p.getPoints().size() != 3 ) {
10758 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
10761 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
10764 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
10768 catch ( final Exception e ) {
10769 e.printStackTrace( System.out );
10775 private static boolean testPostOrderIterator() {
10777 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10778 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10779 PhylogenyNodeIterator it0;
10780 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
10783 for( it0.reset(); it0.hasNext(); ) {
10786 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
10787 new NHXParser() )[ 0 ];
10788 final PhylogenyNodeIterator it = t1.iteratorPostorder();
10789 if ( !it.next().getName().equals( "A" ) ) {
10792 if ( !it.next().getName().equals( "B" ) ) {
10795 if ( !it.next().getName().equals( "ab" ) ) {
10798 if ( !it.next().getName().equals( "C" ) ) {
10801 if ( !it.next().getName().equals( "D" ) ) {
10804 if ( !it.next().getName().equals( "cd" ) ) {
10807 if ( !it.next().getName().equals( "abcd" ) ) {
10810 if ( !it.next().getName().equals( "E" ) ) {
10813 if ( !it.next().getName().equals( "F" ) ) {
10816 if ( !it.next().getName().equals( "ef" ) ) {
10819 if ( !it.next().getName().equals( "G" ) ) {
10822 if ( !it.next().getName().equals( "H" ) ) {
10825 if ( !it.next().getName().equals( "gh" ) ) {
10828 if ( !it.next().getName().equals( "efgh" ) ) {
10831 if ( !it.next().getName().equals( "r" ) ) {
10834 if ( it.hasNext() ) {
10838 catch ( final Exception e ) {
10839 e.printStackTrace( System.out );
10845 private static boolean testPreOrderIterator() {
10847 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10848 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10849 PhylogenyNodeIterator it0;
10850 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10853 for( it0.reset(); it0.hasNext(); ) {
10856 PhylogenyNodeIterator it = t0.iteratorPreorder();
10857 if ( !it.next().getName().equals( "r" ) ) {
10860 if ( !it.next().getName().equals( "ab" ) ) {
10863 if ( !it.next().getName().equals( "A" ) ) {
10866 if ( !it.next().getName().equals( "B" ) ) {
10869 if ( !it.next().getName().equals( "cd" ) ) {
10872 if ( !it.next().getName().equals( "C" ) ) {
10875 if ( !it.next().getName().equals( "D" ) ) {
10878 if ( it.hasNext() ) {
10881 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r",
10882 new NHXParser() )[ 0 ];
10883 it = t1.iteratorPreorder();
10884 if ( !it.next().getName().equals( "r" ) ) {
10887 if ( !it.next().getName().equals( "abcd" ) ) {
10890 if ( !it.next().getName().equals( "ab" ) ) {
10893 if ( !it.next().getName().equals( "A" ) ) {
10896 if ( !it.next().getName().equals( "B" ) ) {
10899 if ( !it.next().getName().equals( "cd" ) ) {
10902 if ( !it.next().getName().equals( "C" ) ) {
10905 if ( !it.next().getName().equals( "D" ) ) {
10908 if ( !it.next().getName().equals( "efgh" ) ) {
10911 if ( !it.next().getName().equals( "ef" ) ) {
10914 if ( !it.next().getName().equals( "E" ) ) {
10917 if ( !it.next().getName().equals( "F" ) ) {
10920 if ( !it.next().getName().equals( "gh" ) ) {
10923 if ( !it.next().getName().equals( "G" ) ) {
10926 if ( !it.next().getName().equals( "H" ) ) {
10929 if ( it.hasNext() ) {
10933 catch ( final Exception e ) {
10934 e.printStackTrace( System.out );
10940 private static boolean testPropertiesMap() {
10942 final PropertiesList pm = new PropertiesList();
10943 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10944 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10945 final Property p2 = new Property( "something:else",
10947 "improbable:research",
10950 pm.addProperty( p0 );
10951 pm.addProperty( p1 );
10952 pm.addProperty( p2 );
10953 if ( !pm.getProperties( "dimensions:diameter" ).get( 0 ).getValue().equals( "1" ) ) {
10956 if ( !pm.getProperties( "dimensions:length" ).get( 0 ).getValue().equals( "2" ) ) {
10959 if ( pm.getProperties().size() != 3 ) {
10962 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10965 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10968 if ( pm.getProperties().size() != 3 ) {
10972 catch ( final Exception e ) {
10973 e.printStackTrace( System.out );
10979 private static boolean testProteinId() {
10981 final ProteinId id1 = new ProteinId( "a" );
10982 final ProteinId id2 = new ProteinId( "a" );
10983 final ProteinId id3 = new ProteinId( "A" );
10984 final ProteinId id4 = new ProteinId( "b" );
10985 if ( !id1.equals( id1 ) ) {
10988 if ( id1.getId().equals( "x" ) ) {
10991 if ( id1.getId().equals( null ) ) {
10994 if ( !id1.equals( id2 ) ) {
10997 if ( id1.equals( id3 ) ) {
11000 if ( id1.hashCode() != id1.hashCode() ) {
11003 if ( id1.hashCode() != id2.hashCode() ) {
11006 if ( id1.hashCode() == id3.hashCode() ) {
11009 if ( id1.compareTo( id1 ) != 0 ) {
11012 if ( id1.compareTo( id2 ) != 0 ) {
11015 if ( id1.compareTo( id3 ) != 0 ) {
11018 if ( id1.compareTo( id4 ) >= 0 ) {
11021 if ( id4.compareTo( id1 ) <= 0 ) {
11024 if ( !id4.getId().equals( "b" ) ) {
11027 final ProteinId id5 = new ProteinId( " C " );
11028 if ( !id5.getId().equals( "C" ) ) {
11031 if ( id5.equals( id1 ) ) {
11035 catch ( final Exception e ) {
11036 e.printStackTrace( System.out );
11042 private static boolean testReIdMethods() {
11044 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11045 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
11046 final long count = PhylogenyNode.getNodeCount();
11047 p.levelOrderReID();
11048 if ( p.getNode( "r" ).getId() != count ) {
11051 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
11054 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
11057 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
11060 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
11063 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
11066 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
11069 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
11072 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
11075 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
11078 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
11081 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
11084 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
11087 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
11090 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
11094 catch ( final Exception e ) {
11095 e.printStackTrace( System.out );
11101 private static boolean testRerooting() {
11103 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11104 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",
11105 new NHXParser() )[ 0 ];
11106 if ( !t1.isRooted() ) {
11109 t1.reRoot( t1.getNode( "D" ) );
11110 t1.reRoot( t1.getNode( "CD" ) );
11111 t1.reRoot( t1.getNode( "A" ) );
11112 t1.reRoot( t1.getNode( "B" ) );
11113 t1.reRoot( t1.getNode( "AB" ) );
11114 t1.reRoot( t1.getNode( "D" ) );
11115 t1.reRoot( t1.getNode( "C" ) );
11116 t1.reRoot( t1.getNode( "CD" ) );
11117 t1.reRoot( t1.getNode( "A" ) );
11118 t1.reRoot( t1.getNode( "B" ) );
11119 t1.reRoot( t1.getNode( "AB" ) );
11120 t1.reRoot( t1.getNode( "D" ) );
11121 t1.reRoot( t1.getNode( "D" ) );
11122 t1.reRoot( t1.getNode( "C" ) );
11123 t1.reRoot( t1.getNode( "A" ) );
11124 t1.reRoot( t1.getNode( "B" ) );
11125 t1.reRoot( t1.getNode( "AB" ) );
11126 t1.reRoot( t1.getNode( "C" ) );
11127 t1.reRoot( t1.getNode( "D" ) );
11128 t1.reRoot( t1.getNode( "CD" ) );
11129 t1.reRoot( t1.getNode( "D" ) );
11130 t1.reRoot( t1.getNode( "A" ) );
11131 t1.reRoot( t1.getNode( "B" ) );
11132 t1.reRoot( t1.getNode( "AB" ) );
11133 t1.reRoot( t1.getNode( "C" ) );
11134 t1.reRoot( t1.getNode( "D" ) );
11135 t1.reRoot( t1.getNode( "CD" ) );
11136 t1.reRoot( t1.getNode( "D" ) );
11137 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
11140 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
11143 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
11146 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
11149 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
11152 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
11155 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",
11156 new NHXParser() )[ 0 ];
11157 t2.reRoot( t2.getNode( "A" ) );
11158 t2.reRoot( t2.getNode( "D" ) );
11159 t2.reRoot( t2.getNode( "ABC" ) );
11160 t2.reRoot( t2.getNode( "A" ) );
11161 t2.reRoot( t2.getNode( "B" ) );
11162 t2.reRoot( t2.getNode( "D" ) );
11163 t2.reRoot( t2.getNode( "C" ) );
11164 t2.reRoot( t2.getNode( "ABC" ) );
11165 t2.reRoot( t2.getNode( "A" ) );
11166 t2.reRoot( t2.getNode( "B" ) );
11167 t2.reRoot( t2.getNode( "AB" ) );
11168 t2.reRoot( t2.getNode( "AB" ) );
11169 t2.reRoot( t2.getNode( "D" ) );
11170 t2.reRoot( t2.getNode( "C" ) );
11171 t2.reRoot( t2.getNode( "B" ) );
11172 t2.reRoot( t2.getNode( "AB" ) );
11173 t2.reRoot( t2.getNode( "D" ) );
11174 t2.reRoot( t2.getNode( "D" ) );
11175 t2.reRoot( t2.getNode( "ABC" ) );
11176 t2.reRoot( t2.getNode( "A" ) );
11177 t2.reRoot( t2.getNode( "B" ) );
11178 t2.reRoot( t2.getNode( "AB" ) );
11179 t2.reRoot( t2.getNode( "D" ) );
11180 t2.reRoot( t2.getNode( "C" ) );
11181 t2.reRoot( t2.getNode( "ABC" ) );
11182 t2.reRoot( t2.getNode( "A" ) );
11183 t2.reRoot( t2.getNode( "B" ) );
11184 t2.reRoot( t2.getNode( "AB" ) );
11185 t2.reRoot( t2.getNode( "D" ) );
11186 t2.reRoot( t2.getNode( "D" ) );
11187 t2.reRoot( t2.getNode( "C" ) );
11188 t2.reRoot( t2.getNode( "A" ) );
11189 t2.reRoot( t2.getNode( "B" ) );
11190 t2.reRoot( t2.getNode( "AB" ) );
11191 t2.reRoot( t2.getNode( "C" ) );
11192 t2.reRoot( t2.getNode( "D" ) );
11193 t2.reRoot( t2.getNode( "ABC" ) );
11194 t2.reRoot( t2.getNode( "D" ) );
11195 t2.reRoot( t2.getNode( "A" ) );
11196 t2.reRoot( t2.getNode( "B" ) );
11197 t2.reRoot( t2.getNode( "AB" ) );
11198 t2.reRoot( t2.getNode( "C" ) );
11199 t2.reRoot( t2.getNode( "D" ) );
11200 t2.reRoot( t2.getNode( "ABC" ) );
11201 t2.reRoot( t2.getNode( "D" ) );
11202 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11205 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11208 t2.reRoot( t2.getNode( "ABC" ) );
11209 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11212 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11215 t2.reRoot( t2.getNode( "AB" ) );
11216 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11219 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11222 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11225 t2.reRoot( t2.getNode( "AB" ) );
11226 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11229 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11232 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11235 t2.reRoot( t2.getNode( "D" ) );
11236 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11239 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11242 t2.reRoot( t2.getNode( "ABC" ) );
11243 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
11246 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
11249 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
11250 new NHXParser() )[ 0 ];
11251 t3.reRoot( t3.getNode( "B" ) );
11252 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11255 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11258 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11261 t3.reRoot( t3.getNode( "B" ) );
11262 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11265 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11268 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11271 t3.reRoot( t3.getRoot() );
11272 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11275 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
11278 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
11282 catch ( final Exception e ) {
11283 e.printStackTrace( System.out );
11289 private static boolean testSDIse() {
11291 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11292 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
11293 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
11294 gene1.setRooted( true );
11295 species1.setRooted( true );
11296 final SDI sdi = new SDI( gene1, species1 );
11297 if ( !gene1.getRoot().isDuplication() ) {
11300 final Phylogeny species2 = factory.create(
11301 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11302 new NHXParser() )[ 0 ];
11303 final Phylogeny gene2 = factory.create(
11304 "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11305 new NHXParser() )[ 0 ];
11306 species2.setRooted( true );
11307 gene2.setRooted( true );
11308 final SDI sdi2 = new SDI( gene2, species2 );
11309 if ( sdi2.getDuplicationsSum() != 0 ) {
11312 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
11315 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
11318 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
11321 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
11324 if ( !gene2.getNode( "r" ).isSpeciation() ) {
11327 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
11330 final Phylogeny species3 = factory.create(
11331 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11332 new NHXParser() )[ 0 ];
11333 final Phylogeny gene3 = factory.create(
11334 "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11335 new NHXParser() )[ 0 ];
11336 species3.setRooted( true );
11337 gene3.setRooted( true );
11338 final SDI sdi3 = new SDI( gene3, species3 );
11339 if ( sdi3.getDuplicationsSum() != 1 ) {
11342 if ( !gene3.getNode( "aa" ).isDuplication() ) {
11345 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
11348 final Phylogeny species4 = factory.create(
11349 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11350 new NHXParser() )[ 0 ];
11351 final Phylogeny gene4 = factory.create(
11352 "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11353 new NHXParser() )[ 0 ];
11354 species4.setRooted( true );
11355 gene4.setRooted( true );
11356 final SDI sdi4 = new SDI( gene4, species4 );
11357 if ( sdi4.getDuplicationsSum() != 1 ) {
11360 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
11363 if ( !gene4.getNode( "abc" ).isDuplication() ) {
11366 if ( gene4.getNode( "abcd" ).isDuplication() ) {
11369 if ( species4.getNumberOfExternalNodes() != 6 ) {
11372 if ( gene4.getNumberOfExternalNodes() != 6 ) {
11375 final Phylogeny species5 = factory.create(
11376 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11377 new NHXParser() )[ 0 ];
11378 final Phylogeny gene5 = factory.create(
11379 "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
11380 new NHXParser() )[ 0 ];
11381 species5.setRooted( true );
11382 gene5.setRooted( true );
11383 final SDI sdi5 = new SDI( gene5, species5 );
11384 if ( sdi5.getDuplicationsSum() != 2 ) {
11387 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
11390 if ( !gene5.getNode( "adc" ).isDuplication() ) {
11393 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
11396 if ( species5.getNumberOfExternalNodes() != 6 ) {
11399 if ( gene5.getNumberOfExternalNodes() != 6 ) {
11402 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
11403 // Conjecture for Comparing Molecular Phylogenies"
11404 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
11405 final Phylogeny species6 = factory.create(
11406 "(((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,"
11407 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11408 new NHXParser() )[ 0 ];
11409 final Phylogeny gene6 = factory.create(
11410 "(((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,"
11411 + "((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,"
11412 + "(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;",
11413 new NHXParser() )[ 0 ];
11414 species6.setRooted( true );
11415 gene6.setRooted( true );
11416 final SDI sdi6 = new SDI( gene6, species6 );
11417 if ( sdi6.getDuplicationsSum() != 3 ) {
11420 if ( !gene6.getNode( "r" ).isDuplication() ) {
11423 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
11426 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
11429 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
11432 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
11435 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
11438 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
11441 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
11444 sdi6.computeMappingCostL();
11445 if ( sdi6.computeMappingCostL() != 17 ) {
11448 if ( species6.getNumberOfExternalNodes() != 9 ) {
11451 if ( gene6.getNumberOfExternalNodes() != 9 ) {
11454 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
11455 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
11456 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
11457 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
11458 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
11459 species7.setRooted( true );
11460 final Phylogeny gene7_1 = Test
11461 .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])" );
11462 gene7_1.setRooted( true );
11463 final SDI sdi7 = new SDI( gene7_1, species7 );
11464 if ( sdi7.getDuplicationsSum() != 0 ) {
11467 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
11470 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
11473 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
11476 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
11479 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
11482 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
11485 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
11488 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
11491 final Phylogeny gene7_2 = Test
11492 .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])" );
11493 gene7_2.setRooted( true );
11494 final SDI sdi7_2 = new SDI( gene7_2, species7 );
11495 if ( sdi7_2.getDuplicationsSum() != 1 ) {
11498 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
11501 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
11504 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
11507 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
11510 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
11513 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
11516 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
11519 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
11522 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
11526 catch ( final Exception e ) {
11532 private static boolean testSDIunrooted() {
11534 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11535 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef",
11536 new NHXParser() )[ 0 ];
11537 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
11538 final Iterator<PhylogenyBranch> iter = l.iterator();
11539 PhylogenyBranch br = iter.next();
11540 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
11543 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
11547 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11550 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11554 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
11557 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
11561 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11564 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11568 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11571 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11575 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
11578 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
11582 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11585 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11589 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11592 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11596 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11599 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11603 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
11606 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
11610 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11613 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11617 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
11620 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
11624 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
11627 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
11631 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
11634 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
11638 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
11641 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
11644 if ( iter.hasNext() ) {
11647 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
11648 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
11649 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
11651 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11654 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11658 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11661 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11665 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11668 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11671 if ( iter1.hasNext() ) {
11674 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
11675 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
11676 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
11678 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
11681 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
11685 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
11688 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
11692 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
11695 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
11698 if ( iter2.hasNext() ) {
11701 final Phylogeny species0 = factory.create(
11702 "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
11703 new NHXParser() )[ 0 ];
11704 final Phylogeny gene1 = factory.create(
11705 "(((((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])",
11706 new NHXParser() )[ 0 ];
11707 species0.setRooted( true );
11708 gene1.setRooted( true );
11709 final SDIR sdi_unrooted = new SDIR();
11710 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
11711 if ( sdi_unrooted.getCount() != 1 ) {
11714 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
11717 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
11720 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
11723 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11726 final Phylogeny gene2 = factory.create(
11727 "(((((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])",
11728 new NHXParser() )[ 0 ];
11729 gene2.setRooted( true );
11730 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
11731 if ( sdi_unrooted.getCount() != 1 ) {
11734 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11737 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11740 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
11743 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11746 final Phylogeny species6 = factory.create(
11747 "(((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,"
11748 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11749 new NHXParser() )[ 0 ];
11750 final Phylogeny gene6 = factory.create(
11751 "((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],"
11752 + "(((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],"
11753 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11754 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11755 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11756 new NHXParser() )[ 0 ];
11757 species6.setRooted( true );
11758 gene6.setRooted( true );
11759 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
11760 if ( sdi_unrooted.getCount() != 1 ) {
11763 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11766 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11769 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11772 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11775 if ( !p6[ 0 ].getRoot().isDuplication() ) {
11778 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11781 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11784 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11787 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11790 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11793 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11796 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11800 final Phylogeny species7 = factory.create(
11801 "(((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,"
11802 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11803 new NHXParser() )[ 0 ];
11804 final Phylogeny gene7 = factory.create(
11805 "((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],"
11806 + "(((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],"
11807 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11808 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11809 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11810 new NHXParser() )[ 0 ];
11811 species7.setRooted( true );
11812 gene7.setRooted( true );
11813 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11814 if ( sdi_unrooted.getCount() != 1 ) {
11817 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11820 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11823 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11826 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11829 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11832 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11835 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11838 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11841 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11844 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11847 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11850 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11854 final Phylogeny species8 = factory.create(
11855 "(((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,"
11856 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11857 new NHXParser() )[ 0 ];
11858 final Phylogeny gene8 = factory.create(
11859 "((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],"
11860 + "(((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],"
11861 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11862 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11863 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11864 new NHXParser() )[ 0 ];
11865 species8.setRooted( true );
11866 gene8.setRooted( true );
11867 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11868 if ( sdi_unrooted.getCount() != 1 ) {
11871 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11874 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11877 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11880 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11883 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11886 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11889 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11892 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11895 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11898 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11901 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11904 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11909 catch ( final Exception e ) {
11910 e.printStackTrace( System.out );
11916 private static boolean testSequenceDbWsTools1() {
11918 final PhylogenyNode n = new PhylogenyNode();
11919 n.setName( "NP_001025424" );
11920 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11921 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11922 || !acc.getValue().equals( "NP_001025424" ) ) {
11925 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11926 acc = SequenceDbWsTools.obtainSeqAccession( n );
11927 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11928 || !acc.getValue().equals( "NP_001025424" ) ) {
11931 n.setName( "NP_001025424.1" );
11932 acc = SequenceDbWsTools.obtainSeqAccession( n );
11933 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11934 || !acc.getValue().equals( "NP_001025424" ) ) {
11937 n.setName( "NM_001030253" );
11938 acc = SequenceDbWsTools.obtainSeqAccession( n );
11939 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11940 || !acc.getValue().equals( "NM_001030253" ) ) {
11943 n.setName( "BCL2_HUMAN" );
11944 acc = SequenceDbWsTools.obtainSeqAccession( n );
11945 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11946 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11947 System.out.println( acc.toString() );
11950 n.setName( "P10415" );
11951 acc = SequenceDbWsTools.obtainSeqAccession( n );
11952 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11953 || !acc.getValue().equals( "P10415" ) ) {
11954 System.out.println( acc.toString() );
11957 n.setName( " P10415 " );
11958 acc = SequenceDbWsTools.obtainSeqAccession( n );
11959 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11960 || !acc.getValue().equals( "P10415" ) ) {
11961 System.out.println( acc.toString() );
11964 n.setName( "_P10415|" );
11965 acc = SequenceDbWsTools.obtainSeqAccession( n );
11966 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11967 || !acc.getValue().equals( "P10415" ) ) {
11968 System.out.println( acc.toString() );
11971 n.setName( "AY695820" );
11972 acc = SequenceDbWsTools.obtainSeqAccession( n );
11973 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11974 || !acc.getValue().equals( "AY695820" ) ) {
11975 System.out.println( acc.toString() );
11978 n.setName( "_AY695820_" );
11979 acc = SequenceDbWsTools.obtainSeqAccession( n );
11980 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11981 || !acc.getValue().equals( "AY695820" ) ) {
11982 System.out.println( acc.toString() );
11985 n.setName( "AAA59452" );
11986 acc = SequenceDbWsTools.obtainSeqAccession( n );
11987 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11988 || !acc.getValue().equals( "AAA59452" ) ) {
11989 System.out.println( acc.toString() );
11992 n.setName( "_AAA59452_" );
11993 acc = SequenceDbWsTools.obtainSeqAccession( n );
11994 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11995 || !acc.getValue().equals( "AAA59452" ) ) {
11996 System.out.println( acc.toString() );
11999 n.setName( "AAA59452.1" );
12000 acc = SequenceDbWsTools.obtainSeqAccession( n );
12001 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12002 || !acc.getValue().equals( "AAA59452.1" ) ) {
12003 System.out.println( acc.toString() );
12006 n.setName( "_AAA59452.1_" );
12007 acc = SequenceDbWsTools.obtainSeqAccession( n );
12008 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12009 || !acc.getValue().equals( "AAA59452.1" ) ) {
12010 System.out.println( acc.toString() );
12013 n.setName( "GI:94894583" );
12014 acc = SequenceDbWsTools.obtainSeqAccession( n );
12015 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12016 || !acc.getValue().equals( "94894583" ) ) {
12017 System.out.println( acc.toString() );
12020 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12021 acc = SequenceDbWsTools.obtainSeqAccession( n );
12022 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
12023 || !acc.getValue().equals( "71845847" ) ) {
12024 System.out.println( acc.toString() );
12027 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
12028 acc = SequenceDbWsTools.obtainSeqAccession( n );
12029 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
12030 || !acc.getValue().equals( "AAZ45343.1" ) ) {
12031 System.out.println( acc.toString() );
12035 catch ( final Exception e ) {
12041 private static boolean testSequenceDbWsTools2() {
12043 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
12044 SequenceDbWsTools.obtainSeqInformation( n1 );
12045 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
12048 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12051 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12054 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
12057 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
12058 SequenceDbWsTools.obtainSeqInformation( n2 );
12059 if ( !n2.getNodeData().getSequence().getName()
12060 .equals( "Danio rerio B-cell CLL/lymphoma 2a (bcl2a), mRNA" ) ) {
12063 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
12066 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12069 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
12072 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
12073 SequenceDbWsTools.obtainSeqInformation( n3 );
12074 if ( !n3.getNodeData().getSequence().getName()
12075 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
12078 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
12081 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
12084 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
12088 catch ( final IOException e ) {
12089 System.out.println();
12090 System.out.println( "the following might be due to absence internet connection:" );
12091 e.printStackTrace( System.out );
12094 catch ( final Exception e ) {
12095 e.printStackTrace();
12101 private static boolean testSequenceIdParsing() {
12103 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
12104 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12105 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12106 if ( id != null ) {
12107 System.out.println( "value =" + id.getValue() );
12108 System.out.println( "provider=" + id.getSource() );
12112 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
12113 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12114 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12115 if ( id != null ) {
12116 System.out.println( "value =" + id.getValue() );
12117 System.out.println( "provider=" + id.getSource() );
12121 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
12122 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12123 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
12124 if ( id != null ) {
12125 System.out.println( "value =" + id.getValue() );
12126 System.out.println( "provider=" + id.getSource() );
12130 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
12131 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12132 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
12133 if ( id != null ) {
12134 System.out.println( "value =" + id.getValue() );
12135 System.out.println( "provider=" + id.getSource() );
12139 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
12140 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12141 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
12142 if ( id != null ) {
12143 System.out.println( "value =" + id.getValue() );
12144 System.out.println( "provider=" + id.getSource() );
12148 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
12149 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12150 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
12151 if ( id != null ) {
12152 System.out.println( "value =" + id.getValue() );
12153 System.out.println( "provider=" + id.getSource() );
12157 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
12158 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12159 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
12160 if ( id != null ) {
12161 System.out.println( "value =" + id.getValue() );
12162 System.out.println( "provider=" + id.getSource() );
12166 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
12167 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12168 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12169 if ( id != null ) {
12170 System.out.println( "value =" + id.getValue() );
12171 System.out.println( "provider=" + id.getSource() );
12175 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
12176 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12177 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
12178 if ( id != null ) {
12179 System.out.println( "value =" + id.getValue() );
12180 System.out.println( "provider=" + id.getSource() );
12184 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
12185 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12186 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
12187 if ( id != null ) {
12188 System.out.println( "value =" + id.getValue() );
12189 System.out.println( "provider=" + id.getSource() );
12193 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
12194 if ( id != null ) {
12195 System.out.println( "value =" + id.getValue() );
12196 System.out.println( "provider=" + id.getSource() );
12199 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
12200 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12201 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
12202 if ( id != null ) {
12203 System.out.println( "value =" + id.getValue() );
12204 System.out.println( "provider=" + id.getSource() );
12208 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
12209 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12210 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12211 if ( id != null ) {
12212 System.out.println( "value =" + id.getValue() );
12213 System.out.println( "provider=" + id.getSource() );
12217 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
12218 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
12219 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
12220 if ( id != null ) {
12221 System.out.println( "value =" + id.getValue() );
12222 System.out.println( "provider=" + id.getSource() );
12226 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
12227 if ( id != null ) {
12228 System.out.println( "value =" + id.getValue() );
12229 System.out.println( "provider=" + id.getSource() );
12233 catch ( final Exception e ) {
12234 e.printStackTrace( System.out );
12240 private static boolean testSequenceWriter() {
12242 final String n = ForesterUtil.LINE_SEPARATOR;
12243 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
12246 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
12249 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
12252 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
12255 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
12256 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
12259 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
12260 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
12264 catch ( final Exception e ) {
12265 e.printStackTrace();
12271 private static boolean testSpecies() {
12273 final Species s1 = new BasicSpecies( "a" );
12274 final Species s2 = new BasicSpecies( "a" );
12275 final Species s3 = new BasicSpecies( "A" );
12276 final Species s4 = new BasicSpecies( "b" );
12277 if ( !s1.equals( s1 ) ) {
12280 if ( s1.getSpeciesId().equals( "x" ) ) {
12283 if ( s1.getSpeciesId().equals( null ) ) {
12286 if ( !s1.equals( s2 ) ) {
12289 if ( s1.equals( s3 ) ) {
12292 if ( s1.hashCode() != s1.hashCode() ) {
12295 if ( s1.hashCode() != s2.hashCode() ) {
12298 if ( s1.hashCode() == s3.hashCode() ) {
12301 if ( s1.compareTo( s1 ) != 0 ) {
12304 if ( s1.compareTo( s2 ) != 0 ) {
12307 if ( s1.compareTo( s3 ) != 0 ) {
12310 if ( s1.compareTo( s4 ) >= 0 ) {
12313 if ( s4.compareTo( s1 ) <= 0 ) {
12316 if ( !s4.getSpeciesId().equals( "b" ) ) {
12319 final Species s5 = new BasicSpecies( " C " );
12320 if ( !s5.getSpeciesId().equals( "C" ) ) {
12323 if ( s5.equals( s1 ) ) {
12327 catch ( final Exception e ) {
12328 e.printStackTrace( System.out );
12334 private static boolean testSplit() {
12336 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12337 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12338 //Archaeopteryx.createApplication( p0 );
12339 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12340 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12341 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12342 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12343 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12344 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12345 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12346 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12347 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12348 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12349 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
12350 // System.out.println( s0.toString() );
12352 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12353 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12354 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12355 if ( s0.match( query_nodes ) ) {
12358 query_nodes = new HashSet<PhylogenyNode>();
12359 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12360 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12361 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12362 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12363 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12364 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12365 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12366 if ( !s0.match( query_nodes ) ) {
12370 query_nodes = new HashSet<PhylogenyNode>();
12371 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12372 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12373 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12374 if ( !s0.match( query_nodes ) ) {
12378 query_nodes = new HashSet<PhylogenyNode>();
12379 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12380 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12381 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12382 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12383 if ( !s0.match( query_nodes ) ) {
12387 query_nodes = new HashSet<PhylogenyNode>();
12388 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12389 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12390 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12391 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12392 if ( !s0.match( query_nodes ) ) {
12396 query_nodes = new HashSet<PhylogenyNode>();
12397 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12398 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12399 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12400 if ( !s0.match( query_nodes ) ) {
12403 query_nodes = new HashSet<PhylogenyNode>();
12404 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12405 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12406 if ( !s0.match( query_nodes ) ) {
12409 query_nodes = new HashSet<PhylogenyNode>();
12410 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12411 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12412 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12413 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12414 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12415 if ( !s0.match( query_nodes ) ) {
12418 query_nodes = new HashSet<PhylogenyNode>();
12419 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12420 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12421 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12422 if ( !s0.match( query_nodes ) ) {
12425 query_nodes = new HashSet<PhylogenyNode>();
12426 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12427 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12428 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12429 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12430 if ( !s0.match( query_nodes ) ) {
12433 query_nodes = new HashSet<PhylogenyNode>();
12434 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12435 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12436 if ( s0.match( query_nodes ) ) {
12439 query_nodes = new HashSet<PhylogenyNode>();
12440 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12441 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12442 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12443 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12444 if ( s0.match( query_nodes ) ) {
12447 query_nodes = new HashSet<PhylogenyNode>();
12448 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12449 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12450 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12451 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12452 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12453 if ( s0.match( query_nodes ) ) {
12456 query_nodes = new HashSet<PhylogenyNode>();
12457 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12458 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12459 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12460 if ( s0.match( query_nodes ) ) {
12463 query_nodes = new HashSet<PhylogenyNode>();
12464 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12465 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12466 if ( s0.match( query_nodes ) ) {
12469 query_nodes = new HashSet<PhylogenyNode>();
12470 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12471 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12472 if ( s0.match( query_nodes ) ) {
12475 query_nodes = new HashSet<PhylogenyNode>();
12476 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12477 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12478 if ( s0.match( query_nodes ) ) {
12481 query_nodes = new HashSet<PhylogenyNode>();
12482 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12483 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12484 if ( s0.match( query_nodes ) ) {
12487 query_nodes = new HashSet<PhylogenyNode>();
12488 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12489 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12490 if ( s0.match( query_nodes ) ) {
12493 query_nodes = new HashSet<PhylogenyNode>();
12494 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12495 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12496 if ( s0.match( query_nodes ) ) {
12499 query_nodes = new HashSet<PhylogenyNode>();
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 ) ) {
12506 query_nodes = new HashSet<PhylogenyNode>();
12507 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12508 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12509 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12510 if ( s0.match( query_nodes ) ) {
12513 query_nodes = new HashSet<PhylogenyNode>();
12514 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12515 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12516 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12517 if ( s0.match( query_nodes ) ) {
12520 query_nodes = new HashSet<PhylogenyNode>();
12521 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12522 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12523 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12524 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12525 if ( s0.match( query_nodes ) ) {
12529 // query_nodes = new HashSet<PhylogenyNode>();
12530 // query_nodes.add( new PhylogenyNode( "X" ) );
12531 // query_nodes.add( new PhylogenyNode( "Y" ) );
12532 // query_nodes.add( new PhylogenyNode( "A" ) );
12533 // query_nodes.add( new PhylogenyNode( "B" ) );
12534 // query_nodes.add( new PhylogenyNode( "C" ) );
12535 // query_nodes.add( new PhylogenyNode( "D" ) );
12536 // query_nodes.add( new PhylogenyNode( "E" ) );
12537 // query_nodes.add( new PhylogenyNode( "F" ) );
12538 // query_nodes.add( new PhylogenyNode( "G" ) );
12539 // if ( !s0.match( query_nodes ) ) {
12542 // query_nodes = new HashSet<PhylogenyNode>();
12543 // query_nodes.add( new PhylogenyNode( "X" ) );
12544 // query_nodes.add( new PhylogenyNode( "Y" ) );
12545 // query_nodes.add( new PhylogenyNode( "A" ) );
12546 // query_nodes.add( new PhylogenyNode( "B" ) );
12547 // query_nodes.add( new PhylogenyNode( "C" ) );
12548 // if ( !s0.match( query_nodes ) ) {
12552 // query_nodes = new HashSet<PhylogenyNode>();
12553 // query_nodes.add( new PhylogenyNode( "X" ) );
12554 // query_nodes.add( new PhylogenyNode( "Y" ) );
12555 // query_nodes.add( new PhylogenyNode( "D" ) );
12556 // query_nodes.add( new PhylogenyNode( "E" ) );
12557 // query_nodes.add( new PhylogenyNode( "F" ) );
12558 // query_nodes.add( new PhylogenyNode( "G" ) );
12559 // if ( !s0.match( query_nodes ) ) {
12563 // query_nodes = new HashSet<PhylogenyNode>();
12564 // query_nodes.add( new PhylogenyNode( "X" ) );
12565 // query_nodes.add( new PhylogenyNode( "Y" ) );
12566 // query_nodes.add( new PhylogenyNode( "A" ) );
12567 // query_nodes.add( new PhylogenyNode( "B" ) );
12568 // query_nodes.add( new PhylogenyNode( "C" ) );
12569 // query_nodes.add( new PhylogenyNode( "D" ) );
12570 // if ( !s0.match( query_nodes ) ) {
12574 // query_nodes = new HashSet<PhylogenyNode>();
12575 // query_nodes.add( new PhylogenyNode( "X" ) );
12576 // query_nodes.add( new PhylogenyNode( "Y" ) );
12577 // query_nodes.add( new PhylogenyNode( "E" ) );
12578 // query_nodes.add( new PhylogenyNode( "F" ) );
12579 // query_nodes.add( new PhylogenyNode( "G" ) );
12580 // if ( !s0.match( query_nodes ) ) {
12584 // query_nodes = new HashSet<PhylogenyNode>();
12585 // query_nodes.add( new PhylogenyNode( "X" ) );
12586 // query_nodes.add( new PhylogenyNode( "Y" ) );
12587 // query_nodes.add( new PhylogenyNode( "F" ) );
12588 // query_nodes.add( new PhylogenyNode( "G" ) );
12589 // if ( !s0.match( query_nodes ) ) {
12593 query_nodes = new HashSet<PhylogenyNode>();
12594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12597 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12598 if ( s0.match( query_nodes ) ) {
12602 query_nodes = new HashSet<PhylogenyNode>();
12603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12606 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12607 if ( s0.match( query_nodes ) ) {
12610 ///////////////////////////
12612 query_nodes = new HashSet<PhylogenyNode>();
12613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12614 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12615 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12616 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12617 if ( s0.match( query_nodes ) ) {
12621 query_nodes = new HashSet<PhylogenyNode>();
12622 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12623 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12624 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12625 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12626 if ( s0.match( query_nodes ) ) {
12630 query_nodes = new HashSet<PhylogenyNode>();
12631 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12632 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12633 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12634 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12635 if ( s0.match( query_nodes ) ) {
12639 query_nodes = new HashSet<PhylogenyNode>();
12640 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12641 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12642 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12643 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12644 if ( s0.match( query_nodes ) ) {
12648 query_nodes = new HashSet<PhylogenyNode>();
12649 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12650 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12651 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12652 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12653 if ( s0.match( query_nodes ) ) {
12657 query_nodes = new HashSet<PhylogenyNode>();
12658 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12659 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12661 if ( s0.match( query_nodes ) ) {
12665 query_nodes = new HashSet<PhylogenyNode>();
12666 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12667 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12668 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12670 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12671 if ( s0.match( query_nodes ) ) {
12675 query_nodes = new HashSet<PhylogenyNode>();
12676 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12677 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12678 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
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( "X" ) );
12687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12689 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12690 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12691 if ( s0.match( query_nodes ) ) {
12695 query_nodes = new HashSet<PhylogenyNode>();
12696 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
12697 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
12698 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12699 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12700 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12702 if ( s0.match( query_nodes ) ) {
12706 catch ( final Exception e ) {
12707 e.printStackTrace();
12713 private static boolean testSplitStrict() {
12715 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12716 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
12717 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
12718 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12719 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12720 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12721 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12722 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12723 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12724 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12725 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
12726 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
12727 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12728 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12729 if ( s0.match( query_nodes ) ) {
12732 query_nodes = new HashSet<PhylogenyNode>();
12733 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12734 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12735 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12736 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12740 if ( !s0.match( query_nodes ) ) {
12744 query_nodes = new HashSet<PhylogenyNode>();
12745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12748 if ( !s0.match( query_nodes ) ) {
12752 query_nodes = new HashSet<PhylogenyNode>();
12753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12757 if ( !s0.match( query_nodes ) ) {
12761 query_nodes = new HashSet<PhylogenyNode>();
12762 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12763 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12764 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12765 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12766 if ( !s0.match( query_nodes ) ) {
12770 query_nodes = new HashSet<PhylogenyNode>();
12771 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12772 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12773 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12774 if ( !s0.match( query_nodes ) ) {
12778 query_nodes = new HashSet<PhylogenyNode>();
12779 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12780 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12781 if ( !s0.match( query_nodes ) ) {
12785 query_nodes = new HashSet<PhylogenyNode>();
12786 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12787 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12788 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12789 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12790 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12791 if ( !s0.match( query_nodes ) ) {
12795 query_nodes = new HashSet<PhylogenyNode>();
12796 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12797 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12798 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12799 if ( !s0.match( query_nodes ) ) {
12803 query_nodes = new HashSet<PhylogenyNode>();
12804 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12805 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12806 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12807 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12808 if ( !s0.match( query_nodes ) ) {
12812 query_nodes = new HashSet<PhylogenyNode>();
12813 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12814 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12815 if ( s0.match( query_nodes ) ) {
12819 query_nodes = new HashSet<PhylogenyNode>();
12820 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12821 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12822 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12823 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12824 if ( s0.match( query_nodes ) ) {
12828 query_nodes = new HashSet<PhylogenyNode>();
12829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12830 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12831 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12832 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12833 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12834 if ( s0.match( query_nodes ) ) {
12838 query_nodes = new HashSet<PhylogenyNode>();
12839 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12840 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12841 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12842 if ( s0.match( query_nodes ) ) {
12846 query_nodes = new HashSet<PhylogenyNode>();
12847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12849 if ( s0.match( query_nodes ) ) {
12853 query_nodes = new HashSet<PhylogenyNode>();
12854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12855 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12856 if ( s0.match( query_nodes ) ) {
12860 query_nodes = new HashSet<PhylogenyNode>();
12861 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12862 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12863 if ( s0.match( query_nodes ) ) {
12867 query_nodes = new HashSet<PhylogenyNode>();
12868 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12869 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12870 if ( s0.match( query_nodes ) ) {
12874 query_nodes = new HashSet<PhylogenyNode>();
12875 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12876 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12877 if ( s0.match( query_nodes ) ) {
12881 query_nodes = new HashSet<PhylogenyNode>();
12882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12884 if ( s0.match( query_nodes ) ) {
12888 query_nodes = new HashSet<PhylogenyNode>();
12889 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12892 if ( s0.match( query_nodes ) ) {
12896 query_nodes = new HashSet<PhylogenyNode>();
12897 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12900 if ( s0.match( query_nodes ) ) {
12904 query_nodes = new HashSet<PhylogenyNode>();
12905 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12906 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12907 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12908 if ( s0.match( query_nodes ) ) {
12912 query_nodes = new HashSet<PhylogenyNode>();
12913 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12914 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12915 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12916 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12917 if ( s0.match( query_nodes ) ) {
12921 catch ( final Exception e ) {
12922 e.printStackTrace();
12928 private static boolean testSubtreeDeletion() {
12930 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12931 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12932 t1.deleteSubtree( t1.getNode( "A" ), false );
12933 if ( t1.getNumberOfExternalNodes() != 5 ) {
12936 t1.toNewHampshireX();
12937 t1.deleteSubtree( t1.getNode( "E" ), false );
12938 if ( t1.getNumberOfExternalNodes() != 4 ) {
12941 t1.toNewHampshireX();
12942 t1.deleteSubtree( t1.getNode( "F" ), false );
12943 if ( t1.getNumberOfExternalNodes() != 3 ) {
12946 t1.toNewHampshireX();
12947 t1.deleteSubtree( t1.getNode( "D" ), false );
12948 t1.toNewHampshireX();
12949 if ( t1.getNumberOfExternalNodes() != 3 ) {
12952 t1.deleteSubtree( t1.getNode( "def" ), false );
12953 t1.toNewHampshireX();
12954 if ( t1.getNumberOfExternalNodes() != 2 ) {
12957 t1.deleteSubtree( t1.getNode( "B" ), false );
12958 t1.toNewHampshireX();
12959 if ( t1.getNumberOfExternalNodes() != 1 ) {
12962 t1.deleteSubtree( t1.getNode( "C" ), false );
12963 t1.toNewHampshireX();
12964 if ( t1.getNumberOfExternalNodes() != 1 ) {
12967 t1.deleteSubtree( t1.getNode( "abc" ), false );
12968 t1.toNewHampshireX();
12969 if ( t1.getNumberOfExternalNodes() != 1 ) {
12972 t1.deleteSubtree( t1.getNode( "r" ), false );
12973 if ( t1.getNumberOfExternalNodes() != 0 ) {
12976 if ( !t1.isEmpty() ) {
12979 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12980 t2.deleteSubtree( t2.getNode( "A" ), false );
12981 t2.toNewHampshireX();
12982 if ( t2.getNumberOfExternalNodes() != 5 ) {
12985 t2.deleteSubtree( t2.getNode( "abc" ), false );
12986 t2.toNewHampshireX();
12987 if ( t2.getNumberOfExternalNodes() != 3 ) {
12990 t2.deleteSubtree( t2.getNode( "def" ), false );
12991 t2.toNewHampshireX();
12992 if ( t2.getNumberOfExternalNodes() != 1 ) {
12996 catch ( final Exception e ) {
12997 e.printStackTrace( System.out );
13003 private static boolean testSupportCount() {
13005 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13006 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
13007 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
13008 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
13009 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))" + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
13011 SupportCount.count( t0_1, phylogenies_1, true, false );
13012 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
13013 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
13014 + "(((((A,B),C),D),E),((F,G),X))" + "(((((A,Y),B),C),D),((F,G),E))" + "(((((A,B),C),D),E),(F,G))"
13015 + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G))" + "(((((A,B),C),D),E),(F,G),Z)"
13016 + "(((((A,B),C),D),E),(F,G))" + "((((((A,B),C),D),E),F),G)" + "(((((X,Y),F,G),E),((A,B),C)),D)",
13018 SupportCount.count( t0_2, phylogenies_2, true, false );
13019 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
13020 while ( it.hasNext() ) {
13021 final PhylogenyNode n = it.next();
13022 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
13026 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
13027 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
13028 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
13029 SupportCount.count( t0_3, phylogenies_3, true, false );
13030 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
13031 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
13034 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
13037 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
13040 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
13043 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
13046 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
13049 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
13052 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
13055 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
13058 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
13061 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13062 final Phylogeny[] phylogenies_4 = factory
13063 .create( "((((((A,X),C),B),D),E),F) " + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
13064 SupportCount.count( t0_4, phylogenies_4, true, false );
13065 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
13066 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
13069 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
13072 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
13075 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
13078 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
13081 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
13084 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
13087 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
13090 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
13093 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
13096 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13097 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13098 double d = SupportCount.compare( b1, a, true, true, true );
13099 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
13102 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13103 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13104 d = SupportCount.compare( b2, a, true, true, true );
13105 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
13108 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
13109 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
13110 d = SupportCount.compare( b3, a, true, true, true );
13111 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
13114 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
13115 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
13116 d = SupportCount.compare( b4, a, true, true, false );
13117 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
13121 catch ( final Exception e ) {
13122 e.printStackTrace( System.out );
13128 private static boolean testSupportTransfer() {
13130 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13131 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)",
13132 new NHXParser() )[ 0 ];
13133 final Phylogeny p2 = factory.create(
13134 "(((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)",
13135 new NHXParser() )[ 0 ];
13136 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
13139 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
13142 support_transfer.moveBranchLengthsToBootstrap( p1 );
13143 support_transfer.transferSupportValues( p1, p2 );
13144 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
13147 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
13150 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
13153 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
13156 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
13159 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
13162 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
13165 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
13169 catch ( final Exception e ) {
13170 e.printStackTrace( System.out );
13176 private static boolean testTaxonomyExtraction() {
13178 final PhylogenyNode n0 = PhylogenyNode
13179 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13180 if ( n0.getNodeData().isHasTaxonomy() ) {
13183 final PhylogenyNode n1 = PhylogenyNode
13184 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13185 if ( n1.getNodeData().isHasTaxonomy() ) {
13186 System.out.println( n1.toString() );
13189 final PhylogenyNode n2x = PhylogenyNode
13190 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13191 if ( n2x.getNodeData().isHasTaxonomy() ) {
13194 final PhylogenyNode n3 = PhylogenyNode
13195 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13196 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13197 System.out.println( n3.toString() );
13200 final PhylogenyNode n4 = PhylogenyNode
13201 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13202 if ( n4.getNodeData().isHasTaxonomy() ) {
13203 System.out.println( n4.toString() );
13206 final PhylogenyNode n5 = PhylogenyNode
13207 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13208 if ( n5.getNodeData().isHasTaxonomy() ) {
13209 System.out.println( n5.toString() );
13212 final PhylogenyNode n6 = PhylogenyNode
13213 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13214 if ( n6.getNodeData().isHasTaxonomy() ) {
13215 System.out.println( n6.toString() );
13218 final PhylogenyNode n7 = PhylogenyNode
13219 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13220 if ( n7.getNodeData().isHasTaxonomy() ) {
13221 System.out.println( n7.toString() );
13224 final PhylogenyNode n8 = PhylogenyNode
13225 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13226 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13227 System.out.println( n8.toString() );
13230 final PhylogenyNode n9 = PhylogenyNode
13231 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13232 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
13233 System.out.println( n9.toString() );
13236 final PhylogenyNode n10x = PhylogenyNode
13237 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13238 if ( n10x.getNodeData().isHasTaxonomy() ) {
13239 System.out.println( n10x.toString() );
13242 final PhylogenyNode n10xx = PhylogenyNode
13243 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13244 if ( n10xx.getNodeData().isHasTaxonomy() ) {
13245 System.out.println( n10xx.toString() );
13248 final PhylogenyNode n10 = PhylogenyNode
13249 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
13250 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
13251 System.out.println( n10.toString() );
13254 final PhylogenyNode n11 = PhylogenyNode
13255 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13256 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13257 System.out.println( n11.toString() );
13260 final PhylogenyNode n12 = PhylogenyNode
13261 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
13262 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13263 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13264 System.out.println( n12.toString() );
13267 final PhylogenyNode n13 = PhylogenyNode
13268 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13269 if ( n13.getNodeData().isHasTaxonomy() ) {
13270 System.out.println( n13.toString() );
13273 final PhylogenyNode n14 = PhylogenyNode
13274 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13275 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13276 System.out.println( n14.toString() );
13279 final PhylogenyNode n15 = PhylogenyNode
13280 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13281 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13282 System.out.println( n15.toString() );
13285 final PhylogenyNode n16 = PhylogenyNode
13286 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13287 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13288 System.out.println( n16.toString() );
13291 final PhylogenyNode n17 = PhylogenyNode
13292 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13293 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
13294 System.out.println( n17.toString() );
13297 final PhylogenyNode n18 = PhylogenyNode
13298 .createInstanceFromNhxString( "Mus_musculus_musculus_392",
13299 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13300 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13301 System.out.println( n18.toString() );
13304 final PhylogenyNode n19 = PhylogenyNode
13305 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
13306 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13307 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13308 System.out.println( n19.toString() );
13311 final PhylogenyNode n20 = PhylogenyNode
13312 .createInstanceFromNhxString( "Mus musculus musculus 392",
13313 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13314 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13315 System.out.println( n20.toString() );
13318 final PhylogenyNode n21 = PhylogenyNode
13319 .createInstanceFromNhxString( "Mus musculus musculus K392",
13320 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13321 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
13322 System.out.println( n21.toString() );
13325 final PhylogenyNode n23 = PhylogenyNode
13326 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
13327 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13328 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13329 System.out.println( n23.toString() );
13332 final PhylogenyNode n24 = PhylogenyNode
13333 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13334 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13335 System.out.println( n24.toString() );
13339 final PhylogenyNode n25 = PhylogenyNode
13340 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
13341 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13342 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
13343 System.out.println( n25.toString() );
13346 final PhylogenyNode n26 = PhylogenyNode
13347 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
13348 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13349 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
13350 System.out.println( n26.toString() );
13353 final PhylogenyNode n27 = PhylogenyNode
13354 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
13355 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
13356 System.out.println( n27.toString() );
13360 catch ( final Exception e ) {
13361 e.printStackTrace( System.out );
13367 private static boolean testTreeCopy() {
13369 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
13370 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
13371 final Phylogeny t1 = t0.copy();
13372 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
13375 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13378 t0.deleteSubtree( t0.getNode( "c" ), true );
13379 t0.deleteSubtree( t0.getNode( "a" ), true );
13380 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
13381 t0.getNode( "b" ).setName( "Bee" );
13382 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
13385 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13388 t0.deleteSubtree( t0.getNode( "e" ), true );
13389 t0.deleteSubtree( t0.getNode( "Bee" ), true );
13390 t0.deleteSubtree( t0.getNode( "d" ), true );
13391 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
13395 catch ( final Exception e ) {
13396 e.printStackTrace();
13402 private static boolean testTreeMethods() {
13404 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
13405 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
13406 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
13407 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
13408 System.out.println( t0.toNewHampshireX() );
13411 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
13412 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
13413 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
13416 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
13419 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
13423 catch ( final Exception e ) {
13424 e.printStackTrace( System.out );
13430 private static boolean testUniprotEntryRetrieval() {
13432 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 5000 );
13433 if ( !entry.getAccession().equals( "P12345" ) ) {
13436 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
13439 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
13442 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
13445 if ( !entry.getGeneName().equals( "GOT2" ) ) {
13448 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
13451 if ( entry.getMolecularSequence() == null ) {
13454 if ( !entry.getMolecularSequence().getMolecularSequenceAsString()
13455 .startsWith( "MALLHSARVLSGVASAFHPGLAAAASARASSWWAHVEMGPPDPILGVTEAYKRDTNSKKMNLGVGAYRDDNGKPYVLPSVRKAEAQIAAKGLDKEYLPIGGLAEFCRASAELALGENSEV" )
13456 || !entry.getMolecularSequence().getMolecularSequenceAsString().endsWith( "LAHAIHQVTK" ) ) {
13457 System.out.println( "got: " + entry.getMolecularSequence().getMolecularSequenceAsString() );
13458 System.out.println( "expected something else." );
13462 catch ( final IOException e ) {
13463 System.out.println();
13464 System.out.println( "the following might be due to absence internet connection:" );
13465 e.printStackTrace( System.out );
13468 catch ( final NullPointerException f ) {
13469 f.printStackTrace( System.out );
13472 catch ( final Exception e ) {
13478 private static boolean testUniprotTaxonomySearch() {
13480 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
13482 if ( results.size() != 1 ) {
13485 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13488 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13491 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13494 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13497 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13501 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
13502 if ( results.size() != 1 ) {
13505 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13508 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13511 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13514 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13517 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13521 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
13522 if ( results.size() != 1 ) {
13525 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13528 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13531 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13534 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13537 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13541 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
13542 if ( results.size() != 1 ) {
13545 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
13548 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
13551 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
13554 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13557 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
13560 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
13563 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
13566 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13567 .equals( "Nematostella vectensis" ) ) {
13568 System.out.println( results.get( 0 ).getLineage() );
13573 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
13574 if ( results.size() != 1 ) {
13577 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13580 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13583 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13586 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13589 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13592 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13593 .equals( "Xenopus tropicalis" ) ) {
13594 System.out.println( results.get( 0 ).getLineage() );
13599 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
13600 if ( results.size() != 1 ) {
13603 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13606 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13609 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13612 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13615 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13618 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13619 .equals( "Xenopus tropicalis" ) ) {
13620 System.out.println( results.get( 0 ).getLineage() );
13625 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
13626 if ( results.size() != 1 ) {
13629 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
13632 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
13635 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
13638 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
13641 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
13644 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
13645 .equals( "Xenopus tropicalis" ) ) {
13646 System.out.println( results.get( 0 ).getLineage() );
13650 catch ( final IOException e ) {
13651 System.out.println();
13652 System.out.println( "the following might be due to absence internet connection:" );
13653 e.printStackTrace( System.out );
13656 catch ( final Exception e ) {