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.PropertiesMap;
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.Sequence;
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;
128 import org.forester.ws.wabi.TxSearch;
129 import org.forester.ws.wabi.TxSearch.RANKS;
130 import org.forester.ws.wabi.TxSearch.TAX_NAME_CLASS;
131 import org.forester.ws.wabi.TxSearch.TAX_RANK;
133 @SuppressWarnings( "unused")
134 public final class Test {
136 private final static String PATH_TO_RESOURCES = System.getProperty( "user.dir" )
137 + ForesterUtil.getFileSeparator() + "resources"
138 + ForesterUtil.getFileSeparator();
139 private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" )
140 + ForesterUtil.getFileSeparator() + "test_data"
141 + ForesterUtil.getFileSeparator();
142 private final static boolean PERFORM_DB_TESTS = false;
143 private static final boolean PERFORM_WEB_TREE_ACCESS = true;
144 private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/"
145 + ForesterConstants.PHYLO_XML_VERSION + "/"
146 + ForesterConstants.PHYLO_XML_XSD;
147 private static final String PHYLOXML_REMOTE_XSD = ForesterConstants.PHYLO_XML_LOCATION + "/"
148 + ForesterConstants.PHYLO_XML_VERSION + "/"
149 + ForesterConstants.PHYLO_XML_XSD;
150 private final static boolean USE_LOCAL_PHYLOXML_SCHEMA = true;
151 private final static double ZERO_DIFF = 1.0E-9;
153 public static boolean isEqual( final double a, final double b ) {
154 return ( ( Math.abs( a - b ) ) < Test.ZERO_DIFF );
157 public static void main( final String[] args ) {
158 System.out.println( "[Java version: " + ForesterUtil.JAVA_VERSION + " " + ForesterUtil.JAVA_VENDOR + "]" );
159 System.out.println( "[OS: " + ForesterUtil.OS_NAME + " " + ForesterUtil.OS_ARCH + " " + ForesterUtil.OS_VERSION
161 Locale.setDefault( Locale.US );
162 System.out.println( "[Locale: " + Locale.getDefault() + "]" );
165 System.out.print( "[Test if directory with files for testing exists/is readable: " );
166 if ( Test.testDir( PATH_TO_TEST_DATA ) ) {
167 System.out.println( "OK.]" );
170 System.out.println( "could not find/read from directory \"" + PATH_TO_TEST_DATA + "\".]" );
171 System.out.println( "Testing aborted." );
174 System.out.print( "[Test if resources directory exists/is readable: " );
175 if ( testDir( PATH_TO_RESOURCES ) ) {
176 System.out.println( "OK.]" );
179 System.out.println( "could not find/read from directory \"" + Test.PATH_TO_RESOURCES + "\".]" );
180 System.out.println( "Testing aborted." );
183 final long start_time = new Date().getTime();
184 System.out.print( "MSA entropy: " );
185 if ( Test.testMsaEntropy() ) {
186 System.out.println( "OK." );
190 System.out.println( "failed." );
193 System.out.print( "Basic node methods: " );
194 if ( Test.testBasicNodeMethods() ) {
195 System.out.println( "OK." );
199 System.out.println( "failed." );
202 System.out.print( "Protein id: " );
203 if ( !testProteinId() ) {
204 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( "Species: " );
212 if ( !testSpecies() ) {
213 System.out.println( "failed." );
219 System.out.println( "OK." );
220 System.out.print( "Basic domain: " );
221 if ( !testBasicDomain() ) {
222 System.out.println( "failed." );
228 System.out.println( "OK." );
229 System.out.print( "Basic protein: " );
230 if ( !testBasicProtein() ) {
231 System.out.println( "failed." );
237 System.out.println( "OK." );
238 System.out.print( "Sequence writer: " );
239 if ( testSequenceWriter() ) {
240 System.out.println( "OK." );
244 System.out.println( "failed." );
247 System.out.print( "Sequence id parsing: " );
248 if ( testSequenceIdParsing() ) {
249 System.out.println( "OK." );
253 System.out.println( "failed." );
256 System.out.print( "UniProtKB id extraction: " );
257 if ( Test.testExtractUniProtKbProteinSeqIdentifier() ) {
258 System.out.println( "OK." );
262 System.out.println( "failed." );
265 System.out.print( "Sequence DB tools 1: " );
266 if ( testSequenceDbWsTools1() ) {
267 System.out.println( "OK." );
271 System.out.println( "failed." );
274 System.out.print( "Hmmscan output parser: " );
275 if ( testHmmscanOutputParser() ) {
276 System.out.println( "OK." );
280 System.out.println( "failed." );
283 System.out.print( "Overlap removal: " );
284 if ( !org.forester.test.Test.testOverlapRemoval() ) {
285 System.out.println( "failed." );
291 System.out.println( "OK." );
292 System.out.print( "Engulfing overlap removal: " );
293 if ( !Test.testEngulfingOverlapRemoval() ) {
294 System.out.println( "failed." );
300 System.out.println( "OK." );
301 System.out.print( "Taxonomy code extraction: " );
302 if ( Test.testExtractTaxonomyCodeFromNodeName() ) {
303 System.out.println( "OK." );
307 System.out.println( "failed." );
310 System.out.print( "SN extraction: " );
311 if ( Test.testExtractSNFromNodeName() ) {
312 System.out.println( "OK." );
316 System.out.println( "failed." );
319 System.out.print( "Taxonomy extraction (general): " );
320 if ( Test.testTaxonomyExtraction() ) {
321 System.out.println( "OK." );
325 System.out.println( "failed." );
328 System.out.print( "Uri for Aptx web sequence accession: " );
329 if ( Test.testCreateUriForSeqWeb() ) {
330 System.out.println( "OK." );
334 System.out.println( "failed." );
337 System.out.print( "Basic node construction and parsing of NHX (node level): " );
338 if ( Test.testNHXNodeParsing() ) {
339 System.out.println( "OK." );
343 System.out.println( "failed." );
346 System.out.print( "NHX parsing iterating: " );
347 if ( Test.testNHParsingIter() ) {
348 System.out.println( "OK." );
352 System.out.println( "failed." );
355 System.out.print( "NH parsing: " );
356 if ( Test.testNHParsing() ) {
357 System.out.println( "OK." );
361 System.out.println( "failed." );
364 System.out.print( "Conversion to NHX (node level): " );
365 if ( Test.testNHXconversion() ) {
366 System.out.println( "OK." );
370 System.out.println( "failed." );
373 System.out.print( "NHX parsing: " );
374 if ( Test.testNHXParsing() ) {
375 System.out.println( "OK." );
379 System.out.println( "failed." );
382 System.out.print( "NHX parsing with quotes: " );
383 if ( Test.testNHXParsingQuotes() ) {
384 System.out.println( "OK." );
388 System.out.println( "failed." );
391 System.out.print( "NHX parsing (MrBayes): " );
392 if ( Test.testNHXParsingMB() ) {
393 System.out.println( "OK." );
397 System.out.println( "failed." );
400 System.out.print( "Nexus characters parsing: " );
401 if ( Test.testNexusCharactersParsing() ) {
402 System.out.println( "OK." );
406 System.out.println( "failed." );
409 System.out.print( "Nexus tree parsing iterating: " );
410 if ( Test.testNexusTreeParsingIterating() ) {
411 System.out.println( "OK." );
415 System.out.println( "failed." );
418 System.out.print( "Nexus tree parsing: " );
419 if ( Test.testNexusTreeParsing() ) {
420 System.out.println( "OK." );
424 System.out.println( "failed." );
427 System.out.print( "Nexus tree parsing (translating): " );
428 if ( Test.testNexusTreeParsingTranslating() ) {
429 System.out.println( "OK." );
433 System.out.println( "failed." );
436 System.out.print( "Nexus matrix parsing: " );
437 if ( Test.testNexusMatrixParsing() ) {
438 System.out.println( "OK." );
442 System.out.println( "failed." );
445 System.out.print( "Basic phyloXML parsing: " );
446 if ( Test.testBasicPhyloXMLparsing() ) {
447 System.out.println( "OK." );
451 System.out.println( "failed." );
454 System.out.print( "Basic phyloXML parsing (validating against schema): " );
455 if ( testBasicPhyloXMLparsingValidating() ) {
456 System.out.println( "OK." );
460 System.out.println( "failed." );
463 System.out.print( "Roundtrip phyloXML parsing (validating against schema): " );
464 if ( Test.testBasicPhyloXMLparsingRoundtrip() ) {
465 System.out.println( "OK." );
469 System.out.println( "failed." );
472 System.out.print( "phyloXML Distribution Element: " );
473 if ( Test.testPhyloXMLparsingOfDistributionElement() ) {
474 System.out.println( "OK." );
478 System.out.println( "failed." );
481 System.out.print( "Tol XML parsing: " );
482 if ( Test.testBasicTolXMLparsing() ) {
483 System.out.println( "OK." );
487 System.out.println( "failed." );
490 System.out.print( "Copying of node data: " );
491 if ( Test.testCopyOfNodeData() ) {
492 System.out.println( "OK." );
496 System.out.println( "failed." );
499 System.out.print( "Tree copy: " );
500 if ( Test.testTreeCopy() ) {
501 System.out.println( "OK." );
505 System.out.println( "failed." );
508 System.out.print( "Basic tree methods: " );
509 if ( Test.testBasicTreeMethods() ) {
510 System.out.println( "OK." );
514 System.out.println( "failed." );
517 System.out.print( "Tree methods: " );
518 if ( Test.testTreeMethods() ) {
519 System.out.println( "OK." );
523 System.out.println( "failed." );
526 System.out.print( "Postorder Iterator: " );
527 if ( Test.testPostOrderIterator() ) {
528 System.out.println( "OK." );
532 System.out.println( "failed." );
535 System.out.print( "Preorder Iterator: " );
536 if ( Test.testPreOrderIterator() ) {
537 System.out.println( "OK." );
541 System.out.println( "failed." );
544 System.out.print( "Levelorder Iterator: " );
545 if ( Test.testLevelOrderIterator() ) {
546 System.out.println( "OK." );
550 System.out.println( "failed." );
553 System.out.print( "Re-id methods: " );
554 if ( Test.testReIdMethods() ) {
555 System.out.println( "OK." );
559 System.out.println( "failed." );
562 System.out.print( "Methods on last external nodes: " );
563 if ( Test.testLastExternalNodeMethods() ) {
564 System.out.println( "OK." );
568 System.out.println( "failed." );
571 System.out.print( "Methods on external nodes: " );
572 if ( Test.testExternalNodeRelatedMethods() ) {
573 System.out.println( "OK." );
577 System.out.println( "failed." );
580 System.out.print( "Deletion of external nodes: " );
581 if ( Test.testDeletionOfExternalNodes() ) {
582 System.out.println( "OK." );
586 System.out.println( "failed." );
589 System.out.print( "Subtree deletion: " );
590 if ( Test.testSubtreeDeletion() ) {
591 System.out.println( "OK." );
595 System.out.println( "failed." );
598 System.out.print( "Phylogeny branch: " );
599 if ( Test.testPhylogenyBranch() ) {
600 System.out.println( "OK." );
604 System.out.println( "failed." );
607 System.out.print( "Rerooting: " );
608 if ( Test.testRerooting() ) {
609 System.out.println( "OK." );
613 System.out.println( "failed." );
616 System.out.print( "Mipoint rooting: " );
617 if ( Test.testMidpointrooting() ) {
618 System.out.println( "OK." );
622 System.out.println( "failed." );
625 System.out.print( "Node removal: " );
626 if ( Test.testNodeRemoval() ) {
627 System.out.println( "OK." );
631 System.out.println( "failed." );
634 System.out.print( "Support count: " );
635 if ( Test.testSupportCount() ) {
636 System.out.println( "OK." );
640 System.out.println( "failed." );
643 System.out.print( "Support transfer: " );
644 if ( Test.testSupportTransfer() ) {
645 System.out.println( "OK." );
649 System.out.println( "failed." );
652 System.out.print( "Finding of LCA: " );
653 if ( Test.testGetLCA() ) {
654 System.out.println( "OK." );
658 System.out.println( "failed." );
661 System.out.print( "Finding of LCA 2: " );
662 if ( Test.testGetLCA2() ) {
663 System.out.println( "OK." );
667 System.out.println( "failed." );
670 System.out.print( "Calculation of distance between nodes: " );
671 if ( Test.testGetDistance() ) {
672 System.out.println( "OK." );
676 System.out.println( "failed." );
679 System.out.print( "Descriptive statistics: " );
680 if ( Test.testDescriptiveStatistics() ) {
681 System.out.println( "OK." );
685 System.out.println( "failed." );
688 System.out.print( "Data objects and methods: " );
689 if ( Test.testDataObjects() ) {
690 System.out.println( "OK." );
694 System.out.println( "failed." );
697 System.out.print( "Properties map: " );
698 if ( Test.testPropertiesMap() ) {
699 System.out.println( "OK." );
703 System.out.println( "failed." );
706 System.out.print( "SDIse: " );
707 if ( Test.testSDIse() ) {
708 System.out.println( "OK." );
712 System.out.println( "failed." );
715 System.out.print( "SDIunrooted: " );
716 if ( Test.testSDIunrooted() ) {
717 System.out.println( "OK." );
721 System.out.println( "failed." );
724 System.out.print( "GSDI: " );
725 if ( TestGSDI.test() ) {
726 System.out.println( "OK." );
730 System.out.println( "failed." );
733 System.out.print( "RIO: " );
734 if ( TestRIO.test() ) {
735 System.out.println( "OK." );
739 System.out.println( "failed." );
742 System.out.print( "Phylogeny reconstruction:" );
743 System.out.println();
744 if ( TestPhylogenyReconstruction.test( new File( PATH_TO_TEST_DATA ) ) ) {
745 System.out.println( "OK." );
749 System.out.println( "failed." );
752 System.out.print( "Analysis of domain architectures: " );
753 System.out.println();
754 if ( TestSurfacing.test( new File( PATH_TO_TEST_DATA ) ) ) {
755 System.out.println( "OK." );
759 System.out.println( "failed." );
762 System.out.print( "GO: " );
763 System.out.println();
764 if ( TestGo.test( new File( PATH_TO_TEST_DATA ) ) ) {
765 System.out.println( "OK." );
769 System.out.println( "failed." );
772 System.out.print( "Modeling tools: " );
773 if ( TestPccx.test() ) {
774 System.out.println( "OK." );
778 System.out.println( "failed." );
781 System.out.print( "Split Matrix strict: " );
782 if ( Test.testSplitStrict() ) {
783 System.out.println( "OK." );
787 System.out.println( "failed." );
790 System.out.print( "Split Matrix: " );
791 if ( Test.testSplit() ) {
792 System.out.println( "OK." );
796 System.out.println( "failed." );
799 System.out.print( "Confidence Assessor: " );
800 if ( Test.testConfidenceAssessor() ) {
801 System.out.println( "OK." );
805 System.out.println( "failed." );
808 System.out.print( "Basic table: " );
809 if ( Test.testBasicTable() ) {
810 System.out.println( "OK." );
814 System.out.println( "failed." );
817 System.out.print( "General table: " );
818 if ( Test.testGeneralTable() ) {
819 System.out.println( "OK." );
823 System.out.println( "failed." );
826 System.out.print( "Amino acid sequence: " );
827 if ( Test.testAminoAcidSequence() ) {
828 System.out.println( "OK." );
832 System.out.println( "failed." );
835 System.out.print( "General MSA parser: " );
836 if ( Test.testGeneralMsaParser() ) {
837 System.out.println( "OK." );
841 System.out.println( "failed." );
844 System.out.print( "Fasta parser for msa: " );
845 if ( Test.testFastaParser() ) {
846 System.out.println( "OK." );
850 System.out.println( "failed." );
853 System.out.print( "Creation of balanced phylogeny: " );
854 if ( Test.testCreateBalancedPhylogeny() ) {
855 System.out.println( "OK." );
859 System.out.println( "failed." );
862 System.out.print( "Genbank accessor parsing: " );
863 if ( Test.testGenbankAccessorParsing() ) {
864 System.out.println( "OK." );
868 System.out.println( "failed." );
872 final String os = ForesterUtil.OS_NAME.toLowerCase();
873 if ( ( os.indexOf( "mac" ) >= 0 ) && ( os.indexOf( "os" ) > 0 ) ) {
874 path = "/usr/local/bin/mafft";
876 else if ( os.indexOf( "win" ) >= 0 ) {
877 path = "C:\\Program Files\\mafft-win\\mafft.bat";
881 if ( !MsaInferrer.isInstalled( path ) ) {
882 path = "/usr/bin/mafft";
884 if ( !MsaInferrer.isInstalled( path ) ) {
885 path = "/usr/local/bin/mafft";
888 if ( MsaInferrer.isInstalled( path ) ) {
889 System.out.print( "MAFFT (external program): " );
890 if ( Test.testMafft( path ) ) {
891 System.out.println( "OK." );
895 System.out.println( "failed [will not count towards failed tests]" );
898 System.out.print( "Next nodes with collapsed: " );
899 if ( Test.testNextNodeWithCollapsing() ) {
900 System.out.println( "OK." );
904 System.out.println( "failed." );
907 System.out.print( "Simple MSA quality: " );
908 if ( Test.testMsaQualityMethod() ) {
909 System.out.println( "OK." );
913 System.out.println( "failed." );
916 System.out.print( "Deleteable MSA: " );
917 if ( Test.testDeleteableMsa() ) {
918 System.out.println( "OK." );
922 System.out.println( "failed." );
925 if ( PERFORM_DB_TESTS ) {
926 System.out.print( "Uniprot Entry Retrieval: " );
927 if ( Test.testUniprotEntryRetrieval() ) {
928 System.out.println( "OK." );
932 System.out.println( "failed." );
935 System.out.print( "Ebi Entry Retrieval: " );
936 if ( Test.testEbiEntryRetrieval() ) {
937 System.out.println( "OK." );
941 System.out.println( "failed." );
944 System.out.print( "Sequence DB tools 2: " );
945 if ( testSequenceDbWsTools2() ) {
946 System.out.println( "OK." );
950 System.out.println( "failed." );
954 System.out.print( "Uniprot Taxonomy Search: " );
955 if ( Test.testUniprotTaxonomySearch() ) {
956 System.out.println( "OK." );
960 System.out.println( "failed." );
964 if ( PERFORM_WEB_TREE_ACCESS ) {
965 System.out.print( "NHX parsing from URL: " );
966 if ( Test.testNHXparsingFromURL() ) {
967 System.out.println( "OK." );
971 System.out.println( "failed." );
974 System.out.print( "NHX parsing from URL 2: " );
975 if ( Test.testNHXparsingFromURL2() ) {
976 System.out.println( "OK." );
980 System.out.println( "failed." );
983 System.out.print( "phyloXML parsing from URL: " );
984 if ( Test.testPhyloXMLparsingFromURL() ) {
985 System.out.println( "OK." );
989 System.out.println( "failed." );
992 System.out.print( "TreeBase acccess: " );
993 if ( Test.testTreeBaseReading() ) {
994 System.out.println( "OK." );
998 System.out.println( "failed." );
1002 System.out.print( "ToL access: " );
1003 if ( Test.testToLReading() ) {
1004 System.out.println( "OK." );
1008 System.out.println( "failed." );
1012 System.out.print( "TreeFam access: " );
1013 if ( Test.testTreeFamReading() ) {
1014 System.out.println( "OK." );
1018 System.out.println( "failed." );
1023 System.out.print( "Pfam tree access: " );
1024 if ( Test.testPfamTreeReading() ) {
1025 System.out.println( "OK." );
1029 System.out.println( "failed." );
1033 System.out.println();
1034 final Runtime rt = java.lang.Runtime.getRuntime();
1035 final long free_memory = rt.freeMemory() / 1000000;
1036 final long total_memory = rt.totalMemory() / 1000000;
1037 System.out.println( "Running time : " + ( new Date().getTime() - start_time ) + "ms " + "(free memory: "
1038 + free_memory + "MB, total memory: " + total_memory + "MB)" );
1039 System.out.println();
1040 System.out.println( "Successful tests: " + succeeded );
1041 System.out.println( "Failed tests: " + failed );
1042 System.out.println();
1044 System.out.println( "OK." );
1047 System.out.println( "Not OK." );
1051 public static boolean testEngulfingOverlapRemoval() {
1053 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1054 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
1055 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
1056 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1057 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1058 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
1059 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1060 final List<Boolean> covered = new ArrayList<Boolean>();
1061 covered.add( true ); // 0
1062 covered.add( false ); // 1
1063 covered.add( true ); // 2
1064 covered.add( false ); // 3
1065 covered.add( true ); // 4
1066 covered.add( true ); // 5
1067 covered.add( false ); // 6
1068 covered.add( true ); // 7
1069 covered.add( true ); // 8
1070 if ( ForesterUtil.isEngulfed( d0, covered ) ) {
1073 if ( ForesterUtil.isEngulfed( d1, covered ) ) {
1076 if ( ForesterUtil.isEngulfed( d2, covered ) ) {
1079 if ( !ForesterUtil.isEngulfed( d3, covered ) ) {
1082 if ( ForesterUtil.isEngulfed( d4, covered ) ) {
1085 if ( ForesterUtil.isEngulfed( d5, covered ) ) {
1088 if ( !ForesterUtil.isEngulfed( d6, covered ) ) {
1091 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1092 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
1093 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
1094 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
1095 abc.addProteinDomain( a );
1096 abc.addProteinDomain( b );
1097 abc.addProteinDomain( c );
1098 final Protein abc_r1 = ForesterUtil.removeOverlappingDomains( 3, false, abc );
1099 final Protein abc_r2 = ForesterUtil.removeOverlappingDomains( 3, true, abc );
1100 if ( abc.getNumberOfProteinDomains() != 3 ) {
1103 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
1106 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
1109 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().equals( "a" ) ) {
1112 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().equals( "b" ) ) {
1115 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1116 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
1117 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
1118 final Protein def = new BasicProtein( "def", "nemve", 0 );
1119 def.addProteinDomain( d );
1120 def.addProteinDomain( e );
1121 def.addProteinDomain( f );
1122 final Protein def_r1 = ForesterUtil.removeOverlappingDomains( 5, false, def );
1123 final Protein def_r2 = ForesterUtil.removeOverlappingDomains( 5, true, def );
1124 if ( def.getNumberOfProteinDomains() != 3 ) {
1127 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
1130 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
1133 if ( !def_r2.getProteinDomain( 0 ).getDomainId().equals( "d" ) ) {
1136 if ( !def_r2.getProteinDomain( 1 ).getDomainId().equals( "f" ) ) {
1139 if ( !def_r2.getProteinDomain( 2 ).getDomainId().equals( "e" ) ) {
1143 catch ( final Exception e ) {
1144 e.printStackTrace( System.out );
1150 public static final boolean testNHXparsingFromURL2() {
1152 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1153 final Phylogeny phys[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1157 TAXONOMY_EXTRACTION.NO,
1159 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1162 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1163 System.out.println( phys[ 0 ].toNewHampshire() );
1166 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1167 System.out.println( phys[ 1 ].toNewHampshire() );
1170 final Phylogeny phys2[] = AptxUtil.readPhylogeniesFromUrl( new URL( s ),
1174 TAXONOMY_EXTRACTION.NO,
1176 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1179 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1180 System.out.println( phys2[ 0 ].toNewHampshire() );
1183 if ( !phys2[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1184 System.out.println( phys2[ 1 ].toNewHampshire() );
1187 final Phylogeny phys3[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1188 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1189 if ( ( phys3 == null ) || ( phys3.length != 1 ) ) {
1194 .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))))));" ) ) {
1195 System.out.println( phys3[ 0 ].toNewHampshire() );
1198 final Phylogeny phys4[] = AptxUtil.readPhylogeniesFromUrl( new URL( "http://swisstree.vital-it.ch:80/"
1199 + "SwissTree/ST001/consensus_tree.nhx" ), false, false, false, TAXONOMY_EXTRACTION.NO, false );
1200 if ( ( phys4 == null ) || ( phys4.length != 1 ) ) {
1205 .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))))));" ) ) {
1206 System.out.println( phys4[ 0 ].toNewHampshire() );
1210 catch ( final Exception e ) {
1211 e.printStackTrace();
1216 public static final boolean testNHXparsingFromURL() {
1218 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/simple/simple_1.nh";
1219 final URL u = new URL( s );
1220 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1221 final Phylogeny[] phys = factory.create( u, new NHXParser() );
1222 if ( ( phys == null ) || ( phys.length != 5 ) ) {
1225 if ( !phys[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1226 System.out.println( phys[ 0 ].toNewHampshire() );
1229 if ( !phys[ 1 ].toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1230 System.out.println( phys[ 1 ].toNewHampshire() );
1233 final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() );
1234 if ( ( phys2 == null ) || ( phys2.length != 5 ) ) {
1237 if ( !phys2[ 0 ].toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1238 System.out.println( phys2[ 0 ].toNewHampshire() );
1241 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1242 final NHXParser p = new NHXParser();
1243 final URL u2 = new URL( s );
1245 if ( !p.hasNext() ) {
1248 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1251 if ( !p.hasNext() ) {
1255 if ( !p.hasNext() ) {
1258 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1261 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1265 if ( !p.hasNext() ) {
1268 if ( !p.next().toNewHampshire().equals( "((((A,B),C),D),(E,F));" ) ) {
1271 if ( !p.next().toNewHampshire().equals( "((1,2,3),(4,5,6),(7,8,9));" ) ) {
1275 catch ( final Exception e ) {
1276 e.printStackTrace();
1281 public static boolean testOverlapRemoval() {
1283 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
1284 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1285 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
1286 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
1287 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
1288 final List<Boolean> covered = new ArrayList<Boolean>();
1289 covered.add( true ); // 0
1290 covered.add( false ); // 1
1291 covered.add( true ); // 2
1292 covered.add( false ); // 3
1293 covered.add( true ); // 4
1294 covered.add( true ); // 5
1295 covered.add( false ); // 6
1296 covered.add( true ); // 7
1297 covered.add( true ); // 8
1298 if ( ForesterUtil.calculateOverlap( d0, covered ) != 3 ) {
1301 if ( ForesterUtil.calculateOverlap( d1, covered ) != 2 ) {
1304 if ( ForesterUtil.calculateOverlap( d2, covered ) != 6 ) {
1307 if ( ForesterUtil.calculateOverlap( d3, covered ) != 0 ) {
1310 if ( ForesterUtil.calculateOverlap( d4, covered ) != 2 ) {
1313 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 1, -1 );
1314 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, -1 );
1315 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
1316 ab.addProteinDomain( a );
1317 ab.addProteinDomain( b );
1318 final Protein ab_s0 = ForesterUtil.removeOverlappingDomains( 3, false, ab );
1319 if ( ab.getNumberOfProteinDomains() != 2 ) {
1322 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
1325 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().equals( "b" ) ) {
1328 final Protein ab_s1 = ForesterUtil.removeOverlappingDomains( 4, false, ab );
1329 if ( ab.getNumberOfProteinDomains() != 2 ) {
1332 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
1335 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
1336 final Domain d = new BasicDomain( "d",
1343 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
1344 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
1345 cde.addProteinDomain( c );
1346 cde.addProteinDomain( d );
1347 cde.addProteinDomain( e );
1348 final Protein cde_s0 = ForesterUtil.removeOverlappingDomains( 0, false, cde );
1349 if ( cde.getNumberOfProteinDomains() != 3 ) {
1352 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
1355 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1356 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1357 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1358 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
1359 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
1360 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
1361 fghi.addProteinDomain( f );
1362 fghi.addProteinDomain( g );
1363 fghi.addProteinDomain( h );
1364 fghi.addProteinDomain( i );
1365 fghi.addProteinDomain( i );
1366 fghi.addProteinDomain( i );
1367 fghi.addProteinDomain( i2 );
1368 final Protein fghi_s0 = ForesterUtil.removeOverlappingDomains( 10, false, fghi );
1369 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1372 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
1375 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().equals( "h" ) ) {
1378 final Protein fghi_s1 = ForesterUtil.removeOverlappingDomains( 11, false, fghi );
1379 if ( fghi.getNumberOfProteinDomains() != 7 ) {
1382 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
1385 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
1386 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
1387 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
1388 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
1389 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
1390 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
1391 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1392 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
1393 jklm.addProteinDomain( j );
1394 jklm.addProteinDomain( k );
1395 jklm.addProteinDomain( l );
1396 jklm.addProteinDomain( m );
1397 jklm.addProteinDomain( m0 );
1398 jklm.addProteinDomain( m1 );
1399 jklm.addProteinDomain( m2 );
1400 final Protein jklm_s0 = ForesterUtil.removeOverlappingDomains( 10, false, jklm );
1401 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1404 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
1407 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().equals( "l" ) ) {
1410 final Protein jklm_s1 = ForesterUtil.removeOverlappingDomains( 11, false, jklm );
1411 if ( jklm.getNumberOfProteinDomains() != 7 ) {
1414 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
1417 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
1418 final Protein od = new BasicProtein( "od", "varanus", 0 );
1419 od.addProteinDomain( only );
1420 final Protein od_s0 = ForesterUtil.removeOverlappingDomains( 0, false, od );
1421 if ( od.getNumberOfProteinDomains() != 1 ) {
1424 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
1428 catch ( final Exception e ) {
1429 e.printStackTrace( System.out );
1435 public static final boolean testPfamTreeReading() {
1437 final URL u = new URL( WebserviceUtil.PFAM_SERVER + "/family/PF" + "01849" + "/tree/download" );
1438 final NHXParser parser = new NHXParser();
1439 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1440 parser.setReplaceUnderscores( false );
1441 parser.setGuessRootedness( true );
1442 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1443 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1444 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1447 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1451 catch ( final Exception e ) {
1452 e.printStackTrace();
1457 public static final boolean testPhyloXMLparsingFromURL() {
1459 final String s = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/examples/archaeopteryx_a/apaf_bcl2.xml";
1460 final URL u = new URL( s );
1461 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1462 final Phylogeny[] phys = factory.create( u.openStream(), PhyloXmlParser.createPhyloXmlParser() );
1463 if ( ( phys == null ) || ( phys.length != 2 ) ) {
1467 catch ( final Exception e ) {
1468 e.printStackTrace();
1473 public static final boolean testToLReading() {
1475 final URL u = new URL( WebserviceUtil.TOL_URL_BASE + "15079" );
1476 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1477 final Phylogeny[] phys = factory.create( u.openStream(), new TolParser() );
1478 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1481 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "15079" ) ) {
1484 if ( !phys[ 0 ].getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Protacanthopterygii" ) ) {
1487 if ( phys[ 0 ].getNumberOfExternalNodes() < 5 ) {
1491 catch ( final Exception e ) {
1492 e.printStackTrace();
1497 public static final boolean testTreeBaseReading() {
1499 final URL u = new URL( WebserviceUtil.TREEBASE_PHYLOWS_TREE_URL_BASE + "825?format=nexus" );
1500 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
1501 parser.setReplaceUnderscores( true );
1502 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1503 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1504 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1507 final URL u2 = new URL( WebserviceUtil.TREEBASE_PHYLOWS_STUDY_URL_BASE + "15613?format=nexus" );
1508 final NexusPhylogeniesParser parser2 = new NexusPhylogeniesParser();
1509 parser2.setReplaceUnderscores( true );
1510 final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance();
1511 final Phylogeny[] phys2 = factory2.create( u2.openStream(), parser2 );
1512 if ( ( phys2 == null ) || ( phys2.length != 9 ) ) {
1516 catch ( final Exception e ) {
1517 e.printStackTrace();
1522 public static final boolean testTreeFamReading() {
1524 final URL u = new URL( WebserviceUtil.TREE_FAM_URL_BASE + "101004" + "/tree/newick" );
1525 final NHXParser parser = new NHXParser();
1526 parser.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
1527 parser.setReplaceUnderscores( false );
1528 parser.setGuessRootedness( true );
1529 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1530 final Phylogeny[] phys = factory.create( u.openStream(), parser );
1531 if ( ( phys == null ) || ( phys.length != 1 ) ) {
1534 if ( phys[ 0 ].getNumberOfExternalNodes() < 10 ) {
1538 catch ( final Exception e ) {
1539 e.printStackTrace();
1544 private final static Phylogeny createPhylogeny( final String nhx ) throws IOException {
1545 final Phylogeny p = ParserBasedPhylogenyFactory.getInstance().create( nhx, new NHXParser() )[ 0 ];
1549 private final static Event getEvent( final Phylogeny p, final String n1, final String n2 ) {
1550 return PhylogenyMethods.calculateLCA( p.getNode( n1 ), p.getNode( n2 ) ).getNodeData().getEvent();
1553 private static boolean testAminoAcidSequence() {
1555 final Sequence aa1 = BasicSequence.createAaSequence( "aa1", "aAklm-?xX*z$#" );
1556 if ( aa1.getLength() != 13 ) {
1559 if ( aa1.getResidueAt( 0 ) != 'A' ) {
1562 if ( aa1.getResidueAt( 2 ) != 'K' ) {
1565 if ( !new String( aa1.getMolecularSequence() ).equals( "AAKLM-XXX*ZXX" ) ) {
1568 final Sequence aa2 = BasicSequence.createAaSequence( "aa3", "ARNDCQEGHILKMFPSTWYVX*-BZOJU" );
1569 if ( !new String( aa2.getMolecularSequence() ).equals( "ARNDCQEGHILKMFPSTWYVX*-BZXXU" ) ) {
1572 final Sequence dna1 = BasicSequence.createDnaSequence( "dna1", "ACGTUX*-?RYMKWSN" );
1573 if ( !new String( dna1.getMolecularSequence() ).equals( "ACGTNN*-NRYMKWSN" ) ) {
1576 final Sequence rna1 = BasicSequence.createRnaSequence( "rna1", "..ACGUTX*-?RYMKWSN" );
1577 if ( !new String( rna1.getMolecularSequence() ).equals( "--ACGUNN*-NRYMKWSN" ) ) {
1581 catch ( final Exception e ) {
1582 e.printStackTrace();
1588 private static boolean testBasicDomain() {
1590 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1591 if ( !pd.getDomainId().equals( "id" ) ) {
1594 if ( pd.getNumber() != 1 ) {
1597 if ( pd.getTotalCount() != 4 ) {
1600 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
1603 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1604 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1605 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
1606 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
1607 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
1608 if ( !a1.equals( a1 ) ) {
1611 if ( !a1.equals( a1_copy ) ) {
1614 if ( !a1.equals( a1_equal ) ) {
1617 if ( !a1.equals( a2 ) ) {
1620 if ( a1.equals( a3 ) ) {
1623 if ( a1.compareTo( a1 ) != 0 ) {
1626 if ( a1.compareTo( a1_copy ) != 0 ) {
1629 if ( a1.compareTo( a1_equal ) != 0 ) {
1632 if ( a1.compareTo( a2 ) != 0 ) {
1635 if ( a1.compareTo( a3 ) == 0 ) {
1639 catch ( final Exception e ) {
1640 e.printStackTrace( System.out );
1646 private static boolean testBasicNodeMethods() {
1648 if ( PhylogenyNode.getNodeCount() != 0 ) {
1651 final PhylogenyNode n1 = new PhylogenyNode();
1652 final PhylogenyNode n2 = PhylogenyNode
1653 .createInstanceFromNhxString( "", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1654 final PhylogenyNode n3 = PhylogenyNode
1655 .createInstanceFromNhxString( "n3", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1656 final PhylogenyNode n4 = PhylogenyNode
1657 .createInstanceFromNhxString( "n4:0.01", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1658 if ( n1.isHasAssignedEvent() ) {
1661 if ( PhylogenyNode.getNodeCount() != 4 ) {
1664 if ( n3.getIndicator() != 0 ) {
1667 if ( n3.getNumberOfExternalNodes() != 1 ) {
1670 if ( !n3.isExternal() ) {
1673 if ( !n3.isRoot() ) {
1676 if ( !n4.getName().equals( "n4" ) ) {
1680 catch ( final Exception e ) {
1681 e.printStackTrace( System.out );
1687 private static boolean testBasicPhyloXMLparsing() {
1689 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1690 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1691 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1693 if ( xml_parser.getErrorCount() > 0 ) {
1694 System.out.println( xml_parser.getErrorMessages().toString() );
1697 if ( phylogenies_0.length != 4 ) {
1700 final Phylogeny t1 = phylogenies_0[ 0 ];
1701 final Phylogeny t2 = phylogenies_0[ 1 ];
1702 final Phylogeny t3 = phylogenies_0[ 2 ];
1703 final Phylogeny t4 = phylogenies_0[ 3 ];
1704 if ( t1.getNumberOfExternalNodes() != 1 ) {
1707 if ( !t1.isRooted() ) {
1710 if ( t1.isRerootable() ) {
1713 if ( !t1.getType().equals( "gene_tree" ) ) {
1716 if ( t2.getNumberOfExternalNodes() != 2 ) {
1719 if ( !isEqual( t2.getNode( "node a" ).getDistanceToParent(), 1.0 ) ) {
1722 if ( !isEqual( t2.getNode( "node b" ).getDistanceToParent(), 2.0 ) ) {
1725 if ( t2.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1728 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1731 if ( !t2.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1734 if ( t2.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1737 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1738 .startsWith( "actgtgggggt" ) ) {
1741 if ( !t2.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1742 .startsWith( "ctgtgatgcat" ) ) {
1745 if ( t3.getNumberOfExternalNodes() != 4 ) {
1748 if ( !t1.getName().equals( "t1" ) ) {
1751 if ( !t2.getName().equals( "t2" ) ) {
1754 if ( !t3.getName().equals( "t3" ) ) {
1757 if ( !t4.getName().equals( "t4" ) ) {
1760 if ( !t3.getIdentifier().getValue().equals( "1-1" ) ) {
1763 if ( !t3.getIdentifier().getProvider().equals( "treebank" ) ) {
1766 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1769 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getName()
1770 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1773 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1776 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1779 if ( !t3.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource().equals( "UniProtKB" ) ) {
1782 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1783 .equals( "apoptosis" ) ) {
1786 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1787 .equals( "GO:0006915" ) ) {
1790 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1791 .equals( "UniProtKB" ) ) {
1794 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1795 .equals( "experimental" ) ) {
1798 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1799 .equals( "function" ) ) {
1802 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1803 .getValue() != 1 ) {
1806 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1807 .getType().equals( "ml" ) ) {
1810 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1811 .equals( "apoptosis" ) ) {
1814 if ( ( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1815 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
1818 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1819 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
1822 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1823 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
1826 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1827 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
1830 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1831 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
1834 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
1835 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
1838 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
1839 .equals( "GO:0005829" ) ) {
1842 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
1843 .equals( "intracellular organelle" ) ) {
1846 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
1849 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
1850 .equals( "UniProt link" ) ) ) {
1853 if ( !( t3.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
1856 final SortedSet<Accession> x = t3.getNode( "root node" ).getNodeData().getSequence().getCrossReferences();
1857 if ( x.size() != 4 ) {
1861 for( final Accession acc : x ) {
1863 if ( !acc.getSource().equals( "KEGG" ) ) {
1866 if ( !acc.getValue().equals( "hsa:596" ) ) {
1873 catch ( final Exception e ) {
1874 e.printStackTrace( System.out );
1880 private static boolean testBasicPhyloXMLparsingRoundtrip() {
1882 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1883 final PhyloXmlParser xml_parser = PhyloXmlParser.createPhyloXmlParser();
1884 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
1885 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
1888 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
1890 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
1892 if ( xml_parser.getErrorCount() > 0 ) {
1893 System.out.println( xml_parser.getErrorMessages().toString() );
1896 if ( phylogenies_0.length != 4 ) {
1899 final StringBuffer t1_sb = new StringBuffer( phylogenies_0[ 0 ].toPhyloXML( 0 ) );
1900 final Phylogeny[] phylogenies_t1 = factory.create( t1_sb, xml_parser );
1901 if ( phylogenies_t1.length != 1 ) {
1904 final Phylogeny t1_rt = phylogenies_t1[ 0 ];
1905 if ( !t1_rt.getDistanceUnit().equals( "cc" ) ) {
1908 if ( !t1_rt.isRooted() ) {
1911 if ( t1_rt.isRerootable() ) {
1914 if ( !t1_rt.getType().equals( "gene_tree" ) ) {
1917 final StringBuffer t2_sb = new StringBuffer( phylogenies_0[ 1 ].toPhyloXML( 0 ) );
1918 final Phylogeny[] phylogenies_t2 = factory.create( t2_sb, xml_parser );
1919 final Phylogeny t2_rt = phylogenies_t2[ 0 ];
1920 if ( t2_rt.getNode( "node a" ).getNodeData().getTaxonomies().size() != 2 ) {
1923 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 0 ).getCommonName().equals( "some parasite" ) ) {
1926 if ( !t2_rt.getNode( "node a" ).getNodeData().getTaxonomy( 1 ).getCommonName().equals( "the host" ) ) {
1929 if ( t2_rt.getNode( "node a" ).getNodeData().getSequences().size() != 2 ) {
1932 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 0 ).getMolecularSequence()
1933 .startsWith( "actgtgggggt" ) ) {
1936 if ( !t2_rt.getNode( "node a" ).getNodeData().getSequence( 1 ).getMolecularSequence()
1937 .startsWith( "ctgtgatgcat" ) ) {
1940 final StringBuffer t3_sb_0 = new StringBuffer( phylogenies_0[ 2 ].toPhyloXML( 0 ) );
1941 final Phylogeny[] phylogenies_1_0 = factory.create( t3_sb_0, xml_parser );
1942 final StringBuffer t3_sb = new StringBuffer( phylogenies_1_0[ 0 ].toPhyloXML( 0 ) );
1943 final Phylogeny[] phylogenies_1 = factory.create( t3_sb, xml_parser );
1944 if ( phylogenies_1.length != 1 ) {
1947 final Phylogeny t3_rt = phylogenies_1[ 0 ];
1948 if ( !t3_rt.getName().equals( "t3" ) ) {
1951 if ( t3_rt.getNumberOfExternalNodes() != 4 ) {
1954 if ( !t3_rt.getIdentifier().getValue().equals( "1-1" ) ) {
1957 if ( !t3_rt.getIdentifier().getProvider().equals( "treebank" ) ) {
1960 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getType().equals( "protein" ) ) {
1963 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getName()
1964 .equals( "Apoptosis facilitator Bcl-2-like 14 protein" ) ) {
1967 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getSymbol().equals( "BCL2L14" ) ) {
1970 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getValue().equals( "Q9BZR8" ) ) {
1973 if ( !t3_rt.getNode( "root node" ).getNodeData().getSequence().getAccession().getSource()
1974 .equals( "UniProtKB" ) ) {
1977 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
1978 .equals( "apoptosis" ) ) {
1981 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getRef()
1982 .equals( "GO:0006915" ) ) {
1985 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getSource()
1986 .equals( "UniProtKB" ) ) {
1989 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getEvidence()
1990 .equals( "experimental" ) ) {
1993 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getType()
1994 .equals( "function" ) ) {
1997 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
1998 .getValue() != 1 ) {
2001 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getConfidence()
2002 .getType().equals( "ml" ) ) {
2005 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getDesc()
2006 .equals( "apoptosis" ) ) {
2009 if ( ( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2010 .getProperty( "AFFY:expression" ).getAppliesTo() != AppliesTo.ANNOTATION ) {
2013 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2014 .getProperty( "AFFY:expression" ).getDataType().equals( "xsd:double" ) ) {
2017 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2018 .getProperty( "AFFY:expression" ).getRef().equals( "AFFY:expression" ) ) {
2021 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2022 .getProperty( "AFFY:expression" ).getUnit().equals( "AFFY:x" ) ) {
2025 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2026 .getProperty( "AFFY:expression" ).getValue().equals( "0.2" ) ) {
2029 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 2 ) ).getProperties()
2030 .getProperty( "MED:disease" ).getValue().equals( "lymphoma" ) ) {
2033 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 1 ) ).getRef()
2034 .equals( "GO:0005829" ) ) {
2037 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getAnnotation( 0 ) ).getDesc()
2038 .equals( "intracellular organelle" ) ) {
2041 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getType().equals( "source" ) ) ) {
2044 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getUri( 0 ).getDescription()
2045 .equals( "UniProt link" ) ) ) {
2048 if ( !( t3_rt.getNode( "root node" ).getNodeData().getSequence().getLocation().equals( "12p13-p12" ) ) ) {
2051 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDoi().equals( "10.1038/387489a0" ) ) ) {
2054 if ( !( t3_rt.getNode( "root node" ).getNodeData().getReference().getDescription()
2055 .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." ) ) ) {
2058 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getTaxonomyCode().equals( "ECDYS" ) ) {
2061 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getScientificName().equals( "ecdysozoa" ) ) {
2064 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getCommonName().equals( "molting animals" ) ) {
2067 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
2070 if ( !t3_rt.getNode( "root node" ).getNodeData().getTaxonomy().getIdentifier().getProvider()
2071 .equals( "ncbi" ) ) {
2074 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getTotalLength() != 124 ) {
2077 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2078 .getName().equals( "B" ) ) {
2081 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2082 .getFrom() != 21 ) {
2085 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getTo() != 44 ) {
2088 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2089 .getLength() != 24 ) {
2092 if ( t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 )
2093 .getConfidence() != 2144 ) {
2096 if ( !t3_rt.getNode( "node bc" ).getNodeData().getSequence().getDomainArchitecture().getDomain( 0 ).getId()
2097 .equals( "pfam" ) ) {
2100 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 3 ) {
2103 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2106 if ( t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 1 ) {
2109 if ( !t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().getType().equals( "domains" ) ) {
2112 final Taxonomy taxbb = t3_rt.getNode( "node bb" ).getNodeData().getTaxonomy();
2113 if ( !taxbb.getAuthority().equals( "Stephenson, 1935" ) ) {
2116 if ( !taxbb.getCommonName().equals( "starlet sea anemone" ) ) {
2119 if ( !taxbb.getIdentifier().getProvider().equals( "EOL" ) ) {
2122 if ( !taxbb.getIdentifier().getValue().equals( "704294" ) ) {
2125 if ( !taxbb.getTaxonomyCode().equals( "NEMVE" ) ) {
2128 if ( !taxbb.getScientificName().equals( "Nematostella vectensis" ) ) {
2131 if ( taxbb.getSynonyms().size() != 2 ) {
2134 if ( !taxbb.getSynonyms().contains( "Nematostella vectensis Stephenson1935" ) ) {
2137 if ( !taxbb.getSynonyms().contains( "See Anemone" ) ) {
2140 if ( !taxbb.getUri( 0 ).getDescription().equals( "EOL" ) ) {
2143 if ( !taxbb.getUri( 0 ).getType().equals( "linkout" ) ) {
2146 if ( !taxbb.getUri( 0 ).getValue().toString().equals( "http://www.eol.org/pages/704294" ) ) {
2149 if ( ( ( BinaryCharacters ) t3_rt.getNode( "node bb" ).getNodeData().getBinaryCharacters().copy() )
2150 .getLostCount() != BinaryCharacters.COUNT_DEFAULT ) {
2153 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCount() != 1 ) {
2156 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getGainedCharacters().size() != 1 ) {
2159 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCount() != 3 ) {
2162 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getLostCharacters().size() != 3 ) {
2165 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCount() != 2 ) {
2168 if ( t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getPresentCharacters().size() != 2 ) {
2171 if ( !t3_rt.getNode( "node b" ).getNodeData().getBinaryCharacters().getType().equals( "characters" ) ) {
2175 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getDesc().equals( "Silurian" ) ) {
2178 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getValue().toPlainString()
2179 .equalsIgnoreCase( "435" ) ) {
2182 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMin().toPlainString().equalsIgnoreCase( "416" ) ) {
2185 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getMax().toPlainString()
2186 .equalsIgnoreCase( "443.7" ) ) {
2189 if ( !t3_rt.getNode( "node ba" ).getNodeData().getDate().getUnit().equals( "mya" ) ) {
2192 if ( !t3_rt.getNode( "node bb" ).getNodeData().getDate().getDesc().equals( "Triassic" ) ) {
2195 if ( !t3_rt.getNode( "node bc" ).getNodeData().getDate().getValue().toPlainString()
2196 .equalsIgnoreCase( "433" ) ) {
2199 final SortedSet<Accession> x = t3_rt.getNode( "root node" ).getNodeData().getSequence()
2200 .getCrossReferences();
2201 if ( x.size() != 4 ) {
2205 for( final Accession acc : x ) {
2207 if ( !acc.getSource().equals( "KEGG" ) ) {
2210 if ( !acc.getValue().equals( "hsa:596" ) ) {
2217 catch ( final Exception e ) {
2218 e.printStackTrace( System.out );
2224 private static boolean testBasicPhyloXMLparsingValidating() {
2226 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2227 PhyloXmlParser xml_parser = null;
2229 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
2231 catch ( final Exception e ) {
2232 // Do nothing -- means were not running from jar.
2234 if ( xml_parser == null ) {
2235 xml_parser = PhyloXmlParser.createPhyloXmlParser();
2236 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
2237 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
2240 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
2243 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml",
2245 if ( xml_parser.getErrorCount() > 0 ) {
2246 System.out.println( xml_parser.getErrorMessages().toString() );
2249 if ( phylogenies_0.length != 4 ) {
2252 final Phylogeny t1 = phylogenies_0[ 0 ];
2253 final Phylogeny t2 = phylogenies_0[ 1 ];
2254 final Phylogeny t3 = phylogenies_0[ 2 ];
2255 final Phylogeny t4 = phylogenies_0[ 3 ];
2256 if ( !t1.getName().equals( "t1" ) ) {
2259 if ( !t2.getName().equals( "t2" ) ) {
2262 if ( !t3.getName().equals( "t3" ) ) {
2265 if ( !t4.getName().equals( "t4" ) ) {
2268 if ( t1.getNumberOfExternalNodes() != 1 ) {
2271 if ( t2.getNumberOfExternalNodes() != 2 ) {
2274 if ( t3.getNumberOfExternalNodes() != 4 ) {
2277 final String x2 = Test.PATH_TO_TEST_DATA + "phyloxml_test_t1.xml";
2278 final Phylogeny[] phylogenies_1 = factory.create( x2, xml_parser );
2279 if ( xml_parser.getErrorCount() > 0 ) {
2280 System.out.println( "errors:" );
2281 System.out.println( xml_parser.getErrorMessages().toString() );
2284 if ( phylogenies_1.length != 4 ) {
2287 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t3.xml",
2289 if ( xml_parser.getErrorCount() > 0 ) {
2290 System.out.println( "errors:" );
2291 System.out.println( xml_parser.getErrorMessages().toString() );
2294 if ( phylogenies_2.length != 1 ) {
2297 if ( phylogenies_2[ 0 ].getNumberOfExternalNodes() != 2 ) {
2300 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_test_t4.xml",
2302 if ( xml_parser.getErrorCount() > 0 ) {
2303 System.out.println( xml_parser.getErrorMessages().toString() );
2306 if ( phylogenies_3.length != 2 ) {
2309 final Phylogeny a = phylogenies_3[ 0 ];
2310 if ( !a.getName().equals( "tree 4" ) ) {
2313 if ( a.getNumberOfExternalNodes() != 3 ) {
2316 if ( !a.getNode( "node b1" ).getNodeData().getSequence().getName().equals( "b1 gene" ) ) {
2319 if ( !a.getNode( "node b1" ).getNodeData().getTaxonomy().getCommonName().equals( "b1 species" ) ) {
2322 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "special_characters.xml",
2324 if ( xml_parser.getErrorCount() > 0 ) {
2325 System.out.println( xml_parser.getErrorMessages().toString() );
2328 if ( phylogenies_4.length != 1 ) {
2331 final Phylogeny s = phylogenies_4[ 0 ];
2332 if ( s.getNumberOfExternalNodes() != 6 ) {
2335 s.getNode( "first" );
2337 s.getNode( "\"<a'b&c'd\">\"" );
2338 s.getNode( "'''\"" );
2339 s.getNode( "\"\"\"" );
2340 s.getNode( "dick & doof" );
2342 catch ( final Exception e ) {
2343 e.printStackTrace( System.out );
2349 private static boolean testBasicProtein() {
2351 final BasicProtein p0 = new BasicProtein( "p0", "owl", 0 );
2352 final Domain a = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2353 final Domain b = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2354 final Domain c = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2355 final Domain d = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2356 final Domain e = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2357 final Domain x = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2358 final Domain y = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2359 p0.addProteinDomain( y );
2360 p0.addProteinDomain( e );
2361 p0.addProteinDomain( b );
2362 p0.addProteinDomain( c );
2363 p0.addProteinDomain( d );
2364 p0.addProteinDomain( a );
2365 p0.addProteinDomain( x );
2366 if ( !p0.toDomainArchitectureString( "~" ).equals( "a~b~c~d~e~x~y" ) ) {
2369 if ( !p0.toDomainArchitectureString( "~", 3, "=" ).equals( "a~b~c~d~e~x~y" ) ) {
2373 final BasicProtein aa0 = new BasicProtein( "aa", "owl", 0 );
2374 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2375 aa0.addProteinDomain( a1 );
2376 if ( !aa0.toDomainArchitectureString( "~" ).equals( "a" ) ) {
2379 if ( !aa0.toDomainArchitectureString( "~", 3, "" ).equals( "a" ) ) {
2383 final BasicProtein aa1 = new BasicProtein( "aa", "owl", 0 );
2384 final Domain a11 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2385 final Domain a12 = new BasicDomain( "a", 2, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2386 aa1.addProteinDomain( a11 );
2387 aa1.addProteinDomain( a12 );
2388 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a" ) ) {
2391 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "a~a" ) ) {
2394 aa1.addProteinDomain( new BasicDomain( "a", 20, 30, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2395 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a" ) ) {
2398 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2401 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "a~a~a" ) ) {
2404 aa1.addProteinDomain( new BasicDomain( "a", 30, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2405 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a" ) ) {
2408 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa" ) ) {
2411 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa" ) ) {
2414 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a" ) ) {
2417 aa1.addProteinDomain( new BasicDomain( "b", 32, 40, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2418 if ( !aa1.toDomainArchitectureString( "~" ).equals( "a~a~a~a~b" ) ) {
2421 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "aaa~b" ) ) {
2424 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "aaa~b" ) ) {
2427 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "a~a~a~a~b" ) ) {
2430 aa1.addProteinDomain( new BasicDomain( "c", 1, 2, ( short ) 1, ( short ) 5, 0.1, -12 ) );
2431 if ( !aa1.toDomainArchitectureString( "~" ).equals( "c~a~a~a~a~b" ) ) {
2434 if ( !aa1.toDomainArchitectureString( "~", 3, "" ).equals( "c~aaa~b" ) ) {
2437 if ( !aa1.toDomainArchitectureString( "~", 4, "" ).equals( "c~aaa~b" ) ) {
2440 if ( !aa1.toDomainArchitectureString( "~", 5, "" ).equals( "c~a~a~a~a~b" ) ) {
2444 final BasicProtein p00 = new BasicProtein( "p0", "owl", 0 );
2445 final Domain a0 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 5, 0.1, -12 );
2446 final Domain b0 = new BasicDomain( "b", 11, 20, ( short ) 1, ( short ) 5, 0.1, -12 );
2447 final Domain c0 = new BasicDomain( "c", 9, 23, ( short ) 1, ( short ) 5, 0.1, -12 );
2448 final Domain d0 = new BasicDomain( "d", 15, 30, ( short ) 1, ( short ) 5, 0.1, -12 );
2449 final Domain e0 = new BasicDomain( "e", 60, 70, ( short ) 1, ( short ) 5, 0.1, -12 );
2450 final Domain e1 = new BasicDomain( "e", 61, 71, ( short ) 1, ( short ) 5, 0.1, -12 );
2451 final Domain e2 = new BasicDomain( "e", 62, 72, ( short ) 1, ( short ) 5, 0.1, -12 );
2452 final Domain e3 = new BasicDomain( "e", 63, 73, ( short ) 1, ( short ) 5, 0.1, -12 );
2453 final Domain e4 = new BasicDomain( "e", 64, 74, ( short ) 1, ( short ) 5, 0.1, -12 );
2454 final Domain e5 = new BasicDomain( "e", 65, 75, ( short ) 1, ( short ) 5, 0.1, -12 );
2455 final Domain x0 = new BasicDomain( "x", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2456 final Domain y0 = new BasicDomain( "y", 100, 110, ( short ) 1, ( short ) 5, 0.1, -12 );
2457 final Domain y1 = new BasicDomain( "y", 120, 130, ( short ) 1, ( short ) 5, 0.1, -12 );
2458 final Domain y2 = new BasicDomain( "y", 140, 150, ( short ) 1, ( short ) 5, 0.1, -12 );
2459 final Domain y3 = new BasicDomain( "y", 160, 170, ( short ) 1, ( short ) 5, 0.1, -12 );
2460 final Domain z0 = new BasicDomain( "z", 200, 210, ( short ) 1, ( short ) 5, 0.1, -12 );
2461 final Domain z1 = new BasicDomain( "z", 300, 310, ( short ) 1, ( short ) 5, 0.1, -12 );
2462 final Domain z2 = new BasicDomain( "z", 400, 410, ( short ) 1, ( short ) 5, 0.1, -12 );
2463 final Domain zz0 = new BasicDomain( "Z", 500, 510, ( short ) 1, ( short ) 5, 0.1, -12 );
2464 final Domain zz1 = new BasicDomain( "Z", 600, 610, ( short ) 1, ( short ) 5, 0.1, -12 );
2465 p00.addProteinDomain( y0 );
2466 p00.addProteinDomain( e0 );
2467 p00.addProteinDomain( b0 );
2468 p00.addProteinDomain( c0 );
2469 p00.addProteinDomain( d0 );
2470 p00.addProteinDomain( a0 );
2471 p00.addProteinDomain( x0 );
2472 p00.addProteinDomain( y1 );
2473 p00.addProteinDomain( y2 );
2474 p00.addProteinDomain( y3 );
2475 p00.addProteinDomain( e1 );
2476 p00.addProteinDomain( e2 );
2477 p00.addProteinDomain( e3 );
2478 p00.addProteinDomain( e4 );
2479 p00.addProteinDomain( e5 );
2480 p00.addProteinDomain( z0 );
2481 p00.addProteinDomain( z1 );
2482 p00.addProteinDomain( z2 );
2483 p00.addProteinDomain( zz0 );
2484 p00.addProteinDomain( zz1 );
2485 if ( !p00.toDomainArchitectureString( "~", 3, "" ).equals( "a~b~c~d~eee~x~yyy~zzz~Z~Z" ) ) {
2488 if ( !p00.toDomainArchitectureString( "~", 4, "" ).equals( "a~b~c~d~eee~x~yyy~z~z~z~Z~Z" ) ) {
2491 if ( !p00.toDomainArchitectureString( "~", 5, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2494 if ( !p00.toDomainArchitectureString( "~", 6, "" ).equals( "a~b~c~d~eee~x~y~y~y~y~z~z~z~Z~Z" ) ) {
2497 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" ) ) {
2500 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
2501 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2502 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
2503 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
2504 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
2505 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
2506 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
2507 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
2508 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
2509 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
2510 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
2511 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
2512 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
2513 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
2514 p.addProteinDomain( B15 );
2515 p.addProteinDomain( C50 );
2516 p.addProteinDomain( A60 );
2517 p.addProteinDomain( A30 );
2518 p.addProteinDomain( C70 );
2519 p.addProteinDomain( B35 );
2520 p.addProteinDomain( B40 );
2521 p.addProteinDomain( A0 );
2522 p.addProteinDomain( A10 );
2523 p.addProteinDomain( A20 );
2524 p.addProteinDomain( B25 );
2525 p.addProteinDomain( D80 );
2526 List<String> domains_ids = new ArrayList<String>();
2527 domains_ids.add( "A" );
2528 domains_ids.add( "B" );
2529 domains_ids.add( "C" );
2530 if ( !p.contains( domains_ids, false ) ) {
2533 if ( !p.contains( domains_ids, true ) ) {
2536 domains_ids.add( "X" );
2537 if ( p.contains( domains_ids, false ) ) {
2540 if ( p.contains( domains_ids, true ) ) {
2543 domains_ids = new ArrayList<String>();
2544 domains_ids.add( "A" );
2545 domains_ids.add( "C" );
2546 domains_ids.add( "D" );
2547 if ( !p.contains( domains_ids, false ) ) {
2550 if ( !p.contains( domains_ids, true ) ) {
2553 domains_ids = new ArrayList<String>();
2554 domains_ids.add( "A" );
2555 domains_ids.add( "D" );
2556 domains_ids.add( "C" );
2557 if ( !p.contains( domains_ids, false ) ) {
2560 if ( p.contains( domains_ids, true ) ) {
2563 domains_ids = new ArrayList<String>();
2564 domains_ids.add( "A" );
2565 domains_ids.add( "A" );
2566 domains_ids.add( "B" );
2567 if ( !p.contains( domains_ids, false ) ) {
2570 if ( !p.contains( domains_ids, true ) ) {
2573 domains_ids = new ArrayList<String>();
2574 domains_ids.add( "A" );
2575 domains_ids.add( "A" );
2576 domains_ids.add( "A" );
2577 domains_ids.add( "B" );
2578 domains_ids.add( "B" );
2579 if ( !p.contains( domains_ids, false ) ) {
2582 if ( !p.contains( domains_ids, true ) ) {
2585 domains_ids = new ArrayList<String>();
2586 domains_ids.add( "A" );
2587 domains_ids.add( "A" );
2588 domains_ids.add( "B" );
2589 domains_ids.add( "A" );
2590 domains_ids.add( "B" );
2591 domains_ids.add( "B" );
2592 domains_ids.add( "A" );
2593 domains_ids.add( "B" );
2594 domains_ids.add( "C" );
2595 domains_ids.add( "A" );
2596 domains_ids.add( "C" );
2597 domains_ids.add( "D" );
2598 if ( !p.contains( domains_ids, false ) ) {
2601 if ( p.contains( domains_ids, true ) ) {
2605 catch ( final Exception e ) {
2606 e.printStackTrace( System.out );
2612 private static boolean testBasicTable() {
2614 final BasicTable<String> t0 = new BasicTable<String>();
2615 if ( t0.getNumberOfColumns() != 0 ) {
2618 if ( t0.getNumberOfRows() != 0 ) {
2621 t0.setValue( 3, 2, "23" );
2622 t0.setValue( 10, 1, "error" );
2623 t0.setValue( 10, 1, "110" );
2624 t0.setValue( 9, 1, "19" );
2625 t0.setValue( 1, 10, "101" );
2626 t0.setValue( 10, 10, "1010" );
2627 t0.setValue( 100, 10, "10100" );
2628 t0.setValue( 0, 0, "00" );
2629 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
2632 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
2635 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
2638 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
2641 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
2644 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
2647 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
2650 if ( t0.getNumberOfColumns() != 101 ) {
2653 if ( t0.getNumberOfRows() != 11 ) {
2656 if ( t0.getValueAsString( 49, 4 ) != null ) {
2659 final String l = ForesterUtil.getLineSeparator();
2660 final StringBuffer source = new StringBuffer();
2661 source.append( "" + l );
2662 source.append( "# 1 1 1 1 1 1 1 1" + l );
2663 source.append( " 00 01 02 03" + l );
2664 source.append( " 10 11 12 13 " + l );
2665 source.append( "20 21 22 23 " + l );
2666 source.append( " 30 31 32 33" + l );
2667 source.append( "40 41 42 43" + l );
2668 source.append( " # 1 1 1 1 1 " + l );
2669 source.append( "50 51 52 53 54" + l );
2670 final BasicTable<String> t1 = BasicTableParser.parse( source.toString(), ' ' );
2671 if ( t1.getNumberOfColumns() != 5 ) {
2674 if ( t1.getNumberOfRows() != 6 ) {
2677 if ( !t1.getValueAsString( 0, 0 ).equals( "00" ) ) {
2680 if ( !t1.getValueAsString( 1, 0 ).equals( "01" ) ) {
2683 if ( !t1.getValueAsString( 3, 0 ).equals( "03" ) ) {
2686 if ( !t1.getValueAsString( 4, 5 ).equals( "54" ) ) {
2689 final StringBuffer source1 = new StringBuffer();
2690 source1.append( "" + l );
2691 source1.append( "# 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2692 source1.append( " 00; 01 ;02;03" + l );
2693 source1.append( " 10; 11; 12; 13 " + l );
2694 source1.append( "20; 21; 22; 23 " + l );
2695 source1.append( " 30; 31; 32; 33" + l );
2696 source1.append( "40;41;42;43" + l );
2697 source1.append( " # 1 1 1 1 1 " + l );
2698 source1.append( ";;;50 ; ;52; 53;;54 " + l );
2699 final BasicTable<String> t2 = BasicTableParser.parse( source1.toString(), ';' );
2700 if ( t2.getNumberOfColumns() != 5 ) {
2703 if ( t2.getNumberOfRows() != 6 ) {
2706 if ( !t2.getValueAsString( 0, 0 ).equals( "00" ) ) {
2709 if ( !t2.getValueAsString( 1, 0 ).equals( "01" ) ) {
2712 if ( !t2.getValueAsString( 3, 0 ).equals( "03" ) ) {
2715 if ( !t2.getValueAsString( 3, 3 ).equals( "33" ) ) {
2718 if ( !t2.getValueAsString( 3, 5 ).equals( "53" ) ) {
2721 if ( !t2.getValueAsString( 1, 5 ).equals( "" ) ) {
2724 final StringBuffer source2 = new StringBuffer();
2725 source2.append( "" + l );
2726 source2.append( "comment: 1; 1; 1; 1 ;1 ;1; 1 ;1;" + l );
2727 source2.append( " 00; 01 ;02;03" + l );
2728 source2.append( " 10; 11; 12; 13 " + l );
2729 source2.append( "20; 21; 22; 23 " + l );
2730 source2.append( " " + l );
2731 source2.append( " 30; 31; 32; 33" + l );
2732 source2.append( "40;41;42;43" + l );
2733 source2.append( " comment: 1 1 1 1 1 " + l );
2734 source2.append( ";;;50 ; 52; 53;;54 " + l );
2735 final List<BasicTable<String>> tl = BasicTableParser.parse( source2.toString(),
2741 if ( tl.size() != 2 ) {
2744 final BasicTable<String> t3 = tl.get( 0 );
2745 final BasicTable<String> t4 = tl.get( 1 );
2746 if ( t3.getNumberOfColumns() != 4 ) {
2749 if ( t3.getNumberOfRows() != 3 ) {
2752 if ( t4.getNumberOfColumns() != 4 ) {
2755 if ( t4.getNumberOfRows() != 3 ) {
2758 if ( !t3.getValueAsString( 0, 0 ).equals( "00" ) ) {
2761 if ( !t4.getValueAsString( 0, 0 ).equals( "30" ) ) {
2765 catch ( final Exception e ) {
2766 e.printStackTrace( System.out );
2772 private static boolean testBasicTolXMLparsing() {
2774 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2775 final TolParser parser = new TolParser();
2776 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2484.tol", parser );
2777 if ( parser.getErrorCount() > 0 ) {
2778 System.out.println( parser.getErrorMessages().toString() );
2781 if ( phylogenies_0.length != 1 ) {
2784 final Phylogeny t1 = phylogenies_0[ 0 ];
2785 if ( t1.getNumberOfExternalNodes() != 5 ) {
2788 if ( !t1.isRooted() ) {
2791 if ( !t1.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Mesozoa" ) ) {
2794 if ( !t1.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2484" ) ) {
2797 if ( !t1.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Rhombozoa" ) ) {
2800 if ( t1.getRoot().getChildNode( 0 ).getNumberOfDescendants() != 3 ) {
2803 final Phylogeny[] phylogenies_1 = factory.create( Test.PATH_TO_TEST_DATA + "tol_2.tol", parser );
2804 if ( parser.getErrorCount() > 0 ) {
2805 System.out.println( parser.getErrorMessages().toString() );
2808 if ( phylogenies_1.length != 1 ) {
2811 final Phylogeny t2 = phylogenies_1[ 0 ];
2812 if ( t2.getNumberOfExternalNodes() != 664 ) {
2815 if ( !t2.isRooted() ) {
2818 if ( !t2.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Eubacteria" ) ) {
2821 if ( !t2.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "2" ) ) {
2824 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2827 if ( t2.getRoot().getNumberOfDescendants() != 24 ) {
2830 if ( !t2.getRoot().getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName().equals( "Aquificae" ) ) {
2833 if ( !t2.getRoot().getChildNode( 0 ).getChildNode( 0 ).getNodeData().getTaxonomy().getScientificName()
2834 .equals( "Aquifex" ) ) {
2837 final Phylogeny[] phylogenies_2 = factory.create( Test.PATH_TO_TEST_DATA + "tol_5.tol", parser );
2838 if ( parser.getErrorCount() > 0 ) {
2839 System.out.println( parser.getErrorMessages().toString() );
2842 if ( phylogenies_2.length != 1 ) {
2845 final Phylogeny t3 = phylogenies_2[ 0 ];
2846 if ( t3.getNumberOfExternalNodes() != 184 ) {
2849 if ( !t3.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Viruses" ) ) {
2852 if ( !t3.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "5" ) ) {
2855 if ( t3.getRoot().getNumberOfDescendants() != 6 ) {
2858 final Phylogeny[] phylogenies_3 = factory.create( Test.PATH_TO_TEST_DATA + "tol_4567.tol", parser );
2859 if ( parser.getErrorCount() > 0 ) {
2860 System.out.println( parser.getErrorMessages().toString() );
2863 if ( phylogenies_3.length != 1 ) {
2866 final Phylogeny t4 = phylogenies_3[ 0 ];
2867 if ( t4.getNumberOfExternalNodes() != 1 ) {
2870 if ( !t4.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Marpissa decorata" ) ) {
2873 if ( !t4.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "4567" ) ) {
2876 if ( t4.getRoot().getNumberOfDescendants() != 0 ) {
2879 final Phylogeny[] phylogenies_4 = factory.create( Test.PATH_TO_TEST_DATA + "tol_16299.tol", parser );
2880 if ( parser.getErrorCount() > 0 ) {
2881 System.out.println( parser.getErrorMessages().toString() );
2884 if ( phylogenies_4.length != 1 ) {
2887 final Phylogeny t5 = phylogenies_4[ 0 ];
2888 if ( t5.getNumberOfExternalNodes() != 13 ) {
2891 if ( !t5.getRoot().getNodeData().getTaxonomy().getScientificName().equals( "Hominidae" ) ) {
2894 if ( !t5.getRoot().getNodeData().getTaxonomy().getIdentifier().getValue().equals( "16299" ) ) {
2897 if ( t5.getRoot().getNumberOfDescendants() != 2 ) {
2901 catch ( final Exception e ) {
2902 e.printStackTrace( System.out );
2908 private static boolean testBasicTreeMethods() {
2910 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2911 final Phylogeny t2 = factory.create( "((A:1,B:2)AB:1,(C:3,D:5)CD:3)ABCD:0.5", new NHXParser() )[ 0 ];
2912 if ( t2.getNumberOfExternalNodes() != 4 ) {
2915 if ( t2.getHeight() != 8.5 ) {
2918 if ( !t2.isCompletelyBinary() ) {
2921 if ( t2.isEmpty() ) {
2924 final Phylogeny t3 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3)", new NHXParser() )[ 0 ];
2925 if ( t3.getNumberOfExternalNodes() != 5 ) {
2928 if ( t3.getHeight() != 11 ) {
2931 if ( t3.isCompletelyBinary() ) {
2934 final PhylogenyNode n = t3.getNode( "ABC" );
2935 final Phylogeny t4 = factory.create( "((A:1,B:2,C:10)ABC:1,(D:3,E:5)DE:3,(F,G,H,I))", new NHXParser() )[ 0 ];
2936 if ( t4.getNumberOfExternalNodes() != 9 ) {
2939 if ( t4.getHeight() != 11 ) {
2942 if ( t4.isCompletelyBinary() ) {
2945 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)" );
2946 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
2947 if ( t5.getNumberOfExternalNodes() != 8 ) {
2950 if ( t5.getHeight() != 15 ) {
2953 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)" );
2954 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
2955 if ( t6.getHeight() != 15 ) {
2958 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)" );
2959 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
2960 if ( t7.getHeight() != 15 ) {
2963 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)" );
2964 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
2965 if ( t8.getNumberOfExternalNodes() != 10 ) {
2968 if ( t8.getHeight() != 15 ) {
2971 final char[] a9 = new char[] { 'a' };
2972 final Phylogeny t9 = factory.create( a9, new NHXParser() )[ 0 ];
2973 if ( t9.getHeight() != 0 ) {
2976 final char[] a10 = new char[] { 'a', ':', '6' };
2977 final Phylogeny t10 = factory.create( a10, new NHXParser() )[ 0 ];
2978 if ( t10.getHeight() != 6 ) {
2982 catch ( final Exception e ) {
2983 e.printStackTrace( System.out );
2989 private static boolean testConfidenceAssessor() {
2991 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
2992 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
2993 final Phylogeny[] ev0 = factory
2994 .create( "((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);((((A,B),C),D),E);",
2996 ConfidenceAssessor.evaluate( "bootstrap", ev0, t0, false, 1, 0, 2 );
2997 if ( !isEqual( t0.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3000 if ( !isEqual( t0.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 3 ) ) {
3003 final Phylogeny t1 = factory.create( "((((A,B)ab[&&NHX:B=50],C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3004 final Phylogeny[] ev1 = factory
3005 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3007 ConfidenceAssessor.evaluate( "bootstrap", ev1, t1, false, 1 );
3008 if ( !isEqual( t1.getNode( "ab" ).getBranchData().getConfidence( 1 ).getValue(), 7 ) ) {
3011 if ( !isEqual( t1.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3014 final Phylogeny t_b = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3015 final Phylogeny[] ev_b = factory
3016 .create( "((A,C),X);((A,X),C);(A,C);((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3018 ConfidenceAssessor.evaluate( "bootstrap", ev_b, t_b, false, 1 );
3019 if ( !isEqual( t_b.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 4 ) ) {
3022 if ( !isEqual( t_b.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3026 final Phylogeny t1x = factory.create( "((((A,B)ab,C)abc,D)abcd,E)abcde", new NHXParser() )[ 0 ];
3027 final Phylogeny[] ev1x = factory
3028 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));",
3030 ConfidenceAssessor.evaluate( "bootstrap", ev1x, t1x, true, 1 );
3031 if ( !isEqual( t1x.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3034 if ( !isEqual( t1x.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 7 ) ) {
3037 final Phylogeny t_bx = factory.create( "((((A,C)ac,D)acd,E)acde,B)abcde", new NHXParser() )[ 0 ];
3038 final Phylogeny[] ev_bx = factory
3039 .create( "((((A,B),C),D),E);((A,B),((E,D),C));(((A,B),C),(E,D));(A,(((E,D),C),B));(B,(A,((E,D),C)));(C,((E,D),(A,B)));(D,(E,((A,B),C)));((((A,C)ac,D)acd,E)acde,B)abcd",
3041 ConfidenceAssessor.evaluate( "bootstrap", ev_bx, t_bx, true, 1 );
3042 if ( !isEqual( t_bx.getNode( "ac" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3045 if ( !isEqual( t_bx.getNode( "acd" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3049 final Phylogeny[] t2 = factory
3050 .create( "((((a,b),c),d),e);(((a,b),c),(d,e));(((((a,b),c),d),e),f);((((a,b),c),(d,e)),f);(((a,b),c),d,e);((a,b,c),d,e);",
3052 final Phylogeny[] ev2 = factory
3053 .create( "((((a,b),c),d),e);((((a,b),c),d),e);((((a,b),e),d),c);((((a,b),e),d),c);(((a,b),(c,d)),e);((a,b),x);((a,b),(x,y));(a,b);(a,e);(a,b,c);",
3055 for( final Phylogeny target : t2 ) {
3056 ConfidenceAssessor.evaluate( "bootstrap", ev2, target, false, 1 );
3059 final Phylogeny t4 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,G)abcdefg",
3060 new NHXParser() )[ 0 ];
3061 final Phylogeny[] ev4 = factory.create( "(((A,B),C),(X,Y));((F,G),((A,B,C),(D,E)))", new NHXParser() );
3062 ConfidenceAssessor.evaluate( "bootstrap", ev4, t4, false, 1 );
3063 if ( !isEqual( t4.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3066 if ( !isEqual( t4.getNode( "abc" ).getBranchData().getConfidence( 0 ).getValue(), 2 ) ) {
3069 if ( !isEqual( t4.getNode( "abcde" ).getBranchData().getConfidence( 0 ).getValue(), 1 ) ) {
3073 catch ( final Exception e ) {
3074 e.printStackTrace();
3080 private static boolean testCopyOfNodeData() {
3082 final PhylogenyNode n1 = PhylogenyNode
3083 .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]" );
3084 final PhylogenyNode n2 = n1.copyNodeData();
3085 if ( !n1.toNewHampshireX().equals( n2.toNewHampshireX() ) ) {
3089 catch ( final Exception e ) {
3090 e.printStackTrace();
3096 private static boolean testCreateBalancedPhylogeny() {
3098 final Phylogeny p0 = DevelopmentTools.createBalancedPhylogeny( 6, 5 );
3099 if ( p0.getRoot().getNumberOfDescendants() != 5 ) {
3102 if ( p0.getNumberOfExternalNodes() != 15625 ) {
3105 final Phylogeny p1 = DevelopmentTools.createBalancedPhylogeny( 2, 10 );
3106 if ( p1.getRoot().getNumberOfDescendants() != 10 ) {
3109 if ( p1.getNumberOfExternalNodes() != 100 ) {
3113 catch ( final Exception e ) {
3114 e.printStackTrace();
3120 private static boolean testCreateUriForSeqWeb() {
3122 final PhylogenyNode n = new PhylogenyNode();
3123 n.setName( "tr|B3RJ64" );
3124 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B3RJ64" ) ) {
3127 n.setName( "B0LM41_HUMAN" );
3128 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "B0LM41_HUMAN" ) ) {
3131 n.setName( "NP_001025424" );
3132 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "NP_001025424" ) ) {
3135 n.setName( "_NM_001030253-" );
3136 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "NM_001030253" ) ) {
3139 n.setName( "XM_002122186" );
3140 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_NUCCORE + "XM_002122186" ) ) {
3143 n.setName( "dgh_AAA34956_gdg" );
3144 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3147 n.setName( "AAA34956" );
3148 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_PROTEIN + "AAA34956" ) ) {
3151 n.setName( "GI:394892" );
3152 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3153 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3156 n.setName( "gi_394892" );
3157 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3158 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3161 n.setName( "gi6335_gi_394892_56635_Gi_43" );
3162 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.NCBI_GI + "394892" ) ) {
3163 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3166 n.setName( "P12345" );
3167 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3168 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3171 n.setName( "gi_fdgjmn-3jk5-243 mnefmn fg023-0 P12345 4395jtmnsrg02345m1ggi92450jrg890j4t0j240" );
3172 if ( !TreePanelUtil.createUriForSeqWeb( n, null, null ).equals( ForesterUtil.UNIPROT_KB + "P12345" ) ) {
3173 System.out.println( TreePanelUtil.createUriForSeqWeb( n, null, null ) );
3177 catch ( final Exception e ) {
3178 e.printStackTrace( System.out );
3184 private static boolean testDataObjects() {
3186 final Confidence s0 = new Confidence();
3187 final Confidence s1 = new Confidence();
3188 if ( !s0.isEqual( s1 ) ) {
3191 final Confidence s2 = new Confidence( 0.23, "bootstrap" );
3192 final Confidence s3 = new Confidence( 0.23, "bootstrap" );
3193 if ( s2.isEqual( s1 ) ) {
3196 if ( !s2.isEqual( s3 ) ) {
3199 final Confidence s4 = ( Confidence ) s3.copy();
3200 if ( !s4.isEqual( s3 ) ) {
3207 final Taxonomy t1 = new Taxonomy();
3208 final Taxonomy t2 = new Taxonomy();
3209 final Taxonomy t3 = new Taxonomy();
3210 final Taxonomy t4 = new Taxonomy();
3211 final Taxonomy t5 = new Taxonomy();
3212 t1.setIdentifier( new Identifier( "ecoli" ) );
3213 t1.setTaxonomyCode( "ECOLI" );
3214 t1.setScientificName( "E. coli" );
3215 t1.setCommonName( "coli" );
3216 final Taxonomy t0 = ( Taxonomy ) t1.copy();
3217 if ( !t1.isEqual( t0 ) ) {
3220 t2.setIdentifier( new Identifier( "ecoli" ) );
3221 t2.setTaxonomyCode( "OTHER" );
3222 t2.setScientificName( "what" );
3223 t2.setCommonName( "something" );
3224 if ( !t1.isEqual( t2 ) ) {
3227 t2.setIdentifier( new Identifier( "nemve" ) );
3228 if ( t1.isEqual( t2 ) ) {
3231 t1.setIdentifier( null );
3232 t3.setTaxonomyCode( "ECOLI" );
3233 t3.setScientificName( "what" );
3234 t3.setCommonName( "something" );
3235 if ( !t1.isEqual( t3 ) ) {
3238 t1.setIdentifier( null );
3239 t1.setTaxonomyCode( "" );
3240 t4.setScientificName( "E. ColI" );
3241 t4.setCommonName( "something" );
3242 if ( !t1.isEqual( t4 ) ) {
3245 t4.setScientificName( "B. subtilis" );
3246 t4.setCommonName( "something" );
3247 if ( t1.isEqual( t4 ) ) {
3250 t1.setIdentifier( null );
3251 t1.setTaxonomyCode( "" );
3252 t1.setScientificName( "" );
3253 t5.setCommonName( "COLI" );
3254 if ( !t1.isEqual( t5 ) ) {
3257 t5.setCommonName( "vibrio" );
3258 if ( t1.isEqual( t5 ) ) {
3263 final Identifier id0 = new Identifier( "123", "pfam" );
3264 final Identifier id1 = ( Identifier ) id0.copy();
3265 if ( !id1.isEqual( id1 ) ) {
3268 if ( !id1.isEqual( id0 ) ) {
3271 if ( !id0.isEqual( id1 ) ) {
3278 final ProteinDomain pd0 = new ProteinDomain( "abc", 100, 200 );
3279 final ProteinDomain pd1 = ( ProteinDomain ) pd0.copy();
3280 if ( !pd1.isEqual( pd1 ) ) {
3283 if ( !pd1.isEqual( pd0 ) ) {
3288 final ProteinDomain pd2 = new ProteinDomain( pd0.getName(), pd0.getFrom(), pd0.getTo(), "id" );
3289 final ProteinDomain pd3 = ( ProteinDomain ) pd2.copy();
3290 if ( !pd3.isEqual( pd3 ) ) {
3293 if ( !pd2.isEqual( pd3 ) ) {
3296 if ( !pd0.isEqual( pd3 ) ) {
3301 // DomainArchitecture
3302 // ------------------
3303 final ProteinDomain d0 = new ProteinDomain( "domain0", 10, 20 );
3304 final ProteinDomain d1 = new ProteinDomain( "domain1", 30, 40 );
3305 final ProteinDomain d2 = new ProteinDomain( "domain2", 50, 60 );
3306 final ProteinDomain d3 = new ProteinDomain( "domain3", 70, 80 );
3307 final ProteinDomain d4 = new ProteinDomain( "domain4", 90, 100 );
3308 final ArrayList<PhylogenyData> domains0 = new ArrayList<PhylogenyData>();
3313 final DomainArchitecture ds0 = new DomainArchitecture( domains0, 110 );
3314 if ( ds0.getNumberOfDomains() != 4 ) {
3317 final DomainArchitecture ds1 = ( DomainArchitecture ) ds0.copy();
3318 if ( !ds0.isEqual( ds0 ) ) {
3321 if ( !ds0.isEqual( ds1 ) ) {
3324 if ( ds1.getNumberOfDomains() != 4 ) {
3327 final ArrayList<PhylogenyData> domains1 = new ArrayList<PhylogenyData>();
3332 final DomainArchitecture ds2 = new DomainArchitecture( domains1, 200 );
3333 if ( ds0.isEqual( ds2 ) ) {
3339 final DomainArchitecture ds3 = new DomainArchitecture( "120>30>40>0.9>b>50>60>0.4>c>10>20>0.1>a" );
3340 if ( !ds3.toNHX().toString().equals( ":DS=120>10>20>0.1>a>30>40>0.9>b>50>60>0.4>c" ) ) {
3341 System.out.println( ds3.toNHX() );
3344 if ( ds3.getNumberOfDomains() != 3 ) {
3349 final Event e1 = new Event( Event.EventType.fusion );
3350 if ( e1.isDuplication() ) {
3353 if ( !e1.isFusion() ) {
3356 if ( !e1.asText().toString().equals( "fusion" ) ) {
3359 if ( !e1.asSimpleText().toString().equals( "fusion" ) ) {
3362 final Event e11 = new Event( Event.EventType.fusion );
3363 if ( !e11.isEqual( e1 ) ) {
3366 if ( !e11.toNHX().toString().equals( "" ) ) {
3369 final Event e2 = new Event( Event.EventType.speciation_or_duplication );
3370 if ( e2.isDuplication() ) {
3373 if ( !e2.isSpeciationOrDuplication() ) {
3376 if ( !e2.asText().toString().equals( "speciation_or_duplication" ) ) {
3379 if ( !e2.asSimpleText().toString().equals( "?" ) ) {
3382 if ( !e2.toNHX().toString().equals( ":D=?" ) ) {
3385 if ( e11.isEqual( e2 ) ) {
3388 final Event e2c = ( Event ) e2.copy();
3389 if ( !e2c.isEqual( e2 ) ) {
3392 Event e3 = new Event( 1, 2, 3 );
3393 if ( e3.isDuplication() ) {
3396 if ( e3.isSpeciation() ) {
3399 if ( e3.isGeneLoss() ) {
3402 if ( !e3.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3405 final Event e3c = ( Event ) e3.copy();
3406 final Event e3cc = ( Event ) e3c.copy();
3407 if ( !e3c.asSimpleText().toString().equals( "D2S3L" ) ) {
3411 if ( !e3c.isEqual( e3cc ) ) {
3414 Event e4 = new Event( 1, 2, 3 );
3415 if ( !e4.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3418 if ( !e4.asSimpleText().toString().equals( "D2S3L" ) ) {
3421 final Event e4c = ( Event ) e4.copy();
3423 final Event e4cc = ( Event ) e4c.copy();
3424 if ( !e4cc.asText().toString().equals( "duplications [1] speciations [2] gene-losses [3]" ) ) {
3427 if ( !e4c.isEqual( e4cc ) ) {
3430 final Event e5 = new Event();
3431 if ( !e5.isUnassigned() ) {
3434 if ( !e5.asText().toString().equals( "unassigned" ) ) {
3437 if ( !e5.asSimpleText().toString().equals( "" ) ) {
3440 final Event e6 = new Event( 1, 0, 0 );
3441 if ( !e6.asText().toString().equals( "duplication" ) ) {
3444 if ( !e6.asSimpleText().toString().equals( "D" ) ) {
3447 final Event e7 = new Event( 0, 1, 0 );
3448 if ( !e7.asText().toString().equals( "speciation" ) ) {
3451 if ( !e7.asSimpleText().toString().equals( "S" ) ) {
3454 final Event e8 = new Event( 0, 0, 1 );
3455 if ( !e8.asText().toString().equals( "gene-loss" ) ) {
3458 if ( !e8.asSimpleText().toString().equals( "L" ) ) {
3462 catch ( final Exception e ) {
3463 e.printStackTrace( System.out );
3469 private static boolean testDeletionOfExternalNodes() {
3471 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
3472 final Phylogeny t0 = factory.create( "A", new NHXParser() )[ 0 ];
3473 final PhylogenyWriter w = new PhylogenyWriter();
3474 if ( t0.isEmpty() ) {
3477 if ( t0.getNumberOfExternalNodes() != 1 ) {
3480 t0.deleteSubtree( t0.getNode( "A" ), false );
3481 if ( t0.getNumberOfExternalNodes() != 0 ) {
3484 if ( !t0.isEmpty() ) {
3487 final Phylogeny t1 = factory.create( "(A,B)r", new NHXParser() )[ 0 ];
3488 if ( t1.getNumberOfExternalNodes() != 2 ) {
3491 t1.deleteSubtree( t1.getNode( "A" ), false );
3492 if ( t1.getNumberOfExternalNodes() != 1 ) {
3495 if ( !t1.getNode( "B" ).getName().equals( "B" ) ) {
3498 t1.deleteSubtree( t1.getNode( "B" ), false );
3499 if ( t1.getNumberOfExternalNodes() != 1 ) {
3502 t1.deleteSubtree( t1.getNode( "r" ), false );
3503 if ( !t1.isEmpty() ) {
3506 final Phylogeny t2 = factory.create( "((A,B),C)", new NHXParser() )[ 0 ];
3507 if ( t2.getNumberOfExternalNodes() != 3 ) {
3510 t2.deleteSubtree( t2.getNode( "B" ), false );
3511 if ( t2.getNumberOfExternalNodes() != 2 ) {
3514 t2.toNewHampshireX();
3515 PhylogenyNode n = t2.getNode( "A" );
3516 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3519 t2.deleteSubtree( t2.getNode( "A" ), false );
3520 if ( t2.getNumberOfExternalNodes() != 2 ) {
3523 t2.deleteSubtree( t2.getNode( "C" ), true );
3524 if ( t2.getNumberOfExternalNodes() != 1 ) {
3527 final Phylogeny t3 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
3528 if ( t3.getNumberOfExternalNodes() != 4 ) {
3531 t3.deleteSubtree( t3.getNode( "B" ), true );
3532 if ( t3.getNumberOfExternalNodes() != 3 ) {
3535 n = t3.getNode( "A" );
3536 if ( !n.getNextExternalNode().getName().equals( "C" ) ) {
3539 n = n.getNextExternalNode();
3540 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3543 t3.deleteSubtree( t3.getNode( "A" ), true );
3544 if ( t3.getNumberOfExternalNodes() != 2 ) {
3547 n = t3.getNode( "C" );
3548 if ( !n.getNextExternalNode().getName().equals( "D" ) ) {
3551 t3.deleteSubtree( t3.getNode( "C" ), true );
3552 if ( t3.getNumberOfExternalNodes() != 1 ) {
3555 t3.deleteSubtree( t3.getNode( "D" ), true );
3556 if ( t3.getNumberOfExternalNodes() != 0 ) {
3559 final Phylogeny t4 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3560 if ( t4.getNumberOfExternalNodes() != 6 ) {
3563 t4.deleteSubtree( t4.getNode( "B2" ), true );
3564 if ( t4.getNumberOfExternalNodes() != 5 ) {
3567 String s = w.toNewHampshire( t4, true ).toString();
3568 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3571 t4.deleteSubtree( t4.getNode( "B11" ), true );
3572 if ( t4.getNumberOfExternalNodes() != 4 ) {
3575 t4.deleteSubtree( t4.getNode( "C" ), true );
3576 if ( t4.getNumberOfExternalNodes() != 3 ) {
3579 n = t4.getNode( "A" );
3580 n = n.getNextExternalNode();
3581 if ( !n.getName().equals( "B12" ) ) {
3584 n = n.getNextExternalNode();
3585 if ( !n.getName().equals( "D" ) ) {
3588 s = w.toNewHampshire( t4, true ).toString();
3589 if ( !s.equals( "((A,B12),D);" ) ) {
3592 final Phylogeny t5 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3593 t5.deleteSubtree( t5.getNode( "A" ), true );
3594 if ( t5.getNumberOfExternalNodes() != 5 ) {
3597 s = w.toNewHampshire( t5, true ).toString();
3598 if ( !s.equals( "(((B11,B12),B2),(C,D));" ) ) {
3601 final Phylogeny t6 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3602 t6.deleteSubtree( t6.getNode( "B11" ), true );
3603 if ( t6.getNumberOfExternalNodes() != 5 ) {
3606 s = w.toNewHampshire( t6, false ).toString();
3607 if ( !s.equals( "((A,(B12,B2)),(C,D));" ) ) {
3610 final Phylogeny t7 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3611 t7.deleteSubtree( t7.getNode( "B12" ), true );
3612 if ( t7.getNumberOfExternalNodes() != 5 ) {
3615 s = w.toNewHampshire( t7, true ).toString();
3616 if ( !s.equals( "((A,(B11,B2)),(C,D));" ) ) {
3619 final Phylogeny t8 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3620 t8.deleteSubtree( t8.getNode( "B2" ), true );
3621 if ( t8.getNumberOfExternalNodes() != 5 ) {
3624 s = w.toNewHampshire( t8, false ).toString();
3625 if ( !s.equals( "((A,(B11,B12)),(C,D));" ) ) {
3628 final Phylogeny t9 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3629 t9.deleteSubtree( t9.getNode( "C" ), true );
3630 if ( t9.getNumberOfExternalNodes() != 5 ) {
3633 s = w.toNewHampshire( t9, true ).toString();
3634 if ( !s.equals( "((A,((B11,B12),B2)),D);" ) ) {
3637 final Phylogeny t10 = factory.create( "((A,((B11,B12),B2)),(C,D))", new NHXParser() )[ 0 ];
3638 t10.deleteSubtree( t10.getNode( "D" ), true );
3639 if ( t10.getNumberOfExternalNodes() != 5 ) {
3642 s = w.toNewHampshire( t10, true ).toString();
3643 if ( !s.equals( "((A,((B11,B12),B2)),C);" ) ) {
3646 final Phylogeny t11 = factory.create( "(A,B,C)", new NHXParser() )[ 0 ];
3647 t11.deleteSubtree( t11.getNode( "A" ), true );
3648 if ( t11.getNumberOfExternalNodes() != 2 ) {
3651 s = w.toNewHampshire( t11, true ).toString();
3652 if ( !s.equals( "(B,C);" ) ) {
3655 t11.deleteSubtree( t11.getNode( "C" ), true );
3656 if ( t11.getNumberOfExternalNodes() != 1 ) {
3659 s = w.toNewHampshire( t11, false ).toString();
3660 if ( !s.equals( "B;" ) ) {
3663 final Phylogeny t12 = factory.create( "((A1,A2,A3),(B1,B2,B3),(C1,C2,C3))", new NHXParser() )[ 0 ];
3664 t12.deleteSubtree( t12.getNode( "B2" ), true );
3665 if ( t12.getNumberOfExternalNodes() != 8 ) {
3668 s = w.toNewHampshire( t12, true ).toString();
3669 if ( !s.equals( "((A1,A2,A3),(B1,B3),(C1,C2,C3));" ) ) {
3672 t12.deleteSubtree( t12.getNode( "B3" ), true );
3673 if ( t12.getNumberOfExternalNodes() != 7 ) {
3676 s = w.toNewHampshire( t12, true ).toString();
3677 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2,C3));" ) ) {
3680 t12.deleteSubtree( t12.getNode( "C3" ), true );
3681 if ( t12.getNumberOfExternalNodes() != 6 ) {
3684 s = w.toNewHampshire( t12, true ).toString();
3685 if ( !s.equals( "((A1,A2,A3),B1,(C1,C2));" ) ) {
3688 t12.deleteSubtree( t12.getNode( "A1" ), true );
3689 if ( t12.getNumberOfExternalNodes() != 5 ) {
3692 s = w.toNewHampshire( t12, true ).toString();
3693 if ( !s.equals( "((A2,A3),B1,(C1,C2));" ) ) {
3696 t12.deleteSubtree( t12.getNode( "B1" ), true );
3697 if ( t12.getNumberOfExternalNodes() != 4 ) {
3700 s = w.toNewHampshire( t12, true ).toString();
3701 if ( !s.equals( "((A2,A3),(C1,C2));" ) ) {
3704 t12.deleteSubtree( t12.getNode( "A3" ), true );
3705 if ( t12.getNumberOfExternalNodes() != 3 ) {
3708 s = w.toNewHampshire( t12, true ).toString();
3709 if ( !s.equals( "(A2,(C1,C2));" ) ) {
3712 t12.deleteSubtree( t12.getNode( "A2" ), true );
3713 if ( t12.getNumberOfExternalNodes() != 2 ) {
3716 s = w.toNewHampshire( t12, true ).toString();
3717 if ( !s.equals( "(C1,C2);" ) ) {
3720 final Phylogeny t13 = factory.create( "(A,B,C,(D:1.0,E:2.0):3.0)", new NHXParser() )[ 0 ];
3721 t13.deleteSubtree( t13.getNode( "D" ), true );
3722 if ( t13.getNumberOfExternalNodes() != 4 ) {
3725 s = w.toNewHampshire( t13, true ).toString();
3726 if ( !s.equals( "(A,B,C,E:5.0);" ) ) {
3729 final Phylogeny t14 = factory.create( "((A,B,C,(D:0.1,E:0.4):1.0),F)", new NHXParser() )[ 0 ];
3730 t14.deleteSubtree( t14.getNode( "E" ), true );
3731 if ( t14.getNumberOfExternalNodes() != 5 ) {
3734 s = w.toNewHampshire( t14, true ).toString();
3735 if ( !s.equals( "((A,B,C,D:1.1),F);" ) ) {
3738 final Phylogeny t15 = factory.create( "((A1,A2,A3,A4),(B1,B2,B3,B4),(C1,C2,C3,C4))", new NHXParser() )[ 0 ];
3739 t15.deleteSubtree( t15.getNode( "B2" ), true );
3740 if ( t15.getNumberOfExternalNodes() != 11 ) {
3743 t15.deleteSubtree( t15.getNode( "B1" ), true );
3744 if ( t15.getNumberOfExternalNodes() != 10 ) {
3747 t15.deleteSubtree( t15.getNode( "B3" ), true );
3748 if ( t15.getNumberOfExternalNodes() != 9 ) {
3751 t15.deleteSubtree( t15.getNode( "B4" ), true );
3752 if ( t15.getNumberOfExternalNodes() != 8 ) {
3755 t15.deleteSubtree( t15.getNode( "A1" ), true );
3756 if ( t15.getNumberOfExternalNodes() != 7 ) {
3759 t15.deleteSubtree( t15.getNode( "C4" ), true );
3760 if ( t15.getNumberOfExternalNodes() != 6 ) {
3764 catch ( final Exception e ) {
3765 e.printStackTrace( System.out );
3771 private static boolean testDescriptiveStatistics() {
3773 final DescriptiveStatistics dss1 = new BasicDescriptiveStatistics();
3774 dss1.addValue( 82 );
3775 dss1.addValue( 78 );
3776 dss1.addValue( 70 );
3777 dss1.addValue( 58 );
3778 dss1.addValue( 42 );
3779 if ( dss1.getN() != 5 ) {
3782 if ( !Test.isEqual( dss1.getMin(), 42 ) ) {
3785 if ( !Test.isEqual( dss1.getMax(), 82 ) ) {
3788 if ( !Test.isEqual( dss1.arithmeticMean(), 66 ) ) {
3791 if ( !Test.isEqual( dss1.sampleStandardDeviation(), 16.24807680927192 ) ) {
3794 if ( !Test.isEqual( dss1.median(), 70 ) ) {
3797 if ( !Test.isEqual( dss1.midrange(), 62 ) ) {
3800 if ( !Test.isEqual( dss1.sampleVariance(), 264 ) ) {
3803 if ( !Test.isEqual( dss1.pearsonianSkewness(), -0.7385489458759964 ) ) {
3806 if ( !Test.isEqual( dss1.coefficientOfVariation(), 0.24618298195866547 ) ) {
3809 if ( !Test.isEqual( dss1.sampleStandardUnit( 66 - 16.24807680927192 ), -1.0 ) ) {
3812 if ( !Test.isEqual( dss1.getValue( 1 ), 78 ) ) {
3815 dss1.addValue( 123 );
3816 if ( !Test.isEqual( dss1.arithmeticMean(), 75.5 ) ) {
3819 if ( !Test.isEqual( dss1.getMax(), 123 ) ) {
3822 if ( !Test.isEqual( dss1.standardErrorOfMean(), 11.200446419674531 ) ) {
3825 final DescriptiveStatistics dss2 = new BasicDescriptiveStatistics();
3826 dss2.addValue( -1.85 );
3827 dss2.addValue( 57.5 );
3828 dss2.addValue( 92.78 );
3829 dss2.addValue( 57.78 );
3830 if ( !Test.isEqual( dss2.median(), 57.64 ) ) {
3833 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 39.266984753946495 ) ) {
3836 final double[] a = dss2.getDataAsDoubleArray();
3837 if ( !Test.isEqual( a[ 3 ], 57.78 ) ) {
3840 dss2.addValue( -100 );
3841 if ( !Test.isEqual( dss2.sampleStandardDeviation(), 75.829111296388 ) ) {
3844 if ( !Test.isEqual( dss2.sampleVariance(), 5750.05412 ) ) {
3847 final double[] ds = new double[ 14 ];
3862 final int[] bins = BasicDescriptiveStatistics.performBinning( ds, 0, 40, 4 );
3863 if ( bins.length != 4 ) {
3866 if ( bins[ 0 ] != 2 ) {
3869 if ( bins[ 1 ] != 3 ) {
3872 if ( bins[ 2 ] != 4 ) {
3875 if ( bins[ 3 ] != 5 ) {
3878 final double[] ds1 = new double[ 9 ];
3888 final int[] bins1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 4 );
3889 if ( bins1.length != 4 ) {
3892 if ( bins1[ 0 ] != 2 ) {
3895 if ( bins1[ 1 ] != 3 ) {
3898 if ( bins1[ 2 ] != 0 ) {
3901 if ( bins1[ 3 ] != 4 ) {
3904 final int[] bins1_1 = BasicDescriptiveStatistics.performBinning( ds1, 0, 40, 3 );
3905 if ( bins1_1.length != 3 ) {
3908 if ( bins1_1[ 0 ] != 3 ) {
3911 if ( bins1_1[ 1 ] != 2 ) {
3914 if ( bins1_1[ 2 ] != 4 ) {
3917 final int[] bins1_2 = BasicDescriptiveStatistics.performBinning( ds1, 1, 39, 3 );
3918 if ( bins1_2.length != 3 ) {
3921 if ( bins1_2[ 0 ] != 2 ) {
3924 if ( bins1_2[ 1 ] != 2 ) {
3927 if ( bins1_2[ 2 ] != 2 ) {
3930 final DescriptiveStatistics dss3 = new BasicDescriptiveStatistics();
3944 dss3.addValue( 10 );
3945 dss3.addValue( 10 );
3946 dss3.addValue( 10 );
3947 final AsciiHistogram histo = new AsciiHistogram( dss3 );
3948 histo.toStringBuffer( 10, '=', 40, 5 );
3949 histo.toStringBuffer( 3, 8, 10, '=', 40, 5, null );
3951 catch ( final Exception e ) {
3952 e.printStackTrace( System.out );
3958 private static boolean testDir( final String file ) {
3960 final File f = new File( file );
3961 if ( !f.exists() ) {
3964 if ( !f.isDirectory() ) {
3967 if ( !f.canRead() ) {
3971 catch ( final Exception e ) {
3977 private static boolean testEbiEntryRetrieval() {
3979 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainEntry( "AAK41263" );
3980 if ( !entry.getAccession().equals( "AAK41263" ) ) {
3981 System.out.println( entry.getAccession() );
3984 if ( !entry.getTaxonomyScientificName().equals( "Sulfolobus solfataricus P2" ) ) {
3985 System.out.println( entry.getTaxonomyScientificName() );
3988 if ( !entry.getSequenceName()
3989 .equals( "Sulfolobus solfataricus P2 Glycogen debranching enzyme, hypothetical (treX-like)" ) ) {
3990 System.out.println( entry.getSequenceName() );
3993 // if ( !entry.getSequenceSymbol().equals( "" ) ) {
3994 // System.out.println( entry.getSequenceSymbol() );
3997 if ( !entry.getGeneName().equals( "treX-like" ) ) {
3998 System.out.println( entry.getGeneName() );
4001 if ( !entry.getTaxonomyIdentifier().equals( "273057" ) ) {
4002 System.out.println( entry.getTaxonomyIdentifier() );
4005 if ( !entry.getAnnotations().first().getRefValue().equals( "3.2.1.33" ) ) {
4006 System.out.println( entry.getAnnotations().first().getRefValue() );
4009 if ( !entry.getAnnotations().first().getRefSource().equals( "EC" ) ) {
4010 System.out.println( entry.getAnnotations().first().getRefSource() );
4013 if ( entry.getCrossReferences().size() != 5 ) {
4017 final SequenceDatabaseEntry entry1 = SequenceDbWsTools.obtainEntry( "ABJ16409" );
4018 if ( !entry1.getAccession().equals( "ABJ16409" ) ) {
4021 if ( !entry1.getTaxonomyScientificName().equals( "Felis catus" ) ) {
4022 System.out.println( entry1.getTaxonomyScientificName() );
4025 if ( !entry1.getSequenceName().equals( "Felis catus (domestic cat) partial BCL2" ) ) {
4026 System.out.println( entry1.getSequenceName() );
4029 if ( !entry1.getTaxonomyIdentifier().equals( "9685" ) ) {
4030 System.out.println( entry1.getTaxonomyIdentifier() );
4033 if ( !entry1.getGeneName().equals( "BCL2" ) ) {
4034 System.out.println( entry1.getGeneName() );
4037 if ( entry1.getCrossReferences().size() != 6 ) {
4041 final SequenceDatabaseEntry entry2 = SequenceDbWsTools.obtainEntry( "NM_184234" );
4042 if ( !entry2.getAccession().equals( "NM_184234" ) ) {
4045 if ( !entry2.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4046 System.out.println( entry2.getTaxonomyScientificName() );
4049 if ( !entry2.getSequenceName()
4050 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
4051 System.out.println( entry2.getSequenceName() );
4054 if ( !entry2.getTaxonomyIdentifier().equals( "9606" ) ) {
4055 System.out.println( entry2.getTaxonomyIdentifier() );
4058 if ( !entry2.getGeneName().equals( "RBM39" ) ) {
4059 System.out.println( entry2.getGeneName() );
4062 if ( entry2.getCrossReferences().size() != 3 ) {
4066 final SequenceDatabaseEntry entry3 = SequenceDbWsTools.obtainEntry( "HM043801" );
4067 if ( !entry3.getAccession().equals( "HM043801" ) ) {
4070 if ( !entry3.getTaxonomyScientificName().equals( "Bursaphelenchus xylophilus" ) ) {
4071 System.out.println( entry3.getTaxonomyScientificName() );
4074 if ( !entry3.getSequenceName().equals( "Bursaphelenchus xylophilus RAF gene, complete cds" ) ) {
4075 System.out.println( entry3.getSequenceName() );
4078 if ( !entry3.getTaxonomyIdentifier().equals( "6326" ) ) {
4079 System.out.println( entry3.getTaxonomyIdentifier() );
4082 if ( !entry3.getSequenceSymbol().equals( "RAF" ) ) {
4083 System.out.println( entry3.getSequenceSymbol() );
4086 if ( !ForesterUtil.isEmpty( entry3.getGeneName() ) ) {
4089 if ( entry3.getCrossReferences().size() != 8 ) {
4094 final SequenceDatabaseEntry entry4 = SequenceDbWsTools.obtainEntry( "AAA36557.1" );
4095 if ( !entry4.getAccession().equals( "AAA36557" ) ) {
4098 if ( !entry4.getTaxonomyScientificName().equals( "Homo sapiens" ) ) {
4099 System.out.println( entry4.getTaxonomyScientificName() );
4102 if ( !entry4.getSequenceName().equals( "Homo sapiens (human) ras protein" ) ) {
4103 System.out.println( entry4.getSequenceName() );
4106 if ( !entry4.getTaxonomyIdentifier().equals( "9606" ) ) {
4107 System.out.println( entry4.getTaxonomyIdentifier() );
4110 if ( !entry4.getGeneName().equals( "ras" ) ) {
4111 System.out.println( entry4.getGeneName() );
4114 // if ( !entry4.getChromosome().equals( "ras" ) ) {
4115 // System.out.println( entry4.getChromosome() );
4118 // if ( !entry4.getMap().equals( "ras" ) ) {
4119 // System.out.println( entry4.getMap() );
4125 // final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
4126 // if ( !entry5.getAccession().equals( "HM043801" ) ) {
4129 final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "AAZ45343.1" );
4130 if ( !entry5.getAccession().equals( "AAZ45343" ) ) {
4133 if ( !entry5.getTaxonomyScientificName().equals( "Dechloromonas aromatica RCB" ) ) {
4134 System.out.println( entry5.getTaxonomyScientificName() );
4137 if ( !entry5.getSequenceName().equals( "Dechloromonas aromatica RCB 1,4-alpha-glucan branching enzyme" ) ) {
4138 System.out.println( entry5.getSequenceName() );
4141 if ( !entry5.getTaxonomyIdentifier().equals( "159087" ) ) {
4142 System.out.println( entry5.getTaxonomyIdentifier() );
4146 catch ( final IOException e ) {
4147 System.out.println();
4148 System.out.println( "the following might be due to absence internet connection:" );
4149 e.printStackTrace( System.out );
4152 catch ( final Exception e ) {
4153 e.printStackTrace();
4159 private static boolean testExternalNodeRelatedMethods() {
4161 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
4162 final Phylogeny t1 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4163 PhylogenyNode n = t1.getNode( "A" );
4164 n = n.getNextExternalNode();
4165 if ( !n.getName().equals( "B" ) ) {
4168 n = n.getNextExternalNode();
4169 if ( !n.getName().equals( "C" ) ) {
4172 n = n.getNextExternalNode();
4173 if ( !n.getName().equals( "D" ) ) {
4176 n = t1.getNode( "B" );
4177 while ( !n.isLastExternalNode() ) {
4178 n = n.getNextExternalNode();
4180 final Phylogeny t2 = factory.create( "(((A,B),C),D)", new NHXParser() )[ 0 ];
4181 n = t2.getNode( "A" );
4182 n = n.getNextExternalNode();
4183 if ( !n.getName().equals( "B" ) ) {
4186 n = n.getNextExternalNode();
4187 if ( !n.getName().equals( "C" ) ) {
4190 n = n.getNextExternalNode();
4191 if ( !n.getName().equals( "D" ) ) {
4194 n = t2.getNode( "B" );
4195 while ( !n.isLastExternalNode() ) {
4196 n = n.getNextExternalNode();
4198 final Phylogeny t3 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4199 n = t3.getNode( "A" );
4200 n = n.getNextExternalNode();
4201 if ( !n.getName().equals( "B" ) ) {
4204 n = n.getNextExternalNode();
4205 if ( !n.getName().equals( "C" ) ) {
4208 n = n.getNextExternalNode();
4209 if ( !n.getName().equals( "D" ) ) {
4212 n = n.getNextExternalNode();
4213 if ( !n.getName().equals( "E" ) ) {
4216 n = n.getNextExternalNode();
4217 if ( !n.getName().equals( "F" ) ) {
4220 n = n.getNextExternalNode();
4221 if ( !n.getName().equals( "G" ) ) {
4224 n = n.getNextExternalNode();
4225 if ( !n.getName().equals( "H" ) ) {
4228 n = t3.getNode( "B" );
4229 while ( !n.isLastExternalNode() ) {
4230 n = n.getNextExternalNode();
4232 final Phylogeny t4 = factory.create( "((A,B),(C,D))", new NHXParser() )[ 0 ];
4233 for( final PhylogenyNodeIterator iter = t4.iteratorExternalForward(); iter.hasNext(); ) {
4234 final PhylogenyNode node = iter.next();
4236 final Phylogeny t5 = factory.create( "(((A,B),(C,D)),((E,F),(G,H)))", new NHXParser() )[ 0 ];
4237 for( final PhylogenyNodeIterator iter = t5.iteratorExternalForward(); iter.hasNext(); ) {
4238 final PhylogenyNode node = iter.next();
4240 final Phylogeny t6 = factory.create( "((((((A))),(((B))),((C)),((((D)))),E)),((F)))", new NHXParser() )[ 0 ];
4241 final PhylogenyNodeIterator iter = t6.iteratorExternalForward();
4242 if ( !iter.next().getName().equals( "A" ) ) {
4245 if ( !iter.next().getName().equals( "B" ) ) {
4248 if ( !iter.next().getName().equals( "C" ) ) {
4251 if ( !iter.next().getName().equals( "D" ) ) {
4254 if ( !iter.next().getName().equals( "E" ) ) {
4257 if ( !iter.next().getName().equals( "F" ) ) {
4260 if ( iter.hasNext() ) {
4264 catch ( final Exception e ) {
4265 e.printStackTrace( System.out );
4271 private static boolean testExtractSNFromNodeName() {
4273 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2_Mus_musculus" ).equals( "Mus musculus" ) ) {
4276 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus" ).equals( "Mus musculus" ) ) {
4279 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCDO2" ).equals( "Mus musculus" ) ) {
4282 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus musculus BCDO2" )
4283 .equals( "Mus musculus musculus" ) ) {
4286 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_BCDO2" )
4287 .equals( "Mus musculus musculus" ) ) {
4290 if ( !ParserUtils.extractScientificNameFromNodeName( "BCDO2 Mus musculus musculus" )
4291 .equals( "Mus musculus musculus" ) ) {
4294 if ( !ParserUtils.extractScientificNameFromNodeName( "Bcl Mus musculus musculus" )
4295 .equals( "Mus musculus musculus" ) ) {
4298 if ( ParserUtils.extractScientificNameFromNodeName( "vcl Mus musculus musculus" ) != null ) {
4301 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_BCDO2" )
4302 .equals( "Mus musculus musculus" ) ) {
4305 if ( !ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_Musculus" )
4306 .equals( "Mus musculus musculus" ) ) {
4309 if ( ParserUtils.extractScientificNameFromNodeName( "could_be_anything_Mus_musculus_musculus_musculus" ) != null ) {
4312 if ( ParserUtils.extractScientificNameFromNodeName( "musculus" ) != null ) {
4315 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus" ) != null ) {
4318 if ( ParserUtils.extractScientificNameFromNodeName( "mus_musculus_musculus" ) != null ) {
4321 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_1" )
4322 .equals( "Mus musculus musculus" ) ) {
4325 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_1" ).equals( "Mus musculus" ) ) {
4328 if ( ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_bcl" ) != null ) {
4331 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_BCL" ).equals( "Mus musculus" ) ) {
4334 if ( ParserUtils.extractScientificNameFromNodeName( "Mus musculus bcl" ) != null ) {
4337 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus BCL" ).equals( "Mus musculus" ) ) {
4340 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus xBCL" ).equals( "Mus musculus" ) ) {
4343 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus musculus x1" ).equals( "Mus musculus" ) ) {
4346 if ( !ParserUtils.extractScientificNameFromNodeName( " -XS12_Mus_musculus_12" ).equals( "Mus musculus" ) ) {
4349 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12 affrre e" )
4350 .equals( "Mus musculus" ) ) {
4353 if ( !ParserUtils.extractScientificNameFromNodeName( " -1234_Mus_musculus_12_affrre_e" )
4354 .equals( "Mus musculus" ) ) {
4357 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus" ).equals( "Mus musculus" ) ) {
4360 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4361 .equals( "Mus musculus musculus" ) ) {
4364 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_2bcl2" )
4365 .equals( "Mus musculus musculus" ) ) {
4368 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_musculus_bcl2" )
4369 .equals( "Mus musculus musculus" ) ) {
4372 if ( !ParserUtils.extractScientificNameFromNodeName( "Mus_musculus_123" ).equals( "Mus musculus" ) ) {
4375 if ( !ParserUtils.extractScientificNameFromNodeName( "Pilostyles mexicana Mexico Breedlove 27233" )
4376 .equals( "Pilostyles mexicana" ) ) {
4379 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_strain_K12/DH10B" )
4380 .equals( "Escherichia coli strain K12/DH10B" ) ) {
4383 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K12/DH10B" )
4384 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4387 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K12/DH10B" )
4388 .equals( "Escherichia coli str. K12/DH10B" ) ) {
4391 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis_lyrata_subsp_lyrata" )
4392 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4395 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata" )
4396 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4399 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata 395" )
4400 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4403 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp. lyrata bcl2" )
4404 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4407 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subsp lyrata bcl2" )
4408 .equals( "Arabidopsis lyrata subsp. lyrata" ) ) {
4411 if ( !ParserUtils.extractScientificNameFromNodeName( "Arabidopsis lyrata subspecies lyrata bcl2" )
4412 .equals( "Arabidopsis lyrata subspecies lyrata" ) ) {
4415 if ( !ParserUtils.extractScientificNameFromNodeName( "Verbascum sinuatum var. adenosepalum bcl2" )
4416 .equals( "Verbascum sinuatum var. adenosepalum" ) ) {
4419 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12)" )
4420 .equals( "Escherichia coli (strain K12)" ) ) {
4423 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (strain K12) bcl2" )
4424 .equals( "Escherichia coli (strain K12)" ) ) {
4427 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12)" )
4428 .equals( "Escherichia coli (str. K12)" ) ) {
4431 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str K12)" )
4432 .equals( "Escherichia coli (str. K12)" ) ) {
4435 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (str. K12) bcl2" )
4436 .equals( "Escherichia coli (str. K12)" ) ) {
4439 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli (var K12) bcl2" )
4440 .equals( "Escherichia coli (var. K12)" ) ) {
4443 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str. K-12 substr. MG1655star" )
4444 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4447 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star" )
4448 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4452 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star" )
4453 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4456 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia coli str K-12 substr MG1655star gene1" )
4457 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4461 .extractScientificNameFromNodeName( "could be anything Escherichia coli str K-12 substr MG1655star GENE1" )
4462 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4465 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4466 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4469 if ( !ParserUtils.extractScientificNameFromNodeName( "Escherichia_coli_str_K-12_substr_MG1655star" )
4470 .equals( "Escherichia coli str. K-12 substr. MG1655star" ) ) {
4473 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp." ).equals( "Macrocera sp." ) ) {
4476 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. 123" ).equals( "Macrocera sp." ) ) {
4479 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp. K12" ).equals( "Macrocera sp." ) ) {
4482 if ( !ParserUtils.extractScientificNameFromNodeName( "something Macrocera sp. K12" )
4483 .equals( "Macrocera sp." ) ) {
4486 if ( !ParserUtils.extractScientificNameFromNodeName( "Macrocera sp" ).equals( "Macrocera sp." ) ) {
4489 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp merenskyanum 07 48" )
4490 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4493 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum ssp. merenskyanum" )
4494 .equals( "Sesamum rigidum subsp. merenskyanum" ) ) {
4497 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp. merenskyanum)" )
4498 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4501 if ( !ParserUtils.extractScientificNameFromNodeName( "Sesamum rigidum (ssp merenskyanum)" )
4502 .equals( "Sesamum rigidum (subsp. merenskyanum)" ) ) {
4506 catch ( final Exception e ) {
4507 e.printStackTrace( System.out );
4513 private static boolean testExtractTaxonomyCodeFromNodeName() {
4515 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "MOUSE", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4518 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4519 .equals( "SOYBN" ) ) {
4522 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4523 .equals( "ARATH" ) ) {
4526 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " ARATH ", TAXONOMY_EXTRACTION.AGGRESSIVE )
4527 .equals( "ARATH" ) ) {
4530 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4533 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "RAT", TAXONOMY_EXTRACTION.AGGRESSIVE ).equals( "RAT" ) ) {
4536 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "RAT1", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4539 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( " _SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4540 .equals( "SOYBN" ) ) {
4543 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4544 .equals( "SOYBN" ) ) {
4547 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4548 .equals( "SOYBN" ) ) {
4551 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "qwerty_SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4552 .equals( "SOYBN" ) ) {
4555 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "ABCD_SOYBN ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4556 .equals( "SOYBN" ) ) {
4559 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "SOYBN", TAXONOMY_EXTRACTION.AGGRESSIVE )
4560 .equals( "SOYBN" ) ) {
4563 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( ",SOYBN,", TAXONOMY_EXTRACTION.AGGRESSIVE )
4564 .equals( "SOYBN" ) ) {
4567 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "xxx,SOYBN,xxx", TAXONOMY_EXTRACTION.AGGRESSIVE )
4568 .equals( "SOYBN" ) ) {
4571 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "xxxSOYBNxxx", TAXONOMY_EXTRACTION.AGGRESSIVE ) != null ) {
4574 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "-SOYBN~", TAXONOMY_EXTRACTION.AGGRESSIVE )
4575 .equals( "SOYBN" ) ) {
4578 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "NNN8_ECOLI/1-2:0.01",
4579 TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT ).equals( "ECOLI" ) ) {
4582 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "blag_9YX45-blag", TAXONOMY_EXTRACTION.AGGRESSIVE )
4583 .equals( "9YX45" ) ) {
4586 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE function = 23445",
4587 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4588 .equals( "MOUSE" ) ) {
4591 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE+function = 23445",
4592 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4593 .equals( "MOUSE" ) ) {
4596 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE|function = 23445",
4597 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4598 .equals( "MOUSE" ) ) {
4601 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEfunction = 23445",
4602 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4605 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSEFunction = 23445",
4606 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4609 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4610 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4613 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT function = 23445",
4614 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4617 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT|function = 23445",
4618 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ).equals( "RAT" ) ) {
4621 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATfunction = 23445",
4622 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4625 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RATFunction = 23445",
4626 TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4629 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_RAT/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4630 .equals( "RAT" ) ) {
4633 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_PIG/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4634 .equals( "PIG" ) ) {
4638 .extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED )
4639 .equals( "MOUSE" ) ) {
4642 if ( !ParserUtils.extractTaxonomyCodeFromNodeName( "BCL2_MOUSE/1-3", TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT )
4643 .equals( "MOUSE" ) ) {
4646 if ( ParserUtils.extractTaxonomyCodeFromNodeName( "_MOUSE ", TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED ) != null ) {
4650 catch ( final Exception e ) {
4651 e.printStackTrace( System.out );
4657 private static boolean testExtractUniProtKbProteinSeqIdentifier() {
4659 PhylogenyNode n = new PhylogenyNode();
4660 n.setName( "tr|B3RJ64" );
4661 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4664 n.setName( "tr.B3RJ64" );
4665 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4668 n.setName( "tr=B3RJ64" );
4669 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4672 n.setName( "tr-B3RJ64" );
4673 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4676 n.setName( "tr/B3RJ64" );
4677 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4680 n.setName( "tr\\B3RJ64" );
4681 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4684 n.setName( "tr_B3RJ64" );
4685 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4688 n.setName( " tr|B3RJ64 " );
4689 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4692 n.setName( "-tr|B3RJ64-" );
4693 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4696 n.setName( "-tr=B3RJ64-" );
4697 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4700 n.setName( "_tr=B3RJ64_" );
4701 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4704 n.setName( " tr_tr|B3RJ64_sp|123 " );
4705 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4708 n.setName( "B3RJ64" );
4709 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4712 n.setName( "sp|B3RJ64" );
4713 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4716 n.setName( "sp|B3RJ64C" );
4717 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4720 n.setName( "sp B3RJ64" );
4721 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4724 n.setName( "sp|B3RJ6X" );
4725 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4728 n.setName( "sp|B3RJ6" );
4729 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4732 n.setName( "K1PYK7_CRAGI" );
4733 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4736 n.setName( "K1PYK7_PEA" );
4737 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PEA" ) ) {
4740 n.setName( "K1PYK7_RAT" );
4741 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_RAT" ) ) {
4744 n.setName( "K1PYK7_PIG" );
4745 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4748 n.setName( "~K1PYK7_PIG~" );
4749 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_PIG" ) ) {
4752 n.setName( "123456_ECOLI-K1PYK7_CRAGI-sp" );
4753 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4756 n.setName( "K1PYKX_CRAGI" );
4757 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4760 n.setName( "XXXXX_CRAGI" );
4761 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "XXXXX_CRAGI" ) ) {
4764 n.setName( "tr|H3IB65|H3IB65_STRPU~2-2" );
4765 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "H3IB65" ) ) {
4768 n.setName( "jgi|Lacbi2|181470|Lacbi1.estExt_GeneWisePlus_human.C_10729~2-3" );
4769 if ( SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ) != null ) {
4772 n.setName( "sp|Q86U06|RBM23_HUMAN~2-2" );
4773 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "Q86U06" ) ) {
4776 n = new PhylogenyNode();
4777 org.forester.phylogeny.data.Sequence seq = new org.forester.phylogeny.data.Sequence();
4778 seq.setSymbol( "K1PYK7_CRAGI" );
4779 n.getNodeData().addSequence( seq );
4780 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4783 seq.setSymbol( "tr|B3RJ64" );
4784 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4787 n = new PhylogenyNode();
4788 seq = new org.forester.phylogeny.data.Sequence();
4789 seq.setName( "K1PYK7_CRAGI" );
4790 n.getNodeData().addSequence( seq );
4791 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK7_CRAGI" ) ) {
4794 seq.setName( "tr|B3RJ64" );
4795 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4798 n = new PhylogenyNode();
4799 seq = new org.forester.phylogeny.data.Sequence();
4800 seq.setAccession( new Accession( "K1PYK8_CRAGI", "?" ) );
4801 n.getNodeData().addSequence( seq );
4802 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "K1PYK8_CRAGI" ) ) {
4805 n = new PhylogenyNode();
4806 seq = new org.forester.phylogeny.data.Sequence();
4807 seq.setAccession( new Accession( "tr|B3RJ64", "?" ) );
4808 n.getNodeData().addSequence( seq );
4809 if ( !SequenceAccessionTools.obtainUniProtAccessorFromDataFields( n ).equals( "B3RJ64" ) ) {
4813 n = new PhylogenyNode();
4814 n.setName( "ACP19736" );
4815 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4818 n = new PhylogenyNode();
4819 n.setName( "|ACP19736|" );
4820 if ( !SequenceAccessionTools.obtainGenbankAccessorFromDataFields( n ).equals( "ACP19736" ) ) {
4824 catch ( final Exception e ) {
4825 e.printStackTrace( System.out );
4831 private static boolean testFastaParser() {
4833 if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) {
4836 if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) {
4839 final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) );
4840 if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) {
4843 if ( !msa_0.getIdentifier( 0 ).equals( "one dumb" ) ) {
4846 if ( !msa_0.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "DKXASDFXSFXFKFKSXDFKSLX" ) ) {
4849 if ( !msa_0.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "SXDFKSXLFSFPWEXPRXWXERR" ) ) {
4852 if ( !msa_0.getSequenceAsString( 3 ).toString().equalsIgnoreCase( "AAAAAAAAAAAAAAAAAAAAAAA" ) ) {
4855 if ( !msa_0.getSequenceAsString( 4 ).toString().equalsIgnoreCase( "DDDDDDDDDDDDDDDDDDDDAXF" ) ) {
4859 catch ( final Exception e ) {
4860 e.printStackTrace();
4866 private static boolean testGenbankAccessorParsing() {
4867 //The format for GenBank Accession numbers are:
4868 //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals
4869 //Protein: 3 letters + 5 numerals
4870 //http://www.ncbi.nlm.nih.gov/Sequin/acc.html
4871 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "AY423861" ).equals( "AY423861" ) ) {
4874 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( ".AY423861.2" ).equals( "AY423861.2" ) ) {
4877 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "345_.AY423861.24_345" ).equals( "AY423861.24" ) ) {
4880 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY423861" ) != null ) {
4883 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AY4238612" ) != null ) {
4886 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "AAY4238612" ) != null ) {
4889 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "Y423861" ) != null ) {
4892 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "S12345" ).equals( "S12345" ) ) {
4895 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "|S12345|" ).equals( "S12345" ) ) {
4898 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "|S123456" ) != null ) {
4901 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABC123456" ) != null ) {
4904 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "ABC12345" ).equals( "ABC12345" ) ) {
4907 if ( !SequenceAccessionTools.parseGenbankAccessorFromString( "&ABC12345&" ).equals( "ABC12345" ) ) {
4910 if ( SequenceAccessionTools.parseGenbankAccessorFromString( "ABCD12345" ) != null ) {
4916 private static boolean testGeneralMsaParser() {
4918 final String msa_str_0 = "seq1 abcd\n\nseq2 efgh\n";
4919 final Msa msa_0 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_0.getBytes() ) );
4920 final String msa_str_1 = "seq1 abc\nseq2 ghi\nseq1 def\nseq2 jkm\n";
4921 final Msa msa_1 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_1.getBytes() ) );
4922 final String msa_str_2 = "seq1 abc\nseq2 ghi\n\ndef\njkm\n";
4923 final Msa msa_2 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_2.getBytes() ) );
4924 final String msa_str_3 = "seq1 abc\n def\nseq2 ghi\n jkm\n";
4925 final Msa msa_3 = GeneralMsaParser.parse( new ByteArrayInputStream( msa_str_3.getBytes() ) );
4926 if ( !msa_1.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4929 if ( !msa_1.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4932 if ( !msa_1.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4935 if ( !msa_1.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4938 if ( !msa_2.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4941 if ( !msa_2.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4944 if ( !msa_2.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4947 if ( !msa_2.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4950 if ( !msa_3.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdef" ) ) {
4953 if ( !msa_3.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "ghixkm" ) ) {
4956 if ( !msa_3.getIdentifier( 0 ).toString().equals( "seq1" ) ) {
4959 if ( !msa_3.getIdentifier( 1 ).toString().equals( "seq2" ) ) {
4962 final Msa msa_4 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_1.txt" ) );
4963 if ( !msa_4.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4966 if ( !msa_4.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4969 if ( !msa_4.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4972 final Msa msa_5 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_2.txt" ) );
4973 if ( !msa_5.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefxx" ) ) {
4976 if ( !msa_5.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixyy" ) ) {
4979 if ( !msa_5.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxpzz" ) ) {
4982 final Msa msa_6 = GeneralMsaParser.parse( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) );
4983 if ( !msa_6.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "abcdefeeeeeeeexx" ) ) {
4986 if ( !msa_6.getSequenceAsString( 1 ).toString().equalsIgnoreCase( "efghixffffffffyy" ) ) {
4989 if ( !msa_6.getSequenceAsString( 2 ).toString().equalsIgnoreCase( "klmnxphhhhhhhhzz" ) ) {
4993 catch ( final Exception e ) {
4994 e.printStackTrace();
5000 private static boolean testGeneralTable() {
5002 final GeneralTable<Integer, String> t0 = new GeneralTable<Integer, String>();
5003 t0.setValue( 3, 2, "23" );
5004 t0.setValue( 10, 1, "error" );
5005 t0.setValue( 10, 1, "110" );
5006 t0.setValue( 9, 1, "19" );
5007 t0.setValue( 1, 10, "101" );
5008 t0.setValue( 10, 10, "1010" );
5009 t0.setValue( 100, 10, "10100" );
5010 t0.setValue( 0, 0, "00" );
5011 if ( !t0.getValue( 3, 2 ).equals( "23" ) ) {
5014 if ( !t0.getValue( 10, 1 ).equals( "110" ) ) {
5017 if ( !t0.getValueAsString( 1, 10 ).equals( "101" ) ) {
5020 if ( !t0.getValueAsString( 10, 10 ).equals( "1010" ) ) {
5023 if ( !t0.getValueAsString( 100, 10 ).equals( "10100" ) ) {
5026 if ( !t0.getValueAsString( 9, 1 ).equals( "19" ) ) {
5029 if ( !t0.getValueAsString( 0, 0 ).equals( "00" ) ) {
5032 if ( !t0.getValueAsString( 49, 4 ).equals( "" ) ) {
5035 if ( !t0.getValueAsString( 22349, 3434344 ).equals( "" ) ) {
5038 final GeneralTable<String, String> t1 = new GeneralTable<String, String>();
5039 t1.setValue( "3", "2", "23" );
5040 t1.setValue( "10", "1", "error" );
5041 t1.setValue( "10", "1", "110" );
5042 t1.setValue( "9", "1", "19" );
5043 t1.setValue( "1", "10", "101" );
5044 t1.setValue( "10", "10", "1010" );
5045 t1.setValue( "100", "10", "10100" );
5046 t1.setValue( "0", "0", "00" );
5047 t1.setValue( "qwerty", "zxcvbnm", "asdef" );
5048 if ( !t1.getValue( "3", "2" ).equals( "23" ) ) {
5051 if ( !t1.getValue( "10", "1" ).equals( "110" ) ) {
5054 if ( !t1.getValueAsString( "1", "10" ).equals( "101" ) ) {
5057 if ( !t1.getValueAsString( "10", "10" ).equals( "1010" ) ) {
5060 if ( !t1.getValueAsString( "100", "10" ).equals( "10100" ) ) {
5063 if ( !t1.getValueAsString( "9", "1" ).equals( "19" ) ) {
5066 if ( !t1.getValueAsString( "0", "0" ).equals( "00" ) ) {
5069 if ( !t1.getValueAsString( "qwerty", "zxcvbnm" ).equals( "asdef" ) ) {
5072 if ( !t1.getValueAsString( "49", "4" ).equals( "" ) ) {
5075 if ( !t1.getValueAsString( "22349", "3434344" ).equals( "" ) ) {
5079 catch ( final Exception e ) {
5080 e.printStackTrace( System.out );
5086 private static boolean testGetDistance() {
5088 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5089 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",
5090 new NHXParser() )[ 0 ];
5091 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "C" ) ) != 0 ) {
5094 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "def" ) ) != 0 ) {
5097 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ef" ) ) != 0 ) {
5100 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "r" ) ) != 0 ) {
5103 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "A" ) ) != 0 ) {
5106 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "B" ) ) != 3 ) {
5109 if ( PhylogenyMethods.calculateDistance( p1.getNode( "B" ), p1.getNode( "A" ) ) != 3 ) {
5112 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "C" ) ) != 8 ) {
5115 if ( PhylogenyMethods.calculateDistance( p1.getNode( "C" ), p1.getNode( "A" ) ) != 8 ) {
5118 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "D" ) ) != 22 ) {
5121 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "E" ) ) != 32 ) {
5124 if ( PhylogenyMethods.calculateDistance( p1.getNode( "E" ), p1.getNode( "A" ) ) != 32 ) {
5127 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "F" ) ) != 33 ) {
5130 if ( PhylogenyMethods.calculateDistance( p1.getNode( "F" ), p1.getNode( "A" ) ) != 33 ) {
5133 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ab" ) ) != 1 ) {
5136 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "A" ) ) != 1 ) {
5139 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "abc" ) ) != 4 ) {
5142 if ( PhylogenyMethods.calculateDistance( p1.getNode( "abc" ), p1.getNode( "A" ) ) != 4 ) {
5145 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "r" ) ) != 9 ) {
5148 if ( PhylogenyMethods.calculateDistance( p1.getNode( "r" ), p1.getNode( "A" ) ) != 9 ) {
5151 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "def" ) ) != 15 ) {
5154 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "A" ) ) != 15 ) {
5157 if ( PhylogenyMethods.calculateDistance( p1.getNode( "A" ), p1.getNode( "ef" ) ) != 23 ) {
5160 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "A" ) ) != 23 ) {
5163 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "def" ) ) != 8 ) {
5166 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "ef" ) ) != 8 ) {
5169 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "r" ) ) != 14 ) {
5172 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "abc" ) ) != 19 ) {
5175 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ef" ), p1.getNode( "ab" ) ) != 22 ) {
5178 if ( PhylogenyMethods.calculateDistance( p1.getNode( "ab" ), p1.getNode( "ef" ) ) != 22 ) {
5181 if ( PhylogenyMethods.calculateDistance( p1.getNode( "def" ), p1.getNode( "abc" ) ) != 11 ) {
5184 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",
5185 new NHXParser() )[ 0 ];
5186 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "B" ) ) != 9 ) {
5189 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "C" ) ) != 10 ) {
5192 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "D" ) ) != 14 ) {
5195 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "ghi" ) ) != 8 ) {
5198 if ( PhylogenyMethods.calculateDistance( p2.getNode( "A" ), p2.getNode( "I" ) ) != 20 ) {
5201 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "ghi" ) ) != 10 ) {
5204 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "r" ) ) != 0 ) {
5207 if ( PhylogenyMethods.calculateDistance( p2.getNode( "r" ), p2.getNode( "G" ) ) != 13 ) {
5210 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "r" ) ) != 13 ) {
5213 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "H" ) ) != 21 ) {
5216 if ( PhylogenyMethods.calculateDistance( p2.getNode( "G" ), p2.getNode( "I" ) ) != 22 ) {
5220 catch ( final Exception e ) {
5221 e.printStackTrace( System.out );
5227 private static boolean testGetLCA() {
5229 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5230 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5231 new NHXParser() )[ 0 ];
5232 final PhylogenyNode A = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "A" ) );
5233 if ( !A.getName().equals( "A" ) ) {
5236 final PhylogenyNode gh = PhylogenyMethods.calculateLCA( p1.getNode( "gh" ), p1.getNode( "gh" ) );
5237 if ( !gh.getName().equals( "gh" ) ) {
5240 final PhylogenyNode ab = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "B" ) );
5241 if ( !ab.getName().equals( "ab" ) ) {
5244 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "A" ) );
5245 if ( !ab2.getName().equals( "ab" ) ) {
5248 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "G" ) );
5249 if ( !gh2.getName().equals( "gh" ) ) {
5252 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCA( p1.getNode( "G" ), p1.getNode( "H" ) );
5253 if ( !gh3.getName().equals( "gh" ) ) {
5256 final PhylogenyNode abc = PhylogenyMethods.calculateLCA( p1.getNode( "C" ), p1.getNode( "A" ) );
5257 if ( !abc.getName().equals( "abc" ) ) {
5260 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "C" ) );
5261 if ( !abc2.getName().equals( "abc" ) ) {
5264 final PhylogenyNode abcd = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "D" ) );
5265 if ( !abcd.getName().equals( "abcd" ) ) {
5268 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCA( p1.getNode( "D" ), p1.getNode( "A" ) );
5269 if ( !abcd2.getName().equals( "abcd" ) ) {
5272 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "F" ) );
5273 if ( !abcdef.getName().equals( "abcdef" ) ) {
5276 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "A" ) );
5277 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5280 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "F" ) );
5281 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5284 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCA( p1.getNode( "F" ), p1.getNode( "ab" ) );
5285 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5288 final PhylogenyNode abcde = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "E" ) );
5289 if ( !abcde.getName().equals( "abcde" ) ) {
5292 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "A" ) );
5293 if ( !abcde2.getName().equals( "abcde" ) ) {
5296 final PhylogenyNode r = PhylogenyMethods.calculateLCA( p1.getNode( "abcdefgh" ), p1.getNode( "abcdefgh" ) );
5297 if ( !r.getName().equals( "abcdefgh" ) ) {
5300 final PhylogenyNode r2 = PhylogenyMethods.calculateLCA( p1.getNode( "A" ), p1.getNode( "H" ) );
5301 if ( !r2.getName().equals( "abcdefgh" ) ) {
5304 final PhylogenyNode r3 = PhylogenyMethods.calculateLCA( p1.getNode( "H" ), p1.getNode( "A" ) );
5305 if ( !r3.getName().equals( "abcdefgh" ) ) {
5308 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCA( p1.getNode( "E" ), p1.getNode( "abcde" ) );
5309 if ( !abcde3.getName().equals( "abcde" ) ) {
5312 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCA( p1.getNode( "abcde" ), p1.getNode( "E" ) );
5313 if ( !abcde4.getName().equals( "abcde" ) ) {
5316 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCA( p1.getNode( "ab" ), p1.getNode( "B" ) );
5317 if ( !ab3.getName().equals( "ab" ) ) {
5320 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCA( p1.getNode( "B" ), p1.getNode( "ab" ) );
5321 if ( !ab4.getName().equals( "ab" ) ) {
5324 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5325 final PhylogenyNode cd = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "d" ) );
5326 if ( !cd.getName().equals( "cd" ) ) {
5329 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "c" ) );
5330 if ( !cd2.getName().equals( "cd" ) ) {
5333 final PhylogenyNode cde = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "e" ) );
5334 if ( !cde.getName().equals( "cde" ) ) {
5337 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCA( p2.getNode( "e" ), p2.getNode( "c" ) );
5338 if ( !cde2.getName().equals( "cde" ) ) {
5341 final PhylogenyNode cdef = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "f" ) );
5342 if ( !cdef.getName().equals( "cdef" ) ) {
5345 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCA( p2.getNode( "d" ), p2.getNode( "f" ) );
5346 if ( !cdef2.getName().equals( "cdef" ) ) {
5349 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCA( p2.getNode( "f" ), p2.getNode( "d" ) );
5350 if ( !cdef3.getName().equals( "cdef" ) ) {
5353 final PhylogenyNode rt = PhylogenyMethods.calculateLCA( p2.getNode( "c" ), p2.getNode( "a" ) );
5354 if ( !rt.getName().equals( "r" ) ) {
5357 final Phylogeny p3 = factory
5358 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5359 new NHXParser() )[ 0 ];
5360 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCA( p3.getNode( "b" ), p3.getNode( "c" ) );
5361 if ( !bc_3.getName().equals( "bc" ) ) {
5364 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "c" ) );
5365 if ( !ac_3.getName().equals( "abc" ) ) {
5368 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "d" ) );
5369 if ( !ad_3.getName().equals( "abcde" ) ) {
5372 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "f" ) );
5373 if ( !af_3.getName().equals( "abcdef" ) ) {
5376 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "g" ) );
5377 if ( !ag_3.getName().equals( "" ) ) {
5380 if ( !ag_3.isRoot() ) {
5383 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCA( p3.getNode( "a" ), p3.getNode( "l" ) );
5384 if ( !al_3.getName().equals( "" ) ) {
5387 if ( !al_3.isRoot() ) {
5390 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "k" ), p3.getNode( "l" ) );
5391 if ( !kl_3.getName().equals( "" ) ) {
5394 if ( !kl_3.isRoot() ) {
5397 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCA( p3.getNode( "f" ), p3.getNode( "l" ) );
5398 if ( !fl_3.getName().equals( "" ) ) {
5401 if ( !fl_3.isRoot() ) {
5404 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCA( p3.getNode( "g" ), p3.getNode( "k" ) );
5405 if ( !gk_3.getName().equals( "ghijk" ) ) {
5408 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5409 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCA( p4.getNode( "b" ), p4.getNode( "c" ) );
5410 if ( !r_4.getName().equals( "r" ) ) {
5413 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5414 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCA( p5.getNode( "a" ), p5.getNode( "c" ) );
5415 if ( !r_5.getName().equals( "root" ) ) {
5418 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5419 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCA( p6.getNode( "c" ), p6.getNode( "a" ) );
5420 if ( !r_6.getName().equals( "rot" ) ) {
5423 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5424 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCA( p7.getNode( "a" ), p7.getNode( "e" ) );
5425 if ( !r_7.getName().equals( "rott" ) ) {
5429 catch ( final Exception e ) {
5430 e.printStackTrace( System.out );
5436 private static boolean testGetLCA2() {
5438 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5439 // final Phylogeny p_a = factory.create( "(a)", new NHXParser() )[ 0 ];
5440 final Phylogeny p_a = NHXParser.parse( "(a)" )[ 0 ];
5441 PhylogenyMethods.preOrderReId( p_a );
5442 final PhylogenyNode p_a_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_a.getNode( "a" ),
5443 p_a.getNode( "a" ) );
5444 if ( !p_a_1.getName().equals( "a" ) ) {
5447 final Phylogeny p_b = NHXParser.parse( "((a)b)" )[ 0 ];
5448 PhylogenyMethods.preOrderReId( p_b );
5449 final PhylogenyNode p_b_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "b" ),
5450 p_b.getNode( "a" ) );
5451 if ( !p_b_1.getName().equals( "b" ) ) {
5454 final PhylogenyNode p_b_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_b.getNode( "a" ),
5455 p_b.getNode( "b" ) );
5456 if ( !p_b_2.getName().equals( "b" ) ) {
5459 final Phylogeny p_c = factory.create( "(((a)b)c)", new NHXParser() )[ 0 ];
5460 PhylogenyMethods.preOrderReId( p_c );
5461 final PhylogenyNode p_c_1 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "b" ),
5462 p_c.getNode( "a" ) );
5463 if ( !p_c_1.getName().equals( "b" ) ) {
5466 final PhylogenyNode p_c_2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5467 p_c.getNode( "c" ) );
5468 if ( !p_c_2.getName().equals( "c" ) ) {
5469 System.out.println( p_c_2.getName() );
5473 final PhylogenyNode p_c_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "a" ),
5474 p_c.getNode( "b" ) );
5475 if ( !p_c_3.getName().equals( "b" ) ) {
5478 final PhylogenyNode p_c_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p_c.getNode( "c" ),
5479 p_c.getNode( "a" ) );
5480 if ( !p_c_4.getName().equals( "c" ) ) {
5483 final Phylogeny p1 = factory.create( "((((((A,B)ab,C)abc,D)abcd,E)abcde,F)abcdef,(G,H)gh)abcdefgh",
5484 new NHXParser() )[ 0 ];
5485 PhylogenyMethods.preOrderReId( p1 );
5486 final PhylogenyNode A = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5487 p1.getNode( "A" ) );
5488 if ( !A.getName().equals( "A" ) ) {
5491 final PhylogenyNode gh = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "gh" ),
5492 p1.getNode( "gh" ) );
5493 if ( !gh.getName().equals( "gh" ) ) {
5496 final PhylogenyNode ab = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5497 p1.getNode( "B" ) );
5498 if ( !ab.getName().equals( "ab" ) ) {
5501 final PhylogenyNode ab2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5502 p1.getNode( "A" ) );
5503 if ( !ab2.getName().equals( "ab" ) ) {
5506 final PhylogenyNode gh2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5507 p1.getNode( "G" ) );
5508 if ( !gh2.getName().equals( "gh" ) ) {
5511 final PhylogenyNode gh3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "G" ),
5512 p1.getNode( "H" ) );
5513 if ( !gh3.getName().equals( "gh" ) ) {
5516 final PhylogenyNode abc = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "C" ),
5517 p1.getNode( "A" ) );
5518 if ( !abc.getName().equals( "abc" ) ) {
5521 final PhylogenyNode abc2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5522 p1.getNode( "C" ) );
5523 if ( !abc2.getName().equals( "abc" ) ) {
5526 final PhylogenyNode abcd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5527 p1.getNode( "D" ) );
5528 if ( !abcd.getName().equals( "abcd" ) ) {
5531 final PhylogenyNode abcd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "D" ),
5532 p1.getNode( "A" ) );
5533 if ( !abcd2.getName().equals( "abcd" ) ) {
5536 final PhylogenyNode abcdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5537 p1.getNode( "F" ) );
5538 if ( !abcdef.getName().equals( "abcdef" ) ) {
5541 final PhylogenyNode abcdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5542 p1.getNode( "A" ) );
5543 if ( !abcdef2.getName().equals( "abcdef" ) ) {
5546 final PhylogenyNode abcdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5547 p1.getNode( "F" ) );
5548 if ( !abcdef3.getName().equals( "abcdef" ) ) {
5551 final PhylogenyNode abcdef4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "F" ),
5552 p1.getNode( "ab" ) );
5553 if ( !abcdef4.getName().equals( "abcdef" ) ) {
5556 final PhylogenyNode abcde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5557 p1.getNode( "E" ) );
5558 if ( !abcde.getName().equals( "abcde" ) ) {
5561 final PhylogenyNode abcde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5562 p1.getNode( "A" ) );
5563 if ( !abcde2.getName().equals( "abcde" ) ) {
5566 final PhylogenyNode r = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcdefgh" ),
5567 p1.getNode( "abcdefgh" ) );
5568 if ( !r.getName().equals( "abcdefgh" ) ) {
5571 final PhylogenyNode r2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "A" ),
5572 p1.getNode( "H" ) );
5573 if ( !r2.getName().equals( "abcdefgh" ) ) {
5576 final PhylogenyNode r3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "H" ),
5577 p1.getNode( "A" ) );
5578 if ( !r3.getName().equals( "abcdefgh" ) ) {
5581 final PhylogenyNode abcde3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "E" ),
5582 p1.getNode( "abcde" ) );
5583 if ( !abcde3.getName().equals( "abcde" ) ) {
5586 final PhylogenyNode abcde4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "abcde" ),
5587 p1.getNode( "E" ) );
5588 if ( !abcde4.getName().equals( "abcde" ) ) {
5591 final PhylogenyNode ab3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "ab" ),
5592 p1.getNode( "B" ) );
5593 if ( !ab3.getName().equals( "ab" ) ) {
5596 final PhylogenyNode ab4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p1.getNode( "B" ),
5597 p1.getNode( "ab" ) );
5598 if ( !ab4.getName().equals( "ab" ) ) {
5601 final Phylogeny p2 = factory.create( "(a,b,(((c,d)cd,e)cde,f)cdef)r", new NHXParser() )[ 0 ];
5602 PhylogenyMethods.preOrderReId( p2 );
5603 final PhylogenyNode cd = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5604 p2.getNode( "d" ) );
5605 if ( !cd.getName().equals( "cd" ) ) {
5608 final PhylogenyNode cd2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5609 p2.getNode( "c" ) );
5610 if ( !cd2.getName().equals( "cd" ) ) {
5613 final PhylogenyNode cde = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5614 p2.getNode( "e" ) );
5615 if ( !cde.getName().equals( "cde" ) ) {
5618 final PhylogenyNode cde2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "e" ),
5619 p2.getNode( "c" ) );
5620 if ( !cde2.getName().equals( "cde" ) ) {
5623 final PhylogenyNode cdef = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5624 p2.getNode( "f" ) );
5625 if ( !cdef.getName().equals( "cdef" ) ) {
5628 final PhylogenyNode cdef2 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "d" ),
5629 p2.getNode( "f" ) );
5630 if ( !cdef2.getName().equals( "cdef" ) ) {
5633 final PhylogenyNode cdef3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "f" ),
5634 p2.getNode( "d" ) );
5635 if ( !cdef3.getName().equals( "cdef" ) ) {
5638 final PhylogenyNode rt = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p2.getNode( "c" ),
5639 p2.getNode( "a" ) );
5640 if ( !rt.getName().equals( "r" ) ) {
5643 final Phylogeny p3 = factory
5644 .create( "((((a,(b,c)bc)abc,(d,e)de)abcde,f)abcdef,(((g,h)gh,(i,j)ij)ghij,k)ghijk,l)",
5645 new NHXParser() )[ 0 ];
5646 PhylogenyMethods.preOrderReId( p3 );
5647 final PhylogenyNode bc_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "b" ),
5648 p3.getNode( "c" ) );
5649 if ( !bc_3.getName().equals( "bc" ) ) {
5652 final PhylogenyNode ac_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5653 p3.getNode( "c" ) );
5654 if ( !ac_3.getName().equals( "abc" ) ) {
5657 final PhylogenyNode ad_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5658 p3.getNode( "d" ) );
5659 if ( !ad_3.getName().equals( "abcde" ) ) {
5662 final PhylogenyNode af_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5663 p3.getNode( "f" ) );
5664 if ( !af_3.getName().equals( "abcdef" ) ) {
5667 final PhylogenyNode ag_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5668 p3.getNode( "g" ) );
5669 if ( !ag_3.getName().equals( "" ) ) {
5672 if ( !ag_3.isRoot() ) {
5675 final PhylogenyNode al_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "a" ),
5676 p3.getNode( "l" ) );
5677 if ( !al_3.getName().equals( "" ) ) {
5680 if ( !al_3.isRoot() ) {
5683 final PhylogenyNode kl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "k" ),
5684 p3.getNode( "l" ) );
5685 if ( !kl_3.getName().equals( "" ) ) {
5688 if ( !kl_3.isRoot() ) {
5691 final PhylogenyNode fl_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "f" ),
5692 p3.getNode( "l" ) );
5693 if ( !fl_3.getName().equals( "" ) ) {
5696 if ( !fl_3.isRoot() ) {
5699 final PhylogenyNode gk_3 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p3.getNode( "g" ),
5700 p3.getNode( "k" ) );
5701 if ( !gk_3.getName().equals( "ghijk" ) ) {
5704 final Phylogeny p4 = factory.create( "(a,b,c)r", new NHXParser() )[ 0 ];
5705 PhylogenyMethods.preOrderReId( p4 );
5706 final PhylogenyNode r_4 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p4.getNode( "b" ),
5707 p4.getNode( "c" ) );
5708 if ( !r_4.getName().equals( "r" ) ) {
5711 final Phylogeny p5 = factory.create( "((a,b),c,d)root", new NHXParser() )[ 0 ];
5712 PhylogenyMethods.preOrderReId( p5 );
5713 final PhylogenyNode r_5 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p5.getNode( "a" ),
5714 p5.getNode( "c" ) );
5715 if ( !r_5.getName().equals( "root" ) ) {
5718 final Phylogeny p6 = factory.create( "((a,b),c,d)rot", new NHXParser() )[ 0 ];
5719 PhylogenyMethods.preOrderReId( p6 );
5720 final PhylogenyNode r_6 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p6.getNode( "c" ),
5721 p6.getNode( "a" ) );
5722 if ( !r_6.getName().equals( "rot" ) ) {
5725 final Phylogeny p7 = factory.create( "(((a,b)x,c)x,d,e)rott", new NHXParser() )[ 0 ];
5726 PhylogenyMethods.preOrderReId( p7 );
5727 final PhylogenyNode r_7 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "a" ),
5728 p7.getNode( "e" ) );
5729 if ( !r_7.getName().equals( "rott" ) ) {
5732 final PhylogenyNode r_71 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5733 p7.getNode( "a" ) );
5734 if ( !r_71.getName().equals( "rott" ) ) {
5737 final PhylogenyNode r_72 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5738 p7.getNode( "rott" ) );
5739 if ( !r_72.getName().equals( "rott" ) ) {
5742 final PhylogenyNode r_73 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5743 p7.getNode( "a" ) );
5744 if ( !r_73.getName().equals( "rott" ) ) {
5747 final PhylogenyNode r_74 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "rott" ),
5748 p7.getNode( "rott" ) );
5749 if ( !r_74.getName().equals( "rott" ) ) {
5752 final PhylogenyNode r_75 = PhylogenyMethods.calculateLCAonTreeWithIdsInPreOrder( p7.getNode( "e" ),
5753 p7.getNode( "e" ) );
5754 if ( !r_75.getName().equals( "e" ) ) {
5758 catch ( final Exception e ) {
5759 e.printStackTrace( System.out );
5765 private static boolean testHmmscanOutputParser() {
5766 final String test_dir = Test.PATH_TO_TEST_DATA;
5768 final HmmscanPerDomainTableParser parser1 = new HmmscanPerDomainTableParser( new File( test_dir
5769 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_1" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5771 final HmmscanPerDomainTableParser parser2 = new HmmscanPerDomainTableParser( new File( test_dir
5772 + ForesterUtil.getFileSeparator() + "hmmscan30b3_output_2" ), "MONBR", INDIVIDUAL_SCORE_CUTOFF.NONE );
5773 final List<Protein> proteins = parser2.parse();
5774 if ( parser2.getProteinsEncountered() != 4 ) {
5777 if ( proteins.size() != 4 ) {
5780 if ( parser2.getDomainsEncountered() != 69 ) {
5783 if ( parser2.getDomainsIgnoredDueToDuf() != 0 ) {
5786 if ( parser2.getDomainsIgnoredDueToFsEval() != 0 ) {
5789 if ( parser2.getDomainsIgnoredDueToIEval() != 0 ) {
5792 final Protein p1 = proteins.get( 0 );
5793 if ( p1.getNumberOfProteinDomains() != 15 ) {
5796 if ( p1.getLength() != 850 ) {
5799 final Protein p2 = proteins.get( 1 );
5800 if ( p2.getNumberOfProteinDomains() != 51 ) {
5803 if ( p2.getLength() != 1291 ) {
5806 final Protein p3 = proteins.get( 2 );
5807 if ( p3.getNumberOfProteinDomains() != 2 ) {
5810 final Protein p4 = proteins.get( 3 );
5811 if ( p4.getNumberOfProteinDomains() != 1 ) {
5814 if ( !p4.getProteinDomain( 0 ).getDomainId().toString().equals( "DNA_pol_B_new" ) ) {
5817 if ( p4.getProteinDomain( 0 ).getFrom() != 51 ) {
5820 if ( p4.getProteinDomain( 0 ).getTo() != 395 ) {
5823 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainEvalue(), 1.2e-39 ) ) {
5826 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getPerDomainScore(), 135.7 ) ) {
5829 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getNumber(), 1 ) ) {
5832 if ( !Test.isEqual( p4.getProteinDomain( 0 ).getTotalCount(), 1 ) ) {
5836 catch ( final Exception e ) {
5837 e.printStackTrace( System.out );
5843 private static boolean testLastExternalNodeMethods() {
5845 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5846 final char[] a0 = { '(', '(', 'A', ',', 'B', ')', ',', '(', 'C', ',', 'D', ')', ')', };
5847 final Phylogeny t0 = factory.create( a0, new NHXParser() )[ 0 ];
5848 final PhylogenyNode n1 = t0.getNode( "A" );
5849 if ( n1.isLastExternalNode() ) {
5852 final PhylogenyNode n2 = t0.getNode( "B" );
5853 if ( n2.isLastExternalNode() ) {
5856 final PhylogenyNode n3 = t0.getNode( "C" );
5857 if ( n3.isLastExternalNode() ) {
5860 final PhylogenyNode n4 = t0.getNode( "D" );
5861 if ( !n4.isLastExternalNode() ) {
5865 catch ( final Exception e ) {
5866 e.printStackTrace( System.out );
5872 private static boolean testLevelOrderIterator() {
5874 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
5875 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
5876 PhylogenyNodeIterator it0;
5877 for( it0 = t0.iteratorLevelOrder(); it0.hasNext(); ) {
5880 for( it0.reset(); it0.hasNext(); ) {
5883 final PhylogenyNodeIterator it = t0.iteratorLevelOrder();
5884 if ( !it.next().getName().equals( "r" ) ) {
5887 if ( !it.next().getName().equals( "ab" ) ) {
5890 if ( !it.next().getName().equals( "cd" ) ) {
5893 if ( !it.next().getName().equals( "A" ) ) {
5896 if ( !it.next().getName().equals( "B" ) ) {
5899 if ( !it.next().getName().equals( "C" ) ) {
5902 if ( !it.next().getName().equals( "D" ) ) {
5905 if ( it.hasNext() ) {
5908 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",
5909 new NHXParser() )[ 0 ];
5910 PhylogenyNodeIterator it2;
5911 for( it2 = t2.iteratorLevelOrder(); it2.hasNext(); ) {
5914 for( it2.reset(); it2.hasNext(); ) {
5917 final PhylogenyNodeIterator it3 = t2.iteratorLevelOrder();
5918 if ( !it3.next().getName().equals( "r" ) ) {
5921 if ( !it3.next().getName().equals( "abc" ) ) {
5924 if ( !it3.next().getName().equals( "defg" ) ) {
5927 if ( !it3.next().getName().equals( "A" ) ) {
5930 if ( !it3.next().getName().equals( "B" ) ) {
5933 if ( !it3.next().getName().equals( "C" ) ) {
5936 if ( !it3.next().getName().equals( "D" ) ) {
5939 if ( !it3.next().getName().equals( "E" ) ) {
5942 if ( !it3.next().getName().equals( "F" ) ) {
5945 if ( !it3.next().getName().equals( "G" ) ) {
5948 if ( !it3.next().getName().equals( "1" ) ) {
5951 if ( !it3.next().getName().equals( "2" ) ) {
5954 if ( !it3.next().getName().equals( "3" ) ) {
5957 if ( !it3.next().getName().equals( "4" ) ) {
5960 if ( !it3.next().getName().equals( "5" ) ) {
5963 if ( !it3.next().getName().equals( "6" ) ) {
5966 if ( !it3.next().getName().equals( "f1" ) ) {
5969 if ( !it3.next().getName().equals( "f2" ) ) {
5972 if ( !it3.next().getName().equals( "f3" ) ) {
5975 if ( !it3.next().getName().equals( "a" ) ) {
5978 if ( !it3.next().getName().equals( "b" ) ) {
5981 if ( !it3.next().getName().equals( "f21" ) ) {
5984 if ( !it3.next().getName().equals( "X" ) ) {
5987 if ( !it3.next().getName().equals( "Y" ) ) {
5990 if ( !it3.next().getName().equals( "Z" ) ) {
5993 if ( it3.hasNext() ) {
5996 final Phylogeny t4 = factory.create( "((((D)C)B)A)r", new NHXParser() )[ 0 ];
5997 PhylogenyNodeIterator it4;
5998 for( it4 = t4.iteratorLevelOrder(); it4.hasNext(); ) {
6001 for( it4.reset(); it4.hasNext(); ) {
6004 final PhylogenyNodeIterator it5 = t4.iteratorLevelOrder();
6005 if ( !it5.next().getName().equals( "r" ) ) {
6008 if ( !it5.next().getName().equals( "A" ) ) {
6011 if ( !it5.next().getName().equals( "B" ) ) {
6014 if ( !it5.next().getName().equals( "C" ) ) {
6017 if ( !it5.next().getName().equals( "D" ) ) {
6020 final Phylogeny t5 = factory.create( "A", new NHXParser() )[ 0 ];
6021 PhylogenyNodeIterator it6;
6022 for( it6 = t5.iteratorLevelOrder(); it6.hasNext(); ) {
6025 for( it6.reset(); it6.hasNext(); ) {
6028 final PhylogenyNodeIterator it7 = t5.iteratorLevelOrder();
6029 if ( !it7.next().getName().equals( "A" ) ) {
6032 if ( it.hasNext() ) {
6036 catch ( final Exception e ) {
6037 e.printStackTrace( System.out );
6043 private static boolean testMafft( final String path ) {
6045 final List<String> opts = new ArrayList<String>();
6046 opts.add( "--maxiterate" );
6048 opts.add( "--localpair" );
6049 opts.add( "--quiet" );
6051 final MsaInferrer mafft = Mafft.createInstance( path );
6052 msa = mafft.infer( new File( PATH_TO_TEST_DATA + "ncbi_sn.fasta" ), opts );
6053 if ( ( msa == null ) || ( msa.getLength() < 20 ) || ( msa.getNumberOfSequences() != 19 ) ) {
6056 if ( !msa.getIdentifier( 0 ).toString().equals( "a" ) ) {
6060 catch ( final Exception e ) {
6061 e.printStackTrace( System.out );
6067 private static boolean testMidpointrooting() {
6069 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6070 final Phylogeny t0 = factory.create( "(A:1,B:4,C:2,D:2,E:6,F:1,G:1,H:1)", new NHXParser() )[ 0 ];
6071 PhylogenyMethods.midpointRoot( t0 );
6072 if ( !isEqual( t0.getNode( "E" ).getDistanceToParent(), 5 ) ) {
6075 if ( !isEqual( t0.getNode( "B" ).getDistanceToParent(), 4 ) ) {
6078 if ( !isEqual( PhylogenyMethods.calculateLCA( t0.getNode( "F" ), t0.getNode( "G" ) ).getDistanceToParent(),
6082 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",
6083 new NHXParser() )[ 0 ];
6084 if ( !t1.isRooted() ) {
6087 PhylogenyMethods.midpointRoot( t1 );
6088 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6091 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6094 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6097 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6100 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6103 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6106 t1.reRoot( t1.getNode( "A" ) );
6107 PhylogenyMethods.midpointRoot( t1 );
6108 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
6111 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
6114 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
6117 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 4 ) ) {
6120 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 1 ) ) {
6124 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 3 ) ) {
6128 catch ( final Exception e ) {
6129 e.printStackTrace( System.out );
6135 private static boolean testMsaQualityMethod() {
6137 final Sequence s0 = BasicSequence.createAaSequence( "a", "ABAXEFGHIJJE-" );
6138 final Sequence s1 = BasicSequence.createAaSequence( "b", "ABBXEFGHIJJBB" );
6139 final Sequence s2 = BasicSequence.createAaSequence( "c", "AXCXEFGHIJJ--" );
6140 final Sequence s3 = BasicSequence.createAaSequence( "d", "AXDDEFGHIJ---" );
6141 final List<Sequence> l = new ArrayList<Sequence>();
6146 final Msa msa = BasicMsa.createInstance( l );
6147 if ( !isEqual( 1, MsaMethods.calculateIdentityRatio( msa, 0 ) ) ) {
6150 if ( !isEqual( 0.5, MsaMethods.calculateIdentityRatio( msa, 1 ) ) ) {
6153 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 2 ) ) ) {
6156 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 3 ) ) ) {
6159 if ( !isEqual( 0.75, MsaMethods.calculateIdentityRatio( msa, 10 ) ) ) {
6162 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 11 ) ) ) {
6165 if ( !isEqual( 0.25, MsaMethods.calculateIdentityRatio( msa, 12 ) ) ) {
6169 catch ( final Exception e ) {
6170 e.printStackTrace( System.out );
6176 private static boolean testMsaEntropy() {
6178 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAAAAA" );
6179 final Sequence s1 = BasicSequence.createAaSequence( "b", "AAAIACC" );
6180 final Sequence s2 = BasicSequence.createAaSequence( "c", "AAIIIIF" );
6181 final Sequence s3 = BasicSequence.createAaSequence( "d", "AIIIVVW" );
6182 final List<Sequence> l = new ArrayList<Sequence>();
6187 final Msa msa = BasicMsa.createInstance( l );
6188 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 0 ) );
6189 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 1 ) );
6190 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 2 ) );
6191 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 3 ) );
6192 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 4 ) );
6193 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 5 ) );
6194 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa, 6 ) );
6195 System.out.println();
6196 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 0 ) );
6197 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 1 ) );
6198 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 2 ) );
6199 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 3 ) );
6200 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 4 ) );
6201 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 5 ) );
6202 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 6, msa, 6 ) );
6203 final List<Sequence> l2 = new ArrayList<Sequence>();
6204 l2.add( BasicSequence.createAaSequence( "1", "AAAAAAA" ) );
6205 l2.add( BasicSequence.createAaSequence( "2", "AAAIACC" ) );
6206 l2.add( BasicSequence.createAaSequence( "3", "AAIIIIF" ) );
6207 l2.add( BasicSequence.createAaSequence( "4", "AIIIVVW" ) );
6208 l2.add( BasicSequence.createAaSequence( "5", "AAAAAAA" ) );
6209 l2.add( BasicSequence.createAaSequence( "6", "AAAIACC" ) );
6210 l2.add( BasicSequence.createAaSequence( "7", "AAIIIIF" ) );
6211 l2.add( BasicSequence.createAaSequence( "8", "AIIIVVW" ) );
6212 l2.add( BasicSequence.createAaSequence( "9", "AAAAAAA" ) );
6213 l2.add( BasicSequence.createAaSequence( "10", "AAAIACC" ) );
6214 l2.add( BasicSequence.createAaSequence( "11", "AAIIIIF" ) );
6215 l2.add( BasicSequence.createAaSequence( "12", "AIIIVVW" ) );
6216 l2.add( BasicSequence.createAaSequence( "13", "AAIIIIF" ) );
6217 l2.add( BasicSequence.createAaSequence( "14", "AIIIVVW" ) );
6218 l2.add( BasicSequence.createAaSequence( "15", "AAAAAAA" ) );
6219 l2.add( BasicSequence.createAaSequence( "16", "AAAIACC" ) );
6220 l2.add( BasicSequence.createAaSequence( "17", "AAIIIIF" ) );
6221 l2.add( BasicSequence.createAaSequence( "18", "AIIIVVW" ) );
6222 l2.add( BasicSequence.createAaSequence( "19", "AAAAAAA" ) );
6223 l2.add( BasicSequence.createAaSequence( "20", "AAAIACC" ) );
6224 l2.add( BasicSequence.createAaSequence( "21", "AAIIIIF" ) );
6225 l2.add( BasicSequence.createAaSequence( "22", "AIIIVVW" ) );
6226 final Msa msa2 = BasicMsa.createInstance( l2 );
6227 System.out.println();
6228 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 0 ) );
6229 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 1 ) );
6230 System.out.println( MsaMethods.calcNormalizedShannonsEntropy( 20, msa2, 2 ) );
6232 catch ( final Exception e ) {
6233 e.printStackTrace( System.out );
6239 private static boolean testDeleteableMsa() {
6241 final Sequence s0 = BasicSequence.createAaSequence( "a", "AAAA" );
6242 final Sequence s1 = BasicSequence.createAaSequence( "b", "BAAA" );
6243 final Sequence s2 = BasicSequence.createAaSequence( "c", "CAAA" );
6244 final Sequence s3 = BasicSequence.createAaSequence( "d", "DAAA" );
6245 final Sequence s4 = BasicSequence.createAaSequence( "e", "EAAA" );
6246 final Sequence s5 = BasicSequence.createAaSequence( "f", "FAAA" );
6247 final List<Sequence> l0 = new ArrayList<Sequence>();
6254 final DeleteableMsa dmsa0 = DeleteableMsa.createInstance( l0 );
6255 dmsa0.deleteRow( "b", false );
6256 if ( !dmsa0.getIdentifier( 1 ).equals( "c" ) ) {
6259 dmsa0.deleteRow( "e", false );
6260 dmsa0.deleteRow( "a", false );
6261 dmsa0.deleteRow( "f", false );
6262 if ( dmsa0.getLength() != 4 ) {
6265 if ( dmsa0.getNumberOfSequences() != 2 ) {
6268 if ( !dmsa0.getIdentifier( 0 ).equals( "c" ) ) {
6271 if ( !dmsa0.getIdentifier( 1 ).equals( "d" ) ) {
6274 if ( dmsa0.getResidueAt( 0, 0 ) != 'C' ) {
6277 if ( !dmsa0.getSequenceAsString( 0 ).toString().equals( "CAAA" ) ) {
6280 if ( dmsa0.getColumnAt( 0 ).size() != 2 ) {
6283 dmsa0.deleteRow( "c", false );
6284 dmsa0.deleteRow( "d", false );
6285 if ( dmsa0.getNumberOfSequences() != 0 ) {
6289 final Sequence s_0 = BasicSequence.createAaSequence( "a", "--A---B-C--X----" );
6290 final Sequence s_1 = BasicSequence.createAaSequence( "b", "--B-----C-------" );
6291 final Sequence s_2 = BasicSequence.createAaSequence( "c", "--C--AB-C------Z" );
6292 final Sequence s_3 = BasicSequence.createAaSequence( "d", "--D--AA-C-------" );
6293 final Sequence s_4 = BasicSequence.createAaSequence( "e", "--E--AA-C-------" );
6294 final Sequence s_5 = BasicSequence.createAaSequence( "f", "--F--AB-CD--Y---" );
6295 final List<Sequence> l1 = new ArrayList<Sequence>();
6302 final DeleteableMsa dmsa1 = DeleteableMsa.createInstance( l1 );
6303 dmsa1.deleteGapOnlyColumns();
6304 dmsa1.deleteRow( "a", false );
6305 dmsa1.deleteRow( "f", false );
6306 dmsa1.deleteRow( "d", false );
6307 dmsa1.deleteGapOnlyColumns();
6308 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C-" ) ) {
6311 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "CABCZ" ) ) {
6314 if ( !dmsa1.getSequenceAsString( 2 ).toString().equals( "EAAC-" ) ) {
6317 dmsa1.deleteRow( "c", false );
6318 dmsa1.deleteGapOnlyColumns();
6319 final Writer w0 = new StringWriter();
6320 dmsa1.write( w0, MSA_FORMAT.FASTA );
6321 final Writer w1 = new StringWriter();
6322 dmsa1.write( w1, MSA_FORMAT.PHYLIP );
6323 if ( !dmsa1.getSequenceAsString( 0 ).toString().equals( "B--C" ) ) {
6326 if ( !dmsa1.getSequenceAsString( 1 ).toString().equals( "EAAC" ) ) {
6330 final Sequence s__0 = BasicSequence.createAaSequence( "a", "A------" );
6331 final Sequence s__1 = BasicSequence.createAaSequence( "b", "BB-----" );
6332 final Sequence s__2 = BasicSequence.createAaSequence( "c", "CCC----" );
6333 final Sequence s__3 = BasicSequence.createAaSequence( "d", "DDDD---" );
6334 final Sequence s__4 = BasicSequence.createAaSequence( "e", "EEEEE--" );
6335 final Sequence s__5 = BasicSequence.createAaSequence( "f", "FFFFFF-" );
6336 final List<Sequence> l2 = new ArrayList<Sequence>();
6343 final DeleteableMsa dmsa2 = DeleteableMsa.createInstance( l2 );
6344 dmsa2.deleteGapColumns( 0.5 );
6345 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A---" ) ) {
6348 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB--" ) ) {
6351 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CCC-" ) ) {
6354 dmsa2.deleteGapColumns( 0.2 );
6355 if ( !dmsa2.getSequenceAsString( 0 ).toString().equals( "A-" ) ) {
6358 if ( !dmsa2.getSequenceAsString( 1 ).toString().equals( "BB" ) ) {
6361 if ( !dmsa2.getSequenceAsString( 2 ).toString().equals( "CC" ) ) {
6364 dmsa2.deleteGapColumns( 0 );
6365 dmsa2.deleteRow( "a", false );
6366 dmsa2.deleteRow( "b", false );
6367 dmsa2.deleteRow( "f", false );
6368 dmsa2.deleteRow( "e", false );
6369 dmsa2.setIdentifier( 0, "new_c" );
6370 dmsa2.setIdentifier( 1, "new_d" );
6371 dmsa2.setResidueAt( 0, 0, 'x' );
6372 final Sequence s = dmsa2.deleteRow( "new_d", true );
6373 if ( !s.getMolecularSequenceAsString().equals( "D" ) ) {
6376 final Writer w = new StringWriter();
6377 dmsa2.write( w, MSA_FORMAT.PHYLIP );
6378 final String phylip = w.toString();
6379 if ( !phylip.equals( "new_c x" + ForesterUtil.LINE_SEPARATOR ) ) {
6382 final Writer w2 = new StringWriter();
6383 dmsa2.write( w2, MSA_FORMAT.FASTA );
6384 final String fasta = w2.toString();
6385 if ( !fasta.equals( ">new_c" + ForesterUtil.LINE_SEPARATOR + "x" + ForesterUtil.LINE_SEPARATOR ) ) {
6389 catch ( final Exception e ) {
6390 e.printStackTrace( System.out );
6396 private static boolean testNextNodeWithCollapsing() {
6398 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
6400 List<PhylogenyNode> ext = new ArrayList<PhylogenyNode>();
6401 final StringBuffer sb0 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6402 final Phylogeny t0 = factory.create( sb0, new NHXParser() )[ 0 ];
6403 t0.getNode( "cd" ).setCollapse( true );
6404 t0.getNode( "cde" ).setCollapse( true );
6405 n = t0.getFirstExternalNode();
6406 while ( n != null ) {
6408 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6410 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6413 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6416 if ( !ext.get( 2 ).getName().equals( "cde" ) ) {
6419 if ( !ext.get( 3 ).getName().equals( "f" ) ) {
6422 if ( !ext.get( 4 ).getName().equals( "g" ) ) {
6425 if ( !ext.get( 5 ).getName().equals( "h" ) ) {
6429 final StringBuffer sb1 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6430 final Phylogeny t1 = factory.create( sb1, new NHXParser() )[ 0 ];
6431 t1.getNode( "ab" ).setCollapse( true );
6432 t1.getNode( "cd" ).setCollapse( true );
6433 t1.getNode( "cde" ).setCollapse( true );
6434 n = t1.getNode( "ab" );
6435 ext = new ArrayList<PhylogenyNode>();
6436 while ( n != null ) {
6438 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6440 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6443 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6446 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6449 if ( !ext.get( 3 ).getName().equals( "g" ) ) {
6452 if ( !ext.get( 4 ).getName().equals( "h" ) ) {
6458 final StringBuffer sb2 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6459 final Phylogeny t2 = factory.create( sb2, new NHXParser() )[ 0 ];
6460 t2.getNode( "ab" ).setCollapse( true );
6461 t2.getNode( "cd" ).setCollapse( true );
6462 t2.getNode( "cde" ).setCollapse( true );
6463 t2.getNode( "c" ).setCollapse( true );
6464 t2.getNode( "d" ).setCollapse( true );
6465 t2.getNode( "e" ).setCollapse( true );
6466 t2.getNode( "gh" ).setCollapse( true );
6467 n = t2.getNode( "ab" );
6468 ext = new ArrayList<PhylogenyNode>();
6469 while ( n != null ) {
6471 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6473 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6476 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6479 if ( !ext.get( 2 ).getName().equals( "f" ) ) {
6482 if ( !ext.get( 3 ).getName().equals( "gh" ) ) {
6488 final StringBuffer sb3 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6489 final Phylogeny t3 = factory.create( sb3, new NHXParser() )[ 0 ];
6490 t3.getNode( "ab" ).setCollapse( true );
6491 t3.getNode( "cd" ).setCollapse( true );
6492 t3.getNode( "cde" ).setCollapse( true );
6493 t3.getNode( "c" ).setCollapse( true );
6494 t3.getNode( "d" ).setCollapse( true );
6495 t3.getNode( "e" ).setCollapse( true );
6496 t3.getNode( "gh" ).setCollapse( true );
6497 t3.getNode( "fgh" ).setCollapse( true );
6498 n = t3.getNode( "ab" );
6499 ext = new ArrayList<PhylogenyNode>();
6500 while ( n != null ) {
6502 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6504 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6507 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6510 if ( !ext.get( 2 ).getName().equals( "fgh" ) ) {
6516 final StringBuffer sb4 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6517 final Phylogeny t4 = factory.create( sb4, new NHXParser() )[ 0 ];
6518 t4.getNode( "ab" ).setCollapse( true );
6519 t4.getNode( "cd" ).setCollapse( true );
6520 t4.getNode( "cde" ).setCollapse( true );
6521 t4.getNode( "c" ).setCollapse( true );
6522 t4.getNode( "d" ).setCollapse( true );
6523 t4.getNode( "e" ).setCollapse( true );
6524 t4.getNode( "gh" ).setCollapse( true );
6525 t4.getNode( "fgh" ).setCollapse( true );
6526 t4.getNode( "abcdefgh" ).setCollapse( true );
6527 n = t4.getNode( "abcdefgh" );
6528 if ( n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes() != null ) {
6533 final StringBuffer sb5 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6534 final Phylogeny t5 = factory.create( sb5, new NHXParser() )[ 0 ];
6536 n = t5.getFirstExternalNode();
6537 while ( n != null ) {
6539 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6541 if ( ext.size() != 8 ) {
6544 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6547 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6550 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6553 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6556 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6559 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6562 if ( !ext.get( 6 ).getName().equals( "g" ) ) {
6565 if ( !ext.get( 7 ).getName().equals( "h" ) ) {
6570 final StringBuffer sb6 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6571 final Phylogeny t6 = factory.create( sb6, new NHXParser() )[ 0 ];
6573 t6.getNode( "ab" ).setCollapse( true );
6574 n = t6.getNode( "ab" );
6575 while ( n != null ) {
6577 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6579 if ( ext.size() != 7 ) {
6582 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6585 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6588 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6591 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6594 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6597 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6600 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6605 final StringBuffer sb7 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6606 final Phylogeny t7 = factory.create( sb7, new NHXParser() )[ 0 ];
6608 t7.getNode( "cd" ).setCollapse( true );
6609 n = t7.getNode( "a" );
6610 while ( n != null ) {
6612 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6614 if ( ext.size() != 7 ) {
6617 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6620 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6623 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6626 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6629 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6632 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6635 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6640 final StringBuffer sb8 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h))fgh)cdefgh)abcdefgh" );
6641 final Phylogeny t8 = factory.create( sb8, new NHXParser() )[ 0 ];
6643 t8.getNode( "cd" ).setCollapse( true );
6644 t8.getNode( "c" ).setCollapse( true );
6645 t8.getNode( "d" ).setCollapse( true );
6646 n = t8.getNode( "a" );
6647 while ( n != null ) {
6649 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6651 if ( ext.size() != 7 ) {
6654 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6657 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6660 if ( !ext.get( 2 ).getName().equals( "cd" ) ) {
6661 System.out.println( "2 fail" );
6664 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6667 if ( !ext.get( 4 ).getName().equals( "f" ) ) {
6670 if ( !ext.get( 5 ).getName().equals( "g" ) ) {
6673 if ( !ext.get( 6 ).getName().equals( "h" ) ) {
6678 final StringBuffer sb9 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6679 final Phylogeny t9 = factory.create( sb9, new NHXParser() )[ 0 ];
6681 t9.getNode( "gh" ).setCollapse( true );
6682 n = t9.getNode( "a" );
6683 while ( n != null ) {
6685 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6687 if ( ext.size() != 7 ) {
6690 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6693 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6696 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6699 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6702 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6705 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6708 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6713 final StringBuffer sb10 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6714 final Phylogeny t10 = factory.create( sb10, new NHXParser() )[ 0 ];
6716 t10.getNode( "gh" ).setCollapse( true );
6717 t10.getNode( "g" ).setCollapse( true );
6718 t10.getNode( "h" ).setCollapse( true );
6719 n = t10.getNode( "a" );
6720 while ( n != null ) {
6722 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6724 if ( ext.size() != 7 ) {
6727 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6730 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6733 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6736 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6739 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6742 if ( !ext.get( 5 ).getName().equals( "f" ) ) {
6745 if ( !ext.get( 6 ).getName().equals( "gh" ) ) {
6750 final StringBuffer sb11 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6751 final Phylogeny t11 = factory.create( sb11, new NHXParser() )[ 0 ];
6753 t11.getNode( "gh" ).setCollapse( true );
6754 t11.getNode( "fgh" ).setCollapse( true );
6755 n = t11.getNode( "a" );
6756 while ( n != null ) {
6758 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6760 if ( ext.size() != 6 ) {
6763 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6766 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6769 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6772 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6775 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6778 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6783 final StringBuffer sb12 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6784 final Phylogeny t12 = factory.create( sb12, new NHXParser() )[ 0 ];
6786 t12.getNode( "gh" ).setCollapse( true );
6787 t12.getNode( "fgh" ).setCollapse( true );
6788 t12.getNode( "g" ).setCollapse( true );
6789 t12.getNode( "h" ).setCollapse( true );
6790 t12.getNode( "f" ).setCollapse( true );
6791 n = t12.getNode( "a" );
6792 while ( n != null ) {
6794 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6796 if ( ext.size() != 6 ) {
6799 if ( !ext.get( 0 ).getName().equals( "a" ) ) {
6802 if ( !ext.get( 1 ).getName().equals( "b" ) ) {
6805 if ( !ext.get( 2 ).getName().equals( "c" ) ) {
6808 if ( !ext.get( 3 ).getName().equals( "d" ) ) {
6811 if ( !ext.get( 4 ).getName().equals( "e" ) ) {
6814 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6819 final StringBuffer sb13 = new StringBuffer( "((a,b)ab,(((c,d)cd,e)cde,(f,(g,h)gh)fgh)cdefgh)abcdefgh" );
6820 final Phylogeny t13 = factory.create( sb13, new NHXParser() )[ 0 ];
6822 t13.getNode( "ab" ).setCollapse( true );
6823 t13.getNode( "b" ).setCollapse( true );
6824 t13.getNode( "fgh" ).setCollapse( true );
6825 t13.getNode( "gh" ).setCollapse( true );
6826 n = t13.getNode( "ab" );
6827 while ( n != null ) {
6829 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6831 if ( ext.size() != 5 ) {
6834 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6837 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6840 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6843 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6846 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6851 final StringBuffer sb14 = new StringBuffer( "((a,b,0)ab,(((c,d)cd,e)cde,(f,(g,h,1,2)gh,0)fgh)cdefgh)abcdefgh" );
6852 final Phylogeny t14 = factory.create( sb14, new NHXParser() )[ 0 ];
6854 t14.getNode( "ab" ).setCollapse( true );
6855 t14.getNode( "a" ).setCollapse( true );
6856 t14.getNode( "fgh" ).setCollapse( true );
6857 t14.getNode( "gh" ).setCollapse( true );
6858 n = t14.getNode( "ab" );
6859 while ( n != null ) {
6861 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6863 if ( ext.size() != 5 ) {
6866 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6869 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6872 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6875 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6878 if ( !ext.get( 4 ).getName().equals( "fgh" ) ) {
6883 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" );
6884 final Phylogeny t15 = factory.create( sb15, new NHXParser() )[ 0 ];
6886 t15.getNode( "ab" ).setCollapse( true );
6887 t15.getNode( "a" ).setCollapse( true );
6888 t15.getNode( "fgh" ).setCollapse( true );
6889 t15.getNode( "gh" ).setCollapse( true );
6890 n = t15.getNode( "ab" );
6891 while ( n != null ) {
6893 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6895 if ( ext.size() != 6 ) {
6898 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6901 if ( !ext.get( 1 ).getName().equals( "c" ) ) {
6904 if ( !ext.get( 2 ).getName().equals( "d" ) ) {
6907 if ( !ext.get( 3 ).getName().equals( "e" ) ) {
6910 if ( !ext.get( 4 ).getName().equals( "x" ) ) {
6913 if ( !ext.get( 5 ).getName().equals( "fgh" ) ) {
6918 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" );
6919 final Phylogeny t16 = factory.create( sb16, new NHXParser() )[ 0 ];
6921 t16.getNode( "ab" ).setCollapse( true );
6922 t16.getNode( "a" ).setCollapse( true );
6923 t16.getNode( "fgh" ).setCollapse( true );
6924 t16.getNode( "gh" ).setCollapse( true );
6925 t16.getNode( "cd" ).setCollapse( true );
6926 t16.getNode( "cde" ).setCollapse( true );
6927 t16.getNode( "d" ).setCollapse( true );
6928 t16.getNode( "x" ).setCollapse( true );
6929 n = t16.getNode( "ab" );
6930 while ( n != null ) {
6932 n = n.getNextExternalNodeWhileTakingIntoAccountCollapsedNodes();
6934 if ( ext.size() != 4 ) {
6937 if ( !ext.get( 0 ).getName().equals( "ab" ) ) {
6940 if ( !ext.get( 1 ).getName().equals( "cde" ) ) {
6943 if ( !ext.get( 2 ).getName().equals( "x" ) ) {
6946 if ( !ext.get( 3 ).getName().equals( "fgh" ) ) {
6950 catch ( final Exception e ) {
6951 e.printStackTrace( System.out );
6957 private static boolean testNexusCharactersParsing() {
6959 final NexusCharactersParser parser = new NexusCharactersParser();
6960 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex" ) );
6962 String[] labels = parser.getCharStateLabels();
6963 if ( labels.length != 7 ) {
6966 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6969 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6972 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
6975 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
6978 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
6981 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
6984 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
6987 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
6989 labels = parser.getCharStateLabels();
6990 if ( labels.length != 7 ) {
6993 if ( !labels[ 0 ].equals( "14-3-3" ) ) {
6996 if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
6999 if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7002 if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7005 if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7008 if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7011 if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7015 catch ( final Exception e ) {
7016 e.printStackTrace( System.out );
7022 private static boolean testNexusMatrixParsing() {
7024 final NexusBinaryStatesMatrixParser parser = new NexusBinaryStatesMatrixParser();
7025 parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_9.nex" ) );
7027 final CharacterStateMatrix<BinaryStates> m = parser.getMatrix();
7028 if ( m.getNumberOfCharacters() != 9 ) {
7031 if ( m.getNumberOfIdentifiers() != 5 ) {
7034 if ( m.getState( 0, 0 ) != BinaryStates.PRESENT ) {
7037 if ( m.getState( 0, 1 ) != BinaryStates.ABSENT ) {
7040 if ( m.getState( 1, 0 ) != BinaryStates.PRESENT ) {
7043 if ( m.getState( 2, 0 ) != BinaryStates.ABSENT ) {
7046 if ( m.getState( 4, 8 ) != BinaryStates.PRESENT ) {
7049 if ( !m.getIdentifier( 0 ).equals( "MOUSE" ) ) {
7052 if ( !m.getIdentifier( 4 ).equals( "ARATH" ) ) {
7055 // if ( labels.length != 7 ) {
7058 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7061 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7064 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7067 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7070 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7073 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7076 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7079 // parser.setSource( new File( Test.PATH_TO_TEST_DATA + "nexus_test_8.nex" ) );
7081 // labels = parser.getCharStateLabels();
7082 // if ( labels.length != 7 ) {
7085 // if ( !labels[ 0 ].equals( "14-3-3" ) ) {
7088 // if ( !labels[ 1 ].equals( "2-Hacid_dh" ) ) {
7091 // if ( !labels[ 2 ].equals( "2-Hacid_dh_C" ) ) {
7094 // if ( !labels[ 3 ].equals( "2-oxoacid_dh" ) ) {
7097 // if ( !labels[ 4 ].equals( "2OG-FeII_Oxy" ) ) {
7100 // if ( !labels[ 5 ].equals( "3-HAO" ) ) {
7103 // if ( !labels[ 6 ].equals( "3_5_exonuc" ) ) {
7107 catch ( final Exception e ) {
7108 e.printStackTrace( System.out );
7114 private static boolean testNexusTreeParsing() {
7116 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7117 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7118 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex", parser );
7119 if ( phylogenies.length != 1 ) {
7122 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 25 ) {
7125 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7129 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex", parser );
7130 if ( phylogenies.length != 1 ) {
7133 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7136 if ( !phylogenies[ 0 ].getName().equals( "name" ) ) {
7140 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex", parser );
7141 if ( phylogenies.length != 1 ) {
7144 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7147 if ( !phylogenies[ 0 ].getName().equals( "" ) ) {
7150 if ( phylogenies[ 0 ].isRooted() ) {
7154 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_4.nex", parser );
7155 if ( phylogenies.length != 18 ) {
7158 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 10 ) {
7161 if ( !phylogenies[ 0 ].getName().equals( "tree 0" ) ) {
7164 if ( !phylogenies[ 1 ].getName().equals( "tree 1" ) ) {
7167 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 10 ) {
7170 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
7173 if ( phylogenies[ 3 ].getNumberOfExternalNodes() != 3 ) {
7176 if ( phylogenies[ 4 ].getNumberOfExternalNodes() != 3 ) {
7179 if ( phylogenies[ 5 ].getNumberOfExternalNodes() != 3 ) {
7182 if ( phylogenies[ 6 ].getNumberOfExternalNodes() != 3 ) {
7185 if ( phylogenies[ 7 ].getNumberOfExternalNodes() != 3 ) {
7188 if ( !phylogenies[ 8 ].getName().equals( "tree 8" ) ) {
7191 if ( phylogenies[ 8 ].isRooted() ) {
7194 if ( phylogenies[ 8 ].getNumberOfExternalNodes() != 3 ) {
7197 if ( !phylogenies[ 9 ].getName().equals( "tree 9" ) ) {
7200 if ( !phylogenies[ 9 ].isRooted() ) {
7203 if ( phylogenies[ 9 ].getNumberOfExternalNodes() != 3 ) {
7206 if ( !phylogenies[ 10 ].getName().equals( "tree 10" ) ) {
7209 if ( !phylogenies[ 10 ].isRooted() ) {
7212 if ( phylogenies[ 10 ].getNumberOfExternalNodes() != 3 ) {
7215 if ( !phylogenies[ 11 ].getName().equals( "tree 11" ) ) {
7218 if ( phylogenies[ 11 ].isRooted() ) {
7221 if ( phylogenies[ 11 ].getNumberOfExternalNodes() != 3 ) {
7224 if ( !phylogenies[ 12 ].getName().equals( "tree 12" ) ) {
7227 if ( !phylogenies[ 12 ].isRooted() ) {
7230 if ( phylogenies[ 12 ].getNumberOfExternalNodes() != 3 ) {
7233 if ( !phylogenies[ 13 ].getName().equals( "tree 13" ) ) {
7236 if ( !phylogenies[ 13 ].isRooted() ) {
7239 if ( phylogenies[ 13 ].getNumberOfExternalNodes() != 3 ) {
7242 if ( !phylogenies[ 14 ].getName().equals( "tree 14" ) ) {
7245 if ( !phylogenies[ 14 ].isRooted() ) {
7248 if ( phylogenies[ 14 ].getNumberOfExternalNodes() != 10 ) {
7251 if ( !phylogenies[ 15 ].getName().equals( "tree 15" ) ) {
7254 if ( phylogenies[ 15 ].isRooted() ) {
7257 if ( phylogenies[ 15 ].getNumberOfExternalNodes() != 10 ) {
7260 if ( !phylogenies[ 16 ].getName().equals( "tree 16" ) ) {
7263 if ( !phylogenies[ 16 ].isRooted() ) {
7266 if ( phylogenies[ 16 ].getNumberOfExternalNodes() != 10 ) {
7269 if ( !phylogenies[ 17 ].getName().equals( "tree 17" ) ) {
7272 if ( phylogenies[ 17 ].isRooted() ) {
7275 if ( phylogenies[ 17 ].getNumberOfExternalNodes() != 10 ) {
7278 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7280 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S15613.nex", p2 );
7281 if ( phylogenies.length != 9 ) {
7284 if ( !isEqual( 0.48039661496919533, phylogenies[ 0 ].getNode( "Diadocidia_spinosula" )
7285 .getDistanceToParent() ) ) {
7288 if ( !isEqual( 0.3959796191512233, phylogenies[ 0 ].getNode( "Diadocidia_stanfordensis" )
7289 .getDistanceToParent() ) ) {
7292 if ( !phylogenies[ 0 ].getName().equals( "Family Diadocidiidae MLT (Imported_tree_0)" ) ) {
7295 if ( !phylogenies[ 1 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7298 if ( !phylogenies[ 2 ].getName().equals( "Family Diadocidiidae BAT (con_50_majrule)" ) ) {
7301 if ( !isEqual( 0.065284, phylogenies[ 7 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7304 if ( !isEqual( 0.065284, phylogenies[ 8 ].getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7308 catch ( final Exception e ) {
7309 e.printStackTrace( System.out );
7315 private static boolean testNexusTreeParsingIterating() {
7317 final NexusPhylogeniesParser p = new NexusPhylogeniesParser();
7318 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_1.nex" );
7319 if ( !p.hasNext() ) {
7322 Phylogeny phy = p.next();
7323 if ( phy == null ) {
7326 if ( phy.getNumberOfExternalNodes() != 25 ) {
7329 if ( !phy.getName().equals( "" ) ) {
7332 if ( p.hasNext() ) {
7336 if ( phy != null ) {
7341 if ( !p.hasNext() ) {
7345 if ( phy == null ) {
7348 if ( phy.getNumberOfExternalNodes() != 25 ) {
7351 if ( !phy.getName().equals( "" ) ) {
7354 if ( p.hasNext() ) {
7358 if ( phy != null ) {
7362 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_2.nex" );
7363 if ( !p.hasNext() ) {
7367 if ( phy == null ) {
7370 if ( phy.getNumberOfExternalNodes() != 10 ) {
7373 if ( !phy.getName().equals( "name" ) ) {
7376 if ( p.hasNext() ) {
7380 if ( phy != null ) {
7385 if ( !p.hasNext() ) {
7389 if ( phy == null ) {
7392 if ( phy.getNumberOfExternalNodes() != 10 ) {
7395 if ( !phy.getName().equals( "name" ) ) {
7398 if ( p.hasNext() ) {
7402 if ( phy != null ) {
7406 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_3.nex" );
7407 if ( !p.hasNext() ) {
7411 if ( phy == null ) {
7414 if ( phy.getNumberOfExternalNodes() != 3 ) {
7417 if ( !phy.getName().equals( "" ) ) {
7420 if ( phy.isRooted() ) {
7423 if ( p.hasNext() ) {
7427 if ( phy != null ) {
7432 if ( !p.hasNext() ) {
7436 if ( phy == null ) {
7439 if ( phy.getNumberOfExternalNodes() != 3 ) {
7442 if ( !phy.getName().equals( "" ) ) {
7445 if ( p.hasNext() ) {
7449 if ( phy != null ) {
7453 p.setSource( Test.PATH_TO_TEST_DATA + "nexus_test_4_1.nex" );
7454 if ( !p.hasNext() ) {
7459 if ( phy == null ) {
7462 if ( phy.getNumberOfExternalNodes() != 10 ) {
7465 if ( !phy.getName().equals( "tree 0" ) ) {
7469 if ( !p.hasNext() ) {
7473 if ( phy == null ) {
7476 if ( phy.getNumberOfExternalNodes() != 10 ) {
7479 if ( !phy.getName().equals( "tree 1" ) ) {
7483 if ( !p.hasNext() ) {
7487 if ( phy == null ) {
7490 if ( phy.getNumberOfExternalNodes() != 3 ) {
7491 System.out.println( phy.toString() );
7494 if ( !phy.getName().equals( "" ) ) {
7497 if ( phy.isRooted() ) {
7501 if ( !p.hasNext() ) {
7505 if ( phy == null ) {
7508 if ( phy.getNumberOfExternalNodes() != 4 ) {
7511 if ( !phy.getName().equals( "" ) ) {
7514 if ( !phy.isRooted() ) {
7518 if ( !p.hasNext() ) {
7522 if ( phy == null ) {
7525 if ( phy.getNumberOfExternalNodes() != 5 ) {
7526 System.out.println( phy.getNumberOfExternalNodes() );
7529 if ( !phy.getName().equals( "" ) ) {
7532 if ( !phy.isRooted() ) {
7536 if ( !p.hasNext() ) {
7540 if ( phy == null ) {
7543 if ( phy.getNumberOfExternalNodes() != 3 ) {
7546 if ( !phy.getName().equals( "" ) ) {
7549 if ( phy.isRooted() ) {
7553 if ( !p.hasNext() ) {
7557 if ( phy == null ) {
7560 if ( phy.getNumberOfExternalNodes() != 2 ) {
7563 if ( !phy.getName().equals( "" ) ) {
7566 if ( !phy.isRooted() ) {
7570 if ( !p.hasNext() ) {
7574 if ( phy.getNumberOfExternalNodes() != 3 ) {
7577 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7580 if ( !phy.isRooted() ) {
7584 if ( !p.hasNext() ) {
7588 if ( phy.getNumberOfExternalNodes() != 3 ) {
7591 if ( !phy.toNewHampshire().equals( "((AA,BB),CC);" ) ) {
7594 if ( !phy.getName().equals( "tree 8" ) ) {
7598 if ( !p.hasNext() ) {
7602 if ( phy.getNumberOfExternalNodes() != 3 ) {
7605 if ( !phy.toNewHampshire().equals( "((a,b),cc);" ) ) {
7608 if ( !phy.getName().equals( "tree 9" ) ) {
7612 if ( !p.hasNext() ) {
7616 if ( phy.getNumberOfExternalNodes() != 3 ) {
7619 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7622 if ( !phy.getName().equals( "tree 10" ) ) {
7625 if ( !phy.isRooted() ) {
7629 if ( !p.hasNext() ) {
7633 if ( phy.getNumberOfExternalNodes() != 3 ) {
7636 if ( !phy.toNewHampshire().equals( "((1,2),3);" ) ) {
7639 if ( !phy.getName().equals( "tree 11" ) ) {
7642 if ( phy.isRooted() ) {
7646 if ( !p.hasNext() ) {
7650 if ( phy.getNumberOfExternalNodes() != 3 ) {
7653 if ( !phy.toNewHampshire().equals( "((aa,bb),cc);" ) ) {
7656 if ( !phy.getName().equals( "tree 12" ) ) {
7659 if ( !phy.isRooted() ) {
7663 if ( !p.hasNext() ) {
7667 if ( phy.getNumberOfExternalNodes() != 3 ) {
7670 if ( !phy.toNewHampshire().equals( "((a,b),c);" ) ) {
7673 if ( !phy.getName().equals( "tree 13" ) ) {
7676 if ( !phy.isRooted() ) {
7680 if ( !p.hasNext() ) {
7684 if ( phy.getNumberOfExternalNodes() != 10 ) {
7685 System.out.println( phy.getNumberOfExternalNodes() );
7690 .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;" ) ) {
7691 System.out.println( phy.toNewHampshire() );
7694 if ( !phy.getName().equals( "tree 14" ) ) {
7697 if ( !phy.isRooted() ) {
7701 if ( !p.hasNext() ) {
7705 if ( phy.getNumberOfExternalNodes() != 10 ) {
7706 System.out.println( phy.getNumberOfExternalNodes() );
7711 .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;" ) ) {
7712 System.out.println( phy.toNewHampshire() );
7715 if ( !phy.getName().equals( "tree 15" ) ) {
7718 if ( phy.isRooted() ) {
7722 if ( !p.hasNext() ) {
7726 if ( phy.getNumberOfExternalNodes() != 10 ) {
7727 System.out.println( phy.getNumberOfExternalNodes() );
7732 .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;" ) ) {
7733 System.out.println( phy.toNewHampshire() );
7736 if ( !phy.getName().equals( "tree 16" ) ) {
7739 if ( !phy.isRooted() ) {
7743 if ( !p.hasNext() ) {
7747 if ( phy.getNumberOfExternalNodes() != 10 ) {
7748 System.out.println( phy.getNumberOfExternalNodes() );
7753 .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;" ) ) {
7754 System.out.println( phy.toNewHampshire() );
7757 if ( !phy.getName().equals( "tree 17" ) ) {
7760 if ( phy.isRooted() ) {
7764 if ( p.hasNext() ) {
7768 if ( phy != null ) {
7773 if ( !p.hasNext() ) {
7777 if ( phy == null ) {
7780 if ( phy.getNumberOfExternalNodes() != 10 ) {
7783 if ( !phy.getName().equals( "tree 0" ) ) {
7787 if ( !p.hasNext() ) {
7791 if ( phy == null ) {
7794 if ( phy.getNumberOfExternalNodes() != 10 ) {
7797 if ( !phy.getName().equals( "tree 1" ) ) {
7801 if ( !p.hasNext() ) {
7805 if ( phy == null ) {
7808 if ( phy.getNumberOfExternalNodes() != 3 ) {
7811 if ( !phy.getName().equals( "" ) ) {
7814 if ( phy.isRooted() ) {
7818 if ( !p.hasNext() ) {
7822 if ( phy == null ) {
7825 if ( phy.getNumberOfExternalNodes() != 4 ) {
7828 if ( !phy.getName().equals( "" ) ) {
7831 if ( !phy.isRooted() ) {
7835 if ( !p.hasNext() ) {
7839 if ( phy == null ) {
7842 if ( phy.getNumberOfExternalNodes() != 5 ) {
7843 System.out.println( phy.getNumberOfExternalNodes() );
7846 if ( !phy.getName().equals( "" ) ) {
7849 if ( !phy.isRooted() ) {
7853 if ( !p.hasNext() ) {
7857 if ( phy == null ) {
7860 if ( phy.getNumberOfExternalNodes() != 3 ) {
7863 if ( !phy.getName().equals( "" ) ) {
7866 if ( phy.isRooted() ) {
7870 final NexusPhylogeniesParser p2 = new NexusPhylogeniesParser();
7871 p2.setSource( Test.PATH_TO_TEST_DATA + "S15613.nex" );
7873 if ( !p2.hasNext() ) {
7877 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7880 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7884 if ( !p2.hasNext() ) {
7889 if ( !p2.hasNext() ) {
7894 if ( !p2.hasNext() ) {
7899 if ( !p2.hasNext() ) {
7904 if ( !p2.hasNext() ) {
7909 if ( !p2.hasNext() ) {
7914 if ( !p2.hasNext() ) {
7919 if ( !p2.hasNext() ) {
7923 if ( !isEqual( 0.065284, phy.getNode( "Bradysia_amoena" ).getDistanceToParent() ) ) {
7926 if ( p2.hasNext() ) {
7930 if ( phy != null ) {
7935 if ( !p2.hasNext() ) {
7939 if ( !isEqual( 0.48039661496919533, phy.getNode( "Diadocidia_spinosula" ).getDistanceToParent() ) ) {
7942 if ( !isEqual( 0.3959796191512233, phy.getNode( "Diadocidia_stanfordensis" ).getDistanceToParent() ) ) {
7946 catch ( final Exception e ) {
7947 e.printStackTrace( System.out );
7953 private static boolean testNexusTreeParsingTranslating() {
7955 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
7956 final NexusPhylogeniesParser parser = new NexusPhylogeniesParser();
7957 Phylogeny[] phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_5.nex", parser );
7958 if ( phylogenies.length != 1 ) {
7961 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7964 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7967 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7970 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7973 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7974 .equals( "Aranaeus" ) ) {
7978 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_6.nex", parser );
7979 if ( phylogenies.length != 3 ) {
7982 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
7985 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
7988 if ( phylogenies[ 0 ].isRooted() ) {
7991 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
7994 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
7997 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
7998 .equals( "Aranaeus" ) ) {
8001 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8004 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8007 if ( phylogenies[ 1 ].isRooted() ) {
8010 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8013 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8016 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8017 .equals( "Aranaeus" ) ) {
8020 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8023 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8026 if ( !phylogenies[ 2 ].isRooted() ) {
8029 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8032 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8035 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8036 .equals( "Aranaeus" ) ) {
8040 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "nexus_test_7.nex", parser );
8041 if ( phylogenies.length != 3 ) {
8044 if ( phylogenies[ 0 ].getNumberOfExternalNodes() != 3 ) {
8047 if ( !phylogenies[ 0 ].getName().equals( "Tree0" ) ) {
8050 if ( phylogenies[ 0 ].isRooted() ) {
8053 if ( !phylogenies[ 0 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8056 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8059 if ( !phylogenies[ 0 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8060 .equals( "Aranaeus" ) ) {
8063 if ( phylogenies[ 1 ].getNumberOfExternalNodes() != 3 ) {
8066 if ( !phylogenies[ 1 ].getName().equals( "Tree1" ) ) {
8069 if ( phylogenies[ 1 ].isRooted() ) {
8072 if ( !phylogenies[ 1 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8075 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8078 if ( !phylogenies[ 1 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8079 .equals( "Aranaeus" ) ) {
8082 if ( phylogenies[ 2 ].getNumberOfExternalNodes() != 3 ) {
8085 if ( !phylogenies[ 2 ].getName().equals( "Tree2" ) ) {
8088 if ( !phylogenies[ 2 ].isRooted() ) {
8091 if ( !phylogenies[ 2 ].getFirstExternalNode().getName().equals( "Scarabaeus" ) ) {
8094 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getName().equals( "Drosophila" ) ) {
8097 if ( !phylogenies[ 2 ].getFirstExternalNode().getNextExternalNode().getNextExternalNode().getName()
8098 .equals( "Aranaeus" ) ) {
8101 phylogenies = factory.create( Test.PATH_TO_TEST_DATA + "S14117.nex", parser );
8102 if ( phylogenies.length != 3 ) {
8105 if ( !isEqual( phylogenies[ 2 ].getNode( "Aloysia lycioides 251-76-02169" ).getDistanceToParent(),
8110 catch ( final Exception e ) {
8111 e.printStackTrace( System.out );
8117 private static boolean testNHParsing() {
8119 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
8120 final Phylogeny p1 = factory.create( "(A,B1)", new NHXParser() )[ 0 ];
8121 if ( !p1.toNewHampshireX().equals( "(A,B1)" ) ) {
8124 final NHXParser nhxp = new NHXParser();
8125 nhxp.setTaxonomyExtraction( NHXParser.TAXONOMY_EXTRACTION.NO );
8126 nhxp.setReplaceUnderscores( true );
8127 final Phylogeny uc0 = factory.create( "(A__A_,_B_B)", nhxp )[ 0 ];
8128 if ( !uc0.getRoot().getChildNode( 0 ).getName().equals( "A A" ) ) {
8131 if ( !uc0.getRoot().getChildNode( 1 ).getName().equals( "B B" ) ) {
8134 final Phylogeny p1b = factory
8135 .create( " \n \t \b \r \f ; ( \n \t \b \r \f; A ; \n \t \b \r \f, \n \t \b \r \f; B ; \n \t \b \r \f 1 \n \t \b \r \f ; \n \t \b \r \f );;;;; \n \t \b \r \f;;; \n \t \b \r \f ",
8136 new NHXParser() )[ 0 ];
8137 if ( !p1b.toNewHampshireX().equals( "(';A;',';B;1;')" ) ) {
8140 if ( !p1b.toNewHampshire().equals( "(';A;',';B;1;');" ) ) {
8143 final Phylogeny p2 = factory.create( new StringBuffer( "(A,B2)" ), new NHXParser() )[ 0 ];
8144 final Phylogeny p3 = factory.create( new char[] { '(', 'A', ',', 'B', '3', ')' }, new NHXParser() )[ 0 ];
8145 final Phylogeny p4 = factory.create( "(A,B4);", new NHXParser() )[ 0 ];
8146 final Phylogeny p5 = factory.create( new StringBuffer( "(A,B5);" ), new NHXParser() )[ 0 ];
8147 final Phylogeny[] p7 = factory.create( "(A,B7);(C,D7)", new NHXParser() );
8148 final Phylogeny[] p8 = factory.create( "(A,B8) (C,D8)", new NHXParser() );
8149 final Phylogeny[] p9 = factory.create( "(A,B9)\n(C,D9)", new NHXParser() );
8150 final Phylogeny[] p10 = factory.create( "(A,B10);(C,D10);", new NHXParser() );
8151 final Phylogeny[] p11 = factory.create( "(A,B11);(C,D11) (E,F11)\t(G,H11)", new NHXParser() );
8152 final Phylogeny[] p12 = factory.create( "(A,B12) (C,D12) (E,F12) (G,H12)", new NHXParser() );
8153 final Phylogeny[] p13 = factory.create( " ; (;A; , ; B ; 1 3 ; \n)\t ( \n ;"
8154 + " C ; ,; D;13;);;;;;;(;E;,;F;13 ;) ; "
8155 + "; ; ( \t\n\r\b; G ;, ;H ;1 3; ) ; ; ;",
8157 if ( !p13[ 0 ].toNewHampshireX().equals( "(';A;',';B;13;')" ) ) {
8160 if ( !p13[ 1 ].toNewHampshireX().equals( "(';C;',';D;13;')" ) ) {
8163 if ( !p13[ 2 ].toNewHampshireX().equals( "(';E;',';F;13;')" ) ) {
8166 if ( !p13[ 3 ].toNewHampshireX().equals( "(';G;',';H;13;')" ) ) {
8169 final Phylogeny[] p14 = factory.create( "(A,B14)ab", new NHXParser() );
8170 final Phylogeny[] p15 = factory.create( "(A,B15)ab;", new NHXParser() );
8171 final String p16_S = "((A,B),C)";
8172 final Phylogeny[] p16 = factory.create( p16_S, new NHXParser() );
8173 if ( p16.length != 1 ) {
8176 if ( !p16[ 0 ].toNewHampshireX().equals( p16_S ) ) {
8179 final String p17_S = "(C,(A,B))";
8180 final Phylogeny[] p17 = factory.create( p17_S, new NHXParser() );
8181 if ( p17.length != 1 ) {
8184 if ( !p17[ 0 ].toNewHampshireX().equals( p17_S ) ) {
8187 final String p18_S = "((A,B),(C,D))";
8188 final Phylogeny[] p18 = factory.create( p18_S, new NHXParser() );
8189 if ( p18.length != 1 ) {
8192 if ( !p18[ 0 ].toNewHampshireX().equals( p18_S ) ) {
8195 final String p19_S = "(((A,B),C),D)";
8196 final Phylogeny[] p19 = factory.create( p19_S, new NHXParser() );
8197 if ( p19.length != 1 ) {
8200 if ( !p19[ 0 ].toNewHampshireX().equals( p19_S ) ) {
8203 final String p20_S = "(A,(B,(C,D)))";
8204 final Phylogeny[] p20 = factory.create( p20_S, new NHXParser() );
8205 if ( p20.length != 1 ) {
8208 if ( !p20[ 0 ].toNewHampshireX().equals( p20_S ) ) {
8211 final String p21_S = "(A,(B,(C,(D,E))))";
8212 final Phylogeny[] p21 = factory.create( p21_S, new NHXParser() );
8213 if ( p21.length != 1 ) {
8216 if ( !p21[ 0 ].toNewHampshireX().equals( p21_S ) ) {
8219 final String p22_S = "((((A,B),C),D),E)";
8220 final Phylogeny[] p22 = factory.create( p22_S, new NHXParser() );
8221 if ( p22.length != 1 ) {
8224 if ( !p22[ 0 ].toNewHampshireX().equals( p22_S ) ) {
8227 final String p23_S = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8228 final Phylogeny[] p23 = factory.create( p23_S, new NHXParser() );
8229 if ( p23.length != 1 ) {
8230 System.out.println( "xl=" + p23.length );
8234 if ( !p23[ 0 ].toNewHampshireX().equals( p23_S ) ) {
8237 final String p24_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8238 final Phylogeny[] p24 = factory.create( p24_S, new NHXParser() );
8239 if ( p24.length != 1 ) {
8242 if ( !p24[ 0 ].toNewHampshireX().equals( p24_S ) ) {
8245 final String p241_S1 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8246 final String p241_S2 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8247 final Phylogeny[] p241 = factory.create( p241_S1 + p241_S2, new NHXParser() );
8248 if ( p241.length != 2 ) {
8251 if ( !p241[ 0 ].toNewHampshireX().equals( p241_S1 ) ) {
8254 if ( !p241[ 1 ].toNewHampshireX().equals( p241_S2 ) ) {
8257 final String p25_S = "((((((((((((((A,B)ab,C)abc,D)abcd,E)"
8258 + "abcde,(B,(C,(D,E)de)cde)bcde)abcde,(B,((A,(B,(C,(D,"
8259 + "E)de)cde)bcde)abcde,(D,E)de)cde)bcde)abcde,B)ab,C)"
8260 + "abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde,"
8261 + "((((A,((((((((A,B)ab,C)abc,((((A,B)ab,C)abc,D)abcd,"
8262 + "E)abcde)abcd,E)abcde,((((A,B)ab,C)abc,D)abcd,E)abcde)"
8263 + "ab,C)abc,((((A,B)ab,C)abc,D)abcd,E)abcde)abcd,E)abcde"
8264 + ")ab,C)abc,D)abcd,E)abcde)ab,C)abc,((((A,B)ab,C)abc,D)" + "abcd,E)abcde)abcd,E)abcde";
8265 final Phylogeny[] p25 = factory.create( p25_S, new NHXParser() );
8266 if ( !p25[ 0 ].toNewHampshireX().equals( p25_S ) ) {
8269 final String p26_S = "(A,B)ab";
8270 final Phylogeny[] p26 = factory.create( p26_S, new NHXParser() );
8271 if ( !p26[ 0 ].toNewHampshireX().equals( p26_S ) ) {
8274 final String p27_S = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8275 final Phylogeny[] p27s = factory.create( p27_S, new NHXParser() );
8276 if ( p27s.length != 1 ) {
8277 System.out.println( "xxl=" + p27s.length );
8281 if ( !p27s[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8282 System.out.println( p27s[ 0 ].toNewHampshireX() );
8286 final Phylogeny[] p27 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ),
8288 if ( p27.length != 1 ) {
8289 System.out.println( "yl=" + p27.length );
8293 if ( !p27[ 0 ].toNewHampshireX().equals( p27_S ) ) {
8294 System.out.println( p27[ 0 ].toNewHampshireX() );
8298 final String p28_S1 = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8299 final String p28_S2 = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8300 final String p28_S3 = "(A,B)ab";
8301 final String p28_S4 = "((((A,B),C),D),;E;)";
8302 final Phylogeny[] p28 = factory.create( new File( Test.PATH_TO_TEST_DATA + "phylogeny28.nhx" ),
8304 if ( !p28[ 0 ].toNewHampshireX().equals( p28_S1 ) ) {
8307 if ( !p28[ 1 ].toNewHampshireX().equals( p28_S2 ) ) {
8310 if ( !p28[ 2 ].toNewHampshireX().equals( p28_S3 ) ) {
8313 if ( !p28[ 3 ].toNewHampshireX().equals( "((((A,B),C),D),';E;')" ) ) {
8316 if ( p28.length != 4 ) {
8319 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";
8320 final Phylogeny[] p29 = factory.create( p29_S, new NHXParser() );
8321 if ( !p29[ 0 ].toNewHampshireX().equals( p29_S ) ) {
8324 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";
8325 final Phylogeny[] p30 = factory.create( p30_S, new NHXParser() );
8326 if ( !p30[ 0 ].toNewHampshireX().equals( p30_S ) ) {
8329 final String p32_S = " ; ; \n \t \b \f \r ;;;;;; ";
8330 final Phylogeny[] p32 = factory.create( p32_S, new NHXParser() );
8331 if ( ( p32.length != 0 ) ) {
8334 final String p33_S = "A";
8335 final Phylogeny[] p33 = factory.create( p33_S, new NHXParser() );
8336 if ( !p33[ 0 ].toNewHampshireX().equals( p33_S ) ) {
8339 final String p34_S = "B;";
8340 final Phylogeny[] p34 = factory.create( p34_S, new NHXParser() );
8341 if ( !p34[ 0 ].toNewHampshireX().equals( "B" ) ) {
8344 final String p35_S = "B:0.2";
8345 final Phylogeny[] p35 = factory.create( p35_S, new NHXParser() );
8346 if ( !p35[ 0 ].toNewHampshireX().equals( p35_S ) ) {
8349 final String p36_S = "(A)";
8350 final Phylogeny[] p36 = factory.create( p36_S, new NHXParser() );
8351 if ( !p36[ 0 ].toNewHampshireX().equals( p36_S ) ) {
8354 final String p37_S = "((A))";
8355 final Phylogeny[] p37 = factory.create( p37_S, new NHXParser() );
8356 if ( !p37[ 0 ].toNewHampshireX().equals( p37_S ) ) {
8359 final String p38_S = "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8360 final Phylogeny[] p38 = factory.create( p38_S, new NHXParser() );
8361 if ( !p38[ 0 ].toNewHampshireX().equals( p38_S ) ) {
8364 final String p39_S = "(((B,((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8";
8365 final Phylogeny[] p39 = factory.create( p39_S, new NHXParser() );
8366 if ( !p39[ 0 ].toNewHampshireX().equals( p39_S ) ) {
8369 final String p40_S = "(A,B,C)";
8370 final Phylogeny[] p40 = factory.create( p40_S, new NHXParser() );
8371 if ( !p40[ 0 ].toNewHampshireX().equals( p40_S ) ) {
8374 final String p41_S = "(A,B,C,D,E,F,G,H,I,J,K)";
8375 final Phylogeny[] p41 = factory.create( p41_S, new NHXParser() );
8376 if ( !p41[ 0 ].toNewHampshireX().equals( p41_S ) ) {
8379 final String p42_S = "(A,B,(X,Y,Z),D,E,F,G,H,I,J,K)";
8380 final Phylogeny[] p42 = factory.create( p42_S, new NHXParser() );
8381 if ( !p42[ 0 ].toNewHampshireX().equals( p42_S ) ) {
8384 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)";
8385 final Phylogeny[] p43 = factory.create( p43_S, new NHXParser() );
8386 if ( !p43[ 0 ].toNewHampshireX().equals( p43_S ) ) {
8389 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)))";
8390 final Phylogeny[] p44 = factory.create( p44_S, new NHXParser() );
8391 if ( !p44[ 0 ].toNewHampshireX().equals( p44_S ) ) {
8394 final String p45_S = "((((((((((A))))))))),(((((((((B))))))))),(((((((((C))))))))))";
8395 final Phylogeny[] p45 = factory.create( p45_S, new NHXParser() );
8396 if ( !p45[ 0 ].toNewHampshireX().equals( p45_S ) ) {
8399 final String p46_S = "";
8400 final Phylogeny[] p46 = factory.create( p46_S, new NHXParser() );
8401 if ( p46.length != 0 ) {
8404 final Phylogeny p47 = factory.create( new StringBuffer( "((A,B)ab:2[0.44],C)" ), new NHXParser() )[ 0 ];
8405 if ( !isEqual( 0.44, p47.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8408 final Phylogeny p48 = factory.create( new StringBuffer( "((A,B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8409 if ( !isEqual( 88, p48.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8412 final Phylogeny p49 = factory
8413 .create( new StringBuffer( "((A,B)a[comment:a,b;(a)]b:2[0.44][comment(a,b,b);],C)" ),
8414 new NHXParser() )[ 0 ];
8415 if ( !isEqual( 0.44, p49.getNode( "ab" ).getBranchData().getConfidence( 0 ).getValue() ) ) {
8418 final Phylogeny p50 = factory.create( new StringBuffer( "((\"A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8419 if ( p50.getNode( "A" ) == null ) {
8422 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8423 .equals( "((A,B)ab:2.0[88],C);" ) ) {
8426 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.NONE ).equals( "((A,B)ab:2.0,C);" ) ) {
8429 if ( !p50.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES )
8430 .equals( "((A,B)88:2.0,C);" ) ) {
8433 final Phylogeny p51 = factory.create( new StringBuffer( "((\"A(A\",B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8434 if ( p51.getNode( "A(A" ) == null ) {
8437 final Phylogeny p52 = factory.create( new StringBuffer( "(('A(A',B)ab:2[88],C)" ), new NHXParser() )[ 0 ];
8438 if ( p52.getNode( "A(A" ) == null ) {
8441 final Phylogeny p53 = factory
8442 .create( new StringBuffer( "(('A(A',\"B (x (a' ,b) f(x);\"[com])[ment]ab:2[88],C)" ),
8443 new NHXParser() )[ 0 ];
8444 if ( p53.getNode( "B (x (a' ,b) f(x);" ) == null ) {
8447 final Phylogeny p54 = factory.create( new StringBuffer( "((A,B):[88],C)" ), new NHXParser() )[ 0 ];
8448 if ( p54.getNode( "A" ) == null ) {
8451 if ( !p54.toNewHampshire( NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ).equals( "((A,B)[88],C);" ) ) {
8454 final Phylogeny p55 = factory
8455 .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);" ),
8456 new NHXParser() )[ 0 ];
8459 .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);" ) ) {
8460 System.out.println( p55.toNewHampshire() );
8463 final Phylogeny p56 = factory
8464 .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);" ),
8465 new NHXParser() )[ 0 ];
8468 .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);" ) ) {
8469 System.out.println( p56.toNewHampshire() );
8472 final Phylogeny p57 = factory
8473 .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);" ),
8474 new NHXParser() )[ 0 ];
8477 .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);" ) ) {
8478 System.out.println( p56.toNewHampshire() );
8481 final String s58 = "('Homo \"man\" sapiens:1',\"Homo 'man' sapiens;\")';root \"1_ )';";
8482 final Phylogeny p58 = factory.create( new StringBuffer( s58 ), new NHXParser() )[ 0 ];
8483 if ( !p58.toNewHampshire().equals( s58 ) ) {
8484 System.out.println( p58.toNewHampshire() );
8487 final String s59 = "('Homo \"man sapiens:1',\"Homo 'man sapiens\")\"root; '1_ )\";";
8488 final Phylogeny p59 = factory.create( new StringBuffer( s59 ), new NHXParser() )[ 0 ];
8489 if ( !p59.toNewHampshire().equals( s59 ) ) {
8490 System.out.println( p59.toNewHampshire() );
8493 final String s60 = "('\" ;,:\":\"',\"'abc def' g's_\",'=:0.45+,.:%~`!@#$%^&*()_-+={} | ;,');";
8494 final Phylogeny p60 = factory.create( new StringBuffer( s60 ), new NHXParser() )[ 0 ];
8495 if ( !p60.toNewHampshire().equals( s60 ) ) {
8496 System.out.println( p60.toNewHampshire() );
8499 final String s61 = "('H[omo] \"man\" sapiens:1',\"H[omo] 'man' sapiens;\",H[omo] sapiens)';root \"1_ )';";
8500 final Phylogeny p61 = factory.create( new StringBuffer( s61 ), new NHXParser() )[ 0 ];
8501 if ( !p61.toNewHampshire()
8502 .equals( "('H{omo} \"man\" sapiens:1',\"H{omo} 'man' sapiens;\",Hsapiens)';root \"1_ )';" ) ) {
8503 System.out.println( p61.toNewHampshire() );
8507 catch ( final Exception e ) {
8508 e.printStackTrace( System.out );
8514 private static boolean testNHParsingIter() {
8516 final String p0_str = "(A,B);";
8517 final NHXParser p = new NHXParser();
8518 p.setSource( p0_str );
8519 if ( !p.hasNext() ) {
8522 final Phylogeny p0 = p.next();
8523 if ( !p0.toNewHampshire().equals( p0_str ) ) {
8524 System.out.println( p0.toNewHampshire() );
8527 if ( p.hasNext() ) {
8530 if ( p.next() != null ) {
8534 final String p00_str = "(A,B)root;";
8535 p.setSource( p00_str );
8536 final Phylogeny p00 = p.next();
8537 if ( !p00.toNewHampshire().equals( p00_str ) ) {
8538 System.out.println( p00.toNewHampshire() );
8542 final String p000_str = "A;";
8543 p.setSource( p000_str );
8544 final Phylogeny p000 = p.next();
8545 if ( !p000.toNewHampshire().equals( p000_str ) ) {
8546 System.out.println( p000.toNewHampshire() );
8550 final String p0000_str = "A";
8551 p.setSource( p0000_str );
8552 final Phylogeny p0000 = p.next();
8553 if ( !p0000.toNewHampshire().equals( "A;" ) ) {
8554 System.out.println( p0000.toNewHampshire() );
8558 p.setSource( "(A)" );
8559 final Phylogeny p00000 = p.next();
8560 if ( !p00000.toNewHampshire().equals( "(A);" ) ) {
8561 System.out.println( p00000.toNewHampshire() );
8565 final String p1_str = "(A,B)(C,D)(E,F)(G,H)";
8566 p.setSource( p1_str );
8567 if ( !p.hasNext() ) {
8570 final Phylogeny p1_0 = p.next();
8571 if ( !p1_0.toNewHampshire().equals( "(A,B);" ) ) {
8572 System.out.println( p1_0.toNewHampshire() );
8575 if ( !p.hasNext() ) {
8578 final Phylogeny p1_1 = p.next();
8579 if ( !p1_1.toNewHampshire().equals( "(C,D);" ) ) {
8580 System.out.println( "(C,D) != " + p1_1.toNewHampshire() );
8583 if ( !p.hasNext() ) {
8586 final Phylogeny p1_2 = p.next();
8587 if ( !p1_2.toNewHampshire().equals( "(E,F);" ) ) {
8588 System.out.println( "(E,F) != " + p1_2.toNewHampshire() );
8591 if ( !p.hasNext() ) {
8594 final Phylogeny p1_3 = p.next();
8595 if ( !p1_3.toNewHampshire().equals( "(G,H);" ) ) {
8596 System.out.println( "(G,H) != " + p1_3.toNewHampshire() );
8599 if ( p.hasNext() ) {
8602 if ( p.next() != null ) {
8606 final String p2_str = "((1,2,3),B);(C,D) (E,F)root;(G,H); ;(X)";
8607 p.setSource( p2_str );
8608 if ( !p.hasNext() ) {
8611 Phylogeny p2_0 = p.next();
8612 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8613 System.out.println( p2_0.toNewHampshire() );
8616 if ( !p.hasNext() ) {
8619 Phylogeny p2_1 = p.next();
8620 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8621 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8624 if ( !p.hasNext() ) {
8627 Phylogeny p2_2 = p.next();
8628 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8629 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8632 if ( !p.hasNext() ) {
8635 Phylogeny p2_3 = p.next();
8636 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8637 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8640 if ( !p.hasNext() ) {
8643 Phylogeny p2_4 = p.next();
8644 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8645 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8648 if ( p.hasNext() ) {
8651 if ( p.next() != null ) {
8656 if ( !p.hasNext() ) {
8660 if ( !p2_0.toNewHampshire().equals( "((1,2,3),B);" ) ) {
8661 System.out.println( p2_0.toNewHampshire() );
8664 if ( !p.hasNext() ) {
8668 if ( !p2_1.toNewHampshire().equals( "(C,D);" ) ) {
8669 System.out.println( "(C,D) != " + p2_1.toNewHampshire() );
8672 if ( !p.hasNext() ) {
8676 if ( !p2_2.toNewHampshire().equals( "(E,F)root;" ) ) {
8677 System.out.println( "(E,F)root != " + p2_2.toNewHampshire() );
8680 if ( !p.hasNext() ) {
8684 if ( !p2_3.toNewHampshire().equals( "(G,H);" ) ) {
8685 System.out.println( "(G,H) != " + p2_3.toNewHampshire() );
8688 if ( !p.hasNext() ) {
8692 if ( !p2_4.toNewHampshire().equals( "(X);" ) ) {
8693 System.out.println( "(X) != " + p2_4.toNewHampshire() );
8696 if ( p.hasNext() ) {
8699 if ( p.next() != null ) {
8703 final String p3_str = "((A,B),C)abc";
8704 p.setSource( p3_str );
8705 if ( !p.hasNext() ) {
8708 final Phylogeny p3_0 = p.next();
8709 if ( !p3_0.toNewHampshire().equals( "((A,B),C)abc;" ) ) {
8712 if ( p.hasNext() ) {
8715 if ( p.next() != null ) {
8719 final String p4_str = "((A,B)ab,C)abc";
8720 p.setSource( p4_str );
8721 if ( !p.hasNext() ) {
8724 final Phylogeny p4_0 = p.next();
8725 if ( !p4_0.toNewHampshire().equals( "((A,B)ab,C)abc;" ) ) {
8728 if ( p.hasNext() ) {
8731 if ( p.next() != null ) {
8735 final String p5_str = "(((A,B)ab,C)abc,D)abcd";
8736 p.setSource( p5_str );
8737 if ( !p.hasNext() ) {
8740 final Phylogeny p5_0 = p.next();
8741 if ( !p5_0.toNewHampshire().equals( "(((A,B)ab,C)abc,D)abcd;" ) ) {
8744 if ( p.hasNext() ) {
8747 if ( p.next() != null ) {
8751 final String p6_str = "(A,(B,(C,(D,E)de)cde)bcde)abcde";
8752 p.setSource( p6_str );
8753 if ( !p.hasNext() ) {
8756 Phylogeny p6_0 = p.next();
8757 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8760 if ( p.hasNext() ) {
8763 if ( p.next() != null ) {
8767 if ( !p.hasNext() ) {
8771 if ( !p6_0.toNewHampshire().equals( "(A,(B,(C,(D,E)de)cde)bcde)abcde;" ) ) {
8774 if ( p.hasNext() ) {
8777 if ( p.next() != null ) {
8781 final String p7_str = "((((A,B)ab,C)abc,D)abcd,E)abcde";
8782 p.setSource( p7_str );
8783 if ( !p.hasNext() ) {
8786 Phylogeny p7_0 = p.next();
8787 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8790 if ( p.hasNext() ) {
8793 if ( p.next() != null ) {
8797 if ( !p.hasNext() ) {
8801 if ( !p7_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8804 if ( p.hasNext() ) {
8807 if ( p.next() != null ) {
8811 final String p8_str = "((((A,B)ab,C)abc,D)abcd,E)abcde ((((a,b)ab,c)abc,d)abcd,e)abcde";
8812 p.setSource( p8_str );
8813 if ( !p.hasNext() ) {
8816 Phylogeny p8_0 = p.next();
8817 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8820 if ( !p.hasNext() ) {
8823 if ( !p.hasNext() ) {
8826 Phylogeny p8_1 = p.next();
8827 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8830 if ( p.hasNext() ) {
8833 if ( p.next() != null ) {
8837 if ( !p.hasNext() ) {
8841 if ( !p8_0.toNewHampshire().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde;" ) ) {
8844 if ( !p.hasNext() ) {
8848 if ( !p8_1.toNewHampshire().equals( "((((a,b)ab,c)abc,d)abcd,e)abcde;" ) ) {
8851 if ( p.hasNext() ) {
8854 if ( p.next() != null ) {
8860 if ( p.hasNext() ) {
8864 p.setSource( new File( Test.PATH_TO_TEST_DATA + "phylogeny27.nhx" ) );
8865 if ( !p.hasNext() ) {
8868 Phylogeny p_27 = p.next();
8869 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8870 System.out.println( p_27.toNewHampshireX() );
8874 if ( p.hasNext() ) {
8877 if ( p.next() != null ) {
8881 if ( !p.hasNext() ) {
8885 if ( !p_27.toNewHampshireX().equals( "((((A,B)ab,C)abc,D)abcd,E)abcde" ) ) {
8886 System.out.println( p_27.toNewHampshireX() );
8890 if ( p.hasNext() ) {
8893 if ( p.next() != null ) {
8897 final String p30_str = "(A,B);(C,D)";
8898 final NHXParser p30 = new NHXParser();
8899 p30.setSource( p30_str );
8900 if ( !p30.hasNext() ) {
8903 Phylogeny phy30 = p30.next();
8904 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8905 System.out.println( phy30.toNewHampshire() );
8908 if ( !p30.hasNext() ) {
8911 Phylogeny phy301 = p30.next();
8912 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8913 System.out.println( phy301.toNewHampshire() );
8916 if ( p30.hasNext() ) {
8919 if ( p30.hasNext() ) {
8922 if ( p30.next() != null ) {
8925 if ( p30.next() != null ) {
8929 if ( !p30.hasNext() ) {
8933 if ( !phy30.toNewHampshire().equals( "(A,B);" ) ) {
8934 System.out.println( phy30.toNewHampshire() );
8937 if ( !p30.hasNext() ) {
8940 phy301 = p30.next();
8941 if ( !phy301.toNewHampshire().equals( "(C,D);" ) ) {
8942 System.out.println( phy301.toNewHampshire() );
8945 if ( p30.hasNext() ) {
8948 if ( p30.hasNext() ) {
8951 if ( p30.next() != null ) {
8954 if ( p30.next() != null ) {
8958 catch ( final Exception e ) {
8959 e.printStackTrace( System.out );
8965 private static boolean testNHXconversion() {
8967 final PhylogenyNode n1 = new PhylogenyNode();
8968 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
8969 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
8970 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
8971 final PhylogenyNode n5 = PhylogenyNode
8972 .createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:E=1.1.1.1:D=Y:Co=Y:B=56:T=1]" );
8973 final PhylogenyNode n6 = PhylogenyNode
8974 .createInstanceFromNhxString( "n6:0.000001[&&NHX:S=Ecoli:E=1.1.1.1:D=N:Co=N:B=100:T=1]" );
8975 if ( !n1.toNewHampshireX().equals( "" ) ) {
8978 if ( !n2.toNewHampshireX().equals( "" ) ) {
8981 if ( !n3.toNewHampshireX().equals( "n3" ) ) {
8984 if ( !n4.toNewHampshireX().equals( "n4:0.01" ) ) {
8987 if ( !n5.toNewHampshireX().equals( "n5:0.1[&&NHX:T=1:S=Ecoli:D=Y:B=56]" ) ) {
8990 if ( !n6.toNewHampshireX().equals( "n6:1.0E-6[&&NHX:T=1:S=Ecoli:D=N:B=100]" ) ) {
8991 System.out.println( n6.toNewHampshireX() );
8994 final PhylogenyNode n7 = new PhylogenyNode();
8995 n7.setName( " gks:dr-m4 \" ' `@:[]sadq04 " );
8996 if ( !n7.toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS )
8997 .equals( "'gks:dr-m4 \" ` `@:[]sadq04'" ) ) {
8998 System.out.println( n7
8999 .toNewHampshire( true, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ) );
9003 catch ( final Exception e ) {
9004 e.printStackTrace( System.out );
9010 private static boolean testNHXNodeParsing() {
9012 final PhylogenyNode n1 = new PhylogenyNode();
9013 final PhylogenyNode n2 = PhylogenyNode.createInstanceFromNhxString( "" );
9014 final PhylogenyNode n3 = PhylogenyNode.createInstanceFromNhxString( "n3" );
9015 final PhylogenyNode n4 = PhylogenyNode.createInstanceFromNhxString( "n4:0.01" );
9016 final PhylogenyNode n5 = PhylogenyNode
9017 .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]" );
9018 if ( !n3.getName().equals( "n3" ) ) {
9021 if ( n3.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9024 if ( n3.isDuplication() ) {
9027 if ( n3.isHasAssignedEvent() ) {
9030 if ( PhylogenyMethods.getBranchWidthValue( n3 ) != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) {
9033 if ( !n4.getName().equals( "n4" ) ) {
9036 if ( n4.getDistanceToParent() != 0.01 ) {
9039 if ( !n5.getName().equals( "n5" ) ) {
9042 if ( PhylogenyMethods.getConfidenceValue( n5 ) != 56 ) {
9045 if ( n5.getDistanceToParent() != 0.1 ) {
9048 if ( !PhylogenyMethods.getSpecies( n5 ).equals( "Ecoli" ) ) {
9051 if ( !n5.isDuplication() ) {
9054 if ( !n5.isHasAssignedEvent() ) {
9057 final PhylogenyNode n8 = PhylogenyNode
9058 .createInstanceFromNhxString( "ABCD_ECOLI/1-2:0.01",
9059 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9060 if ( !n8.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9063 if ( !PhylogenyMethods.getSpecies( n8 ).equals( "ECOLI" ) ) {
9066 final PhylogenyNode n9 = PhylogenyNode
9067 .createInstanceFromNhxString( "ABCD_ECOLI/1-12:0.01",
9068 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9069 if ( !n9.getName().equals( "ABCD_ECOLI/1-12" ) ) {
9072 if ( !PhylogenyMethods.getSpecies( n9 ).equals( "ECOLI" ) ) {
9075 final PhylogenyNode n10 = PhylogenyNode
9076 .createInstanceFromNhxString( "n10.ECOLI", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9077 if ( !n10.getName().equals( "n10.ECOLI" ) ) {
9080 final PhylogenyNode n20 = PhylogenyNode
9081 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9082 if ( !n20.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9085 if ( !PhylogenyMethods.getSpecies( n20 ).equals( "ECOLI" ) ) {
9088 final PhylogenyNode n20x = PhylogenyNode
9089 .createInstanceFromNhxString( "N20_ECOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9090 if ( !n20x.getName().equals( "N20_ECOL1/1-2" ) ) {
9093 if ( !PhylogenyMethods.getSpecies( n20x ).equals( "ECOL1" ) ) {
9096 final PhylogenyNode n20xx = PhylogenyNode
9097 .createInstanceFromNhxString( "N20_eCOL1/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9098 if ( !n20xx.getName().equals( "N20_eCOL1/1-2" ) ) {
9101 if ( PhylogenyMethods.getSpecies( n20xx ).length() > 0 ) {
9104 final PhylogenyNode n20xxx = PhylogenyNode
9105 .createInstanceFromNhxString( "n20_ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9106 if ( !n20xxx.getName().equals( "n20_ecoli/1-2" ) ) {
9109 if ( PhylogenyMethods.getSpecies( n20xxx ).length() > 0 ) {
9112 final PhylogenyNode n20xxxx = PhylogenyNode
9113 .createInstanceFromNhxString( "n20_Ecoli/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9114 if ( !n20xxxx.getName().equals( "n20_Ecoli/1-2" ) ) {
9117 if ( PhylogenyMethods.getSpecies( n20xxxx ).length() > 0 ) {
9120 final PhylogenyNode n21 = PhylogenyNode
9121 .createInstanceFromNhxString( "N21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9122 if ( !n21.getName().equals( "N21_PIG" ) ) {
9125 if ( !PhylogenyMethods.getSpecies( n21 ).equals( "PIG" ) ) {
9128 final PhylogenyNode n21x = PhylogenyNode
9129 .createInstanceFromNhxString( "n21_PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9130 if ( !n21x.getName().equals( "n21_PIG" ) ) {
9133 if ( PhylogenyMethods.getSpecies( n21x ).length() > 0 ) {
9136 final PhylogenyNode n22 = PhylogenyNode
9137 .createInstanceFromNhxString( "n22/PIG", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9138 if ( !n22.getName().equals( "n22/PIG" ) ) {
9141 if ( PhylogenyMethods.getSpecies( n22 ).length() > 0 ) {
9144 final PhylogenyNode n23 = PhylogenyNode
9145 .createInstanceFromNhxString( "n23/PIG_1", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9146 if ( !n23.getName().equals( "n23/PIG_1" ) ) {
9149 if ( PhylogenyMethods.getSpecies( n23 ).length() > 0 ) {
9152 final PhylogenyNode a = PhylogenyNode
9153 .createInstanceFromNhxString( "ABCD_ECOLI/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9154 if ( !a.getName().equals( "ABCD_ECOLI/1-2" ) ) {
9157 if ( !PhylogenyMethods.getSpecies( a ).equals( "ECOLI" ) ) {
9160 final PhylogenyNode c1 = PhylogenyNode
9161 .createInstanceFromNhxString( "n10_BOVIN/1000-2000",
9162 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9163 if ( !c1.getName().equals( "n10_BOVIN/1000-2000" ) ) {
9166 if ( !PhylogenyMethods.getSpecies( c1 ).equals( "BOVIN" ) ) {
9169 final PhylogenyNode c2 = PhylogenyNode
9170 .createInstanceFromNhxString( "N10_Bovin_1/1000-2000",
9171 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9172 if ( !c2.getName().equals( "N10_Bovin_1/1000-2000" ) ) {
9175 if ( PhylogenyMethods.getSpecies( c2 ).length() > 0 ) {
9178 final PhylogenyNode e3 = PhylogenyNode
9179 .createInstanceFromNhxString( "n10_RAT~", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9180 if ( !e3.getName().equals( "n10_RAT~" ) ) {
9183 if ( !PhylogenyMethods.getSpecies( e3 ).equals( "RAT" ) ) {
9186 final PhylogenyNode n11 = PhylogenyNode
9187 .createInstanceFromNhxString( "N111111_ECOLI/1-2:0.4",
9188 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9189 if ( !n11.getName().equals( "N111111_ECOLI/1-2" ) ) {
9192 if ( n11.getDistanceToParent() != 0.4 ) {
9195 if ( !PhylogenyMethods.getSpecies( n11 ).equals( "ECOLI" ) ) {
9198 final PhylogenyNode n12 = PhylogenyNode
9199 .createInstanceFromNhxString( "N111111-ECOLI---/jdj:0.4",
9200 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9201 if ( !n12.getName().equals( "N111111-ECOLI---/jdj" ) ) {
9204 if ( n12.getDistanceToParent() != 0.4 ) {
9207 if ( PhylogenyMethods.getSpecies( n12 ).length() > 0 ) {
9210 final PhylogenyNode o = PhylogenyNode
9211 .createInstanceFromNhxString( "ABCD_MOUSE", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9212 if ( !o.getName().equals( "ABCD_MOUSE" ) ) {
9215 if ( !PhylogenyMethods.getSpecies( o ).equals( "MOUSE" ) ) {
9218 if ( n1.getName().compareTo( "" ) != 0 ) {
9221 if ( PhylogenyMethods.getConfidenceValue( n1 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9224 if ( n1.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9227 if ( n2.getName().compareTo( "" ) != 0 ) {
9230 if ( PhylogenyMethods.getConfidenceValue( n2 ) != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
9233 if ( n2.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
9236 final PhylogenyNode n00 = PhylogenyNode
9237 .createInstanceFromNhxString( "n7:0.000001[&&NHX:GN=gene_name:AC=accession123:S=Ecoli:D=N:Co=N:B=100:T=1]" );
9238 if ( !n00.getNodeData().getSequence().getName().equals( "gene_name" ) ) {
9241 if ( !n00.getNodeData().getSequence().getAccession().getValue().equals( "accession123" ) ) {
9244 final PhylogenyNode nx = PhylogenyNode.createInstanceFromNhxString( "n5:0.1[&&NHX:S=Ecoli:GN=gene_1]" );
9245 if ( !nx.getNodeData().getSequence().getName().equals( "gene_1" ) ) {
9248 final PhylogenyNode n13 = PhylogenyNode
9249 .createInstanceFromNhxString( "BLAH_12345/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9250 if ( !n13.getName().equals( "BLAH_12345/1-2" ) ) {
9253 if ( PhylogenyMethods.getSpecies( n13 ).equals( "12345" ) ) {
9256 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9259 if ( !n13.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9262 final PhylogenyNode n14 = PhylogenyNode
9263 .createInstanceFromNhxString( "BLA1_9QX45/1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9264 if ( !n14.getName().equals( "BLA1_9QX45/1-2" ) ) {
9267 if ( !PhylogenyMethods.getSpecies( n14 ).equals( "9QX45" ) ) {
9270 final PhylogenyNode n15 = PhylogenyNode
9271 .createInstanceFromNhxString( "something_wicked[123]",
9272 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9273 if ( !n15.getName().equals( "something_wicked" ) ) {
9276 if ( n15.getBranchData().getNumberOfConfidences() != 1 ) {
9279 if ( !isEqual( n15.getBranchData().getConfidence( 0 ).getValue(), 123 ) ) {
9282 final PhylogenyNode n16 = PhylogenyNode
9283 .createInstanceFromNhxString( "something_wicked2[9]",
9284 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9285 if ( !n16.getName().equals( "something_wicked2" ) ) {
9288 if ( n16.getBranchData().getNumberOfConfidences() != 1 ) {
9291 if ( !isEqual( n16.getBranchData().getConfidence( 0 ).getValue(), 9 ) ) {
9294 final PhylogenyNode n17 = PhylogenyNode
9295 .createInstanceFromNhxString( "something_wicked3[a]",
9296 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9297 if ( !n17.getName().equals( "something_wicked3" ) ) {
9300 if ( n17.getBranchData().getNumberOfConfidences() != 0 ) {
9303 final PhylogenyNode n18 = PhylogenyNode
9304 .createInstanceFromNhxString( ":0.5[91]", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9305 if ( !isEqual( n18.getDistanceToParent(), 0.5 ) ) {
9308 if ( n18.getBranchData().getNumberOfConfidences() != 1 ) {
9311 if ( !isEqual( n18.getBranchData().getConfidence( 0 ).getValue(), 91 ) ) {
9314 final PhylogenyNode n19 = PhylogenyNode
9315 .createInstanceFromNhxString( "BLAH_1-roejojoej", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9316 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1" ) ) {
9319 if ( !n19.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9322 final PhylogenyNode n30 = PhylogenyNode
9323 .createInstanceFromNhxString( "BLAH_1234567-roejojoej",
9324 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9325 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "1234567" ) ) {
9328 if ( !n30.getNodeData().getTaxonomy().getIdentifier().getProvider().equals( "uniprot" ) ) {
9331 final PhylogenyNode n31 = PhylogenyNode
9332 .createInstanceFromNhxString( "BLAH_12345678-roejojoej",
9333 NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9334 if ( n31.getNodeData().isHasTaxonomy() ) {
9337 final PhylogenyNode n32 = PhylogenyNode
9338 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9339 if ( n32.getNodeData().isHasTaxonomy() ) {
9342 final PhylogenyNode n40 = PhylogenyNode
9343 .createInstanceFromNhxString( "BCL2_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9344 if ( !n40.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
9347 final PhylogenyNode n41 = PhylogenyNode
9348 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9349 if ( n41.getNodeData().isHasTaxonomy() ) {
9352 final PhylogenyNode n42 = PhylogenyNode
9353 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
9354 if ( n42.getNodeData().isHasTaxonomy() ) {
9357 final PhylogenyNode n43 = PhylogenyNode.createInstanceFromNhxString( "12345",
9358 NHXParser.TAXONOMY_EXTRACTION.NO );
9359 if ( n43.getNodeData().isHasTaxonomy() ) {
9362 final PhylogenyNode n44 = PhylogenyNode
9363 .createInstanceFromNhxString( "12345~1-2", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
9364 if ( n44.getNodeData().isHasTaxonomy() ) {
9368 catch ( final Exception e ) {
9369 e.printStackTrace( System.out );
9375 private static boolean testNHXParsing() {
9377 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9378 final Phylogeny p1 = factory.create( "(A [&&NHX:S=a_species],B1[&&NHX:S=b_species])", new NHXParser() )[ 0 ];
9379 if ( !p1.toNewHampshireX().equals( "(A[&&NHX:S=a_species],B1[&&NHX:S=b_species])" ) ) {
9382 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]";
9383 final Phylogeny[] p2 = factory.create( p2_S, new NHXParser() );
9384 if ( !p2[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9387 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]";
9388 final Phylogeny[] p2b = factory.create( p2b_S, new NHXParser() );
9389 if ( !p2b[ 0 ].toNewHampshireX().equals( "(((((((A:0.2):0.2):0.3):0.4):0.5):0.6):0.7):0.8" ) ) {
9392 final Phylogeny[] p3 = factory
9393 .create( "[ comment&&NHX,())))](((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq]",
9395 if ( !p3[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9398 final Phylogeny[] p4 = factory
9399 .create( "(((((((A:0.2[&&NHX:S=qwerty]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=asdf]):0.4[&&NHX:S=zxc]):0.5[&&NHX:S=a]):0.6[&&NHX:S=asd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(]",
9401 if ( !p4[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9404 final Phylogeny[] p5 = factory
9405 .create( "[] ( [][ ][ ] ([((( &&NHXcomment only![[[[[[]([]((((A:0.2[&&NHX:S=q[comment )))]werty][,,,,))]):0.2[&&NHX:S=uiop]):0.3[&&NHX:S=a[comment,,))]sdf])[comment(((]:0.4[&&NHX:S=zxc][comment(((][comment(((]):0.5[&&NHX:S=a]):0.6[&&NHX:S=a[comment(((]sd]):0.7[&&NHX:S=za]):0.8[&&NHX:S=zaq][comment(((]",
9407 if ( !p5[ 0 ].toNewHampshireX().equals( p2_S ) ) {
9410 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)";
9411 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)";
9412 final Phylogeny[] p6 = factory.create( p6_S_C, new NHXParser() );
9413 if ( !p6[ 0 ].toNewHampshireX().equals( p6_S_WO_C ) ) {
9416 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)))";
9417 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)))";
9418 final Phylogeny[] p7 = factory.create( p7_S_C, new NHXParser() );
9419 if ( !p7[ 0 ].toNewHampshireX().equals( p7_S_WO_C ) ) {
9422 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]) ))[,,, ])))))))";
9423 final String p8_S_WO_C = "((((((((((A[&&NHX:S=a]))))))))),(((((((((B[&&NHX:S=b]))))))))),(((((((((C[&&NHX:S=c]))))))))))";
9424 final Phylogeny[] p8 = factory.create( p8_S_C, new NHXParser() );
9425 if ( !p8[ 0 ].toNewHampshireX().equals( p8_S_WO_C ) ) {
9428 final Phylogeny p9 = factory.create( "((A:0.2,B:0.3):0.5[91],C:0.1)root:0.1[100]", new NHXParser() )[ 0 ];
9429 if ( !p9.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9432 final Phylogeny p10 = factory
9433 .create( " [79] ( (A [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
9434 new NHXParser() )[ 0 ];
9435 if ( !p10.toNewHampshireX().equals( "((A:0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9438 final Phylogeny p11 = factory
9439 .create( " [79] ( ('A: \" ' [co mment] :0 .2[comment],B:0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],C: 0.1)[comment]root:0.1[100] [comment]",
9440 new NHXParser() )[ 0 ];
9441 if ( !p11.toNewHampshireX().equals( "(('A: \"':0.2,B:0.3):0.5[&&NHX:B=91],C:0.1)root:0.1[&&NHX:B=100]" ) ) {
9445 catch ( final Exception e ) {
9446 e.printStackTrace( System.out );
9452 private static boolean testNHXParsingMB() {
9454 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9455 final Phylogeny p1 = factory.create( "(1[&prob=0.9500000000000000e+00,prob_stddev=0.1100000000000000e+00,"
9456 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9457 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9458 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9459 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9460 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9461 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9462 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9463 + "7.369400000000000e-02}])", new NHXParser() )[ 0 ];
9464 if ( !isEqual( p1.getNode( "1" ).getDistanceToParent(), 4.129e-02 ) ) {
9467 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getValue(), 0.9500000000000000e+00 ) ) {
9470 if ( !isEqual( p1.getNode( "1" ).getBranchData().getConfidence( 0 ).getStandardDeviation(),
9471 0.1100000000000000e+00 ) ) {
9474 if ( !isEqual( p1.getNode( "2" ).getDistanceToParent(), 6.375699999999999e-02 ) ) {
9477 if ( !isEqual( p1.getNode( "2" ).getBranchData().getConfidence( 0 ).getValue(), 0.810000000000000e+00 ) ) {
9480 final Phylogeny p2 = factory
9481 .create( "(1[something_else(?)s,prob=0.9500000000000000e+00{}(((,p)rob_stddev=0.110000000000e+00,"
9482 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9483 + "prob+-sd=\"100+-0\"]:4.129000000000000e-02[&length_mean=4.153987461671767e-02,"
9484 + "length_median=4.129000000000000e-02,length_95%HPD={3.217800000000000e-02,"
9485 + "5.026800000000000e-02}],2[&prob=0.810000000000000e+00,prob_stddev=0.000000000000000e+00,"
9486 + "prob_range={1.000000000000000e+00,1.000000000000000e+00},prob(percent)=\"100\","
9487 + "prob+-sd=\"100+-0\"]:6.375699999999999e-02[&length_mean=6.395210411945065e-02,"
9488 + "length_median=6.375699999999999e-02,length_95%HPD={5.388600000000000e-02,"
9489 + "7.369400000000000e-02}])",
9490 new NHXParser() )[ 0 ];
9491 if ( p2.getNode( "1" ) == null ) {
9494 if ( p2.getNode( "2" ) == null ) {
9498 catch ( final Exception e ) {
9499 e.printStackTrace( System.out );
9506 private static boolean testNHXParsingQuotes() {
9508 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9509 final NHXParser p = new NHXParser();
9510 final Phylogeny[] phylogenies_0 = factory.create( new File( Test.PATH_TO_TEST_DATA + "quotes.nhx" ), p );
9511 if ( phylogenies_0.length != 5 ) {
9514 final Phylogeny phy = phylogenies_0[ 4 ];
9515 if ( phy.getNumberOfExternalNodes() != 7 ) {
9518 if ( phy.getNodes( "a name in double quotes from tree ((a,b),c)" ).size() != 1 ) {
9521 if ( phy.getNodes( "charles darwin 'origin of species'" ).size() != 1 ) {
9524 if ( !phy.getNodes( "charles darwin 'origin of species'" ).get( 0 ).getNodeData().getTaxonomy()
9525 .getScientificName().equals( "hsapiens" ) ) {
9528 if ( phy.getNodes( "shouldbetogether single quotes" ).size() != 1 ) {
9531 if ( phy.getNodes( "'single quotes' inside double quotes" ).size() != 1 ) {
9534 if ( phy.getNodes( "\"double quotes\" inside single quotes" ).size() != 1 ) {
9537 if ( phy.getNodes( "noquotes" ).size() != 1 ) {
9540 if ( phy.getNodes( "A ( B C '" ).size() != 1 ) {
9543 final NHXParser p1p = new NHXParser();
9544 p1p.setIgnoreQuotes( true );
9545 final Phylogeny p1 = factory.create( "(\"A\",'B1')", p1p )[ 0 ];
9546 if ( !p1.toNewHampshire().equals( "(A,B1);" ) ) {
9549 final NHXParser p2p = new NHXParser();
9550 p1p.setIgnoreQuotes( false );
9551 final Phylogeny p2 = factory.create( "(\"A\",'B1')", p2p )[ 0 ];
9552 if ( !p2.toNewHampshire().equals( "(A,B1);" ) ) {
9555 final NHXParser p3p = new NHXParser();
9556 p3p.setIgnoreQuotes( false );
9557 final Phylogeny p3 = factory.create( "(\"A)\",'B1')", p3p )[ 0 ];
9558 if ( !p3.toNewHampshire().equals( "('A)',B1);" ) ) {
9561 final NHXParser p4p = new NHXParser();
9562 p4p.setIgnoreQuotes( false );
9563 final Phylogeny p4 = factory.create( "(\"A)\",'B(),; x')", p4p )[ 0 ];
9564 if ( !p4.toNewHampshire().equals( "('A)','B(),; x');" ) ) {
9567 final Phylogeny p10 = factory
9568 .create( " [79] ( (\"A \n\tB \" [co mment] :0 .2[comment],'B':0.3[com])[com ment]: 0. 5 \t[ 9 1 ][ comment],'C (or D?\\//;,))': 0.1)[comment]'\nroot is here (cool, was! ) ':0.1[100] [comment]",
9569 new NHXParser() )[ 0 ];
9570 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]";
9571 if ( !p10.toNewHampshireX().equals( p10_clean_str ) ) {
9574 final Phylogeny p11 = factory.create( p10.toNewHampshireX(), new NHXParser() )[ 0 ];
9575 if ( !p11.toNewHampshireX().equals( p10_clean_str ) ) {
9578 final Phylogeny p12 = factory
9579 .create( " [79] ( (\"A \n\tB \" [[][] :0 .2[comment][\t&\t&\n N\tH\tX:S=mo\tnkey !],'\tB\t\b\t\n\f\rB B ':0.0\b3[])\t[com ment]: 0. 5 \t[ 9 1 ][ \ncomment],'C\t (or D?\\//;,))': 0.\b1)[comment]'\nroot \tis here (cool, \b\t\n\f\r was! ) ':0.1[100] [comment]",
9580 new NHXParser() )[ 0 ];
9581 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]";
9582 if ( !p12.toNewHampshireX().equals( p12_clean_str ) ) {
9585 final Phylogeny p13 = factory.create( p12.toNewHampshireX(), new NHXParser() )[ 0 ];
9586 if ( !p13.toNewHampshireX().equals( p12_clean_str ) ) {
9589 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;";
9590 if ( !p13.toNewHampshire().equals( p12_clean_str_nh ) ) {
9593 final Phylogeny p14 = factory.create( p13.toNewHampshire(), new NHXParser() )[ 0 ];
9594 if ( !p14.toNewHampshire().equals( p12_clean_str_nh ) ) {
9598 catch ( final Exception e ) {
9599 e.printStackTrace( System.out );
9605 private static boolean testNodeRemoval() {
9607 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9608 final Phylogeny t0 = factory.create( "((a)b)", new NHXParser() )[ 0 ];
9609 PhylogenyMethods.removeNode( t0.getNode( "b" ), t0 );
9610 if ( !t0.toNewHampshire().equals( "(a);" ) ) {
9613 final Phylogeny t1 = factory.create( "((a:2)b:4)", new NHXParser() )[ 0 ];
9614 PhylogenyMethods.removeNode( t1.getNode( "b" ), t1 );
9615 if ( !t1.toNewHampshire().equals( "(a:6.0);" ) ) {
9618 final Phylogeny t2 = factory.create( "((a,b),c)", new NHXParser() )[ 0 ];
9619 PhylogenyMethods.removeNode( t2.getNode( "b" ), t2 );
9620 if ( !t2.toNewHampshire().equals( "((a),c);" ) ) {
9624 catch ( final Exception e ) {
9625 e.printStackTrace( System.out );
9631 private static boolean testPhylogenyBranch() {
9633 final PhylogenyNode a1 = PhylogenyNode.createInstanceFromNhxString( "a" );
9634 final PhylogenyNode b1 = PhylogenyNode.createInstanceFromNhxString( "b" );
9635 final PhylogenyBranch a1b1 = new PhylogenyBranch( a1, b1 );
9636 final PhylogenyBranch b1a1 = new PhylogenyBranch( b1, a1 );
9637 if ( !a1b1.equals( a1b1 ) ) {
9640 if ( !a1b1.equals( b1a1 ) ) {
9643 if ( !b1a1.equals( a1b1 ) ) {
9646 final PhylogenyBranch a1_b1 = new PhylogenyBranch( a1, b1, true );
9647 final PhylogenyBranch b1_a1 = new PhylogenyBranch( b1, a1, true );
9648 final PhylogenyBranch a1_b1_ = new PhylogenyBranch( a1, b1, false );
9649 if ( a1_b1.equals( b1_a1 ) ) {
9652 if ( a1_b1.equals( a1_b1_ ) ) {
9655 final PhylogenyBranch b1_a1_ = new PhylogenyBranch( b1, a1, false );
9656 if ( !a1_b1.equals( b1_a1_ ) ) {
9659 if ( a1_b1_.equals( b1_a1_ ) ) {
9662 if ( !a1_b1_.equals( b1_a1 ) ) {
9666 catch ( final Exception e ) {
9667 e.printStackTrace( System.out );
9673 private static boolean testPhyloXMLparsingOfDistributionElement() {
9675 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9676 PhyloXmlParser xml_parser = null;
9678 xml_parser = PhyloXmlParser.createPhyloXmlParserXsdValidating();
9680 catch ( final Exception e ) {
9681 // Do nothing -- means were not running from jar.
9683 if ( xml_parser == null ) {
9684 xml_parser = PhyloXmlParser.createPhyloXmlParser();
9685 if ( USE_LOCAL_PHYLOXML_SCHEMA ) {
9686 xml_parser.setValidateAgainstSchema( PHYLOXML_LOCAL_XSD );
9689 xml_parser.setValidateAgainstSchema( PHYLOXML_REMOTE_XSD );
9692 final Phylogeny[] phylogenies_0 = factory.create( Test.PATH_TO_TEST_DATA + "phyloxml_distribution.xml",
9694 if ( xml_parser.getErrorCount() > 0 ) {
9695 System.out.println( xml_parser.getErrorMessages().toString() );
9698 if ( phylogenies_0.length != 1 ) {
9701 final Phylogeny t1 = phylogenies_0[ 0 ];
9702 PhylogenyNode n = null;
9703 Distribution d = null;
9704 n = t1.getNode( "root node" );
9705 if ( !n.getNodeData().isHasDistribution() ) {
9708 if ( n.getNodeData().getDistributions().size() != 1 ) {
9711 d = n.getNodeData().getDistribution();
9712 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9715 if ( d.getPoints().size() != 1 ) {
9718 if ( d.getPolygons() != null ) {
9721 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9724 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9727 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9730 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9733 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9736 n = t1.getNode( "node a" );
9737 if ( !n.getNodeData().isHasDistribution() ) {
9740 if ( n.getNodeData().getDistributions().size() != 2 ) {
9743 d = n.getNodeData().getDistribution( 1 );
9744 if ( !d.getDesc().equals( "San Diego" ) ) {
9747 if ( d.getPoints().size() != 1 ) {
9750 if ( d.getPolygons() != null ) {
9753 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9756 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9759 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9762 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9765 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9768 n = t1.getNode( "node bb" );
9769 if ( !n.getNodeData().isHasDistribution() ) {
9772 if ( n.getNodeData().getDistributions().size() != 1 ) {
9775 d = n.getNodeData().getDistribution( 0 );
9776 if ( d.getPoints().size() != 3 ) {
9779 if ( d.getPolygons().size() != 2 ) {
9782 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9785 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9788 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9791 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9794 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9797 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9800 Polygon p = d.getPolygons().get( 0 );
9801 if ( p.getPoints().size() != 3 ) {
9804 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9807 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9810 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9813 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9816 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9819 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9822 p = d.getPolygons().get( 1 );
9823 if ( p.getPoints().size() != 3 ) {
9826 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9829 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9832 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9836 final StringBuffer t1_sb = new StringBuffer( t1.toPhyloXML( 0 ) );
9837 final Phylogeny[] rt = factory.create( t1_sb, xml_parser );
9838 if ( rt.length != 1 ) {
9841 final Phylogeny t1_rt = rt[ 0 ];
9842 n = t1_rt.getNode( "root node" );
9843 if ( !n.getNodeData().isHasDistribution() ) {
9846 if ( n.getNodeData().getDistributions().size() != 1 ) {
9849 d = n.getNodeData().getDistribution();
9850 if ( !d.getDesc().equals( "Hirschweg 38" ) ) {
9853 if ( d.getPoints().size() != 1 ) {
9856 if ( d.getPolygons() != null ) {
9859 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "472" ) ) {
9862 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9865 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9868 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "47.48148427110029" ) ) {
9871 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "8.768951296806335" ) ) {
9874 n = t1_rt.getNode( "node a" );
9875 if ( !n.getNodeData().isHasDistribution() ) {
9878 if ( n.getNodeData().getDistributions().size() != 2 ) {
9881 d = n.getNodeData().getDistribution( 1 );
9882 if ( !d.getDesc().equals( "San Diego" ) ) {
9885 if ( d.getPoints().size() != 1 ) {
9888 if ( d.getPolygons() != null ) {
9891 if ( !d.getPoints().get( 0 ).getAltitude().toString().equals( "104" ) ) {
9894 if ( !d.getPoints().get( 0 ).getAltiudeUnit().equals( "m" ) ) {
9897 if ( !d.getPoints().get( 0 ).getGeodeticDatum().equals( "WGS84" ) ) {
9900 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "32.880933" ) ) {
9903 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "-117.217543" ) ) {
9906 n = t1_rt.getNode( "node bb" );
9907 if ( !n.getNodeData().isHasDistribution() ) {
9910 if ( n.getNodeData().getDistributions().size() != 1 ) {
9913 d = n.getNodeData().getDistribution( 0 );
9914 if ( d.getPoints().size() != 3 ) {
9917 if ( d.getPolygons().size() != 2 ) {
9920 if ( !d.getPoints().get( 0 ).getLatitude().toString().equals( "1" ) ) {
9923 if ( !d.getPoints().get( 0 ).getLongitude().toString().equals( "2" ) ) {
9926 if ( !d.getPoints().get( 1 ).getLatitude().toString().equals( "3" ) ) {
9929 if ( !d.getPoints().get( 1 ).getLongitude().toString().equals( "4" ) ) {
9932 if ( !d.getPoints().get( 2 ).getLatitude().toString().equals( "5" ) ) {
9935 if ( !d.getPoints().get( 2 ).getLongitude().toString().equals( "6" ) ) {
9938 p = d.getPolygons().get( 0 );
9939 if ( p.getPoints().size() != 3 ) {
9942 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "0.1" ) ) {
9945 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "0.2" ) ) {
9948 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9951 if ( !p.getPoints().get( 2 ).getLatitude().toString().equals( "0.5" ) ) {
9954 if ( !p.getPoints().get( 2 ).getLongitude().toString().equals( "0.6" ) ) {
9957 if ( !p.getPoints().get( 2 ).getAltitude().toString().equals( "30" ) ) {
9960 p = d.getPolygons().get( 1 );
9961 if ( p.getPoints().size() != 3 ) {
9964 if ( !p.getPoints().get( 0 ).getLatitude().toString().equals( "1.49348902489947473" ) ) {
9967 if ( !p.getPoints().get( 0 ).getLongitude().toString().equals( "2.567489393947847492" ) ) {
9970 if ( !p.getPoints().get( 0 ).getAltitude().toString().equals( "10" ) ) {
9974 catch ( final Exception e ) {
9975 e.printStackTrace( System.out );
9981 private static boolean testPostOrderIterator() {
9983 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
9984 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
9985 PhylogenyNodeIterator it0;
9986 for( it0 = t0.iteratorPostorder(); it0.hasNext(); ) {
9989 for( it0.reset(); it0.hasNext(); ) {
9992 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
9993 final PhylogenyNodeIterator it = t1.iteratorPostorder();
9994 if ( !it.next().getName().equals( "A" ) ) {
9997 if ( !it.next().getName().equals( "B" ) ) {
10000 if ( !it.next().getName().equals( "ab" ) ) {
10003 if ( !it.next().getName().equals( "C" ) ) {
10006 if ( !it.next().getName().equals( "D" ) ) {
10009 if ( !it.next().getName().equals( "cd" ) ) {
10012 if ( !it.next().getName().equals( "abcd" ) ) {
10015 if ( !it.next().getName().equals( "E" ) ) {
10018 if ( !it.next().getName().equals( "F" ) ) {
10021 if ( !it.next().getName().equals( "ef" ) ) {
10024 if ( !it.next().getName().equals( "G" ) ) {
10027 if ( !it.next().getName().equals( "H" ) ) {
10030 if ( !it.next().getName().equals( "gh" ) ) {
10033 if ( !it.next().getName().equals( "efgh" ) ) {
10036 if ( !it.next().getName().equals( "r" ) ) {
10039 if ( it.hasNext() ) {
10043 catch ( final Exception e ) {
10044 e.printStackTrace( System.out );
10050 private static boolean testPreOrderIterator() {
10052 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10053 final Phylogeny t0 = factory.create( "((A,B)ab,(C,D)cd)r", new NHXParser() )[ 0 ];
10054 PhylogenyNodeIterator it0;
10055 for( it0 = t0.iteratorPreorder(); it0.hasNext(); ) {
10058 for( it0.reset(); it0.hasNext(); ) {
10061 PhylogenyNodeIterator it = t0.iteratorPreorder();
10062 if ( !it.next().getName().equals( "r" ) ) {
10065 if ( !it.next().getName().equals( "ab" ) ) {
10068 if ( !it.next().getName().equals( "A" ) ) {
10071 if ( !it.next().getName().equals( "B" ) ) {
10074 if ( !it.next().getName().equals( "cd" ) ) {
10077 if ( !it.next().getName().equals( "C" ) ) {
10080 if ( !it.next().getName().equals( "D" ) ) {
10083 if ( it.hasNext() ) {
10086 final Phylogeny t1 = factory.create( "(((A,B)ab,(C,D)cd)abcd,((E,F)ef,(G,H)gh)efgh)r", new NHXParser() )[ 0 ];
10087 it = t1.iteratorPreorder();
10088 if ( !it.next().getName().equals( "r" ) ) {
10091 if ( !it.next().getName().equals( "abcd" ) ) {
10094 if ( !it.next().getName().equals( "ab" ) ) {
10097 if ( !it.next().getName().equals( "A" ) ) {
10100 if ( !it.next().getName().equals( "B" ) ) {
10103 if ( !it.next().getName().equals( "cd" ) ) {
10106 if ( !it.next().getName().equals( "C" ) ) {
10109 if ( !it.next().getName().equals( "D" ) ) {
10112 if ( !it.next().getName().equals( "efgh" ) ) {
10115 if ( !it.next().getName().equals( "ef" ) ) {
10118 if ( !it.next().getName().equals( "E" ) ) {
10121 if ( !it.next().getName().equals( "F" ) ) {
10124 if ( !it.next().getName().equals( "gh" ) ) {
10127 if ( !it.next().getName().equals( "G" ) ) {
10130 if ( !it.next().getName().equals( "H" ) ) {
10133 if ( it.hasNext() ) {
10137 catch ( final Exception e ) {
10138 e.printStackTrace( System.out );
10144 private static boolean testPropertiesMap() {
10146 final PropertiesMap pm = new PropertiesMap();
10147 final Property p0 = new Property( "dimensions:diameter", "1", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10148 final Property p1 = new Property( "dimensions:length", "2", "metric:mm", "xsd:decimal", AppliesTo.NODE );
10149 final Property p2 = new Property( "something:else",
10151 "improbable:research",
10154 pm.addProperty( p0 );
10155 pm.addProperty( p1 );
10156 pm.addProperty( p2 );
10157 if ( !pm.getProperty( "dimensions:diameter" ).getValue().equals( "1" ) ) {
10160 if ( !pm.getProperty( "dimensions:length" ).getValue().equals( "2" ) ) {
10163 if ( pm.getProperties().size() != 3 ) {
10166 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 2 ) {
10169 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10172 if ( pm.getProperties().size() != 3 ) {
10175 pm.removeProperty( "dimensions:diameter" );
10176 if ( pm.getProperties().size() != 2 ) {
10179 if ( pm.getPropertiesWithGivenReferencePrefix( "dimensions" ).size() != 1 ) {
10182 if ( pm.getPropertiesWithGivenReferencePrefix( "something" ).size() != 1 ) {
10186 catch ( final Exception e ) {
10187 e.printStackTrace( System.out );
10193 private static boolean testProteinId() {
10195 final ProteinId id1 = new ProteinId( "a" );
10196 final ProteinId id2 = new ProteinId( "a" );
10197 final ProteinId id3 = new ProteinId( "A" );
10198 final ProteinId id4 = new ProteinId( "b" );
10199 if ( !id1.equals( id1 ) ) {
10202 if ( id1.getId().equals( "x" ) ) {
10205 if ( id1.getId().equals( null ) ) {
10208 if ( !id1.equals( id2 ) ) {
10211 if ( id1.equals( id3 ) ) {
10214 if ( id1.hashCode() != id1.hashCode() ) {
10217 if ( id1.hashCode() != id2.hashCode() ) {
10220 if ( id1.hashCode() == id3.hashCode() ) {
10223 if ( id1.compareTo( id1 ) != 0 ) {
10226 if ( id1.compareTo( id2 ) != 0 ) {
10229 if ( id1.compareTo( id3 ) != 0 ) {
10232 if ( id1.compareTo( id4 ) >= 0 ) {
10235 if ( id4.compareTo( id1 ) <= 0 ) {
10238 if ( !id4.getId().equals( "b" ) ) {
10241 final ProteinId id5 = new ProteinId( " C " );
10242 if ( !id5.getId().equals( "C" ) ) {
10245 if ( id5.equals( id1 ) ) {
10249 catch ( final Exception e ) {
10250 e.printStackTrace( System.out );
10256 private static boolean testReIdMethods() {
10258 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10259 final Phylogeny p = factory.create( "((1,2)A,(((X,Y,Z)a,b)3)B,(4,5,6)C)r", new NHXParser() )[ 0 ];
10260 final long count = PhylogenyNode.getNodeCount();
10261 p.levelOrderReID();
10262 if ( p.getNode( "r" ).getId() != count ) {
10265 if ( p.getNode( "A" ).getId() != ( count + 1 ) ) {
10268 if ( p.getNode( "B" ).getId() != ( count + 1 ) ) {
10271 if ( p.getNode( "C" ).getId() != ( count + 1 ) ) {
10274 if ( p.getNode( "1" ).getId() != ( count + 2 ) ) {
10277 if ( p.getNode( "2" ).getId() != ( count + 2 ) ) {
10280 if ( p.getNode( "3" ).getId() != ( count + 2 ) ) {
10283 if ( p.getNode( "4" ).getId() != ( count + 2 ) ) {
10286 if ( p.getNode( "5" ).getId() != ( count + 2 ) ) {
10289 if ( p.getNode( "6" ).getId() != ( count + 2 ) ) {
10292 if ( p.getNode( "a" ).getId() != ( count + 3 ) ) {
10295 if ( p.getNode( "b" ).getId() != ( count + 3 ) ) {
10298 if ( p.getNode( "X" ).getId() != ( count + 4 ) ) {
10301 if ( p.getNode( "Y" ).getId() != ( count + 4 ) ) {
10304 if ( p.getNode( "Z" ).getId() != ( count + 4 ) ) {
10308 catch ( final Exception e ) {
10309 e.printStackTrace( System.out );
10315 private static boolean testRerooting() {
10317 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10318 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",
10319 new NHXParser() )[ 0 ];
10320 if ( !t1.isRooted() ) {
10323 t1.reRoot( t1.getNode( "D" ) );
10324 t1.reRoot( t1.getNode( "CD" ) );
10325 t1.reRoot( t1.getNode( "A" ) );
10326 t1.reRoot( t1.getNode( "B" ) );
10327 t1.reRoot( t1.getNode( "AB" ) );
10328 t1.reRoot( t1.getNode( "D" ) );
10329 t1.reRoot( t1.getNode( "C" ) );
10330 t1.reRoot( t1.getNode( "CD" ) );
10331 t1.reRoot( t1.getNode( "A" ) );
10332 t1.reRoot( t1.getNode( "B" ) );
10333 t1.reRoot( t1.getNode( "AB" ) );
10334 t1.reRoot( t1.getNode( "D" ) );
10335 t1.reRoot( t1.getNode( "D" ) );
10336 t1.reRoot( t1.getNode( "C" ) );
10337 t1.reRoot( t1.getNode( "A" ) );
10338 t1.reRoot( t1.getNode( "B" ) );
10339 t1.reRoot( t1.getNode( "AB" ) );
10340 t1.reRoot( t1.getNode( "C" ) );
10341 t1.reRoot( t1.getNode( "D" ) );
10342 t1.reRoot( t1.getNode( "CD" ) );
10343 t1.reRoot( t1.getNode( "D" ) );
10344 t1.reRoot( t1.getNode( "A" ) );
10345 t1.reRoot( t1.getNode( "B" ) );
10346 t1.reRoot( t1.getNode( "AB" ) );
10347 t1.reRoot( t1.getNode( "C" ) );
10348 t1.reRoot( t1.getNode( "D" ) );
10349 t1.reRoot( t1.getNode( "CD" ) );
10350 t1.reRoot( t1.getNode( "D" ) );
10351 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 1 ) ) {
10354 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 2 ) ) {
10357 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 3 ) ) {
10360 if ( !isEqual( t1.getNode( "D" ).getDistanceToParent(), 2.5 ) ) {
10363 if ( !isEqual( t1.getNode( "CD" ).getDistanceToParent(), 2.5 ) ) {
10366 if ( !isEqual( t1.getNode( "AB" ).getDistanceToParent(), 4 ) ) {
10369 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",
10370 new NHXParser() )[ 0 ];
10371 t2.reRoot( t2.getNode( "A" ) );
10372 t2.reRoot( t2.getNode( "D" ) );
10373 t2.reRoot( t2.getNode( "ABC" ) );
10374 t2.reRoot( t2.getNode( "A" ) );
10375 t2.reRoot( t2.getNode( "B" ) );
10376 t2.reRoot( t2.getNode( "D" ) );
10377 t2.reRoot( t2.getNode( "C" ) );
10378 t2.reRoot( t2.getNode( "ABC" ) );
10379 t2.reRoot( t2.getNode( "A" ) );
10380 t2.reRoot( t2.getNode( "B" ) );
10381 t2.reRoot( t2.getNode( "AB" ) );
10382 t2.reRoot( t2.getNode( "AB" ) );
10383 t2.reRoot( t2.getNode( "D" ) );
10384 t2.reRoot( t2.getNode( "C" ) );
10385 t2.reRoot( t2.getNode( "B" ) );
10386 t2.reRoot( t2.getNode( "AB" ) );
10387 t2.reRoot( t2.getNode( "D" ) );
10388 t2.reRoot( t2.getNode( "D" ) );
10389 t2.reRoot( t2.getNode( "ABC" ) );
10390 t2.reRoot( t2.getNode( "A" ) );
10391 t2.reRoot( t2.getNode( "B" ) );
10392 t2.reRoot( t2.getNode( "AB" ) );
10393 t2.reRoot( t2.getNode( "D" ) );
10394 t2.reRoot( t2.getNode( "C" ) );
10395 t2.reRoot( t2.getNode( "ABC" ) );
10396 t2.reRoot( t2.getNode( "A" ) );
10397 t2.reRoot( t2.getNode( "B" ) );
10398 t2.reRoot( t2.getNode( "AB" ) );
10399 t2.reRoot( t2.getNode( "D" ) );
10400 t2.reRoot( t2.getNode( "D" ) );
10401 t2.reRoot( t2.getNode( "C" ) );
10402 t2.reRoot( t2.getNode( "A" ) );
10403 t2.reRoot( t2.getNode( "B" ) );
10404 t2.reRoot( t2.getNode( "AB" ) );
10405 t2.reRoot( t2.getNode( "C" ) );
10406 t2.reRoot( t2.getNode( "D" ) );
10407 t2.reRoot( t2.getNode( "ABC" ) );
10408 t2.reRoot( t2.getNode( "D" ) );
10409 t2.reRoot( t2.getNode( "A" ) );
10410 t2.reRoot( t2.getNode( "B" ) );
10411 t2.reRoot( t2.getNode( "AB" ) );
10412 t2.reRoot( t2.getNode( "C" ) );
10413 t2.reRoot( t2.getNode( "D" ) );
10414 t2.reRoot( t2.getNode( "ABC" ) );
10415 t2.reRoot( t2.getNode( "D" ) );
10416 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10419 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10422 t2.reRoot( t2.getNode( "ABC" ) );
10423 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10426 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10429 t2.reRoot( t2.getNode( "AB" ) );
10430 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10433 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10436 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10439 t2.reRoot( t2.getNode( "AB" ) );
10440 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10443 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10446 if ( !isEqual( t2.getNode( "D" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10449 t2.reRoot( t2.getNode( "D" ) );
10450 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10453 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10456 t2.reRoot( t2.getNode( "ABC" ) );
10457 if ( !isEqual( t2.getNode( "AB" ).getBranchData().getConfidence( 0 ).getValue(), 55 ) ) {
10460 if ( !isEqual( t2.getNode( "ABC" ).getBranchData().getConfidence( 0 ).getValue(), 33 ) ) {
10463 final Phylogeny t3 = factory.create( "(A[&&NHX:B=10],B[&&NHX:B=20],C[&&NHX:B=30],D[&&NHX:B=40])",
10464 new NHXParser() )[ 0 ];
10465 t3.reRoot( t3.getNode( "B" ) );
10466 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10469 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10472 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10475 t3.reRoot( t3.getNode( "B" ) );
10476 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10479 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10482 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10485 t3.reRoot( t3.getRoot() );
10486 if ( t3.getNode( "B" ).getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10489 if ( t3.getNode( "A" ).getParent().getBranchData().getConfidence( 0 ).getValue() != 20 ) {
10492 if ( t3.getNode( "A" ).getParent().getNumberOfDescendants() != 3 ) {
10496 catch ( final Exception e ) {
10497 e.printStackTrace( System.out );
10503 private static boolean testSDIse() {
10505 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10506 final Phylogeny species1 = factory.create( "[&&NHX:S=yeast]", new NHXParser() )[ 0 ];
10507 final Phylogeny gene1 = factory.create( "(A1[&&NHX:S=yeast],A2[&&NHX:S=yeast])", new NHXParser() )[ 0 ];
10508 gene1.setRooted( true );
10509 species1.setRooted( true );
10510 final SDI sdi = new SDI( gene1, species1 );
10511 if ( !gene1.getRoot().isDuplication() ) {
10514 final Phylogeny species2 = factory
10515 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10516 new NHXParser() )[ 0 ];
10517 final Phylogeny gene2 = factory
10518 .create( "(((([&&NHX:S=A],[&&NHX:S=B])ab,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10519 new NHXParser() )[ 0 ];
10520 species2.setRooted( true );
10521 gene2.setRooted( true );
10522 final SDI sdi2 = new SDI( gene2, species2 );
10523 if ( sdi2.getDuplicationsSum() != 0 ) {
10526 if ( !gene2.getNode( "ab" ).isSpeciation() ) {
10529 if ( !gene2.getNode( "ab" ).isHasAssignedEvent() ) {
10532 if ( !gene2.getNode( "abc" ).isSpeciation() ) {
10535 if ( !gene2.getNode( "abc" ).isHasAssignedEvent() ) {
10538 if ( !gene2.getNode( "r" ).isSpeciation() ) {
10541 if ( !gene2.getNode( "r" ).isHasAssignedEvent() ) {
10544 final Phylogeny species3 = factory
10545 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10546 new NHXParser() )[ 0 ];
10547 final Phylogeny gene3 = factory
10548 .create( "(((([&&NHX:S=A],[&&NHX:S=A])aa,[&&NHX:S=C])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10549 new NHXParser() )[ 0 ];
10550 species3.setRooted( true );
10551 gene3.setRooted( true );
10552 final SDI sdi3 = new SDI( gene3, species3 );
10553 if ( sdi3.getDuplicationsSum() != 1 ) {
10556 if ( !gene3.getNode( "aa" ).isDuplication() ) {
10559 if ( !gene3.getNode( "aa" ).isHasAssignedEvent() ) {
10562 final Phylogeny species4 = factory
10563 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10564 new NHXParser() )[ 0 ];
10565 final Phylogeny gene4 = factory
10566 .create( "(((([&&NHX:S=A],[&&NHX:S=C])ac,[&&NHX:S=B])abc,[&&NHX:S=D])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10567 new NHXParser() )[ 0 ];
10568 species4.setRooted( true );
10569 gene4.setRooted( true );
10570 final SDI sdi4 = new SDI( gene4, species4 );
10571 if ( sdi4.getDuplicationsSum() != 1 ) {
10574 if ( !gene4.getNode( "ac" ).isSpeciation() ) {
10577 if ( !gene4.getNode( "abc" ).isDuplication() ) {
10580 if ( gene4.getNode( "abcd" ).isDuplication() ) {
10583 if ( species4.getNumberOfExternalNodes() != 6 ) {
10586 if ( gene4.getNumberOfExternalNodes() != 6 ) {
10589 final Phylogeny species5 = factory
10590 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10591 new NHXParser() )[ 0 ];
10592 final Phylogeny gene5 = factory
10593 .create( "(((([&&NHX:S=A],[&&NHX:S=D])ad,[&&NHX:S=C])adc,[&&NHX:S=B])abcd,([&&NHX:S=E],[&&NHX:S=F])ef)r",
10594 new NHXParser() )[ 0 ];
10595 species5.setRooted( true );
10596 gene5.setRooted( true );
10597 final SDI sdi5 = new SDI( gene5, species5 );
10598 if ( sdi5.getDuplicationsSum() != 2 ) {
10601 if ( !gene5.getNode( "ad" ).isSpeciation() ) {
10604 if ( !gene5.getNode( "adc" ).isDuplication() ) {
10607 if ( !gene5.getNode( "abcd" ).isDuplication() ) {
10610 if ( species5.getNumberOfExternalNodes() != 6 ) {
10613 if ( gene5.getNumberOfExternalNodes() != 6 ) {
10616 // Trees from Louxin Zhang 1997 "On a Mirkin-Muchnik-Smith
10617 // Conjecture for Comparing Molecular Phylogenies"
10618 // J. of Comput Bio. Vol. 4, No 2, pp.177-187
10619 final Phylogeny species6 = factory
10620 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
10621 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10622 new NHXParser() )[ 0 ];
10623 final Phylogeny gene6 = factory
10624 .create( "(((1:0.1[&&NHX:S=1],2:0.1[&&NHX:S=2])1-2:0.1,3:0.1[&&NHX:S=3])1-2-3:0.1,"
10625 + "((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,"
10626 + "(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;",
10627 new NHXParser() )[ 0 ];
10628 species6.setRooted( true );
10629 gene6.setRooted( true );
10630 final SDI sdi6 = new SDI( gene6, species6 );
10631 if ( sdi6.getDuplicationsSum() != 3 ) {
10634 if ( !gene6.getNode( "r" ).isDuplication() ) {
10637 if ( !gene6.getNode( "4-5-6" ).isDuplication() ) {
10640 if ( !gene6.getNode( "7-8-9" ).isDuplication() ) {
10643 if ( !gene6.getNode( "1-2" ).isSpeciation() ) {
10646 if ( !gene6.getNode( "1-2-3" ).isSpeciation() ) {
10649 if ( !gene6.getNode( "5-6" ).isSpeciation() ) {
10652 if ( !gene6.getNode( "8-9" ).isSpeciation() ) {
10655 if ( !gene6.getNode( "4-5-6-7-8-9" ).isSpeciation() ) {
10658 sdi6.computeMappingCostL();
10659 if ( sdi6.computeMappingCostL() != 17 ) {
10662 if ( species6.getNumberOfExternalNodes() != 9 ) {
10665 if ( gene6.getNumberOfExternalNodes() != 9 ) {
10668 final Phylogeny species7 = Test.createPhylogeny( "(((((((" + "([&&NHX:S=a1],[&&NHX:S=a2]),"
10669 + "([&&NHX:S=b1],[&&NHX:S=b2])" + "),[&&NHX:S=x]),(" + "([&&NHX:S=m1],[&&NHX:S=m2]),"
10670 + "([&&NHX:S=n1],[&&NHX:S=n2])" + ")),(" + "([&&NHX:S=i1],[&&NHX:S=i2]),"
10671 + "([&&NHX:S=j1],[&&NHX:S=j2])" + ")),(" + "([&&NHX:S=e1],[&&NHX:S=e2]),"
10672 + "([&&NHX:S=f1],[&&NHX:S=f2])" + ")),[&&NHX:S=y]),[&&NHX:S=z])" );
10673 species7.setRooted( true );
10674 final Phylogeny gene7_1 = Test
10675 .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])" );
10676 gene7_1.setRooted( true );
10677 final SDI sdi7 = new SDI( gene7_1, species7 );
10678 if ( sdi7.getDuplicationsSum() != 0 ) {
10681 if ( !Test.getEvent( gene7_1, "a1", "a2" ).isSpeciation() ) {
10684 if ( !Test.getEvent( gene7_1, "a1", "b1" ).isSpeciation() ) {
10687 if ( !Test.getEvent( gene7_1, "a1", "x" ).isSpeciation() ) {
10690 if ( !Test.getEvent( gene7_1, "a1", "m1" ).isSpeciation() ) {
10693 if ( !Test.getEvent( gene7_1, "a1", "i1" ).isSpeciation() ) {
10696 if ( !Test.getEvent( gene7_1, "a1", "e1" ).isSpeciation() ) {
10699 if ( !Test.getEvent( gene7_1, "a1", "y" ).isSpeciation() ) {
10702 if ( !Test.getEvent( gene7_1, "a1", "z" ).isSpeciation() ) {
10705 final Phylogeny gene7_2 = Test
10706 .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])" );
10707 gene7_2.setRooted( true );
10708 final SDI sdi7_2 = new SDI( gene7_2, species7 );
10709 if ( sdi7_2.getDuplicationsSum() != 1 ) {
10712 if ( !Test.getEvent( gene7_2, "a1", "a2" ).isSpeciation() ) {
10715 if ( !Test.getEvent( gene7_2, "a1", "b1" ).isSpeciation() ) {
10718 if ( !Test.getEvent( gene7_2, "a1", "x" ).isSpeciation() ) {
10721 if ( !Test.getEvent( gene7_2, "a1", "m1" ).isSpeciation() ) {
10724 if ( !Test.getEvent( gene7_2, "a1", "i1" ).isSpeciation() ) {
10727 if ( !Test.getEvent( gene7_2, "a1", "j2" ).isDuplication() ) {
10730 if ( !Test.getEvent( gene7_2, "a1", "e1" ).isSpeciation() ) {
10733 if ( !Test.getEvent( gene7_2, "a1", "y" ).isSpeciation() ) {
10736 if ( !Test.getEvent( gene7_2, "a1", "z" ).isSpeciation() ) {
10740 catch ( final Exception e ) {
10746 private static boolean testSDIunrooted() {
10748 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
10749 final Phylogeny p0 = factory.create( "((((A,B)ab,(C1,C2)cc)abc,D)abcd,(E,F)ef)abcdef", new NHXParser() )[ 0 ];
10750 final List<PhylogenyBranch> l = SDIR.getBranchesInPreorder( p0 );
10751 final Iterator<PhylogenyBranch> iter = l.iterator();
10752 PhylogenyBranch br = iter.next();
10753 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "ef" ) ) {
10756 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "ef" ) ) {
10760 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10763 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10767 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "ab" ) ) {
10770 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "ab" ) ) {
10774 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10777 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10781 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10784 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10788 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "abc" ) ) {
10791 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "abc" ) ) {
10795 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10798 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10802 if ( !br.getFirstNode().getName().equals( "C1" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10805 if ( !br.getSecondNode().getName().equals( "C1" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10809 if ( !br.getFirstNode().getName().equals( "C2" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10812 if ( !br.getSecondNode().getName().equals( "C2" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10816 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "cc" ) ) {
10819 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "cc" ) ) {
10823 if ( !br.getFirstNode().getName().equals( "abc" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10826 if ( !br.getSecondNode().getName().equals( "abc" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10830 if ( !br.getFirstNode().getName().equals( "abcd" ) && !br.getFirstNode().getName().equals( "D" ) ) {
10833 if ( !br.getSecondNode().getName().equals( "abcd" ) && !br.getSecondNode().getName().equals( "D" ) ) {
10837 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "abcd" ) ) {
10840 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "abcd" ) ) {
10844 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "E" ) ) {
10847 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "E" ) ) {
10851 if ( !br.getFirstNode().getName().equals( "ef" ) && !br.getFirstNode().getName().equals( "F" ) ) {
10854 if ( !br.getSecondNode().getName().equals( "ef" ) && !br.getSecondNode().getName().equals( "F" ) ) {
10857 if ( iter.hasNext() ) {
10860 final Phylogeny p1 = factory.create( "(C,(A,B)ab)abc", new NHXParser() )[ 0 ];
10861 final List<PhylogenyBranch> l1 = SDIR.getBranchesInPreorder( p1 );
10862 final Iterator<PhylogenyBranch> iter1 = l1.iterator();
10864 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10867 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10871 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10874 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10878 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10881 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10884 if ( iter1.hasNext() ) {
10887 final Phylogeny p2 = factory.create( "((A,B)ab,C)abc", new NHXParser() )[ 0 ];
10888 final List<PhylogenyBranch> l2 = SDIR.getBranchesInPreorder( p2 );
10889 final Iterator<PhylogenyBranch> iter2 = l2.iterator();
10891 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "C" ) ) {
10894 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "C" ) ) {
10898 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "A" ) ) {
10901 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "A" ) ) {
10905 if ( !br.getFirstNode().getName().equals( "ab" ) && !br.getFirstNode().getName().equals( "B" ) ) {
10908 if ( !br.getSecondNode().getName().equals( "ab" ) && !br.getSecondNode().getName().equals( "B" ) ) {
10911 if ( iter2.hasNext() ) {
10914 final Phylogeny species0 = factory
10915 .create( "(((([&&NHX:S=A],[&&NHX:S=B]),[&&NHX:S=C]),[&&NHX:S=D]),([&&NHX:S=E],[&&NHX:S=F]))",
10916 new NHXParser() )[ 0 ];
10917 final Phylogeny gene1 = factory
10918 .create( "(((((A:0.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
10919 new NHXParser() )[ 0 ];
10920 species0.setRooted( true );
10921 gene1.setRooted( true );
10922 final SDIR sdi_unrooted = new SDIR();
10923 sdi_unrooted.infer( gene1, species0, false, true, true, true, 10 );
10924 if ( sdi_unrooted.getCount() != 1 ) {
10927 if ( sdi_unrooted.getMinimalDuplications() != 0 ) {
10930 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.4 ) ) {
10933 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 1.0 ) ) {
10936 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10939 final Phylogeny gene2 = factory
10940 .create( "(((((A:2.6[&&NHX:S=A],B:0.1[&&NHX:S=B])ab:0.1,C:0.1[&&NHX:S=C])abc:0.3,D:1.0[&&NHX:S=D])abcd:0.2,E:0.1[&&NHX:S=E])abcde:0.2,F:0.2[&&NHX:S=F])",
10941 new NHXParser() )[ 0 ];
10942 gene2.setRooted( true );
10943 sdi_unrooted.infer( gene2, species0, false, false, true, true, 10 );
10944 if ( sdi_unrooted.getCount() != 1 ) {
10947 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10950 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10953 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 2.0 ) ) {
10956 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10959 final Phylogeny species6 = factory
10960 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
10961 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
10962 new NHXParser() )[ 0 ];
10963 final Phylogeny gene6 = factory
10964 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
10965 + "(((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],"
10966 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
10967 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
10968 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
10969 new NHXParser() )[ 0 ];
10970 species6.setRooted( true );
10971 gene6.setRooted( true );
10972 Phylogeny[] p6 = sdi_unrooted.infer( gene6, species6, false, true, true, true, 10 );
10973 if ( sdi_unrooted.getCount() != 1 ) {
10976 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
10979 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
10982 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
10985 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
10988 if ( !p6[ 0 ].getRoot().isDuplication() ) {
10991 if ( !p6[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
10994 if ( !p6[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
10997 if ( p6[ 0 ].getNode( "1-2" ).isDuplication() ) {
11000 if ( p6[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11003 if ( p6[ 0 ].getNode( "5-6" ).isDuplication() ) {
11006 if ( p6[ 0 ].getNode( "8-9" ).isDuplication() ) {
11009 if ( p6[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11013 final Phylogeny species7 = factory
11014 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11015 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11016 new NHXParser() )[ 0 ];
11017 final Phylogeny gene7 = factory
11018 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11019 + "(((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],"
11020 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11021 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11022 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11023 new NHXParser() )[ 0 ];
11024 species7.setRooted( true );
11025 gene7.setRooted( true );
11026 Phylogeny[] p7 = sdi_unrooted.infer( gene7, species7, true, true, true, true, 10 );
11027 if ( sdi_unrooted.getCount() != 1 ) {
11030 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11033 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11036 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11039 if ( sdi_unrooted.getMinimalMappingCost() != 17 ) {
11042 if ( !p7[ 0 ].getRoot().isDuplication() ) {
11045 if ( !p7[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11048 if ( !p7[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11051 if ( p7[ 0 ].getNode( "1-2" ).isDuplication() ) {
11054 if ( p7[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11057 if ( p7[ 0 ].getNode( "5-6" ).isDuplication() ) {
11060 if ( p7[ 0 ].getNode( "8-9" ).isDuplication() ) {
11063 if ( p7[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11067 final Phylogeny species8 = factory
11068 .create( "(((1:[&&NHX:S=1],5:[&&NHX:S=5])1-5,((4:[&&NHX:S=4],6:[&&NHX:S=6])4-6,2:[&&NHX:S=2])4-6-2)1-5-4-6-2,"
11069 + "((9:[&&NHX:S=9],3:[&&NHX:S=3])9-3,(8:[&&NHX:S=8],7:[&&NHX:S=7])8-7)9-3-8-7)",
11070 new NHXParser() )[ 0 ];
11071 final Phylogeny gene8 = factory
11072 .create( "((5:0.1[&&NHX:S=5],6:0.1[&&NHX:S=6])5-6:0.05[&&NHX:S=6],(4:0.1[&&NHX:S=4],"
11073 + "(((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],"
11074 + "(7:0.1[&&NHX:S=7],(8:0.1[&&NHX:S=8],"
11075 + "9:0.1[&&NHX:S=9])8-9:0.1[&&NHX:S=9])7-8-9:0.1[&&NHX:S=8])"
11076 + "4-5-6-7-8-9:0.1[&&NHX:S=5])4-5-6:0.05[&&NHX:S=5])",
11077 new NHXParser() )[ 0 ];
11078 species8.setRooted( true );
11079 gene8.setRooted( true );
11080 Phylogeny[] p8 = sdi_unrooted.infer( gene8, species8, false, false, true, true, 10 );
11081 if ( sdi_unrooted.getCount() != 1 ) {
11084 if ( !Test.isEqual( sdi_unrooted.getMinimalDiffInSubTreeHeights(), 0.0 ) ) {
11087 if ( !Test.isEqual( sdi_unrooted.getMinimalTreeHeight(), 0.375 ) ) {
11090 if ( sdi_unrooted.getMinimalDuplications() != 3 ) {
11093 if ( sdi_unrooted.getMinimalMappingCost() != Integer.MAX_VALUE ) {
11096 if ( !p8[ 0 ].getRoot().isDuplication() ) {
11099 if ( !p8[ 0 ].getNode( "4-5-6" ).isDuplication() ) {
11102 if ( !p8[ 0 ].getNode( "7-8-9" ).isDuplication() ) {
11105 if ( p8[ 0 ].getNode( "1-2" ).isDuplication() ) {
11108 if ( p8[ 0 ].getNode( "1-2-3" ).isDuplication() ) {
11111 if ( p8[ 0 ].getNode( "5-6" ).isDuplication() ) {
11114 if ( p8[ 0 ].getNode( "8-9" ).isDuplication() ) {
11117 if ( p8[ 0 ].getNode( "4-5-6-7-8-9" ).isDuplication() ) {
11122 catch ( final Exception e ) {
11123 e.printStackTrace( System.out );
11129 private static boolean testSequenceDbWsTools1() {
11131 final PhylogenyNode n = new PhylogenyNode();
11132 n.setName( "NP_001025424" );
11133 Accession acc = SequenceDbWsTools.obtainSeqAccession( n );
11134 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11135 || !acc.getValue().equals( "NP_001025424" ) ) {
11138 n.setName( "340 0559 -- _NP_001025424_dsfdg15 05" );
11139 acc = SequenceDbWsTools.obtainSeqAccession( n );
11140 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11141 || !acc.getValue().equals( "NP_001025424" ) ) {
11144 n.setName( "NP_001025424.1" );
11145 acc = SequenceDbWsTools.obtainSeqAccession( n );
11146 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11147 || !acc.getValue().equals( "NP_001025424" ) ) {
11150 n.setName( "NM_001030253" );
11151 acc = SequenceDbWsTools.obtainSeqAccession( n );
11152 if ( ( acc == null ) || !acc.getSource().equals( Source.REFSEQ.toString() )
11153 || !acc.getValue().equals( "NM_001030253" ) ) {
11156 n.setName( "BCL2_HUMAN" );
11157 acc = SequenceDbWsTools.obtainSeqAccession( n );
11158 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11159 || !acc.getValue().equals( "BCL2_HUMAN" ) ) {
11160 System.out.println( acc.toString() );
11163 n.setName( "P10415" );
11164 acc = SequenceDbWsTools.obtainSeqAccession( n );
11165 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11166 || !acc.getValue().equals( "P10415" ) ) {
11167 System.out.println( acc.toString() );
11170 n.setName( " P10415 " );
11171 acc = SequenceDbWsTools.obtainSeqAccession( n );
11172 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11173 || !acc.getValue().equals( "P10415" ) ) {
11174 System.out.println( acc.toString() );
11177 n.setName( "_P10415|" );
11178 acc = SequenceDbWsTools.obtainSeqAccession( n );
11179 if ( ( acc == null ) || !acc.getSource().equals( Source.UNIPROT.toString() )
11180 || !acc.getValue().equals( "P10415" ) ) {
11181 System.out.println( acc.toString() );
11184 n.setName( "AY695820" );
11185 acc = SequenceDbWsTools.obtainSeqAccession( n );
11186 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11187 || !acc.getValue().equals( "AY695820" ) ) {
11188 System.out.println( acc.toString() );
11191 n.setName( "_AY695820_" );
11192 acc = SequenceDbWsTools.obtainSeqAccession( n );
11193 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11194 || !acc.getValue().equals( "AY695820" ) ) {
11195 System.out.println( acc.toString() );
11198 n.setName( "AAA59452" );
11199 acc = SequenceDbWsTools.obtainSeqAccession( n );
11200 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11201 || !acc.getValue().equals( "AAA59452" ) ) {
11202 System.out.println( acc.toString() );
11205 n.setName( "_AAA59452_" );
11206 acc = SequenceDbWsTools.obtainSeqAccession( n );
11207 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11208 || !acc.getValue().equals( "AAA59452" ) ) {
11209 System.out.println( acc.toString() );
11212 n.setName( "AAA59452.1" );
11213 acc = SequenceDbWsTools.obtainSeqAccession( n );
11214 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11215 || !acc.getValue().equals( "AAA59452.1" ) ) {
11216 System.out.println( acc.toString() );
11219 n.setName( "_AAA59452.1_" );
11220 acc = SequenceDbWsTools.obtainSeqAccession( n );
11221 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11222 || !acc.getValue().equals( "AAA59452.1" ) ) {
11223 System.out.println( acc.toString() );
11226 n.setName( "GI:94894583" );
11227 acc = SequenceDbWsTools.obtainSeqAccession( n );
11228 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11229 || !acc.getValue().equals( "94894583" ) ) {
11230 System.out.println( acc.toString() );
11233 n.setName( "gi|71845847|1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11234 acc = SequenceDbWsTools.obtainSeqAccession( n );
11235 if ( ( acc == null ) || !acc.getSource().equals( Source.GI.toString() )
11236 || !acc.getValue().equals( "71845847" ) ) {
11237 System.out.println( acc.toString() );
11240 n.setName( "gi|71845847|gb|AAZ45343.1| 1,4-alpha-glucan branching enzyme [Dechloromonas aromatica RCB]" );
11241 acc = SequenceDbWsTools.obtainSeqAccession( n );
11242 if ( ( acc == null ) || !acc.getSource().equals( Source.NCBI.toString() )
11243 || !acc.getValue().equals( "AAZ45343.1" ) ) {
11244 System.out.println( acc.toString() );
11248 catch ( final Exception e ) {
11254 private static boolean testSequenceDbWsTools2() {
11256 final PhylogenyNode n1 = new PhylogenyNode( "NP_001025424" );
11257 SequenceDbWsTools.obtainSeqInformation( n1 );
11258 if ( !n1.getNodeData().getSequence().getName().equals( "Bcl2" ) ) {
11261 if ( !n1.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11264 if ( !n1.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11267 if ( !n1.getNodeData().getSequence().getAccession().getValue().equals( "NP_001025424" ) ) {
11270 final PhylogenyNode n2 = new PhylogenyNode( "NM_001030253" );
11271 SequenceDbWsTools.obtainSeqInformation( n2 );
11272 if ( !n2.getNodeData().getSequence().getName()
11273 .equals( "Danio rerio B-cell leukemia/lymphoma 2 (bcl2), mRNA" ) ) {
11276 if ( !n2.getNodeData().getTaxonomy().getScientificName().equals( "Danio rerio" ) ) {
11279 if ( !n2.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11282 if ( !n2.getNodeData().getSequence().getAccession().getValue().equals( "NM_001030253" ) ) {
11285 final PhylogenyNode n3 = new PhylogenyNode( "NM_184234.2" );
11286 SequenceDbWsTools.obtainSeqInformation( n3 );
11287 if ( !n3.getNodeData().getSequence().getName()
11288 .equals( "Homo sapiens RNA binding motif protein 39 (RBM39), transcript variant 1, mRNA" ) ) {
11291 if ( !n3.getNodeData().getTaxonomy().getScientificName().equals( "Homo sapiens" ) ) {
11294 if ( !n3.getNodeData().getSequence().getAccession().getSource().equals( Source.REFSEQ.toString() ) ) {
11297 if ( !n3.getNodeData().getSequence().getAccession().getValue().equals( "NM_184234" ) ) {
11301 catch ( final IOException e ) {
11302 System.out.println();
11303 System.out.println( "the following might be due to absence internet connection:" );
11304 e.printStackTrace( System.out );
11307 catch ( final Exception e ) {
11308 e.printStackTrace();
11314 private static boolean testSequenceIdParsing() {
11316 Accession id = SequenceAccessionTools.parseAccessorFromString( "gb_ADF31344_segmented_worms_" );
11317 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11318 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11319 if ( id != null ) {
11320 System.out.println( "value =" + id.getValue() );
11321 System.out.println( "provider=" + id.getSource() );
11325 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms|gb_ADF31344" );
11326 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11327 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11328 if ( id != null ) {
11329 System.out.println( "value =" + id.getValue() );
11330 System.out.println( "provider=" + id.getSource() );
11334 id = SequenceAccessionTools.parseAccessorFromString( "segmented worms gb_ADF31344 and more" );
11335 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11336 || !id.getValue().equals( "ADF31344" ) || !id.getSource().equals( "ncbi" ) ) {
11337 if ( id != null ) {
11338 System.out.println( "value =" + id.getValue() );
11339 System.out.println( "provider=" + id.getSource() );
11343 id = SequenceAccessionTools.parseAccessorFromString( "gb_AAA96518_1" );
11344 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11345 || !id.getValue().equals( "AAA96518" ) || !id.getSource().equals( "ncbi" ) ) {
11346 if ( id != null ) {
11347 System.out.println( "value =" + id.getValue() );
11348 System.out.println( "provider=" + id.getSource() );
11352 id = SequenceAccessionTools.parseAccessorFromString( "gb_EHB07727_1_rodents_" );
11353 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11354 || !id.getValue().equals( "EHB07727" ) || !id.getSource().equals( "ncbi" ) ) {
11355 if ( id != null ) {
11356 System.out.println( "value =" + id.getValue() );
11357 System.out.println( "provider=" + id.getSource() );
11361 id = SequenceAccessionTools.parseAccessorFromString( "dbj_BAF37827_1_turtles_" );
11362 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11363 || !id.getValue().equals( "BAF37827" ) || !id.getSource().equals( "ncbi" ) ) {
11364 if ( id != null ) {
11365 System.out.println( "value =" + id.getValue() );
11366 System.out.println( "provider=" + id.getSource() );
11370 id = SequenceAccessionTools.parseAccessorFromString( "emb_CAA73223_1_primates_" );
11371 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11372 || !id.getValue().equals( "CAA73223" ) || !id.getSource().equals( "ncbi" ) ) {
11373 if ( id != null ) {
11374 System.out.println( "value =" + id.getValue() );
11375 System.out.println( "provider=" + id.getSource() );
11379 id = SequenceAccessionTools.parseAccessorFromString( "mites|ref_XP_002434188_1" );
11380 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11381 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11382 if ( id != null ) {
11383 System.out.println( "value =" + id.getValue() );
11384 System.out.println( "provider=" + id.getSource() );
11388 id = SequenceAccessionTools.parseAccessorFromString( "mites_ref_XP_002434188_1_bla_XP_12345" );
11389 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11390 || !id.getValue().equals( "XP_002434188" ) || !id.getSource().equals( "refseq" ) ) {
11391 if ( id != null ) {
11392 System.out.println( "value =" + id.getValue() );
11393 System.out.println( "provider=" + id.getSource() );
11397 id = SequenceAccessionTools.parseAccessorFromString( "P4A123" );
11398 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11399 || !id.getValue().equals( "P4A123" ) || !id.getSource().equals( "uniprot" ) ) {
11400 if ( id != null ) {
11401 System.out.println( "value =" + id.getValue() );
11402 System.out.println( "provider=" + id.getSource() );
11406 id = SequenceAccessionTools.parseAccessorFromString( "XP_12345" );
11407 if ( id != null ) {
11408 System.out.println( "value =" + id.getValue() );
11409 System.out.println( "provider=" + id.getSource() );
11413 id = SequenceAccessionTools.parseAccessorFromString( "N3B004Z009" );
11414 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11415 || !id.getValue().equals( "N3B004Z009" ) || !id.getSource().equals( "uniprot" ) ) {
11416 if ( id != null ) {
11417 System.out.println( "value =" + id.getValue() );
11418 System.out.println( "provider=" + id.getSource() );
11422 id = SequenceAccessionTools.parseAccessorFromString( "A4CAA4ZBB9" );
11423 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11424 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11425 if ( id != null ) {
11426 System.out.println( "value =" + id.getValue() );
11427 System.out.println( "provider=" + id.getSource() );
11431 id = SequenceAccessionTools.parseAccessorFromString( "ecoli_A4CAA4ZBB9_rt" );
11432 if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getSource() )
11433 || !id.getValue().equals( "A4CAA4ZBB9" ) || !id.getSource().equals( "uniprot" ) ) {
11434 if ( id != null ) {
11435 System.out.println( "value =" + id.getValue() );
11436 System.out.println( "provider=" + id.getSource() );
11440 id = SequenceAccessionTools.parseAccessorFromString( "Q4CAA4ZBB9" );
11441 if ( id != null ) {
11442 System.out.println( "value =" + id.getValue() );
11443 System.out.println( "provider=" + id.getSource() );
11447 catch ( final Exception e ) {
11448 e.printStackTrace( System.out );
11454 private static boolean testSequenceWriter() {
11456 final String n = ForesterUtil.LINE_SEPARATOR;
11457 if ( !SequenceWriter.toFasta( "name", "awes", 5 ).toString().equals( ">name" + n + "awes" ) ) {
11460 if ( !SequenceWriter.toFasta( "name", "awes", 4 ).toString().equals( ">name" + n + "awes" ) ) {
11463 if ( !SequenceWriter.toFasta( "name", "awes", 3 ).toString().equals( ">name" + n + "awe" + n + "s" ) ) {
11466 if ( !SequenceWriter.toFasta( "name", "awes", 2 ).toString().equals( ">name" + n + "aw" + n + "es" ) ) {
11469 if ( !SequenceWriter.toFasta( "name", "awes", 1 ).toString()
11470 .equals( ">name" + n + "a" + n + "w" + n + "e" + n + "s" ) ) {
11473 if ( !SequenceWriter.toFasta( "name", "abcdefghij", 3 ).toString()
11474 .equals( ">name" + n + "abc" + n + "def" + n + "ghi" + n + "j" ) ) {
11478 catch ( final Exception e ) {
11479 e.printStackTrace();
11485 private static boolean testSpecies() {
11487 final Species s1 = new BasicSpecies( "a" );
11488 final Species s2 = new BasicSpecies( "a" );
11489 final Species s3 = new BasicSpecies( "A" );
11490 final Species s4 = new BasicSpecies( "b" );
11491 if ( !s1.equals( s1 ) ) {
11494 if ( s1.getSpeciesId().equals( "x" ) ) {
11497 if ( s1.getSpeciesId().equals( null ) ) {
11500 if ( !s1.equals( s2 ) ) {
11503 if ( s1.equals( s3 ) ) {
11506 if ( s1.hashCode() != s1.hashCode() ) {
11509 if ( s1.hashCode() != s2.hashCode() ) {
11512 if ( s1.hashCode() == s3.hashCode() ) {
11515 if ( s1.compareTo( s1 ) != 0 ) {
11518 if ( s1.compareTo( s2 ) != 0 ) {
11521 if ( s1.compareTo( s3 ) != 0 ) {
11524 if ( s1.compareTo( s4 ) >= 0 ) {
11527 if ( s4.compareTo( s1 ) <= 0 ) {
11530 if ( !s4.getSpeciesId().equals( "b" ) ) {
11533 final Species s5 = new BasicSpecies( " C " );
11534 if ( !s5.getSpeciesId().equals( "C" ) ) {
11537 if ( s5.equals( s1 ) ) {
11541 catch ( final Exception e ) {
11542 e.printStackTrace( System.out );
11548 private static boolean testSplit() {
11550 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11551 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11552 //Archaeopteryx.createApplication( p0 );
11553 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11554 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11555 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11556 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11557 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11558 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11559 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11560 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11561 ex.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11562 ex.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11563 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, false, ex );
11564 // System.out.println( s0.toString() );
11566 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11567 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11568 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11569 if ( s0.match( query_nodes ) ) {
11572 query_nodes = new HashSet<PhylogenyNode>();
11573 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11574 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11575 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11576 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11577 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11578 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11579 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11580 if ( !s0.match( query_nodes ) ) {
11584 query_nodes = new HashSet<PhylogenyNode>();
11585 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11586 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11587 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11588 if ( !s0.match( query_nodes ) ) {
11592 query_nodes = new HashSet<PhylogenyNode>();
11593 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11594 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11595 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11596 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11597 if ( !s0.match( query_nodes ) ) {
11601 query_nodes = new HashSet<PhylogenyNode>();
11602 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11603 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11604 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11605 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11606 if ( !s0.match( query_nodes ) ) {
11610 query_nodes = new HashSet<PhylogenyNode>();
11611 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11612 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11613 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11614 if ( !s0.match( query_nodes ) ) {
11618 query_nodes = new HashSet<PhylogenyNode>();
11619 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11620 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11621 if ( !s0.match( query_nodes ) ) {
11625 query_nodes = new HashSet<PhylogenyNode>();
11626 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11627 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11628 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11629 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11630 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11631 if ( !s0.match( query_nodes ) ) {
11635 query_nodes = new HashSet<PhylogenyNode>();
11636 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11637 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11638 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11639 if ( !s0.match( query_nodes ) ) {
11643 query_nodes = new HashSet<PhylogenyNode>();
11644 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11645 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11646 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11647 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11648 if ( !s0.match( query_nodes ) ) {
11652 query_nodes = new HashSet<PhylogenyNode>();
11653 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11654 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11655 if ( s0.match( query_nodes ) ) {
11659 query_nodes = new HashSet<PhylogenyNode>();
11660 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11661 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11662 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11663 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11664 if ( s0.match( query_nodes ) ) {
11668 query_nodes = new HashSet<PhylogenyNode>();
11669 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11670 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11671 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11672 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11673 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11674 if ( s0.match( query_nodes ) ) {
11678 query_nodes = new HashSet<PhylogenyNode>();
11679 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11680 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11681 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11682 if ( s0.match( query_nodes ) ) {
11686 query_nodes = new HashSet<PhylogenyNode>();
11687 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11688 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11689 if ( s0.match( query_nodes ) ) {
11693 query_nodes = new HashSet<PhylogenyNode>();
11694 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11695 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11696 if ( s0.match( query_nodes ) ) {
11700 query_nodes = new HashSet<PhylogenyNode>();
11701 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11702 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11703 if ( s0.match( query_nodes ) ) {
11707 query_nodes = new HashSet<PhylogenyNode>();
11708 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11709 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11710 if ( s0.match( query_nodes ) ) {
11714 query_nodes = new HashSet<PhylogenyNode>();
11715 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11716 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11717 if ( s0.match( query_nodes ) ) {
11721 query_nodes = new HashSet<PhylogenyNode>();
11722 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11723 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11724 if ( s0.match( query_nodes ) ) {
11728 query_nodes = new HashSet<PhylogenyNode>();
11729 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11730 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11731 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11732 if ( s0.match( query_nodes ) ) {
11736 query_nodes = new HashSet<PhylogenyNode>();
11737 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11738 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11739 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11740 if ( s0.match( query_nodes ) ) {
11744 query_nodes = new HashSet<PhylogenyNode>();
11745 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11746 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11747 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11748 if ( s0.match( query_nodes ) ) {
11752 query_nodes = new HashSet<PhylogenyNode>();
11753 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11754 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11755 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11756 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11757 if ( s0.match( query_nodes ) ) {
11761 // query_nodes = new HashSet<PhylogenyNode>();
11762 // query_nodes.add( new PhylogenyNode( "X" ) );
11763 // query_nodes.add( new PhylogenyNode( "Y" ) );
11764 // query_nodes.add( new PhylogenyNode( "A" ) );
11765 // query_nodes.add( new PhylogenyNode( "B" ) );
11766 // query_nodes.add( new PhylogenyNode( "C" ) );
11767 // query_nodes.add( new PhylogenyNode( "D" ) );
11768 // query_nodes.add( new PhylogenyNode( "E" ) );
11769 // query_nodes.add( new PhylogenyNode( "F" ) );
11770 // query_nodes.add( new PhylogenyNode( "G" ) );
11771 // if ( !s0.match( query_nodes ) ) {
11774 // query_nodes = new HashSet<PhylogenyNode>();
11775 // query_nodes.add( new PhylogenyNode( "X" ) );
11776 // query_nodes.add( new PhylogenyNode( "Y" ) );
11777 // query_nodes.add( new PhylogenyNode( "A" ) );
11778 // query_nodes.add( new PhylogenyNode( "B" ) );
11779 // query_nodes.add( new PhylogenyNode( "C" ) );
11780 // if ( !s0.match( query_nodes ) ) {
11784 // query_nodes = new HashSet<PhylogenyNode>();
11785 // query_nodes.add( new PhylogenyNode( "X" ) );
11786 // query_nodes.add( new PhylogenyNode( "Y" ) );
11787 // query_nodes.add( new PhylogenyNode( "D" ) );
11788 // query_nodes.add( new PhylogenyNode( "E" ) );
11789 // query_nodes.add( new PhylogenyNode( "F" ) );
11790 // query_nodes.add( new PhylogenyNode( "G" ) );
11791 // if ( !s0.match( query_nodes ) ) {
11795 // query_nodes = new HashSet<PhylogenyNode>();
11796 // query_nodes.add( new PhylogenyNode( "X" ) );
11797 // query_nodes.add( new PhylogenyNode( "Y" ) );
11798 // query_nodes.add( new PhylogenyNode( "A" ) );
11799 // query_nodes.add( new PhylogenyNode( "B" ) );
11800 // query_nodes.add( new PhylogenyNode( "C" ) );
11801 // query_nodes.add( new PhylogenyNode( "D" ) );
11802 // if ( !s0.match( query_nodes ) ) {
11806 // query_nodes = new HashSet<PhylogenyNode>();
11807 // query_nodes.add( new PhylogenyNode( "X" ) );
11808 // query_nodes.add( new PhylogenyNode( "Y" ) );
11809 // query_nodes.add( new PhylogenyNode( "E" ) );
11810 // query_nodes.add( new PhylogenyNode( "F" ) );
11811 // query_nodes.add( new PhylogenyNode( "G" ) );
11812 // if ( !s0.match( query_nodes ) ) {
11816 // query_nodes = new HashSet<PhylogenyNode>();
11817 // query_nodes.add( new PhylogenyNode( "X" ) );
11818 // query_nodes.add( new PhylogenyNode( "Y" ) );
11819 // query_nodes.add( new PhylogenyNode( "F" ) );
11820 // query_nodes.add( new PhylogenyNode( "G" ) );
11821 // if ( !s0.match( query_nodes ) ) {
11825 query_nodes = new HashSet<PhylogenyNode>();
11826 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11827 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11828 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11829 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11830 if ( s0.match( query_nodes ) ) {
11834 query_nodes = new HashSet<PhylogenyNode>();
11835 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11836 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11837 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11838 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11839 if ( s0.match( query_nodes ) ) {
11842 ///////////////////////////
11844 query_nodes = new HashSet<PhylogenyNode>();
11845 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11846 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11847 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11848 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11849 if ( s0.match( query_nodes ) ) {
11853 query_nodes = new HashSet<PhylogenyNode>();
11854 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11855 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11856 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11857 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11858 if ( s0.match( query_nodes ) ) {
11862 query_nodes = new HashSet<PhylogenyNode>();
11863 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11864 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11865 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11866 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11867 if ( s0.match( query_nodes ) ) {
11871 query_nodes = new HashSet<PhylogenyNode>();
11872 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11873 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11874 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11875 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11876 if ( s0.match( query_nodes ) ) {
11880 query_nodes = new HashSet<PhylogenyNode>();
11881 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11882 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11883 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11884 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11885 if ( s0.match( query_nodes ) ) {
11889 query_nodes = new HashSet<PhylogenyNode>();
11890 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11891 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11892 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11893 if ( s0.match( query_nodes ) ) {
11897 query_nodes = new HashSet<PhylogenyNode>();
11898 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11899 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11900 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11901 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11902 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11903 if ( s0.match( query_nodes ) ) {
11907 query_nodes = new HashSet<PhylogenyNode>();
11908 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11909 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11910 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11911 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11912 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11913 if ( s0.match( query_nodes ) ) {
11917 query_nodes = new HashSet<PhylogenyNode>();
11918 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11919 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11920 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11921 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11922 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11923 if ( s0.match( query_nodes ) ) {
11927 query_nodes = new HashSet<PhylogenyNode>();
11928 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "X" ) );
11929 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "Y" ) );
11930 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11931 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11932 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11933 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11934 if ( s0.match( query_nodes ) ) {
11938 catch ( final Exception e ) {
11939 e.printStackTrace();
11945 private static boolean testSplitStrict() {
11947 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
11948 final Phylogeny p0 = factory.create( "(((A,B,C),D),(E,(F,G)))R", new NHXParser() )[ 0 ];
11949 final Set<PhylogenyNode> ex = new HashSet<PhylogenyNode>();
11950 ex.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11951 ex.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11952 ex.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11953 ex.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11954 ex.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11955 ex.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11956 ex.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11957 final TreeSplitMatrix s0 = new TreeSplitMatrix( p0, true, ex );
11958 Set<PhylogenyNode> query_nodes = new HashSet<PhylogenyNode>();
11959 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11960 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11961 if ( s0.match( query_nodes ) ) {
11964 query_nodes = new HashSet<PhylogenyNode>();
11965 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11966 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11967 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11968 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11969 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11970 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11971 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11972 if ( !s0.match( query_nodes ) ) {
11976 query_nodes = new HashSet<PhylogenyNode>();
11977 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11978 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11979 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11980 if ( !s0.match( query_nodes ) ) {
11984 query_nodes = new HashSet<PhylogenyNode>();
11985 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11986 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
11987 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
11988 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
11989 if ( !s0.match( query_nodes ) ) {
11993 query_nodes = new HashSet<PhylogenyNode>();
11994 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
11995 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
11996 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
11997 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
11998 if ( !s0.match( query_nodes ) ) {
12002 query_nodes = new HashSet<PhylogenyNode>();
12003 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12004 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12005 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12006 if ( !s0.match( query_nodes ) ) {
12010 query_nodes = new HashSet<PhylogenyNode>();
12011 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12012 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12013 if ( !s0.match( query_nodes ) ) {
12017 query_nodes = new HashSet<PhylogenyNode>();
12018 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12019 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12020 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12021 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12022 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12023 if ( !s0.match( query_nodes ) ) {
12027 query_nodes = new HashSet<PhylogenyNode>();
12028 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12029 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12030 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12031 if ( !s0.match( query_nodes ) ) {
12035 query_nodes = new HashSet<PhylogenyNode>();
12036 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12037 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12038 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12039 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12040 if ( !s0.match( query_nodes ) ) {
12044 query_nodes = new HashSet<PhylogenyNode>();
12045 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12046 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12047 if ( s0.match( query_nodes ) ) {
12051 query_nodes = new HashSet<PhylogenyNode>();
12052 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12053 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12054 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12055 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12056 if ( s0.match( query_nodes ) ) {
12060 query_nodes = new HashSet<PhylogenyNode>();
12061 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12062 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12063 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12064 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12065 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12066 if ( s0.match( query_nodes ) ) {
12070 query_nodes = new HashSet<PhylogenyNode>();
12071 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12072 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12073 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12074 if ( s0.match( query_nodes ) ) {
12078 query_nodes = new HashSet<PhylogenyNode>();
12079 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12080 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12081 if ( s0.match( query_nodes ) ) {
12085 query_nodes = new HashSet<PhylogenyNode>();
12086 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12087 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12088 if ( s0.match( query_nodes ) ) {
12092 query_nodes = new HashSet<PhylogenyNode>();
12093 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12094 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "C" ) );
12095 if ( s0.match( query_nodes ) ) {
12099 query_nodes = new HashSet<PhylogenyNode>();
12100 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12101 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12102 if ( s0.match( query_nodes ) ) {
12106 query_nodes = new HashSet<PhylogenyNode>();
12107 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12108 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12109 if ( s0.match( query_nodes ) ) {
12113 query_nodes = new HashSet<PhylogenyNode>();
12114 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12115 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12116 if ( s0.match( query_nodes ) ) {
12120 query_nodes = new HashSet<PhylogenyNode>();
12121 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12122 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "F" ) );
12123 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12124 if ( s0.match( query_nodes ) ) {
12128 query_nodes = new HashSet<PhylogenyNode>();
12129 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12130 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "B" ) );
12131 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12132 if ( s0.match( query_nodes ) ) {
12136 query_nodes = new HashSet<PhylogenyNode>();
12137 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12138 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12139 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12140 if ( s0.match( query_nodes ) ) {
12144 query_nodes = new HashSet<PhylogenyNode>();
12145 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "E" ) );
12146 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "D" ) );
12147 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "A" ) );
12148 query_nodes.add( PhylogenyNode.createInstanceFromNhxString( "G" ) );
12149 if ( s0.match( query_nodes ) ) {
12153 catch ( final Exception e ) {
12154 e.printStackTrace();
12160 private static boolean testSubtreeDeletion() {
12162 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12163 final Phylogeny t1 = factory.create( "((A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12164 t1.deleteSubtree( t1.getNode( "A" ), false );
12165 if ( t1.getNumberOfExternalNodes() != 5 ) {
12168 t1.toNewHampshireX();
12169 t1.deleteSubtree( t1.getNode( "E" ), false );
12170 if ( t1.getNumberOfExternalNodes() != 4 ) {
12173 t1.toNewHampshireX();
12174 t1.deleteSubtree( t1.getNode( "F" ), false );
12175 if ( t1.getNumberOfExternalNodes() != 3 ) {
12178 t1.toNewHampshireX();
12179 t1.deleteSubtree( t1.getNode( "D" ), false );
12180 t1.toNewHampshireX();
12181 if ( t1.getNumberOfExternalNodes() != 3 ) {
12184 t1.deleteSubtree( t1.getNode( "def" ), false );
12185 t1.toNewHampshireX();
12186 if ( t1.getNumberOfExternalNodes() != 2 ) {
12189 t1.deleteSubtree( t1.getNode( "B" ), false );
12190 t1.toNewHampshireX();
12191 if ( t1.getNumberOfExternalNodes() != 1 ) {
12194 t1.deleteSubtree( t1.getNode( "C" ), false );
12195 t1.toNewHampshireX();
12196 if ( t1.getNumberOfExternalNodes() != 1 ) {
12199 t1.deleteSubtree( t1.getNode( "abc" ), false );
12200 t1.toNewHampshireX();
12201 if ( t1.getNumberOfExternalNodes() != 1 ) {
12204 t1.deleteSubtree( t1.getNode( "r" ), false );
12205 if ( t1.getNumberOfExternalNodes() != 0 ) {
12208 if ( !t1.isEmpty() ) {
12211 final Phylogeny t2 = factory.create( "(((1,2,3)A,B,C)abc,(D,E,F)def)r", new NHXParser() )[ 0 ];
12212 t2.deleteSubtree( t2.getNode( "A" ), false );
12213 t2.toNewHampshireX();
12214 if ( t2.getNumberOfExternalNodes() != 5 ) {
12217 t2.deleteSubtree( t2.getNode( "abc" ), false );
12218 t2.toNewHampshireX();
12219 if ( t2.getNumberOfExternalNodes() != 3 ) {
12222 t2.deleteSubtree( t2.getNode( "def" ), false );
12223 t2.toNewHampshireX();
12224 if ( t2.getNumberOfExternalNodes() != 1 ) {
12228 catch ( final Exception e ) {
12229 e.printStackTrace( System.out );
12235 private static boolean testSupportCount() {
12237 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12238 final Phylogeny t0_1 = factory.create( "(((A,B),C),(D,E))", new NHXParser() )[ 0 ];
12239 final Phylogeny[] phylogenies_1 = factory.create( "(((A,B),C),(D,E)) " + "(((C,B),A),(D,E))"
12240 + "(((A,B),C),(D,E)) " + "(((A,B),C),(D,E))"
12241 + "(((A,B),C),(D,E))" + "(((C,B),A),(D,E))"
12242 + "(((E,B),D),(C,A))" + "(((C,B),A),(D,E))"
12243 + "(((A,B),C),(D,E))" + "(((A,B),C),(D,E))",
12245 SupportCount.count( t0_1, phylogenies_1, true, false );
12246 final Phylogeny t0_2 = factory.create( "(((((A,B),C),D),E),(F,G))", new NHXParser() )[ 0 ];
12247 final Phylogeny[] phylogenies_2 = factory.create( "(((((A,B),C),D),E),(F,G))"
12248 + "(((((A,B),C),D),E),((F,G),X))"
12249 + "(((((A,Y),B),C),D),((F,G),E))"
12250 + "(((((A,B),C),D),E),(F,G))"
12251 + "(((((A,B),C),D),E),(F,G))"
12252 + "(((((A,B),C),D),E),(F,G))"
12253 + "(((((A,B),C),D),E),(F,G),Z)"
12254 + "(((((A,B),C),D),E),(F,G))"
12255 + "((((((A,B),C),D),E),F),G)"
12256 + "(((((X,Y),F,G),E),((A,B),C)),D)",
12258 SupportCount.count( t0_2, phylogenies_2, true, false );
12259 final PhylogenyNodeIterator it = t0_2.iteratorPostorder();
12260 while ( it.hasNext() ) {
12261 final PhylogenyNode n = it.next();
12262 if ( !n.isExternal() && ( PhylogenyMethods.getConfidenceValue( n ) != 10 ) ) {
12266 final Phylogeny t0_3 = factory.create( "(((A,B)ab,C)abc,((D,E)de,F)def)", new NHXParser() )[ 0 ];
12267 final Phylogeny[] phylogenies_3 = factory.create( "(((A,B),C),((D,E),F))" + "(((A,C),B),((D,F),E))"
12268 + "(((C,A),B),((F,D),E))" + "(((A,B),F),((D,E),C))" + "(((((A,B),C),D),E),F)", new NHXParser() );
12269 SupportCount.count( t0_3, phylogenies_3, true, false );
12270 t0_3.reRoot( t0_3.getNode( "def" ).getId() );
12271 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "ab" ) ) != 3 ) {
12274 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "abc" ) ) != 4 ) {
12277 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "def" ) ) != 4 ) {
12280 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "de" ) ) != 2 ) {
12283 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "A" ) ) != 5 ) {
12286 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "B" ) ) != 5 ) {
12289 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "C" ) ) != 5 ) {
12292 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "D" ) ) != 5 ) {
12295 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "E" ) ) != 5 ) {
12298 if ( PhylogenyMethods.getConfidenceValue( t0_3.getNode( "F" ) ) != 5 ) {
12301 final Phylogeny t0_4 = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12302 final Phylogeny[] phylogenies_4 = factory.create( "((((((A,X),C),B),D),E),F) "
12303 + "(((A,B,Z),C,Q),(((D,Y),E),F))", new NHXParser() );
12304 SupportCount.count( t0_4, phylogenies_4, true, false );
12305 t0_4.reRoot( t0_4.getNode( "F" ).getId() );
12306 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "1" ) ) != 1 ) {
12309 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "2" ) ) != 2 ) {
12312 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "3" ) ) != 1 ) {
12315 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "4" ) ) != 2 ) {
12318 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "A" ) ) != 2 ) {
12321 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "B" ) ) != 2 ) {
12324 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "C" ) ) != 2 ) {
12327 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "D" ) ) != 2 ) {
12330 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "E" ) ) != 2 ) {
12333 if ( PhylogenyMethods.getConfidenceValue( t0_4.getNode( "F" ) ) != 2 ) {
12336 Phylogeny a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12337 final Phylogeny b1 = factory.create( "(((((B,A)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12338 double d = SupportCount.compare( b1, a, true, true, true );
12339 if ( !Test.isEqual( d, 5.0 / 5.0 ) ) {
12342 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12343 final Phylogeny b2 = factory.create( "(((((C,B)1,A)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12344 d = SupportCount.compare( b2, a, true, true, true );
12345 if ( !Test.isEqual( d, 4.0 / 5.0 ) ) {
12348 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)", new NHXParser() )[ 0 ];
12349 final Phylogeny b3 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)", new NHXParser() )[ 0 ];
12350 d = SupportCount.compare( b3, a, true, true, true );
12351 if ( !Test.isEqual( d, 2.0 / 5.0 ) ) {
12354 a = factory.create( "(((((A,B)1,C)2,D)3,E)4,F)r", new NHXParser() )[ 0 ];
12355 final Phylogeny b4 = factory.create( "(((((F,C)1,A)2,B)3,D)4,E)r", new NHXParser() )[ 0 ];
12356 d = SupportCount.compare( b4, a, true, true, false );
12357 if ( !Test.isEqual( d, 1.0 / 5.0 ) ) {
12361 catch ( final Exception e ) {
12362 e.printStackTrace( System.out );
12368 private static boolean testSupportTransfer() {
12370 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12371 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)",
12372 new NHXParser() )[ 0 ];
12373 final Phylogeny p2 = factory
12374 .create( "(((A:0.1,B:0.3)ab:0.4,C)abc:0.5,((D,E)de,(F,G)fg,(H,I)hi:0.59)defghi)", new NHXParser() )[ 0 ];
12375 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) >= 0.0 ) {
12378 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) >= 0.0 ) {
12381 support_transfer.moveBranchLengthsToBootstrap( p1 );
12382 support_transfer.transferSupportValues( p1, p2 );
12383 if ( p2.getNode( "ab" ).getDistanceToParent() != 0.4 ) {
12386 if ( p2.getNode( "abc" ).getDistanceToParent() != 0.5 ) {
12389 if ( p2.getNode( "hi" ).getDistanceToParent() != 0.59 ) {
12392 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "ab" ) ) != 97 ) {
12395 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "abc" ) ) != 57 ) {
12398 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "de" ) ) != 10 ) {
12401 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "fg" ) ) != 50 ) {
12404 if ( PhylogenyMethods.getConfidenceValue( p2.getNode( "hi" ) ) != 64 ) {
12408 catch ( final Exception e ) {
12409 e.printStackTrace( System.out );
12415 private static boolean testTaxonomyExtraction() {
12417 final PhylogenyNode n0 = PhylogenyNode
12418 .createInstanceFromNhxString( "sd_12345678", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12419 if ( n0.getNodeData().isHasTaxonomy() ) {
12422 final PhylogenyNode n1 = PhylogenyNode
12423 .createInstanceFromNhxString( "sd_12345x", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12424 if ( n1.getNodeData().isHasTaxonomy() ) {
12425 System.out.println( n1.toString() );
12428 final PhylogenyNode n2x = PhylogenyNode
12429 .createInstanceFromNhxString( "12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12430 if ( n2x.getNodeData().isHasTaxonomy() ) {
12433 final PhylogenyNode n3 = PhylogenyNode
12434 .createInstanceFromNhxString( "BLAG_12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12435 if ( !n3.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12436 System.out.println( n3.toString() );
12439 final PhylogenyNode n4 = PhylogenyNode
12440 .createInstanceFromNhxString( "blag-12345", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12441 if ( n4.getNodeData().isHasTaxonomy() ) {
12442 System.out.println( n4.toString() );
12445 final PhylogenyNode n5 = PhylogenyNode
12446 .createInstanceFromNhxString( "12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12447 if ( n5.getNodeData().isHasTaxonomy() ) {
12448 System.out.println( n5.toString() );
12451 final PhylogenyNode n6 = PhylogenyNode
12452 .createInstanceFromNhxString( "BLAG-12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12453 if ( n6.getNodeData().isHasTaxonomy() ) {
12454 System.out.println( n6.toString() );
12457 final PhylogenyNode n7 = PhylogenyNode
12458 .createInstanceFromNhxString( "BLAG-12345_blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12459 if ( n7.getNodeData().isHasTaxonomy() ) {
12460 System.out.println( n7.toString() );
12463 final PhylogenyNode n8 = PhylogenyNode
12464 .createInstanceFromNhxString( "BLAG_12345-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12465 if ( !n8.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12466 System.out.println( n8.toString() );
12469 final PhylogenyNode n9 = PhylogenyNode
12470 .createInstanceFromNhxString( "BLAG_12345/blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12471 if ( !n9.getNodeData().getTaxonomy().getIdentifier().getValue().equals( "12345" ) ) {
12472 System.out.println( n9.toString() );
12475 final PhylogenyNode n10x = PhylogenyNode
12476 .createInstanceFromNhxString( "BLAG_12X45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12477 if ( n10x.getNodeData().isHasTaxonomy() ) {
12478 System.out.println( n10x.toString() );
12481 final PhylogenyNode n10xx = PhylogenyNode
12482 .createInstanceFromNhxString( "BLAG_1YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12483 if ( n10xx.getNodeData().isHasTaxonomy() ) {
12484 System.out.println( n10xx.toString() );
12487 final PhylogenyNode n10 = PhylogenyNode
12488 .createInstanceFromNhxString( "BLAG_9YX45-blag", NHXParser.TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
12489 if ( !n10.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9YX45" ) ) {
12490 System.out.println( n10.toString() );
12493 final PhylogenyNode n11 = PhylogenyNode
12494 .createInstanceFromNhxString( "BLAG_Mus_musculus", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12495 if ( !n11.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12496 System.out.println( n11.toString() );
12499 final PhylogenyNode n12 = PhylogenyNode
12500 .createInstanceFromNhxString( "BLAG_Mus_musculus_musculus",
12501 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12502 if ( !n12.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12503 System.out.println( n12.toString() );
12506 final PhylogenyNode n13 = PhylogenyNode
12507 .createInstanceFromNhxString( "BLAG_Mus_musculus1", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12508 if ( n13.getNodeData().isHasTaxonomy() ) {
12509 System.out.println( n13.toString() );
12512 final PhylogenyNode n14 = PhylogenyNode
12513 .createInstanceFromNhxString( "Mus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12514 if ( !n14.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12515 System.out.println( n14.toString() );
12518 final PhylogenyNode n15 = PhylogenyNode
12519 .createInstanceFromNhxString( "Mus_musculus_K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12520 if ( !n15.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12521 System.out.println( n15.toString() );
12524 final PhylogenyNode n16 = PhylogenyNode
12525 .createInstanceFromNhxString( "Mus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12526 if ( !n16.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12527 System.out.println( n16.toString() );
12530 final PhylogenyNode n17 = PhylogenyNode
12531 .createInstanceFromNhxString( "Mus musculus K392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12532 if ( !n17.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus" ) ) {
12533 System.out.println( n17.toString() );
12537 final PhylogenyNode n18 = PhylogenyNode
12538 .createInstanceFromNhxString( "Mus_musculus_musculus_392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12539 if ( !n18.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12540 System.out.println( n18.toString() );
12543 final PhylogenyNode n19 = PhylogenyNode
12544 .createInstanceFromNhxString( "Mus_musculus_musculus_K392",
12545 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12546 if ( !n19.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12547 System.out.println( n19.toString() );
12550 final PhylogenyNode n20 = PhylogenyNode
12551 .createInstanceFromNhxString( "Mus musculus musculus 392", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12552 if ( !n20.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12553 System.out.println( n20.toString() );
12556 final PhylogenyNode n21 = PhylogenyNode
12557 .createInstanceFromNhxString( "Mus musculus musculus K392",
12558 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12559 if ( !n21.getNodeData().getTaxonomy().getScientificName().equals( "Mus musculus musculus" ) ) {
12560 System.out.println( n21.toString() );
12563 final PhylogenyNode n22 = PhylogenyNode
12564 .createInstanceFromNhxString( "NEMVE_Nematostella_vectensis",
12565 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12566 if ( !n22.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12567 System.out.println( n22.toString() );
12570 final PhylogenyNode n23 = PhylogenyNode
12571 .createInstanceFromNhxString( "9EMVE_Nematostella_vectensis",
12572 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12573 if ( !n23.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12574 System.out.println( n23.toString() );
12577 final PhylogenyNode n24 = PhylogenyNode
12578 .createInstanceFromNhxString( "9EMVE_Nematostella", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12579 if ( !n24.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12580 System.out.println( n24.toString() );
12584 final PhylogenyNode n25 = PhylogenyNode
12585 .createInstanceFromNhxString( "Nematostella_vectensis_NEMVE",
12586 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12587 if ( !n25.getNodeData().getTaxonomy().getTaxonomyCode().equals( "NEMVE" ) ) {
12588 System.out.println( n25.toString() );
12591 final PhylogenyNode n26 = PhylogenyNode
12592 .createInstanceFromNhxString( "Nematostella_vectensis_9EMVE",
12593 NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12594 if ( !n26.getNodeData().getTaxonomy().getScientificName().equals( "Nematostella vectensis" ) ) {
12595 System.out.println( n26.toString() );
12598 final PhylogenyNode n27 = PhylogenyNode
12599 .createInstanceFromNhxString( "Nematostella_9EMVE", NHXParser.TAXONOMY_EXTRACTION.AGGRESSIVE );
12600 if ( !n27.getNodeData().getTaxonomy().getTaxonomyCode().equals( "9EMVE" ) ) {
12601 System.out.println( n27.toString() );
12605 catch ( final Exception e ) {
12606 e.printStackTrace( System.out );
12612 private static boolean testTreeCopy() {
12614 final String str_0 = "((((a,b),c),d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=animals]";
12615 final Phylogeny t0 = Phylogeny.createInstanceFromNhxString( str_0 );
12616 final Phylogeny t1 = t0.copy();
12617 if ( !t1.toNewHampshireX().equals( t0.toNewHampshireX() ) ) {
12620 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12623 t0.deleteSubtree( t0.getNode( "c" ), true );
12624 t0.deleteSubtree( t0.getNode( "a" ), true );
12625 t0.getRoot().getNodeData().getTaxonomy().setScientificName( "metazoa" );
12626 t0.getNode( "b" ).setName( "Bee" );
12627 if ( !t0.toNewHampshireX().equals( "((Bee,d)[&&NHX:S=lizards],e[&&NHX:S=reptiles])r[&&NHX:S=metazoa]" ) ) {
12630 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12633 t0.deleteSubtree( t0.getNode( "e" ), true );
12634 t0.deleteSubtree( t0.getNode( "Bee" ), true );
12635 t0.deleteSubtree( t0.getNode( "d" ), true );
12636 if ( !t1.toNewHampshireX().equals( str_0 ) ) {
12640 catch ( final Exception e ) {
12641 e.printStackTrace();
12647 private static boolean testTreeMethods() {
12649 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
12650 final Phylogeny t0 = factory.create( "((((A,B)ab,C)abc,D)abcd,E)", new NHXParser() )[ 0 ];
12651 PhylogenyMethods.collapseSubtreeStructure( t0.getNode( "abcd" ) );
12652 if ( !t0.toNewHampshireX().equals( "((A,B,C,D)abcd,E)" ) ) {
12653 System.out.println( t0.toNewHampshireX() );
12656 final Phylogeny t1 = factory.create( "((((A:0.1,B)ab:0.2,C)abc:0.3,D)abcd:0.4,E)", new NHXParser() )[ 0 ];
12657 PhylogenyMethods.collapseSubtreeStructure( t1.getNode( "abcd" ) );
12658 if ( !isEqual( t1.getNode( "A" ).getDistanceToParent(), 0.6 ) ) {
12661 if ( !isEqual( t1.getNode( "B" ).getDistanceToParent(), 0.5 ) ) {
12664 if ( !isEqual( t1.getNode( "C" ).getDistanceToParent(), 0.3 ) ) {
12668 catch ( final Exception e ) {
12669 e.printStackTrace( System.out );
12675 private static boolean testUniprotEntryRetrieval() {
12677 final SequenceDatabaseEntry entry = SequenceDbWsTools.obtainUniProtEntry( "P12345", 200 );
12678 if ( !entry.getAccession().equals( "P12345" ) ) {
12681 if ( !entry.getTaxonomyScientificName().equals( "Oryctolagus cuniculus" ) ) {
12684 if ( !entry.getSequenceName().equals( "Aspartate aminotransferase, mitochondrial" ) ) {
12687 if ( !entry.getSequenceSymbol().equals( "mAspAT" ) ) {
12690 if ( !entry.getGeneName().equals( "GOT2" ) ) {
12693 if ( !entry.getTaxonomyIdentifier().equals( "9986" ) ) {
12697 catch ( final IOException e ) {
12698 System.out.println();
12699 System.out.println( "the following might be due to absence internet connection:" );
12700 e.printStackTrace( System.out );
12703 catch ( final Exception e ) {
12709 private static boolean testUniprotTaxonomySearch() {
12711 List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
12713 if ( results.size() != 1 ) {
12716 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12719 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12722 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12725 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12728 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12732 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Nematostella vectensis", 10 );
12733 if ( results.size() != 1 ) {
12736 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12739 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12742 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12745 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12748 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12752 results = SequenceDbWsTools.getTaxonomiesFromId( "45351", 10 );
12753 if ( results.size() != 1 ) {
12756 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12759 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12762 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12765 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12768 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12772 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "NEMVE", 10 );
12773 if ( results.size() != 1 ) {
12776 if ( !results.get( 0 ).getCode().equals( "NEMVE" ) ) {
12779 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "starlet sea anemone" ) ) {
12782 if ( !results.get( 0 ).getId().equalsIgnoreCase( "45351" ) ) {
12785 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12788 if ( !results.get( 0 ).getScientificName().equals( "Nematostella vectensis" ) ) {
12791 if ( !results.get( 0 ).getLineage().get( 1 ).equals( "Eukaryota" ) ) {
12794 if ( !results.get( 0 ).getLineage().get( 2 ).equals( "Metazoa" ) ) {
12797 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12798 .equals( "Nematostella vectensis" ) ) {
12799 System.out.println( results.get( 0 ).getLineage() );
12804 results = SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( "Xenopus tropicalis", 10 );
12805 if ( results.size() != 1 ) {
12808 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12811 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12814 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12817 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12820 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12823 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12824 .equals( "Xenopus tropicalis" ) ) {
12825 System.out.println( results.get( 0 ).getLineage() );
12830 results = SequenceDbWsTools.getTaxonomiesFromId( "8364", 10 );
12831 if ( results.size() != 1 ) {
12834 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12837 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12840 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12843 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12846 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12849 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12850 .equals( "Xenopus tropicalis" ) ) {
12851 System.out.println( results.get( 0 ).getLineage() );
12856 results = SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( "XENTR", 10 );
12857 if ( results.size() != 1 ) {
12860 if ( !results.get( 0 ).getCode().equals( "XENTR" ) ) {
12863 if ( !results.get( 0 ).getCommonName().equalsIgnoreCase( "Western clawed frog" ) ) {
12866 if ( !results.get( 0 ).getId().equalsIgnoreCase( "8364" ) ) {
12869 if ( !results.get( 0 ).getRank().equalsIgnoreCase( "species" ) ) {
12872 if ( !results.get( 0 ).getScientificName().equals( "Xenopus tropicalis" ) ) {
12875 if ( !results.get( 0 ).getLineage().get( results.get( 0 ).getLineage().size() - 1 )
12876 .equals( "Xenopus tropicalis" ) ) {
12877 System.out.println( results.get( 0 ).getLineage() );
12881 catch ( final IOException e ) {
12882 System.out.println();
12883 System.out.println( "the following might be due to absence internet connection:" );
12884 e.printStackTrace( System.out );
12887 catch ( final Exception e ) {
12893 private static boolean testWabiTxSearch() {
12895 String result = "";
12896 result = TxSearch.searchSimple( "nematostella" );
12897 result = TxSearch.getTxId( "nematostella" );
12898 if ( !result.equals( "45350" ) ) {
12901 result = TxSearch.getTxName( "45350" );
12902 if ( !result.equals( "Nematostella" ) ) {
12905 result = TxSearch.getTxId( "nematostella vectensis" );
12906 if ( !result.equals( "45351" ) ) {
12909 result = TxSearch.getTxName( "45351" );
12910 if ( !result.equals( "Nematostella vectensis" ) ) {
12913 result = TxSearch.getTxId( "Bacillus subtilis subsp. subtilis str. N170" );
12914 if ( !result.equals( "536089" ) ) {
12917 result = TxSearch.getTxName( "536089" );
12918 if ( !result.equals( "Bacillus subtilis subsp. subtilis str. N170" ) ) {
12921 final List<String> queries = new ArrayList<String>();
12922 queries.add( "Campylobacter coli" );
12923 queries.add( "Escherichia coli" );
12924 queries.add( "Arabidopsis" );
12925 queries.add( "Trichoplax" );
12926 queries.add( "Samanea saman" );
12927 queries.add( "Kluyveromyces marxianus" );
12928 queries.add( "Bacillus subtilis subsp. subtilis str. N170" );
12929 queries.add( "Bornavirus parrot/PDD/2008" );
12930 final List<RANKS> ranks = new ArrayList<RANKS>();
12931 ranks.add( RANKS.SUPERKINGDOM );
12932 ranks.add( RANKS.KINGDOM );
12933 ranks.add( RANKS.FAMILY );
12934 ranks.add( RANKS.GENUS );
12935 ranks.add( RANKS.TRIBE );
12936 result = TxSearch.searchLineage( queries, ranks );
12937 result = TxSearch.searchParam( "Homo sapiens", TAX_NAME_CLASS.ALL, TAX_RANK.SPECIES, 10, true );
12938 result = TxSearch.searchParam( "Samanea saman", TAX_NAME_CLASS.SCIENTIFIC_NAME, TAX_RANK.ALL, 10, true );
12940 catch ( final Exception e ) {
12941 System.out.println();
12942 System.out.println( "the following might be due to absence internet connection:" );
12943 e.printStackTrace( System.out );